174 lines
5.6 KiB
PHP
174 lines
5.6 KiB
PHP
<?php
|
|
include_once "dbconf.php";
|
|
include_once "class.php";
|
|
$ps4 = new ps4();
|
|
|
|
$sql = "SELECT * FROM game_time";
|
|
$results = DB::query($sql);
|
|
|
|
$rootpage = $_GET['rootpage'];
|
|
$orderby = isset($_GET['orderby']) ? $_GET['orderby'] : "lastplayed_desc";
|
|
$details = isset($_GET['details']) ? $_GET['details'] : "";
|
|
?>
|
|
|
|
<div class="refresh center500">
|
|
<strong>Last refresh : </strong> <?php echo date(DATE_RFC2822); ?>
|
|
</div>
|
|
|
|
<div class="center500 padding-bottom-3">
|
|
<div class="orderby">
|
|
<a href="<?php echo $rootpage; ?>?orderby=totaltime_asc"><i class="material-icons md-arrow <?php if (
|
|
$orderby == "totaltime_asc"
|
|
) {
|
|
echo "md-active";
|
|
} ?> vertical-align-middle padding-bottom-3">arrow_drop_up</i></a>
|
|
Total Time
|
|
<a href="<?php echo $rootpage; ?>?orderby=totaltime_desc"><i class="material-icons md-arrow <?php if (
|
|
$orderby == "totaltime_desc"
|
|
) {
|
|
echo "md-active";
|
|
} ?> vertical-align-middle padding-bottom-3">arrow_drop_down</i></a>
|
|
</div>
|
|
|
|
<div class="orderby">
|
|
<a href="<?php echo $rootpage; ?>?orderby=firstplayed_asc"><i class="material-icons md-arrow <?php if (
|
|
$orderby == "firstplayed_asc"
|
|
) {
|
|
echo "md-active";
|
|
} ?> vertical-align-middle padding-bottom-3">arrow_drop_up</i></a>
|
|
First Played
|
|
<a href="<?php echo $rootpage; ?>?orderby=firstplayed_desc"><i class="material-icons md-arrow <?php if (
|
|
$orderby == "firstplayed_desc"
|
|
) {
|
|
echo "md-active";
|
|
} ?> vertical-align-middle padding-bottom-3">arrow_drop_down</i></a>
|
|
</div>
|
|
|
|
<div class="orderby">
|
|
<a href="<?php echo $rootpage; ?>?orderby=lastplayed_asc"><i class="material-icons md-arrow <?php if (
|
|
$orderby == "lastplayed_asc"
|
|
) {
|
|
echo "md-active";
|
|
} ?> vertical-align-middle padding-bottom-3">arrow_drop_up</i></a>
|
|
Last Played
|
|
<a href="<?php echo $rootpage; ?>?orderby=lastplayed_desc"><i class="material-icons md-arrow vertical-align-middle padding-bottom-3 <?php if (
|
|
$orderby == "lastplayed_desc"
|
|
) {
|
|
echo "md-active";
|
|
} ?>">arrow_drop_down</i></a>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if (DB::count() > 0) {
|
|
// output data of each row
|
|
|
|
foreach ($results as $row) {
|
|
$games[$row["game_id"]]["game_id"] = $row["game_id"];
|
|
$games[$row["game_id"]]["game_name"] = $row["game_name"];
|
|
isset($games[$row["game_id"]]["game_total_time"]) ?:
|
|
($games[$row["game_id"]]["game_total_time"] = 0);
|
|
|
|
isset($games[$row["game_id"]]["game_played_first"]) ?:
|
|
($games[$row["game_id"]]["game_played_first"] = $row["game_start"]);
|
|
isset($games[$row["game_id"]]["game_played_last"]) ?:
|
|
($games[$row["game_id"]]["game_played_last"] = $row["game_end"]);
|
|
if ($row["game_start"] < $games[$row["game_id"]]["game_played_first"]) {
|
|
$games[$row["game_id"]]["game_played_first"] = $row["game_start"];
|
|
}
|
|
|
|
if ($row["game_end"] == "") {
|
|
$games[$row["game_id"]]["game_time"][$row["id"]] = -1;
|
|
$games[$row["game_id"]]["game_played_last"] = -1;
|
|
$games[$row["game_id"]]["game_total_time"] +=
|
|
(round(microtime(true) * 1000) - $row["game_start"]) / 1000;
|
|
} else {
|
|
$games[$row["game_id"]]["game_time"][$row["id"]] =
|
|
($row["game_end"] - $row["game_start"]) / 1000;
|
|
$games[$row["game_id"]]["game_total_time"] +=
|
|
($row["game_end"] - $row["game_start"]) / 1000;
|
|
if (
|
|
$row["game_end"] > $games[$row["game_id"]]["game_played_last"] and
|
|
$games[$row["game_id"]]["game_played_last"] != -1
|
|
) {
|
|
$games[$row["game_id"]]["game_played_last"] = $row["game_end"];
|
|
}
|
|
}
|
|
}
|
|
|
|
// reorder
|
|
sort($games);
|
|
$games = $ps4->games_reorder($games, $orderby);
|
|
|
|
foreach ($games as $key => $value) {
|
|
echo "<div class=\"game\">";
|
|
echo "<div class=\"thumbnail\">";
|
|
$thumbnailurl = $ps4->thumbnailurl($games[$key]["game_id"]);
|
|
if ($thumbnailurl == "images/no-thumbnail.png") {
|
|
$thumbnailsrc = $thumbnailurl;
|
|
} else {
|
|
$thumbnailsrc = 'data:image/jpeg;base64,' . base64_encode($thumbnailurl);
|
|
}
|
|
|
|
$thumbnailurlfinal =
|
|
"<img src=\"" .
|
|
$thumbnailsrc .
|
|
"\" border=0 weight=\"80px\" height=\"80px\" onclick=\"thumbnailupdateurl('" .
|
|
$games[$key]["game_id"] .
|
|
"', '" .
|
|
str_replace("'", "", $games[$key]["game_name"]) .
|
|
"', '" .
|
|
$rootpage .
|
|
"', '" .
|
|
$orderby .
|
|
"', '" .
|
|
$details .
|
|
"');\">";
|
|
|
|
echo $thumbnailurlfinal;
|
|
|
|
echo "</div>";
|
|
echo "<div class=\"info\">";
|
|
echo "<strong>" . $games[$key]["game_name"] . "</strong>";
|
|
echo "<br/>";
|
|
echo "<div class=\"gameinfoline\"><div class=\"gameinfohead\">Total Time Played</div><div class=\"gameinfoseparator\"></div><div class=\"gameinfodetails\"><a href=\"" .
|
|
$rootpage .
|
|
"?orderby=" .
|
|
$orderby .
|
|
"&details=";
|
|
if ($details != $games[$key]["game_id"]) {
|
|
echo $games[$key]["game_id"];
|
|
}
|
|
echo "\">" .
|
|
$ps4->playtime($games[$key]["game_total_time"], true) .
|
|
"</a></div></div>";
|
|
echo "<div class=\"gameinfoline\"><div class=\"gameinfohead\">First Played</div><div class=\"gameinfoseparator\"></div><div class=\"gameinfodetails\">" .
|
|
$ps4->secondsToDate($games[$key]["game_played_first"]) .
|
|
"</div></div>";
|
|
echo "<div class=\"gameinfoline\"><div class=\"gameinfohead\">Last Played</div><div class=\"gameinfoseparator\"></div><div class=\"gameinfodetails\">";
|
|
|
|
if ($games[$key]["game_played_last"] == -1) {
|
|
echo "<strong>now playing</strong>";
|
|
} else {
|
|
echo $ps4->secondsToDate($games[$key]["game_played_last"]);
|
|
}
|
|
echo "</div></div>";
|
|
|
|
echo "</div>"; // info
|
|
|
|
if ($details == $games[$key]["game_id"]) {
|
|
$ps4->gameTimeDetails($games[$key]["game_id"]);
|
|
}
|
|
|
|
echo "</div>"; // game
|
|
}
|
|
|
|
/*
|
|
echo "<pre>";
|
|
print_r($games);
|
|
echo "</pre>";
|
|
*/
|
|
} else {
|
|
echo "0 results";
|
|
} ?>
|
|
|