top
Loading...
怎么利用PHP去ping一個地址
<HTML>
<HEAD>
<TITLE>怎么利用PHP去ping一個地址</TITLE>
<!--
/***************************
* 孟憲會
* amxh@21cn.com
* http://elove.heha.net
* http://go.163.com/~colorweb
***************************
//-->

</HEAD>


<BODY BGCOLOR=#FFFFFF>


<FORM method='POST' action='<?php echo $PHP_SELF;?>'>

<table border=1 cellspacing=0 cellpadding=1 width="400" bgcolor=#808080>
<tr>
<th colspan=2 align=center>怎么利用PHP去ping一個地址</th>
</tr>
<tr>
<th bgcolor=#066b98>請輸入url或ip地址:</th>
<td><INPUT type='text' name='server' size='30' maxlength='30'></td>
</tr>
<tr>
<td>?lt;/td>
<td><INPUT type='submit' value='發送' Onclick="this.value='Pinging...'"></td>
</tr>
</table>
</FORM>

</BODY>
</HTML>

<?php

if(($server == '127.0.0.1') | | ($server == 'localhost') | | ($server == getenv("SERVER_ADDR"))) {

echo "<HR noshade size=1<br>";

echo "<font color=red size=1>Fuck Off!</font><br>";

echo "<HR noshade size=1<br>";
exit;

} else {
if($server =="") {

echo "<H2>請輸入url或ip地址:</H2>";
exit;
}

$ip = getenv("REMOTE_ADDR");
$hname = getenv("HTTP_HOST");

echo "<b>Your IP is:</b> <i>$ip</i><br>"
."<b>Trying to ping:</b> <i>$server</i><br>"
."<b>Using server:</b> <i>$hname</i>";

echo "<HR noshade size=1<br>";

echo "<b>STATS:</b><br><br>";


$command = "ping -c4 $server";

exec($command, $result, $rval);

if(count($result) <= 0) {

echo "<font color=red>沒有響應</font><br>";

echo "<HR noshade size=1>";

exit;
}

for ($i = 0; $i < count($result); $i++) {

echo "<font color=red>$result[$i]</font><br>";

}
echo "<HR noshade size=1>";
#include("powered.txt");
}
?>


北斗有巢氏 有巢氏北斗