????? ?????? ??????? ?? ??? ???????? ?? ????? ??? ??????
مرسل: الخميس أكتوبر 09, 2008 11:46 pm
????? ?????? ??????? ?? ??? ???????? ?? ????? ??? ??????
??? ??? ?????? ???? ???? ???? ????????... ???? ???? ?????? ?????? ?? ???? ????? CNN.
?????: ???: portal/block/weather.php
???????? ?????? ???? ????????? ???? ???? ??? ?? ???????.
??? ??? ?????? ???? ???? ???? ????????... ???? ???? ?????? ?????? ?? ???? ????? CNN.
?????: ???: portal/block/weather.php
كود: تحديد الكل
<?php
if (!defined('IN_PHPBB'))
{
exit;
}
//???? IF ??? ??? ????? ???????? ?? 3 ?????
if($config['portal_weather_last_update']<time()-3*3600){
//??????? ???? ???? ??? ???????? ?? ?????
$url = "http://weather.cnn.com/weather/forecast.jsp?celcius=true&locCode=OSHM&zipCode=443326227772";
$text = file_get_contents($url);
//?????? ??? ???????? ?? ??????
preg_match_all('#<div class="cnnWeatherTempCurrent">([0-9\-\+]+).</div>#', $text, $info);
$current_temp = $info[1][0];
preg_match_all('#<b>Hi ([0-9\-\+]+).</b>#', $text, $info);
$high_temp = $info[1][0];
preg_match_all('#<b>Lo ([0-9\-\+]+).</b>#', $text, $info);
$low_temp = $info[1][0];
preg_match_all('#"cnnWeatherConditionCurrent">([a-zA-Z0-9 ]+)</span>#', $text, $info);
$current_condition = trim($info[1][0]);
$current_condition = ($user->lang["PWATH_".$current_condition])?$user->lang["PWATH_".$current_condition]:$current_condition;
preg_match_all('#<b>Sunrise: </b>([0-9:]+) .<br>#', $text, $info);
$sunrise = $info[1][0];
preg_match_all('#<b>Sunset: </b>([0-9:]+) .<br>#', $text, $info);
$sunset = $info[1][0];
preg_match_all('#<b>Humidity: </b>([0-9]+)%<br>#', $text, $info);
$humidity = $info[1][0];
preg_match_all('#src="http:\/\/i\.cdn\.turner\.com\/cnn\/\.element\/img\/2\.0\/weather\/04\/([0-9]+)\.gif"#', $text, $info);
$img_src = $info[1][0];
set_config('portal_weather_last_update',time());
set_config('portal_weather_info',$current_temp."|".$high_temp."|".$low_temp."|".$current_condition."|".$sunrise."|".$sunset."|".$humidity."|".$img_src);
}else{
$info = explode("|",$config['portal_weather_info']);
$current_temp = $info[0];
$high_temp = $info[1];
$low_temp = $info[2];
$current_condition = $info[3];
$sunrise = $info[4];
$sunset = $info[5];
$humidity = $info[6];
$img_src = $info[7];
}
$template->assign_vars(array(
'PW_CURRENT_TEMP' => $current_temp,
'PW_HIGH_TEMP' => $high_temp,
'PW_LOW_TEMP' => $low_temp,
'PW_CURRENT_CONDITION' => $current_condition,
'PW_SUNRISE' => $sunrise." ".$user->lang['datetime']['am'],
'PW_SUNSET' => $sunset." ".$user->lang['datetime']['pm'],
'PW_HUMIDITY' => $humidity,
'PW_IMG_SRC' => $img_src,
));
?>