SRCDS Steam group


Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[COLLECTION] PHP stuff for game servers!
#16
(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 Toungue

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 Sad
Reply
#17
(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 Toungue

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 Sad

Open your port 80 and allow whatever webserver you're using to go through your firewall.
Reply
#18
(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 Toungue

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 Sad

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 Sad
Reply
#19
(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 Toungue

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 Sad

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 Sad

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. Wink EDIT: Or anything else!
Reply
#20
Thanks realchamp for ur help Smile

i will give it a shot
Reply
#21
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$error5))
{

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?
Reply
#22
What does $sock contain and you probably miss a = operator in your if statement Smile
Reply
#23
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$error5))
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.
Reply
#24
So if the server is online you want the stat / status?
Reply
#25
(05-26-2010, 08:06 AM)realchamp Wrote:  So if the server is online you want the stat / status?

Yeah, exactly that
Reply
#26
Wrote this for you, feel feel to use it Smile
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$errstr1);

        if (!
$socket) { return $server; }

        
stream_set_timeout($socket1);
        
stream_set_blocking($socketTRUE);
        
fwrite($socket"\xFF\xFF\xFF\xFF\x54Source Engine Query\x00");
        
$packet fread($socket4096);
        @
fclose($socket);

        if (!
$packet) { return $server; }

        
$header                substr($packet04);
        
$response_type         substr($packet41);
        
$network_version       ord(substr($packet51));

        if (
$response_type != "I") { exit("NOT A SOURCE SERVER"); }

        
$packet_array          explode("\x00"substr($packet6), 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($packet02)));
        
$server['players']     = ord(substr($packet21));
        
$server['playersmax']  = ord(substr($packet31));
        
$server['bots']        = ord(substr($packet41));
        
$server['status']      = 1;
        
$server['dedicated']   =     substr($packet51); 
        
$server['os']          =     substr($packet61); 
        
$server['password']    = ord(substr($packet71)); 
        
$server['vac']         = ord(substr($packet81)); 

        return 
$server;
    }
}
    
$query = new query;
    
$link "something.tld";
    
$port 1337;
    if(
fsockopen($link$port$num$error5)) {
        
$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();
    }
  
?>
Reply
#27
Great, I'll test it out Smile
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'?
Reply
#28
(05-26-2010, 11:37 PM)Nomarky Wrote:  Great, I'll test it out Smile
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".
Reply
#29
(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.
Reply
#30
(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.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)