Originally posted by The Fox
View Post
PHP Code:
<?php
######################
## forged on gowap.ro#
######################
require_once'config.php';
require_once'functions.php';
$formeruri='http://www.4shared.com/mp3/'.$_GET['id'].'/'.$_GET['mod'].'.html';
# get direct download link
$client = new SoapClient("http://api.4shared.com/servlet/services/DesktopApp?wsdl");
$dlid = $client->getDirectLink(LOGIN,PASSWORD,$formeruri);
$id = $client->decodeLink(LOGIN,PASSWORD,$formeruri);
$info = $client->getFileInfo(LOGIN,PASSWORD,$id);
$regx=array('|\[(.*?)]|i','|\((.*?)\)|i','|www(.*?)$|i');
$nume_fisier=preg_replace($regx,'',utf8_format($info->name));
/// check if 302 and switch $url to header location
/// otherwise use $dlid former url got from api
$head = array_change_key_case(get_headers($dlid, TRUE));
/// switch here
if(!empty($head['location'])){$dlid=$head['location'];}
## if the $url is file location we force to get 200 ok
## the $url location from header must also return 200 ok
$status=get_headers($dlid);
echo $status[0]." ";
if($status[0]=="HTTP/1.1 200 OK") {
echo' <a href="'.htmlspecialchars($dlid).'">'.$nume_fisier.' ['.format_bytes($info->size).'] </a><br/>';
}
/*
## we use else statement if header is not 200 ok
## this works if they modify the header other than 302 or 200
## it will work fine but you will not be able to stop the user
## for beeing redirected if the file doesn't exist anymore .
## uncomment if you want to use it !
else {
echo' <a href="'.htmlspecialchars($dlid).'">'.$nume_fisier.' ['.format_bytes($info->size).'] </a><br/>';
}
*/
## comment this line if you want to use the upper one !
else {
echo"<h1>This file is not available !</h1>";
}
?>
Comment