Skip to content

Instantly share code, notes, and snippets.

@venj
Created March 14, 2013 08:02
Show Gist options
  • Save venj/5159660 to your computer and use it in GitHub Desktop.
Save venj/5159660 to your computer and use it in GitHub Desktop.
<?php
if ($_GET["shorturl"]) {
$short_url = $_GET["shorturl"];
$ch = curl_init($short_url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_NOBODY, TRUE);
curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
/*
echo "<p>" . curl_getinfo($ch, CURLINFO_EFFECTIVE_URL) . "</p>";
$info = curl_getinfo($ch);
echo "<p>" . $info["redirect_count"] . "</p>";
*/
}
else {
$html =<<<END
<form action="/url.php" method="get" accept-charset="utf-8">
<p><input type="text" name="shorturl" value="">
<input type="submit" value="Expand"></p>
</form>
END;
echo $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment