<?php
include 'set.php';
error_reporting(0);
$wer=$_SERVER['QUERY_STRING'];
$url='http://m.images.yandex.ru/search?'.$wer;


$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_REFERER, 'http://yandex.ru');
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
$cnt = curl_exec($curl);
curl_close($curl);
$cnt=str_replace('"search"','"find.php"',$cnt);
$cnt=str_replace('"search?','"find.php?',$cnt);
$cnt=str_replace('"/search?','"'.$way.'/find.php?',$cnt);

$cnt=preg_replace('/<!(.*?)<\/table>/si','',$cnt);
$cnt=preg_replace('/<div class="b\-foot">(.*?)<\/html>/si','',$cnt);

$cnt=str_replace('http://resize.yandex.net/',''.$way.'/img_resize/?',$cnt);
$cnt=str_replace('height="48"','height = "48" style="border:1px #ff0000 solid;margin:1px"',$cnt);

$cnt=str_replace('http://m.images.yandex.ru/search','find.php',$cnt);
$cnt=preg_replace('/Поискать в (.*?)<\/a>/si','',$cnt);

$cnt=str_replace('<ul class="b-tabsline">','',$cnt);
$cnt=str_replace('</ul>','',$cnt);
$cnt=str_replace('<th><input id="find.php"','<th style="width:100%"><input class="inp" id="find.php"',$cnt);

$cnt=str_replace('&amp;','&',$cnt);
$cnt=str_replace('&','_uhjb65482K',$cnt);
$cnt=str_replace('_uhjb65482K','&amp;',$cnt);
$cnt=str_replace('"alt=','" alt=',$cnt);
//$cnt=preg_replace('/class="site">(.*?)<\/a>/si','class="site"></a>',$cnt);
//if(substr_count($cnt,'img_resize')) $cnt=preg_replace('/<div class="b\-prew">(.*?)<\/div>/si','',$cnt);
$cnt=str_replace("&amp;nbsp;",'&nbsp;',$cnt);
$cnt=preg_replace('/<table(.*?)>/si','',$cnt);
$cnt=preg_replace('/<td(.*?)>/si','',$cnt);
$cnt=preg_replace('/<th(.*?)>/si','',$cnt);
$cnt=str_replace('</table>','',$cnt);
$cnt=str_replace('</td>','',$cnt);
$cnt=str_replace('<tr>','',$cnt);
$cnt=str_replace('</tr>','',$cnt);
$cnt=str_replace('</th>','',$cnt);
$cnt=preg_replace('/<span(.*?)Обои<\/a>/si','<div class="'.$div_razd.'">Результаты поиска:</div>',$cnt);
$cnt=str_replace('<input type="submit"','<div></div><input class="submit" type="submit"',$cnt);

$cnt=str_replace('"orig"><a href="http://','"orig"><a href = "down.php?file=http://',$cnt);
$cnt=preg_replace('/class="site">(.*?)<\/a>/si','</a>',$cnt);
$cnt=preg_replace('/<div class="b-error">(.*?)<\/div>/si','<b>Невозможно отобразить даную картинку. Возможно сервер недоступен. Вы можете выбрать из ниже предложеных:</b>',$cnt);

////////////////////

$cnt=preg_replace('/<p>(.*?)<\/p>/si','',$cnt);
include ("head.php");
echo "<div class=\"$div_razd\"><a href=\"/\">[$copy]</a> [Результаты:]</div>\n";
echo '<div class="'.$div_body.'">';
echo($cnt);
echo '</div>';
include ("foot.php");
exit();
/*********/


/*--------------------------------*/
?>
