<?php
function
Networkcheck(
$url
){
$agent
=
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0"
;
$ch
=curl_init();
curl_setopt(
$ch
, CURLOPT_URL,
$url
);
curl_setopt(
$ch
, CURLOPT_USERAGENT,
$agent
);
curl_setopt(
$ch
, CURLOPT_RETURNTRANSFER, 1);
curl_setopt(
$ch
,CURLOPT_VERBOSE,false);
curl_setopt(
$ch
, CURLOPT_TIMEOUT, 5);
curl_setopt(
$ch
,CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt(
$ch
,CURLOPT_SSLVERSION,3);
curl_setopt(
$ch
,CURLOPT_SSL_VERIFYHOST, FALSE);
$page
=curl_exec(
$ch
);
$httpcode
= curl_getinfo(
$ch
, CURLINFO_HTTP_CODE);
curl_close(
$ch
);
if
(
$httpcode
>=200 &&
$httpcode
<300)
return
true;
else
return
false;
}
if
(Networkcheck(
"https://www.baidu.com"
))
echo
"Website OK"
;
else
echo
"Website DOWN"
;
?>