Is cURL enabled for Free Users?

Status
Not open for further replies.

datasync

New Member
Messages
16
Reaction score
0
Points
1
I tried testing to see if curl works using the following code, and it says that it is enabled, however when I check to see if a website exists, it keeps returning true even though the website doesn't exist.
This says that cURL is enabled:
PHP:
echo 'Curl: ', function_exists('curl_version') ? 'Enabled' : 'Disabled';
This function keeps returning true when the clearly doesn't exist:
PHP:
  if (isDomainAvailible('http://www.googfenjnkfele.com'))
       {
               echo "Up and running!";
       }
       else
       {
               echo "Woops, nothing found there.";
       }

       //returns true, if domain is availible, false if not
       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;
       }
 

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
368
Points
83
Hi,

Due to the way the free hosting servers are set up, it appears that when a domain name fails to resolve, the domain resolves to the Domain Does Not Exist page instead. This means that if the domain fails to resolve, a default response will still be returned. This is why your script is returning true for a domain that shouldn't resolve.

Although I don't expect this to be changed, it is possible to work around this. An example would be to use a function like this, to check if a domain name resolves properly:

Code:
function domainResolves($domain) {
    return gethostbyname(parse_url($domain)['host']) != '198.91.80.25';
}


Thank you,
 

caftpx10

Well-Known Member
Messages
1,534
Reaction score
114
Points
63
Well, that explains why my script didn't work under my account.
 

datasync

New Member
Messages
16
Reaction score
0
Points
1
Hi,

Due to the way the free hosting servers are set up, it appears that when a domain name fails to resolve, the domain resolves to the Domain Does Not Exist page instead. This means that if the domain fails to resolve, a default response will still be returned. This is why your script is returning true for a domain that shouldn't resolve.

Although I don't expect this to be changed, it is possible to work around this. An example would be to use a function like this, to check if a domain name resolves properly:

Code:
function domainResolves($domain) {
    return gethostbyname(parse_url($domain)['host']) != '198.91.80.25';
}


Thank you,
Ah, perfect! Thank you friend.
 
Status
Not open for further replies.
Top