// Gets the Server Headers for the given URL function getHeaders($url) { while ($code != 200) { $options = array( 'allowRedirects' => false, 'maxRedirects' => 0); $r = new HTTP_Request($url,$options); $r->setMethod(HTTP_REQUEST_METHOD_GET); $r->sendRequest(); $page = $r->getResponseBody(); $page = strtolower($page); $code = $r->getResponseCode(); if(!$page) { echo 'No Web Server Found'; exit(); } if ($code === 404) { echo '404 Not Found'; exit(); } echo 'Server Code: ' .$code. '
'; foreach ($r->getResponseHeader() as $name => $value) { echo '' .$name. ': ' .$value. '
'; } $redirectLoc = $r->getResponseHeader('location'); if (preg_match("/http\:\/\/.*$/",$redirectLoc,$matchedUrl)) { $url = $matchedUrl[0]; } elseif (preg_match("/https\:\/\/.*$/",$redirectLoc,$matchedUrl)) { $url = $matchedUrl[0]; } elseif (preg_match("/https\:\/\/[^\/]*/",$url,$matchedUrl)) { $url = $matchedUrl[0]."/".$redirectLoc; } else { $url = preg_match("/http\:\/\/[^\/]*/",$url,$matchedUrl); $url = $matchedUrl[0]."/".$redirectLoc; } echo '
'; } }