Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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
You can’t perform that action at this time.