source: branches/version-2_5-dev/data/class/pages/admin/LC_Page_Admin_Login.php @ 19803

Revision 19803, 4.8 KB checked in by Seasoft, 13 years ago (diff)

#834(パラメータの定数名に「URL」を含むにもかかわらず、パスのみのものがある)

  • 一斉置換前の現状記録のためのコミット

#628(未使用処理・定義などの削除)

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Revision Date
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
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
25require_once(CLASS_FILE_PATH . "pages/admin/LC_Page_Admin.php");
26
27/**
28 * 管理者ログイン のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Login extends LC_Page_Admin {
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        $this->action();
60        $this->sendResponse();
61    }
62
63    /**
64     * Page のアクション.
65     *
66     * @return void
67     */
68    function action() {
69        $objQuery = new SC_Query();
70        $this->objSess = new SC_Session();
71        $ret = false;
72
73        if (!isset($_POST['login_id'])) $_POST['login_id'] = "";
74        if (!isset($_POST['password'])) $_POST['password'] = "";
75
76        // 入力判定
77        if(strlen($_POST{'login_id'}) > 0 && strlen($_POST{'password'}) >= ID_MIN_LEN && strlen($_POST{'password'}) <= ID_MAX_LEN) {
78            // 認証パスワードの判定
79            $ret = $this->fnCheckPassword($objQuery);
80        }
81
82        if($ret) {
83            // 成功
84            $this->objDisplay->redirect($this->getLocation(URL_HOME));
85            exit;
86        } else {
87            // エラーページの表示
88            SC_Utils_Ex::sfDispError(LOGIN_ERROR);
89            exit;
90        }
91    }
92
93    /**
94     * デストラクタ.
95     *
96     * @return void
97     */
98    function destroy() {
99        parent::destroy();
100    }
101
102    /* 認証パスワードの判定 */
103    function fnCheckPassword(&$objQuery) {
104        $sql = "SELECT member_id, password, authority, login_date, name FROM dtb_member WHERE login_id = ? AND del_flg <> 1 AND work = 1";
105        $arrcol = array ($_POST['login_id']);
106        // DBから暗号化パスワードを取得する。
107        $data_list = $objQuery->getAll($sql ,$arrcol);
108        // パスワードの取得
109        $password = $data_list[0]['password'];
110        // ユーザ入力パスワードの判定
111        $ret = sha1($_POST['password'] . ":" . AUTH_MAGIC);
112
113        if ($ret == $password) {
114               // セッション登録
115            $this->fnSetLoginSession($data_list[0]['member_id'], $data_list[0]['authority'], $data_list[0]['login_date'], $data_list[0]['name']);
116            // ログイン日時の登録
117            $this->fnSetLoginDate();
118            return true;
119        }
120
121        // パスワード
122        GC_Utils_Ex::gfPrintLog($_POST['login_id'] . " password incorrect.");
123        return false;
124    }
125
126    /* 認証セッションの登録 */
127    function fnSetLoginSession($member_id,$authority,$login_date, $login_name = '') {
128
129        // 認証済みの設定
130        $this->objSess->SetSession('cert', CERT_STRING);
131        $this->objSess->SetSession('login_id', $_POST{'login_id'});
132        $this->objSess->SetSession('authority', $authority);
133        $this->objSess->SetSession('member_id', $member_id);
134        $this->objSess->SetSession('login_name', $login_name);
135        $this->objSess->SetSession('uniqid', $this->objSess->getUniqId());
136
137        if(strlen($login_date) > 0) {
138            $this->objSess->SetSession('last_login', $login_date);
139        } else {
140            $this->objSess->SetSession('last_login', date("Y-m-d H:i:s"));
141        }
142        $sid = $this->objSess->GetSID();
143        // ログに記録する
144        GC_Utils_Ex::gfPrintLog("login : user=".$_SESSION{'login_id'}." auth=".$_SESSION{'authority'}." lastlogin=". $_SESSION{'last_login'} ." sid=".$sid);
145    }
146
147    /* ログイン日時の更新 */
148    function fnSetLoginDate() {
149        $objQuery = new SC_Query();
150        $sqlval['login_date'] = date("Y-m-d H:i:s");
151        $member_id = $this->objSess->GetSession('member_id');
152        $where = "member_id = " . $member_id;
153        $ret = $objQuery->update("dtb_member", $sqlval, $where);
154    }
155}
156?>
Note: See TracBrowser for help on using the repository browser.