MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.
[COLLECTION] PHP stuff for game servers!
Thread Rating:
2 Vote(s) - 5 Average
1
2
3
4
5
[COLLECTION] PHP stuff for game servers!
Posts: 7,779
Threads: 177
Joined: May 2008
Reputation:
83
12-24-2009, 03:56 AM
(This post was last modified: 04-25-2015, 09:52 AM by realchamp .)
Hello I'd like to share all these with you
!!
Announcement All these scripts are free of charge and can be used in your own projects.
Convert SteamID to Steam Community ID:
PHP Code:
<?php
function steamid ( $steamid ) {
$id = explode ( ":" , $steamid );
$id [ 2 ] = $id [ 2 ] * 2 ;
$id [ 2 ] = $id [ 2 ] + $id [ 1 ];
$ro = "765611979" ;
$ra = $id [ 2 ] + 60265728 ;
$final = $ro . $ra ;
$url = "http://steamcommunity.com/profiles/" . $final ;
return $url ;
}
echo steamid ( "STEAM_0:1:12345678" ); // Your SteamID!
steamid.php (Size: 334 bytes / Downloads: 92)
Game queries for Counter-Strike: Source, Day of Defeat: Source, Team Fortress 2, Left 4 Dead, Left 4 Dead 2, GarrysMod, Half-Life 2(plus all sub mods) and most of HL1 engine games.
PHP Code:
<?php
// Thanks to Richard Perry.
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 = query_source ( "127.0.0.1:27015" );
echo $query [ 'game' ];
query.php (Size: 2.46 KB / Downloads: 252)
More to come,
- realchamp.
Posts: 7,779
Threads: 177
Joined: May 2008
Reputation:
83
Added some game queries
Have fun!
Posts: 1,655
Threads: 38
Joined: Apr 2008
Reputation:
20
Nice job! I'll have to use some of this stuff in the future!
Posts: 7,779
Threads: 177
Joined: May 2008
Reputation:
83
(12-24-2009, 11:54 AM) Beaverbeliever Wrote: Nice job! I'll have to use some of this stuff in the future!
Thanks still more to come
Posts: 24
Threads: 4
Joined: Jun 2009
Reputation:
0
Hey realchamp what would I need to change in that query script to be able to get all the player names in the server?
Posts: 4
Threads: 0
Joined: Apr 2010
Reputation:
0
Hey champ,
I was wondering im getting a t_echo error when i use the query script, could you help me out if possible?
Thanks,
Dan
Posts: 7,779
Threads: 177
Joined: May 2008
Reputation:
83
Post your code please
Posts: 4
Threads: 0
Joined: Apr 2010
Reputation:
0
Code:
<html>
<body>
<?php
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;
}
?>
<?php
$query = query_source("127.0.0.1:27015")
echo $query['game'];
?>
</body>
</html>
Posts: 24
Threads: 4
Joined: Jun 2009
Reputation:
0
04-02-2010, 07:10 AM
(This post was last modified: 04-02-2010, 07:12 AM by Rambomst .)
$query = query_source("127.0.0.1:27015") requires a ; at the end so it should look like
PHP Code:
<?php
$query = query_source ( "127.0.0.1:27015" );
echo $query [ 'game' ];
?>
It seems realchamp also forgot to put that in
Posts: 7,779
Threads: 177
Joined: May 2008
Reputation:
83
Edited
Posts: 4
Threads: 0
Joined: Apr 2010
Reputation:
0
holy shit thanks alot mate you rule i dident even notice that.
Posts: 18
Threads: 2
Joined: May 2010
Reputation:
0
Posts: 7,779
Threads: 177
Joined: May 2008
Reputation:
83
Install them? Just run the script on your webserver with PHP 5.0 <= installed.
Posts: 18
Threads: 2
Joined: May 2010
Reputation:
0
(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!!!!
Posts: 7,779
Threads: 177
Joined: May 2008
Reputation:
83
(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
Users browsing this thread: 1 Guest(s)