ECMall的註冊與登陸機制

ecmall的註冊流程index.php?app=member&act=register。 php

首先app是member,act是register方法。 html

index.php中。經過ecmall的startup方法來啓動,主要包含了eccore/ecmall.php,startup方法中包含eccore/controller/app.base.php和eccore/model/model.base.php基礎類,經過 數據庫

1$app= isset($_REQUEST['app']) ? trim($_REQUEST['app']) : $default_app;
2$act= isset($_REQUEST['act']) ? trim($_REQUEST['act']) : $default_act; 

來獲取app和act。 app

若是是註冊,act=member那麼 frontend

1$app_class_name= ucfirst($app) . 'App';
2/* 實例化控制器 */
3$app= new$app_class_name();

這裏的$app = new MemberApp,調用MemberApp類裏面的register方法。而在register方法裏面,獲取註冊信息。經過global.lib.php中的ms方法。 函數

1include(ROOT_PATH . '/includes/passport.base.php');
2include(ROOT_PATH . '/includes/passports/'. MEMBER_TYPE . '.passport.php'.regissword.php

而在register中ms()函數中如下程序 this

1include(ROOT_PATH . '/includes/passports/'. MEMBER_TYPE . '.passport.php');
2$class_name  = ucfirst(MEMBER_TYPE) . 'Passport';
3$ms= new$class_name();

包含了default.passport.php中的DefaultPassport類,而他又繼承了BasePassport,他有幾行代碼 htm

1$user_class_name= ucfirst($this->_name) . 'PassportUser';
2$this->user = new$user_class_name();

因此程序裏面的$this -> user就是這麼來的。 對象

$user_class_name其實就是includes/passports/default.passport.php中的DefaultPassportUser類。而他又extends了BasePassportUser,他調用了BasePassportUser中的_local_add()方法。而_local_add()方法經過調用model中的member.model.php中的初始化數據,經過eccore/model/model.base.php中的BaseModel類下的function add($data, $compatible = false)方法來進行數據庫處理。從而完成了註冊功能。 繼承

01/**
02 *  添加一條記錄
03 *
04 *  @author Garbin
05 *  @param  array $data
06 *  @return mixed
07 */
08functionadd($data, $compatible= false)
09{
10    if(empty($data) || !$this->dataEnough($data))
11    {
12        returnfalse;
13    }
14    $data= $this->_valid($data);
15    if(!$data)
16    {
17        $this->_error('no_valid_data');
18        returnfalse;
19    }
20    $insert_info= $this->_getInsertInfo($data);
21    $mode= $compatible? 'REPLACE': 'INSERT';
22    $this->db->query("{$mode} INTO {$this->table}{$insert_info['fields']} VALUES{$insert_info['values']}");
23    $insert_id= $this->db->insert_id();
24    if($insert_id)
25    {
26        if($insert_info['length'] > 1)
27        {
28            for($i= $insert_id; $i< $insert_id+ $insert_info['length']; $i++)
29            {
30                $id[] = $i;
31            }
32        }
33        else
34        {
35            /* 添加單條記錄 */
36            $id= $insert_id;
37        }
38    }
39    return$id;
40}

登陸機制

ecmall電子商務系統的登錄,過程其實很是複雜。首先他是經過調用mall\default\login.html來調用登錄頁面,調用的程序是經過app\frontend.base.php的login方法來調用來實現的。

if (!IS_POST)程序表示登錄頁面的顯示,經過$this->display('login.html')的調用來處理。ecmall的login.html頁面主要有如下幾個變量要傳遞,user_name,password,captcha三個變量,來用用於登錄驗證。$user_name = trim($_POST['user_name'])和$password  = $_POST['password']主要是用來接受用戶名和密碼的。經過鏈接登錄中心$ms =& ms()來調用$ms->user->auth($user_name, $password)來進行登錄驗證的。

文件includes/global.lib.php中的function &ms()就是用來鏈接登錄中心的。 include(ROOT_PATH . '/includes/passports/' . MEMBER_TYPE . '.passport.php'); $class_name  = ucfirst(MEMBER_TYPE) . 'Passport';$ms = new $class_name();這裏就是來聲明登錄對象的。

相關文章
相關標籤/搜索