Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function isDomainAvailable($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;
- }
- $file = fopen("sites.txt", "r");
- $sites = array();
- while (!feof($file)) {
- $sites[] = fgets($file);
- }
- fclose($file);
- foreach ($sites as $value) {
- echo "$value <br>";
- if(!strstr($value, "http://") && !strstr($value, "https://"))
- {
- $value = "http://" . $value;
- }
- if (isDomainAvailable($value))
- {
- header("Location: $value");
- }
- else
- {
- echo "Woops, nothing found there. </br>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement