Prettier Formatting

This commit is contained in:
2019-09-12 17:15:11 -04:00
parent 37f97054e4
commit 7d72c7c593
6 changed files with 451 additions and 387 deletions

394
class.php
View File

@@ -1,206 +1,242 @@
<?php <?php
class ps4 { class ps4
{
public function dbconf()
{
global $dbconf;
$dbconf = require "dbconf.php";
return $dbconf;
}
public function dbconf() { function mysql_conn($sql = null)
global $dbconf; {
$dbconf = require "dbconf.php"; $db = $this->dbconf();
return $dbconf;
// Create connection
$conn = new mysqli($db["servername"], $db["username"], $db["password"], $db["dbname"]);
$conn->set_charset("utf8");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} }
function mysql_conn($sql=null) { if ($sql == null) {
echo "Error: No SQL Request?";
$conn->close();
return null;
} else {
$return = $conn->query($sql);
$conn->close();
return $return;
}
}
$db = $this->dbconf(); function gameTimeDetails($gameid)
{
$result = $this->mysql_conn("SELECT * FROM game_time WHERE game_id = '" . $gameid . "' ORDER BY game_start DESC;");
if ($result->num_rows > 0) {
$i = 0;
echo '<div class="PlaytimeDetails FontSmaller">';
echo '<div class="row"><div class="head PlaytimeStart">Start</div><div class="head PlaytimeEnd">End</div><div class="head PlaytimeTotal">Time Played</div></div>';
while ($row = $result->fetch_assoc()) {
echo '<div class="row">';
$i++;
echo '<div class="PlaytimeStart">' . $this->secondsToDate($row["game_start"]) . '</div>';
// Create connection echo '<div class="PlaytimeEnd">';
$conn = new mysqli($db["servername"], $db["username"], $db["password"], $db["dbname"]); if ($row["game_end"] == "") {
$conn->set_charset("utf8"); echo "<strong>now playing</strong>";
// Check connection } else {
if ($conn->connect_error) { echo $this->secondsToDate($row["game_end"]);
die("Connection failed: " . $conn->connect_error); }
} echo '</div>';
if ($sql == null) { echo '<div class="PlaytimeTotal">';
echo "Error: No SQL Request?"; if ($row["game_end"] == "") {
$conn->close(); echo $this->playtime((round(microtime(true) * 1000) - $row["game_start"]) / 1000, true);
return null; } else {
} else { echo $this->playtime(($row["game_end"] - $row["game_start"]) / 1000, true);
$return = $conn->query($sql); }
$conn->close(); echo '</div>';
return $return;
}
}
function gameTimeDetails($gameid) { echo '</div>';
$result = $this->mysql_conn("SELECT * FROM game_time WHERE game_id = '". $gameid ."' ORDER BY game_start DESC;"); }
if ($result->num_rows > 0) { echo '<div class="row"><div class="head PlaytimeStart"></div><div class="head PlaytimeEnd"></div><div class="head PlaytimeTotal">' .
$i=0; $i .
echo '<div class="PlaytimeDetails FontSmaller">'; ' sessions</div></div>';
echo '<div class="row"><div class="head PlaytimeStart">Start</div><div class="head PlaytimeEnd">End</div><div class="head PlaytimeTotal">Time Played</div></div>'; echo '</div>';
while ($row = $result->fetch_assoc()) { echo '<div class="padding-bottom-10"></div>';
echo '<div class="row">'; }
$i++; }
echo '<div class="PlaytimeStart">'. $this->secondsToDate($row["game_start"]) .'</div>';
echo '<div class="PlaytimeEnd">'; function playtime($seconds, $text = false)
if ($row["game_end"] == "") { {
echo "<strong>now playing</strong>"; $playtime = null;
} else { $label = null;
echo $this->secondsToDate($row["game_end"]);
}
echo '</div>';
echo '<div class="PlaytimeTotal">'; if ($seconds < 60) {
if ($row["game_end"] == "") { if ($text == true) {
echo $this->playtime(((round(microtime(true) * 1000)-$row["game_start"])/1000),true); $label = "second";
} else { }
echo $this->playtime((($row["game_end"]-$row["game_start"])/1000),true); if ($seconds > 1) {
} $label .= "s";
echo '</div>'; }
$playtime = $seconds;
} elseif ($seconds / 60 < 60) {
if ($text == true) {
$label = "minute";
}
if ($seconds / 60 > 1) {
$label .= "s";
}
$playtime = round($seconds / 60, 2);
} else {
if ($text == true) {
$label = "hour";
}
if ($seconds / 60 / 60 > 1) {
$label .= "s";
}
$playtime = round($seconds / 60 / 60, 2);
}
echo '</div>'; $return = $playtime;
} if ($text == true) {
echo '<div class="row"><div class="head PlaytimeStart"></div><div class="head PlaytimeEnd"></div><div class="head PlaytimeTotal">'. $i .' sessions</div></div>'; $return = $return . " " . $label;
echo '</div>'; }
echo '<div class="padding-bottom-10"></div>'; return $return;
} }
}
function playtime($seconds, $text=false) { function secondsToDate($seconds)
$playtime = null; {
$label = null; return date("d M Y H:i:s", $seconds / 1000);
}
if ($seconds < 60) { function thumbnailurl($game_id)
if ($text == true) { {
$label = "second"; $result = $this->mysql_conn("SELECT thumbnail_url FROM game_thumbnail WHERE game_id = '" . $game_id . "' limit 1;");
} if ($result->num_rows > 0) {
if ($seconds > 1) { $label .= "s"; } while ($row = $result->fetch_assoc()) {
$playtime = $seconds; $url = $row["thumbnail_url"];
} else }
if ($seconds/60 < 60) { } else {
if ($text == true) { $url = "images/no-thumbnail.png";
$label = "minute"; }
} return $url;
if ($seconds/60 > 1) { $label .= "s"; } }
$playtime = round($seconds/60,2);
} else {
if ($text == true) {
$label = "hour";
}
if ($seconds/60/60 > 1) { $label .= "s"; }
$playtime = round($seconds/60/60,2);
}
$return = $playtime; function thumbnailupdateurl($gameid, $gamename, $url)
if ($text == true) { $return = $return ." ". $label; } {
return $return; $actualurl = $this->thumbnailurl($gameid);
} if ($actualurl == "images/no-thumbnail.png") {
$sql = "INSERT INTO game_thumbnail (game_id, thumbnail_url) VALUES ('" . $gameid . "', '" . $url . "');";
} else {
$sql = "UPDATE game_thumbnail SET thumbnail_url = '" . $url . "' WHERE game_id = '" . $gameid . "';";
}
function secondsToDate($seconds) { if ($url == "" or $url == "null") {
return date("d M Y H:i:s", $seconds/1000); echo "<div class=\"message-error center500\"><div class=\"message-head\">ERROR</div><div class=\"message-details\">No URL specified.</div>";
} } else {
if ($this->isImage($url)) {
$result = $this->mysql_conn($sql);
if ($result == 1) {
echo "<div class=\"message-success center500\"><div class=\"message-head\">SUCCESS</div><div class=\"message-details\">Updated image URL for <strong>" .
$gamename .
"</strong> (" .
$gameid .
")</div>";
} else {
echo "<div class=\"message-error center500\"><div class=\"message-head\">ERROR</div><div class=\"message-details\">Can't update image URL for <strong>" .
$gamename .
"</strong> (" .
$gameid .
")</div>";
}
} else {
echo "<div class=\"message-error center500\"><div class=\"message-head\">ERROR</div><div class=\"message-details\">Not an image.</div>";
}
}
}
function thumbnailurl($game_id) { function isImage($url)
$result = $this->mysql_conn("SELECT thumbnail_url FROM game_thumbnail WHERE game_id = '". $game_id ."' limit 1;"); {
if ($result->num_rows > 0) { $params = array(
while ($row = $result->fetch_assoc()) { 'http' => array(
$url = $row["thumbnail_url"]; 'method' => 'HEAD'
} )
} else { );
$url = "images/no-thumbnail.png"; $ctx = stream_context_create($params);
} $fp = @fopen($url, 'rb', false, $ctx);
return $url; if (!$fp) {
} return false;
} // Problem with url
function thumbnailupdateurl($gameid,$gamename,$url) { $meta = stream_get_meta_data($fp);
$actualurl = $this->thumbnailurl($gameid); if ($meta === false) {
if ($actualurl == "images/no-thumbnail.png") { fclose($fp);
$sql = "INSERT INTO game_thumbnail (game_id, thumbnail_url) VALUES ('".$gameid."', '".$url."');"; return false; // Problem reading data from url
} else { }
$sql = "UPDATE game_thumbnail SET thumbnail_url = '".$url."' WHERE game_id = '".$gameid."';";
}
if (($url == "") or ($url == "null")) { $wrapper_data = $meta["wrapper_data"];
echo "<div class=\"message-error center500\"><div class=\"message-head\">ERROR</div><div class=\"message-details\">No URL specified.</div>"; if (is_array($wrapper_data)) {
} else { foreach (array_keys($wrapper_data) as $hh) {
if ($this->isImage($url)) { if (substr($wrapper_data[$hh], 0, 19) == "Content-Type: image") {
$result = $this->mysql_conn($sql); // strlen("Content-Type: image") == 19
if ($result == 1) { fclose($fp);
echo "<div class=\"message-success center500\"><div class=\"message-head\">SUCCESS</div><div class=\"message-details\">Updated image URL for <strong>". $gamename ."</strong> (". $gameid .")</div>"; return true;
} else { }
echo "<div class=\"message-error center500\"><div class=\"message-head\">ERROR</div><div class=\"message-details\">Can't update image URL for <strong>". $gamename ."</strong> (". $gameid .")</div>"; }
} }
} else {
echo "<div class=\"message-error center500\"><div class=\"message-head\">ERROR</div><div class=\"message-details\">Not an image.</div>";
}
}
} fclose($fp);
return false;
}
function isImage($url) function games_reorder($games, $orderby = "last_played_desc")
{ {
$params = array('http' => array( function totaltime_asc($a, $b)
'method' => 'HEAD' {
)); return $a["game_total_time"] <= $b["game_total_time"] ? -1 : 1;
$ctx = stream_context_create($params); }
$fp = @fopen($url, 'rb', false, $ctx); function totaltime_desc($a, $b)
if (!$fp) {
return false; // Problem with url return $a["game_total_time"] >= $b["game_total_time"] ? -1 : 1;
}
$meta = stream_get_meta_data($fp); function firstplayed_asc($a, $b)
if ($meta === false) {
{ return $a["game_played_first"] <= $b["game_played_first"] ? -1 : 1;
fclose($fp); }
return false; // Problem reading data from url function firstplayed_desc($a, $b)
} {
return $a["game_played_first"] >= $b["game_played_first"] ? -1 : 1;
}
$wrapper_data = $meta["wrapper_data"]; function lastplayed_asc($a, $b)
if(is_array($wrapper_data)){ {
foreach(array_keys($wrapper_data) as $hh){ if ($a["game_played_last"] == -1) {
if (substr($wrapper_data[$hh], 0, 19) == "Content-Type: image") // strlen("Content-Type: image") == 19 $a["game_played_last"] = round(microtime(true) * 1000);
{ }
fclose($fp); if ($b["game_played_last"] == -1) {
return true; $b["game_played_last"] = round(microtime(true) * 1000);
} }
} return $a["game_played_last"] <= $b["game_played_last"] ? -1 : 1;
} }
function lastplayed_desc($a, $b)
fclose($fp); {
return false; if ($a["game_played_last"] == -1) {
} $a["game_played_last"] = round(microtime(true) * 1000);
}
function games_reorder($games,$orderby="last_played_desc") { if ($b["game_played_last"] == -1) {
function totaltime_asc($a,$b) { $b["game_played_last"] = round(microtime(true) * 1000);
return ($a["game_total_time"] <= $b["game_total_time"]) ? -1 : 1; }
} return $a["game_played_last"] >= $b["game_played_last"] ? -1 : 1;
function totaltime_desc($a,$b) { }
return ($a["game_total_time"] >= $b["game_total_time"]) ? -1 : 1;
}
function firstplayed_asc($a,$b) {
return ($a["game_played_first"] <= $b["game_played_first"]) ? -1 : 1;
}
function firstplayed_desc($a,$b) {
return ($a["game_played_first"] >= $b["game_played_first"]) ? -1 : 1;
}
function lastplayed_asc($a,$b) {
if ($a["game_played_last"] == -1) { $a["game_played_last"] = (round(microtime(true) * 1000)); }
if ($b["game_played_last"] == -1) { $b["game_played_last"] = (round(microtime(true) * 1000)); }
return ($a["game_played_last"] <= $b["game_played_last"]) ? -1 : 1;
}
function lastplayed_desc($a,$b) {
if ($a["game_played_last"] == -1) { $a["game_played_last"] = (round(microtime(true) * 1000)); }
if ($b["game_played_last"] == -1) { $b["game_played_last"] = (round(microtime(true) * 1000)); }
return ($a["game_played_last"] >= $b["game_played_last"]) ? -1 : 1;
}
usort($games, $orderby);
return $games;
}
usort($games, $orderby);
return $games;
}
} }
?> ?>

View File

@@ -7,8 +7,6 @@ error_reporting(E_ALL);
$rootpage = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : "index.php"; $rootpage = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : "index.php";
$orderby = isset($_GET['orderby']) ? $_GET['orderby'] : "lastplayed_desc"; $orderby = isset($_GET['orderby']) ? $_GET['orderby'] : "lastplayed_desc";
$details = isset($_GET['details']) ? $_GET['details'] : ""; $details = isset($_GET['details']) ? $_GET['details'] : "";
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
@@ -26,7 +24,7 @@ $details = isset($_GET['details']) ? $_GET['details'] : "";
update(); update();
}); });
function update() { function update() {
$.get('page.php?rootpage=<?php echo $rootpage ?>&orderby=<?php echo $orderby ?>&details=<?php echo $details ?>', function(data) { $.get('page.php?rootpage=<?php echo $rootpage; ?>&orderby=<?php echo $orderby; ?>&details=<?php echo $details; ?>', function(data) {
$("#page").html(data); $("#page").html(data);
window.setTimeout(update, 10000); // 10 secondes window.setTimeout(update, 10000); // 10 secondes
}); });

179
page.php
View File

@@ -1,5 +1,5 @@
<?php <?php
include_once("class.php"); include_once "class.php";
$ps4 = new ps4(); $ps4 = new ps4();
@@ -9,107 +9,146 @@ $result = $ps4->mysql_conn($sql);
$rootpage = $_GET['rootpage']; $rootpage = $_GET['rootpage'];
$orderby = isset($_GET['orderby']) ? $_GET['orderby'] : "lastplayed_desc"; $orderby = isset($_GET['orderby']) ? $_GET['orderby'] : "lastplayed_desc";
$details = isset($_GET['details']) ? $_GET['details'] : ""; $details = isset($_GET['details']) ? $_GET['details'] : "";
?> ?>
<div class="refresh center500"> <div class="refresh center500">
<strong>Last refresh : </strong> <?php echo date(DATE_RFC2822) ?> <strong>Last refresh : </strong> <?php echo date(DATE_RFC2822); ?>
</div> </div>
<div class="center500 padding-bottom-3"> <div class="center500 padding-bottom-3">
<div class="orderby"> <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> <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 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> <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>
<div class="orderby"> <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> <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 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> <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>
<div class="orderby"> <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> <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 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> <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>
</div> </div>
<?php <?php if ($result->num_rows > 0) {
if ($result->num_rows > 0) { // output data of each row
// output data of each row
while ($row = $result->fetch_assoc()) { while ($row = $result->fetch_assoc()) {
$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);
$games[$row["game_id"]]["game_id"] = $row["game_id"]; isset($games[$row["game_id"]]["game_played_first"]) ?: ($games[$row["game_id"]]["game_played_first"] = $row["game_start"]);
$games[$row["game_id"]]["game_name"] = $row["game_name"]; isset($games[$row["game_id"]]["game_played_last"]) ?: ($games[$row["game_id"]]["game_played_last"] = $row["game_end"]);
isset($games[$row["game_id"]]["game_total_time"]) ?: $games[$row["game_id"]]["game_total_time"] = 0; if ($row["game_start"] < $games[$row["game_id"]]["game_played_first"]) {
$games[$row["game_id"]]["game_played_first"] = $row["game_start"];
}
isset($games[$row["game_id"]]["game_played_first"]) ?: $games[$row["game_id"]]["game_played_first"] = $row["game_start"]; if ($row["game_end"] == "") {
isset($games[$row["game_id"]]["game_played_last"]) ?: $games[$row["game_id"]]["game_played_last"] = $row["game_end"]; $games[$row["game_id"]]["game_time"][$row["id"]] = -1;
if ($row["game_start"] < $games[$row["game_id"]]["game_played_first"]) { $games[$row["game_id"]]["game_played_last"] = -1;
$games[$row["game_id"]]["game_played_first"] = $row["game_start"]; $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"];
}
}
}
if ($row["game_end"] == "") { // reorder
$games[$row["game_id"]]["game_time"][$row["id"]] = -1; sort($games);
$games[$row["game_id"]]["game_played_last"] = -1; $games = $ps4->games_reorder($games, $orderby);
$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 foreach ($games as $key => $value) {
sort($games); echo "<div class=\"game\">";
$games = $ps4->games_reorder($games, $orderby); echo "<div class=\"thumbnail\">";
echo "<img src=\"" .
$ps4->thumbnailurl($games[$key]["game_id"]) .
"\" border=0 weight=\"80px\" height=\"80px\" onclick=\"thumbnailupdateurl('" .
$games[$key]["game_id"] .
"', '" .
str_replace("'", "", $games[$key]["game_name"]) .
"', '" .
$rootpage .
"', '" .
$orderby .
"', '" .
$details .
"');\">";
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\">";
foreach ($games as $key => $value) { if ($games[$key]["game_played_last"] == -1) {
echo "<div class=\"game\">"; echo "<strong>now playing</strong>";
echo "<div class=\"thumbnail\">"; } else {
echo "<img src=\"".$ps4->thumbnailurl($games[$key]["game_id"])."\" border=0 weight=\"80px\" height=\"80px\" onclick=\"thumbnailupdateurl('". $games[$key]["game_id"] ."', '". str_replace("'", "", $games[$key]["game_name"]) ."', '". $rootpage ."', '". $orderby ."', '". $details ."');\">"; echo $ps4->secondsToDate($games[$key]["game_played_last"]);
echo "</div>"; }
echo "<div class=\"info\">"; echo "</div></div>";
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 "</div>"; // info
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"]);
}
if ($details == $games[$key]["game_id"]) { echo "</div>"; // game
$ps4->gameTimeDetails($games[$key]["game_id"]); }
}
echo "</div>"; // game /*
}
/*
echo "<pre>"; echo "<pre>";
print_r($games); print_r($games);
echo "</pre>"; echo "</pre>";
*/ */
} else { } else {
echo "0 results"; echo "0 results";
} } ?>
?>

View File

@@ -1,12 +1,12 @@
<?php <?php
include_once("class.php"); include_once "class.php";
$ps4 = new ps4(); $ps4 = new ps4();
if($_SERVER["REQUEST_METHOD"] == "POST"){ if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($_POST['what'] == 'thumbnail') { if ($_POST['what'] == 'thumbnail') {
$ps4->thumbnailupdateurl($_POST['gameid'],$_POST['gamename'],$_POST['url']); $ps4->thumbnailupdateurl($_POST['gameid'], $_POST['gamename'], $_POST['url']);
} }
} }
?> ?>

181
style.css
View File

@@ -1,6 +1,7 @@
body{ body {
background-color: #1C406A; background-color: #1c406a;
font-family: 'Barlow';font-size: 16px; font-family: "Barlow";
font-size: 16px;
} }
body:before { body:before {
@@ -20,180 +21,180 @@ body:before {
} }
a { a {
color: #000; color: #000;
text-decoration: none; text-decoration: none;
font-weight: bold; font-weight: bold;
} }
.refresh{ .refresh {
background: #cadbeb; background: #cadbeb;
border: 1px solid #5f94c2; border: 1px solid #5f94c2;
border-radius: 4px; border-radius: 4px;
display: block; display: block;
padding-bottom: 3px; padding-bottom: 3px;
margin-bottom: 10px; margin-bottom: 10px;
} }
.thumbnail { .thumbnail {
float: left; float: left;
width: 95px; width: 95px;
height: 90px; height: 90px;
padding-top: 10px; padding-top: 10px;
padding-left: 10px; padding-left: 10px;
} }
.thumbnail img { .thumbnail img {
border: 1px solid #3b6f9d; border: 1px solid #3b6f9d;
border-radius: 4px; border-radius: 4px;
} }
.info { .info {
float: left; float: left;
width: auto; width: auto;
padding-top: 10px; padding-top: 10px;
padding-bottom: 10px; padding-bottom: 10px;
} }
/* Clear floats after the columns */ /* Clear floats after the columns */
.game:after { .game:after {
content: ""; content: "";
display: table; display: table;
clear: both; clear: both;
} }
.game{ .game {
width: 500px; width: 500px;
background: #cadbeb; background: #cadbeb;
border: 1px solid #3b6f9d; border: 1px solid #3b6f9d;
border-radius: 4px; border-radius: 4px;
margin-top: 10px; margin-top: 10px;
display: block; display: block;
overflow: auto; overflow: auto;
opacity: 0.95; opacity: 0.95;
} }
#message { #message {
width: 100%; width: 100%;
height: 100%; height: 100%;
margin-bottom: 5px; margin-bottom: 5px;
padding-bottom: 5px; padding-bottom: 5px;
} }
.message-error { .message-error {
background: #fca4a4; background: #fca4a4;
border: 1px solid #8e0000; border: 1px solid #8e0000;
border-radius: 4px; border-radius: 4px;
} }
.message-success { .message-success {
background: #a7d6ad; background: #a7d6ad;
border: 1px solid #034c00; border: 1px solid #034c00;
border-radius: 4px; border-radius: 4px;
} }
.message-head { .message-head {
display: block; display: block;
text-align: center; text-align: center;
font-weight: bold; font-weight: bold;
} }
.message-details { .message-details {
display: block; display: block;
text-align: center; text-align: center;
} }
.center500 { .center500 {
width: 500px; width: 500px;
text-align: center; text-align: center;
} }
.orderby { .orderby {
color: #1f3b53; color: #1f3b53;
font-weight: bold; font-weight: bold;
align-content: center; align-content: center;
display: inline-block; display: inline-block;
background-color: #95b8d7; background-color: #95b8d7;
border: 1px solid #274a68; border: 1px solid #274a68;
border-radius: 4px; border-radius: 4px;
} }
.material-icons.md-arrow { .material-icons.md-arrow {
color: #5f94c2; color: #5f94c2;
}
.material-icons.md-arrow.md-active {
color: #274a68;
} }
.material-icons.md-arrow.md-active { color: #274a68; }
.vertical-align-middle { .vertical-align-middle {
vertical-align: middle; vertical-align: middle;
} }
.padding-bottom-3 { .padding-bottom-3 {
padding-bottom: 3px; padding-bottom: 3px;
} }
.padding-bottom-10 { .padding-bottom-10 {
padding-bottom: 10px; padding-bottom: 10px;
} }
.gameinfoline { .gameinfoline {
} }
.gameinfohead { .gameinfohead {
display: inline-block; display: inline-block;
width: 150px; width: 150px;
text-align: left; text-align: left;
} }
.gameinfoseparator:before { .gameinfoseparator:before {
content: ""; content: "";
} }
.gameinfoseparator { .gameinfoseparator {
display: inline; display: inline;
} }
.gameinfodetails { .gameinfodetails {
padding-left: 3px; padding-left: 3px;
display: inline; display: inline;
} }
.PlaytimeDetails { .PlaytimeDetails {
display: table; display: table;
padding: 5px; padding: 5px;
margin-right: 10px; margin-right: 10px;
border-radius: 4px; border-radius: 4px;
border: 1px solid #274a68; border: 1px solid #274a68;
} }
.PlaytimeStart { .PlaytimeStart {
width: 140px; width: 140px;
display: table-cell; display: table-cell;
} }
.PlaytimeEnd { .PlaytimeEnd {
width: 140px; width: 140px;
display: table-cell; display: table-cell;
} }
.PlaytimeTotal { .PlaytimeTotal {
width: 100px; width: 100px;
display: table-cell; display: table-cell;
} }
.head { .head {
font-weight: bold; font-weight: bold;
} }
.row { .row {
display: table-row; display: table-row;
} }
.row:nth-child(even) { .row:nth-child(even) {
background:#95b8d7; background: #95b8d7;
} }
.cell { .cell {
display: table-cell; display: table-cell;
} }
.FontSmaller { .FontSmaller {
font-size: 14px; font-size: 14px;
} }

View File

@@ -1,41 +1,31 @@
function thumbnailupdateurl(gameid, gamename, rootpage, orderby, details) { function thumbnailupdateurl(gameid, gamename, rootpage, orderby, details) {
var url = prompt("Enter Image URL for " + gamename + " (" + gameid + ")", "");
var url = prompt("Enter Image URL for " + gamename + " (" + gameid + ")", ""); if (url === "") {
alert("Enter something !");
} else {
var data = {
what: "thumbnail",
gameid: gameid,
gamename: gamename,
url: url
};
if (url === "") { $.ajax({
type: "POST",
alert ("Enter something !"); url: "post.php",
data: data,
} else { success: function(data, textStatus, jqXHR) {
$(document).ready(function() {
var data = { $("#message").html(data);
'what': 'thumbnail', $("#message").fadeIn("slow", function() {
'gameid': gameid, $("#message")
'gamename': gamename, .delay(3000)
'url': url .fadeOut();
}; });
$("#page").load("page.php?rootpage=" + rootpage + "&orderby=" + orderby + "&details=" + details);
});
}
$.ajax( });
{ }
type: "POST", }
url: "post.php",
data: data,
success: function(data, textStatus, jqXHR)
{
$( document ).ready(function(){
$('#message').html(data);
$('#message').fadeIn('slow', function(){
$('#message').delay(3000).fadeOut();
});
$("#page").load('page.php?rootpage=' + rootpage + '&orderby=' + orderby + '&details=' + details);
});
}
});
}
}