<?php
include 'conf.php';


	$url = 'http://zomp3.ru/video/index.php?'.$_SERVER['QUERY_STRING'].'';
	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, $url); 
	curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1');
	curl_setopt($curl, CURLOPT_REFERER, "http://zomp3.ru/video/index.php?");
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($curl, CURLOPT_COOKIEJAR, 'sess.txt');
	curl_setopt($curl, CURLOPT_COOKIEFILE, 'sess.txt');
	curl_setopt($curl, CURLOPT_NOBODY, 1);
	curl_setopt($curl, CURLOPT_HEADER, 1);
	
	$res = curl_exec($curl);
	curl_close($curl);
	
	
	preg_match('/Location:(.*?)\n/', $res, $link);
	$link = 'http://zomp3.ru/video/'.trim($link[1]).'';
	$names = explode('/', $link);
	$name = str_replace('zomp3ru', ''.DOWN_rekl.'', $names[6]);
	$name = str_replace('zomp3_ru', ''.DOWN_rekl.'', $name);
	$name = str_replace('zomp3.ru', ''.DOWN_rekl.'', $name);
	
	$info = get_headers($link,1);
	foreach ($info as $key=>$value)
		{
			header(''.$key.': '.$value.'');
		}
		header('Content-Disposition: attachment;filename="'.$name.'"');
		readfile($link);
	

?>