Posted by admin | Posted in Javascript, PHP | Posted on 09-03-2010
0
今天才知道原來的FCK 已經改名字..
http://ckeditor.com/
1
2
3
4
5
6
7
8
9
10
11
12
13
| <textarea cols="80" id="editor1" name="editor1" rows="10">test</textarea>
<?php
// Include CKEditor class.
include_once "ckeditor/ckeditor.php";
// Create class instance.
$CKEditor = new CKEditor();
// Path to CKEditor directory, ideally instead of relative dir, use an absolute path:
// $CKEditor->basePath = '/ckeditor/'
// If not set, CKEditor will try to detect the correct path.
$CKEditor->basePath = 'ckeditor/';
// Replace textarea with id (or name) "editor1".
$CKEditor->replace("editor1");
?> |
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’);
}
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);
Posted by admin | Posted in PHP, SEO網站優化 | Posted on 23-11-2009
0
php Snoopy手冊 中文版
Snoopy是什麼?
Snoopy是一個php類,用來模仿web流覽器的功能,它能完成獲取網頁內容和發送表單的任務。
Snoopy的一些特點:
* 方便抓取網頁的內容
* 方便抓取網頁的文本內容 (去除HTML標籤)
* 方便抓取網頁的鏈結
* 支援代理主機
* 支援基本的用戶名/密碼驗證
* 支援設置 user_agent, referer(來路), cookies 和 header content(頭文件)
* 支援流覽器轉向,並能控制轉向深度
* 能把網頁中的鏈結擴展成高質量的url(默認)
* 方便提交資料並且獲取返回值
* 支持跟蹤HTML框架(v0.92增加)
* 支持再轉向的時候傳遞cookies (v0.92增加)
要求:
Snoopy requires PHP with PCRE (Perl Compatible Regular Expressions),
which should be PHP 3.0.9 and up. For read timeout support, it requires
PHP 4 Beta 4 or later. Snoopy was developed and tested with PHP 3.0.12.
類方法:
fetch($URI)
———–
這是為了抓取網頁的內容而使用的方法。
$URI參數是被抓取網頁的URL地址。
抓取的結果被存儲在 $this->results 中。
如果你正在抓取的是一個框架,Snoopy將會將每個框架追蹤後存入陣列中,然後存入 $this->results。
fetchtext($URI)
—————
本方法類似於fetch(),唯一不同的就是本方法會去除HTML標籤和其他的無關資料,只返回網頁中的文字內容。
fetchform($URI)
—————
本方法類似於fetch(),唯一不同的就是本方法會去除HTML標籤和其他的無關資料,只返回網頁中表單內容(form)。
fetchlinks($URI)
—————-
本方法類似於fetch(),唯一不同的就是本方法會去除HTML標籤和其他的無關資料,只返回網頁中鏈結(link)。
默認情況下,相對鏈結將自動補全,轉換成完整的URL。
submit($URI,$formvars)
———————-
本方法向$URL指定的鏈結位址發送確認表單。$formvars是一個存儲表單參數的陣列。
submittext($URI,$formvars)
————————–
本方法類似於submit(),唯一不同的就是本方法會去除HTML標籤和其他的無關資料,只返回登陸後網頁中的文字內容。
submitlinks($URI)
—————-
本方法類似於submit(),唯一不同的就是本方法會去除HTML標籤和其他的無關資料,只返回網頁中鏈結(link)。
默認情況下,相對鏈結將自動補全,轉換成完整的URL。
類屬性: (缺省值在括弧裏)
$host 連接的主機
$port 連接的埠
$proxy_host 使用的代理主機,如果有的話
$proxy_port 使用的代理主機埠,如果有的話
$agent 用戶代理偽裝 (Snoopy v0.1)
$referer 來路資訊,如果有的話
$cookies cookies, 如果有的話
$rawheaders 其他的頭資訊, 如果有的話
$maxredirs 最大重定向次數, 0=不允許 (5)
$offsiteok whether or not to allow redirects off-site. (true)
$expandlinks 是否將鏈結都補全為完整地址 (true)
$user 認證用戶名, 如果有的話
$pass 認證用戶名, 如果有的話
$accept http 接受類型 (image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*)
$error 哪里報錯, 如果有的話
$response_code 從伺服器返回的回應代碼
$headers 從伺服器返回的頭資訊
$maxlength 最長返回資料長度
$read_timeout 讀取操作超時 (requires PHP 4 Beta 4+)
設置為0為沒有超時
$timed_out 如果一次讀取操作超時了,本屬性返回 true (requires PHP 4 Beta 4+)
$maxframes 允許追蹤的框架最大數量
$status 抓取的http的狀態
$temp_dir 網頁伺服器能夠寫入的暫存檔案目錄 (/tmp)
$curl_path cURL binary 的目錄, 如果沒有cURL binary就設置為 false