The following html code creates a hostmonter. php file, copy the following code to the file, save it, upload it to the server, and then use a browser or a Linux timer or other tools, the code below is checked every 10 minutes. The following code contains three domain names. Modify multiple domain names as needed:
-------------- Code content ------------
<Html>
<Body>
<Meta http-equiv = "refresh" content = "600">
<? Php
Function check ($ host, $ find)
{
$ Fp = fsockopen ($ host, 80, $ errno, $ errstr, 10 );
If (! $ Fp)
{
Echo "$ errstr ($ errno) \ n ";
} Else
{
$ Header = 'get/HTTP/1.1 \ r \ n ";
$ Header. = "Host: $ host \ r \ n ";
$ Header. = "Connection: close \ r \ n ";
Fputs ($ fp, $ header );
While (! Feof ($ fp ))
{
$ Str. = fgets ($ fp, 1024 );
}
Fclose ($ fp );
Return (strpos ($ str, $ find )! = False );
}
}
Function OK ($ host)
{
/* Change the following youremail@139.com to your email address */
/* Mail ('1970 @ qq.com ', 'monitoring', $ host. 'drop ');*/
Echo "$ host-OK <br> ";
}
Function posttohost ($ host)
{
/* The following uses the Western Digital text message interface as an example */
$ Maildomain = 'domain name ';
$ Mailpwd = 'Password ';
$ Sendmobile = 'mobile phone number for receiving alerts, which can be China Unicom/China Telecom 189/mobile ';
$ Sendcontent = "$ host fault !";
$ Sendport = '3 ′;
If ($ maildomain! = ""){
$ Key = md5 ($ maildomain. $ mailpwd );
$ Url = "http://usericp.west263.cn/default.aspx.pdf;
$ 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-urlencoded \ r \ n ".
"Content-Length:". strlen ($ data). "\ r \ n ",
'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 <br> ";
} Else {
Echo "$ result <br> ";
}
}
}
For ($ I = 1; $ I <= 3; $ I ++)
{
If ($ I = 1)
{
/* Change the following URL 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 "record filing number:" to a special character string in the source code of your website homepage */
$ Find = 'filing No :';
If (! Check ($ host, $ find ))
{
Posttohost ($ host );
}
Else
{OK ($ host );}
}
?>
</Body>
<Html>
-------------- Code ended ---------------
From: lonely blog