added PHP master server
This commit is contained in:
30
web/master/ping.php
Normal file
30
web/master/ping.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
if (!($db = sqlite_open( 'openra.db', 0666, $e )))
|
||||
{
|
||||
echo 'Database error: ', $e;
|
||||
return;
|
||||
}
|
||||
|
||||
$addr = $_SERVER['REMOTE_ADDR'] . ':' . $_REQUEST['port'];
|
||||
$prune = 'DELETE FROM servers WHERE address = \'' . sqlite_escape_string( $addr ) . '\'';
|
||||
echo $prune . "\n\n";
|
||||
|
||||
sqlite_exec( $db, $prune );
|
||||
|
||||
$q = 'INSERT INTO servers VALUES ('.
|
||||
'\'' . sqlite_escape_string( $_REQUEST['name'] ) . '\', '.
|
||||
'\'' . sqlite_escape_string( $addr ) . '\', '.
|
||||
sqlite_escape_string( $_REQUEST['players'] ) . ', '.
|
||||
sqlite_escape_string( $_REQUEST['state'] ) . ', '.
|
||||
time() . ')';
|
||||
|
||||
echo $q;
|
||||
|
||||
if (!sqlite_exec( $db, $q ))
|
||||
{
|
||||
echo 'Error in query:' . sqlite_error_string( sqlite_last_error() );
|
||||
}
|
||||
|
||||
sqlite_close( $db );
|
||||
?>
|
||||
Reference in New Issue
Block a user