PHP CURL-REQUEST TO CHECK, IF A WEBSITE EXISTS/IS ONLINE.
if(isset($_POST['submit'])){
if (isDomainAvailible($_POST['url']))
{
echo "Up^^^^^^^^^^^^^";
}
else
{
echo "Down__________";
}
}
function isDomainAvailible($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;
}
?>
<html>
<body>
<form action="#" method="post">
<input type="url" name="url" >
<input type="submit" value="Check" name="submit">
</form>
</body>
</html>
No comments:
Post a Comment