EOSERV Forum > Programming > php request: $uptime displayed on website
Topic is locked.
Page: << 1 2 >>
php request: $uptime displayed on website
Author Message
Post #140048 php request: $uptime displayed on website

anyone got a code for using php to display game server uptime on a web page?

---
Beware of your thoughts, they become your words. Beware of your words, they become your actions.
Beware of your actions, they become your habits. Beware of your habits, they become your character.
Beware of your character, it becomes your destiny.
- Unknown
14 years, 10 weeks ago
Post #140050 Re: request: $uptime displayed on website

You cant specificly just have a few lines of code for the uptime. You have to keep track of how long it stays up and how long it stays down then average it, so you would have to make a database and log it every so with php. Let me see if theres a way for you to steal it off eoserv.


Edit: Ok, made a little app to parse the xml, and select your server.

Just chance the ?server=NameHere in the url. It has to be exactly how its showing on your server.


Use something along the lines of : 

<?php

include "http://projecthub.hostoi.com/projects/eoserv/uptime.php?server=Endless%20Edge";

?>

http://projecthub.hostoi.com/projects/eoserv/uptime.php?server=Endless%20Edge

---
Andrewbob - I would be on the fucking copter of rofls

Programmer, Web Developer, and Graphics Designer
14 years, 10 weeks ago
Post #140061 Re: request: $uptime displayed on website


I am not sure that your example even works... and if it is actually getting any real data, your formula waaaaay off.

14 years, 10 weeks ago
Post #140062 Re: request: $uptime displayed on website
Apollo posted: (11th Apr 2012, 08:39 pm)


I am not sure that your example even works... and if it is actually getting any real data, your formula waaaaay off.


Its grabbing it straight from the eoserv xml. It should work. My example should also work since when you include an html file/php file, if it includes any html/text it will include it in your page.

<?php

if (isset($_GET['server']))
{
$xml = simplexml_load_file("https://eoserv.net/SLN/xml");
$servers = 0;

foreach ($xml->children() as $child)
{
if ($_GET['server'] == $child->name[0])
{
$servers += 1;
echo $child->uptime[0];
}
}

if ($servers == 0)
{
echo "Sorry, but the server '".$_GET['server']."' is currently not on the server list.";
}
}

?>
---
Andrewbob - I would be on the fucking copter of rofls

Programmer, Web Developer, and Graphics Designer
14 years, 10 weeks ago
Post #140063 Re: request: $uptime displayed on website

im not sure if this is what you are asking for so just ignore this if im wrong.


<?php
$uptime = shell_exec("cut -d. -f1 /proc/uptime");
$days = floor($uptime/60/60/24);
$hours = $uptime/60/60%24;
$mins = $uptime/60%60;
$secs = $uptime%60;
echo "up $days days $hours hours $mins minutes and $secs seconds";
?>

14 years, 10 weeks ago
Post #140064 Re: request: $uptime displayed on website

No, hes asking for the uptime on his server. 


What is the format of the uptime in the xml anyway? 

---
Andrewbob - I would be on the fucking copter of rofls

Programmer, Web Developer, and Graphics Designer
14 years, 10 weeks ago
Post #140253 Re: request: $uptime displayed on website

So, no one has a code that will work?

---
Beware of your thoughts, they become your words. Beware of your words, they become your actions.
Beware of your actions, they become your habits. Beware of your habits, they become your character.
Beware of your character, it becomes your destiny.
- Unknown
14 years, 10 weeks ago
Post #140257 Re: request: $uptime displayed on website

My code works. What exactly are you looking for, I might of misunderstood.

---
Andrewbob - I would be on the fucking copter of rofls

Programmer, Web Developer, and Graphics Designer
14 years, 10 weeks ago
Post #140259 Re: request: $uptime displayed on website
Wildsurvival posted: (15th Apr 2012, 02:19 am)

My code works. What exactly are you looking for, I might of misunderstood.


when I use this

<?php

if (isset($_GET['server']))
{
$xml = simplexml_load_file("https://eoserv.net/SLN/xml");
$servers = 0;

foreach ($xml->children() as $child)
{
if ($_GET['server'] == $child->name[0])
{
$servers += 1;
echo $child->uptime[0];
}
}

if ($servers == 0)
{
echo "Sorry, but the server '".$_GET['server']."' is currently not on the server list.";
}
}

?>


it returns a blank page http://eo-red.us/uptest.php

and why should it access eoserv.net at all? isn't the information in my database? I know damned good and well when I type $uptime in my client it doesn't connect to eoserv.net before it returns the value......
---
Beware of your thoughts, they become your words. Beware of your words, they become your actions.
Beware of your actions, they become your habits. Beware of your habits, they become your character.
Beware of your character, it becomes your destiny.
- Unknown
14 years, 10 weeks ago
Post #140274 Re: php request: $uptime displayed on website

That is because eoserv.net doesn't check any stored uptime. If a connection is made from your server to eoserv.net then your server is visible, every subsequent connection adds to the time eoserv.net's SLN thinks your server is running. If a connection cannot be made, the SLN determines your server is officially offline and the uptime is reset.

@Wildsurvival: You should use your own script to check for an open connection. Also, your time format is fucked to hell. Looks like rawtime.

14 years, 10 weeks ago
Post #140275 Re: php request: $uptime displayed on website
Apollo posted: (15th Apr 2012, 03:44 am)

That is because eoserv.net doesn't check any stored uptime. If a connection is made from your server to eoserv.net then your server is visible, every subsequent connection adds to the time eoserv.net's SLN thinks your server is running. If a connection cannot be made, the SLN determines yourserver is officially offline and the uptime is reset.

@Wildsurvival: You should use your own script to check for an open connection. Also, your time format is fucked to hell. Looks like rawtime.



I was just hoping someone would have a method of retrieving the uptime via php that I could use to display it on my site. I'm not trying to duplicate SLN functions, just display the uptime.

---
Beware of your thoughts, they become your words. Beware of your words, they become your actions.
Beware of your actions, they become your habits. Beware of your habits, they become your character.
Beware of your character, it becomes your destiny.
- Unknown
14 years, 10 weeks ago
Post #140281 Re: php request: $uptime displayed on website
Redrocco posted: (15th Apr 2012, 02:40 am)

Wildsurvival posted: (15th Apr 2012, 02:19 am)

My code works. What exactly are you looking for, I might of misunderstood.


when I use this

<?php

if (isset($_GET['server']))
{
$xml = simplexml_load_file("https://eoserv.net/SLN/xml");
$servers = 0;

foreach ($xml->children() as $child)
{
if ($_GET['server'] == $child->name[0])
{
$servers += 1;
echo $child->uptime[0];
}
}

if ($servers == 0)
{
echo "Sorry, but the server '".$_GET['server']."' is currently not on the server list.";
}
}

?>


it returns a blank page http://eo-red.us/uptest.php

and why should it access eoserv.net at all? isn't the information in my database? I know damned good and well when I type $uptime in my client it doesn't connect to eoserv.net before it returns the value......

It won't because you haven't defined a server, try uptime.php?server=yourserver
---
If money doesn't grow on trees, then why do banks have branches?
14 years, 10 weeks ago
Post #140294 Re: php request: $uptime displayed on website
Apollo posted: (15th Apr 2012, 03:44 am)

That is because eoserv.net doesn't check any stored uptime. If a connection is made from your server to eoserv.net then your server is visible, every subsequent connection adds to the time eoserv.net's SLN thinks your server is running. If a connection cannot be made, the SLN determines your server is officially offline and the uptime is reset.

@Wildsurvival: You should use your own script to check for an open connection. Also, your time format is fucked to hell. Looks like rawtime.



Yeah I didn't modify the time format, as I have no clue what format it is in.

 

---
Andrewbob - I would be on the fucking copter of rofls

Programmer, Web Developer, and Graphics Designer
14 years, 10 weeks ago
Post #140334 Re: php request: $uptime displayed on website
DanScott posted: (15th Apr 2012, 09:41 am)

Redrocco posted: (15th Apr 2012, 02:40 am)

Wildsurvival posted: (15th Apr 2012, 02:19 am)

My code works. What exactly are you looking for, I might of misunderstood.


when I use this

<?php

if (isset($_GET['server']))
{
$xml = simplexml_load_file("https://eoserv.net/SLN/xml");
$servers = 0;

foreach ($xml->children() as $child)
{
if ($_GET['server'] == $child->name[0])
{
$servers += 1;
echo $child->uptime[0];
}
}

if ($servers == 0)
{
echo "Sorry, but the server '".$_GET['server']."' is currently not on the server list.";
}
}

?>


it returns a blank page http://eo-red.us/uptest.php

and why should it access eoserv.net at all? isn't the information in my database? I know damned good and well when I type $uptime in my client it doesn't connect to eoserv.net before it returns the value......

It won't because you haven't defined a server, try uptime.php?server=yourserver

it still doesn't work for me
---
Beware of your thoughts, they become your words. Beware of your words, they become your actions.
Beware of your actions, they become your habits. Beware of your habits, they become your character.
Beware of your character, it becomes your destiny.
- Unknown
14 years, 10 weeks ago
Post #140337 Re: php request: $uptime displayed on website
Redrocco posted: (15th Apr 2012, 11:55 pm)

DanScott posted: (15th Apr 2012, 09:41 am)

Redrocco posted: (15th Apr 2012, 02:40 am)

Wildsurvival posted: (15th Apr 2012, 02:19 am)

My code works. What exactly are you looking for, I might of misunderstood.


when I use this

<?php

if (isset($_GET['server']))
{
$xml = simplexml_load_file("https://eoserv.net/SLN/xml");
$servers = 0;

foreach ($xml->children() as $child)
{
if ($_GET['server'] == $child->name[0])
{
$servers += 1;
echo $child->uptime[0];
}
}

if ($servers == 0)
{
echo "Sorry, but the server '".$_GET['server']."' is currently not on the server list.";
}
}

?>


it returns a blank page http://eo-red.us/uptest.php

and why should it access eoserv.net at all? isn't the information in my database? I know damned good and well when I type $uptime in my client it doesn't connect to eoserv.net before it returns the value......

It won't because you haven't defined a server, try uptime.php?server=yourserver

it still doesn't work for me

To be honest with you bud, I think it'd probably be worth while looking at the source to see how EOSERV communicates with the database & just how it records the uptime and then code in some kind of system that updates a "uptime" field in maybe a new table called server properties? (Just brainstorming here) I wouldn't know how to go about the C++ side of this but you're quite right in thinking that there's no need to contact the SLN at all considering $uptime works in game without pulling from the SLN. 
---
If money doesn't grow on trees, then why do banks have branches?
14 years, 10 weeks ago
Page: << 1 2 >>
Topic is locked.
EOSERV Forum > Programming > php request: $uptime displayed on website