跳到主要內容

發表文章

目前顯示的是 5月, 2011的文章

卡馬警衛 - 使用手冊

(核心架構 2.0,持續開發中) 卡馬警衛 x 掰噗   掰噗是在噗浪上和陪伴卡馬警衛工作的好夥伴 卡馬警衛截自此手冊更新前提供以下服務 自動回應 互動聊天 當日星座運勢查詢 地區天氣預報查詢 颱風最新動態 即時地震報告 當期發票號碼查詢 台鐵時刻與票價查詢 台灣電視節目查詢 咕狗翻譯 Youtube 影片/音樂 點播 以及影片資訊轉載功能 噗浪狗仔搜尋引擎 (beta) ※  請不要濫用服務資源,留給網友更多的福利  ※

Run a Long-Time Script with Self Modification Detection

Since PHP is convenient tool to process text contents and data from internet, sometimes we use PHP to process a large amount of data as batch script program, and running for a long time. But we may want to change the process rules from PHP script without restarting the program manually. In this case a self modification detection is very useful. class ScriptUpdater{ private static $scripts; private static $md5; //add a script file to watch the modification, filePath can be string or array public static function addScript($filePath){ if(is_array($filePath)) return self::addScript(array_pop($filePath)) && self::addScript($filePath); return ($md5 = @md5_file($filePath)) && (self::$scripts[$filePath] = $md5); } //reutrn the modified file or false, (if modified excutes a function) public static function update($onUpdateFunc = null, $args = null){ if($onUpdateFunc) return self::_watch() && @call_user_func_array($onUpdateFunc, $args); e...