final60 Posted January 6, 2009 Share Posted January 6, 2009 Im just wondering if I might be able to add to the existing server status php code I have on my site. It simply shows different images (green for server open, amber for server lock, red for server closed). How might i add to the code to log the last time the server closed and could I use a counter from the point when the server status displays open? So it additionally have: Last reset: Jan 4th 2009 13:44 (When the server status last displayed the red "closed" image) Uptime: 24hrs 32m 14s (A counter running from when server status last displayed the green "open" image) <?php // retrieve information from Ryzom's website $server_data = file('[url=http://atys.ryzom.com/serverstatus/status.php]http://atys.ryzom.com/serverstatus/status.php[/url]'); for ($i = 0; $i < sizeof($server_data); $i ++) { $data = explode('|',$server_data[$i]); $server = $data[0]; $status = '<img src="<a href="http://www.dcpryzom.co.uk/images/server_closed.jpg" target="_blank">[url=http://www.dcpryzom.co.uk/images/server_closed.jpg]http://www.dcpryzom.co.uk/images/server_closed.jpg[/url]</a>" alt="Closed" />'; $server_img['Aniro'] = '<img src="<a href="http://www.dcpryzom.co.uk/images/server_ani.jpg" target="_blank">[url=http://www.dcpryzom.co.uk/images/server_ani.jpg]http://www.dcpryzom.co.uk/images/server_ani.jpg[/url]</a>" alt="Aniro"/>'; $server_img['Leanon'] = '<img src="<a href="http://www.dcpryzom.co.uk/images/server_lea.jpg" target="_blank">[url=http://www.dcpryzom.co.uk/images/server_lea.jpg]http://www.dcpryzom.co.uk/images/server_lea.jpg[/url]</a>" alt="Leanon"/>'; $server_img['Arispotle'] = '<img src="<a href="http://www.dcpryzom.co.uk/images/server_ari.jpg" target="_blank">[url=http://www.dcpryzom.co.uk/images/server_ari.jpg]http://www.dcpryzom.co.uk/images/server_ari.jpg[/url]</a>" alt="Arispotle"/>'; switch($data[1]) { case 1: $status = '<img src="<a href="http://www.dcpryzom.co.uk/images/server_open.jpg" target="_blank">[url=http://www.dcpryzom.co.uk/images/server_open.jpg]http://www.dcpryzom.co.uk/images/server_open.jpg[/url]</a>" alt="Open" />'; break; case 2: $status = '<img src="<a href="http://www.dcpryzom.co.uk/images/server_locked.jpg" target="_blank">[url=http://www.dcpryzom.co.uk/images/server_locked.jpg]http://www.dcpryzom.co.uk/images/server_locked.jpg[/url]</a>" alt="Locked" />'; break; } echo $server_img[$server] . $status .'<br />'; }?> Quote Link to comment https://forums.phpfreaks.com/topic/139697-adding-too-existing-server-status-code/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.