moved to MeekroDB and also saving image directly to DB

This commit is contained in:
2020-08-30 15:40:33 -04:00
parent ca46e463fb
commit 267c513f43
3 changed files with 78 additions and 62 deletions

View File

@@ -1,10 +1,10 @@
<?php
include_once "dbconf.php";
include_once "class.php";
$ps4 = new ps4();
$sql = "SELECT * FROM game_time";
$result = $ps4->mysql_conn($sql);
$results = DB::query($sql);
$rootpage = $_GET['rootpage'];
$orderby = isset($_GET['orderby']) ? $_GET['orderby'] : "lastplayed_desc";
@@ -59,16 +59,19 @@ $details = isset($_GET['details']) ? $_GET['details'] : "";
</div>
</div>
<?php if ($result->num_rows > 0) {
<?php if (DB::count() > 0) {
// output data of each row
while ($row = $result->fetch_assoc()) {
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_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"]);
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"];
}
@@ -76,10 +79,13 @@ $details = isset($_GET['details']) ? $_GET['details'] : "";
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;
$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;
$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
@@ -96,8 +102,16 @@ $details = isset($_GET['details']) ? $_GET['details'] : "";
foreach ($games as $key => $value) {
echo "<div class=\"game\">";
echo "<div class=\"thumbnail\">";
echo "<img src=\"" .
$ps4->thumbnailurl($games[$key]["game_id"]) .
$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"] .
"', '" .
@@ -109,6 +123,9 @@ $details = isset($_GET['details']) ? $_GET['details'] : "";
"', '" .
$details .
"');\">";
echo $thumbnailurlfinal;
echo "</div>";
echo "<div class=\"info\">";
echo "<strong>" . $games[$key]["game_name"] . "</strong>";
@@ -121,7 +138,9 @@ $details = isset($_GET['details']) ? $_GET['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 "\">" .
$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>";