wowshrine.net
Keep your hearthstone set to Shrine!
Login or Register to remove ads! You're browsing our forum and website as a Guest meaning you can only see a portion of the forum in read-only mode.
World of Warcraft Diablo Immortal Warcraft Rumble Advertise Discord YouTube

WoW server uptime script PHP for TrinityCore


WoW server uptime script PHP for TrinityCore
« on: April 13, 2022, 02:18:38 AM »
WoW server uptime script in PHP using PDO for TrinityCore.
It's custom, simple and secure.



Code: [Select]
<?php
// WoW server uptime and max. players
$query_uptime_wotlk "SELECT starttime, maxplayers FROM uptime WHERE realmid = &#39;1&#39; ORDER BY starttime DESC LIMIT 1"
$query_con_uptime_wotlk $conn -> prepare($query_uptime_wotlk);
$query_con_uptime_wotlk->execute();
$res_uptime_wotlk $query_con_uptime_wotlk->fetch(PDO::FETCH_ASSOC);

$uptimetime time() - $res_uptime_wotlk[&#39;starttime&#39;];

function format_uptime($seconds) {
$secs  intval($seconds 60);
$mins  intval($seconds 60 60);
$hours intval($seconds 3600 24);
$days  intval($seconds 86400);

$uptimeString=&#39;&#39;;

if ($days) {
$uptimeString .= $days;
$uptimeString .= ((=== $days) ? &#39; day&#39; : &#39; days&#39;);
}
if ($hours) {
$uptimeString .= (($days) ? &#39;, &#39; : &#39;&#39;).$hours;
$uptimeString .= ((=== $hours) ? &#39; hour&#39; : &#39; hours&#39;);
}
if ($mins) {
$uptimeString .= (($days || $hours) ? &#39;, &#39; : &#39;&#39;).$mins;
$uptimeString .= ((=== $mins) ? &#39; minute&#39; : &#39; minutes&#39;);
}
if ($secs) {
$uptimeString .= (($days || $hours || $mins) ? &#39;, &#39; : &#39;&#39;).$secs;
$uptimeString .= ((=== $secs) ? &#39; second&#39; : &#39; seconds&#39;);
}
return $uptimeString;
}

$staticUptime format_uptime($uptimetime);
unset($uptimetime);

echo "
<div>
<span style=\"font-size:0.8em;color:#B0BEC5;\">Uptime: "
.$staticUptime."</span><br />
<span style=\"font-size:0.8em;color:#B0BEC5;\">Max. players: "
.$res_uptime_wotlk[maxplayers]."</span>
</div>"
;

unset($staticUptime);
unset($query_con_uptime_wotlk);
?>



Info!
&#39; is single quote (')
You can customize the echo "" results according to your needs.
PDO is inherently secure.


--
« Last Edit: March 10, 2024, 11:35:52 PM by Ls »
 





Linux Ubuntu Guides Linux games - Lutris.net Advertise on wowshrine.net Advertise on wowshrine.net