<?php
include 'simple_html_dom.php';
include 'conf.php';

if(isset($_GET['page']) && is_numeric($_GET['page']))
{

	$url = 'http://mp3.waprik.ru/audio/'.trim($_GET['id']).'/'.intval($_GET['page']).'';
}
else
{
	$url = 'http://mp3.waprik.ru/audio/'.trim($_GET['id']).'/';
}

$headd = get_headers($url, 1);
if (isset($headd['Location']))
{
	$loc = str_replace('http://mp3.waprik.ru/', ''.HOME.'', $headd['Location']);
	header('Location: '.$loc.'');
	exit;
	
}

$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, CURLINFO_HEADER_OUT, FALSE);
curl_setopt($curl, CURLOPT_REFERER, 'http://mp3.waprik.ru/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
$res = curl_exec($curl);

$data = new simple_html_dom();
$data->load($res);
curl_close($curl);

include 'head.php';

if ($data == false)
	{
		echo 'Serverda xatolik!<br/>';
		include 'foot.php';
		exit;
	}

$tmp = $data->find('div[class="title"]', 0);
	if ($tmp != false)
		{
			$p = $tmp->innertext;
			$p = str_replace('href="http://mp3.waprik.ru/', 'href="'.HOME.'', $p);
			$p = str_replace('Ищем', 'Qidiruv', $p);
			echo '<div class="phdr">'.$p.'</div>';
				
		}
		
$tmp = $data->find('div[class="block"]', 0);
if ($tmp != false)
	{
		$p = $tmp->innertext;
		$p = str_replace('href="http://mp3.waprik.ru/', 'href="'.HOME.'', $p);
		$p = str_replace('Ищем', 'Qidiruv', $p);
		$p = str_replace('<div class="nav_2">', '</div><div class="topmenu">', $p);
		$p = str_replace('&lt;- туда', '<< Oldingi', $p);
		$p = str_replace('сюда -&gt;</a>', 'Keyingi >></a></div>', $p);
		$p = str_replace('Страницы:', 'Sahifa', $p);
		$p = str_replace('small_text', 'time', $p);
		$p = str_replace('<div class="nav_o">', '</div><div class="itopmenu">', $p);
		$p = str_replace('</div>', '', $p);
		$p = str_replace('<hr />', '', $p);
		$p = str_replace('<div class="clear">', '</div><div class="menu">', $p);
		$p = str_replace('Страница', 'Sahifa:', $p);
		$p = str_replace('<div class="nav">', '', $p);
		//$p = str_replace('сюда -&gt;', 'Keyingi >>', $p);
		
		$p = str_replace('www.Xorazm.Net', 'UzDown.Ru', $p);
		$p = str_replace('www.voydod.net', 'UzDown.Ru', $p);
		$p = str_replace('www.UmmoN.uz', 'UzDown.Ru', $p);
		$p = str_replace('UzFly.Com', 'UzDown.Ru', $p);
		$p = str_replace('Yoshlar.com', 'UzDown.Ru', $p);
		$p = str_replace('www.8TV.uz', 'UzDown.Ru', $p);
		$p = str_replace('www.vk.com/bestmusicuz', 'UzDown.Ru', $p);
		$p = str_replace('WwW.Mp3Uz.NeT', 'UzDown.Ru', $p);
		$p = str_replace('HAYOL.UZ', 'UzDown.Ru', $p);
		$p = str_replace('Www.HaYoL.Uz', 'UzDown.Ru', $p);
		$p = str_replace('XitMusic.uCoz.cOm', 'UzDown.Ru', $p);
		$p = str_replace('Muzaffar91@mailL.RU', 'UzDown.Ru', $p);
		$p = str_replace('AJOYIB.com', 'UzDown.Ru', $p);
		$p = str_replace('www.bestmusic.uz', 'UzDown.Ru', $p);
		
echo '<div class="menu">'.$p.'</div></div></div></div>';

			
	}
echo '</div><div class="gmenu"><a href="'.HOME.'">Yangi qidiruv</a></div>';
	
$data->clear();
unset($data);
include 'foot.php';
?>