Просмотр файла meteo/meteo.php

Размер файла: 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=\"&#1055;&#1086;&#1075;&#1086;&#1076;&#1072;\">";
print "<p align=\"center\">";
print "<small>";

if ($city!=""){
$host = "wap.gismeteo.ru";

if ($city=="mosk"){$path="/27612.wml"; $title="&#1052;&#1086;&#1089;&#1082;&#1074;&#1072;:";};
if ($city=="novosib"){$path="/29634.wml"; $title="&#1053;&#1086;&#1074;&#1086;&#1089;&#1080;&#1073;&#1080;&#1088;&#1089;&#1082;:";};
if ($city=="vlad"){$path="/31960.wml"; $title="&#1042;&#1083;&#1072;&#1076;&#1080;&#1074;&#1086;&#1089;&#1090;&#1086;&#1082;:";};

$fp = fsockopen($host,80,$errno,$errstr,30);
if(!$fp) echo"<b>&#1054;&#1096;&#1080;&#1073;&#1082;&#1072; &#1087;&#1088;&#1080; &#1089;&#1086;&#1077;&#1076;&#1080;&#1085;&#1077;&#1085;&#1080;&#1080;!</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","&#1076;&#1077;&#1085;&#1100;",$text);
$text=str_replace("Night","&#1085;&#1086;&#1095;&#1100;",$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>&#1042;&#1099; &#1085;&#1077; &#1074;&#1099;&#1073;&#1088;&#1072;&#1083;&#1080; &#1075;&#1086;&#1088;&#1086;&#1076;, &#1074;&#1077;&#1088;&#1085;&#1080;&#1090;&#1077;&#1089;&#1100; &#1085;&#1072;&#1079;&#1072;&#1076;!</b>";};
print "</small></p></card></wml>";
?>