File size: 2.14Kb
<?
header("Content-type:text/vnd.wap.wml;charset=utf-8");
print "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
print "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">";
print "<wml>";
print "<card id=\"index\" title=\"Погода\">";
print "<p align=\"center\">";
print "<small>";
if ($city!=""){
$host = "wap.gismeteo.ru";
if ($city=="mosk"){$path="/27612.wml"; $title="Москва:";};
if ($city=="novosib"){$path="/29634.wml"; $title="Новосибирск:";};
if ($city=="vlad"){$path="/31960.wml"; $title="Владивосток:";};
$fp = fsockopen($host,80,$errno,$errstr,30);
if(!$fp) echo"<b>Ошибка при соединении!</b><br/>";
else{
$headers = "GET $path HTTP/1.0\r\n";
$headers .= "Host: $host\r\n";
$headers .= "Accept: *\r\n";
$headers .="Accept-Charset: UTF-8\r\n";
$headers .= "Accept-Charset: *\r\n";
$headers .= "Accept-Encoding: deflate\r\n";
$headers .= "Accept-Language: ru\r\n";
$headers .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; ru) Opera 8.01\r\n\r\n";
fwrite($fp,$headers);
while($text != "\r\n") $text = fgets($fp,128);
$text = "";
while(!feof($fp)) $text .= fgets($fp,4096);
fclose($fp);
$text=strstr($text,"<p><b>");
$rep=strstr($text,'<p><a href');
$text=str_replace($rep,"",$text);
$text=str_replace("Day","день",$text);
$text=str_replace("Night","ночь",$text);
$text=str_replace("img/","http://wap.gismeteo.ru/img/",$text);
print "<b>$title</b>";
print "</small></p>";
print "<p align=\"left\"><small>";
print "$text";};}
else {print "<b>Вы не выбрали город, вернитесь назад!</b>";};
print "</small></p></card></wml>";
?>