commit 5098802adbd09f031de59bffc37abd9ba60e12fc Author: Sebastien Plante Date: Thu Nov 29 17:05:04 2018 -0500 first commit diff --git a/class.php b/class.php new file mode 100644 index 0000000..508c641 --- /dev/null +++ b/class.php @@ -0,0 +1,79 @@ +set_charset("utf8"); + // Check connection + if ($conn->connect_error) { + die("Connection failed: " . $conn->connect_error); + } + + if ($sql == null) { + echo "Error: No SQL Request?"; + $conn->close(); + return null; + } else { + $return = $conn->query($sql); + $conn->close(); + return $return; + } + } + + function playtime($seconds, $text=false) { + $playtime = null; + $label = null; + + if ($seconds < 60) { + if ($text == true) { + $label = "second"; + } + if ($seconds > 1) { $label .= "s"; } + $playtime = $seconds; + } else + if ($seconds/60 < 60) { + if ($text == true) { + $label = "minute"; + } + if ($seconds/60 > 1) { $label .= "s"; } + $playtime = round($seconds/60,2); + } else + if ($seconds/60/60 < 60) { + if ($text == true) { + $label = "hour"; + } + if ($seconds/60/60 > 1) { $label .= "s"; } + $playtime = round($seconds/60/60,2); + } + + $return = $playtime; + if ($text == true) { $return = $return ." ". $label; } + return $return; + } + + function secondsToDate($seconds) { + return date("d/m/Y H:i:s", $seconds/1000); + } + + function thumbnailurl($game_id) { + $result = $this->mysql_conn("SELECT thumbnail_url FROM game_thumbnail WHERE game_id = '". $game_id ."' limit 1;"); + if ($result->num_rows > 0) { + while ($row = $result->fetch_assoc()) { + $url = $row["thumbnail_url"]; + } + } else { + $url = "no-thumbnail.png"; + } + return $url; + } + +} + +?> \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..55e7365 --- /dev/null +++ b/index.php @@ -0,0 +1,98 @@ +mysql_conn($sql); + +echo " + + + + + + +"; + +echo "Date : ". date(DATE_RFC2822) ."

"; + +if ($result->num_rows > 0) { + // output data of each row + + 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; + + 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"]; + } + } + } + +$currentid = ""; +foreach ($games as $key => $value) { + echo "
"; + echo "
"; + echo "thumbnailurl($key)."\" border=0 weight=\"80px\" height=\"80px\">"; + echo "
"; + echo "
"; + echo "(". $games[$key]["game_id"] .") ". $games[$key]["game_name"] .""; + echo "
"; + echo "Total Time Played : ". $ps4->playtime($games[$key]["game_total_time"],true) .""; + echo "
First Played on : ". $ps4->secondsToDate($games[$key]["game_played_first"]); + echo "
Last Played on : "; + + if ($games[$key]["game_played_last"] == -1) { + echo "now playing"; + } else { + echo $ps4->secondsToDate($games[$key]["game_played_last"]); + } + echo "
"; // info + echo "
"; // game +} + +/* +echo "
";
+print_r($games);
+echo "
"; +*/ + +echo " +

+To Do :
+- populer le details
+- crée la fonction pour set thumbnail
+- ordre d'affichage?
+"; + +} else { + echo "0 results"; +} + +echo " + + +"; +?> diff --git a/no-thumbnail.png b/no-thumbnail.png new file mode 100644 index 0000000..d7ca46b Binary files /dev/null and b/no-thumbnail.png differ diff --git a/style.css b/style.css new file mode 100644 index 0000000..da18ab1 --- /dev/null +++ b/style.css @@ -0,0 +1,32 @@ +body{ + background-color: #d3d3d3; +} + +.thumbnail { + float: left; + width: 95px; + height: 90px; + padding-top: 10px; + padding-left: 10px; +} +.info { + float: left; + width: auto; + height: 90px; + padding-top: 10px; +} + +/* Clear floats after the columns */ +.game:after { + content: ""; + display: table; + clear: both; +} + +.game{ + width: 600px; + background: #00b0bc; + border: 1px solid #027c84; + border-radius: 2px; + margin-bottom: 10px; +} \ No newline at end of file