Hi everyone, just would like to ask if anyone could assist in this …
below script was left abandoned and i am not good in curl. From what i was told, when it goes to the site without extension of .mp3, curl will only start and it will go to the page with the download being triggered.
<<<<<downloadagent.php>
<?php
// Check needed parameter
if ( !( isset( $_GET["id"] ) && is_numeric( $_GET["id"] ) && ( $index = (int)$_GET["id"] ) ) ){
exit();
}
// Include scripts
include( "scripts/options.php" );
include( "scripts/main.php" );
$arr = array("mp3");
if ( $song = new Song( $index ) ){
var_dump( $song );
if ( $song->index ){
$song->downloads++;
$song->update();
$arr1 = explode(".",$song->url);
$ext = $arr1[count($arr1)-1];
if(in_array($ext,$arr)){
header( "Location: $song->url" );
}else{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0");
curl_setopt($ch, CURLOPT_URL, $song->url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
$data = curl_exec($ch);
$last_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
$arr_last = explode("?",$last_url);
echo $last_url = $arr_last[0];
curl_close($ch);
$arr1 = explode(".",$last_url);
$ext = $arr1[count($arr1)-1];
if(in_array($ext,$arr)){
header( "Location: $song->url" );
}else{
echo $data;
}
}
}
}
?>
From the downloadagent.php, when i check the source code…it shows this…
object(Song)#1 (5) {
["index"]=>
int(163)
["name"]=>
string(34) "Eyes On The Money (Prod. Sdotfire)"
["url"]=>
string(45) "http://www.hulkshare.com/dl/a5dfciq2eoxm/?d=1"
["downloads"]=>
int(11)
["length"]=>
int(0)
}
but still, the page wont load properly… is there anything missed out from the code ?
kindly advise.
Many thanks