So I have this server status script which checks to see if the server is online or offline. I know for a fact that nothing is wrong with the script because I have used the same script on 3-4 different hosters. Now that I'm at NFO the script worked fine for probably the first hour and now it just constantly says it's offline. I have a separate webhost besides from NFO.
The script checks the ports 5121, 6121, and 6900. Players are able to connect to the server so I know the ports aren't blocked. Does anyone have any ideas to throw in? I would appreciate the help. Thanks!
Server Status Script
-
- New to forums
- Posts: 3
- https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
- Joined: Wed Jun 29, 2011 2:28 pm
Re: Server Status Script
What type of server are you querying? What is the exact error?
-
- New to forums
- Posts: 3
- Joined: Wed Jun 29, 2011 2:28 pm
Re: Server Status Script
This is the Patch Notice that players see on the patcher. Of course there you can see that it says offline.
Here is the snippet of code:
This is the error message I get:
Here is the snippet of code:
Code: Select all
$host = '66.150.214.78';
$user = '..';
$pass = '..';
$db = '..';
$online = '<font color="Green">Online</font>';
$offline = '<font color="Red">Offline</font>';
$acc_port = '6900';
$char_port = '6121';
$map_port = '5121';
$interval = time()+60;
/* Check Server Status, If Server Status Was Not Checked In Last $interval seconds */
if($_COOKIE["checked"] != "true") {
/* Check Server Status */
$acc = fsockopen($host, $acc_port, $errno, $errstr, 1);
$char = fsockopen($host, $char_port, $errno, $errstr, 1);
$map = fsockopen($host, $map_port, $errno, $errstr, 1);
/* Workout Server Status & Set Cookie */
if(!$acc){ $acc_status = $offline; setcookie("acc_status", "offline", $interval); } else { $acc_status = $online; }
if(!$char){ $char_status = $offline; setcookie("char_status", "offline", $interval); } else { $char_status = $online; }
if(!$map){ $map_status = $offline; setcookie("map_status", "offline", $interval); } else { $map_status = $online; }
/* Set Cookie To Let The Script Know, Server Status is Checked */
setcookie("checked", "true", $interval);
} else if($_COOKIE["checked"] == "true") {
/* Read Cookie Values */
if($_COOKIE["acc_status"] == "offline"){ $acc_status = $offline; } else { $acc_status = $online; }
if($_COOKIE["char_status"] == "offline"){ $char_status = $offline; } else { $char_status = $online; }
if($_COOKIE["map_status"] == "offline"){ $map_status = $offline; } else { $map_status = $online; }
}
$link = mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($db);
$query = mysql_query("SELECT `char`.`name`, `login`.`level` FROM `char` LEFT JOIN `login` ON `login`.`account_id` = `char`.`account_id` WHERE `char`.`online` != '0'");
//$result = mysql_query($query,$link);
$online = mysql_num_rows($query);
mysql_close($link);
The script is running from my separate webhost to connect to the NFO server.Warning: fsockopen() [function.fsockopen]: unable to connect to 66.150.214.78:6900 (Connection timed out) in /home6/fusionro/public_html/Patch/notice.php on line 27
Warning: fsockopen() [function.fsockopen]: unable to connect to 66.150.214.78:6121 (Connection timed out) in /home6/fusionro/public_html/Patch/notice.php on line 28
Warning: fsockopen() [function.fsockopen]: unable to connect to 66.150.214.78:5121 (Connection timed out) in /home6/fusionro/public_html/Patch/notice.php on line 29
Warning: Cannot modify header information - headers already sent by (output started at /home6/fusionro/public_html/Patch/notice.php:27) in /home6/fusionro/public_html/Patch/notice.php on line 32
Warning: Cannot modify header information - headers already sent by (output started at /home6/fusionro/public_html/Patch/notice.php:27) in /home6/fusionro/public_html/Patch/notice.php on line 33
Warning: Cannot modify header information - headers already sent by (output started at /home6/fusionro/public_html/Patch/notice.php:27) in /home6/fusionro/public_html/Patch/notice.php on line 34
Warning: Cannot modify header information - headers already sent by (output started at /home6/fusionro/public_html/Patch/notice.php:27) in /home6/fusionro/public_html/Patch/notice.php on line 37
Re: Server Status Script
What server type are you querying? Where are you running this from? Are you certain that the server hasn't banned/blocked the IP that you are querying from?
-
- New to forums
- Posts: 3
- Joined: Wed Jun 29, 2011 2:28 pm
Re: Server Status Script
I figured out what it was. It was my webhost needing to have the dedicated IP to open the port.