Posts: 18
Threads: 2
Joined: May 2010
Reputation:
0
05-21-2010, 02:55 AM
(This post was last modified: 05-21-2010, 02:55 AM by DNG.)
(05-21-2010, 01:23 AM)realchamp Wrote: (05-21-2010, 01:11 AM)DNG Wrote: (05-21-2010, 12:28 AM)realchamp Wrote: Install them? Just run the script on your webserver with PHP 5.0 <= installed.
This is the point, i have a web-hosting in php + Gamerserver in Win7 ultimate @ home,,
what to do?? i am confused!!!!
Put the PHP file in your web folder(htdocs) and open it with your browser(http://localhost/query.php). Ofcause you'll need to make some changes to what it shall query
I thought of the localhost, but how to make it online, i think there are some Microsoft tools i have to install, unfortunately i am not familiar with them
Posts: 7,778
Threads: 176
Joined: May 2008
Reputation:
83
(05-21-2010, 02:55 AM)DNG Wrote: (05-21-2010, 01:23 AM)realchamp Wrote: (05-21-2010, 01:11 AM)DNG Wrote: (05-21-2010, 12:28 AM)realchamp Wrote: Install them? Just run the script on your webserver with PHP 5.0 <= installed.
This is the point, i have a web-hosting in php + Gamerserver in Win7 ultimate @ home,,
what to do?? i am confused!!!!
Put the PHP file in your web folder(htdocs) and open it with your browser(http://localhost/query.php). Ofcause you'll need to make some changes to what it shall query
I thought of the localhost, but how to make it online, i think there are some Microsoft tools i have to install, unfortunately i am not familiar with them
Open your port 80 and allow whatever webserver you're using to go through your firewall.
Posts: 18
Threads: 2
Joined: May 2010
Reputation:
0
(05-21-2010, 03:11 AM)realchamp Wrote: (05-21-2010, 02:55 AM)DNG Wrote: (05-21-2010, 01:23 AM)realchamp Wrote: (05-21-2010, 01:11 AM)DNG Wrote: (05-21-2010, 12:28 AM)realchamp Wrote: Install them? Just run the script on your webserver with PHP 5.0 <= installed.
This is the point, i have a web-hosting in php + Gamerserver in Win7 ultimate @ home,,
what to do?? i am confused!!!!
Put the PHP file in your web folder(htdocs) and open it with your browser(http://localhost/query.php). Ofcause you'll need to make some changes to what it shall query
I thought of the localhost, but how to make it online, i think there are some Microsoft tools i have to install, unfortunately i am not familiar with them
Open your port 80 and allow whatever webserver you're using to go through your firewall.
how to?
& do i have to do portforwarding for the game as well??
and what about the safety measurement?
Do i need to do some actions to be in the safe side, to keep hackers away from my network
Posts: 7,778
Threads: 176
Joined: May 2008
Reputation:
83
05-21-2010, 04:29 AM
(This post was last modified: 05-21-2010, 04:29 AM by realchamp.)
(05-21-2010, 03:28 AM)DNG Wrote: (05-21-2010, 03:11 AM)realchamp Wrote: (05-21-2010, 02:55 AM)DNG Wrote: (05-21-2010, 01:23 AM)realchamp Wrote: (05-21-2010, 01:11 AM)DNG Wrote: (05-21-2010, 12:28 AM)realchamp Wrote: Install them? Just run the script on your webserver with PHP 5.0 <= installed.
This is the point, i have a web-hosting in php + Gamerserver in Win7 ultimate @ home,,
what to do?? i am confused!!!!
Put the PHP file in your web folder(htdocs) and open it with your browser(http://localhost/query.php). Ofcause you'll need to make some changes to what it shall query
I thought of the localhost, but how to make it online, i think there are some Microsoft tools i have to install, unfortunately i am not familiar with them
Open your port 80 and allow whatever webserver you're using to go through your firewall.
how to?
& do i have to do portforwarding for the game as well??
and what about the safety measurement?
Do i need to do some actions to be in the safe side, to keep hackers away from my network
Just like you would open your game ports. But if it is LAN only you won't need to portforward anything at all.
Safety is fine. Just don't run a FTP server without encrypted data. EDIT: Or anything else!
Posts: 18
Threads: 2
Joined: May 2010
Reputation:
0
Thanks realchamp for ur help
i will give it a shot
Posts: 46
Threads: 11
Joined: Dec 2007
Reputation:
0
I'm trying to intergrate this as part of a php web panel, and want to display the current status of the server (online/offline/updating). I'm trying to combine this with a server status script I found, but it returns the status as online even if the server isn't responding
PHP Code:
if ($sock = @fsockopen($_ip, $_port, $num, $error, 5)) {
echo "".$q['name']."<br/>"; echo "$_ip:$_port"; echo '<b><FONT COLOR=lime>Online</b></FONT><br>'; echo "Map: ".$q['map']."<br/>"; echo "Players: ".$q['players'].""; echo "/"; echo "".$q['max']."<br/>";
}else{ echo "$_ip:$_port<br>"; echo "<FONT COLOR='RED'>Server Offline</FONT><br>"; }
I think I'm missing something really simple, but it displays the first argument even if the server isn't responding...any ideas?
Posts: 7,778
Threads: 176
Joined: May 2008
Reputation:
83
What does $sock contain and you probably miss a = operator in your if statement
Posts: 46
Threads: 11
Joined: Dec 2007
Reputation:
0
05-26-2010, 07:38 AM
(This post was last modified: 05-26-2010, 07:38 AM by Nomarky.)
Ahh, I took that line from a simple server query script I found somewhere:
PHP Code:
<?php $ip = "xx.xx.xx.xx"; $port = "27015"; if ($sock = @fsockopen($ip, $port, $num, $error, 5)) echo '<B><FONT COLOR=lime>Online</b></FONT>'; else{ echo '<B><FONT COLOR=red>Offline</b></FONT>'; fclose($sock); } ?>
I'm just trying to add the server query into that framework I guess.
Posts: 7,778
Threads: 176
Joined: May 2008
Reputation:
83
So if the server is online you want the stat / status?
Posts: 46
Threads: 11
Joined: Dec 2007
Reputation:
0
(05-26-2010, 08:06 AM)realchamp Wrote: So if the server is online you want the stat / status?
Yeah, exactly that
Posts: 7,778
Threads: 176
Joined: May 2008
Reputation:
83
05-26-2010, 08:20 AM
(This post was last modified: 04-25-2015, 09:54 AM by realchamp.)
Wrote this for you, feel feel to use it
PHP Code:
<?php class query { public function query_source($address) { $array = explode(":", $address);
$server['status'] = 0; $server['ip'] = $array[0]; $server['port'] = $array[1];
if (!$server['ip'] || !$server['port']) { exit("EMPTY OR INVALID ADDRESS"); }
$socket = @fsockopen("udp://{$server['ip']}", $server['port'], $errno, $errstr, 1);
if (!$socket) { return $server; }
stream_set_timeout($socket, 1); stream_set_blocking($socket, TRUE); fwrite($socket, "\xFF\xFF\xFF\xFF\x54Source Engine Query\x00"); $packet = fread($socket, 4096); @fclose($socket);
if (!$packet) { return $server; }
$header = substr($packet, 0, 4); $response_type = substr($packet, 4, 1); $network_version = ord(substr($packet, 5, 1));
if ($response_type != "I") { exit("NOT A SOURCE SERVER"); }
$packet_array = explode("\x00", substr($packet, 6), 5); $server['name'] = $packet_array[0]; $server['map'] = $packet_array[1]; $server['game'] = $packet_array[2]; $server['description'] = $packet_array[3]; $packet = $packet_array[4]; $app_id = array_pop(unpack("S", substr($packet, 0, 2))); $server['players'] = ord(substr($packet, 2, 1)); $server['playersmax'] = ord(substr($packet, 3, 1)); $server['bots'] = ord(substr($packet, 4, 1)); $server['status'] = 1; $server['dedicated'] = substr($packet, 5, 1); $server['os'] = substr($packet, 6, 1); $server['password'] = ord(substr($packet, 7, 1)); $server['vac'] = ord(substr($packet, 8, 1));
return $server; } } $query = new query; $link = "something.tld"; $port = 1337; if(fsockopen($link, $port, $num, $error, 5)) { $server = $query->query_source($link . ":" . $port); echo "Server is online and running " . $server['map'] . " with " . $server['players'] . " / " . $server['playersmax']; } else { echo "Server is not active"; die(); } ?>
Posts: 46
Threads: 11
Joined: Dec 2007
Reputation:
0
05-26-2010, 11:37 PM
(This post was last modified: 05-27-2010, 12:12 AM by Nomarky.)
Great, I'll test it out
Ok, the problem I have is that if the server is crashed/not responding it still shows as online, with blank map and players:
Online
Map:
Players: /
But if I close the server down, it correctly shows as offline. Is there a way to add a check so that the server shows as online only if it responds to the query? Or better yet shows as 'Not Responding'?
Posts: 7,778
Threads: 176
Joined: May 2008
Reputation:
83
(05-26-2010, 11:37 PM)Nomarky Wrote: Great, I'll test it out
Ok, the problem I have is that if the server is crashed/not responding it still shows as online, with blank map and players:
Online
Map:
Players: /
But if I close the server down, it correctly shows as offline. Is there a way to add a check so that the server shows as online only if it responds to the query? Or better yet shows as 'Not Responding'?
It shouldn't show up as "online" if it is down, if the server is crashed it should show up as "offline".
Posts: 46
Threads: 11
Joined: Dec 2007
Reputation:
0
(05-27-2010, 04:03 AM)realchamp Wrote: It shouldn't show up as "online" if it is down, if the server is crashed it should show up as "offline".
If the server has crashed and the console is frozen, it still shows the status as online:
Server is online and running with /
It only shows as offline I stop the server.
Posts: 7,778
Threads: 176
Joined: May 2008
Reputation:
83
(05-27-2010, 08:31 AM)Nomarky Wrote: (05-27-2010, 04:03 AM)realchamp Wrote: It shouldn't show up as "online" if it is down, if the server is crashed it should show up as "offline".
If the server has crashed and the console is frozen, it still shows the status as online:
Server is online and running with /
It only shows as offline I stop the server.
Well the server is still running. But you could check werether if the amount of players is above 0. But if it is running and still working, it will show as offline.
|