<?
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->">
</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]
© 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看看。挺不错的一些冬冬。
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->">
</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]
© 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看看。挺不错的一些冬冬。
exec("ping $ip", $arr); print("<xmp>");
print_r($arr);?>
exec("ping $PingDNS", $Info);
这一句最关键???请指教,谢谢
我就是来自云南省红河州的:)
<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
我不知道错误出现在哪里,请指教,谢过:)
现在涉及到GIF版权问题,PHP早已不支持GIF了。可以用JPG或PNG格式,效果一样。
// 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);
}
?>
再问个问题:我如何在exec("ping $PingDNS", $Info);执行后取得一个返回值,这个返回值能够标记它是否ping通或没有ping通,exec只能返回外部程序执行后传回的最后一行啊,help me!!!!
<?
exec("ping 10.10.1.242", $Info);
if($Info[3]=='Request timed out.') {
print "不通";
}
?>
你看这样行吗.呵呵.
搂主的问题是 :“如何用PHP实现我的本机与在同一局域网中的另外一台机子(ip已知)ping的命令”。
首先:php只能调用服务器上的系统命令,就是只能实现服务器到另一台
机子的ping,如果搂主的机器不是服务器那么
你说的功能php将无法实现。
其次:ping命令在unix(linux)下得到的结果和windows下ping的结果不一样。