全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1761|回复: 3

自动测试目标IP到本地的ping值 网页版

[复制链接]
发表于 2011-6-13 19:56:34 | 显示全部楼层 |阅读模式
有没有代码 ?会的贴一下
发表于 2011-6-14 10:52:03 | 显示全部楼层
看看这个行不
<?php
$register_globals = (bool) ini_get('register_gobals');
$system = ini_get('system');
$unix = (bool) $unix;
$win  = (bool)  $windows;
//
If ($register_globals)
{
   $ip = getenv(REMOTE_ADDR);
   $self = $PHP_SELF;
}
else
{
   $submit = $_GET['submit'];
   $count  = $_GET['count'];
   $host   = $_GET['host'];
   $ip     = $_SERVER['REMOTE_ADDR'];
   $self   = $_SERVER['PHP_SELF'];
};
// form submitted ?
If ($submit == "Ping!")
{
   // over count ?
   If ($count > $max_count)
   {
      echo 'Maximum for count is: '.$max_count;
      echo '<a href="'.$self.'">Back</a>';
   }
   else
   {
      // replace bad chars
      $host= preg_replace ("/[^A-Za-z0-9.-]/","",$host);
      $count= preg_replace ("/[^0-9]/","",$count);
      echo '<body bgcolor="#FFFFFF" text="#000000"></body>';
      echo("Ping Output:<br>");
      echo '<pre>';           
      //check target IP or domain
      if ($unix)
      {
         system ("ping -c$count -w$count $host");
         system("killall ping");// kill all ping processes in case there are some stalled ones or use echo 'ping' to execute ping without shell
      }
      else
      {
         system("ping -n $count $host");
      }
      echo '</pre>';
    }
}
else
{
    echo '<body bgcolor="#FFFFFF" text="#000000"></body>';
    echo '<p><font size="2">Your IP is: '.$ip.'</font></p>';
    echo '<form methode="post" action="'.$self.'">';
    echo '   Enter IP or Host <input type="text" name="host" value="'.$ip.'"></input>';
    echo '   Enter Count <input type="text" name="count" size="2" value="4"></input>';
    echo '   <input type="submit" name="submit" value="Ping!"></input>';
    echo '</form>';
    echo '<br><b>'.$system.'</b>';
    echo '</body></html>';
}
?>
发表于 2011-6-14 12:47:03 | 显示全部楼层
好用不
发表于 2011-6-14 12:55:26 | 显示全部楼层
谢谢了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-5-14 11:03 , Processed in 0.061560 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表