<?php

include 'simple_html_dom.php';
include 'conf.php';

if(isset($_POST['only']))
{
	$url = 'http://mp3.waprik.ru/index.php?query='.urlencode($_POST['query']).'&only=1&action=query&form=true';
	$ok = true;
}
elseif(isset($_POST['query']))
{
	$url = 'http://mp3.waprik.ru/index.php?query='.urlencode($_POST['query']).'&action=query&form=true';
	$ok = true;
}
else
{
	$url = 'http://mp3.waprik.ru/index.php?';
	$ok = false;
}

if($ok == true)
{
	$headd = get_headers($url, 1);
	if (isset($headd['Location']))
	{
		$loc = str_replace('http://mp3.waprik.ru/', ''.HOME.'', $headd['Location']);
		header('Location: '.$loc.'');
		exit();
	}
	else
	{
		include 'head.php';
		echo 'XATO';
		include 'foot.php';
	}
}
else
{

		include 'head.php';
echo '<div class="phdr">Mp3 Qidiruv</div><div class="gmenu">Ijrochi yoki qo\'shiq nomini kiriting:
</br>Masalan: Rayhon - Buyurmadi baxt
		<form action="?" method="post">
<input name="query" type="text" /><br/>

<input name="only" type="checkbox" value="1" /><b>Matn bilan izlash</b><br />
					<input name="action" type="hidden" value="query" />
					<input name="form" type="hidden" value="true" />
<input value="Qidirish" type="submit" />
			</div>
		</form>
		';

	
	include 'foot.php';
}
?>