Created
March 9, 2017 03:09
-
-
Save JRMorris77/2d917b63eb328d17a262f986748fe053 to your computer and use it in GitHub Desktop.
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 | |
if (isDEVAvailible('http://premium.wpmudev.org')) | |
{ | |
echo "<h1>premium.wpmudev.org is Up and running!</h1>"; | |
} | |
else | |
{ | |
echo "<h1>Woops, nothing found at premium.wpmudev.org.</h1>"; | |
} | |
//returns true, if domain is availible, false if not | |
function isDEVAvailible($domain) | |
{ | |
//check, if a valid url is provided | |
if(!filter_var($domain, FILTER_VALIDATE_URL)) | |
{ | |
return false; | |
} | |
//initialize curl | |
$curlInit = curl_init($domain); | |
curl_setopt($curlInit,CURLOPT_CONNECTTIMEOUT,10); | |
curl_setopt($curlInit,CURLOPT_HEADER,true); | |
curl_setopt($curlInit,CURLOPT_NOBODY,true); | |
curl_setopt($curlInit,CURLOPT_RETURNTRANSFER,true); | |
//get answer | |
$response = curl_exec($curlInit); | |
curl_close($curlInit); | |
if ($response) return true; | |
return false; | |
} | |
if (isGoogleAvailible('http://google.com')) | |
{ | |
echo "<h1>google.com is Up and running!</h1>"; | |
} | |
else | |
{ | |
echo "<h1>Woops, nothing found at google.com.</h1>"; | |
} | |
//returns true, if domain is availible, false if not | |
function isGoogleAvailible($domain) | |
{ | |
//check, if a valid url is provided | |
if(!filter_var($domain, FILTER_VALIDATE_URL)) | |
{ | |
return false; | |
} | |
//initialize curl | |
$curlInit = curl_init($domain); | |
curl_setopt($curlInit,CURLOPT_CONNECTTIMEOUT,10); | |
curl_setopt($curlInit,CURLOPT_HEADER,true); | |
curl_setopt($curlInit,CURLOPT_NOBODY,true); | |
curl_setopt($curlInit,CURLOPT_RETURNTRANSFER,true); | |
//get answer | |
$response = curl_exec($curlInit); | |
curl_close($curlInit); | |
if ($response) return true; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment