1 | <?php |
---|
2 | /** |
---|
3 | * @copyright 2005-2008 OpenPNE Project |
---|
4 | * @license http://www.php.net/license/3_01.txt PHP License 3.01 |
---|
5 | */ |
---|
6 | |
---|
7 | if (empty($_REQUEST['ksid'])) { |
---|
8 | __logout(); |
---|
9 | } |
---|
10 | |
---|
11 | session_name('OpenPNEktai'); |
---|
12 | require_once 'OpenPNE/Auth.php'; |
---|
13 | |
---|
14 | $config = get_auth_config(true); |
---|
15 | $auth = new OpenPNE_Auth($config); |
---|
16 | $auth->setExpire($GLOBALS['OpenPNE']['ktai']['session_lifetime']); |
---|
17 | $auth->setIdle($GLOBALS['OpenPNE']['ktai']['session_idletime']); |
---|
18 | |
---|
19 | if ( !$auth->auth() |
---|
20 | || !($u = db_member_c_member_id4username_encrypted($auth->getUsername(), true)) |
---|
21 | || db_member_is_login_rejected($u)) { |
---|
22 | $auth->logout(); |
---|
23 | |
---|
24 | __logout(); |
---|
25 | } |
---|
26 | |
---|
27 | if (db_member_is_blacklist($u)) { |
---|
28 | ktai_display_error('ログインできませんでした。'); |
---|
29 | } |
---|
30 | |
---|
31 | $auth->uid($u); |
---|
32 | $GLOBALS['AUTH'] = $auth; |
---|
33 | |
---|
34 | $GLOBALS['KTAI_C_MEMBER_ID'] = $auth->uid(); |
---|
35 | $GLOBALS['KTAI_URL_TAIL'] = "ksid=" . session_id(); |
---|
36 | |
---|
37 | // ログインモードが email でない場合、ログインに必要な情報が入力されているかどうかをチェックする |
---|
38 | if (OPENPNE_AUTH_MODE != 'email' && empty($_SESSION['regist_step'])) { |
---|
39 | $current_page = $GLOBALS['__Framework']['current_type'] . '_' . $GLOBALS['__Framework']['current_action']; |
---|
40 | |
---|
41 | // プロフィールが未登録の場合でもアクセスすることのできるアクション |
---|
42 | $prof_ext_page = array( |
---|
43 | 'page_h_regist_pre', |
---|
44 | 'do_h_regist_prof', |
---|
45 | 'page_h_regist_prof', |
---|
46 | ); |
---|
47 | |
---|
48 | // メールアドレスが未登録の場合でもアクセスすることのできるアクション |
---|
49 | $mail_ext_page = array( |
---|
50 | 'do_h_regist_address', |
---|
51 | 'page_h_regist_address', |
---|
52 | ); |
---|
53 | |
---|
54 | $is_registered_profile = db_member_is_registered_nickname_birth_day($u); |
---|
55 | $is_registered_profile_action = in_array($current_page, $prof_ext_page); |
---|
56 | |
---|
57 | $is_registered_address = db_member_is_ktai_address_registered($u); |
---|
58 | $is_registered_address_action = in_array($current_page, $mail_ext_page); |
---|
59 | |
---|
60 | if ($is_registered_profile && $is_registered_address) { |
---|
61 | $_SESSION['regist_step'] = true; |
---|
62 | } elseif ($is_registered_address && OPENPNE_AUTH_MODE == 'pneid') { |
---|
63 | $_SESSION['regist_step'] = true; |
---|
64 | } else { |
---|
65 | $_SESSION['regist_step'] = false; |
---|
66 | } |
---|
67 | |
---|
68 | // プロフィールが未登録 |
---|
69 | if (!$is_registered_profile && !$is_registered_profile_action && OPENPNE_AUTH_MODE == 'slavepne') { |
---|
70 | openpne_redirect('ktai', 'page_h_regist_pre'); |
---|
71 | } |
---|
72 | |
---|
73 | // メールアドレスが未登録 |
---|
74 | if (!$is_registered_address && !$is_registered_address_action) { |
---|
75 | openpne_redirect('ktai', 'page_h_regist_address'); |
---|
76 | } |
---|
77 | |
---|
78 | $_SESSION['regist_step'] = false; |
---|
79 | } |
---|
80 | |
---|
81 | function __logout($msg = 0, $c_member_id = 0) |
---|
82 | { |
---|
83 | @session_destroy(); |
---|
84 | |
---|
85 | if ($msg) { |
---|
86 | $_REQUEST['msg'] = $msg; |
---|
87 | } |
---|
88 | if ($c_member_id) { |
---|
89 | $_REQUEST['kad'] = t_encrypt(db_member_username4c_member_id($c_member_id, true)); |
---|
90 | } |
---|
91 | $_REQUEST['login_params'] = $_SERVER['QUERY_STRING']; |
---|
92 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
---|
93 | $_POST = array('login_params' => $_SERVER['QUERY_STRING']); |
---|
94 | } else { |
---|
95 | $_GET = array('login_params' => $_SERVER['QUERY_STRING']); |
---|
96 | } |
---|
97 | if (LOGIN_URL_KTAI) { |
---|
98 | client_redirect_absolute(LOGIN_URL_KTAI); |
---|
99 | } else { |
---|
100 | openpne_forward('ktai', 'page', 'o_login'); |
---|
101 | } |
---|
102 | exit; |
---|
103 | } |
---|
104 | |
---|
105 | ?> |
---|