Ver Mensaje Individual
  #10 (permalink)  
Antiguo 23/11/2009, 11:41
Avatar de xalupeao
xalupeao
 
Fecha de Ingreso: mayo-2008
Ubicación: Santiago, Chile
Mensajes: 749
Antigüedad: 15 años, 11 meses
Puntos: 12
Respuesta: Consulta con esta funcion()

Código PHP:
function Ping($ip,$puerto,$juego){
    
    
//Variables globales
    
global $theme_default;

    
//Iniciamos  un enlace con el servidor
    
if($fp fsockopen("udp://".$ip$puerto)) 
    
    
#
    
$r=mysql_query("SELECT game_query FROM juegos WHERE game_id='".sql($juego)."'");
    
#
    
$QueryServer=mysql_fetch_object($r);
    
#
    
$QueryServer=mysql_real_escape_string((string) $QueryServer->game_query);
    
    
//Enviamos la Query Necesaria 
    
fwrite($fp$QueryServer); 

    
//Remove the junk headers sent back 
    
socket_set_timeout($fp,1,0); 
    
    
//trunkamos la salida =P
    
$junk fread($fp,5);
    
    
// Check to see if the server is running 
    
$status socket_get_status($fp);
    
    
    
//vemos si encontro el servidor y si escribio algo
    
$do 1;
    
$server_info"";

    while(
$do)
    {
        
$str_1 fread($fp,1);
        
$server_info .= $str_1;
        
$status socket_get_status($fp);
        if(
$status["unread_bytes"] == 0) {$do 0;}
    }

    if(
$server_info == "")
    
$ping='<img src="themes/'.$theme_default.'/images/down.gif" title="Servidor Offline" alt="Servidor Offline">';
    else
    
$ping='<img src="themes/'.$theme_default.'/images/up.gif" title="Servidor Online" alt="Servidor Online">';
    
fclose($fp);

    return 
$ping
}
# ---