Ver Mensaje Individual
  #9 (permalink)  
Antiguo 23/03/2009, 12:55
Avatar de farra
farra
 
Fecha de Ingreso: marzo-2008
Ubicación: Aqui estoy
Mensajes: 574
Antigüedad: 17 años
Puntos: 20
Respuesta: Quiero que mi sitio le haga un ping a google cuando hay una noticia nueba

bue... aca te pongo con un formulario para que puedas practicar y veas mas facilmente como es que funciona..

le agregue una validacion por si haces publica la pagina para que no te caguen el server...

Código PHP:
<?php 
function FunVerificarTipo($dato){
    
$valores 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890.';
    
$bolean true;
    
$len_dato strlen($dato);            
    for (
$m=0;$m<$len_dato;$m++) {
        if (
strpos($valores,$dato{$m}) === false) {
            
$bolean false;
            break;
        }                
    }
    if (
$bolean) {
        return 
$dato;
    }else{
        return 
"";
    }
}

function 
validaweb($web){
$web=htmlentities($_GET['web']);
$web=substr($web030);
$reemplazar=array("http://","https://");
$por=array("","");
$web=str_replace($reemplazar,$por,$web);
$dominio=explode("/",$web);
$web=$dominio[0];
$web=FunVerificarTipo($web);
return 
$web;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<form id="form1" name="form1" method="get" action="">
  <label>
 IP / URL: <input name="web" type="text" value="<?php if(trim($_GET['web']) != ""){   echo htmlentities($_GET['web']); } ?>" size="50" maxlength="50" />
  </label>
  <label>
  <input type="submit" name="Submit" value="Enviar" />
  </label>
</form>
<strong>Dominio/IP:</strong> 
<em>
<?php if (validaweb($web) != ""){ echo validaweb($web); }else{ echo "La url/ip que escribio no es valido..."; }?>
</em><br /><br /><hr /><br />
<div style="font-family:Courier New, Courier, monospace; color:#EEEEEE; background-color:#000000;  font-size:14px;">
<div style="margin:15px;">
<?php
if (validaweb($web) != ""){
 
$web=validaweb($_GET['web']);
$comando exec('ping '.$web$retval);


foreach (
$retval as $lineas){
echo 
htmlentities($lineas).'<br />';
}

}
?><blink>_</blink><br /><br /></div>
</div>
</body>
</html>
__________________
Firma:
Es mas dificil para el mono entender que el hombre desciende de el....

PD: Siempre doy karma al que me da una buena respuesta... ;0)

Última edición por farra; 23/03/2009 a las 13:27