//i need to run this script repetadly and the time interval can be set by a user
// checking the internet connection
if (!$sock = fsockopen("www.google.com", 80, $errno, $errstr,20))
{
?>
<script type="text/javascript">
alert("Connection problem");
</script>
<?php
}
// retriving data from database and checking the site is down
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
// writing data to database and sending mail
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);
}