設置的前提:你的虛擬主機必須支持apache mod_Rewrite! 你可以在你的虛擬主機控制面板查找或詢問主機商,目前國外很多主流主機商的PHP主機都是默認支持該功能的.
設置方法:
首先:
打開 /includes/application_top.php
查找
define('PAGE_PARSE_START_TIME', microtime());
插入
require('seflt.php');
打開 /includes/application_bottom.php
在?>前插入
ob_end_flush();
其次:
創建.htaccess ; 內容如下:
RewriteEngine on
RewriteBase /
RewriteRule ^([a-z]{2})/(.*)$ Ū?language=ũ&%{QUERY_STRING}
RewriteRule ^manufacturer([0-9{}]+_?[0-9{}]*)(/?.*)$ Ū?manufacturers_id=ũ&%{QUERY_STRING}
RewriteRule ^product([0-9{}]+_?[0-9{}]*)(/?.*)$ Ū?products_id=ũ&%{QUERY_STRING}
RewriteRule ^category([_0-9]+)/(.*)$ Ū?cPath=ũ&%{QUERY_STRING}
RewriteRule ^(.*)\.html(.*)$ ũ.php?%{QUERY_STRING}
再次:
創建seflt.php ; 內容如下:
/*
SEF Link Transformer for osCommerce (SEF stand for Search Engine Friendly)
Version: Lite 0.8.0 Alpha
Author: Silencer (silencer@softhome.net)
Release date: 26 November 2003
Legal notices: i don't care about all legal stuff, too lazy to attach GNU GPL licence,
so forget it. But DO NOT remove my name and as always NO WARRANTIES.
Installation instructions: see readme.txt
Warning - do not use this on heavy loaded shops (more than 10000 visitors per day)
if you not on dedicated server.
*/
function callback($pagecontent) {
$pagecontent = preg_replace_callback("/(<[Aa][ \r\n\t]{1}[^>]*href[^=]*=[ '\"\n\r\t]*)([^ \"'>\r\n\t#]+)([^>]*>)/",'wrap_href',$pagecontent);
return $pagecontent;
}
function transform_uri($param) {
$uriparts = parse_url($param[2]);
$newquery='';
$scheme = $uriparts['scheme'].'://';
if (($scheme != 'http://') && ($scheme != 'https://')) return $param[1].$param[2].$param[3];
$host = $uriparts['host'];
if ($host != $_SERVER['SERVER_NAME'] && $host != $_SERVER['SERVER_ADDR']) return $param[1].$param[2].$param[3];
$host .= '/';
$path = $uriparts['path'];
list($file,$extension) = explode('.', basename($path));
if($extension != 'php') return $param[1].$param[2].$param[3];
$extension = ".html";
$path = rtrim(dirname($path),'/');
$query = $uriparts['query'];
$anchor = $uriparts['anchor'];
if ($a = explode('&',$query)){
foreach ($a as $b) {
list($key,$val) = split('=',$b);
switch ($key) {
case 'cPath':
$path = 'category'.$val.'/'.$path;
break;
case 'language':
$path = $val.'/'.$path;
break;
case 'products_id':
$path .= 'product'.$val.'/'
break;
case 'manufacturers_id':
$path .= 'manufacturer'.$val.'/'
break;
case 'osCsid':
if(strstr($_SERVER["HTTP_USER_AGENT"],'Mozilla')) $newquery .= $key.'='.$val.'&'
break;
default:
if($newquery &line;&line; $key) $newquery .= $key.'='.$val.'&'
}
}
}
if ($newquery) $newquery = '?'.rtrim($newquery,'&');
return $param[1].$scheme.$host.$path.$file.$extension.$newquery.$anchor.$param[3];
}
function wrap_href($param) {
return transform_uri($param);
}
ob_start("callback");
?>
最後:
上傳文件.htaccess、seflt.php到你的虛擬主機的OSC根目錄下.
2009年10月19日 星期一
2007年4月2日 星期一
[OSC]Linux環境下改成
原始碼
@setlocale(LC_TIME, 'zh_TW.UTF-8');
define('DATE_FORMAT_SHORT', '%m/%d%/%Y');
// this is used for strftime()
define('DATE_FORMAT_LONG', '%Y年%m月%d日%A');
// this is used for strftime()
define('DATE_FORMAT', 'm/d/Y');
// this is used for date()
define('DATE_TIME_FORMAT', DATE_FORMAT_SHORT . ' %H:%M:%S');
define('DATE_FORMAT_SHORT', '%m/%d%/%Y');
// this is used for strftime()
define('DATE_FORMAT_LONG', '%Y年%m月%d日%A');
// this is used for strftime()
define('DATE_FORMAT', 'm/d/Y');
// this is used for date()
define('DATE_TIME_FORMAT', DATE_FORMAT_SHORT . ' %H:%M:%S');
這樣會顯示成
2005年12月01日週三
[OSC]目錄架構簡介
管理者部份程式
/osc/admin/ 功能程式
/osc/admin/images/ 管理者用各種圖片存放目錄
/osc/admin/includes/ 版面配置
/osc/admin/includes/boxes/ 功能區塊
/osc/admin/includes/languages/ 管理者語系
/osc/admin/includes/languages/tchinese.php 管理者繁體中文語系通用部份
/osc/admin/includes/languages/ 管理者繁體中文語系功能部份
其他就視程式情況放置
用戶端部份程式
/osc/ 功能程式
/osc/download/ 下載檔案的存放目錄
/osc/images/ 各種圖片存放目錄
/osc/includes/ 版面配置及部份系統設定檔
/osc/includes/boxes/ 功能區塊
/osc/includes/modules/ 外掛模組
/osc/includes/modules/order_total 訂單總合模組
/osc/includes/modules/payment 付款方式模組
/osc/includes/modules/shipping 運送模組
/osc/includes/languages/ 語系
/osc/includes/languages/tchinese.php 繁體中文語系通用部份
/osc/includes/languages/tchinese/ 繁體中文語系功能部份
/osc/includes/languages/tchinese/modules/order_total/ 總合模組繁體中文語系
/osc/includes/languages/tchinese/modules/payment/ 付款模組繁體中文語系
/osc/includes/languages/tchinese/modules/shipping/ 運送模組繁體中文語系
/osc/admin/ 功能程式
/osc/admin/images/ 管理者用各種圖片存放目錄
/osc/admin/includes/ 版面配置
/osc/admin/includes/boxes/ 功能區塊
/osc/admin/includes/languages/ 管理者語系
/osc/admin/includes/languages/tchinese.php 管理者繁體中文語系通用部份
/osc/admin/includes/languages/ 管理者繁體中文語系功能部份
其他就視程式情況放置
用戶端部份程式
/osc/ 功能程式
/osc/download/ 下載檔案的存放目錄
/osc/images/ 各種圖片存放目錄
/osc/includes/ 版面配置及部份系統設定檔
/osc/includes/boxes/ 功能區塊
/osc/includes/modules/ 外掛模組
/osc/includes/modules/order_total 訂單總合模組
/osc/includes/modules/payment 付款方式模組
/osc/includes/modules/shipping 運送模組
/osc/includes/languages/ 語系
/osc/includes/languages/tchinese.php 繁體中文語系通用部份
/osc/includes/languages/tchinese/ 繁體中文語系功能部份
/osc/includes/languages/tchinese/modules/order_total/ 總合模組繁體中文語系
/osc/includes/languages/tchinese/modules/payment/ 付款模組繁體中文語系
/osc/includes/languages/tchinese/modules/shipping/ 運送模組繁體中文語系
2007年3月27日 星期二
[OSC] big5 碼的資料庫輸入與輸出.
在進入資料庫之前要先使用下列函式,以避免造成 "許功蓋" 錯誤:
big5_addslashes('許') => 許\ (資料庫顯示) *輸入
將資料呈現到網頁時要加此函數,才不會造成字後面多各 "\" 符號:
big5_stripslashes('許\ ') => 許 (資料庫輸出) *輸出
big5_addslashes('許') => 許\ (資料庫顯示) *輸入
將資料呈現到網頁時要加此函數,才不會造成字後面多各 "\" 符號:
big5_stripslashes('許\ ') => 許 (資料庫輸出) *輸出
[OSC]資料分頁運用
$sql = "select p.products_id ….."; //搜尋的SQL 語法
$data_split = new splitPageResults($sql, 20); //新的分頁物件 ,設定分成20筆一頁
$result_data_detail = tep_db_query($data_split->sql_query);//搜尋資料庫
運用:$data_split->display_count('目前資料頁數');//顯示分頁數量
if (($data_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')))
{
echo $data_split_split->display_links(20,tep_get_all_get_params(array('page', 'info')));
}
2007年3月26日 星期一
[OSC]常用資料庫搜尋函數
$sql= '帶入欲搜尋的SQL 碼';
tep_db_query($sql) ; 搜尋.
tep_db_num_rows(); 取出搜尋到的資料筆數.
tep_db_fetch_array(); 將資料依比一比抓出來. 常搭配while (){ }
tep_db_query($sql) ; 搜尋.
tep_db_num_rows(); 取出搜尋到的資料筆數.
tep_db_fetch_array(); 將資料依比一比抓出來. 常搭配while (){ }
[OSC]要將非必填欄位改為必填
第一步
修改 \catalog\includes\languages\tchinese.php
找到
define('ENTRY_FAX_NUMBER_ERROR', '');
define('ENTRY_FAX_NUMBER_TEXT', '');
改成
define('ENTRY_FAX_NUMBER_ERROR', '行動電話不得少於 10 個字');
define('ENTRY_FAX_NUMBER_TEXT', '*');
第二步
修改 \catalog\create_account.php
找到
if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {
$error = true;
$messageStack->add('create_account', ENTRY_TELEPHONE_NUMBER_ERROR);
}
在下面加入
if (strlen($fax) < 10) {
$error = true;
$messageStack->add('create_account', ENTRY_FAX_NUMBER_ERROR);
}
修改 \catalog\includes\languages\tchinese.php
找到
define('ENTRY_FAX_NUMBER_ERROR', '');
define('ENTRY_FAX_NUMBER_TEXT', '');
改成
define('ENTRY_FAX_NUMBER_ERROR', '行動電話不得少於 10 個字');
define('ENTRY_FAX_NUMBER_TEXT', '*');
第二步
修改 \catalog\create_account.php
找到
if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {
$error = true;
$messageStack->add('create_account', ENTRY_TELEPHONE_NUMBER_ERROR);
}
在下面加入
if (strlen($fax) < 10) {
$error = true;
$messageStack->add('create_account', ENTRY_FAX_NUMBER_ERROR);
}
訂閱:
文章 (Atom)