For the following HTML format code, you create a new hostmonter.php file, then copy the following code into the file and save it, upload it to the server, and then use a browser or Linux timer and other tools to do it, the following code It is checked every 10 minutes. There are three domain names in the code below. Modify multiple domain names yourself:
——————————————Code content————————————
function posttohost($host)
{
/* The following is an example of the Western Digital SMS interface */
$maildomain=’domain name’;
$mailpwd=’password’;
$sendmobile=’The mobile phone number to receive the alarm, China Unicom/Telecom 189/China Mobile can be used’;
$sendcontent=”$host failed!”;
$sendport=’3′;
if($maildomain!=””){
$key=md5($maildomain.$mailpwd);
$url=”http://usericp.west263.cn/default.aspx”;
$data=array('mobile'=>$sendmobile,'sendcontent'=>mb_convert_encoding($sendcontent, "UTF-8", "gb2312"),'port'=>$sendport,'maildomain'=> ;$maildomain,'key'=>$key);
$data=http_build_query($data);
$opts=array(‘http’=>array(‘method’=>’POST’,
‘header’=>”Content-type: application/x-www-form-urlencodedrn”.
“Content-Length:”.strlen($data).”rn”,
‘content’=>$data),);
$context=stream_context_create($opts);
$html=file_get_contents($url,false,$context);
$result=iconv(“UTF-8″,”gb2312″,$html);
if($result==”200 ok”){
echo “$host – sendOK
”;
}else{
echo “$result
”;
}
}
}
for ($i=1; $i<=3; $i++)
{
if ($i==1)
{
/* Change the URL below to the URL you want to monitor */
$host = ‘www.xxx.com’;
$Content = “www.xxx.com-Unable to connect”;
}elseif ($i==2)
{
$host = ‘www.yyy.com’;
$Content = “www.yyy.com-Unable to connect”;
}elseif ($i==3)
{
$host = ‘www.zzz.com’;
$Content = “www.zzz.com-Unable to connect”;
}
/* Change the "Registration Number:" below to a special string in the source code of your website homepage */
$find = ‘Registration number:’;
if (!check($host, $find))
{
posttohost($host);
}
else
{ok($host);}
}
?>
————————————End of code——————————————
from:lonely blog