$nv_password = $password; $error = ""; require_once NV_ROOTDIR . '/' . DIR_FORUM . '/nukeviet/login.php'; if (!empty($error)) { opidr(array('status' => 'error', 'mess' => $lang_module['openid_confirm_failed'])); die; } } elseif (!$crypt->validate_password($password, $nv_row['password']) or !$check_seccode) { opidr(array('status' => 'error', 'mess' => $lang_module['openid_confirm_failed'])); die; } } else { $page_title = $lang_module['openid_login']; $key_words = $module_info['keywords']; $mod_title = $lang_module['openid_login']; $contents = openid_account_confirm($gfx_chk, $attribs); include NV_ROOTDIR . '/includes/header.php'; echo nv_site_theme($contents, false); include NV_ROOTDIR . '/includes/footer.php'; exit; } } $stmt = $db->prepare('INSERT INTO ' . NV_USERS_GLOBALTABLE . '_openid VALUES (' . (int) $nv_row['userid'] . ', :server, :opid, :email )'); $stmt->bindParam(':server', $attribs['server'], PDO::PARAM_STR); $stmt->bindParam(':opid', $opid, PDO::PARAM_STR); $stmt->bindParam(':email', $email, PDO::PARAM_STR); $stmt->execute(); validUserLog($nv_row, 1, $opid, $current_mode); opidr(array('status' => 'success', 'mess' => $lang_module['login_ok'])); die; }
/** * openidLogin_Res1() * Function thuc hien khi OpenID duoc nhan dien * * @param mixed $attribs * @return */ function openidLogin_Res1($attribs) { global $page_title, $key_words, $mod_title, $db, $crypt, $nv_Request, $lang_module, $lang_global, $module_name, $module_info, $global_config, $gfx_chk, $nv_redirect, $op, $db_config; $email = (isset($attribs['contact/email']) and nv_check_valid_email($attribs['contact/email']) == '') ? $attribs['contact/email'] : ''; if (empty($email)) { $nv_Request->unset_request('openid_attribs', 'session'); openidLogin_Res0($lang_module['logged_in_failed']); die; } $opid = $crypt->hash($attribs['id']); $current_mode = isset($attribs['current_mode']) ? $attribs['current_mode'] : 1; $stmt = $db->prepare('SELECT a.userid AS uid, a.email AS uemail, b.active AS uactive FROM ' . NV_USERS_GLOBALTABLE . '_openid a, ' . NV_USERS_GLOBALTABLE . ' b WHERE a.opid= :opid AND a.email= :email AND a.userid=b.userid'); $stmt->bindParam(':opid', $opid, PDO::PARAM_STR); $stmt->bindParam(':email', $email, PDO::PARAM_STR); $stmt->execute(); list($user_id, $op_email, $user_active) = $stmt->fetch(3); if ($user_id) { $nv_Request->unset_request('openid_attribs', 'session'); if ($op_email != $email) { openidLogin_Res0($lang_module['not_logged_in']); die; } if (!$user_active) { openidLogin_Res0($lang_module['login_no_active']); die; } if (defined('NV_IS_USER_FORUM') and file_exists(NV_ROOTDIR . '/' . DIR_FORUM . '/nukeviet/set_user_login.php')) { require_once NV_ROOTDIR . '/' . DIR_FORUM . '/nukeviet/set_user_login.php'; if (defined('NV_IS_USER_LOGIN_FORUM_OK')) { $nv_redirect = !empty($nv_redirect) ? nv_base64_decode($nv_redirect) : NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name; } else { $nv_redirect = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name; } } else { $query = 'SELECT * FROM ' . NV_USERS_GLOBALTABLE . ' WHERE userid=' . $user_id; $row = $db->query($query)->fetch(); if (!empty($row)) { validUserLog($row, 1, $opid, $current_mode); $nv_redirect = !empty($nv_redirect) ? nv_base64_decode($nv_redirect) : NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name; } else { $nv_redirect = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name; } } Header('Location: ' . nv_url_rewrite($nv_redirect, true)); die; } $stmt = $db->prepare('SELECT * FROM ' . NV_USERS_GLOBALTABLE . ' WHERE email= :email'); $stmt->bindParam(':email', $email, PDO::PARAM_STR); $stmt->execute(); $nv_row = $stmt->fetch(); if (!empty($nv_row)) { $login_allowed = false; if (empty($nv_row['password'])) { $nv_Request->unset_request('openid_attribs', 'session'); $login_allowed = true; } if ($nv_Request->isset_request('openid_account_confirm', 'post')) { $password = $nv_Request->get_string('password', 'post', ''); $nv_seccode = $nv_Request->get_title('nv_seccode', 'post', ''); $nv_seccode = !$gfx_chk ? 1 : (nv_capcha_txt($nv_seccode) ? 1 : 0); $nv_Request->unset_request('openid_attribs', 'session'); if (defined('NV_IS_USER_FORUM') and file_exists(NV_ROOTDIR . '/' . DIR_FORUM . '/nukeviet/login.php')) { $nv_username = $nv_row['username']; $nv_password = $password; require_once NV_ROOTDIR . '/' . DIR_FORUM . '/nukeviet/login.php'; if (empty($error)) { $login_allowed = true; } else { openidLogin_Res0($lang_module['openid_confirm_failed']); die; } } else { if ($crypt->validate_password($password, $nv_row['password']) and $nv_seccode) { $login_allowed = true; } else { openidLogin_Res0($lang_module['openid_confirm_failed']); die; } } } if ($login_allowed) { $stmt = $db->prepare('INSERT INTO ' . NV_USERS_GLOBALTABLE . '_openid VALUES (' . intval($nv_row['userid']) . ', :server, :opid, :email )'); $stmt->bindParam(':server', $attribs['server'], PDO::PARAM_STR); $stmt->bindParam(':opid', $opid, PDO::PARAM_STR); $stmt->bindParam(':email', $email, PDO::PARAM_STR); $stmt->execute(); if (intval($nv_row['active']) != 1) { openidLogin_Res0($lang_module['login_no_active']); } else { validUserLog($nv_row, 1, $opid, $current_mode); Header('Location: ' . nv_url_rewrite(NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name, true)); } die; } $page_title = $lang_module['openid_login']; $key_words = $module_info['keywords']; $mod_title = $lang_module['openid_login']; $lang_module['login_info'] = sprintf($lang_module['openid_confirm_info'], $email); $contents = openid_account_confirm($gfx_chk, $attribs); include NV_ROOTDIR . '/includes/header.php'; echo nv_site_theme($contents); include NV_ROOTDIR . '/includes/footer.php'; exit; } if ($global_config['allowuserreg'] == 2 or $global_config['allowuserreg'] == 3) { $query = 'SELECT * FROM ' . NV_USERS_GLOBALTABLE . '_reg WHERE email= :email'; if ($global_config['allowuserreg'] == 2) { $query .= ' AND regdate>' . (NV_CURRENTTIME - 86400); } $stmt = $db->prepare($query); $stmt->bindParam(':email', $email, PDO::PARAM_STR); $stmt->execute(); $row = $stmt->fetch(); if (!empty($row)) { if ($global_config['allowuserreg'] == 2) { if ($nv_Request->isset_request('openid_active_confirm', 'post')) { $nv_Request->unset_request('openid_attribs', 'session'); $password = $nv_Request->get_string('password', 'post', ''); $nv_seccode = $nv_Request->get_title('nv_seccode', 'post', ''); $nv_seccode = !$gfx_chk ? 1 : (nv_capcha_txt($nv_seccode) ? 1 : 0); if ($crypt->validate_password($password, $row['password']) and $nv_seccode) { $reg_attribs = set_reg_attribs($attribs); $sql = "INSERT INTO " . NV_USERS_GLOBALTABLE . " (\n\t\t\t\t\t\t\tusername, md5username, password, email, first_name, last_name, gender, photo, birthday, regdate,\n\t\t\t\t\t\t\tquestion, answer, passlostkey, view_mail, remember, in_groups,\n\t\t\t\t\t\t\tactive, checknum, last_login, last_ip, last_agent, last_openid, idsite) VALUES (\n\t\t\t\t\t\t\t:username,\n\t\t\t\t\t\t\t:md5username,\n\t\t\t\t\t\t\t:password,\n\t\t\t\t\t\t\t:email,\n\t\t\t\t\t\t\t:first_name,\n\t\t\t\t\t\t\t:last_name,\n\t\t\t\t\t\t\t:gender,\n\t\t\t\t\t\t\t'', 0,\n\t\t\t\t\t\t\t:regdate,\n\t\t\t\t\t\t\t:question,\n\t\t\t\t\t\t\t:answer,\n\t\t\t\t\t\t\t'', 1, 1, '', 1, '', 0, '', '', '', " . $global_config['idsite'] . ")"; $data_insert = array(); $data_insert['username'] = $row['username']; $data_insert['md5username'] = nv_md5safe($row['username']); $data_insert['password'] = $row['password']; $data_insert['email'] = $row['email']; $data_insert['first_name'] = $row['first_name']; $data_insert['last_name'] = $row['last_name']; $data_insert['gender'] = $reg_attribs['gender']; $data_insert['regdate'] = $row['regdate']; $data_insert['question'] = $row['question']; $data_insert['answer'] = $row['answer']; $userid = $db->insert_id($sql, 'userid', $data_insert); if (!$userid) { openidLogin_Res0($lang_module['account_active_error']); die; } $db->query('UPDATE ' . NV_GROUPS_GLOBALTABLE . ' SET numbers = numbers+1 WHERE group_id=4'); $stmt = $db->prepare('DELETE FROM ' . NV_USERS_GLOBALTABLE . '_reg WHERE userid= :userid'); $stmt->bindParam(':userid', $row['userid'], PDO::PARAM_STR); $stmt->execute(); $stmt = $db->prepare('INSERT INTO ' . NV_USERS_GLOBALTABLE . '_openid VALUES (' . $userid . ', :server, :opid, :email )'); $stmt->bindParam(':server', $attribs['server'], PDO::PARAM_STR); $stmt->bindParam(':opid', $opid, PDO::PARAM_STR); $stmt->bindParam(':email', $email, PDO::PARAM_STR); $stmt->execute(); $query = 'SELECT * FROM ' . NV_USERS_GLOBALTABLE . ' WHERE userid=' . $userid; $result = $db->query($query); $row = $result->fetch(); validUserLog($row, 1, $opid, $current_mode); $info = $lang_module['account_active_ok'] . "<br /><br />\n"; $info .= "<img border=\"0\" src=\"" . NV_BASE_SITEURL . "images/load_bar.gif\"><br /><br />\n"; $info .= '[<a href="' . NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '">' . $lang_module['redirect_to_home'] . '</a>]'; $contents = user_info_exit($info); $contents .= '<meta http-equiv="refresh" content="2;url=' . nv_url_rewrite(NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name, true) . '" />'; include NV_ROOTDIR . '/includes/header.php'; echo nv_site_theme($contents); include NV_ROOTDIR . '/includes/footer.php'; exit; } else { openidLogin_Res0($lang_module['openid_confirm_failed']); die; } } $page_title = $mod_title = $lang_module['openid_activate_account']; $key_words = $module_info['keywords']; $lang_module['login_info'] = sprintf($lang_module['openid_active_confirm_info'], $email); $contents = openid_active_confirm($gfx_chk, $attribs); include NV_ROOTDIR . '/includes/header.php'; echo nv_site_theme($contents); include NV_ROOTDIR . '/includes/footer.php'; exit; } else { $nv_Request->unset_request('openid_attribs', 'session'); openidLogin_Res0($lang_module['account_register_to_admin']); die; } } } $option = $nv_Request->get_int('option', 'get', 0); if (!$global_config['allowuserreg']) { $option = 3; } $contents = ''; $page_title = $lang_module['openid_login']; if ($option == 3) { $error = ''; if ($nv_Request->isset_request('nv_login', 'post')) { $nv_username = $nv_Request->get_title('nv_login', 'post', '', 1); $nv_password = $nv_Request->get_title('nv_password', 'post', ''); $nv_seccode = $nv_Request->get_title('nv_seccode', 'post', ''); $check_seccode = !$gfx_chk ? true : (nv_capcha_txt($nv_seccode) ? true : false); if (!$check_seccode) { $error = $lang_global['securitycodeincorrect']; } elseif (empty($nv_username)) { $error = $lang_global['username_empty']; } elseif (empty($nv_password)) { $error = $lang_global['password_empty']; } else { if (defined('NV_IS_USER_FORUM')) { require_once NV_ROOTDIR . '/' . DIR_FORUM . '/nukeviet/login.php'; } else { $error = $lang_global['loginincorrect']; $sql = "SELECT * FROM " . NV_USERS_GLOBALTABLE . " WHERE md5username ='******'"; $row = $db->query($sql)->fetch(); if (!empty($row)) { if ($row['username'] == $nv_username and $crypt->validate($nv_password, $row['password'])) { if (!$row['active']) { $error = $lang_module['login_no_active']; } else { $error = ''; $stmt = $db->prepare('INSERT INTO ' . NV_USERS_GLOBALTABLE . '_openid VALUES (' . intval($row['userid']) . ', :server, :opid, :email )'); $stmt->bindParam(':server', $attribs['server'], PDO::PARAM_STR); $stmt->bindParam(':opid', $opid, PDO::PARAM_STR); $stmt->bindParam(':email', $email, PDO::PARAM_STR); $stmt->execute(); validUserLog($row, 1, $opid); } } } } } if (empty($error)) { $nv_Request->unset_request('openid_attribs', 'session'); $nv_redirect = !empty($nv_redirect) ? nv_base64_decode($nv_redirect) : NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name; $info = $lang_module['login_ok'] . "<br /><br />\n"; $info .= "<img border=\"0\" src=\"" . NV_BASE_SITEURL . "images/load_bar.gif\"><br /><br />\n"; $info .= '[<a href="' . $nv_redirect . '">' . $lang_module['redirect_to_back'] . '</a>]'; $contents .= user_info_exit($info); $contents .= '<meta http-equiv="refresh" content="2;url=' . nv_url_rewrite($nv_redirect, true) . '" />'; include NV_ROOTDIR . '/includes/header.php'; echo nv_site_theme($contents); include NV_ROOTDIR . '/includes/footer.php'; exit; } $array_login = array('nv_login' => $nv_username, 'nv_password' => $nv_password, 'nv_redirect' => $nv_redirect, 'login_info' => '<span style="color:#fb490b;">' . $error . '</span>'); } else { $array_login = array('nv_login' => '', 'nv_password' => '', 'login_info' => $lang_module['openid_note1'], 'nv_redirect' => $nv_redirect); } $contents .= user_openid_login($gfx_chk, $array_login, $attribs); include NV_ROOTDIR . '/includes/header.php'; echo nv_site_theme($contents); include NV_ROOTDIR . '/includes/footer.php'; exit; } elseif ($option == 1 or $option == 2) { $nv_Request->unset_request('openid_attribs', 'session'); $reg_attribs = set_reg_attribs($attribs); if (empty($reg_attribs['username'])) { openidLogin_Res0($lang_module['logged_in_failed']); die; } if ($option == 2) { // Dang nhap bang mot tai khoan do he thong tao tu dong $sql = "INSERT INTO " . NV_USERS_GLOBALTABLE . "\n\t\t\t\t(username, md5username, password, email, first_name, last_name, gender, photo, birthday, regdate,\n\t\t\t\tquestion, answer, passlostkey, view_mail, remember, in_groups,\n\t\t\t\tactive, checknum, last_login, last_ip, last_agent, last_openid, idsite) VALUES (\n\t\t\t\t:username,\n\t\t\t\t:md5username,\n\t\t\t\t'',\n\t\t\t\t:email,\n\t\t\t\t:first_name,\n\t\t\t\t:last_name,\n\t\t\t\t:gender,\n\t\t\t\t'', 0,\n\t\t\t\t" . NV_CURRENTTIME . ",\n\t\t\t\t'', '', '', 0, 0, '', 1, '', 0, '', '', '', " . intval($global_config['idsite']) . "\n\t\t\t)"; $data_insert = array(); $data_insert['username'] = $reg_attribs['username']; $data_insert['md5username'] = nv_md5safe($reg_attribs['username']); $data_insert['email'] = $reg_attribs['email']; $data_insert['first_name'] = $reg_attribs['first_name']; $data_insert['last_name'] = $reg_attribs['last_name']; $data_insert['gender'] = ucfirst($reg_attribs['gender'] ? $reg_attribs['gender'][0] : 'N'); $userid = $db->insert_id($sql, 'userid', $data_insert); if (!$userid) { openidLogin_Res0($lang_module['err_no_save_account']); die; } // Cap nhat so thanh vien $db->query('UPDATE ' . NV_GROUPS_GLOBALTABLE . ' SET numbers = numbers+1 WHERE group_id=4'); $query = 'SELECT * FROM ' . NV_USERS_GLOBALTABLE . ' WHERE userid=' . $userid . ' AND active=1'; $result = $db->query($query); $row = $result->fetch(); $result->closeCursor(); // Luu vao bang thong tin tuy chinh $query_field = array(); $query_field['userid'] = $userid; $result_field = $db->query('SELECT * FROM ' . NV_USERS_GLOBALTABLE . '_field ORDER BY fid ASC'); while ($row_f = $result_field->fetch()) { $query_field[$row_f['field']] = $db->quote($row_f['default_value']); } $db->query('INSERT INTO ' . NV_USERS_GLOBALTABLE . '_info (' . implode(', ', array_keys($query_field)) . ') VALUES (' . implode(', ', array_values($query_field)) . ')'); // Luu vao bang OpenID $stmt = $db->prepare('INSERT INTO ' . NV_USERS_GLOBALTABLE . '_openid VALUES (' . intval($row['userid']) . ', :server, :opid , :email)'); $stmt->bindParam(':server', $reg_attribs['server'], PDO::PARAM_STR); $stmt->bindParam(':opid', $reg_attribs['opid'], PDO::PARAM_STR); $stmt->bindParam(':email', $reg_attribs['email'], PDO::PARAM_STR); $stmt->execute(); validUserLog($row, 1, $reg_attribs['opid'], $current_mode); $nv_redirect = !empty($nv_redirect) ? nv_base64_decode($nv_redirect) : NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name; Header('Location: ' . nv_url_rewrite($nv_redirect, true)); exit; } else { $reg_attribs = serialize($reg_attribs); $nv_Request->set_Session('reg_attribs', $reg_attribs); Header('Location: ' . nv_url_rewrite(NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=register&openid=1&nv_redirect=' . $nv_redirect, true)); exit; } } $array_user_login = array(); if (!defined('NV_IS_USER_FORUM')) { $array_user_login[] = array('title' => $lang_module['openid_note3'], 'link' => NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=login&server=' . $attribs['server'] . '&result=1&option=1&nv_redirect=' . $nv_redirect); $array_user_login[] = array('title' => $lang_module['openid_note4'], 'link' => NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=login&server=' . $attribs['server'] . '&result=1&option=2&nv_redirect=' . $nv_redirect); } else { $array_user_login[] = array('title' => $lang_module['openid_note6'], 'link' => NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=register&nv_redirect=' . $nv_redirect); } $array_user_login[] = array('title' => $lang_module['openid_note5'], 'link' => NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=login&server=' . $attribs['server'] . '&result=1&option=3&nv_redirect=' . $nv_redirect); $page_title = $lang_module['openid_login']; $key_words = $module_info['keywords']; $mod_title = $lang_module['openid_login']; $contents .= user_openid_login2($attribs, $array_user_login); include NV_ROOTDIR . '/includes/header.php'; echo nv_site_theme($contents); include NV_ROOTDIR . '/includes/footer.php'; exit; }
/** * openidLogin_Res1() * Function thuc hien khi OpenID duoc nhan dien * * @param mixed $attribs * @return */ function openidLogin_Res1($attribs) { global $page_title, $key_words, $mod_title, $db, $crypt, $nv_Request, $lang_module, $lang_global, $module_name, $module_info, $global_config, $gfx_chk, $nv_redirect; $email = (isset($attribs['contact/email']) and nv_check_valid_email($attribs['contact/email']) == "") ? $attribs['contact/email'] : ""; if (empty($email)) { $nv_Request->unset_request('openid_attribs', 'session'); openidLogin_Res0($lang_module['logged_in_failed']); die; } $opid = $crypt->hash($attribs['id']); $query = "SELECT a.userid AS uid, a.email AS uemail, b.active AS uactive FROM `" . NV_USERS_GLOBALTABLE . "_openid` a, `" . NV_USERS_GLOBALTABLE . "` b \r\n WHERE a.opid=" . $db->dbescape($opid) . " \r\n AND a.email=" . $db->dbescape($email) . " \r\n AND a.userid=b.userid"; $result = $db->sql_query($query); $numrows = $db->sql_numrows($result); if ($numrows) { list($user_id, $op_email, $user_active) = $db->sql_fetchrow($result); $db->sql_freeresult($result); $nv_Request->unset_request('openid_attribs', 'session'); if ($op_email != $email) { openidLogin_Res0($lang_module['not_logged_in']); die; } if (!$user_active) { openidLogin_Res0($lang_module['login_no_active']); die; } $query = "SELECT * FROM `" . NV_USERS_GLOBALTABLE . "` WHERE `userid`=" . $db->dbescape($user_id); $result = $db->sql_query($query); $row = $db->sql_fetchrow($result); validUserLog($row, 1, $opid); $nv_redirect = !empty($nv_redirect) ? nv_base64_decode($nv_redirect) : NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name; Header("Location: " . $nv_redirect); die; } $query = "SELECT * FROM `" . NV_USERS_GLOBALTABLE . "` WHERE `email`=" . $db->dbescape($email); $result = $db->sql_query($query); $numrows = $db->sql_numrows($result); if ($numrows) { $nv_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $login_allowed = false; if (empty($nv_row['password'])) { $nv_Request->unset_request('openid_attribs', 'session'); $login_allowed = true; } if ($nv_Request->isset_request('openid_account_confirm', 'post')) { $nv_Request->unset_request('openid_attribs', 'session'); if (defined('NV_IS_USER_FORUM') and file_exists(NV_ROOTDIR . '/' . DIR_FORUM . '/nukeviet/login.php')) { $nv_username = $nv_row['username']; $nv_password = $password; require_once NV_ROOTDIR . '/' . DIR_FORUM . '/nukeviet/login.php'; if (empty($error)) { $login_allowed = true; } else { openidLogin_Res0($lang_module['openid_confirm_failed']); die; } } else { $password = $nv_Request->get_string('password', 'post', ''); $nv_seccode = filter_text_input('nv_seccode', 'post', ''); $nv_seccode = !$gfx_chk ? 1 : (nv_capcha_txt($nv_seccode) ? 1 : 0); if ($crypt->validate($password, $nv_row['password']) and $nv_seccode) { $login_allowed = true; } else { openidLogin_Res0($lang_module['openid_confirm_failed']); die; } } } if ($login_allowed) { $sql = "INSERT INTO `" . NV_USERS_GLOBALTABLE . "_openid` VALUES (" . intval($nv_row['userid']) . ", " . $db->dbescape($attribs['id']) . ", " . $db->dbescape($opid) . ", " . $db->dbescape($email) . ")"; $db->sql_query($sql); if (intval($nv_row['active']) != 1) { openidLogin_Res0($lang_module['login_no_active']); } else { validUserLog($nv_row, 1, $opid); Header("Location: " . NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name); } die; } $page_title = $lang_module['openid_login']; $key_words = $module_info['keywords']; $mod_title = $lang_module['openid_login']; $lang_module['login_info'] = sprintf($lang_module['openid_confirm_info'], $email); $contents = openid_account_confirm($gfx_chk, $attribs); include NV_ROOTDIR . "/includes/header.php"; echo nv_site_theme($contents); include NV_ROOTDIR . "/includes/footer.php"; exit; } if ($global_config['allowuserreg'] == 2 or $global_config['allowuserreg'] == 3) { $query = "SELECT * FROM `" . NV_USERS_GLOBALTABLE . "_reg` WHERE `email`=" . $db->dbescape($email); if ($global_config['allowuserreg'] == 2) { $query .= " AND `regdate`>" . (NV_CURRENTTIME - 86400); } $result = $db->sql_query($query); $numrows = $db->sql_numrows($result); if ($numrows) { if ($global_config['allowuserreg'] == 2) { $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if ($nv_Request->isset_request('openid_active_confirm', 'post')) { $nv_Request->unset_request('openid_attribs', 'session'); $password = $nv_Request->get_string('password', 'post', ''); $nv_seccode = filter_text_input('nv_seccode', 'post', ''); $nv_seccode = !$gfx_chk ? 1 : (nv_capcha_txt($nv_seccode) ? 1 : 0); if ($crypt->validate($password, $row['password']) and $nv_seccode) { $reg_attribs = set_reg_attribs($attribs); $sql = "INSERT INTO `" . NV_USERS_GLOBALTABLE . "` (\r\n `userid`, `username`, `password`, `email`, `full_name`, `gender`, `photo`, `birthday`, `regdate`, `website`, \r\n `location`, `yim`, `telephone`, `fax`, `mobile`, `question`, `answer`, `passlostkey`, `view_mail`, `remember`, `in_groups`, \r\n `active`, `checknum`, `last_login`, `last_ip`, `last_agent`, `last_openid`) VALUES (\r\n NULL, \r\n " . $db->dbescape($row['username']) . ", \r\n " . $db->dbescape($row['password']) . ", \r\n " . $db->dbescape($row['email']) . ", \r\n " . $db->dbescape(!empty($row['full_name']) ? $row['full_name'] : $reg_attribs['full_name']) . ", \r\n " . $db->dbescape($reg_attribs['gender']) . ", \r\n '', 0, \r\n " . $db->dbescape($row['regdate']) . ", \r\n '', '', \r\n " . $db->dbescape($reg_attribs['yim']) . ", \r\n '', '', '', \r\n " . $db->dbescape($row['question']) . ", \r\n " . $db->dbescape($row['answer']) . ", \r\n '', 1, 1, '', 1, '', 0, '', '', '')"; $userid = $db->sql_query_insert_id($sql); if (!$userid) { openidLogin_Res0($lang_module['account_active_error']); die; } $sql = "DELETE FROM `" . NV_USERS_GLOBALTABLE . "_reg` WHERE `userid`=" . $db->dbescape($row['userid']); $db->sql_query($sql); $sql = "INSERT INTO `" . NV_USERS_GLOBALTABLE . "_openid` VALUES (" . $userid . ", " . $db->dbescape($attribs['id']) . ", " . $db->dbescape($opid) . ", " . $db->dbescape($email) . ")"; $db->sql_query($sql); $query = "SELECT * FROM `" . NV_USERS_GLOBALTABLE . "` WHERE `userid`=" . $db->dbescape($userid); $result = $db->sql_query($query); $row = $db->sql_fetchrow($result); validUserLog($row, 1, $opid); $info = $lang_module['account_active_ok'] . "<br /><br />\n"; $info .= "<img border=\"0\" src=\"" . NV_BASE_SITEURL . "images/load_bar.gif\"><br /><br />\n"; $info .= "[<a href=\"" . NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "\">" . $lang_module['redirect_to_home'] . "</a>]"; $contents .= user_info_exit($info); $contents .= "<meta http-equiv=\"refresh\" content=\"2;url=" . NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "\" />"; include NV_ROOTDIR . "/includes/header.php"; echo nv_site_theme($contents); include NV_ROOTDIR . "/includes/footer.php"; exit; } else { openidLogin_Res0($lang_module['openid_confirm_failed']); die; } } $page_title = $mod_title = $lang_module['openid_active_title']; $key_words = $module_info['keywords']; $lang_module['login_info'] = sprintf($lang_module['openid_active_confirm_info'], $email); $contents = openid_active_confirm($gfx_chk, $attribs); include NV_ROOTDIR . "/includes/header.php"; echo nv_site_theme($contents); include NV_ROOTDIR . "/includes/footer.php"; exit; } else { $nv_Request->unset_request('openid_attribs', 'session'); openidLogin_Res0($lang_module['account_register_to_admin']); die; } } } $option = $nv_Request->get_int('option', 'get', 0); if (!$global_config['allowuserreg']) { $option = 3; } $contents = ""; if ($option == 3) { $error = ""; if ($nv_Request->isset_request('nv_login', 'post')) { $nv_username = filter_text_input('nv_login', 'post', ''); $nv_password = filter_text_input('nv_password', 'post', ''); $nv_seccode = filter_text_input('nv_seccode', 'post', ''); $check_login = nv_check_valid_login($nv_username, NV_UNICKMAX, NV_UNICKMIN); $check_pass = nv_check_valid_pass($nv_password, NV_UPASSMAX, NV_UPASSMIN); $check_seccode = !$gfx_chk ? true : (nv_capcha_txt($nv_seccode) ? true : false); if (!$check_seccode) { $error = $lang_global['securitycodeincorrect']; } elseif (!empty($check_login)) { $error = $check_login; } elseif (!empty($check_pass)) { $error = $check_pass; } else { $sql = "SELECT * FROM `" . NV_USERS_GLOBALTABLE . "` WHERE `username`=" . $db->dbescape($nv_username); $result = $db->sql_query($sql); $numrows = $db->sql_numrows($result); if ($numrows != 1) { $error = $lang_global['loginincorrect']; } else { $row = $db->sql_fetchrow($result); if (empty($row['password']) or !$crypt->validate($nv_password, $row['password'])) { $error = $lang_global['loginincorrect']; } else { if (!$row['active']) { $error = $lang_module['login_no_active']; } else { $nv_Request->unset_request('openid_attribs', 'session'); $sql = "INSERT INTO `" . NV_USERS_GLOBALTABLE . "_openid` VALUES (" . intval($row['userid']) . ", " . $db->dbescape($attribs['id']) . ", " . $db->dbescape($opid) . ", " . $db->dbescape($email) . ")"; $db->sql_query($sql); validUserLog($row, 1, $opid); } } } } if (empty($error)) { $nv_redirect = !empty($nv_redirect) ? nv_base64_decode($nv_redirect) : NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name; $info = $lang_module['login_ok'] . "<br /><br />\n"; $info .= "<img border=\"0\" src=\"" . NV_BASE_SITEURL . "images/load_bar.gif\"><br /><br />\n"; $info .= "[<a href=\"" . $nv_redirect . "\">" . $lang_module['redirect_to_back'] . "</a>]"; $contents .= user_info_exit($info); $contents .= "<meta http-equiv=\"refresh\" content=\"2;url=" . $nv_redirect . "\" />"; include NV_ROOTDIR . "/includes/header.php"; echo nv_site_theme($contents); include NV_ROOTDIR . "/includes/footer.php"; exit; } $array_login = array("nv_login" => $nv_username, "nv_password" => $nv_password, "nv_redirect" => $nv_redirect, 'login_info' => "<span style=\"color:#fb490b;\">" . $error . "</span>"); } else { $array_login = array("nv_login" => '', "nv_password" => '', 'login_info' => $lang_module['openid_note1'], "nv_redirect" => $nv_redirect); } $contents .= user_openid_login($gfx_chk, $array_login, $attribs); include NV_ROOTDIR . "/includes/header.php"; echo nv_site_theme($contents); include NV_ROOTDIR . "/includes/footer.php"; exit; } elseif ($option == 1 or $option == 2) { $nv_Request->unset_request('openid_attribs', 'session'); $reg_attribs = set_reg_attribs($attribs); if (empty($reg_attribs['username'])) { openidLogin_Res0($lang_module['logged_in_failed']); die; } if ($option == 2) { $sql = "INSERT INTO `" . NV_USERS_GLOBALTABLE . "` \r\n (`userid`, `username`, `password`, `email`, `full_name`, `gender`, `photo`, `birthday`, \r\n `regdate`, `website`, `location`, `yim`, `telephone`, `fax`, `mobile`, `question`, `answer`, `passlostkey`, \r\n `view_mail`, `remember`, `in_groups`, `active`, `checknum`, `last_login`, `last_ip`, `last_agent`, `last_openid`) VALUES \r\n (\r\n NULL, \r\n " . $db->dbescape($reg_attribs['username']) . ", \r\n '', \r\n " . $db->dbescape($reg_attribs['email']) . ", \r\n " . $db->dbescape($reg_attribs['full_name']) . ", \r\n " . $db->dbescape(ucfirst($reg_attribs['gender'])) . ", \r\n '', 0, " . NV_CURRENTTIME . ", '', '', \r\n " . $db->dbescape($reg_attribs['yim']) . ", \r\n '', '', '', '', '', '', 0, 0, '', 1, '', 0, '', '', ''\r\n )"; $userid = $db->sql_query_insert_id($sql); if (!$userid) { openidLogin_Res0($lang_module['err_no_save_account']); die; } $query = "SELECT * FROM `" . NV_USERS_GLOBALTABLE . "` WHERE `userid`=" . $userid . " AND `active`=1"; $result = $db->sql_query($query); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $sql = "INSERT INTO `" . NV_USERS_GLOBALTABLE . "_openid` VALUES (" . intval($row['userid']) . ", " . $db->dbescape($reg_attribs['openid']) . ", " . $db->dbescape($reg_attribs['opid']) . ", " . $db->dbescape($reg_attribs['email']) . ")"; $db->sql_query($sql); validUserLog($row, 1, $reg_attribs['opid']); $nv_redirect = !empty($nv_redirect) ? nv_base64_decode($nv_redirect) : NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name; Header("Location: " . $nv_redirect); exit; } else { $reg_attribs = serialize($reg_attribs); $nv_Request->set_Session('reg_attribs', $reg_attribs); Header("Location: " . NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=register&openid=1&nv_redirect=" . $nv_redirect); exit; } } $array_user_login = array(); if (!defined('NV_IS_USER_FORUM')) { $array_user_login[] = array("title" => $lang_module['openid_note3'], "link" => NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=login&server=" . $attribs['server'] . "&result=1&option=1&nv_redirect=" . $nv_redirect); $array_user_login[] = array("title" => $lang_module['openid_note4'], "link" => NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=login&server=" . $attribs['server'] . "&result=1&option=2&nv_redirect=" . $nv_redirect); } else { $array_user_login[] = array("title" => $lang_module['openid_note6'], "link" => NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=register&nv_redirect=" . $nv_redirect); } $array_user_login[] = array("title" => $lang_module['openid_note5'], "link" => NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=login&server=" . $attribs['server'] . "&result=1&option=3&nv_redirect=" . $nv_redirect); $contents .= user_openid_login2($attribs, $array_user_login); include NV_ROOTDIR . "/includes/header.php"; echo nv_site_theme($contents); include NV_ROOTDIR . "/includes/footer.php"; exit; }