Skip to content

Instantly share code, notes, and snippets.

@SilentKernel
Created February 16, 2017 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SilentKernel/ebbbaac703923fc0e6492e975d308c3f to your computer and use it in GitHub Desktop.
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
<?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