source: branches/feature-module-update/data/class/pages/admin/LC_Page_Admin_Login.php @ 16582

Revision 16582, 4.5 KB checked in by nanasess, 17 years ago (diff)

ライセンス表記変更

  • 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-2007 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_PATH . "pages/LC_Page.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 {
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        $conn = new SC_DBConn();
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'}) > 0) {
68            // 認証パスワードの判定
69            $ret = $this->fnCheckPassword($conn);
70        }
71
72        if($ret) {
73            // 成功
74            $this->sendRedirect($this->getLocation(URL_HOME));
75        } else {
76            // エラーページの表示
77            SC_Utils_Ex::sfDispError(LOGIN_ERROR);
78            exit;
79        }
80    }
81
82    /**
83     * デストラクタ.
84     *
85     * @return void
86     */
87    function destroy() {
88        parent::destroy();
89    }
90
91    /* 認証パスワードの判定 */
92    function fnCheckPassword($conn) {
93        $sql = "SELECT member_id, password, authority, login_date, name FROM dtb_member WHERE login_id = ? AND del_flg <> 1 AND work = 1";
94        $arrcol = array ($_POST['login_id']);
95        // DBから暗号化パスワードを取得する。
96        $data_list = $conn->getAll($sql ,$arrcol);
97        // パスワードの取得
98        $password = $data_list[0]['password'];
99        // ユーザ入力パスワードの判定
100        $ret = sha1($_POST['password'] . ":" . AUTH_MAGIC);
101
102        if ($ret == $password) {
103               // セッション登録
104            $this->fnSetLoginSession($data_list[0]['member_id'], $data_list[0]['authority'], $data_list[0]['login_date'], $data_list[0]['name']);
105            // ログイン日時の登録
106            $this->fnSetLoginDate();
107            return true;
108        }
109
110        // パスワード
111        GC_Utils_Ex::gfPrintLog($_POST['login_id'] . " password incorrect.");
112        return false;
113    }
114
115    /* 認証セッションの登録 */
116    function fnSetLoginSession($member_id,$authority,$login_date, $login_name = '') {
117
118        // 認証済みの設定
119        $this->objSess->SetSession('cert', CERT_STRING);
120        $this->objSess->SetSession('login_id', $_POST{'login_id'});
121        $this->objSess->SetSession('authority', $authority);
122        $this->objSess->SetSession('member_id', $member_id);
123        $this->objSess->SetSession('login_name', $login_name);
124        $this->objSess->SetSession('uniqid', $this->objSess->getUniqId());
125
126        if(strlen($login_date) > 0) {
127            $this->objSess->SetSession('last_login', $login_date);
128        } else {
129            $this->objSess->SetSession('last_login', date("Y-m-d H:i:s"));
130        }
131        $sid = $this->objSess->GetSID();
132        // ログに記録する
133        GC_Utils_Ex::gfPrintLog("login : user=".$_SESSION{'login_id'}." auth=".$_SESSION{'authority'}." lastlogin=". $_SESSION{'last_login'} ." sid=".$sid);
134    }
135
136    /* ログイン日時の更新 */
137    function fnSetLoginDate() {
138        $oquery = new SC_Query();
139        $sqlval['login_date'] = date("Y-m-d H:i:s");
140        $member_id = $this->objSess->GetSession('member_id');
141        $where = "member_id = " . $member_id;
142        $ret = $oquery->update("dtb_member", $sqlval, $where);
143    }
144}
145?>
Note: See TracBrowser for help on using the repository browser.