MGCJerry
08-12-2002, 02:31 AM
Guess who? Its me again with a petty script problem.
I'm trying to have a script query a page that is dynamically created and have the script display whether or not a predetermined value was found.
I have some ereg_replace() commands in there in case some of the queried page didnt have anything that php doesn't like.
Everything works fine all the way up to the "if ereg... etc" statement (verified by using echo $buff5; ) . Regardless of the value to look for, it always returns false.
I have dug into the manual, but everything I try returns false. I tried working on this for 5 hours and I havent gone past this part.
Quick summary:
I want this script to see if my OpenRPG game server is running by probing the central server. If it is running, the script tells you if its running, otherwise it says it isn't running. I want to put this on my site so my visitors can see if my server is up.
Any suggetions?
Thanks in advance.
<?php
$fd = fopen("http://my.openrpg.com/openrpg_servers.php", "r");
while (!feof ($fd)) {
$buffer = fgets($fd, 4096);
//Replace the crap in the metaserver
$buff0 = ereg_replace ("\"", " ", $buffer);
$buff1 = ereg_replace ("\'", "", $buff0);
$buff2 = ereg_replace ("<servers>", "", $buff1);
$buff3 = ereg_replace ("<server", "", $buff2);
$buff4 = ereg_replace ("/>", "", $buff3);
$buff5 = ereg_replace ("2 The Xtreme", "2TX", $buff4);
//Look for Our Server
if (ereg ("OpenRPG Dev", $buff5)) {
echo "Our server is running\n";
return;
} else {
echo "Our Server is not Running\n";
return;
}
}
fclose ($fd);
?>
edit
If you want to check for a server that is always running, have the script search for OpenRPG Dev.
I'm trying to have a script query a page that is dynamically created and have the script display whether or not a predetermined value was found.
I have some ereg_replace() commands in there in case some of the queried page didnt have anything that php doesn't like.
Everything works fine all the way up to the "if ereg... etc" statement (verified by using echo $buff5; ) . Regardless of the value to look for, it always returns false.
I have dug into the manual, but everything I try returns false. I tried working on this for 5 hours and I havent gone past this part.
Quick summary:
I want this script to see if my OpenRPG game server is running by probing the central server. If it is running, the script tells you if its running, otherwise it says it isn't running. I want to put this on my site so my visitors can see if my server is up.
Any suggetions?
Thanks in advance.
<?php
$fd = fopen("http://my.openrpg.com/openrpg_servers.php", "r");
while (!feof ($fd)) {
$buffer = fgets($fd, 4096);
//Replace the crap in the metaserver
$buff0 = ereg_replace ("\"", " ", $buffer);
$buff1 = ereg_replace ("\'", "", $buff0);
$buff2 = ereg_replace ("<servers>", "", $buff1);
$buff3 = ereg_replace ("<server", "", $buff2);
$buff4 = ereg_replace ("/>", "", $buff3);
$buff5 = ereg_replace ("2 The Xtreme", "2TX", $buff4);
//Look for Our Server
if (ereg ("OpenRPG Dev", $buff5)) {
echo "Our server is running\n";
return;
} else {
echo "Our Server is not Running\n";
return;
}
}
fclose ($fd);
?>
edit
If you want to check for a server that is always running, have the script search for OpenRPG Dev.
