first commit
This commit is contained in:
79
class.php
Normal file
79
class.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
class ps4 {
|
||||
|
||||
function mysql_conn($sql=null) {
|
||||
$servername = "10.99.0.1";
|
||||
$username = "ps4";
|
||||
$password = "zpmAeh9cXM7xyFR";
|
||||
$dbname = "ps4";
|
||||
|
||||
// Create connection
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
$conn->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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user