咳咳...
廢話少講, 開始啦~~~~
代碼: 選擇全部
########################################################
## Mod Title: 香港/台灣天氣報告
## Mod Version: 0.0.0
## Author: 本人,
##
## Description:
## 貼檔頭只不過是剛剛無聊看版規是看到的, 基本上沒有甚麼特別, 只是在論
## 壇加個天氣報告的文字而已。
## 版本嘛, 應該甚麼版本都可以, 因為這個「外掛」可以抽出來用來設計你的
## 網站...
##
## Installation Level: Easy
## Installation Time: 不知道...因為小人邊寫邊試...
## Files To Edit: 4
## includes/page_header.php
## language/lang_chinese_traditional_taiwan/lang_main.php
## language/lang_chinese_english/lang_main.php
## templates/SubSilver/overall_header.tpl
##
##########################################################
##
## Installation Notes:
##
## There is some customization that will need to be
## done in Viewtopic_body.tpl It is really up to you
## where you want it to be placed.
##
########################################################
找到
代碼: 選擇全部
//
// Generate HTML required for Mozilla Navigation bar
//
if (!isset($nav_links))
{
$nav_links = array();
}
代碼: 選擇全部
$weather['str'] = file_get_contents("http://www.weather.gov.hk/textonly/forecast/chinesewx.htm");
$weather['time'] = substr($weather['str'], 378, 31);
$weather['time'] = explode(" ", $weather['time']);
$weather['time'] = $weather['time'][0] . "-" . $weather['time'][2] . "-" . $weather['time'][4] . " " . $weather['time'][6] . ":" . $weather['time'][8];
$weather['str'] = file("http://www.weather.gov.hk/textonly/forecast/englishwx.htm");
$weather['temp'] = $weather['str'][12];
$weather['temp'] = str_replace("AIR TEMPERATURE : ", "", $weather['temp']);
$weather['temp'] = str_replace(" DEGREES CELSIUS", "", $weather['temp']);
$weather['temp'] = str_replace(" ", "", $weather['temp']);
$weather['temp'] = str_replace("\n", "", $weather['temp']);
$weather['humi'] = $weather['str'][13];
$weather['humi'] = str_replace("RELATIVE HUMIDITY : ", "", $weather['humi']);
$weather['humi'] = str_replace(" PER CENT", "", $weather['humi']);
$weather['humi'] = str_replace(" ", "", $weather['humi']);
$weather['humi'] = str_replace("\n", "", $weather['humi']);
的數字會因為地區而有所改變,
代碼: 選擇全部
$weather['str'] = file("http://www.cwb.gov.tw/V4e/weather/Data/E02.htm");
$weather['time'] = $weather['str'][15];
$weather['time'] = str_replace("<br>", "", $weather['time']);
$weather['time'] = str_replace("\n", "", $weather['time']);
$weather['time'] = "Issued at 10:30(L), 27 Feb 2006";
$weather['time'] = explode(" ", $weather['time']);
$weather['year'] = $weather['time'][5];
$weather['month'] = $weather['time'][4];
switch ($weather['month']) {
case "Jan":
$weather['month'] = "01";
break;
case "Feb":
$weather['month'] = "02";
break;
case "Mar":
$weather['month'] = "03";
break;
case "Apr":
$weather['month'] = "04";
break;
case "May":
$weather['month'] = "05";
break;
case "Jun":
$weather['month'] = "06";
break;
case "Jul":
$weather['month'] = "07";
break;
case "Aug":
$weather['month'] = "08";
break;
case "Sep":
$weather['month'] = "09";
break;
case "Oct":
$weather['month'] = "10";
break;
case "Nov":
$weather['month'] = "11";
break;
case "Dec":
$weather['month'] = "12";
break;
}
$weather['day'] = $weather['time'][3];
$weather['Hi'] = str_replace("(L),", "", $weather['time'][2]);
$weather['time'] = $weather['year'] . "-" . $weather['month'] . "-" . $weather['day'] . " " . $weather['Hi'];
$weather['data'] = $weather['str'][19]; //這是台北市, 下面有個小小的對照表...
$weather['temp'] = preg_replace("/(.*)\%/", "", $weather['data']);
$weather['temp'] = str_replace("℃", "", $weather['temp']);
$weather['temp'] = str_replace(" ", "", $weather['temp']);
$weather['temp'] = str_replace("<br>", "", $weather['temp']);
$weather['temp'] = str_replace("\n", "", $weather['temp']);
$weather['humi'] = explode(" ", $weather['data']);
$count['humi'] = count($weather['humi'])-4;
$weather['humi'] = $weather['humi'][$count['humi']];
$weather['humi'] = str_replace(" ", "", $weather['humi']);
$weather['humi'] = str_replace("%", "", $weather['humi']);
$weather['humi'] = str_replace("<br>", "", $weather['humi']);
$weather['humi'] = str_replace("\n", "", $weather['humi']);
台灣各區的行數不同喔...要把註釋那行的數字改掉
19 - 台北
21 - 高雄
23 - 基隆
25 - 台北地區
27 - 桃園
29 - 新竹
呃, 之後的看不懂...
如此類推...
這裏看不到的請到http://www.cwb.gov.tw/V4e/weather/Data/E02.htm由台北開始慢慢數...(抱歉啦, 你們氣象站的拼音不是太看得懂...譯到幾個都還不錯吧)
找到
代碼: 選擇全部
'T_SPAN_CLASS1' => $theme['span_class1'],
'T_SPAN_CLASS2' => $theme['span_class2'],
'T_SPAN_CLASS3' => $theme['span_class3'],
代碼: 選擇全部
//
// Weather report
//
'WEATHER_TIME' => $weather['time'],
'WEATHER_TEMP' => $weather['temp'],
'WEATHER_HUMI' => $weather['humi'],
'L_WEATHER_TITLE' => $lang['Weather_title'],
'L_WEATHER_TIME' => $lang['Weather_time'],
'L_WEATHER_HUMI' => $lang['Weather_humi'],
'L_WEATHER_TEMP' => $lang['Weather_temp'],
'L_WEATHER_TEMPS' => $lang['Weather_temp_sign'],
找到
代碼: 選擇全部
//
// That's all Folks!
// -------------------------------------------------
代碼: 選擇全部
//
// Weather Report
//
$lang['Weather_title'] = "天氣報告";
$lang['Weather_temp'] = "氣溫:";
$lang['Weather_temp_sign'] = "℃ ";
$lang['Weather_humi'] = "相對濕度:";
$lang['Weather_time'] = "最後更新:";
找到
代碼: 選擇全部
//
// That's all Folks!
// -------------------------------------------------
代碼: 選擇全部
//
// Weather Report
//
$lang['Weather_title'] = "Weather Report";
$lang['Weather_temp'] = "Temperature:";
$lang['Weather_temp_sign'] = "Degrees Centigrade";
$lang['Weather_humi'] = "Humidity:";
$lang['Weather_time'] = "Last modify:";
找到
代碼: 選擇全部
一個自己喜歡的地方
代碼: 選擇全部
{L_WEATHER_TITLE} - {L_WEATHER_TEMP} {WEATHER_TEMP}{L_WEATHER_TEMPS} / {L_WEATHER_HUMI} {WEATHER_HUMI}% / {L_WEATHER_TIME} {WEATHER_TIME}
2006年2月27日更新:
加了台灣版本...惜本人覺得應該會有更精簡的方法...希望各位大大可以提供, 給予改善...(其實是為了節省流量)