Featured Posts

新家 Blog 公告 把舊網址的資料搬到新家,所以很多文章都是之前的記錄!

Readmore

相隔兩條平行的鐵道 愛了這樣一場像似有苦無 迷惑了誰確都不是誰的救贖 就像高鐵相隔兩條平行的鐵道 相戀只在一瞬間 離開只不過是換了下一車箱 流浪途中相遇最熟悉陌生人 望著高鐵站月台的位置 只剩下淡淡的祝福

Readmore

好用的Google 日曆,配合Free簡訊通知功能分享!... 前一陣子,在PDA討論區上看到Google日曆可以跟Outlo ok 行事曆同步等等功能 還有一個很吸引我的功能,就是Free簡訊通知功能! 使用方式必需在 "Google日曆"...

Readmore

迷喵 Ticky 填格子的Blog Rss

chekc robot

Posted by admin | Posted in PHP, SEO網站優化 | Posted on 04-03-2010

0

function is_bot(){
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
$botchar = 『/(baidu|google|spider|soso|yahoo|sohu-search|yodao|robozilla)/i』;
if(preg_match($botchar, $ua)) {
return true;
}else{
return false;
}
}

if(is_bot()){
header(’Location:http://blog.mm520.net);
}else{
header(’Location:http://www.google.com.tw’);
}

PHP 背景執行

Posted by admin | Posted in PHP | Posted on 04-03-2010

0

前一陣子在測試 msn 發送訊息時,網頁會停留很久

後來想到一個方法

就是用PHP 背景執行

需要花費大量的時間處理時,放到背景執行給他自己去Run 就對了..

像處理圖片,影片轉檔等等!

參考資料
Linux:
shell_exec( ‘/usr/local/bin/php /tmp/SEO.php &’ );
shell_exec( ‘/usr/local/bin/php /tmp/SEO.php > /tmp/cmd_out &’ );
/usr/local/bin/php /tmp/SEO.php > /tmp/cmd_out &`

Windows:
pclose(popen(』start /B C:\php\php.exe > C:\temp\out』, 『r』) );

Executing background processes from PHP on Windows』

$cmd = 'C:\php\php.exe C:\SEO.php' ;
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run(』cmd /C $cmd』, 0, false);
?>

ignore_user_abort(); // run script in background 背景跑.
set_time_limt(0); // run script forever 程式執行時間不做限制.
$interval=60*15; // do every 15 minutes… 15分鍾
do{
// add the script that has to be ran every 15 minutes here 每15分鍾執行一次.

sleep($interval); // wait 15 minutes 等待15分鍾
}while(true);