Created
February 16, 2017 14:35
-
-
Save SilentKernel/ebbbaac703923fc0e6492e975d308c3f to your computer and use it in GitHub Desktop.
Check if website is online with PHP and Free Mobile (France) / Quick and dirty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Sites | |
$sitesArray[] = "https://silentkernel.fr"; | |
$sitesArray[] = "https://storage.silentkernel.fr"; | |
// Users | |
$usersUrlArray[] = "https://smsapi.free-mobile.fr/sendmsg?user=xxxxxxx&pass=xxxxxxxxxx&msg="; | |
// Begin code | |
function getResponseInfo($url) | |
{ | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.23"); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | |
curl_exec($ch); | |
$info = curl_getinfo($ch); | |
curl_close($ch); | |
return $info; | |
} | |
$resultString = ""; | |
foreach ($sitesArray as $url) | |
{ | |
$info = getResponseInfo($url); | |
if (!isset($info["http_code"])) | |
{ | |
$resultString.= " ".$url; | |
} | |
elseif ($info["http_code"] != 200) | |
{ | |
$resultString.= " ".$url; | |
} | |
// Prevent flooding servers | |
sleep(1); | |
} | |
if ($resultString != "") | |
{ | |
$SMS = urlencode("Down :" . $resultString); | |
// var_dump($SMS); | |
foreach ($usersUrlArray as $userUrl) | |
{ | |
getResponseInfo($userUrl . $SMS); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment