1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
6 | * |
---|
7 | * http://www.lockon.co.jp/ |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License |
---|
11 | * as published by the Free Software Foundation; either version 2 |
---|
12 | * of the License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | // {{{ requires |
---|
25 | require_once(CLASS_PATH . "pages/LC_Page.php"); |
---|
26 | |
---|
27 | /** |
---|
28 | * 管理者ログイン のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class LC_Page_Admin_Login extends LC_Page { |
---|
35 | |
---|
36 | // {{{ properties |
---|
37 | |
---|
38 | /** SC_Session インスタンス */ |
---|
39 | var $objSess; |
---|
40 | |
---|
41 | // }}} |
---|
42 | // {{{ functions |
---|
43 | |
---|
44 | /** |
---|
45 | * Page を初期化する. |
---|
46 | * |
---|
47 | * @return void |
---|
48 | */ |
---|
49 | function init() { |
---|
50 | parent::init(); |
---|
51 | } |
---|
52 | |
---|
53 | /** |
---|
54 | * Page のプロセス. |
---|
55 | * |
---|
56 | * @return void |
---|
57 | */ |
---|
58 | function process() { |
---|
59 | $objQuery = new SC_Query(); |
---|
60 | $this->objSess = new SC_Session(); |
---|
61 | $ret = false; |
---|
62 | |
---|
63 | if (!isset($_POST['login_id'])) $_POST['login_id'] = ""; |
---|
64 | if (!isset($_POST['password'])) $_POST['password'] = ""; |
---|
65 | |
---|
66 | // 入力判定 |
---|
67 | if(strlen($_POST{'login_id'}) > 0 && strlen($_POST{'password'}) >= ID_MIN_LEN && strlen($_POST{'password'}) <= ID_MAX_LEN) { |
---|
68 | // 認証パスワードの判定 |
---|
69 | $ret = $this->fnCheckPassword($objQuery); |
---|
70 | } |
---|
71 | |
---|
72 | if($ret) { |
---|
73 | // 成功 |
---|
74 | $this->sendRedirect($this->getLocation(URL_HOME)); |
---|
75 | exit; |
---|
76 | } else { |
---|
77 | // エラーページの表示 |
---|
78 | SC_Utils_Ex::sfDispError(LOGIN_ERROR); |
---|
79 | exit; |
---|
80 | } |
---|
81 | } |
---|
82 | |
---|
83 | /** |
---|
84 | * デストラクタ. |
---|
85 | * |
---|
86 | * @return void |
---|
87 | */ |
---|
88 | function destroy() { |
---|
89 | parent::destroy(); |
---|
90 | } |
---|
91 | |
---|
92 | /* 認証パスワードの判定 */ |
---|
93 | function fnCheckPassword(&$objQuery) { |
---|
94 | $sql = "SELECT member_id, password, authority, login_date, name FROM dtb_member WHERE login_id = ? AND del_flg <> 1 AND work = 1"; |
---|
95 | $arrcol = array ($_POST['login_id']); |
---|
96 | // DBから暗号化パスワードを取得する。 |
---|
97 | $data_list = $objQuery->getAll($sql ,$arrcol); |
---|
98 | // パスワードの取得 |
---|
99 | $password = $data_list[0]['password']; |
---|
100 | // ユーザ入力パスワードの判定 |
---|
101 | $ret = sha1($_POST['password'] . ":" . AUTH_MAGIC); |
---|
102 | |
---|
103 | if ($ret == $password) { |
---|
104 | // セッション登録 |
---|
105 | $this->fnSetLoginSession($data_list[0]['member_id'], $data_list[0]['authority'], $data_list[0]['login_date'], $data_list[0]['name']); |
---|
106 | // ログイン日時の登録 |
---|
107 | $this->fnSetLoginDate(); |
---|
108 | return true; |
---|
109 | } |
---|
110 | |
---|
111 | // パスワード |
---|
112 | GC_Utils_Ex::gfPrintLog($_POST['login_id'] . " password incorrect."); |
---|
113 | return false; |
---|
114 | } |
---|
115 | |
---|
116 | /* 認証セッションの登録 */ |
---|
117 | function fnSetLoginSession($member_id,$authority,$login_date, $login_name = '') { |
---|
118 | |
---|
119 | // 認証済みの設定 |
---|
120 | $this->objSess->SetSession('cert', CERT_STRING); |
---|
121 | $this->objSess->SetSession('login_id', $_POST{'login_id'}); |
---|
122 | $this->objSess->SetSession('authority', $authority); |
---|
123 | $this->objSess->SetSession('member_id', $member_id); |
---|
124 | $this->objSess->SetSession('login_name', $login_name); |
---|
125 | $this->objSess->SetSession('uniqid', $this->objSess->getUniqId()); |
---|
126 | |
---|
127 | if(strlen($login_date) > 0) { |
---|
128 | $this->objSess->SetSession('last_login', $login_date); |
---|
129 | } else { |
---|
130 | $this->objSess->SetSession('last_login', date("Y-m-d H:i:s")); |
---|
131 | } |
---|
132 | $sid = $this->objSess->GetSID(); |
---|
133 | // ログに記録する |
---|
134 | GC_Utils_Ex::gfPrintLog("login : user=".$_SESSION{'login_id'}." auth=".$_SESSION{'authority'}." lastlogin=". $_SESSION{'last_login'} ." sid=".$sid); |
---|
135 | } |
---|
136 | |
---|
137 | /* ログイン日時の更新 */ |
---|
138 | function fnSetLoginDate() { |
---|
139 | $oquery = new SC_Query(); |
---|
140 | $sqlval['login_date'] = date("Y-m-d H:i:s"); |
---|
141 | $member_id = $this->objSess->GetSession('member_id'); |
---|
142 | $where = "member_id = " . $member_id; |
---|
143 | $ret = $oquery->update("dtb_member", $sqlval, $where); |
---|
144 | } |
---|
145 | } |
---|
146 | ?> |
---|