Author Topic: PHP problems on verification of server offline/online  (Read 13397 times)

Offline Ace

  • Full Member
  • ***
  • Posts: 143
  • Band, the MMORPGDM
    • View Profile
    • ACE Intergraphs
  • Rated:
PHP problems on verification of server offline/online
« on: December 20, 2010, 01:42:41 AM »
When I was working with Seal Online Vengence, once I found the port, it was easy to notify clients when a server was down or up.... however using the same system, I am unable to do the same effect with Q2 why is this?  Anyone have an idee how to fix this PHP Code here?
 :???:
Quote
<?php
$serv1 = @fsockopen("aceintergraphs.com", 27910, $errno, $errstr, 1);
$serv2 = @fsockopen("aceintergraphs.com", 27911, $errno, $errstr, 1);
$serv3 = @fsockopen("aceintergraphs.com", 27912, $errno, $errstr, 1);
$serv4 = @fsockopen("aceintergraphs.com", 27913, $errno, $errstr, 1);
$serv5 = @fsockopen("aceintergraphs.com", 27914, $errno, $errstr, 1);
$serv6 = @fsockopen("aceintergraphs.com", 27915, $errno, $errstr, 1);
$serv7 = @fsockopen("aceintergraphs.com", 27916, $errno, $errstr, 1);
$serv8 = @fsockopen("aceintergraphs.com", 27917, $errno, $errstr, 1);
$serv9 = @fsockopen("aceintergraphs.com", 27918, $errno, $errstr, 1);
$serv10 = @fsockopen("aceintergraphs.com", 27919, $errno, $errstr, 1);
$serv11 = @fsockopen("aceintergraphs.com", 27920, $errno, $errstr, 1);
$serv12 = @fsockopen("aceintergraphs.com", 27921, $errno, $errstr, 1);
if ($serv1)
{
   echo '<br>Fezonia';
   echo '<img src="images/sonline.gif" width="100" height="16" alt="The Fezonia Realm is Online">';
   @fclose($serv1);
}
else
{
    echo '<br>Fezonia';
   echo '<img src="images/soffline.gif" width="100" height="16" alt="The Fezonia Realm is Offline">';
   @fclose($serv1);
}
if ($serv2)
{
    echo '<br>Feasa';
   echo '<img src="images/sonline.gif" width="100" height="16" alt="The Feasa Realm is Online">';
   @fclose($serv2);
}
else
{
    echo '<br>Feasa';
   echo '<img src="images/soffline.gif" width="100" height="16" alt="The Feasa Realm is Offline">';
   @fclose($serv2);
}
if ($serv3)
{
    echo '<br>Harlband';
   echo '<img src="images/sonline.gif" width="100" height="16" alt="The Harlband Real is Online">';
   @fclose($serv3);
}
else
{
    echo '<br>Harlband';
   echo '<img src="images/soffline.gif" width="100" height="16" alt="The Harlband Real is Offline">';
   @fclose($serv3);
}
if ($serv4)
{
    echo '<br>Sodoara';
   echo '<img src="images/sonline.gif" width="100" height="16" alt="The Sodoara Real is Online">';
   @fclose($serv4);
}
else
{
    echo '<br>Sodoara';
   echo '<img src="images/soffline.gif" width="100" height="16" alt="The Sodoara Real is Offline">';
   @fclose($serv4);
}
if ($serv5)
{
    echo '<br>Binndroa';
   echo '<img src="images/sonline.gif" width="100" height="16" alt="The Binndroa Real is Online">';
   @fclose($serv5);
}
else
{
    echo '<br>Binndroa';
   echo '<img src="images/soffline.gif" width="100" height="16" alt="The Binndroa Real is Offline">';
   @fclose($serv5);
}
if ($serv6)
{
    echo '<br>Elboria';
   echo '<img src="images/sonline.gif" width="100" height="16" alt="The Elboria Realm is Online">';
   @fclose($serv6);
}
else
{
    echo '<br>Elboria';
   echo '<img src="images/soffline.gif" width="100" height="16" alt="The Elboria Realm is Offline">';
   @fclose($serv6);
}
if ($serv7)
{
    echo '<br>Eskaara';
   echo '<img src="images/sonline.gif" width="100" height="16" alt="The Eskaara Real is Online">';
   @fclose($serv7);
}
else
{
    echo '<br>Eskaara';
   echo '<img src="images/soffline.gif" width="100" height="16" alt="The Eskaara Real is Offline">';
   @fclose($serv7);
}
if ($serv8)
{
    echo '<br>Eldorian';
   echo '<img src="images/sonline.gif" width="100" height="16" alt="The Eldorian Realm is Online">';
   @fclose($serv8);
}
else
{
    echo '<br>Eldorian';
   echo '<img src="images/soffline.gif" width="100" height="16" alt="The Eldorian Realm is Offline">';
   @fclose($serv8);
}
if ($serv9)
{
    echo '<br>Shamka';
   echo '<img src="images/sonline.gif" width="100" height="16" alt="The Shamka Realm is Online">';
   @fclose($serv9);
}
else
{
    echo '<br>Shamka';
   echo '<img src="images/soffline.gif" width="100" height="16" alt="The Shamka Realm is Offline">';
   @fclose($serv9);
}
if ($serv10)
{
    echo '<br>Redaila';
   echo '<img src="images/sonline.gif" width="100" height="16" alt="The Redaila Realm is Online">';
   @fclose($serv10);
}
else
{
    echo '<br>Redaila';
   echo '<img src="images/soffline.gif" width="100" height="16" alt="The Redaila Realm is Offline">';
   @fclose($serv10);
}
if ($serv11)
{
    echo '<br>Skara';
   echo '<img src="images/sonline.gif" width="100" height="16" alt="The Skara Realm is Online">';
   @fclose($serv11);
}
else
{
    echo '<br>Skara';
   echo '<img src="images/soffline.gif" width="100" height="16" alt="The Skara Realm is Offline">';
   @fclose($serv11);
}
if ($serv12)
{
    echo '<br>Prison';
   echo '<img src="images/sonline.gif" width="100" height="16" alt="The Prison is Online">';
   @fclose($serv12);
}
else
{
    echo '<br>Prison';
   echo '<img src="images/soffline.gif" width="100" height="16" alt="The Prison is Offline">';
   @fclose($serv12);
}
?>

I will be greatfull for all your awnsers!  :notworthy:
« Last Edit: December 21, 2010, 01:38:05 PM by Ace »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
~~Ace~~

Offline reaper

  • Opulent Member
  • *
  • Posts: 2872
  • Nice night for a walk, eh? - Nice night for a walk
    • View Profile
  • Rated:
Re: PHP problems on verification of server offline/online
« Reply #1 on: December 20, 2010, 07:46:00 AM »
You probably need to use UDP, and then send a "quake style echo or connect", then read the data and indicate up if it's a normla response.

Example from fsockopen:

<?php
$fp = fsockopen("udp://127.0.0.1", 13, $errno, $errstr);
if (!$fp) {
    echo "ERROR: $errno - $errstr<br />\n";
} else {
    fwrite($fp, "\n");
    echo fread($fp, 26);
    fclose($fp);
}
?>

  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
VaeVictus "reaper is a lying sack of shit and ragequit then had, probably slugs, come alias and beat me, wasnt even the same person playing OBVIOUSLY, accuracies basicly doubled, and strategy

Offline Ace

  • Full Member
  • ***
  • Posts: 143
  • Band, the MMORPGDM
    • View Profile
    • ACE Intergraphs
  • Rated:
Re: PHP problems on verification of server offline/online
« Reply #2 on: December 21, 2010, 01:39:07 AM »
can it been done with DNS, instead of ip? Since this will be dynamic, and my DNS updates as my Ip does...

NOTE:  I trtied udp with my setup, and it lies and says they are up when they are not, up or not...  just not the code your doing yet also


Nevermind about the DNS I can use this instead:

Quote
<?php
$ips = long2ip("www.aceintergraphs.com");
$sv1 = @fsockopen($ips, (27910), $errno, $errstr, 0.25);
« Last Edit: December 21, 2010, 02:58:56 AM by Ace »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
~~Ace~~

Offline Ace

  • Full Member
  • ***
  • Posts: 143
  • Band, the MMORPGDM
    • View Profile
    • ACE Intergraphs
  • Rated:
Re: PHP problems on verification of server offline/online
« Reply #3 on: December 21, 2010, 02:10:24 AM »
Again like Preditcted, its showing it as always online, when the server port is not online for business....  There must be an alternate way:  Here is teh Sample Code for Proof, but only my site, its showing them all online when only 4 was online on testing...

Quote
<?php
$sv1 = fsockopen("udp://99.89.163.144", (27910), $errno, $errstr);
$sv2 = fsockopen("udp://99.89.163.144", (27911), $errno, $errstr);
$sv3 = fsockopen("udp://99.89.163.144", (27912), $errno, $errstr);
$sv4 = fsockopen("udp://99.89.163.144", (27913), $errno, $errstr);
$sv5 = fsockopen("udp://99.89.163.144", (27914), $errno, $errstr);
$sv6 = fsockopen("udp://99.89.163.144", (27915), $errno, $errstr);
$sv7 = fsockopen("udp://99.89.163.144", (27916), $errno, $errstr);
$sv8 = fsockopen("udp://99.89.163.144", (27917), $errno, $errstr);
$sv9 = fsockopen("udp://99.89.163.144", (27918), $errno, $errstr);
$sv10 = fsockopen("udp://99.89.163.144", (27919), $errno, $errstr);
$sv11 = fsockopen("udp://99.89.163.144", (27920), $errno, $errstr);
$sv12 = fsockopen("udp://99.89.163.144", (27921), $errno, $errstr);

if (!$sv1){
   echo '<br>Fezonia';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Fezonia Realm is Offline">';
} else {
    echo '<br>Fezonia';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Fezonia Realm is Online">';
   fclose($sv1);
}
if (!$sv2){
    echo '<br>Feasa';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Feasa Realm is Offline">';
} else {
    echo '<br>Feasa';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Feasa Realm is Online">';
   fclose($sv2);
}
if (!$sv3){
    echo '<br>Harlband';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Harlband Real is Offline">';
} else {
    echo '<br>Harlband';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Harlband Real is Online">';
   fclose($sv3);
}
if (!$sv4){
    echo '<br>Sodoara';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Sodoara Real is Offline">';
} else {
    echo '<br>Sodoara';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Sodoara Real is Online">';
   fclose($sv4);
}
if (!$sv5){
    echo '<br>Binndroa';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Binndroa Real is Offline">';
} else {
    echo '<br>Binndroa';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Binndroa Real is Online">';
   fclose($sv5);
}
if (!$sv6){
    echo '<br>Elboria';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Elboria Realm is Offline">';
} else {
    echo '<br>Elboria';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Elboria Realm is Online">';
   fclose($sv6);
}
if (!$sv7){
    echo '<br>Eskaara';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Eskaara Real is Offline">';
} else {
    echo '<br>Eskaara';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Eskaara Real is Online">';
   fclose($sv7);
}
if (!$sv8){
    echo '<br>Eldorian';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Eldorian Realm is Offline">';
} else {
    echo '<br>Eldorian';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Eldorian Realm is Online">';
   fclose($sv8);
}
if (!$sv9){
    echo '<br>Shamka';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Shamka Realm is Offline">';
} else {
    echo '<br>Shamka';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Shamka Realm is Online">';
   fclose($sv9);
}
if (!$sv10){
    echo '<br>Redaila';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Redaila Realm is Offline">';
} else {
    echo '<br>Redaila';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Redaila Realm is Online">';
   fclose($sv10);
}
if (!$sv11){
    echo '<br>Skara';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Skara Realm is Offline">';
} else {
    echo '<br>Skara';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Skara Realm is Online">';
   fclose($sv11);
}
if (!$sv12){
    echo '<br>Prison';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Prison is Offline">';
} else {
    echo '<br>Prison';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Prison is Online">';
   fclose($sv12);
}
?>
« Last Edit: December 21, 2010, 02:12:53 AM by Ace »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
~~Ace~~

Offline Ace

  • Full Member
  • ***
  • Posts: 143
  • Band, the MMORPGDM
    • View Profile
    • ACE Intergraphs
  • Rated:
Re: PHP problems on verification of server offline/online
« Reply #4 on: December 21, 2010, 12:24:40 PM »
Apparently Q2 responds to PHP differently than most other servers, so I am tryign to find an Alternate methid of server detection, but through PHP if possible...  :dohdohdoh:
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
~~Ace~~

Offline reaper

  • Opulent Member
  • *
  • Posts: 2872
  • Nice night for a walk, eh? - Nice night for a walk
    • View Profile
  • Rated:
Re: PHP problems on verification of server offline/online
« Reply #5 on: December 21, 2010, 01:09:15 PM »
Q2 doesn't respond differently to PHP.  Q2 uses its own network protocol which is independent of server side scripts or programs.

If you are looking to see if a service is tied to a TCP socket, then maybe fsockopen will work with default parameters.  However that's not actually checking that the application is serving up what it should, but that it is listening on a TCP port.  Whether the application is still working depends on the state of the application.

Q2 uses a different protocol than TCP, it uses UDP, which is connectionless.  Therefore to get a response back, you have to send something that warrants a response from the application.

Below sends a challenge, and gets a challenge response.   The fwrite function takes unicode or something, so I just converted "0xF's" which proceed the challenge.  The below is actually fine, it gets a challenge response from the server, if you didn't send the proper challenge, or the Q2 server wasn't responding you wouldn't get a challenge response.  You could assign the response to a variable and test it, then print HTML.

For the hostname, the hostname is always pasrsed from the URL/URI and resolved.  It's better to use the hostname in case the IP changes.  The script you have above doesn't send a challenge, actually I don't think it sends anything to the server, but it would need to send a challenge, and then read the response.

Quote from: php
<?php
$fp = fsockopen("udp://74.54.186.226", 27910, $errno, $errstr);
if (!$fp) {
    echo "ERROR: $errno - $errstr<br />\n";
} else {
    fwrite($fp, "����getchallenge\n");
    echo fread($fp, 26);
    fclose($fp);
}
?>
« Last Edit: December 21, 2010, 01:24:13 PM by reaper »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
VaeVictus "reaper is a lying sack of shit and ragequit then had, probably slugs, come alias and beat me, wasnt even the same person playing OBVIOUSLY, accuracies basicly doubled, and strategy

Offline Ace

  • Full Member
  • ***
  • Posts: 143
  • Band, the MMORPGDM
    • View Profile
    • ACE Intergraphs
  • Rated:
Re: PHP problems on verification of server offline/online
« Reply #6 on: December 21, 2010, 01:32:57 PM »
what about the fopen statements describing I need b for a windows machine on the switch next to \n do I need to do the same in thsi case?
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
~~Ace~~

Offline Ace

  • Full Member
  • ***
  • Posts: 143
  • Band, the MMORPGDM
    • View Profile
    • ACE Intergraphs
  • Rated:
Re: PHP problems on verification of server offline/online
« Reply #7 on: December 21, 2010, 01:37:11 PM »
Ok I tried your Theory, and its still returning all are online with the following code...

Quote
<?php
$serv1 = @fsockopen("udp://www.aceintergraphs.com", 27910, $errno, $errstr);
$serv2 = @fsockopen("udp://www.aceintergraphs.com", 27911, $errno, $errstr);
$serv3 = @fsockopen("udp://www.aceintergraphs.com", 27912, $errno, $errstr);
$serv4 = @fsockopen("udp://www.aceintergraphs.com", 27913, $errno, $errstr);
$serv5 = @fsockopen("udp://www.aceintergraphs.com", 27914, $errno, $errstr);
$serv6 = @fsockopen("udp://www.aceintergraphs.com", 27915, $errno, $errstr);
$serv7 = @fsockopen("udp://www.aceintergraphs.com", 27916, $errno, $errstr);
$serv8 = @fsockopen("udp://www.aceintergraphs.com", 27917, $errno, $errstr);
$serv9 = @fsockopen("udp://www.aceintergraphs.com", 27918, $errno, $errstr);
$serv10 = @fsockopen("udp://www.aceintergraphs.com", 27919, $errno, $errstr);
$serv11 = @fsockopen("udp://www.aceintergraphs.com", 27920, $errno, $errstr);
$serv12 = @fsockopen("udp://www.aceintergraphs.com", 27921, $errno, $errstr);
if ($serv1){
   fwrite($serv1, "����getchallenge\n\b");
   echo '<br>Fezonia';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Fezonia Realm is Online">';
   fclose($serv1);
}else{
    echo '<br>Fezonia';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Fezonia Realm is Offline">';
}
if ($serv2){
   fwrite($serv2, "����getchallenge\n\b");
    echo '<br>Feasa';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Feasa Realm is Online">';
   fclose($serv2);
}else{
    echo '<br>Feasa';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Feasa Realm is Offline">';
}
if ($serv3){
    fwrite($serv3, "����getchallenge\n\b");
   echo '<br>Harlband';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Harlband Real is Online">';
   fclose($serv3);
}else{
    echo '<br>Harlband';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Harlband Real is Offline">';
}
if ($serv4){
    fwrite($serv4, "����getchallenge\n\b");
   echo '<br>Sodoara';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Sodoara Real is Online">';
   fclose($serv4);
}else{
    echo '<br>Sodoara';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Sodoara Real is Offline">';
}
if ($serv5){
    fwrite($serv5, "����getchallenge\n\b");
   echo '<br>Binndroa';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Binndroa Real is Online">';
   fclose($serv5);
}else{
    echo '<br>Binndroa';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Binndroa Real is Offline">';
}
if ($serv6){
    fwrite($serv6, "����getchallenge\n\b");
   echo '<br>Elboria';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Elboria Realm is Online">';
   fclose($serv6);
}else{
    echo '<br>Elboria';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Elboria Realm is Offline">';
}
if ($serv7){
    fwrite($serv7, "����getchallenge\n\b");
   echo '<br>Eskaara';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Eskaara Real is Online">';
   fclose($serv7);
}else{
    echo '<br>Eskaara';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Eskaara Real is Offline">';
}
if ($serv8){
    fwrite($serv8, "����getchallenge\n\b");
   echo '<br>Eldorian';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Eldorian Realm is Online">';
   fclose($serv8);
}else{
    echo '<br>Eldorian';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Eldorian Realm is Offline">';
}
if ($serv9){
    fwrite($serv9, "����getchallenge\n\b");
   echo '<br>Shamka';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Shamka Realm is Online">';
   fclose($serv9);
}else{
    echo '<br>Shamka';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Shamka Realm is Offline">';
}
if ($serv10){
    fwrite($serv10, "����getchallenge\n\b");
   echo '<br>Redaila';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Redaila Realm is Online">';
   fclose($serv10);
}else{
    echo '<br>Redaila';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Redaila Realm is Offline">';
}
if ($serv11){
    fwrite($serv11, "����getchallenge\n\b");
   echo '<br>Skara';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Skara Realm is Online">';
   fclose($serv11);
}else{
    echo '<br>Skara';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Skara Realm is Offline">';
}
if ($serv12){
    fwrite($serv12, "����getchallenge\n\b");
   echo '<br>Prison';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Prison is Online">';
   fclose($serv12);
}else{
    echo '<br>Prison';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Prison is Offline">';
}
?>

EDIT:  I tried without the \b and still not working correctly, and previosly I tried using the (!$serv1({  and it did not work either
« Last Edit: December 21, 2010, 01:42:49 PM by Ace »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
~~Ace~~

Offline reaper

  • Opulent Member
  • *
  • Posts: 2872
  • Nice night for a walk, eh? - Nice night for a walk
    • View Profile
  • Rated:
Re: PHP problems on verification of server offline/online
« Reply #8 on: December 21, 2010, 01:45:56 PM »
you sent the challenge but you didn't test for a challenge-response.  you're literally just printing HTML if you can send a packet to the server.

run the sample I posted and see the output of "echo fread", you just need to assign the output to a variable and test it contains a challenge response, which is in the format "challenge longnumber".

  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
VaeVictus "reaper is a lying sack of shit and ragequit then had, probably slugs, come alias and beat me, wasnt even the same person playing OBVIOUSLY, accuracies basicly doubled, and strategy

Offline Ace

  • Full Member
  • ***
  • Posts: 143
  • Band, the MMORPGDM
    • View Profile
    • ACE Intergraphs
  • Rated:
Re: PHP problems on verification of server offline/online
« Reply #9 on: December 21, 2010, 01:52:39 PM »
I do without the echo, same problem, it keeps saying server is online when its not, I only want the servers that are online working, its as if its reading my open ports rather than reading the server itself, check for yourself www.aceintergraphs.com


besides I am not wanting the echo, if it prints it will mess up the formatting on my site...

Quote
<?php
$serv1 = @fsockopen("udp://www.aceintergraphs.com", 27910, $errno, $errstr);
$serv2 = @fsockopen("udp://www.aceintergraphs.com", 27911, $errno, $errstr);
$serv3 = @fsockopen("udp://www.aceintergraphs.com", 27912, $errno, $errstr);
$serv4 = @fsockopen("udp://www.aceintergraphs.com", 27913, $errno, $errstr);
$serv5 = @fsockopen("udp://www.aceintergraphs.com", 27914, $errno, $errstr);
$serv6 = @fsockopen("udp://www.aceintergraphs.com", 27915, $errno, $errstr);
$serv7 = @fsockopen("udp://www.aceintergraphs.com", 27916, $errno, $errstr);
$serv8 = @fsockopen("udp://www.aceintergraphs.com", 27917, $errno, $errstr);
$serv9 = @fsockopen("udp://www.aceintergraphs.com", 27918, $errno, $errstr);
$serv10 = @fsockopen("udp://www.aceintergraphs.com", 27919, $errno, $errstr);
$serv11 = @fsockopen("udp://www.aceintergraphs.com", 27920, $errno, $errstr);
$serv12 = @fsockopen("udp://www.aceintergraphs.com", 27921, $errno, $errstr);
if ($serv1){
   fwrite($serv1, "����getchallenge\n");
   fread($serv1, 26);
   echo '<br>Fezonia';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Fezonia Realm is Online">';
   fclose($serv1);
}else{
    echo '<br>Fezonia';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Fezonia Realm is Offline">';
}
if ($serv2){
   fwrite($serv2, "����getchallenge\n");
    fread($serv2, 26);
   echo '<br>Feasa';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Feasa Realm is Online">';
   fclose($serv2);
}else{
    echo '<br>Feasa';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Feasa Realm is Offline">';
}
if ($serv3){
    fwrite($serv3, "����getchallenge\n");
   fread($serv3, 26);
   echo '<br>Harlband';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Harlband Real is Online">';
   fclose($serv3);
}else{
    echo '<br>Harlband';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Harlband Real is Offline">';
}
if ($serv4){
    fwrite($serv4, "����getchallenge\n");
   fread($serv4, 26);
   echo '<br>Sodoara';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Sodoara Real is Online">';
   fclose($serv4);
}else{
    echo '<br>Sodoara';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Sodoara Real is Offline">';
}
if ($serv5){
    fwrite($serv5, "����getchallenge\n");
   fread($serv5, 26);
   echo '<br>Binndroa';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Binndroa Real is Online">';
   fclose($serv5);
}else{
    echo '<br>Binndroa';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Binndroa Real is Offline">';
}
if ($serv6){
    fwrite($serv6, "����getchallenge\n");
   fread($serv6, 26);
   echo '<br>Elboria';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Elboria Realm is Online">';
   fclose($serv6);
}else{
    echo '<br>Elboria';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Elboria Realm is Offline">';
}
if ($serv7){
    fwrite($serv7, "����getchallenge\n");
   fread($serv7, 26);
   echo '<br>Eskaara';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Eskaara Real is Online">';
   fclose($serv7);
}else{
    echo '<br>Eskaara';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Eskaara Real is Offline">';
}
if ($serv8){
    fwrite($serv8, "����getchallenge\n");
   fread($serv8, 26);
   echo '<br>Eldorian';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Eldorian Realm is Online">';
   fclose($serv8);
}else{
    echo '<br>Eldorian';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Eldorian Realm is Offline">';
}
if ($serv9){
    fwrite($serv9, "����getchallenge\n");
   fread($serv9, 26);
   echo '<br>Shamka';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Shamka Realm is Online">';
   fclose($serv9);
}else{
    echo '<br>Shamka';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Shamka Realm is Offline">';
}
if ($serv10){
    fwrite($serv10, "����getchallenge\n");
   fread($serv10, 26);
   echo '<br>Redaila';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Redaila Realm is Online">';
   fclose($serv10);
}else{
    echo '<br>Redaila';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Redaila Realm is Offline">';
}
if ($serv11){
    fwrite($serv11, "����getchallenge\n");
   fread($serv11, 26);
   echo '<br>Skara';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Skara Realm is Online">';
   fclose($serv11);
}else{
    echo '<br>Skara';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Skara Realm is Offline">';
}
if ($serv12){
    fwrite($serv12, "����getchallenge\n");
   fread($serv12, 26);
   echo '<br>Prison';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Prison is Online">';
   fclose($serv12);
}else{
    echo '<br>Prison';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Prison is Offline">';
}
?>

with this, server 1 2 and 12 should be open, not all...
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
~~Ace~~

Offline reaper

  • Opulent Member
  • *
  • Posts: 2872
  • Nice night for a walk, eh? - Nice night for a walk
    • View Profile
  • Rated:
Re: PHP problems on verification of server offline/online
« Reply #10 on: December 21, 2010, 02:00:57 PM »
You're just printing HTML if you can send a packet

fread just reads data from the TCP socket, it doesn't make sure it's a response from a quake server

re-read what I posted
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
VaeVictus "reaper is a lying sack of shit and ragequit then had, probably slugs, come alias and beat me, wasnt even the same person playing OBVIOUSLY, accuracies basicly doubled, and strategy

Offline Ace

  • Full Member
  • ***
  • Posts: 143
  • Band, the MMORPGDM
    • View Profile
    • ACE Intergraphs
  • Rated:
Re: PHP problems on verification of server offline/online
« Reply #11 on: December 21, 2010, 02:05:09 PM »
this has been pissing me off, its not your fault and I appriciate your help, but it still insists that all servers are online, when only 3 are online.... I spent 2 days trying to resolve this browsing in php..net and still found not other ways to solve it, I might have to get more detailed with this process, which I am dreading to code....

PS yes I added the echo statement

when you view my page, www.aceintergraphs.com is it showing the same results as I am getting, maybe its because I testing this on teh server itself?
« Last Edit: December 21, 2010, 02:08:46 PM by Ace »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
~~Ace~~

Offline reaper

  • Opulent Member
  • *
  • Posts: 2872
  • Nice night for a walk, eh? - Nice night for a walk
    • View Profile
  • Rated:
Re: PHP problems on verification of server offline/online
« Reply #12 on: December 21, 2010, 02:27:53 PM »
The PHP script says the server is online because you are not checking if it's online or not online.  

You are sending a packet, and then writing HTML saying the server is online...You need to check that you are getting a good response from the Q2 server application

Here is something that works.  You may even want to see if Q2 has a better application level check available, other than verifying in the Q2 network protocol that you get a challenge-response from a challenge

Quote from: php
<?php
$fp = fsockopen("udp://74.54.186.226", 27910, $errno, $errstr);
if (!$fp) {
    echo "ERROR: $errno - $errstr<br />\n";
} else {
    fwrite($fp, "ÿÿÿÿgetchallenge\n");
    $coutput = fread($fp, 26);
    $cresponse = "challenge";

if(strstr($coutput,$cresponse)){
echo "print HTML server up";
}

else{
echo "print HTML server down";
}

fclose($fp);
}
?>

« Last Edit: December 21, 2010, 02:29:32 PM by reaper »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
VaeVictus "reaper is a lying sack of shit and ragequit then had, probably slugs, come alias and beat me, wasnt even the same person playing OBVIOUSLY, accuracies basicly doubled, and strategy

Offline console

  • Brobdingnagian Member
  • ***
  • Posts: 4518
  • "Man, this is the way to travel," said my attorney
    • View Profile
    • tastyspleen.net
  • Rated:
Re: PHP problems on verification of server offline/online
« Reply #13 on: December 21, 2010, 02:29:05 PM »
[NOTE: reaper already replied while I was typing this, but I'll post anyway... see below about 'ping' vs. 'getchallenge'.]

Hi,

What reaper has said about the logic is correct.  Consider where your "if" statements are.  That's where the decision is being made about whether to display "online" or "offline".  

As currently written it reads like this:

if (always_true){
   fwrite($serv1, "����getchallenge\n");
   fread($serv1, 26);
   echo '<br>Fezonia';
   echo '<img src="images/sonline.gif" width="100" height="8" alt="The Fezonia Realm is Online">';
   fclose($serv1);
}else{
    echo '<br>Fezonia';
   echo '<img src="images/soffline.gif" width="100" height="8" alt="The Fezonia Realm is Offline">';
}


Also, though, you'll want to use "ping" instead of "getchallenge" to query whether a Q2 server is online.  It's less work for the server than 'getchallenge'.


Regards,

quadz

  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline reaper

  • Opulent Member
  • *
  • Posts: 2872
  • Nice night for a walk, eh? - Nice night for a walk
    • View Profile
  • Rated:
Re: PHP problems on verification of server offline/online
« Reply #14 on: December 21, 2010, 02:34:57 PM »
Quote from: Ace
Exmples please as well....   on teh variable I mean and how it should be used

The last example I pasted is a working example, but quadz said to use ping, since it's less work on the server.
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
VaeVictus "reaper is a lying sack of shit and ragequit then had, probably slugs, come alias and beat me, wasnt even the same person playing OBVIOUSLY, accuracies basicly doubled, and strategy

 

El Box de Shoutamente

Last 10 Shouts:

 

Costigan_Q2

November 11, 2024, 06:41:06 AM
"Stay cozy folks.

Everything is gonna be fine."

There'll be no excuses for having TDS after January 20th, there'll be no excuses AT ALL!!!
 

|iR|Focalor

November 06, 2024, 03:28:50 AM
 

RailWolf

November 05, 2024, 03:13:44 PM
Nice :)

Tom Servo

November 04, 2024, 05:05:24 PM
The Joe Rogan Experience episode 223 that dropped a couple hours ago with Musk, they're talking about Quake lol.
 

Costigan_Q2

November 04, 2024, 03:37:55 PM
Stay cozy folks.

Everything is gonna be fine.
 

|iR|Focalor

October 31, 2024, 08:56:37 PM
 

Costigan_Q2

October 17, 2024, 06:31:53 PM
Not activated your account yet?

Activate it now! join in the fun!

Tom Servo

October 11, 2024, 03:35:36 PM
HAHAHAHAHAHA
 

|iR|Focalor

October 10, 2024, 12:19:41 PM
I don't worship the devil. Jesus is Lord, friend. He died for your sins. He will forgive you if you just ask.
 

rikwad

October 09, 2024, 07:57:21 PM
Sorry, I couldn't resist my inner asshole.

Show 50 latest
Welcome, Guest. Please login or register.
November 12, 2024, 09:08:26 PM

Login with username, password and session length