Created
January 20, 2014 11:09
-
-
Save cereal-s/8518368 to your computer and use it in GitHub Desktop.
Simple snippet, used to check the redirects of the links. Requires cURL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = false; | |
if($_POST) | |
{ | |
$url = $_POST['url']; | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); | |
curl_setopt($ch, CURLOPT_TIMEOUT, 5); | |
curl_setopt($ch, CURLOPT_HEADER, true); | |
curl_setopt($ch, CURLOPT_NOBODY, true); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | |
$c = curl_exec($ch); | |
curl_close($ch); | |
} | |
?> | |
<form method="POST" action=""> | |
<label for="url">URL</label> | |
<input type="text" name="url" <?php echo $url ? "value=\"$url\"":''; ?> /> | |
<input type="submit" name="submit" value="get the headers" /> | |
</form> | |
<?php | |
if( $_POST ) | |
{ | |
if(preg_match_all('/(?<=Location:).*+/', $c, $matches) > 0) | |
{ | |
echo "<ul>"; | |
foreach($matches as $key => $value) | |
{ | |
foreach($value as $key_1 => $value_1) | |
{ | |
echo "<li><a href=\"$value_1\" target=\"_blank\">$value_1</a></li>"; | |
} | |
} | |
echo "</ul>"; | |
} | |
echo "<h3>Headers for: <a href=\"$url\">$url</a></h3>"; | |
echo "<pre>"; | |
print_r($c); | |
echo "</pre>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment