)/', "\$1$myserver\$2", $xml);
header('Content-Type: text/xml');
echo $xml2;
} else if (array_key_exists('mp3',$_GET)) {
// MP3
$mp3=$_GET['mp3'];
if (!preg_match("/^[-a-zA-Z0-9_]+\.mp3$/", $mp3)) die("URL MP3 INCORRECTA");
$maxRedir=5;
$redirHistory="";
$url="http://www.ivoox.com/" . $mp3;
// For each known url connect and retrieve the redirect url
while (
$maxRedir-- > 0 && (
preg_match("/http:\/\/www\.ivoox\.com\/[-a-zA-Z0-9_]+\.mp3\$/",$url) ||
preg_match("/http:\/\/files\.ivoox\.com\/download\/[0-9]+\$/",$url)
)
) {
$redirHistory .= $url . "
\n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
// Execute
$output = curl_exec($ch);
if ( get_redirect_url($output) ) {
$url=get_redirect_url($output);
} else {
// there was no redirect, should not happen
$res=curl_getinfo($ch);
$url=$res['url'];
}
curl_close($ch);
}
header('Location: ' . $url);
echo "Redirect history: $redirHistory";
} else {
// Ayuda
echo "