function reverse_tinyurl($url){
// Resolves a TinyURL.com encoded url to it's source.
$url = explode('.com/', $url);
$url = 'http://preview.tinyurl.com/'.$url[1];
$preview = file_get_contents($url);
preg_match('/redirecturl" href="(.*)">/', $preview, $matches);
return $matches[1];
}
function tinyurl($url){
// Shortens a url
$html = file_get_contents("http://tinyurl.com/create.php?url=".$url);
preg_match('/http:\/\/preview\.tinyurl\.com\/(.*)<\/b>/', $html, $matches);
return "http://tinyurl.com/".$matches[1];
}
You need to create an account or log in to post comments to this site.