星期一, 7月 09, 2007

血海中的小孩

在這個已經發展成熟,競爭激烈的電腦世界,大公司殺得天昏地暗,細公司積極取得少量的市場,並與大公司合作,最終被收購。市的的競爭令廿年前的藍海,變成一片血紅,誰想佔一席位?除非有極出眾的新產品及極成功的推銷手段,並且有堅定的立場不被收購合併,否則很快會成為這個血海中的血,因為這參與者的實力太低,根本不能和大公司們競爭,螳臂擋車,結果就是一敗塗地,又或者被收購、被合併,辛苦打造出來的品牌,一下子就沒有了。
我就像這個血海中的一個小孩,正努力地找尋生存空間,但這點不容易做到,因為這小孩沒有大公司的財力,有的只是技術和少許﹝少得就像沒有﹞的錢,希望能維持一段時間,但可借這小孩根本就負擔不來。這小孩曾有過自己的獨立伺服器,有過安裝及管理Linux伺服器的經驗,編寫及管理過幾個網站,但他並沒有在這些網站上取得大公司們做相同的網站所取得的利潤,反而因伺服器機件老化而最終要關閉網站。他曾有過兩個討論區,曾努力發表有用的技術文章,可惜無論他多努力,網友們寧願到一些大的討論區看那些從他那處抄回來的文章,也不會去看他的。討論區的會員數沒錯是不停地增加中,但活躍的會員數由本身有的十多名跌到沒有,連他自己都沒有心情去發表了,根本就沒人會看,寫不寫也罷。就這樣,這個血海中的小孩唯有放棄,生存實在是太困難了。
小孩現在再次張眼四看,看不到一個生存點,看到的只是一望無際的血水,有自己的,也有其他參與者的。在這個血海中,那裏會有一小片藍海還未受血淺,可以供他生存的一點點空間?

星期二, 11月 28, 2006

javascript xEmail() function

今天我在 three.com.hk 上找到這段javascript程式碼:
function xEmail(strEmail) {
invalidChars ="~!$^&\*()+|=`\"\'";
if (strEmail==null || isWhitespace(strEmail))
return false;
if (strEmail.indexOf(' ') > -1)
return false;
if ((strEmail.indexOf(".com") == -1) && (strEmail.indexOf(".net") == -1) && (strEmail.indexOf(".org") == -1))
return false;
for (ai=0;ai badChar = invalidChars.charAt(ai);
if (strEmail.indexOf(badChar,0) > -1) {
return false;
}
}
atPos = strEmail.indexOf("@",1);
if (atPos ==-1)
return false;
if (strEmail.indexOf("@",atPos+1) > -1)
return false;
if (strEmail.indexOf("@.",1) > -1)
return false;
if (strEmail.indexOf("..",1) > -1)
return false;
periodPos = strEmail.indexOf(".",atPos);
if (periodPos == -1)
return false;
if (periodPos+2 > strEmail.length)
return false;
return true;
}

錯左一樣野。睇睇第七行幾白痴!乜呢個世界只係得.com .net .org !?three.com.hk 個個月食幾千至幾萬蚊人工的程式員冇聽聞過 .biz .us .cc .hk .tv 之類的 domain 咩?簡直係 programmer 的恥辱!我現在以一個熱愛編程的人這個身份對 three.com.hk 作出強烈的遣責,並要求該班程式員立即作出改善!我不希望這些不完善的垃圾程式碼會再次出現在一個 production system 上!!!

星期六, 10月 15, 2005

USL get onto SourceForge.net!

Well, today sf.net approved my registation of the USL(USB System Lock) project. It is a great solution to enhance system security. This program enable us to use a physical USB Drive to be a key to unlock the computer. Without the key, the computer will be locked by the program and cannot access by anyone. Nowadays, security become more and more important, so I am sure that this program will become very popular soon! Visit the USB System Lock webpage at http://usl.sf.net/ !

星期一, 9月 26, 2005

Valid email address correctly (PHP)

Nowadays, valid the format of the email is not enough, so, we need to valid it with making a testing connection to the email server and ask the email server that the user provided if the email account exisit! Here is a PHP function that can do this for you:
<?php

/* Return value: (true|false)
   true if valid, false if invalid */

function valid_email($email)
{
    global
$HTTP_HOST;

    if (!
eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $email)) {       
        return
false;
    }

    list(
$username,$domain) = split("@",$email);

    if (
checkdnsrr($Domain,"MX")) {
        
getmxrr ($Domain, $mxhost);
        
$host = $mxhost[0];
    }
    else {
        
$host = $domain;         
    }

    
$connect = fsockopen($host,25};
    if (
$connect) {
        if (
ereg("^220", $returns=fgets($connect,1024))) {
            
fputs($connect,'HELO ' . $HTTP_HOST . "\r\n");
            
$returns = fgets ($connect,1024);
            
fputs($connect,'MAIL FROM: <' . $email . ">\r\n");
            
$test1 = fgets($connect,1024);
            
fputs ($connect,'RCPT TO: <' . $email . ">\r\n");
            
$test2 = fgets($connect,1024);
            
fputs ($connect,"QUIT\r\n");
            
fclose($connect);
            if ((!
ereg("^250",$test1)) or (!ereg("^250",$test2))) {
                return
false;
            }
        }
    }
    else {
        return
false;
    }
    return
true;
}

?>

星期一, 8月 01, 2005

A better way to detect IP in PHP

Sometimes we cannot get the correct IP of the client by $_SERVER['REMOTE_ADDR'], so we need the following function!
<?php
function getrealip()
{
    
$ip = FALSE;
    if (!empty(
$_SERVER["HTTP_CLIENT_IP"])) {
        
$ip = $_SERVER["HTTP_CLIENT_IP"];
    }

    if (!empty(
$_SERVER['HTTP_X_FORWARDED_FOR'])) {
        
$ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']);
        if (
$ip) {
            
array_unshift($ips, $ip);
            
$ip = FALSE;
        }

        for (
$i = 0; $i < count($ips); $i++) {
            if (!
eregi ("^(10|172\.16|192\.168)\.", $ips[$i])) {
                if (
version_compare(phpversion(), "5.0.0", ">=")) {
                    if (
ip2long($ips[$i]) != false) {
                        
$ip = $ips[$i];
                        break;
                    }
                } else {
                    if (
ip2long($ips[$i]) != -1) {
                        
$ip = $ips[$i];
                        break;
                    }
                }
            }
        }
    }
    return (
$ip ? $ip : $_SERVER['REMOTE_ADDR']);
}
?>