m3u file:
"); $m3u_url = $_POST['url']; $resp = curl_get_new($m3u_url,$user_agent,false); preg_match_all("/(.)*/",$resp[2],$matches); for($i = 0;$i"); $mp3 = curl_get($matches[0][$i],$user_agent,true); save_file($mp3,$name); } } } //returns a binary function curl_get ($url,$user_agent,$binary) { $ch = curl_init(); curl_setopt ($ch, CURLOPT_PROXY, $proxy); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent); // curl_setopt ($ch, CURLOPT_COOKIEJAR, "c:\cookie.txt"); curl_setopt ($ch, CURLOPT_HEADER, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); if($binary) curl_setopt ($ch, CURLOPT_BINARYTRANSFER, 1); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_TIMEOUT, 120); $result = curl_exec ($ch); curl_close($ch); return $result; } //wrapper for curl_get function curl_get_new($url_page,$user_agent,$binary) { $curl_response = curl_get($url_page,$user_agent,$binary); $resp = parse_response($curl_response); return $resp; } //parses the response from curl function parse_response($response) { /*  ***original code extracted from examples at  ***http://www.webreference.com/programming              /php/cookbook/chap11/1/3.html   ***returns an array in the following format which varies depending on headers returned     [0] => the HTTP error or response code such as 404    [1] => Array    (      [Server] => Microsoft-IIS/5.0      [Date] => Wed, 28 Apr 2004 23:29:20 GMT      [X-Powered-By] => ASP.NET      [Connection] => close      [Set-Cookie] => COOKIESTUFF      [Expires] => Thu, 01 Dec 1994 16:00:00 GMT      [Content-Type] => text/html      [Content-Length] => 4040    )    [2] => Response body (string) */ list($response_headers,$response_body) = explode("\r\n\r\n",$response,2); $response_header_lines = explode("\r\n",$response_headers); // first line of headers is the HTTP response cod $http_response_line = array_shift($response_header_lines); if (preg_match('@^HTTP/[0-9]\.[0-9] ([0-9]{3})@',$http_response_line,$matches)){ $response_code = $matches[1]; } // put the rest of the headers in an array $response_header_array = array(); foreach ($response_header_lines as $header_line) { list($header,$value) = explode(': ',$header_line,2); $response_header_array[$header] = $value; } return array($response_code,$response_header_array,$response_body); } function save_file ($mp3,$filename) { if($mp3) { $filename = "magnatune/" . $filename; if(file_exists($filename)) unlink ($filename); $handle = fopen($filename, "w+"); fwrite($handle, $mp3); fclose($handle); return $mp3; } } ?>