[pLog-svn] r3849 - in plugins/branches/lifetype-1.0: . hknews
hknews/class hknews/class/action hknews/class/view
hknews/locale hknews/templates hkweather hkweather/class
hkweather/class/action hkweather/class/view hkweather/locale
hkweather/templates
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Wed Aug 9 15:54:34 GMT 2006
Author: oscar
Date: 2006-08-09 15:54:33 +0000 (Wed, 09 Aug 2006)
New Revision: 3849
Added:
plugins/branches/lifetype-1.0/hknews/
plugins/branches/lifetype-1.0/hknews/class/
plugins/branches/lifetype-1.0/hknews/class/action/
plugins/branches/lifetype-1.0/hknews/class/action/pluginhknewsconfigaction.class.php
plugins/branches/lifetype-1.0/hknews/class/action/pluginhknewsupdateconfigaction.class.php
plugins/branches/lifetype-1.0/hknews/class/view/
plugins/branches/lifetype-1.0/hknews/class/view/pluginhknewsconfigview.class.php
plugins/branches/lifetype-1.0/hknews/locale/
plugins/branches/lifetype-1.0/hknews/locale/locale_en_UK.php
plugins/branches/lifetype-1.0/hknews/locale/locale_zh_CN.php
plugins/branches/lifetype-1.0/hknews/locale/locale_zh_TW.php
plugins/branches/lifetype-1.0/hknews/pluginhknews.class.php
plugins/branches/lifetype-1.0/hknews/readme.txt
plugins/branches/lifetype-1.0/hknews/templates/
plugins/branches/lifetype-1.0/hknews/templates/hknews.template
plugins/branches/lifetype-1.0/hkweather/
plugins/branches/lifetype-1.0/hkweather/class/
plugins/branches/lifetype-1.0/hkweather/class/action/
plugins/branches/lifetype-1.0/hkweather/class/action/pluginhkweatherconfigaction.class.php
plugins/branches/lifetype-1.0/hkweather/class/action/pluginhkweatherupdateconfigaction.class.php
plugins/branches/lifetype-1.0/hkweather/class/view/
plugins/branches/lifetype-1.0/hkweather/class/view/pluginhkweatherconfigview.class.php
plugins/branches/lifetype-1.0/hkweather/locale/
plugins/branches/lifetype-1.0/hkweather/locale/locale_en_UK.php
plugins/branches/lifetype-1.0/hkweather/locale/locale_zh_CN.php
plugins/branches/lifetype-1.0/hkweather/locale/locale_zh_TW.php
plugins/branches/lifetype-1.0/hkweather/pluginhkweather.class.php
plugins/branches/lifetype-1.0/hkweather/readme.txt
plugins/branches/lifetype-1.0/hkweather/templates/
plugins/branches/lifetype-1.0/hkweather/templates/hkweather.template
Log:
added the 'hknews' and 'hkweather' plugins
Added: plugins/branches/lifetype-1.0/hknews/class/action/pluginhknewsconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.0/hknews/class/action/pluginhknewsconfigaction.class.php 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hknews/class/action/pluginhknewsconfigaction.class.php 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,26 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/hknews/class/view/pluginhknewsconfigview.class.php" );
+
+ /**
+ * shows a form with the current configuration
+ */
+ class PluginHKNewsConfigAction extends AdminAction
+ {
+
+ function PluginHKNewsConfigAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ function perform()
+ {
+ $this->_view = new PluginHKNewsConfigView( $this->_blogInfo );
+
+ $this->setCommonData();
+
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Property changes on: plugins/branches/lifetype-1.0/hknews/class/action/pluginhknewsconfigaction.class.php
___________________________________________________________________
Name: svn:executable
+ *
Added: plugins/branches/lifetype-1.0/hknews/class/action/pluginhknewsupdateconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.0/hknews/class/action/pluginhknewsupdateconfigaction.class.php 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hknews/class/action/pluginhknewsupdateconfigaction.class.php 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,71 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/hknews/class/view/pluginhknewsconfigview.class.php" );
+
+ /**
+ * updates the plugin configuration
+ */
+ class PluginHKNewsUpdateConfigAction extends AdminAction
+ {
+ var $_pluginEnabled;
+ var $_lang;
+ var $_dispitem;
+
+ function PluginHKNewsUpdateConfigAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ function validate()
+ {
+ $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+ $this->_pluginEnabled = ($this->_pluginEnabled != "" );
+ $this->_lang = $this->_request->getValue( "lang" );
+ $this->_dispitem = $this->_request->getValue( "dispitem" );
+ if( $this->_dispitem <= 0 || !ctype_digit($this->_dispitem) ) {
+ $this->_view = new PluginHKNewsConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("hknews_error_dispitem"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+ return true;
+ }
+
+ function perform()
+ {
+ // update the plugin configurations to blog setting
+ $blogSettings = $this->_blogInfo->getSettings();
+ $blogSettings->setValue( "plugin_hknews_enabled", $this->_pluginEnabled );
+ $blogSettings->setValue( "plugin_hknews_lang", $this->_lang );
+ $blogSettings->setValue( "plugin_hknews_dispitem", $this->_dispitem );
+ $this->_blogInfo->setSettings( $blogSettings );
+
+ // save the blogs settings
+ $blogs = new Blogs();
+ if( !$blogs->updateBlog( $this->_blogInfo->getId(), $this->_blogInfo )) {
+ $this->_view = new PluginHKNewsConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_settings"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+ // if everything went ok...
+ $this->_blogInfo->setSettings( $blogSettings );
+ $this->_session->setValue( "blogInfo", $this->_blogInfo );
+ $this->saveSession();
+
+ $this->_view = new PluginHKNewsConfigView( $this->_blogInfo );
+ $this->_view->setSuccessMessage( $this->_locale->tr("hknews_settings_saved_ok"));
+ $this->setCommonData();
+
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Property changes on: plugins/branches/lifetype-1.0/hknews/class/action/pluginhknewsupdateconfigaction.class.php
___________________________________________________________________
Name: svn:executable
+ *
Added: plugins/branches/lifetype-1.0/hknews/class/view/pluginhknewsconfigview.class.php
===================================================================
--- plugins/branches/lifetype-1.0/hknews/class/view/pluginhknewsconfigview.class.php 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hknews/class/view/pluginhknewsconfigview.class.php 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,32 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+ /**
+ * implements the main view of the feed reader plugin
+ */
+ class PluginHKNewsConfigView extends AdminPluginTemplatedView
+ {
+
+ function PluginHKNewsConfigView( $blogInfo )
+ {
+ $this->AdminPluginTemplatedView( $blogInfo, "hknews", "hknews" );
+ }
+
+ function render()
+ {
+ // load some configuration settings
+ $blogSettings = $this->_blogInfo->getSettings();
+ $pluginEnabled = $blogSettings->getValue( "plugin_hknews_enabled" );
+ $lang = $blogSettings->getValue( "plugin_hknews_lang" );
+ $dispitem = $blogSettings->getValue( "plugin_hknews_dispitem" );
+
+ // create a view and export the settings to the template
+ $this->setValue( "pluginEnabled", $pluginEnabled );
+ $this->setValue( "lang", $lang );
+ $this->setValue( "dispitem", $dispitem );
+
+ parent::render();
+ }
+ }
+?>
\ No newline at end of file
Property changes on: plugins/branches/lifetype-1.0/hknews/class/view/pluginhknewsconfigview.class.php
___________________________________________________________________
Name: svn:executable
+ *
Added: plugins/branches/lifetype-1.0/hknews/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.0/hknews/locale/locale_en_UK.php 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hknews/locale/locale_en_UK.php 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,19 @@
+<?php
+$messages["embeddedApps"] = "Embedded Applications";
+
+$messages["HKNews"] = "HKWeather";
+$messages["hknews"] = "hkweather";
+
+$messages["hknews_plugin_enabled"] = "Enable this plugin";
+$messages["hknews_plugin"] = "HKNews Plugin";
+$messages["hknews_dispitem"] = "No. of News";
+
+$messages["hknews_settings_saved_ok"] = "HKNews settings saved successfully!";
+$messages["hknews_error_dispitem"] = "No. of News should > 0!";
+
+$messages["label_configuration"] = "Configuration";
+$messages["label_enable"] = "Enable";
+$messages["label_lang"] = "Language";
+$messages["label_dispitem"] = "No. of News";
+
+?>
\ No newline at end of file
Property changes on: plugins/branches/lifetype-1.0/hknews/locale/locale_en_UK.php
___________________________________________________________________
Name: svn:executable
+ *
Added: plugins/branches/lifetype-1.0/hknews/locale/locale_zh_CN.php
===================================================================
--- plugins/branches/lifetype-1.0/hknews/locale/locale_zh_CN.php 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hknews/locale/locale_zh_CN.php 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,17 @@
+<?php
+$messages["embeddedApps"] = "Embedded Applications";
+$messages["HKNews"] = "馿¸¯æ°é»è®¾å®";
+$messages["hknews"] = "馿¸¯æ°é»";
+
+$messages["hknews_plugin_enabled"] = "å¯å¨é¦æ¸¯æ°é»å¤æç¨å¼";
+$messages["hknews_plugin"] = "馿¸¯æ°é»å¤æç¨å¼";
+$messages["hknews_dispitem"] = "æ¾ç¤ºæ°é»æ°é";
+
+$messages["hknews_settings_saved_ok"] = "馿¸¯æ°é»è®¾å®å¨åæåã";
+$messages["hknews_error_dispitem"] = "馿¸¯æ°é»æ¾ç¤ºæ°éå¿
é¡»è¦ > 0!";
+
+$messages["label_configuration"] = "设å®";
+$messages["label_enable"] = "å¯å¨";
+$messages["label_lang"] = "æ¾ç¤ºè¯è¨";
+$messages["label_dispitem"] = "æ¾ç¤ºæ°é»æ°é";
+?>
\ No newline at end of file
Property changes on: plugins/branches/lifetype-1.0/hknews/locale/locale_zh_CN.php
___________________________________________________________________
Name: svn:executable
+ *
Added: plugins/branches/lifetype-1.0/hknews/locale/locale_zh_TW.php
===================================================================
--- plugins/branches/lifetype-1.0/hknews/locale/locale_zh_TW.php 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hknews/locale/locale_zh_TW.php 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,17 @@
+<?php
+$messages["embeddedApps"] = "Embedded Applications";
+$messages["HKNews"] = "馿¸¯æ°èè¨å®";
+$messages["hknews"] = "馿¸¯æ°è";
+
+$messages["hknews_plugin_enabled"] = "åå馿¸¯æ°è夿ç¨å¼";
+$messages["hknews_plugin"] = "馿¸¯æ°è夿ç¨å¼";
+$messages["hknews_dispitem"] = "顯示æ°èæ¸é";
+
+$messages["hknews_settings_saved_ok"] = "馿¸¯æ°èè¨å®å²åæåã";
+$messages["hknews_error_dispitem"] = "馿¸¯æ°è顯示æ¸éå¿
é è¦ > 0!";
+
+$messages["label_configuration"] = "è¨å®";
+$messages["label_enable"] = "åå";
+$messages["label_lang"] = "顯示èªè¨";
+$messages["label_dispitem"] = "顯示æ°èæ¸é";
+?>
\ No newline at end of file
Property changes on: plugins/branches/lifetype-1.0/hknews/locale/locale_zh_TW.php
___________________________________________________________________
Name: svn:executable
+ *
Added: plugins/branches/lifetype-1.0/hknews/pluginhknews.class.php
===================================================================
--- plugins/branches/lifetype-1.0/hknews/pluginhknews.class.php 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hknews/pluginhknews.class.php 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,133 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+ include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
+
+ /**
+ * Plugin that offers features to returns the hk news information
+ */
+ class PluginHKNews extends PluginBase
+ {
+ var $pluginEnabled;
+ var $lang;
+ var $dispitem;
+
+ function PluginHKNews()
+ {
+ $this->PluginBase();
+
+ $this->id = "hknews";
+ $this->author = "Matthew Chin and Gary Chun";
+ $this->desc = "This plugin display HK News.";
+
+ $this->locales = Array( "en_UK" , "zh_TW" , "zh_CN" );
+
+ $this->init();
+ }
+
+ function init()
+ {
+ $this->registerAdminAction( "hknews", "PluginHKNewsConfigAction" );
+ $this->registerAdminAction( "updateHKNewsConfig", "PluginHKNewsUpdateConfigAction" );
+
+ $menu =& Menu::getMenu();
+ if( !$menu->entryExists( "/menu/controlCenter/embeddedApps" ))
+ $this->addMenuEntry( "/menu/controlCenter", "embeddedApps", "", "", true, false );
+ $this->addMenuEntry( "/menu/controlCenter/embeddedApps", "HKNews", "?op=hknews", "" );
+
+ }
+
+ function register()
+ {
+ $blogSettings = $this->blogInfo->getSettings();
+ $this->pluginEnabled = $blogSettings->getValue( "plugin_hknews_enabled" );
+ $this->lang = $blogSettings->getValue( "plugin_hknews_lang" );
+ $this->dispitem = $blogSettings->getValue( "plugin_hknews_dispitem" );
+ }
+
+ function isEnabled()
+ {
+ return $this->pluginEnabled;
+ }
+ /**
+ * Returns the HKNews
+ */
+ function getHKNews()
+ {
+
+ if ($this->lang == 'Chinese') {
+
+
+$data = file_get_contents('http://app1.rthk.org.hk/text/news/headline.php');
+preg_match_all('/\s*<a href=\"news.php?([^>]+)\">(.*?)<\/a>/i', $data, $matches);
+
+
+$i = 0;
+foreach($matches[0] as $match) {
+if ($i > ($this->dispitem - 1)) { break; }
+
+$data = strip_tags($match);
+$text = "- " . iconv("BIG5", "UTF-8", "$data <br>");
+
+
+$webtext = 'http://app1.rthk.org.hk/text/news/news.php?id=';
+
+$itemid = substr("$match", 30, 6);
+$final = $webtext . $itemid ;
+
+
+$wdata = file_get_contents($final);
+preg_match_all("|<p><font size=\"3\">(.*?)<p> </p>|ism",$wdata,$wmatches);
+
+foreach($wmatches[0] as $wmatch) {
+$wtemp = strip_tags($wmatch);
+$result = iconv("BIG5", "UTF-8", "$wtemp");
+
+print "<A HREF=\"$final\" TITLE=\"$result \">$text</A>" ;
+}
+
+$i++;
+}
+}
+
+else
+{
+
+
+$today = date ("Ymd");
+$file = "http://www.rthk.org.hk/rthk/news/englishnews/" . $today . "/news_" . $today . "_index.htm";
+$data = file_get_contents($file);
+preg_match_all('/<!-- news headline -->\s*<a href=\"\/rthk\/news\/englishnews\/news\.htm\?englishnews([^>]+).*?>(.*?)<\/a>/i', $data, $matches);
+
+
+$i = 0;
+foreach($matches[0] as $match) {
+if ($i > ($this->dispitem - 1)) { break; }
+$data = strip_tags($match);
+$text = "- " . "$data <br>";
+
+
+$webtext = 'http://www.rthk.org.hk/rthk/news/englishnews/';
+$yymmdd = substr("$match", 76, 8);
+$catid = substr("$match", 85, 2);
+$itemid = substr("$match", 88, 6);
+$final = $webtext . '/' . $yymmdd . '/news_' . $yymmdd . '_' . $catid . '_' . $itemid . '.htm' ;
+
+
+$wdata = file_get_contents($final);
+preg_match_all("|<!-- content -->(.*?)<!-- content end -->|ism",$wdata,$wmatches);
+
+foreach($wmatches[0] as $wmatch) {
+$wtemp = strip_tags($wmatch);
+$result = $wtemp;
+
+print "<A HREF=\"$final\" TITLE=\"$result \">$text</A>" ;
+
+}
+
+$i++;
+}
+}
+ }
+ }
+?>
\ No newline at end of file
Property changes on: plugins/branches/lifetype-1.0/hknews/pluginhknews.class.php
___________________________________________________________________
Name: svn:executable
+ *
Added: plugins/branches/lifetype-1.0/hknews/readme.txt
===================================================================
--- plugins/branches/lifetype-1.0/hknews/readme.txt 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hknews/readme.txt 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,18 @@
+Plugin: HK News
+Author: Matthew Chin and Gary Chun
+Release Date: 2006/08/08
+Version: 2.6
+
+This plugin display the HK News. Usage as follow:
+
+You can use:
+1. $hknews->isEnabled() to check the plugin is enabled or not.
+2. $hknews->getHKNews() to get the hk news.
+
+Where:
+
+Example:
+{if $hknews->isEnabled()}
+<h2>HK News</h2>
+{ $hknews->getHKNews() }
+{/if}
\ No newline at end of file
Property changes on: plugins/branches/lifetype-1.0/hknews/readme.txt
___________________________________________________________________
Name: svn:executable
+ *
Added: plugins/branches/lifetype-1.0/hknews/templates/hknews.template
===================================================================
--- plugins/branches/lifetype-1.0/hknews/templates/hknews.template 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hknews/templates/hknews.template 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,67 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=hknews title=$locale->tr("hknews_plugin")}
+<form name="hknewsPluginConfig" method="post">
+ <fieldset class="inputField">
+ <legend>{$locale->tr("label_configuration")}</legend>
+ {include file="$admintemplatepath/successmessage.template"}
+ {include file="$admintemplatepath/errormessage.template"}
+ <div class="field">
+ <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
+ <span class="required"></span>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1" />{$locale->tr("hknews_plugin_enabled")}
+ </div>
+ </div>
+
+ <div class="field">
+ <label for="lang">{$locale->tr("label_lang")}</label>
+ <span class="required"></span>
+ <div class="formHelp">
+ <table>
+ <thead>
+ <tr>
+ <th style="width:20px;"></th>
+ <th style="width:130px;"></th>
+ </tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>
+ <input class="radio" type="radio" name="lang" id="lang" value="English" {if $lang} checked="checked" {/if} />
+ </td>
+ <td>
+ English
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input class="radio" type="radio" name="lang" id="lang" value="Chinese" {if $lang} checked="checked" {/if} />
+ </td>
+ <td>
+ Chinese
+ </td>
+ </tr>
+
+ </tbody>
+ </table>
+ </div></div>
+
+
+ <div class="field">
+ <label for="dispitem">{$locale->tr("label_dispitem")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("hknews_dispitem")}</div>
+ <input class="text" type="text" name="dispitem" id="dispitem" value="{$dispitem}" width="10" />
+ </div>
+ </fieldset>
+
+
+ <div class="buttons">
+ <input type="hidden" name="op" value="updateHKNewsConfig" />
+ <input type="reset" name="{$locale->tr("reset")}" />
+ <input type="submit" name="{$locale->tr("update_settings")}" value="{$locale->tr("update")}" />
+ </div>
+</form>
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
Property changes on: plugins/branches/lifetype-1.0/hknews/templates/hknews.template
___________________________________________________________________
Name: svn:executable
+ *
Added: plugins/branches/lifetype-1.0/hkweather/class/action/pluginhkweatherconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.0/hkweather/class/action/pluginhkweatherconfigaction.class.php 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hkweather/class/action/pluginhkweatherconfigaction.class.php 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,26 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/hkweather/class/view/pluginhkweatherconfigview.class.php" );
+
+ /**
+ * shows a form with the current configuration
+ */
+ class PluginHKWeatherConfigAction extends AdminAction
+ {
+
+ function PluginHKWeatherConfigAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ function perform()
+ {
+ $this->_view = new PluginHKWeatherConfigView( $this->_blogInfo );
+
+ $this->setCommonData();
+
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.0/hkweather/class/action/pluginhkweatherupdateconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.0/hkweather/class/action/pluginhkweatherupdateconfigaction.class.php 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hkweather/class/action/pluginhkweatherupdateconfigaction.class.php 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,61 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/hkweather/class/view/pluginhkweatherconfigview.class.php" );
+
+ /**
+ * updates the plugin configuration
+ */
+ class PluginHKWeatherUpdateConfigAction extends AdminAction
+ {
+ var $_pluginEnabled;
+ var $_lang;
+
+ function PluginHKWeatherUpdateConfigAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ function validate()
+ {
+ $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+ $this->_pluginEnabled = ($this->_pluginEnabled != "" );
+ $this->_lang = $this->_request->getValue( "lang" );
+
+ return true;
+ }
+
+ function perform()
+ {
+ // update the plugin configurations to blog setting
+ $blogSettings = $this->_blogInfo->getSettings();
+ $blogSettings->setValue( "plugin_hkweather_enabled", $this->_pluginEnabled );
+ $blogSettings->setValue( "plugin_hkweather_lang", $this->_lang );
+ $this->_blogInfo->setSettings( $blogSettings );
+
+ // save the blogs settings
+ $blogs = new Blogs();
+ if( !$blogs->updateBlog( $this->_blogInfo->getId(), $this->_blogInfo )) {
+ $this->_view = new PluginHKWeatherConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_settings"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+ // if everything went ok...
+ $this->_blogInfo->setSettings( $blogSettings );
+ $this->_session->setValue( "blogInfo", $this->_blogInfo );
+ $this->saveSession();
+
+ $this->_view = new PluginHKWeatherConfigView( $this->_blogInfo );
+ $this->_view->setSuccessMessage( $this->_locale->tr("hkweather_settings_saved_ok"));
+ $this->setCommonData();
+
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.0/hkweather/class/view/pluginhkweatherconfigview.class.php
===================================================================
--- plugins/branches/lifetype-1.0/hkweather/class/view/pluginhkweatherconfigview.class.php 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hkweather/class/view/pluginhkweatherconfigview.class.php 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,30 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+ /**
+ * implements the main view of the feed reader plugin
+ */
+ class PluginHKWeatherConfigView extends AdminPluginTemplatedView
+ {
+
+ function PluginHKWeatherConfigView( $blogInfo )
+ {
+ $this->AdminPluginTemplatedView( $blogInfo, "hkweather", "hkweather" );
+ }
+
+ function render()
+ {
+ // load some configuration settings
+ $blogSettings = $this->_blogInfo->getSettings();
+ $pluginEnabled = $blogSettings->getValue( "plugin_hkweather_enabled" );
+ $lang = $blogSettings->getValue( "plugin_hkweather_lang" );
+
+ // create a view and export the settings to the template
+ $this->setValue( "pluginEnabled", $pluginEnabled );
+ $this->setValue( "lang", $lang );
+
+ parent::render();
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.0/hkweather/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.0/hkweather/locale/locale_en_UK.php 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hkweather/locale/locale_en_UK.php 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,16 @@
+<?php
+$messages["embeddedApps"] = "Embedded Applications";
+
+$messages["HKWeather"] = "HKWeather";
+$messages["hkweather"] = "hkweather";
+
+$messages["hkweather_plugin_enabled"] = "Enable this plugin";
+$messages["hkweather_plugin"] = "HKWeather Plugin";
+
+$messages["hkweather_settings_saved_ok"] = "HKWeather settings saved successfully!";
+
+$messages["label_configuration"] = "Configuration";
+$messages["label_enable"] = "Enable";
+$messages["label_lang"] = "Language";
+
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.0/hkweather/locale/locale_zh_CN.php
===================================================================
--- plugins/branches/lifetype-1.0/hkweather/locale/locale_zh_CN.php 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hkweather/locale/locale_zh_CN.php 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,15 @@
+<?php
+$messages["embeddedApps"] = "Embedded Applications";
+$messages["HKWeather"] = "馿¸¯å¤©æ°è®¾å®";
+$messages["hkweather"] = "馿¸¯å¤©æ°";
+
+$messages["hkweather_plugin_enabled"] = "å¯å¨é¦æ¸¯å¤©æ°å¤æç¨å¼";
+$messages["hkweather_plugin"] = "馿¸¯å¤©æ°å¤æç¨å¼";
+
+$messages["hkweather_settings_saved_ok"] = "馿¸¯å¤©æ°è®¾å®å¨åæåã";
+
+
+$messages["label_configuration"] = "设å®";
+$messages["label_enable"] = "å¯å¨";
+$messages["label_lang"] = "æ¾ç¤ºè¯è¨";
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.0/hkweather/locale/locale_zh_TW.php
===================================================================
--- plugins/branches/lifetype-1.0/hkweather/locale/locale_zh_TW.php 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hkweather/locale/locale_zh_TW.php 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,15 @@
+<?php
+$messages["embeddedApps"] = "Embedded Applications";
+$messages["HKWeather"] = "馿¸¯å¤©æ°£è¨å®";
+$messages["hkweather"] = "馿¸¯å¤©æ°£";
+
+$messages["hkweather_plugin_enabled"] = "åå馿¸¯å¤©æ°£å¤æç¨å¼";
+$messages["hkweather_plugin"] = "馿¸¯å¤©æ°£å¤æç¨å¼";
+
+$messages["hkweather_settings_saved_ok"] = "馿¸¯å¤©æ°£è¨å®å²åæåã";
+
+
+$messages["label_configuration"] = "è¨å®";
+$messages["label_enable"] = "åå";
+$messages["label_lang"] = "顯示èªè¨";
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.0/hkweather/pluginhkweather.class.php
===================================================================
--- plugins/branches/lifetype-1.0/hkweather/pluginhkweather.class.php 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hkweather/pluginhkweather.class.php 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,1009 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+ include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
+
+ /**
+ * Plugin that offers features to returns the hk weather informaion with rolling 7-day forecast
+ */
+ class PluginHKWeather extends PluginBase
+ {
+ var $pluginEnabled;
+ var $lang;
+
+ function PluginHKWeather()
+ {
+ $this->PluginBase();
+
+ $this->id = "hkweather";
+ $this->author = "Matthew Chin and Gary Chun";
+ $this->desc = "This plugin display HK weather with rolling 7-day forecast.";
+
+ $this->locales = Array( "en_UK" , "zh_TW" , "zh_CN" );
+
+ $this->init();
+ }
+
+ function init()
+ {
+ $this->registerAdminAction( "hkweather", "PluginHKWeatherConfigAction" );
+ $this->registerAdminAction( "updateHKWeatherConfig", "PluginHKWeatherUpdateConfigAction" );
+
+ $menu =& Menu::getMenu();
+ if( !$menu->entryExists( "/menu/controlCenter/embeddedApps" ))
+ $this->addMenuEntry( "/menu/controlCenter", "embeddedApps", "", "", true, false );
+ $this->addMenuEntry( "/menu/controlCenter/embeddedApps", "HKWeather", "?op=hkweather", "" );
+
+ }
+
+ function register()
+ {
+ $blogSettings = $this->blogInfo->getSettings();
+ $this->pluginEnabled = $blogSettings->getValue( "plugin_hkweather_enabled" );
+ $this->lang = $blogSettings->getValue( "plugin_hkweather_lang" );
+ }
+
+ function isEnabled()
+ {
+ return $this->pluginEnabled;
+ }
+ /**
+ * Returns the HKWeather
+ */
+ function getHKWeather()
+ {
+
+if ($this->lang != 'Chinese') {
+
+$file = "http://www.weather.gov.hk/textonly/forecast/englishwx.htm";
+$file2 = "http://www.weather.gov.hk/contente.htm";
+$file3 = "http://www.weather.gov.hk/textonly/forecast/nday.htm";
+
+$contents = file($file);
+$contents2 = file($file2);
+$contents3 = file($file3);
+
+$size = sizeof($contents);
+$size2 = sizeof($contents2);
+$size3 = sizeof($contents3);
+
+$alldata=implode("\n", $contents);
+$alldata2=implode("\n", $contents2);
+$alldata3=implode("\n", $contents3);
+
+preg_match_all("|<pre.*?>(.*?)</pre>|ism",$alldata,$matches);
+preg_match_all("|<!--InsertFLW--.*?>(.*?)<!--InsertTCtrack-->|ism",$alldata2,$matches2);
+preg_match_all("|<!--InsertF5D--.*?>(.*?)<!--EndOfF5D-->|ism",$alldata2,$matches3);
+preg_match_all("|<pre.*?>(.*?)</pre>|ism",$alldata3,$matches4);
+preg_match_all("|<!--InsertWarning--.*?>(.*?)<!--InsertCurrentWeather-->|ism",$alldata2,$matches5);
+
+
+foreach($matches4[1] as $match4)
+{ $pieces4 = explode("\n", $match4);
+
+ $cnt = 10;
+ $landmark = substr("$pieces4[8]", 0, 10);
+
+ while ($landmark != $pieces4[$cnt]){
+ $cnt = $cnt + 2;
+
+ }
+ $cnt = $cnt + 4;
+
+ $oneinfo = substr("$pieces4[$cnt]", 18, 8);
+ $oneinfo = str_replace(" ",'',"$oneinfo");
+ $oneinfow = iconv("BIG5", "UTF-8", "$oneinfo");
+ $cnt = $cnt + 2;
+
+ $oneinfo1 = substr("$pieces4[$cnt]", 0, 70);
+ $oneinfo1w = iconv("BIG5", "UTF-8", "$oneinfo1");
+ $cnt = $cnt + 2;
+
+ $oneinfo2 = substr("$pieces4[$cnt]", 0, 70);
+ $oneinfo2w = iconv("BIG5", "UTF-8", "$oneinfo2");
+ $cnt = $cnt + 2;
+
+ $oneinfo3 = substr("$pieces4[$cnt]", 0, 70);
+ $oneinfo3w = iconv("BIG5", "UTF-8", "$oneinfo3");
+ $cnt = $cnt + 2;
+
+ $oneinfo4 = substr("$pieces4[$cnt]", 0, 70);
+ $oneinfo4w = iconv("BIG5", "UTF-8", "$oneinfo4");
+ $cnt = $cnt + 4;
+
+
+ $twoinfo = substr("$pieces4[$cnt]", 18, 8);
+ $twoinfow = iconv("BIG5", "UTF-8", "$twoinfo");
+ $cnt = $cnt + 2;
+
+ $twoinfo1 = substr("$pieces4[$cnt]", 0, 70);
+ $twoinfo1w = iconv("BIG5", "UTF-8", "$twoinfo1");
+ $cnt = $cnt + 2;
+
+ $twoinfo2 = substr("$pieces4[$cnt]", 0, 70);
+ $twoinfo2w = iconv("BIG5", "UTF-8", "$twoinfo2");
+ $cnt = $cnt + 2;
+
+ $twoinfo3 = substr("$pieces4[$cnt]", 0, 70);
+ $twoinfo3w = iconv("BIG5", "UTF-8", "$twoinfo3");
+ $cnt = $cnt + 2;
+
+ $twoinfo4 = substr("$pieces4[$cnt]", 0, 70);
+ $twoinfo4w = iconv("BIG5", "UTF-8", "$twoinfo4");
+ $cnt = $cnt + 4;
+
+
+ $threeinfo = substr("$pieces4[$cnt]", 18, 8);
+ $threeinfow = iconv("BIG5", "UTF-8", "$threeinfo");
+ $cnt = $cnt + 2;
+
+ $threeinfo1 = substr("$pieces4[$cnt]", 0, 70);
+ $threeinfo1w = iconv("BIG5", "UTF-8", "$threeinfo1");
+ $cnt = $cnt + 2;
+
+ $threeinfo2 = substr("$pieces4[$cnt]", 0, 70);
+ $threeinfo2w = iconv("BIG5", "UTF-8", "$threeinfo2");
+ $cnt = $cnt + 2;
+
+ $threeinfo3 = substr("$pieces4[$cnt]", 0, 70);
+ $threeinfo3w = iconv("BIG5", "UTF-8", "$threeinfo3");
+ $cnt = $cnt + 2;
+
+ $threeinfo4 = substr("$pieces4[$cnt]", 0, 70);
+ $threeinfo4w = iconv("BIG5", "UTF-8", "$threeinfo4");
+ $cnt = $cnt + 4;
+
+
+
+ $fourinfo = substr("$pieces4[$cnt]", 18, 8);
+ $fourinfow = iconv("BIG5", "UTF-8", "$fourinfo");
+ $cnt = $cnt + 2;
+
+ $fourinfo1 = substr("$pieces4[$cnt]", 0, 70);
+ $fourinfo1w = iconv("BIG5", "UTF-8", "$fourinfo1");
+ $cnt = $cnt + 2;
+
+ $fourinfo2 = substr("$pieces4[$cnt]", 0, 70);
+ $fourinfo2w = iconv("BIG5", "UTF-8", "$fourinfo2");
+ $cnt = $cnt + 2;
+
+ $fourinfo3 = substr("$pieces4[$cnt]", 0, 70);
+ $fourinfo3w = iconv("BIG5", "UTF-8", "$fourinfo3");
+ $cnt = $cnt + 2;
+
+ $fourinfo4 = substr("$pieces4[$cnt]", 0, 70);
+ $fourinfo4w = iconv("BIG5", "UTF-8", "$fourinfo4");
+ $cnt = $cnt + 4;
+
+
+
+ $fiveinfo = substr("$pieces4[$cnt]", 18, 8);
+ $fiveinfow = iconv("BIG5", "UTF-8", "$fiveinfo");
+ $cnt = $cnt + 2;
+
+ $fiveinfo1 = substr("$pieces4[$cnt]", 0, 70);
+ $fiveinfo1w = iconv("BIG5", "UTF-8", "$fiveinfo1");
+ $cnt = $cnt + 2;
+
+ $fiveinfo2 = substr("$pieces4[$cnt]", 0, 70);
+ $fiveinfo2w = iconv("BIG5", "UTF-8", "$fiveinfo2");
+ $cnt = $cnt + 2;
+
+ $fiveinfo3 = substr("$pieces4[$cnt]", 0, 70);
+ $fiveinfo3w = iconv("BIG5", "UTF-8", "$fiveinfo3");
+ $cnt = $cnt + 2;
+
+ $fiveinfo4 = substr("$pieces4[$cnt]", 0, 70);
+ $fiveinfo4w = iconv("BIG5", "UTF-8", "$fiveinfo4");
+ $cnt = $cnt + 4;
+
+
+
+ $sixinfo = substr("$pieces4[$cnt]", 18, 8);
+ $sixinfow = iconv("BIG5", "UTF-8", "$sixinfo");
+ $cnt = $cnt + 2;
+
+ $sixinfo1 = substr("$pieces4[$cnt]", 0, 70);
+ $sixinfo1w = iconv("BIG5", "UTF-8", "$sixinfo1");
+ $cnt = $cnt + 2;
+
+ $sixinfo2 = substr("$pieces4[$cnt]", 0, 70);
+ $sixinfo2w = iconv("BIG5", "UTF-8", "$sixinfo2");
+ $cnt = $cnt + 2;
+
+ $sixinfo3 = substr("$pieces4[$cnt]", 0, 70);
+ $sixinfo3w = iconv("BIG5", "UTF-8", "$sixinfo3");
+ $cnt = $cnt + 2;
+
+ $sixinfo4 = substr("$pieces4[$cnt]", 0, 70);
+ $sixinfo4w = iconv("BIG5", "UTF-8", "$sixinfo4");
+ $cnt = $cnt + 4;
+
+
+
+ $seveninfo = substr("$pieces4[$cnt]", 18, 8);
+ $seveninfow = iconv("BIG5", "UTF-8", "$seveninfo");
+ $cnt = $cnt + 2;
+
+ $seveninfo1 = substr("$pieces4[$cnt]", 0, 70);
+ $seveninfo1w = iconv("BIG5", "UTF-8", "$seveninfo1");
+ $cnt = $cnt + 2;
+
+ $seveninfo2 = substr("$pieces4[$cnt]", 0, 70);
+ $seveninfo2w = iconv("BIG5", "UTF-8", "$seveninfo2");
+ $cnt = $cnt + 2;
+
+ $seveninfo3 = substr("$pieces4[$cnt]", 0, 70);
+ $seveninfo3w = iconv("BIG5", "UTF-8", "$seveninfo3");
+ $cnt = $cnt + 2;
+
+ $seveninfo4 = substr("$pieces4[$cnt]", 0, 70);
+ $seveninfo4w = iconv("BIG5", "UTF-8", "$seveninfo4");
+}
+
+foreach($matches2[1] as $match2)
+{ $pieces2 = explode("\n", $match2);
+ $pic2 = substr("$pieces2[32]", 72, 18);
+ $pic2file = explode(" ", $pic2, 2);
+ $trimmed = rtrim($pic2file[0], "\"");
+
+ $time = substr("$pieces2[20]", 40, 16);
+ $time = rtrim($time , " ");
+}
+
+foreach($matches3[1] as $match3)
+{ $pieces3 = explode("\n", $match3);
+ $onedate = substr("$pieces3[124]", 56, 7);
+ $wonedate = iconv("BIG5", "UTF-8", "$onedate");
+ $trimone = rtrim($wonedate , "<");
+
+ $wdayonepic = substr("$pieces3[126]", 56, 3);
+
+ $wdayonepic = explode("<", $wdayonepic, 2);
+ $wonepic = iconv("BIG5", "UTF-8", "$wdayonepic[0]");
+
+ $onepic = substr("$pieces3[144]", 122, 9);
+ $onepicf = "http://www.weather.gov.hk/5day_img/" . $onepic;
+
+ $onetemp = substr("$pieces3[158]", 109, 2);
+ $onetemp2 = substr("$pieces3[158]", 139, 2);
+
+ $twodate = substr("$pieces3[206]", 56, 7);
+
+ $wtwodate = iconv("BIG5", "UTF-8", "$twodate");
+ $trimtwo = rtrim($wtwodate , "<");
+
+ $wdaytwopic = substr("$pieces3[208]", 56, 3);
+
+ $wdaytwopic = explode("<", $wdaytwopic, 2);
+ $wtwopic = iconv("BIG5", "UTF-8", "$wdaytwopic[0]");
+
+ $twopic = substr("$pieces3[226]", 122, 9);
+ $twopicf = "http://www.weather.gov.hk/5day_img/" . $twopic;
+
+ $twotemp = substr("$pieces3[240]", 109, 2);
+ $twotemp2 = substr("$pieces3[240]", 139, 2);
+
+ $threedate = substr("$pieces3[288]", 56, 7);
+ $wthreedate = iconv("BIG5", "UTF-8", "$threedate");
+ $trimthree = rtrim($wthreedate , "<");
+
+ $wdaythreepic = substr("$pieces3[290]", 56, 3);
+ $wdaythreepic = explode("<", $wdaythreepic, 2);
+ $wthreepic = iconv("BIG5", "UTF-8", "$wdaythreepic[0]");
+
+ $threepic = substr("$pieces3[308]", 122, 9);
+ $threepicf = "http://www.weather.gov.hk/5day_img/" . $threepic;
+
+ $threetemp = substr("$pieces3[322]", 109, 2);
+ $threetemp2 = substr("$pieces3[322]", 139, 2);
+
+ $fourdate = substr("$pieces3[370]", 56, 7);
+ $wfourdate = iconv("BIG5", "UTF-8", "$fourdate");
+ $trimfour = rtrim($wfourdate , "<");
+
+ $wdayfourpic = substr("$pieces3[372]", 56, 3);
+ $wdayfourpic = explode("<", $wdayfourpic, 2);
+ $wfourpic = iconv("BIG5", "UTF-8", "$wdayfourpic[0]");
+
+ $fourpic = substr("$pieces3[390]", 122, 9);
+ $fourpicf = "http://www.weather.gov.hk/5day_img/" . $fourpic;
+
+ $fourtemp = substr("$pieces3[404]", 109, 2);
+ $fourtemp2 = substr("$pieces3[404]", 139, 2);
+
+ $fivedate = substr("$pieces3[452]", 56, 7);
+ $wfivedate = iconv("BIG5", "UTF-8", "$fivedate");
+ $trimfive = rtrim($wfivedate , "<");
+
+ $wdayfivepic = substr("$pieces3[454]", 56, 3);
+ $wdayfivepic = explode("<", $wdayfivepic, 2);
+ $wfivepic = iconv("BIG5", "UTF-8", "$wdayfivepic[0]");
+
+ $fivepic = substr("$pieces3[472]", 122, 9);
+ $fivepicf = "http://www.weather.gov.hk/5day_img/" . $fivepic;
+
+ $fivetemp = substr("$pieces3[486]", 109, 2);
+ $fivetemp2 = substr("$pieces3[486]", 139, 2);
+
+ $sixdate = substr("$pieces3[534]", 56, 7);
+ $wsixdate = iconv("BIG5", "UTF-8", "$sixdate");
+ $trimsix = rtrim($wsixdate , "<");
+
+ $wdaysixpic = substr("$pieces3[536]", 56, 3);
+ $wdaysixpic = explode("<", $wdaysixpic, 2);
+ $wsixpic = iconv("BIG5", "UTF-8", "$wdaysixpic[0]");
+
+ $sixpic = substr("$pieces3[554]", 122, 9);
+ $sixpicf = "http://www.weather.gov.hk/5day_img/" . $sixpic;
+
+ $sixtemp = substr("$pieces3[568]", 109, 2);
+ $sixtemp2 = substr("$pieces3[568]", 139, 2);
+
+ $sevendate = substr("$pieces3[616]", 56, 7);
+ $wsevendate = iconv("BIG5", "UTF-8", "$sevendate");
+ $trimseven = rtrim($wsevendate , "<");
+
+ $wdaysevenpic = substr("$pieces3[618]", 56, 3);
+ $wdaysevenpic = explode("<", $wdaysevenpic, 2);
+ $wsevenpic = iconv("BIG5", "UTF-8", "$wdaysevenpic[0]");
+
+ $sevenpic = substr("$pieces3[636]", 122, 9);
+ $sevenpicf = "http://www.weather.gov.hk/5day_img/" . $sevenpic;
+
+ $seventemp = substr("$pieces3[650]", 109, 2);
+ $seventemp2 = substr("$pieces3[650]", 139, 2);
+
+}
+
+foreach($matches5[1] as $match5)
+{ $warning = explode("\n", $match5);
+
+ $warningtest = substr("$warning[2]", 0, 20);
+
+ $warnings = substr("$warning[30]", 76, 9);
+ $warnpic = explode(" ", $warnings, 2);
+ $warningpics1 = trim($warnpic[0], "\"");
+
+ $warningdir1 = "http://www.weather.gov.hk/images_e/" . $warningpics1;
+ $warnings = substr("$warning[30]", 76, 100);
+ $picdesc1 = explode("alt=\"", $warnings, 2);
+
+ $warningtit = explode("\"", $picdesc1[1] , 2);
+ $alttext1 = iconv("BIG5", "UTF-8", "$warningtit[0]");
+
+
+ $warnings = substr("$warning[34]", 76, 9);
+ $warnpic = explode(" ", $warnings, 2);
+ $warningpics2 = trim($warnpic[0], "\"");
+
+ $warningdir2 = "http://www.weather.gov.hk/images_e/" . $warningpics2;
+ $warnings = substr("$warning[34]", 76, 100);
+ $picdesc2 = explode("alt=\"", $warnings, 2);
+
+ $warningtit = explode("\"", $picdesc2[1] , 2);
+ $alttext2 = iconv("BIG5", "UTF-8", "$warningtit[0]");
+
+
+ $warnings = substr("$warning[38]", 76, 9);
+ $warnpic = explode(" ", $warnings, 2);
+ $warningpics3 = trim($warnpic[0], "\"");
+
+ $warningdir3 = "http://www.weather.gov.hk/images_e/" . $warningpics3;
+ $warnings = substr("$warning[38]", 76, 100);
+ $picdesc3 = explode("alt=\"", $warnings, 2);
+
+ $warningtit = explode("\"", $picdesc3[1] , 2);
+ $alttext3 = iconv("BIG5", "UTF-8", "$warningtit[0]");
+
+
+ $warnings = substr("$warning[42]", 76, 9);
+ $warnpic = explode(" ", $warnings, 2);
+ $warningpics4 = trim($warnpic[0], "\"");
+
+ $warningdir4 = "http://www.weather.gov.hk/images_e/" . $warningpics4;
+ $warnings = substr("$warning[42]", 76, 100);
+ $picdesc4 = explode("alt=\"", $warnings, 2);
+
+ $warningtit = explode("\"", $picdesc4[1] , 2);
+ $alttext4 = iconv("BIG5", "UTF-8", "$warningtit[0]");
+
+}
+
+foreach($matches[1] as $match)
+{ $pieces = explode("\n", $match);
+
+ $rest = substr("$pieces[8]", 25);
+ $pic = "http://www.weather.gov.hk/images_e/" . $trimmed;
+
+ print "<IMG border=0 SRC=$pic ALIGN=LEFT>" ;
+
+ echo iconv("BIG5", "UTF-8", "7-Day Weather Forecast: <br>");
+
+ print "<MARQUEE onmouseover=\"this.stop()\" onmouseout=\"this.start()\" scrollamount=\"2\" HSPACE=10 ALIGN=center WIDTH=130 HEIGHT=40 direction=\"up\">
+ <A HREF=\"\" TITLE=\"$wonepic $trimone $oneinfo1w $oneinfo2w $oneinfo3w $oneinfo4w\"><IMG SRC=$onepicf HEIGHT=35 WIDTH=35 ALIGN=LEFT BORDER=0></A>$wonepic $trimone<br><font color=\"#38ACEC\">$onetemp</font> - <font color=\"red\">$onetemp2 </font><sup>o</sup>C<br><br>
+ <A HREF=\"\" TITLE=\"$wtwopic $trimtwo $twoinfo1w $twoinfo2w $twoinfo3w $twoinfo4w\"><IMG SRC=$twopicf HEIGHT=35 WIDTH=35 ALIGN=LEFT BORDER=0></A>$wtwopic $trimtwo<br><font color=\"#38ACEC\">$twotemp</font> - <font color=\"red\">$twotemp2 </font><sup>o</sup>C<br><br>
+ <A HREF=\"\" TITLE=\"$wthreepic $trimthree $threeinfo1w $threeinfo2w $threeinfo3w $threeinfo4w\"><IMG SRC=$threepicf HEIGHT=35 WIDTH=35 ALIGN=LEFT BORDER=0></A>$wthreepic $trimthree<br><font color=\"#38ACEC\">$threetemp</font> - <font color=\"red\">$threetemp2 </font><sup>o</sup>C<br><br>
+ <A HREF=\"\" TITLE=\"$wfourpic $trimfour $fourinfo1w $fourinfo2w $fourinfo3w $fourinfo4w\"><IMG SRC=$fourpicf HEIGHT=35 WIDTH=35 ALIGN=LEFT BORDER=0></A>$wfourpic $trimfour<br><font color=\"#38ACEC\">$fourtemp</font> - <font color=\"red\">$fourtemp2 </font><sup>o</sup>C<br><br>
+ <A HREF=\"\" TITLE=\"$wfivepic $trimfive $fiveinfo1w $fiveinfo2w $fiveinfo3w $fiveinfo4w\"><IMG SRC=$fivepicf HEIGHT=35 WIDTH=35 ALIGN=LEFT BORDER=0></A>$wfivepic $trimfive<br><font color=\"#38ACEC\">$fivetemp</font> - <font color=\"red\">$fivetemp2 </font><sup>o</sup>C<br><br>
+ <A HREF=\"\" TITLE=\"$wsixpic $trimsix $sixinfo1w $sixinfo2w $sixinfo3w $sixinfo4w\"><IMG SRC=$sixpicf HEIGHT=35 WIDTH=35 ALIGN=LEFT BORDER=0></A>$wsixpic $trimsix<br><font color=\"#38ACEC\">$sixtemp</font> - <font color=\"red\">$sixtemp2 </font><sup>o</sup>C<br><br>
+ <A HREF=\"\" TITLE=\"$wsevenpic $trimseven $seveninfo1w $seveninfo2w $seveninfo3w $seveninfo4w\"><IMG SRC=$sevenpicf HEIGHT=35 WIDTH=35 ALIGN=LEFT BORDER=0></A>$wsevenpic $trimseven<br><font color=\"#38ACEC\">$seventemp</font> - <font color=\"red\">$seventemp2 </font><sup>o</sup>C
+
+ </MARQUEE><br>" ;
+
+
+ echo iconv("BIG5", "UTF-8", "$time ");
+ echo iconv("BIG5", "UTF-8", "(GMT +8) ");
+ $title1 = substr("$pieces[2]", 10, 30);
+ echo iconv("BIG5", "UTF-8", "$title1 <br>");
+ echo iconv("BIG5", "UTF-8", "$pieces[4] <br>");
+ echo iconv("BIG5", "UTF-8", "$pieces[6] <br>");
+
+ echo iconv("BIG5", "UTF-8", "WEATHER¡G $rest <br>");
+
+ if($warningdir1 != "http://www.weather.gov.hk/images_e/") {
+ print "<hr>";
+ print "<IMG border=0 SRC=$warningdir1 HEIGHT=48 WIDTH=48 ALIGN=left alt=$alttext1>" ;
+ if($warningdir2 != "http://www.weather.gov.hk/images_e/") {
+ print "<IMG border=0 SRC=$warningdir2 HEIGHT=48 WIDTH=48 ALIGN=left alt=$alttext2>" ;
+ }
+ if($warningdir3 != "http://www.weather.gov.hk/images_e/") {
+ print "<IMG border=0 SRC=$warningdir3 HEIGHT=48 WIDTH=48 ALIGN=left alt=$alttext3>" ;
+ }
+ if($warningdir4 != "http://www.weather.gov.hk/images_e/") {
+ print "<IMG border=0 SRC=$warningdir4 HEIGHT=48 WIDTH=48 ALIGN=left alt=$alttext4>" ;
+ }
+
+
+ }
+
+ $cnt = 0;
+ $cnt2 = 0;
+
+ if(trim($pieces[10]) == "PLEASE BE REMINDED THAT:" ) {
+ $cnt = $cnt + 10;
+ $cnt2 = $cnt2 + 12;
+ }
+ if(trim($pieces[12]) == "PLEASE BE REMINDED THAT:" ) {
+ $cnt = $cnt + 12;
+ $cnt2 = $cnt2 + 14;
+ }
+ if(trim($pieces[14]) == "PLEASE BE REMINDED THAT:" ) {
+ $cnt = $cnt + 14;
+ $cnt2 = $cnt2 + 16;
+ }
+ if(trim($pieces[16]) == "PLEASE BE REMINDED THAT:" ) {
+ $cnt = $cnt + 16;
+ $cnt2 = $cnt2 + 18;
+ }
+ if(trim($pieces[18]) == "PLEASE BE REMINDED THAT:" ) {
+ $cnt = $cnt + 18;
+ $cnt2 = $cnt2 + 20;
+ }
+ if(trim($pieces[20]) == "PLEASE BE REMINDED THAT:" ) {
+ $cnt = $cnt + 20;
+ $cnt2 = $cnt2 + 22;
+ }
+ if(trim($pieces[22]) == "PLEASE BE REMINDED THAT:" ) {
+ $cnt = $cnt + 22;
+ $cnt2 = $cnt2 + 24;
+ }
+ if(trim($pieces[24]) == "PLEASE BE REMINDED THAT:" ) {
+ $cnt = $cnt + 24;
+ $cnt2 = $cnt2 + 26;
+ }
+ if(trim($pieces[26]) == "PLEASE BE REMINDED THAT:" ) {
+ $cnt = $cnt + 26;
+ $cnt2 = $cnt2 + 28;
+ }
+
+ if($cnt != 0) {
+ $cnt = $cnt + 2;
+ while ($landmark != $pieces[$cnt]) {
+ echo iconv("BIG5", "UTF-8", "$pieces[$cnt2]") ;
+ $cnt2 = $cnt2 + 2;
+ $cnt = $cnt + 2;
+
+ }
+ print "<br>";
+ }
+
+
+}
+}
+ELSE
+{
+$file = "http://www.weather.gov.hk/textonly/forecast/chinesewx.htm";
+$file2 = "http://www.weather.gov.hk/contentc.htm";
+$file3 = "http://www.weather.gov.hk/textonly/forecast/ndayc.htm";
+
+
+$contents = file($file);
+$contents2 = file($file2);
+$contents3 = file($file3);
+
+$size = sizeof($contents);
+$size2 = sizeof($contents2);
+$size3 = sizeof($contents3);
+
+$alldata=implode("\n", $contents);
+$alldata2=implode("\n", $contents2);
+$alldata3=implode("\n", $contents3);
+
+preg_match_all("|<pre.*?>(.*?)</pre>|ism",$alldata,$matches);
+preg_match_all("|<!--InsertFLW--.*?>(.*?)<!--InsertTCtrack-->|ism",$alldata2,$matches2);
+preg_match_all("|<!--InsertF5D--.*?>(.*?)<!--EndOfF5D-->|ism",$alldata2,$matches3);
+preg_match_all("|<pre.*?>(.*?)</pre>|ism",$alldata3,$matches4);
+preg_match_all("|<!--InsertWarning--.*?>(.*?)<!--InsertCurrentWeather-->|ism",$alldata2,$matches5);
+
+
+foreach($matches4[1] as $match4)
+{ $pieces4 = explode("\n", $match4);
+
+ $cnt = 6;
+ $landmark = substr("$pieces4[4]", 0, 10);
+
+ while ($landmark != $pieces4[$cnt]){
+ $cnt = $cnt + 2;
+
+ }
+ $cnt = $cnt + 4;
+
+ $oneinfo = substr("$pieces4[$cnt]", 18, 8);
+ $oneinfo = str_replace(" ",'',"$oneinfo");
+ $oneinfow = iconv("BIG5", "UTF-8", "$oneinfo");
+ $cnt = $cnt + 2;
+
+ $oneinfo1 = substr("$pieces4[$cnt]", 0, 70);
+ $oneinfo1 = str_replace(" ",'',"$oneinfo1");
+ $oneinfo1w = iconv("BIG5", "UTF-8", "$oneinfo1");
+ $cnt = $cnt + 2;
+
+ $oneinfo2 = substr("$pieces4[$cnt]", 0, 70);
+ $oneinfo2 = str_replace(" ",'',"$oneinfo2");
+ $oneinfo2w = iconv("BIG5", "UTF-8", "$oneinfo2");
+ $cnt = $cnt + 2;
+
+ $oneinfo3 = substr("$pieces4[$cnt]", 0, 70);
+ $oneinfo3 = str_replace(" ",'',"$oneinfo3");
+ $oneinfo3w = iconv("BIG5", "UTF-8", "$oneinfo3");
+ $cnt = $cnt + 2;
+
+ $oneinfo4 = substr("$pieces4[$cnt]", 0, 70);
+ $oneinfo4 = str_replace(" ",'',"$oneinfo4");
+ $oneinfo4w = iconv("BIG5", "UTF-8", "$oneinfo4");
+ $cnt = $cnt + 4;
+
+
+ $twoinfo = substr("$pieces4[$cnt]", 18, 8);
+ $twoinfo = str_replace(" ",'',"$twoinfo");
+ $twoinfow = iconv("BIG5", "UTF-8", "$twoinfo");
+ $cnt = $cnt + 2;
+
+ $twoinfo1 = substr("$pieces4[$cnt]", 0, 70);
+ $twoinfo1 = str_replace(" ",'',"$twoinfo1");
+ $twoinfo1w = iconv("BIG5", "UTF-8", "$twoinfo1");
+ $cnt = $cnt + 2;
+
+ $twoinfo2 = substr("$pieces4[$cnt]", 0, 70);
+ $twoinfo2 = str_replace(" ",'',"$twoinfo2");
+ $twoinfo2w = iconv("BIG5", "UTF-8", "$twoinfo2");
+ $cnt = $cnt + 2;
+
+ $twoinfo3 = substr("$pieces4[$cnt]", 0, 70);
+ $twoinfo3 = str_replace(" ",'',"$twoinfo3");
+ $twoinfo3w = iconv("BIG5", "UTF-8", "$twoinfo3");
+ $cnt = $cnt + 2;
+
+ $twoinfo4 = substr("$pieces4[$cnt]", 0, 70);
+ $twoinfo4 = str_replace(" ",'',"$twoinfo4");
+ $twoinfo4w = iconv("BIG5", "UTF-8", "$twoinfo4");
+ $cnt = $cnt + 4;
+
+
+ $threeinfo = substr("$pieces4[$cnt]", 18, 8);
+ $threeinfo = str_replace(" ",'',"$threeinfo");
+ $threeinfow = iconv("BIG5", "UTF-8", "$threeinfo");
+ $cnt = $cnt + 2;
+
+ $threeinfo1 = substr("$pieces4[$cnt]", 0, 70);
+ $threeinfo1 = str_replace(" ",'',"$threeinfo1");
+ $threeinfo1w = iconv("BIG5", "UTF-8", "$threeinfo1");
+ $cnt = $cnt + 2;
+
+ $threeinfo2 = substr("$pieces4[$cnt]", 0, 70);
+ $threeinfo2 = str_replace(" ",'',"$threeinfo2");
+ $threeinfo2w = iconv("BIG5", "UTF-8", "$threeinfo2");
+ $cnt = $cnt + 2;
+
+ $threeinfo3 = substr("$pieces4[$cnt]", 0, 70);
+ $threeinfo3 = str_replace(" ",'',"$threeinfo3");
+ $threeinfo3w = iconv("BIG5", "UTF-8", "$threeinfo3");
+ $cnt = $cnt + 2;
+
+ $threeinfo4 = substr("$pieces4[$cnt]", 0, 70);
+ $threeinfo4 = str_replace(" ",'',"$threeinfo4");
+ $threeinfo4w = iconv("BIG5", "UTF-8", "$threeinfo4");
+ $cnt = $cnt + 4;
+
+
+
+ $fourinfo = substr("$pieces4[$cnt]", 18, 8);
+ $fourinfo = str_replace(" ",'',"$fourinfo");
+ $fourinfow = iconv("BIG5", "UTF-8", "$fourinfo");
+ $cnt = $cnt + 2;
+
+ $fourinfo1 = substr("$pieces4[$cnt]", 0, 70);
+ $fourinfo1 = str_replace(" ",'',"$fourinfo1");
+ $fourinfo1w = iconv("BIG5", "UTF-8", "$fourinfo1");
+ $cnt = $cnt + 2;
+
+ $fourinfo2 = substr("$pieces4[$cnt]", 0, 70);
+ $fourinfo2 = str_replace(" ",'',"$fourinfo2");
+ $fourinfo2w = iconv("BIG5", "UTF-8", "$fourinfo2");
+ $cnt = $cnt + 2;
+
+ $fourinfo3 = substr("$pieces4[$cnt]", 0, 70);
+ $fourinfo3 = str_replace(" ",'',"$fourinfo3");
+ $fourinfo3w = iconv("BIG5", "UTF-8", "$fourinfo3");
+ $cnt = $cnt + 2;
+
+ $fourinfo4 = substr("$pieces4[$cnt]", 0, 70);
+ $fourinfo4 = str_replace(" ",'',"$fourinfo4");
+ $fourinfo4w = iconv("BIG5", "UTF-8", "$fourinfo4");
+ $cnt = $cnt + 4;
+
+
+
+ $fiveinfo = substr("$pieces4[$cnt]", 18, 8);
+ $fiveinfo = str_replace(" ",'',"$fiveinfo");
+ $fiveinfow = iconv("BIG5", "UTF-8", "$fiveinfo");
+ $cnt = $cnt + 2;
+
+ $fiveinfo1 = substr("$pieces4[$cnt]", 0, 70);
+ $fiveinfo1 = str_replace(" ",'',"$fiveinfo1");
+ $fiveinfo1w = iconv("BIG5", "UTF-8", "$fiveinfo1");
+ $cnt = $cnt + 2;
+
+ $fiveinfo2 = substr("$pieces4[$cnt]", 0, 70);
+ $fiveinfo2 = str_replace(" ",'',"$fiveinfo2");
+ $fiveinfo2w = iconv("BIG5", "UTF-8", "$fiveinfo2");
+ $cnt = $cnt + 2;
+
+ $fiveinfo3 = substr("$pieces4[$cnt]", 0, 70);
+ $fiveinfo3 = str_replace(" ",'',"$fiveinfo3");
+ $fiveinfo3w = iconv("BIG5", "UTF-8", "$fiveinfo3");
+ $cnt = $cnt + 2;
+
+ $fiveinfo4 = substr("$pieces4[$cnt]", 0, 70);
+ $fiveinfo4 = str_replace(" ",'',"$fiveinfo4");
+ $fiveinfo4w = iconv("BIG5", "UTF-8", "$fiveinfo4");
+ $cnt = $cnt + 4;
+
+
+
+ $sixinfo = substr("$pieces4[$cnt]", 18, 8);
+ $sixinfo = str_replace(" ",'',"$sixinfo");
+ $sixinfow = iconv("BIG5", "UTF-8", "$sixinfo");
+ $cnt = $cnt + 2;
+
+ $sixinfo1 = substr("$pieces4[$cnt]", 0, 70);
+ $sixinfo1 = str_replace(" ",'',"$sixinfo1");
+ $sixinfo1w = iconv("BIG5", "UTF-8", "$sixinfo1");
+ $cnt = $cnt + 2;
+
+ $sixinfo2 = substr("$pieces4[$cnt]", 0, 70);
+ $sixinfo2 = str_replace(" ",'',"$sixinfo2");
+ $sixinfo2w = iconv("BIG5", "UTF-8", "$sixinfo2");
+ $cnt = $cnt + 2;
+
+ $sixinfo3 = substr("$pieces4[$cnt]", 0, 70);
+ $sixinfo3 = str_replace(" ",'',"$sixinfo3");
+ $sixinfo3w = iconv("BIG5", "UTF-8", "$sixinfo3");
+ $cnt = $cnt + 2;
+
+ $sixinfo4 = substr("$pieces4[$cnt]", 0, 70);
+ $sixinfo4 = str_replace(" ",'',"$sixinfo4");
+ $sixinfo4w = iconv("BIG5", "UTF-8", "$sixinfo4");
+ $cnt = $cnt + 4;
+
+
+
+ $seveninfo = substr("$pieces4[$cnt]", 18, 8);
+ $seveninfo = str_replace(" ",'',"$seveninfo");
+ $seveninfow = iconv("BIG5", "UTF-8", "$seveninfo");
+ $cnt = $cnt + 2;
+
+ $seveninfo1 = substr("$pieces4[$cnt]", 0, 70);
+ $seveninfo1 = str_replace(" ",'',"$seveninfo1");
+ $seveninfo1w = iconv("BIG5", "UTF-8", "$seveninfo1");
+ $cnt = $cnt + 2;
+
+ $seveninfo2 = substr("$pieces4[$cnt]", 0, 70);
+ $seveninfo2 = str_replace(" ",'',"$seveninfo2");
+ $seveninfo2w = iconv("BIG5", "UTF-8", "$seveninfo2");
+ $cnt = $cnt + 2;
+
+ $seveninfo3 = substr("$pieces4[$cnt]", 0, 70);
+ $seveninfo3 = str_replace(" ",'',"$seveninfo3");
+ $seveninfo3w = iconv("BIG5", "UTF-8", "$seveninfo3");
+ $cnt = $cnt + 2;
+
+ $seveninfo4 = substr("$pieces4[$cnt]", 0, 70);
+ $seveninfo4 = str_replace(" ",'',"$seveninfo4");
+ $seveninfo4w = iconv("BIG5", "UTF-8", "$seveninfo4");
+}
+
+foreach($matches2[1] as $match2)
+{ $pieces2 = explode("\n", $match2);
+ $pic2 = substr("$pieces2[32]", 72, 18);
+ $pic2file = explode(" ", $pic2, 2);
+ $trimmed = rtrim($pic2file[0], "\"");
+
+ $time = substr("$pieces2[20]", 40, 16);
+ $time = rtrim($time , " ");
+}
+
+foreach($matches3[1] as $match3)
+{ $pieces3 = explode("\n", $match3);
+ $onedate = substr("$pieces3[116]", 68, 9);
+ $wonedate = iconv("BIG5", "UTF-8", "$onedate");
+ $trimone = rtrim($wonedate , "<");
+
+ $wdayonepic = substr("$pieces3[120]", 68, 9);
+
+ $wdayonepic = explode("<", $wdayonepic, 2);
+ $wonepic = iconv("BIG5", "UTF-8", "$wdayonepic[0]");
+
+ $onepic = substr("$pieces3[134]", 129, 9);
+ $onepicf = "http://www.weather.gov.hk/5day_img/" . $onepic;
+
+ $onetemp = substr("$pieces3[148]", 48, 2);
+ $onetemp2 = substr("$pieces3[148]", 78, 2);
+
+ $twodate = substr("$pieces3[190]", 68, 9);
+
+ $wtwodate = iconv("BIG5", "UTF-8", "$twodate");
+ $trimtwo = rtrim($wtwodate , "<");
+
+ $wdaytwopic = substr("$pieces3[194]", 68, 9);
+ $wdaytwopic = explode("<", $wdaytwopic, 2);
+ $wtwopic = iconv("BIG5", "UTF-8", "$wdaytwopic[0]");
+
+ $twopic = substr("$pieces3[208]", 129, 9);
+ $twopicf = "http://www.weather.gov.hk/5day_img/" . $twopic;
+
+ $twotemp = substr("$pieces3[222]", 48, 2);
+ $twotemp2 = substr("$pieces3[222]", 78, 2);
+
+ $threedate = substr("$pieces3[264]", 68, 9);
+ $wthreedate = iconv("BIG5", "UTF-8", "$threedate");
+ $trimthree = rtrim($wthreedate , "<");
+
+ $wdaythreepic = substr("$pieces3[268]", 68, 9);
+ $wdaythreepic = explode("<", $wdaythreepic, 2);
+ $wthreepic = iconv("BIG5", "UTF-8", "$wdaythreepic[0]");
+
+ $threepic = substr("$pieces3[282]", 129, 9);
+ $threepicf = "http://www.weather.gov.hk/5day_img/" . $threepic;
+
+ $threetemp = substr("$pieces3[296]", 48, 2);
+ $threetemp2 = substr("$pieces3[296]", 78, 2);
+
+ $fourdate = substr("$pieces3[338]", 68, 9);
+ $wfourdate = iconv("BIG5", "UTF-8", "$fourdate");
+ $trimfour = rtrim($wfourdate , "<");
+
+ $wdayfourpic = substr("$pieces3[342]", 68, 9);
+ $wdayfourpic = explode("<", $wdayfourpic, 2);
+ $wfourpic = iconv("BIG5", "UTF-8", "$wdayfourpic[0]");
+
+ $fourpic = substr("$pieces3[356]", 129, 9);
+ $fourpicf = "http://www.weather.gov.hk/5day_img/" . $fourpic;
+
+ $fourtemp = substr("$pieces3[370]", 48, 2);
+ $fourtemp2 = substr("$pieces3[370]", 78, 2);
+
+ $fivedate = substr("$pieces3[412]", 68, 9);
+ $wfivedate = iconv("BIG5", "UTF-8", "$fivedate");
+ $trimfive = rtrim($wfivedate , "<");
+
+ $wdayfivepic = substr("$pieces3[416]", 68, 9);
+ $wdayfivepic = explode("<", $wdayfivepic, 2);
+ $wfivepic = iconv("BIG5", "UTF-8", "$wdayfivepic[0]");
+
+ $fivepic = substr("$pieces3[430]", 129, 9);
+ $fivepicf = "http://www.weather.gov.hk/5day_img/" . $fivepic;
+
+ $fivetemp = substr("$pieces3[444]", 48, 2);
+ $fivetemp2 = substr("$pieces3[444]", 78, 2);
+
+ $sixdate = substr("$pieces3[486]", 68, 9);
+ $wsixdate = iconv("BIG5", "UTF-8", "$sixdate");
+ $trimsix = rtrim($wsixdate , "<");
+
+ $wdaysixpic = substr("$pieces3[490]", 68, 9);
+ $wdaysixpic = explode("<", $wdaysixpic, 2);
+ $wsixpic = iconv("BIG5", "UTF-8", "$wdaysixpic[0]");
+
+ $sixpic = substr("$pieces3[504]", 129, 9);
+ $sixpicf = "http://www.weather.gov.hk/5day_img/" . $sixpic;
+
+ $sixtemp = substr("$pieces3[518]", 48, 2);
+ $sixtemp2 = substr("$pieces3[518]", 78, 2);
+
+ $sevendate = substr("$pieces3[560]", 68, 9);
+ $wsevendate = iconv("BIG5", "UTF-8", "$sevendate");
+ $trimseven = rtrim($wsevendate , "<");
+
+ $wdaysevenpic = substr("$pieces3[564]", 68, 9);
+ $wdaysevenpic = explode("<", $wdaysevenpic, 2);
+ $wsevenpic = iconv("BIG5", "UTF-8", "$wdaysevenpic[0]");
+
+ $sevenpic = substr("$pieces3[578]", 129, 9);
+ $sevenpicf = "http://www.weather.gov.hk/5day_img/" . $sevenpic;
+
+ $seventemp = substr("$pieces3[592]", 48, 2);
+ $seventemp2 = substr("$pieces3[592]", 78, 2);
+
+}
+
+foreach($matches5[1] as $match5)
+{ $warning = explode("\n", $match5);
+
+ $warningtest = substr("$warning[2]", 0, 20);
+
+ $warnings = substr("$warning[32]", 77, 9);
+ $warnpic = explode(" ", $warnings, 2);
+ $warningpics1 = trim($warnpic[0], "\"");
+
+ $warningdir1 = "http://www.weather.gov.hk/images_e/" . $warningpics1;
+ $warnings = substr("$warning[32]", 77, 100);
+ $picdesc1 = explode("alt=\"", $warnings, 2);
+
+ $warningtit = explode("\"", $picdesc1[1] , 2);
+ $alttext1 = iconv("BIG5", "UTF-8", "$warningtit[0]");
+
+
+ $warnings = substr("$warning[36]", 77, 9);
+ $warnpic = explode(" ", $warnings, 2);
+ $warningpics2 = trim($warnpic[0], "\"");
+
+ $warningdir2 = "http://www.weather.gov.hk/images_e/" . $warningpics2;
+ $warnings = substr("$warning[36]", 77, 100);
+ $picdesc2 = explode("alt=\"", $warnings, 2);
+
+ $warningtit = explode("\"", $picdesc2[1] , 2);
+ $alttext2 = iconv("BIG5", "UTF-8", "$warningtit[0]");
+
+
+ $warnings = substr("$warning[40]", 77, 9);
+ $warnpic = explode(" ", $warnings, 2);
+ $warningpics3 = trim($warnpic[0], "\"");
+
+ $warningdir3 = "http://www.weather.gov.hk/images_e/" . $warningpics3;
+ $warnings = substr("$warning[40]", 77, 100);
+ $picdesc3 = explode("alt=\"", $warnings, 2);
+
+ $warningtit = explode("\"", $picdesc3[1] , 2);
+ $alttext3 = iconv("BIG5", "UTF-8", "$warningtit[0]");
+
+
+ $warnings = substr("$warning[44]", 77, 9);
+ $warnpic = explode(" ", $warnings, 2);
+ $warningpics4 = trim($warnpic[0], "\"");
+
+ $warningdir4 = "http://www.weather.gov.hk/images_e/" . $warningpics4;
+ $warnings = substr("$warning[44]", 77, 100);
+ $picdesc4 = explode("alt=\"", $warnings, 2);
+
+ $warningtit = explode("\"", $picdesc4[1] , 2);
+ $alttext4 = iconv("BIG5", "UTF-8", "$warningtit[0]");
+
+}
+
+foreach($matches[1] as $match)
+{ $pieces = explode("\n", $match);
+
+ $rest = substr("$pieces[8]", 24);
+ $pic = "http://www.weather.gov.hk/images_e/" . $trimmed;
+
+ print "<IMG border=0 SRC=$pic ALIGN=LEFT>" ;
+
+ echo iconv("BIG5", "UTF-8", "¤C¤Ñ¤Ñ®ð¹w³ø: <br>");
+
+ print "<MARQUEE onmouseover=\"this.stop()\" onmouseout=\"this.start()\" scrollamount=\"2\" HSPACE=10 ALIGN=center WIDTH=130 HEIGHT=40 direction=\"up\">
+ <A HREF=\"\" TITLE=\"$wonepic $trimone $oneinfo1w $oneinfo2w $oneinfo3w $oneinfo4w\"><IMG SRC=$onepicf HEIGHT=35 WIDTH=35 ALIGN=LEFT BORDER=0></A>$wonepic $trimone<br><font color=\"#38ACEC\">$onetemp</font> - <font color=\"red\">$onetemp2 </font><sup>o</sup>C<br><br>
+ <A HREF=\"\" TITLE=\"$wtwopic $trimtwo $twoinfo1w $twoinfo2w $twoinfo3w $twoinfo4w\"><IMG SRC=$twopicf HEIGHT=35 WIDTH=35 ALIGN=LEFT BORDER=0></A>$wtwopic $trimtwo<br><font color=\"#38ACEC\">$twotemp</font> - <font color=\"red\">$twotemp2 </font><sup>o</sup>C<br><br>
+ <A HREF=\"\" TITLE=\"$wthreepic $trimthree $threeinfo1w $threeinfo2w $threeinfo3w $threeinfo4w\"><IMG SRC=$threepicf HEIGHT=35 WIDTH=35 ALIGN=LEFT BORDER=0></A>$wthreepic $trimthree<br><font color=\"#38ACEC\">$threetemp</font> - <font color=\"red\">$threetemp2 </font><sup>o</sup>C<br><br>
+ <A HREF=\"\" TITLE=\"$wfourpic $trimfour $fourinfo1w $fourinfo2w $fourinfo3w $fourinfo4w\"><IMG SRC=$fourpicf HEIGHT=35 WIDTH=35 ALIGN=LEFT BORDER=0></A>$wfourpic $trimfour<br><font color=\"#38ACEC\">$fourtemp</font> - <font color=\"red\">$fourtemp2 </font><sup>o</sup>C<br><br>
+ <A HREF=\"\" TITLE=\"$wfivepic $trimfive $fiveinfo1w $fiveinfo2w $fiveinfo3w $fiveinfo4w\"><IMG SRC=$fivepicf HEIGHT=35 WIDTH=35 ALIGN=LEFT BORDER=0></A>$wfivepic $trimfive<br><font color=\"#38ACEC\">$fivetemp</font> - <font color=\"red\">$fivetemp2 </font><sup>o</sup>C<br><br>
+ <A HREF=\"\" TITLE=\"$wsixpic $trimsix $sixinfo1w $sixinfo2w $sixinfo3w $sixinfo4w\"><IMG SRC=$sixpicf HEIGHT=35 WIDTH=35 ALIGN=LEFT BORDER=0></A>$wsixpic $trimsix<br><font color=\"#38ACEC\">$sixtemp</font> - <font color=\"red\">$sixtemp2 </font><sup>o</sup>C<br><br>
+ <A HREF=\"\" TITLE=\"$wsevenpic $trimseven $seveninfo1w $seveninfo2w $seveninfo3w $seveninfo4w\"><IMG SRC=$sevenpicf HEIGHT=35 WIDTH=35 ALIGN=LEFT BORDER=0></A>$wsevenpic $trimseven<br><font color=\"#38ACEC\">$seventemp</font> - <font color=\"red\">$seventemp2 </font><sup>o</sup>C
+
+ </MARQUEE><br>" ;
+
+
+ echo iconv("BIG5", "UTF-8", "$time ");
+ $title1 = substr("$pieces[2]", 11, 18);
+ $title1 = str_replace(" ",'',"$title1");
+ echo iconv("BIG5", "UTF-8", "$title1 <br>");
+ echo iconv("BIG5", "UTF-8", "$pieces[4] <br>");
+ echo iconv("BIG5", "UTF-8", "$pieces[6] <br>");
+
+ echo iconv("BIG5", "UTF-8", "¤Ñ ®ð ¡G $rest <br>");
+
+ if($warningdir1 != "http://www.weather.gov.hk/images_e/") {
+ print "<hr>";
+ print "<IMG border=0 SRC=$warningdir1 HEIGHT=48 WIDTH=48 ALIGN=left alt=$alttext1>" ;
+ if($warningdir2 != "http://www.weather.gov.hk/images_e/") {
+ print "<IMG border=0 SRC=$warningdir2 HEIGHT=48 WIDTH=48 ALIGN=left alt=$alttext2>" ;
+ }
+ if($warningdir3 != "http://www.weather.gov.hk/images_e/") {
+ print "<IMG border=0 SRC=$warningdir3 HEIGHT=48 WIDTH=48 ALIGN=left alt=$alttext3>" ;
+ }
+ if($warningdir4 != "http://www.weather.gov.hk/images_e/") {
+ print "<IMG border=0 SRC=$warningdir4 HEIGHT=48 WIDTH=48 ALIGN=left alt=$alttext4>" ;
+ }
+
+ }
+
+ $cnt = 0;
+ $cnt2 = 0;
+
+ if(trim($pieces[10]) == "½Ð ª` ·N ¡G" ) {
+ $cnt = $cnt + 10;
+ $cnt2 = $cnt2 + 12;
+ }
+ if(trim($pieces[12]) == "½Ð ª` ·N ¡G" ) {
+ $cnt = $cnt + 12;
+ $cnt2 = $cnt2 + 14;
+ }
+ if(trim($pieces[14]) == "½Ð ª` ·N ¡G" ) {
+ $cnt = $cnt + 14;
+ $cnt2 = $cnt2 + 16;
+ }
+ if(trim($pieces[16]) == "½Ð ª` ·N ¡G" ) {
+ $cnt = $cnt + 16;
+ $cnt2 = $cnt2 + 18;
+ }
+ if(trim($pieces[18]) == "½Ð ª` ·N ¡G" ) {
+ $cnt = $cnt + 18;
+ $cnt2 = $cnt2 + 20;
+ }
+ if(trim($pieces[20]) == "½Ð ª` ·N ¡G" ) {
+ $cnt = $cnt + 20;
+ $cnt2 = $cnt2 + 22;
+ }
+ if(trim($pieces[22]) == "½Ð ª` ·N ¡G" ) {
+ $cnt = $cnt + 22;
+ $cnt2 = $cnt2 + 24;
+ }
+ if(trim($pieces[24]) == "½Ð ª` ·N ¡G" ) {
+ $cnt = $cnt + 24;
+ $cnt2 = $cnt2 + 26;
+ }
+ if(trim($pieces[26]) == "½Ð ª` ·N ¡G" ) {
+ $cnt = $cnt + 26;
+ $cnt2 = $cnt2 + 28;
+ }
+
+ if($cnt != 0) {
+ $cnt = $cnt + 2;
+ while ($landmark != $pieces[$cnt]) {
+ echo iconv("BIG5", "UTF-8", "$pieces[$cnt2]") ;
+ $cnt2 = $cnt2 + 2;
+ $cnt = $cnt + 2;
+
+ }
+ print "<br>";
+ }
+
+
+
+}
+}
+ }
+
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.0/hkweather/readme.txt
===================================================================
--- plugins/branches/lifetype-1.0/hkweather/readme.txt 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hkweather/readme.txt 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,18 @@
+Plugin: HK Weather
+Author: Matthew Chin and Gary Chun
+Release Date: 2006/06/25
+Version: 3.5
+
+This plugin display the HK Weather information and with a rolling 7-day forecast. Usage as follow:
+
+You can use:
+1. $HKWeather->isEnabled() to check the plugin is enabled or not.
+2. $HKWeather->getHKWeather() to get the hk weather.
+
+Where:
+
+Example:
+{if $hkweather->isEnabled()}
+<h2>HK Weather</h2>
+{ $hkweather->getHKWeather() }
+{/if}
\ No newline at end of file
Added: plugins/branches/lifetype-1.0/hkweather/templates/hkweather.template
===================================================================
--- plugins/branches/lifetype-1.0/hkweather/templates/hkweather.template 2006-08-08 21:10:30 UTC (rev 3848)
+++ plugins/branches/lifetype-1.0/hkweather/templates/hkweather.template 2006-08-09 15:54:33 UTC (rev 3849)
@@ -0,0 +1,59 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=hkweather title=$locale->tr("hkweather_plugin")}
+<form name="hkweatherPluginConfig" method="post">
+ <fieldset class="inputField">
+ <legend>{$locale->tr("label_configuration")}</legend>
+ {include file="$admintemplatepath/successmessage.template"}
+ {include file="$admintemplatepath/errormessage.template"}
+ <div class="field">
+ <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
+ <span class="required"></span>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1" />{$locale->tr("hkweather_plugin_enabled")}
+ </div>
+ </div>
+
+ <div class="field">
+ <label for="lang">{$locale->tr("label_lang")}</label>
+ <span class="required"></span>
+ <div class="formHelp">
+ <table>
+ <thead>
+ <tr>
+ <th style="width:20px;"></th>
+ <th style="width:130px;"></th>
+ </tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>
+ <input class="radio" type="radio" name="lang" id="lang" value="English" {if $lang} checked="checked" {/if} />
+ </td>
+ <td>
+ English
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input class="radio" type="radio" name="lang" id="lang" value="Chinese" {if $lang} checked="checked" {/if} />
+ </td>
+ <td>
+ Chinese
+ </td>
+ </tr>
+
+ </tbody>
+ </table>
+ </div></div>
+ </fieldset>
+
+
+ <div class="buttons">
+ <input type="hidden" name="op" value="updateHKWeatherConfig" />
+ <input type="reset" name="{$locale->tr("reset")}" />
+ <input type="submit" name="{$locale->tr("update_settings")}" value="{$locale->tr("update")}" />
+ </div>
+</form>
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
More information about the pLog-svn
mailing list