Skip to content

Instantly share code, notes, and snippets.

@JRMorris77
Created March 9, 2017 03:09
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 JRMorris77/2d917b63eb328d17a262f986748fe053 to your computer and use it in GitHub Desktop.
Save JRMorris77/2d917b63eb328d17a262f986748fe053 to your computer and use it in GitHub Desktop.
<?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