Показать сообщение отдельно

  #9  
Старый 26.10.2009, 20:28
N2kroot
Познающий
Регистрация: 25.10.2009
Сообщений: 54
С нами: 8707616

Репутация: 9
По умолчанию

PHP код:
<?php

if(!function_exists('getmicrotime'))
{
    function 
getmicrotime() 
    { 
        list(
$usec$sec) = explode(" "microtime()); 
        return ((float)
$usec + (float)$sec); 
    }
}
function 
serverInfo($ip$port)
{
    
$ip gethostbyname($ip);
    
$timeStart getmicrotime();
    
$fp fsockopen('udp://'.$ip$port);
    
stream_set_timeout($fp2); 
    if(
$fp
    { 
        
fwrite($fp,"\xFF\xFF\xFF\xFFTSource Engine Query\0\r");
        
$temp fread($fp4);
        
$status socket_get_status($fp); 
        if(
$status['unread_bytes']>0
        {
            
$temp fread($fp$status['unread_bytes']);
            
$server['ping'] = (int)((getmicrotime() - $timeStart)*1000);
            
$array = array(); 
            
$pos 0
            while(
$pos !== false
            { 
                
$pos2 strpos($temp"\0"$pos+1); 
                
$array[] = substr($temp$pos+1$pos2-$pos)."\n"
                
$pos $pos2
            }
            
$server['status'] = 'on';
            if( 
strpos($array[0], $ip) !== 0
            { 
                
$server['players'] = ord($array[5][0]); 
                
$server['maxplayers'] = ord($array[5][1]); 
                
$server['name'] = trim(substr($array[0], 1)); 
                
$server['map'] = trim($array[1]); 
                
$server['game'] = trim($array[2]);
            } 
            else 
            { 
                
$server['players'] = ord($array[5][0]); 
                
$server['maxplayers'] = ord($array[5][1]); 
                
$server['name'] = trim($array[1]); 
                
$server['map'] = trim($array[2]);
                
$server['game'] = trim($array[3]);
            }
            
$command pack("V", -1) . 'W';
            
fwrite($fp$commandstrlen($command));
            
$temp fread($fp1500);
            
$temp substr($temp5);
            
$lo = (ord($temp[1]) << 8) | ord($temp[0]);
            
$hi = (ord($temp[3]) << 8) | ord($temp[2]);
            
$data "\xFF\xFF\xFF\xFF\x55".pack("V", ($hi << 16) | $lo);
            
fwrite($fp$data);
            
$temp fread($fp5);
            
$status socket_get_status($fp);
            if(
$status['unread_bytes']>0
            {
                
$temp fread($fp$status['unread_bytes']);
                
$array = array();
                
$temp substr($temp1);
                for(
$i=1;$i<=$server['players'];$i++)
                {
                    
$temp substr($temp1);
                    
$pos strpos($temp"\0");
                    
$name substr($temp0$pos);
                    
$temp substr($temp$pos+1);
                    
$lo = (ord($temp[1]) << 8) | ord($temp[0]);
                    
$hi = (ord($temp[2]) << 8) | ord($temp[3]);
                    
$temp substr($temp4);
                    
$kills = ($hi << 16) | $lo;
                    
$f = @unpack("f1float"$temp);
                    
$temp substr($temp4);
                    
$time = (int)$f['float'];
                    if(
trim($name))
                        
$server['stats'][] = array("name" => $name"kills" => $kills,
                                                   
"time" => gmdate("H:i:s"$time));
                }
            }
        }
        else
            
$server['status'] = 'off';
    }
    return 
$server;
}

print_r(serverInfo("cs.otstrel.ru"27025));
?>
Вот скрипт снифает который кску,но я получаю массивные данные,а как мне их,к примеру,преобразовать в таблицу?
 
Ответить с цитированием