[ php ]
25 九月, 2010 20:25
phpMyFAQ install 安裝
phpMyFAQ是一個支援多國語言, 完全是資料庫導向的FAQ系統. 其支援多種資料庫,並且提供有WYSIWYG編輯器的內容管理系統, 有影像管理,彈性化的群組與使用者管理,新聞系統,使用者追蹤,語言模組,樣板, 支援PDF,備份系統,動態資料夾,並且易於安裝, 從2003年到現在持續有新版本, 目前已經到2.6版
可以先閱讀原廠網站的安裝
http://www.phpmyfaq.de/documentation.2.6.en.php
安裝方式如下
- 下載最新版的phpMyFAQ 2.6.8
http://www.phpmyfaq.de/getfaq.php?number=2.6.8&ext=.tar.gz
- 在web主機的根目錄解壓縮, 或是在PC端解壓縮再上傳上去, 預設目錄是phpmyfaq-2.6.8
- 預先建立下面的資料夾與檔案, 權限要是777
■config/ 原本就有這個資料夾, 先將資料夾設為777, 到時候會自動產生database.php在裡面
■the directory attachments/
■the directory data/
■the directory images/
- 執行install/setup.php
這個程式會檢查是否有上面的資料夾, 權限是否為777,所以我們應該要先建立起來,如果沒有的話他會提示你要建立
- 輸入資料庫的帳號密碼與名稱, 還有基本的設定, 記得資料庫建立時要是utf8_unicode_ci的校對, 如果是用latin1的話到時候會發現所有中文字都會變成亂碼. 在這裡把default language設成chinese tranditional

- 點選click安裝後就, 系統就完成了.
- 這個版本的phpmyfaq有一個程式有編碼的問題, 因為預設的語言檔已經是UTF-8了, 網頁也都是跑UTF-8,不需要再解碼成latin, 請打開inc\Linkverifier.php的第897行, 將
return ($cron ? '' : utf8_decode($output));
改成
return ($cron ? '' : $output);
直接將內容輸出即可.
- 後續如果有一些翻譯或是設定的問題再參考官網自行修正.
- 修正畫面可以從template的tpl下手.
[ php ]
14 八月, 2009 15:55
php 安裝 --with-imap 選項時出現 U8T_CANONICAL missing
configure php 5.2.10 --with-imap 時出現
checking for U8T_CANONICAL... no
configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.
安裝libc-client-devel就可以解決
yum install libc-client-devel
另外視情況如果有開啟ssl支援的話需要再加入
--with-imap-ssl
[ php ]
25 六月, 2009 11:06
php判斷jason或是xml
php判斷jason或是xml
在找到這個物件
http://tw.php.net/manual/en/tidy.isxml.php
也可以用隱藏錯誤的方法
if($doc = @DOMDocument::loadXML($post_result))
<?php
/**
* 可以解析XML和JSON格式的數據
* 先判斷是XML格式還是JSON格式的數據,然後解析
* 返回解析後的數據,格式為array
* @author skendy 2008-12-16
*/
class checkStringFormat{
var $arr;
public $mark;
/**
* 解析函數,判斷字符串格式
*
* @param string $str
*/
function __construct($str){
if($this->mark = $this->xml_parser($str)){
$this->arr = $this->mark;
}elseif ($this->mark = $this->json_parser($str)){
$this->arr = $this->mark;
}else {
$this->arr = 'NULL';
}
}
/**
* 解析XML格式的字符串
*
* @param string $str
* @return 解析正確就返回解析結果,否則返回false,說明字符串不是XML格式
*/
function xml_parser($str){
$xml_parser = xml_parser_create();
if(!xml_parse($xml_parser,$str,true)){
xml_parser_free($xml_parser);
return false;
}else {
return (json_decode(json_encode(simplexml_load_string($str)),true));
}
}
/**
* 解析JSON格式的字符串
*
* @param string $str
* @return 解析正確就返回解析結果,否則返回false,說明字符串不是JSON格式
*/
function json_parser($str){
$arr = json_decode($str,true);
if(gettype($arr) != "array"){
return false;
}else {
return $arr;
}
}
/**
* 也有可能既不是XML也不是JSON數據
*
* @param string $str
* @return unknown
*/
function string_parser($str){
$strArr = explode("&",$str);
$len = @count($strArr);
if($len < 1){
return false;
}else{
return false;
}
}
/**
* 返回解析的結果
*/
function display(){
return $this->arr;
}
}
?>
[ php ]
02 六月, 2009 19:08
MySQL和phpMyAdmin工具與UTF8中文亂碼的終極研究
最近筆者勤於備份資料,而且試著把建立在MySQL資料庫中的資料在各種平台轉來轉去,發現了許多的問題,而這些問題在網路上有許多網友問過,但看到很多人找不出答案,因而放棄重裝系統或者放棄掉寶貴的舊有資料,那麼我相信筆者這一篇文章可能會讓您放棄掉堅持在所謂的”UTF-8中文亂碼”的迷思。
為什麼筆者稱之為”迷思”,許多使用PHP程式語言搭配MySQL資料庫的朋友百分之一百零一會使用phpMyAdmin,但隨著MySQL資料庫版本的升級,phpMyAdmin資料庫管理工具也跟著改版,曾幾何時您會發現,原本使用phpMyAdmin工具可以在資料表中看到的中文,變成了亂碼。
(閱讀全文)
[ php ]
11 五月, 2009 11:07
atmail demo php 5.61 安裝 install
測試atmail 商用版的功能
atmail是一套歷史悠久的郵件系統, 主要以介面好用著名, 之前安裝過他的open source版本, 不過不是很好用, 這次看了一下費用, 覺得似乎不算貴, 所以打算先研究一下用法, 看是否要付費.
安裝前沒有先看系統需求, 造成在php4的系統安裝完無法登入, 最後重新編譯php 到php5.2.9 才安裝完成.所以切記, 要安裝任何軟體之前請先看系統需求.
http://atmail.com/wiki/doku.php?id=installation:requirement#software_requirements
下載atmail測試版本, 尤於我們已經有使用的mail system, 所以我們只下載webmail的部份, 目前的版本是5.61
標準安裝說明如下:
http://atmail.com/wiki/doku.php?id=installation:webmail_client_installation
這邊我簡單說明我的安裝
- 下載到/tmp或任何你儲存檔案的位置
- 直接在/var/www/html下面解開這個檔案, 解開後會有atmail的目錄
tar zxf atmailphpdemo.tar.gz
- chown -R apache atmail
- 直接打開網站進行安裝的過程
http://ip/atmail
- 進入安裝頁面會測試你是否符合需求, 調整所需的參數在 php.ini設定檔, 尤於atmail有用到ioncube做編碼, 所以一定要裝加速器解碼, 原始檔裡面已經有附可用的so檔
在php.ini加入下面這行
zend_extension= /var/www/html/atmail/ioncube/lin/ioncube_loader_lin_5.2.so
重啟apache
- 選擇語系與同意授權
- 設定資料庫的帳號密碼, 如果資料庫已經存在, 就不需要勾選create database
- smtp設定, 如果此webmail是架在同一台主機, smtp host設定成localhost即可
- 我們是測試版, 所以不會有serial key的那一頁
- 是否要從 squirrelmail或是其它webmail匯入資料, 不過這邊都是要用資料庫的方式記錄資料的webmail才可以, 用config檔的不行
- 管理介面的帳號密碼設定, 這邊只使用了 .htaccess設定, 並沒有一個真正的登入系統.
- 安裝完成, 測試連線與管理
- 選了中文安裝以後, 發現反而中文語系預設沒有安裝, 到http://ip/atmail/webadmin做chinese語系安裝, 並設定為預設檔.
- 中文的翻譯有點怪怪的, 手動修改lang/languages/chinese/chinese.lang, 這是UTF-8的編碼, 修改完以後到主目錄中執行
php lang.php chinese lang/languages/chinese/chinese.lang
完成後重新整理畫面你就會發現你的新翻譯完成了.
關於語系的修改可以參考下面
http://atmail.com/wiki/doku.php?id=customization:creating_new_language_file
http://atmail.com/wiki/doku.php?id=customization:language_system
http://atmail.com/wiki/doku.php?id=customization:language_translation
http://atmail.com/wiki/doku.php?id=customization:interface_customization
- 針對沒有編碼過的標題會有亂碼的問題, 因為整個系統是跑UTF-8, 所以當中文的標題沒有做編碼, 會無法翻譯. 通常會出現這種問題是寫程式發信時沒有針對發信的標題做編碼, 一般正常的郵件不會有問題.
順便一提, 雖然我還沒有購買, 但安裝的過程我有遇到一點問題, 寫信給support, 回應的速度很快喔. 讓人會想要用他們的產品.
[ php ]
10 四月, 2009 00:01
讓phpMyAdmin可以顯示big5與UTF-8中文編碼
phpMyAdmin 網頁預設是 UTF-8,若資料庫內是 Big5 資料,顯示資料庫內容會亂碼,解決方法。
系統環境:
php 5
MySQL 5.0.51
phpMyAdmin 2.11.9.5
修改phpMyAdmin/libraries/select_lang.lib.php
$mysql_charset_map = array 陣列敘述中,將 big5 改成 latin1
'big5' => 'latin1'
$available_languages = array 陣列敘述中,big5那一行將 zhtw-big5 改成 zhtw-big5-utf-8
將 chinese traditional 改為 chinese traditional big5
'zhtw-big5-utf-8' => array('zh[-_](tw|hk)|chinese traditional big5', 'chinese_traditional-big5', 'zh-TW', '中文'),
這樣改完,就可以用 phpMyAdmin看 Big5 資料。 在Language裡面會出現chinese traditional big5 與 chinese traditional 兩個選項, 其中沒有big5的就是標準的UTF-8格式
[ php ]
09 四月, 2009 23:29
使用PHP計算IP的數量與起始結束IP
輸入IP與mask後可以計算出這一段IP裡面的起始IP, 結束IP, Broadcast與Network
#!/usr/local/bin/php
<?php
$ip_addr = "168.95.1.1";
$subnet_mask = "255.255.255.0";
$ip = ip2long($ip_addr);
$nm = ip2long($subnet_mask);
$nw = ($ip & $nm);
$bc = $nw | (~$nm);
echo "IP Address: " . long2ip($ip) . "n";
echo "Subnet Mask: " . long2ip($nm) . "n";
echo "Network Address: " . long2ip($nw) . "n";
echo "Broadcast Address: " . long2ip($bc) . "n";
echo "Number of Hosts: " . ($bc - $nw - 1) . "n";
echo "Host Range: " . long2ip($nw + 1) . " -> " . long2ip($bc - 1) . "n"; ?>
Produces the output:
IP Address: 172.14.1.57
Subnet Mask: 255.255.255.0
Network Address: 172.14.1.0
Broadcast Address: 172.14.1.255
Number of Hosts: 254
Host Range: 172.14.1.1 -> 172.14.1.254
?>
[ php ]
09 四月, 2009 19:04
LifeType 網址設定 自訂Custom URL
當要做SEO 搜尋引擎最佳化時就必需對LifeType的輸出做修正
在網址設定裡面可以使用的參數如下
引用
http://wiki.lifetype.net/index.php/Custom_URLs
Tag:
不屬於英文的字母會被取代
{blogname}: Inserts the blog name. blog的名字
{blogid}: Inserts the blog numerical identifier.
{blogowner}: Inserts the username of the user who owns the blog. 如果使用這個參數要小心一個人有兩個以上的blog的問題
{username}: Inserts the username of the user.
{userid}: Inserts the numerical identifier of this user
{postname}: Inserts the topic of the article.
{postid}: Inserts the article numerical identifier.
{year}: Inserts the 4 digit year.
{month}: Inserts the 2 digit month.
{day}: Inserts the 2 digit day.
{hour}: Inserts the 2 digit hour.
{minute}: Inserst the 2 digit minutes.
{catid}: Inserts the article category name.
{catname}: Inserts the article category id.
{albumname}: Inserts the resource album name.
{albumid}: Inserts the resource album id.
{resourcename}: Inserts the resource file name.
{resourceid}: Inserts the resource numerical identifier.
找到下面的資料
- Apache ModReWrite 是透過 apache 的 mod_rewrite 模組來作 url 轉換,所以 http://www.xxx.com/index.php?blogId=1 會被轉換成 http://www.xxx.com/your-blog 。這跟再使用一般網址時沒有兩樣。因為 Apache 幫你作了所有的轉換工作。
- 簡潔網址與自訂網址是透過 apache 的 ErrorDocument 的設定,來把『錯誤』的網址轉到特定的 pLog 程式來作處理。為什麼叫做錯誤?因為 http://www.xxx.com/your-blog 其實是個不存在的URL,當 apache 接收到後,就把 http://www.xxx.com/your-blog 傳到 error.php,error.php 再把網址轉譯成相對應的 變數如 blogId, articleId 等,再把這個 request 傳到 index.php,再進入 pLog 的正常執行程序。
[ php ]
09 四月, 2009 14:17
LifeType 升級1.2 install安裝說明
昨天晚上花了一點時間, 將我自己原本使用老舊的LifeType 1.0.1版更新到1.2.8版 , 因為原本只是自己寫心得用, 沒有對外開放, 不過如果要對外開放還是得裝一下新的版本比較安全, 功能也比較多
事前準備
備份設定檔 - config/config.properties.php
備份網站 - 將整個資料夾壓縮就可以
備份資料庫 - 可以使用phpmyadmin匯出或是直接壓縮檔案(如果你是自己管主機)
尤於我沒有安裝plugin, 之前也沒有上傳什麼檔案, 所以升級的過程很簡單, 只要直接安裝新版的軟體, 主要是資料庫要升級
-
將原本的站台設定成使用standard的template
因為我想用最乾淨的方式升級, 所以我放棄保留舊的資料, 不過這樣會造成預設的檔案只有standard這個template
-
升級到LifeType 1.1.6
1.0無法直接升級到1.2, 所以需要先升級到1.1.6
下載1.1.6原始檔, 解壓縮
修改config/config.properties.php ,將原本的資料庫帳號密碼填入
修改config/config.properties.php 的權限為777 (不然wizard.php會提醒)
執行wizard.php , 先按上面的fix , 完成後關掉ie, 再執行一次wizard.php
這時後就照下一步, 下一步
-
升級到LifeType 1.2.8
跟升級到1.1.6的方法一樣
下載檔案
-
將wiazard.php移除
修改config/config.properties.php的權限為644
此時應該已經可以進入管理介面
-
語系檔可以重裝, 很奇怪的是預設這些檔案都有, 不過並不會自動加入
進入管理介面->全部站台管控->語系管理->新增語系->掃描語系
-
下載所有的template.zip, 並解開
進入管理介面->全部站台管控->新增模版->掃描模版
這時候應該就會裝好所有預設的模版
-
下載所需的plugin.zip到plugins資料夾
-
1.2_print.zip 可以列印文章
安裝後要手動修改所選的template下面的post.template, 加入
<a href="{$print->printView($post)}">Print View</a>
-
Tommy修改的中文數字驗證,用中文數字取代阿拉伯數字
下載 解開後可以在個人網誌設定 -> 迴響驗證設定 設定所需的參數
修改plugin裡面的locale檔
$messages["authimage_type_code"] = '輸入下面的阿拉伯數字:';