<?
if($Action == "" )
{
?>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="FormDSN" method="post" action="<?="$PHP_SELF?Action=Go"?>">
  Ping
  <input type="text" name="PingDNS">
  <input type="submit" name="Submit" value="Go-&gt;">
</form>
<?
}
if($Action == 'Go')
{
?>
<html>
<head>
<title>PingDSN</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
a.dos:link{font-size: 9pt;text-decoration: underline ; color: #cccccc}
a.dos:hover {font-size: 9pt;text-decoration: underline ; color: #cccccc}
a.dos:active {font-size: 9pt;text-decoration: underline ; color: #cccccc}
a.dos:visited {font-size: 9pt;text-decoration: underline ; color: #cccccc}
a.windows:link{text-decoration: underline ; color: #FF0066}
a.windows:hover {text-decoration: underline ; color: #FF0066}
a.windows:active{text-decoration: underline ; color: #FF0066}
a.windows:visited {text-decoration: underline ; color: #FF0066}
td{font-size: 9pt; FONT-FAMILY:Arial, Helvetica, sans-serif}
-->
</style>
</head><body bgcolor="#FFFFFF" text="#000000">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
  <tr>
    <td valign="top" bgcolor="#6d93e1">
      <table width="100%" border="0" cellspacing="1" cellpadding="5" bgcolor="#000000">
        <tr>
          <td bgcolor="#92afec" align="center"><font color="#FF0066" face="haettenschweiler" size="7">Ping</font></td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td align="left" valign="top" bgcolor="#000000">
      <pre><font color="#CCCCCC">Langwan Crazy Programmer Ping [Version 0.0.1]
&copy; Copyright 2000-20000 Langwan Crazy Programmer
<?
exec("ping $PingDNS", $Info);
for($i = 0; $i < count($Info); $i++)
{
    echo "$Info[$i]\n";
}
?>
</font></pre>
    </td>
  </tr>
</table>
</body>
</html>
<?
}
?>
版权是langwan的。你可以去www.langwan.com看看。挺不错的一些冬冬。

解决方案 »

  1.   

    www.lanwan.com打不开啊,是不是写错了,请你看看好吗,给我一个正确的,谢谢
      

  2.   

    <?php  $ip = "192.168.0.1";
      exec("ping $ip", $arr);  print("<xmp>");
      print_r($arr);?>
      

  3.   

    谢谢红河(ynredriver),想冒昧的问你,你是云南红河洲的吗,我是从你的名字猜想的,不知道对不对,再次感谢:)
      

  4.   

    当然也要谢谢zairwolf,从你给我的源代码上学到的很多,我的感激如滔滔江水连绵不绝,呵呵:)
      

  5.   

    上面的程序都只是假借PHP的外壳, 事实上都是外部调用Ping程序, 将结果输出罢了..
      

  6.   

    老虎哥哥,是不是
    exec("ping $PingDNS", $Info);
    这一句最关键???请指教,谢谢
      

  7.   

    lalazhou(周舟) 你猜对啦!
    我就是来自云南省红河州的:)
      

  8.   

    我还想请教大家的是我怎么配置我的GD图形库啊,我已经把 ";extension=php_gd.dll"前的分号删除掉了,它提示我找不到gd库文件,我不知道该怎么办了,向大家求救,help me!!!
      

  9.   

    我现在已经把GD库配置好了,用phpinfo可以看到GD库已是可用的了,但是我写了以下代码,它却提示我错误信息,很是疑惑啊,请大家指点:
    <HTML>
    <HEAD>
    <TITLE>建立图形</TITLE>
    </HEAD>
    <BODY>
    <?
    header("Content-type:image/gif");
    $image=imagecreate(200,200);
    $red=imagecolorallocate($image,255,0,0);
    $blue=imagecolorallocate($image,0,0,255);
    imagefill($image,0,0,$red);
    imagerectangle($image,30,30,70,70,$blue);
    imagecolortransparent($image,$blue);
    imagegif($image);
    imagedestroy($image);
    ?>
    </BODY>
    </HTML>它提示我:Warning: Cannot add header information - headers already sent by (output started at c:/php/test1/red.php:6) in c:/php/test1/red.php on line 7Warning: ImageGif: No GIF support in this PHP build in c:/php/test1/red.php on line 14
    我不知道错误出现在哪里,请指教,谢过:)
      

  10.   

    to lalazhou(周舟):
    现在涉及到GIF版权问题,PHP早已不支持GIF了。可以用JPG或PNG格式,效果一样。
      

  11.   

    gif,php已经不支持啦,但是你上面所出现的问题,还有另一个原因,就是在header之前不能输出任何的东西啊~~~去掉前面的那些html的文字,就不会有那个warning了
      

  12.   

    <?php // created by joe lumbroso 
    // see some other good php3 scripts 
    // goto http://www.dtheatre.com/scripts echo "<font color=\"red\"><blink><b>Pinging</b></blink></font><br>"; 
    $to_ping = "dtheatre.com"; 
    $count = 3; 
    $psize = 65; 
    echo " Please be patient, this can take a few moments...\n<br><br>"; 
    flush(); while (1) { 
    ?> 
    <pre> 
    <? 
    exec("ping -c $count -s $psize $to_ping", $list); 
    for ($i=0;$i < count($list);$i++) { 
    print $list[$i]."\n"; 

    ?> 
    </pre> 
    <? 
    flush(); 
    sleep(3); 

    ?> 
      

  13.   

    谢谢大家对我的指教,thanks:)
    再问个问题:我如何在exec("ping $PingDNS", $Info);执行后取得一个返回值,这个返回值能够标记它是否ping通或没有ping通,exec只能返回外部程序执行后传回的最后一行啊,help me!!!!
      

  14.   

    to feyge:我把它改成jpg格式的问题就解决了,thanks!
      

  15.   

    to a_sr:我把header前的删除了就ok了,谢谢,但是怎么我在书上看的却是:在标头header与html文件之间需空一行分隔,我空了也是错的啊,奇怪,书上写错了还是我理解有问题。
      

  16.   

    呵呵.好象是header前是不准有什么空格的
      

  17.   

    exec("ping $PingDNS", $Info);中的info的这个数组中从$Info[3]-[6]是表示他通不通.
    <?
    exec("ping 10.10.1.242", $Info);
    if($Info[3]=='Request timed out.') {
    print "不通";
    }
    ?>
    你看这样行吗.呵呵.
      

  18.   

    [重要]
    搂主的问题是 :“如何用PHP实现我的本机与在同一局域网中的另外一台机子(ip已知)ping的命令”。
    首先:php只能调用服务器上的系统命令,就是只能实现服务器到另一台
          机子的ping,如果搂主的机器不是服务器那么
          你说的功能php将无法实现。
    其次:ping命令在unix(linux)下得到的结果和windows下ping的结果不一样。
      

  19.   

    如果搂主的机子装了php+web服务器并且是windows操作系统为什么不直接ping?