//我需要重复运行这个脚本,时间间隔可以由用户设置
// 检查互联网连接
if (!$sock = fsockopen("www.google.com", 80, $errno, $errstr,20))
{
?>
<script type="text/javascript">
alert("Connection problem");
</script>
<?php
}
// 从数据库中检索数据并检查站点是否已关闭
else
{
for($i=0;$i<count($res);$i++)
{
$fp=fsockopen($res[$i]['url'],80,$errno,$errstr,30);
if($fp==false)
{
?>
<script type="text/javascript">
alert("Website is down");
</script>
<?php
// 将数据写入数据库并发送邮件
mail($email[0]['email_id'],"website is down",$res[$i]['url']." is down");
$inputs=array('website_id'=>$res[$i['website_id'],
'date'=>date("Y-m-d H:i:s"),'reason'=>"website down");
$obj3->addLog($inputs);
}
}
}
sleep(300);
}