ecshop的程序中,有個對象:$user,它是用來處理用戶信息的。比如登錄、注冊,還有就是用來和第三方管理通訊和共享資源的。在user.php中,有一條$user->login($username,$password)。這里的$user是來自includes/init.php中的 $user = &init_users();
而init_user函數又在lib_common.php中,他里面有一段非常經典的代碼。
include_once(ROOT_PATH.'includes/modules/integrates/'.$GLOBALS['_CFG']['integrate_code'] . '.php'); $cfg = unserialize($GLOBALS['_CFG']['integrate_config']); $cls = new $GLOBALS['_CFG']['integrate_code']($cfg);
默認情況下 $GLOBAL['_CFG']['integrate_code']的值為:ecshop
這是在、includes、lib_common.php 文件的function load_config() 函數中定義的:
1 if (empty($arr['integrate_code'])) 2 { 3 $arr['integrate_code'] = 'ecshop'; // 默認的會員整合插件為 ecshop 4 }
默認情況下,調用會員整合插件是ecshop。那么這包含的文件就是:'includes/modules/integrates/ecshop.php', 打開ecshop.php這個文件,你會發現它繼承了'includes/modules/integrates/integrate.php'
integrate.php里面有很多的方法:login()登陸,edit_user()編輯用戶資料,add_user()注冊用戶。 使用各自系統整合時,就需要重寫 integrate 基類,然后調用這個重寫后的類。