<?php
include '../inc/head.php';


if(empty($_POST)){
$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, 'http://rugame.mobi/inet/weather/?'.$_SERVER['QUERY_STRING']);



curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
$out = curl_exec($curl);
include 'config.php';
$out=str_replace('href="/inet/weather/','href="',$out);
$out=preg_replace('|города</a>(.*?)</div>|si','города</a></br>',$out);
$out=str_replace('src="/css/thm/18/','src="',$out);

$out=str_replace('action="/inet/weather/','action="',$out);
$out=str_replace('<?xml version="1.0" encoding="utf-8"?>','',$out);
$out=preg_replace('|<!DOCTYPE(.*?)<div class="contur">|si','',$out);
$out=preg_replace('|Предо(.*?)</a><br/>|si','',$out);

$out=preg_replace('|<div class="footer">(.*?)</html>|si','',$out);
curl_close($curl);
echo $out;
}else{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://rugame.mobi/inet/weather/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,"hidden=".$_POST['hidden']."&PHPSESSID=".$_POST['PHPSESSID']."&town=".$_POST['town']."&submit=Найти");
$out = curl_exec($curl);
$out=str_replace('<?xml version="1.0" encoding="utf-8"?>','',$out);
$out=preg_replace('|<!DOCTYPE(.*?)<div class="contur">|si','',$out);
$out=preg_replace('|<div class="footer">(.*?)</html>|si','',$out);

$out=str_replace('action="/inet/weather/','action="',$out);
$out=str_replace('href="/inet/weather/','href="',$out);
$out=str_replace('src="/css/thm/18/','src="',$out);
include 'config.php';

curl_close($curl);
echo $out;
}
include '../inc/foot.php';
?>
