<?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 'Ошибка загрузки данных<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="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('waprik.ru_', ''.DOWN_rekl.'', $p);
echo '<div class="rek2">'.$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 = preg_replace('#<a href="(.*)">Искать</a><br/>#Us', 'Нет', $p);// доделать
echo '<div class="menu">'.$p.'</div>';


			
	}

echo '<div class="rek2"><a href="'.HOME.'audio/'.intval($_GET['w']).'/">Назад</a></div>';



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