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

$url = 'http://mp3.waprik.ru/song/'.trim($_GET['q']).'/'.intval($_GET['w']).'';

$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_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);
		echo '<div class="gmenu">'.$p.'</div>';
		$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);
			
	}
	
$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('оригинал', 'original', $p);
		$p = str_replace('Мб', 'Mb', $p);
		$p = str_replace('Скачать', 'Yuklab olish', $p);
		$p = str_replace('waprik.ru_', ''.DOWN_rekl.'', $p);
echo '<div class="menu">'.$p.'</div>';

			
	}
	
$tmp = $data->find('div[class="block"]', 1);
if ($tmp != false)
	{
		$p = $tmp->innertext;
		
		$p = str_replace('href="http://mp3.waprik.ru/', 'href="'.HOME.'', $p);
		$p = str_replace('Размер', 'Hajmi', $p);
		$p = str_replace('Длительность', 'Vaqti', $p);
		$p = str_replace('Битрейт', 'Tezlik', $p);
		$p = str_replace('Кбит/с', 'Kb/s', $p);
		$p = str_replace('Мб', 'Mb', $p);
		$p = str_replace('<hr />', '', $p);
		$p = str_replace('Текст песни', 'Qo\'shiq matni', $p);
		$p = preg_replace('#<a href="(.*)">Искать</a><br/>#Us', 'Нет', $p);// доделать
echo '<div class="topmenu">'.$p.'</div>';


			
	}

echo '<div class="menu"><a href="'.HOME.'audio/'.intval($_GET['w']).'/">Orqaga</a></div>';



$data->clear();
unset($data);
include 'foot.php';
?>