Here is the procedure for setting up a web host at home and have PHP/MySQL ready with php_curl library support.
Step 1) Download MoWeS
Goto http://www.chsoftware.net/en/useware/mowes/mowes.htm
Choose "Download" from the left menu.
Click "No thanks, take me to the download"
Click "I Do not have a MoWeS Protable II... "
When choosing the component, check
Apache2
MySQL5
PHP5
PHPMyAdmin
and press "Download now".
Notes: I do not know why people keep asking if they should download the SE version of the modules. Just follow exactly the component named above.
Step 2) Extract & start up
Extract the content to C:\mowes. At this moment you should have mowes.exe as C:\mowes\mowes.exe
Run mowes.exe, it prompt you for setup those components you have chosen.
Start the installation and press "OK" several times.
The webhost will start automatically and your browser will start and goto the hosted website.
Step 3) Get ready with CURL library
In the MoWes Portable II windows, press options.
ON: Start Apache and MySQL automatically when MoWeS starts
ON: Hide the Apache window
OFF: Delete xx logfiles after stooping
OFF: Start Webbrowser
OFF: Start External App
other setting left as default.
Press Accept and OK
Press "End" in your Mowes window. The webhost will be down.
Goto C:\mowes\php5, copy the 2 files:
libeay32.dll
ssleay32.dll
to your windows system32 folder ( usually c:\windows\system32).
Open C:\mowes\php5\php.ini in text editor. Modify the following lines:
205:
implicit_flush = On
321:
max_execution_time = 120
674:
extension=php_curl.dll
696:
extension=php_openssl.dll
727:
date.timezone = Asia/Hong_Kong
Save and exit text editor.
Notes: Some of the changes include removal of a ';' (semi-colon). Be really really careful and the line should be completely like the one written above. No exception for any of the above lines, each line contain changes to be made.
Notes 2: for line 727, it specifies the default time zone so that any time displayed will be under that time zone. If you are not from Hong Kong, take a look at HERE for more cities of your choice.
Step 4) Testing
Start mowes.exe. The webhost will be ready.
Put any file C:\mowes\www , for example a.zip
Open your web browser, URL = http://localhost/a.zip
If successful, you will be prompted to download a.zip
Put mingpao.php to C:\mowes\www
If successful, you will be reading today's mingpao
Notes: mingpao.php is the ultimate testing script for your configuration. It can be obtained here.
Sunday, September 14, 2008
Sunday, June 1, 2008
Friday, May 23, 2008
BlackBerry Bold 9000 Hands on
As some of you may know, I work for a company that concentrate on developing Input Method for various platform. I am the one responsible for development on Blackberry and today I received the newest product from RIM, the Bold 9000.
If you have ever played with any of the 8xxx series and now holding a brandnew 9000, you may be impressed by its new interface, new functionality and new plastic/metal case.
However, to make things short, I conclude with one sentence: It looks well, it plays badly.
If you are looking for tech details for Bold, read CNET news, or if you want some screenshot, visit crackberry. The one on my hands looks exactly the same. And it's awesome. (Don't compare it with iPhone though)
As a Chinese Input Method developer, what I concern most, as any Chinese would do, is the ability to display and enter Chinese characters. When comparing with the Font on Pearl, which looks like Chinese Char in CWin31 or just eTen, the ones on Bold are clean and clear, and are as good as those on newest Windows Mobile. Bold support HKSCS natively, so there should be no problem reading Hong Kong News. Moreover, Bold has built-in support for multi-lingual User Interface. One can choose its favorite Interface language right from SetupWizard.
The true power of BB handheld relied on its ability on messaging. Actually I didn't see many Hong Kong Blackberry users typing in Chinese (I see users on MTR mostly). Maybe it's because its poor support on Chinese Char Typing. (Visit here for details on Chinese Support).
Bold supports quite a number of Chinese Input Method (natively, like UI) , like 粵拼, 注音 and 倉頡. However, after the "first taste" of using the input method, I lost my chance to test further... THE INPUT METHOD BROKE MY BLACKBERRY!!!
I started up my Blackberry in English Interface with 粵拼 input method. I went to "message" and compose my first email. Everything is the same as in 8xxx machines, nothing surprising. As I have no real experience using 粵拼, I tried some common strokes like "lee" "sin" "sang" and something like that. The control is really bad as if it is programmed by a guy without any experience on Chinese typing. I tried to type a little faster, but it seems to be extremely slow (on searching output?). The speed is unacceptable and I started losing temper. I tried to hit the keyboard in random and finally it showed me "Input Method Error, restarting..." (not exact phrase). That message popup since then whenever I typed fast enough, which is like 3 key per second (not 3 char per second), which is common for any "normal" Chinese typer. I lost my interest and go on testing something else, like Web Browser.
About half an hour later I switch the machine into Chinese Trad Interface, hoping a native Chinese Interface would gain better performance working in Chinese. I start the message editor again and try typing like before. I sense strangely as i switched between input method. The BB gave me 注音 chars when the active input method is 倉頡, wtf. I keep typing until the proper 倉頡 show up, then after like 2 sec... my BB hanged up. There were no response whatever I do, including pressing and holding the POWER button. It showed me the BB is shutting down and is actually hanged.
There's nothing I can do, and I remove the battery and put it back again (a normal hard reset for BB). I think it will be fine since I do reset like 50-60 times a day when i worked on it (install/uninstall require restarts). But no luck, it gave me "SYSTEM PROCESS ERROR" and force me to reset. And of course, no luck after reset. And i am now holding a bricked Blackberry Bold.
To be lucky is that the machine is a sample from the network provider and I can wait for an exchange a few day later. I should not have great hop as it's just a demo machine anyway. I hope that the stability can be improved before its release. The release date is not announced, and they should have lots of things to do. (and Thx to those sloppy programmers, my state in my company is as firm as it can be)
If you have ever played with any of the 8xxx series and now holding a brandnew 9000, you may be impressed by its new interface, new functionality and new plastic/metal case.
However, to make things short, I conclude with one sentence: It looks well, it plays badly.
If you are looking for tech details for Bold, read CNET news, or if you want some screenshot, visit crackberry. The one on my hands looks exactly the same. And it's awesome. (Don't compare it with iPhone though)
As a Chinese Input Method developer, what I concern most, as any Chinese would do, is the ability to display and enter Chinese characters. When comparing with the Font on Pearl, which looks like Chinese Char in CWin31 or just eTen, the ones on Bold are clean and clear, and are as good as those on newest Windows Mobile. Bold support HKSCS natively, so there should be no problem reading Hong Kong News. Moreover, Bold has built-in support for multi-lingual User Interface. One can choose its favorite Interface language right from SetupWizard.
The true power of BB handheld relied on its ability on messaging. Actually I didn't see many Hong Kong Blackberry users typing in Chinese (I see users on MTR mostly). Maybe it's because its poor support on Chinese Char Typing. (Visit here for details on Chinese Support).
Bold supports quite a number of Chinese Input Method (natively, like UI) , like 粵拼, 注音 and 倉頡. However, after the "first taste" of using the input method, I lost my chance to test further... THE INPUT METHOD BROKE MY BLACKBERRY!!!
I started up my Blackberry in English Interface with 粵拼 input method. I went to "message" and compose my first email. Everything is the same as in 8xxx machines, nothing surprising. As I have no real experience using 粵拼, I tried some common strokes like "lee" "sin" "sang" and something like that. The control is really bad as if it is programmed by a guy without any experience on Chinese typing. I tried to type a little faster, but it seems to be extremely slow (on searching output?). The speed is unacceptable and I started losing temper. I tried to hit the keyboard in random and finally it showed me "Input Method Error, restarting..." (not exact phrase). That message popup since then whenever I typed fast enough, which is like 3 key per second (not 3 char per second), which is common for any "normal" Chinese typer. I lost my interest and go on testing something else, like Web Browser.
About half an hour later I switch the machine into Chinese Trad Interface, hoping a native Chinese Interface would gain better performance working in Chinese. I start the message editor again and try typing like before. I sense strangely as i switched between input method. The BB gave me 注音 chars when the active input method is 倉頡, wtf. I keep typing until the proper 倉頡 show up, then after like 2 sec... my BB hanged up. There were no response whatever I do, including pressing and holding the POWER button. It showed me the BB is shutting down and is actually hanged.
There's nothing I can do, and I remove the battery and put it back again (a normal hard reset for BB). I think it will be fine since I do reset like 50-60 times a day when i worked on it (install/uninstall require restarts). But no luck, it gave me "SYSTEM PROCESS ERROR" and force me to reset. And of course, no luck after reset. And i am now holding a bricked Blackberry Bold.
To be lucky is that the machine is a sample from the network provider and I can wait for an exchange a few day later. I should not have great hop as it's just a demo machine anyway. I hope that the stability can be improved before its release. The release date is not announced, and they should have lots of things to do. (and Thx to those sloppy programmers, my state in my company is as firm as it can be)
Sunday, May 4, 2008
Charles Wilson's War
昨天看完DVD版的Charles Wilson's War,很失望。
失望的不是Tom Hans的表現、不是Julia Roberts的表現、不是故事、不是整個制作的任何一個部份。反之,在這幾個方面我也很喜歡,很欣賞。
使我失望的唯一一個地方,是香港方面的宣傳。
Charles Wilson's War是人物傳記,講述的是一名美國的Congressman,利用他的影響力,以協助阿富汗於八十年代被蘇聯入侵時作出反擊,說白一點,是反戰電影。
此片是2007的制作,香港於2008年3月左右上映。當初第一次接觸到此片,是在RoadShow上看到的宣傳片,中文名好像叫做「韋氏風雲」。宣傳片上最令我留意的,當然是Tom Hans。(自Forrest Gump開始,只要是Tom Hans我也會很留意)也就是說,我看此片的主因,就是看角色,怎樣看此片也是「大卡士」之作吧。
因那是RoadShow的宣傳片,聲音差點聽不到,所以只能用眼去判斷那是什麼的片。宣傳片的內容除了各人的對手戲外,最特出的就是Julia Roberts從水裡走出來的一段,占時間肯定是最長的。看了不只一次,就是看不出這是什麼主題的作品,沒有所謂,反正都會看。
看罷,不能說是非常出色,但也找不到大問題(除了歷史的部份,有關蘇聯撤兵原因的一段過份簡單)。可能因為此片太「美國」,有些背景未能理解,這是自身認識不足的問題,說不上是什麼缺點。
但這港版的宣傳片,也實在是太爛了。其實片中有很多出色的鏡頭,例如在巴基斯坦難民的一段,又或者是Soviet Copters等,都值得加入宣傳片中。至少,從宣傳片中我看不出阿富汗,甚至看不出戰爭。
想深一層,宣傳片的爛,責任何在?是不是發行商的錯?我想也未必。
爛的不是宣傳,而是香港觀眾。如果打正旗號是反戰片,有多少港人會去看?關心國際事務的人不斷減少,炒股的人數則不斷提升,「關心國際大事」就即是「關心會影響股價的事」的意思。縱使Julia Roberts的角色有如「夏蕙姨」,不打緊,找一段載黑超的就無問題。沒有「美色」的西片,怎樣騙你們入去看?
失望的不是Tom Hans的表現、不是Julia Roberts的表現、不是故事、不是整個制作的任何一個部份。反之,在這幾個方面我也很喜歡,很欣賞。
使我失望的唯一一個地方,是香港方面的宣傳。
Charles Wilson's War是人物傳記,講述的是一名美國的Congressman,利用他的影響力,以協助阿富汗於八十年代被蘇聯入侵時作出反擊,說白一點,是反戰電影。
此片是2007的制作,香港於2008年3月左右上映。當初第一次接觸到此片,是在RoadShow上看到的宣傳片,中文名好像叫做「韋氏風雲」。宣傳片上最令我留意的,當然是Tom Hans。(自Forrest Gump開始,只要是Tom Hans我也會很留意)也就是說,我看此片的主因,就是看角色,怎樣看此片也是「大卡士」之作吧。
因那是RoadShow的宣傳片,聲音差點聽不到,所以只能用眼去判斷那是什麼的片。宣傳片的內容除了各人的對手戲外,最特出的就是Julia Roberts從水裡走出來的一段,占時間肯定是最長的。看了不只一次,就是看不出這是什麼主題的作品,沒有所謂,反正都會看。
看罷,不能說是非常出色,但也找不到大問題(除了歷史的部份,有關蘇聯撤兵原因的一段過份簡單)。可能因為此片太「美國」,有些背景未能理解,這是自身認識不足的問題,說不上是什麼缺點。
但這港版的宣傳片,也實在是太爛了。其實片中有很多出色的鏡頭,例如在巴基斯坦難民的一段,又或者是Soviet Copters等,都值得加入宣傳片中。至少,從宣傳片中我看不出阿富汗,甚至看不出戰爭。
想深一層,宣傳片的爛,責任何在?是不是發行商的錯?我想也未必。
爛的不是宣傳,而是香港觀眾。如果打正旗號是反戰片,有多少港人會去看?關心國際事務的人不斷減少,炒股的人數則不斷提升,「關心國際大事」就即是「關心會影響股價的事」的意思。縱使Julia Roberts的角色有如「夏蕙姨」,不打緊,找一段載黑超的就無問題。沒有「美色」的西片,怎樣騙你們入去看?
Tuesday, April 29, 2008
php_curl + cookies
curl_setopt($ch, CURLOPT_COOKIEJAR, "d:\Web\PHP\cookieFileName");
很多script會使用cookies,但cookies path最好是full path
很多script會使用cookies,但cookies path最好是full path
Monday, April 28, 2008
PHP5 + Apache2.2 + cURL + windows XP
我用的是PHP Win32 installer,已選好php_curl的設定,但當行script時發現
Fatal error: Call to undefined function: curl_init() in xxxx.php
於是到phpinfo看,curl module沒有load
再看apache的error log
Unable to load dynamic library 'd:\\PHP\\ext\\php_openssl.dll' - The specified module could not be found.\r\n in Unknown on line 0
file明明存在,但就是load不到,所有file都在其位,path variable, php.ini,httd-conf都ok,但就是不行
最後將ssleay32.dll及libeay32.dll放到system32... 就行了
原因不明,path 明明是正確的... 算了,能行就好
Fatal error: Call to undefined function: curl_init() in xxxx.php
於是到phpinfo看,curl module沒有load
再看apache的error log
Unable to load dynamic library 'd:\\PHP\\ext\\php_openssl.dll' - The specified module could not be found.\r\n in Unknown on line 0
file明明存在,但就是load不到,所有file都在其位,path variable, php.ini,httd-conf都ok,但就是不行
最後將ssleay32.dll及libeay32.dll放到system32... 就行了
原因不明,path 明明是正確的... 算了,能行就好
Sunday, April 27, 2008
My MingPaoNews
記得大學Year 3時曾上過一個course,名為Information Retrieval,學會編寫網上蜘蛛,因忙著做Final Year Project而沒有放心血下這course的project上,回必一想真是感到有點可惜。
兩三年前,當我還在玩PDA的時候,有網友編了個exe,功能是download 即日Apple Daily同明報,再用ebook工具做成電子書,加上定時功能放到PDA上,那麼每天上班也有新聞可讀。可惜這種program要時常update,網上的報紙要是一改版,program即時報廢。當時心想,不如自己寫一個... 幾年也沒有做出來...
今日,不知為什麼一起床就想去做這個東西,寫了一整天,完成了整個php script。
工作:
到www.mingpaonews.com取得所有headline,
用家選擇若干篇興趣的文章後,再submit即可一次過閱讀所選的文章。
功能:
自動設charset為Big5-HKSCS,不用每頁也要手動轉;
文章的附圖也會貼上,onMouseOver可放大。
限制:
娛樂、財經及賽馬的排版是獨立的,沒有處理它們。
Code:
兩三年前,當我還在玩PDA的時候,有網友編了個exe,功能是download 即日Apple Daily同明報,再用ebook工具做成電子書,加上定時功能放到PDA上,那麼每天上班也有新聞可讀。可惜這種program要時常update,網上的報紙要是一改版,program即時報廢。當時心想,不如自己寫一個... 幾年也沒有做出來...
今日,不知為什麼一起床就想去做這個東西,寫了一整天,完成了整個php script。
工作:
到www.mingpaonews.com取得所有headline,
用家選擇若干篇興趣的文章後,再submit即可一次過閱讀所選的文章。
功能:
自動設charset為Big5-HKSCS,不用每頁也要手動轉;
文章的附圖也會貼上,onMouseOver可放大。
限制:
娛樂、財經及賽馬的排版是獨立的,沒有處理它們。
Code:
<?php
function DisplayNewsPage($title,$body,$pic,$pictext)
{
global $base_url;
print '<table border=1><tr><td width=200 VALIGN="top">';
if (is_array($pic))
{
foreach ($pic as $key => $val)
{
print "<img src=\"".$base_url.$val."\" onmouseover=\"popImg(true, this);\" onmouseout=\"popImg(false);\" width=180>"."<BR>\r\n";
print $pictext[$key]."<BR><BR>\r\n";
}
}
print '</td><td VALIGN="top">';
print '<H1>'.$title.'</H1><BR><BR>';
print $body;
print '</td></tr>';
print '</table>';
}
function ProcessNewsPage($url)
{
global $base_url;
$main_content = file_get_contents($base_url.$url);
$pic = "";
$pictext = "";
preg_match_all('|<font size="4" class="txt150" color="#006666">(.*)</font>|U',$main_content, $layer1, PREG_SET_ORDER);
$title = $layer1[0][1];
if (preg_match_all('|<input type="hidden" name="content" value="([^"]*)"|is',$main_content, $layer2, PREG_SET_ORDER))
{
$body = $layer2[0][1];
}
if (preg_match_all("|<font size=2 class='txt150'>(.*)\n.*;javascript:viewlargephoto\('([^']*)'\);|U",$main_content, $layer3, PREG_SET_ORDER))
{
foreach ($layer3 as $val)
{
$pic[] = $val[2];
$pictext[] = $val[1];
}
}
DisplayNewsPage($title,$body,$pic,$pictext);
}
function ProcessPage($name,$url)
{
global $title_keys;
global $base_url;
$main_content = file_get_contents($url);
preg_match_all("|<a[^>]*>(.*)</a>|U",$main_content, $layer1, PREG_SET_ORDER);
foreach($layer1 as $val)
{
if (strstr($val[0],'http')) continue;
if (strstr($val[0],'mailto')) continue;
if (strstr($val[0],'href="#')) continue;
$found = 0;
foreach ($title_keys as $k)
{
if (strstr($val[0],$k))
{
$found = 1;
break;
}
}
if ($found == 1) continue;
if (preg_match_all('|href="([^"]*)"|U',$val[0], $layer2, PREG_SET_ORDER))
{
$a = $layer2[0][1];
if (strstr($val[1],"..."))
{
@$pages[$a]="";
}
else if (@strstr($pages[$a],trim($val[1])))
{
}
else
{
@$pages[$a].=$val[1];
}
}
}
print '<FORM action='.$_SERVER['PHP_SELF'].' method=POST target=_new>';
print '<table border=1><tr>';
print '<td width=100 valign=top>'.$name ."<BR>\n";
print '<INPUT type=SUBMIT value=Submit><INPUT type=RESET>';
print '<INPUT type=HIDDEN name=ShowNews value=1>';
print "<BR>\r\n</td><td valign=top>";
foreach ($pages as $key => $val)
{
print "<INPUT type=CHECKBOX name=$key value=$key>";
print "<a href=".$_SERVER['PHP_SELF']."?ShowNews=1&$key=$key target=_new>$val</a><BR>\n";
}
print '</td></tr></table>';
print '</FORM>';
}
function ProcessAllTitles()
{
global $title_pages_set;
if (!is_array($title_pages_set))
{
echo 'pass 12:00';
return;
}
foreach ($title_pages_set as $key => $val)
{
if (!strstr($val,"main"))
{
ProcessPage($key, $val);
}
}
}
function PrepareTitles()
{
global $title_keys;
global $title_pages_set;
global $today;
global $base_url;
global $main_url;
$title_tag = '<font color="FFFFFF">';
$main_content = file_get_contents($main_url);
$title_pages_set = "";
preg_match_all("|<a[^>]*>(.*)</a>|U",$main_content, $layer1, PREG_SET_ORDER);
foreach($layer1 as $val)
{
if (preg_match_all("|".$title_tag."|U",$val[0], $layer2, PREG_SET_ORDER))
{
$title_pages[$val[0]]=$val[1];
}
}
$removal = array('<font color="FFFFFF">', '</font>');
foreach ($title_pages as $key => $val)
{
$key = preg_replace('| target="[^"]*"|U','',$key);
$new_key = str_replace($removal, "", $key);
$new_val = str_replace($removal, "", $val);
preg_match_all('|href="([^"]*)"|U',$new_key, $layer3, PREG_SET_ORDER);
if (!strstr($layer3[0][1],"http"))
{
$title_keys[] = $layer3[0][1];
$title_pages_set[$new_val] = $base_url.$layer3[0][1];
}
}
}
function PrintJavaScript()
{
print '<script type=\'text/javascript\'>';
print 'function get(eid)';
print '{';
print ' var d = document;';
print ' var r = d.getElementById(eid);';
print ' return r;';
print '}';
print 'function popImg(open, iref)';
print '{';
print ' if (open)';
print ' {';
print ' var top = (iref.offsetParent.offsetParent.offsetTop + iref.offsetTop) + \'px\';';
print ' var curleft = 0;';
print ' var obj = iref;';
print ' do {';
print ' curleft += obj.offsetLeft;';
print ' } while (obj = obj.offsetParent);';
print ' var left = (curleft + iref.offsetWidth )+ \'px\';';
print ' var img = \'<img src="\' + iref.src + \'" />\';';
print ' var d = document;';
print ' if (null == get(\'popImg\'))';
print ' {';
print ' var pop = d.createElement(\'DIV\');';
print ' pop.id = \'popImg\';';
print ' pop.style.position = \'absolute\';';
print ' d.body.appendChild(pop);';
print ' }';
print ' var pop = get(\'popImg\');';
print ' pop.innerHTML = img;';
print ' pop.style.top = top;';
print ' pop.style.left = left;';
print ' pop.style.display = \'block\';';
print ' }';
print ' else';
print ' {';
print ' var pop = get(\'popImg\');';
print ' pop.style.display = \'none\';';
print ' }';
print '}';
print '</script>';
}
function PrepareGlobals()
{
global $HTTP_HEADER;
global $HTTP_FOOTER;
global $today;
global $base_url;
global $main_url;
$HTTP_HEADER = '<html><header><meta http-equiv="Content-Type" content="text/html; charset=Big5-HKSCS"><title>My MingPaoNews</title></header><body>'."\r\n";
$HTTP_FOOTER = "\r\n".'</body></html>'."\r\n" ;
$today = date("Ymd");
$base_url = "http://www.mingpaonews.com/".$today."/";
$main_url = $base_url."main.htm";
}
function DoShowNews()
{
global $HTTP_HEADER;
global $HTTP_FOOTER;
print $HTTP_HEADER;
PrintJavaScript();
foreach($_REQUEST as $key => $value)
{
if ($key == "ShowNews") continue;
ProcessNewsPage($value);
}
print $HTTP_FOOTER;
}
function DoIndex()
{
global $HTTP_HEADER;
global $HTTP_FOOTER;
print $HTTP_HEADER;
PrepareTitles();
ProcessAllTitles();
print $HTTP_FOOTER;
}
// MAIN HERE
PrepareGlobals();
if (isset($_REQUEST['ShowNews']))
{
DoShowNews();
}
else
{
DoIndex();
}
?>
Subscribe to:
Posts (Atom)