龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

根据ping的返回值判断电脑是否在线

时间:2014-07-22 14:51来源: 作者: 点击:
分享到:
RT。 br / br / div br / /div br /
RT。




<?php 
$key="Request timed out.";
$kkk=array(
	"name3" =>array("192.168.0.118","王五","行政",),
	"name4" =>array("192.168.0.140","李四","财务",),
	"name5" =>array("192.168.0.10","张三","后勤",),
	);

echo "<table border='1' height=50% width=520 cellpadding=0 cellspacing='0' valign='top' bgcolor='#6666FF'>"; 
echo "<th align = 'center'>姓名</th>"; 
echo "<th align = 'center'>部门</th>"; 
echo "<th align = 'center'>状态</th>"; 

foreach ($kkk as $ddd) {
	unset($result);
	exec("ping $ddd[0] -n 1",$result,$rval);
		
	if ($result[3] == $key){
		echo "<tr> \n";
		echo "<td align='center'>$ddd[1]</td>";
		echo "<td align='center'>$ddd[2]</td>";
		echo "<td align='center' bgcolor='#000000'><font color='#FF00FF'>离线</font></td>";
		echo "</tr>";
	}else{
		echo "<tr> \n";
		echo "<td align='center'>$ddd[1]</td>";
		echo "<td align='center'>$ddd[2]</td>";
		echo "<td align='center'><font color='#0033FF'>在线</font></td>";
		echo "</tr>";
	}
}
?>
精彩图集

赞助商链接