Untitled
By: a guest | Mar 21st, 2010 | Syntax:
None | Size: 1.29 KB | Hits: 43 | Expires: Never
<?php
function OneOrTwo ( $One, $Two )
{
if ( $One == NuLL OR $One == 0 OR !isset ($One) )
return $Two;
else
return $One;
}
$RefreshTime = 3;
$age = time () - filemtime( 'lastcheck.xml' );
$TimeToDelete = ( mktime ()-604800 );
if ( $age > $RefreshTime )
{
touch('lastcheck.xml');
include ( '../../mysql_config.php' );
include ( '../../includes/OTSChecker.class.php' );
// ==== USUWA STARE OTSY
$SearchQuery = $mysqli -> query ( 'SELECT * FROM `list_ots` WHERE `admin` = "0"' );
$OTServ = NuLL;
while ($Row = $SearchQuery -> fetch_assoc())
{
$OTServ = new OTSChecker ( $Row['ip'] , $Row['port'] , $Row['client'] );
$OTServ -> SocketTimeOut( 1 );
$OTServ -> GetData();
if ( $OTServ -> Status() == 'Online')
{
$mysqli -> query ( 'UPDATE `list_ots` SET `players`="' . OneOrTwo( $OTServ -> GetCountOfPlayersOnline() , $Row['players'] ) . '", `rec`="' . OneOrTwo( $OTServ -> GetMaxPlayersRecord() , $Row['rec'] ) . '", `maxplayers`="' . OneOrTwo( $OTServ -> GetMaxPlayersCount(), $Row['maxplayers'] ) . '", `status` = "1", `lastcheck` = "' .mktime(). '" WHERE `id`="' .$Row['id']. '"' );
} else {
$mysqli -> query ( 'UPDATE `list_ots` SET `status` = "0", `players` = "0", `maxplayers` = "0" WHERE `id`="' .$Row['id']. '"' );
}
}
}
?>