1 | <?php |
---|
2 | /** |
---|
3 | * @copyright 2005-2007 OpenPNE Project |
---|
4 | * @license http://www.php.net/license/3_01.txt PHP License 3.01 |
---|
5 | */ |
---|
6 | |
---|
7 | class pc_do_o_login extends OpenPNE_Action |
---|
8 | { |
---|
9 | var $_auth; |
---|
10 | var $_lc; |
---|
11 | var $_login_params; |
---|
12 | |
---|
13 | function isSecure() |
---|
14 | { |
---|
15 | return false; |
---|
16 | } |
---|
17 | |
---|
18 | function execute($requests) |
---|
19 | { |
---|
20 | $this->_login_params = $requests['login_params']; |
---|
21 | $auth_config = get_auth_config(); |
---|
22 | $auth = new OpenPNE_Auth($auth_config['storage'], $auth_config['options']); |
---|
23 | $this->_auth =& $auth; |
---|
24 | $auth->setExpire($GLOBALS['OpenPNE']['common']['session_lifetime']); |
---|
25 | $auth->setIdle($GLOBALS['OpenPNE']['common']['session_idletime']); |
---|
26 | |
---|
27 | // 現在のセッションを削除 |
---|
28 | $auth->logout(); |
---|
29 | |
---|
30 | if (LOGIN_CHECK_ENABLE) { |
---|
31 | include_once 'OpenPNE/LoginChecker.php'; |
---|
32 | $options = array( |
---|
33 | 'check_num' => LOGIN_CHECK_NUM, |
---|
34 | 'check_time' => LOGIN_CHECK_TIME, |
---|
35 | 'reject_time' => LOGIN_REJECT_TIME, |
---|
36 | ); |
---|
37 | $this->_lc =& new OpenPNE_LoginChecker($options); |
---|
38 | } |
---|
39 | |
---|
40 | if (!$auth->login($requests['is_save'], true)) { |
---|
41 | $this->_fail_login(); |
---|
42 | } |
---|
43 | |
---|
44 | if (LOGIN_CHECK_ENABLE && $this->_lc->is_rejected()) { |
---|
45 | $this->_fail_login(); |
---|
46 | } |
---|
47 | |
---|
48 | $c_member_id = db_member_c_member_id4username_encrypted($auth->getUsername(), false); |
---|
49 | if (!$c_member_id) { |
---|
50 | if (IS_SLAVEPNE) { |
---|
51 | db_member_create_member($_POST['username']); |
---|
52 | } else { |
---|
53 | $this->_fail_login(); |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | db_api_update_token($c_member_id); |
---|
58 | |
---|
59 | $url = OPENPNE_URL; |
---|
60 | if ($this->_login_params) { |
---|
61 | $url .= '?' . $this->_login_params; |
---|
62 | } |
---|
63 | client_redirect_absolute($url); |
---|
64 | } |
---|
65 | |
---|
66 | function _fail_login() |
---|
67 | { |
---|
68 | if (LOGIN_CHECK_ENABLE) { |
---|
69 | $this->_lc->fail_login(); |
---|
70 | } |
---|
71 | $this->_auth->logout(); |
---|
72 | $p = array('msg_code' => 'login_failed', 'login_params' => $this->_login_params); |
---|
73 | openpne_redirect('pc', 'page_o_tologin', $p); |
---|
74 | } |
---|
75 | } |
---|
76 | |
---|
77 | ?> |
---|