sdfssdfs o 192.168.1.AA pero cuando ingreso una ip con con caracteres combinados con numeros en un octeto ejemplo 192.168.1.1AA no puedo impedir que no me lo valide. A ver si me pueden ayudar aqui dejo el código completo
 Cita:   
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PING</title>
<script language="JavaScript" type="text/JavaScript" src="ping.js">
</script>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 250px;
margin-right: 0px;
margin-bottom: 0px;
}</style>
</head>
 
<body bgcolor="#000000">
 
<form name="formulario" id="formulario" action="ping.php" method="post" onSubmit="return validar(this);">
 
<table border="1" align="center" cellspacing="0" cellpadding="0">
<tr>
<td width="302" align="center">
<span style="color: white;"><strong>REALIZAR PING</strong></span>
</td>
</tr>
</table>
 
 
<table border="1" align="center" cellspacing="0" cellpadding="0">
<tr>
<td width="150" align="center">
<span style="color: blue;"><strong>INGRESE IP CPE:</strong></span><br>
</td>
<td width="150" align="center">
<input type="text" name="cpe" id="cpe">
</td>
</tr>
 
<tr>
<td width="150" align="center">
<span style="color: blue;"><strong>INGRESE IP VPN:</strong></span><br>
</td>
<td width="150" align="center">
<input type="text" name="vpn" id="vpn">
</td>
</tr>
 
<table border="1" align="center" cellspacing="0" cellpadding="0">
<tr>
<td width="302" align="center">
<input type="submit" name="PING" id="PING" value="Iniciar"/>
</td>
</tr>
</table>
 
</table>
</form>
</body>
</html>
 <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PING</title>
<script language="JavaScript" type="text/JavaScript" src="ping.js">
</script>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 250px;
margin-right: 0px;
margin-bottom: 0px;
}</style>
</head>
<body bgcolor="#000000">
<form name="formulario" id="formulario" action="ping.php" method="post" onSubmit="return validar(this);">
<table border="1" align="center" cellspacing="0" cellpadding="0">
<tr>
<td width="302" align="center">
<span style="color: white;"><strong>REALIZAR PING</strong></span>
</td>
</tr>
</table>
<table border="1" align="center" cellspacing="0" cellpadding="0">
<tr>
<td width="150" align="center">
<span style="color: blue;"><strong>INGRESE IP CPE:</strong></span><br>
</td>
<td width="150" align="center">
<input type="text" name="cpe" id="cpe">
</td>
</tr>
<tr>
<td width="150" align="center">
<span style="color: blue;"><strong>INGRESE IP VPN:</strong></span><br>
</td>
<td width="150" align="center">
<input type="text" name="vpn" id="vpn">
</td>
</tr>
<table border="1" align="center" cellspacing="0" cellpadding="0">
<tr>
<td width="302" align="center">
<input type="submit" name="PING" id="PING" value="Iniciar"/>
</td>
</tr>
</table>
</table>
</form>
</body>
</html>
Código PHP:
   <?php
if (isset ($_POST))
{
  foreach ($_POST as $inputName  => $value_)
  {
   $$inputName = $value_;
  }
}
else
{
  foreach ($HTTP_POST_VARS as $inputName  => $value_)
  {
   $$inputName = $value_;
  }
}
 
if (isset ($_GET))
{
  foreach ($_GET as $inputName  => $value_)
  {
   $$inputName = $value_;
  }
}
else
{
  foreach ($HTTP_GET_VARS as $inputName  => $value_)
  {
   $$inputName = $value_;
  }
}
 
$comando = "c:\windows\system32\ping " . $cpe;
$salida = shell_exec($comando);
$JOIN=split("\n",$salida);
 
$comando2 = "c:\windows\system32\ping " . $vpn;
$salida2 = shell_exec($comando2);
$JOIN2=split("\n",$salida2);
 
//echo "$comando2";
echo "<html>";
echo "<body bgcolor=\"#000000\" text=\"#FFFFFF\" link=\"#FFFFFF\" vlink=\"#EEEEEE\" LINK=\"#EEEEEE\" background=\"\">";
 
$ip = $_SERVER["REMOTE_ADDR"]; 
echo "<b><h2>Su Dirección IP es :". $ip." </h2>";
$color = "";
 
if (substr_count ($salida,"Respuesta") > 0)
{
  $color = "green";
  /*
     echo "<font color='green'> PING A " . $cpe. " EXITOSO </font><br>";
 
     for($i=0; $i<sizeof($JOIN); $i++)
     {
        echo "<font color='green'>" . $JOIN[$i]. "</font><br>";
        //ob_flush();
        flush();
        usleep(300000);
     }
     */
}
else
{  $color = "red";
  /*
     echo "<font color='red'> PING A " . $cpe. " FALLIDO </font><br>";
     
     for($i=0; $i<sizeof($JOIN); $i++)
     {
        echo "<font color='red'>" . $JOIN[$i]. "</font><br>";
        //ob_flush();
        flush();
        usleep(300000);
     }     
     */
}
 
$color_1 = "";
 
if (substr_count ($salida2,"Respuesta") > 0)
{$color_1 = "green";
  /*
     echo "<font color='green'> PING A " . $vpn. " EXITOSO </font><br>";
 
   for($i=0; $i<sizeof($JOIN2); $i++)
     {  
        echo "<font color='green'>" . $JOIN2[$i]. "</font><br>";
        //ob_flush();
        flush();
        usleep(300000);
     }
     */
}
else
{
  $color_1 = "red";
  /*
   echo "<font color='red'> PING A " . $vpn. " FALLIDO </font><br>";
   
   for($i=0; $i<sizeof($JOIN2); $i++)
     {  
        echo "<font color='red'>" . $JOIN2[$i]. "</font><br>";
        //ob_flush();
        flush();
        usleep(300000);
     }
     */
}
 
 
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" >";
 
   for($i=0; $i < 12; $i++)
     {
       echo "<tr>";
       
       if ($i == 1)
       {
        echo "<td width=\"50%\">";
        echo "<font color='yellow'>" . $JOIN[$i]. "</font><br>"; 
        echo "</td>";
        echo "<td width=\"50%\">";
        echo "<font color='yellow'>" . $JOIN2[$i]. "</font><br>"; 
        echo "</td>";
       }
       else
       {
        if (isset ($JOIN[$i]))
        {
        echo "<td width=\"50%\">";         
        echo "<font color='".$color."'>" . $JOIN[$i]. "</font><br>";
        echo "</td>";
        }
        else
        {
        echo "<td width=\"50%\">";         
         echo "<font color='".$color."'></font><br>";       
        echo "</td>";
        }
     
 
        if (isset ($JOIN2[$i]))
        {
        echo "<td width=\"50%\">";
        echo "<font color='".$color_1."'>" . $JOIN2[$i]. "</font><br>";         
        echo "</td>";
        }
        else
        {
        echo "<td width=\"50%\">";
         echo "<font color='".$color_1."'></font><br>";       
        echo "</td>";
        }
       }
       
       echo "</tr>";
       flush();
       usleep(300000); 
     }
 
echo "</table>";
 
 
  //meter en tablas
  //Volver a tirar el mismo test
    
//echo $salida
echo "</body></html>";
?>
 
<form name="ping" id="ping" action="index.php" method="post">
<input type="hidden" name="$vpn" id="$vpn" ><br>
<input type="hidden" name="$cpe" id="$cpe"><br>
<input type="submit" name="volver" value="Nuevo Ping"><br>
</form>    Cita:   
 function validar()
{
with (document.forms['formulario'])
{
if(cpe.value == "")
{
alert("Ingrese la ip CPE");
cpe.focus();
return false;
}
else
{
partes=cpe.value.split('.');
 
if (partes.length != 4)
{
alert('Ip no valida, Faltan o hay demasiados Valores');
cpe.focus();
return false;
}
else
{
for (i = 0; i < 4; i++)
{
miInteger = parseInt(partes[i]);
 
if (isNaN (miInteger))
{
alert('No puede ingresar caracteres');
cpe.focus();
return false;
}
else
{
if (partes[i] > 255 || partes[i].length == 0)
{
alert('No puede ingresar valores mayores a 255');
cpe.focus();
return false;
}
}
}
//return true;
}
}
 
if(vpn.value == "")
{
alert("Ingrese la ip CPE");
vpn.focus();
return false;
}
else
{
partes=vpn.value.split('.');
 
if (partes.length != 4)
{
alert('Ip no valida, Faltan o hay demasiados Valores');
vpn.focus();
return false;
}
else
{
for (i = 0; i < 4; i++)
{
miInteger = parseInt(partes[i]);
 
if (isNaN (miInteger))
{
alert('No puede ingresar caracteres');
vpn.focus();
return false;
}
else
{
if (partes[i] > 255 || partes[i].length == 0)
{
alert('No puede ingresar valores mayores a 255');
vpn.focus();
return false;
}
}
}
return true;
}
}
}
}
 {
with (document.forms['formulario'])
{
if(cpe.value == "")
{
alert("Ingrese la ip CPE");
cpe.focus();
return false;
}
else
{
partes=cpe.value.split('.');
if (partes.length != 4)
{
alert('Ip no valida, Faltan o hay demasiados Valores');
cpe.focus();
return false;
}
else
{
for (i = 0; i < 4; i++)
{
miInteger = parseInt(partes[i]);
if (isNaN (miInteger))
{
alert('No puede ingresar caracteres');
cpe.focus();
return false;
}
else
{
if (partes[i] > 255 || partes[i].length == 0)
{
alert('No puede ingresar valores mayores a 255');
cpe.focus();
return false;
}
}
}
//return true;
}
}
if(vpn.value == "")
{
alert("Ingrese la ip CPE");
vpn.focus();
return false;
}
else
{
partes=vpn.value.split('.');
if (partes.length != 4)
{
alert('Ip no valida, Faltan o hay demasiados Valores');
vpn.focus();
return false;
}
else
{
for (i = 0; i < 4; i++)
{
miInteger = parseInt(partes[i]);
if (isNaN (miInteger))
{
alert('No puede ingresar caracteres');
vpn.focus();
return false;
}
else
{
if (partes[i] > 255 || partes[i].length == 0)
{
alert('No puede ingresar valores mayores a 255');
vpn.focus();
return false;
}
}
}
return true;
}
}
}
}
 
 
