Free monitoring
#4

PHP код:
<?
$result
=true;
$ip='*.*.*.*';
$port='7777';
function 
monitor_samp($ip$port$request) {
    
$fp = @fsockopen("udp://$ip"$port$errno$errstr1);
    if (!
$fp) return FALSE;
    
stream_set_timeout($fp10); 
    
stream_set_blocking($fptrue); 
    
$ip_array   explode("."$ip);
    
$challenge  'SAMP';
    
$challenge .= chr($ip_array[0]).chr($ip_array[1]).chr($ip_array[2]).chr($ip_array[3]);
    
$challenge .= chr($port      "\xFF");
    
$challenge .= chr($port >> "\xFF");
    if (
$request == "info"$challenge .= "i"
    if (
$request == "settings"$challenge .= "r";
    if (
$request == "players"$challenge .= "d"
    
fwrite($fp$challenge);
    
$buffer fread($fp4096);
    
fclose($fp);
    if (!
trim($buffer)) return FALSE;  
    if (!
substr($buffer04) == "SAMP") return FALSE
    
$buffer substr($buffer11); 
    if (
$request == "info") {
        
$data['password'] = ord(substr($buffer01));
        
$data['players'] = (ord(substr($buffer21))==0) ? ord(substr($buffer12)) : 256+ord(substr($buffer12));
        
$data['maxplayers'] = (ord(substr($buffer41))==0) ? ord(substr($buffer32)) : 256+ord(substr($buffer32));
        
$buffer substr($buffer5);    
        
$data_length ord(substr($buffer04));   
        
$data['name'] = substr($buffer4,  $data_length); 
        
$buffer substr($buffer$data_length); 
        
$data_length ord(substr($buffer04));           
        
$data['gametext'] = substr($buffer4,  $data_length); 
        
$buffer substr($buffer$data_length); 
        
$data_length ord(substr($buffer04));           
        
$data['map'] = substr($buffer4,  $data_length); 
        
$data['ip'] = $ip;
        
$data['port'] = $port;
        return 
$data;
    }
    if (
$request == "settings") {
        
$setting_count ord(substr($buffer02));             
        
$buffer        =     substr($buffer2);
        if (
$setting_count 128) return FALSE
        for (
$i=0$i<$setting_count$i++) {
            if (!
$buffer) return FALSE;
            
$data_length ord(substr($buffer01));            
            
$key substr($buffer1,  $data_length); 
            
$buffer substr($buffer$data_length);
            
$data_length ord(substr($buffer01));            
            
$value substr($buffer1,  $data_length); 
            
$buffer substr($buffer$data_length);
            
$setting[$key] = $value;
         }
         return 
$setting;
     }
    if (
$request == "players") {
        
$player_count ord(substr($buffer02));                          
        
$buffer       substr($buffer2); 
        if (
$player_count 128) return FALSE;
        for (
$i=1$i<=$player_count$i++) {
            if (!
$buffer) return FALSE;
            
$player[$i]['pid'] = ord(substr($buffer01));          
            
$buffer substr($buffer1);              
            
$data_length ord(substr($buffer01));           
            
$player[$i]['name'] = substr($buffer1,  $data_length); 
            
$buffer substr($buffer$data_length);
            list(,
$player[$i]['score']) = unpack("s"substr($buffer04));    
            
$buffer substr($buffer4);
            
$player[$i]['ping'] = ord(substr($buffer04));         
            
$buffer substr($buffer4);             
        }
        return 
$player;
    }
}
if(!
$g=monitor_samp($ip$port"players")) $result=false;
if(
$result){
$f=monitor_samp($ip$port"info");
print 
"<center>".'Игроков:'.$f['players'].'/'.$f['maxplayers']."<br><table border=1 cellspacing=0 cellpadding=0 style='padding: 0px; margin: 0px; width: 100%;'><tr><td><b>Ник</b></th><th><b>Уровень</b></td></tr>";
for(
$i=1$i<501$i++){
if(!
$g[$i]) continue;
$name=$g[$i]["name"];
$score=$g[$i]["score"];
print 
"<tr><td>".$name."</td><td>".$score." уровень </td></tr>";
}
print 
'</table></center>';
}
?>
Reply


Messages In This Thread
Free monitoring - by [CripZ]SERCH - 25.10.2010, 17:02
Re: Free monitoring - by Фархад - 26.10.2010, 16:51
Re: Free monitoring - by [CripZ]SERCH - 26.10.2010, 19:40
Re: Free monitoring - by xJester - 27.10.2010, 03:09
Re: Free monitoring - by Romanius - 27.10.2010, 10:23
Re: Free monitoring - by xJester - 27.10.2010, 11:29
Re: Free monitoring - by [CripZ]SERCH - 27.10.2010, 14:30
Re: Free monitoring - by [CripZ]SERCH - 27.10.2010, 14:40
Re: Free monitoring - by xJester - 27.10.2010, 15:17
Re: Free monitoring - by ZaR - 27.10.2010, 16:27

Forum Jump:


Users browsing this thread: 1 Guest(s)