public function setup() { if (is_mobile() and !$_GET['ignore_ua_check']) { switch ($_GET['app']) { default: HTTP::redirect('/m/'); break; } } if ($_GET['ignore_ua_check'] == 'TRUE') { HTTP::set_cookie('_ignore_ua_check', 'TRUE', time() + 3600 * 24 * 7); } }
public function redirect_action() { if (!in_weixin() or get_setting('weixin_account_role') != 'service') { //HTTP::redirect(base64_decode($_GET['redirect'])); } if ($_GET['code'] and get_setting('weixin_app_id') and get_setting('weixin_app_secret')) { if (!$_GET['thirdlogin'] || !$_GET['state']) { H::redirect_msg('授权失败: Redirect 微信三方登录发起的来源ID错误, Code: ' . htmlspecialchars($_GET['code'])); } $thirdlogin = $_GET['thirdlogin']; $third_info = $this->model('openid_weixin_thirdlogin')->get_third_party_login_by_name($thirdlogin); if (!$third_info || $_GET['state'] != $third_info['token']) { H::redirect_msg('授权失败: Redirect 微信三方登录发起的来源ID错误, Code: ' . htmlspecialchars($_GET['code'])); } if ($access_token = $this->model('openid_weixin_weixin')->get_sns_access_token_by_authorization_code($_GET['code'])) { if ($access_token['errcode']) { H::redirect_msg('授权失败: Redirect ' . $access_token['errcode'] . ' ' . $access_token['errmsg'] . ', Code: ' . htmlspecialchars($_GET['code'])); } if ($weixin_user = $this->model('openid_weixin_weixin')->get_user_info_by_openid($access_token['openid'])) { //已有用户 $user_info = $this->model('account')->get_user_info_by_uid($weixin_user['uid']); HTTP::set_cookie('_user_login', get_login_cookie_hash($user_info['user_name'], $user_info['password'], $user_info['salt'], $user_info['uid'], false)); } else { $access_user = $this->model('openid_weixin_weixin')->get_user_info_by_oauth_openid($access_token['access_token'], $access_token['openid']); if ($access_user) { if ($user_info = $this->model('openid_weixin_weixin')->weixin_auto_register($access_token, $access_user)) { HTTP::set_cookie('_user_login', get_login_cookie_hash($user_info['user_name'], $user_info['password'], $user_info['salt'], $user_info['uid'], false)); } else { H::redirect_msg('用户注册失效,请重试!, State: ' . htmlspecialchars($_GET['state']) . ', Code: ' . htmlspecialchars($_GET['code'])); } } else { H::redirect_msg('远程服务器忙,请稍后再试, State: ' . htmlspecialchars($_GET['state']) . ', Code: ' . htmlspecialchars($_GET['code'])); } } $callback_url = $third_info['url']; $query = array(); $query['state'] = $third_info['token']; $query['openid'] = $access_token['openid']; $query['name'] = $third_info['name']; $callback_url = $callback_url . '?' . http_build_query($query); H::redirect_msg('授权成功,正在跳转...', $callback_url); } else { H::redirect_msg('远程服务器忙,请稍后再试, State: ' . htmlspecialchars($_GET['state']) . ', Code: ' . htmlspecialchars($_GET['code'])); } } else { H::redirect_msg('授权失败, 请返回重新操作, URI: ' . $_SERVER['REQUEST_URI']); } }
public function __construct() { if (AWS_APP::session()->client_info and !$_COOKIE[G_COOKIE_PREFIX . '_user_login']) { // Cookie 清除则 Session 也清除 unset(AWS_APP::session()->client_info); } if (!AWS_APP::session()->client_info and $_COOKIE[G_COOKIE_PREFIX . '_user_login']) { $auth_hash_key = md5(G_COOKIE_HASH_KEY . $_SERVER['HTTP_USER_AGENT'] . $_SERVER['HTTP_ACCEPT_LANGUAGE']); // 解码 Cookie $sso_user_login = H::decode_hash($_COOKIE[G_COOKIE_PREFIX . '_user_login'], $auth_hash_key); $user_name = $sso_user_login['user_name']; $host = 'localhost'; $username = '******'; $password = '******'; $database = 'baji'; $dbc = mysqli_connect($host, $username, $password, $database); if (!$dbc) { die('Could not connect: ' . mysql_error()); } $query = "SELECT * FROM users WHERE user_name = '{$user_name}'"; $data = mysqli_query($dbc, $query) or die('error!!' . mysql_error()); mysqli_close($dbc); $row = mysqli_fetch_array($data); $sso_user_login['password'] = $row['password']; $sso_user_login['uid'] = $row['uid']; $name = H::encode_hash($sso_user_login); HTTP::set_cookie($name); if ($sso_user_login['user_name'] and $sso_user_login['password'] and $sso_user_login['uid']) { if (AWS_APP::model('account')->check_hash_login($sso_user_login['user_name'], $sso_user_login['password'])) { AWS_APP::session()->client_info['__CLIENT_UID'] = $sso_user_login['uid']; AWS_APP::session()->client_info['__CLIENT_USER_NAME'] = $sso_user_login['user_name']; AWS_APP::session()->client_info['__CLIENT_PASSWORD'] = $sso_user_login['password']; return true; } } return false; } }
public function __construct($process_setup = true) { // 获取当前用户 User ID $this->user_id = AWS_APP::user()->get_info('uid'); if ($this->user_info = $this->model('account')->get_user_info_by_uid($this->user_id, TRUE)) { $user_group = $this->model('account')->get_user_group($this->user_info['group_id'], $this->user_info['reputation_group']); if ($this->user_info['default_timezone']) { date_default_timezone_set($this->user_info['default_timezone']); } $this->model('online')->online_active($this->user_id, $this->user_info['last_active']); } else { if ($this->user_id) { $this->model('account')->logout(); } else { $user_group = $this->model('account')->get_user_group_by_id(99); if ($_GET['fromuid']) { HTTP::set_cookie('fromuid', $_GET['fromuid']); } } } $this->user_info['group_name'] = $user_group['group_name']; $this->user_info['permission'] = $user_group['permission']; AWS_APP::session()->permission = $this->user_info['permission']; if ($this->user_info['forbidden'] == 1) { $this->model('account')->logout(); H::redirect_msg(AWS_APP::lang()->_t('抱歉, 你的账号已经被禁止登录'), '/'); } else { TPL::assign('user_id', $this->user_id); TPL::assign('user_info', $this->user_info); } if ($this->user_id and !$this->user_info['permission']['human_valid']) { unset(AWS_APP::session()->human_valid); } else { if ($this->user_info['permission']['human_valid'] and !is_array(AWS_APP::session()->human_valid)) { AWS_APP::session()->human_valid = array(); } } // 引入系统 CSS 文件 TPL::import_css(array('css/common.css', 'css/link.css', 'js/plug_module/style.css')); if (defined('SYSTEM_LANG')) { TPL::import_js(base_url() . '/language/' . SYSTEM_LANG . '.js'); } if (HTTP::is_browser('ie', 8)) { TPL::import_js(array('js/jquery.js', 'js/respond.js')); } else { TPL::import_js('js/jquery.2.js'); } // 引入系统 JS 文件 TPL::import_js(array('js/jquery.form.js', 'js/plug_module/plug-in_module.js', 'js/aws.js', 'js/aw_template.js', 'js/app.js')); // 产生面包屑导航数据 $this->crumb(get_setting('site_name'), base_url()); // 载入插件 if ($plugins = AWS_APP::plugins()->parse($_GET['app'], $_GET['c'], 'setup')) { foreach ($plugins as $plugin_file) { include $plugin_file; } } if (get_setting('site_close') == 'Y' and $this->user_info['group_id'] != 1 and !in_array($_GET['app'], array('admin', 'account', 'upgrade'))) { $this->model('account')->logout(); H::redirect_msg(get_setting('close_notice'), '/account/login/'); } if ($_GET['ignore_ua_check'] == 'TRUE') { HTTP::set_cookie('_ignore_ua_check', 'TRUE', time() + 3600 * 24 * 7); } // 执行控制器 Setup 动作 if ($process_setup) { $this->setup(); } }
public function weixin_auto_register($access_token, $access_user) { if ($user_info = $this->register_user($access_token, $access_user)) { $this->bind_account($access_user, $access_token, $user_info['uid']); HTTP::set_cookie('_user_login', get_login_cookie_hash($user_info['user_name'], $user_info['password'], $user_info['salt'], $user_info['uid'], null, false)); return true; } return false; }
public function setcookie_logout() { HTTP::set_cookie('_user_login', '', time() - 3600); }
public function setup() { if ($_GET['ignore_ua_check'] == 'FALSE') { HTTP::set_cookie('_ignore_ua_check', 'FALSE'); } if (!is_mobile()) { switch ($_GET['act']) { default: HTTP::redirect('/'); break; case 'home': HTTP::redirect('/home/'); break; case 'login': HTTP::redirect('/account/login/'); break; case 'question': HTTP::redirect('/question/' . $_GET['id']); break; case 'register': HTTP::redirect('/account/register/'); break; case 'topic': HTTP::redirect('/topic/' . $_GET['id']); break; case 'people': HTTP::redirect('/people/' . $_GET['id']); break; case 'article': HTTP::redirect('/article/' . $_GET['id']); break; } } if (!$this->user_id and !$this->user_info['permission']['visit_site'] and $_GET['act'] != 'login' and $_GET['act'] != 'register') { HTTP::redirect('/m/login/url-' . base64_encode($_SERVER['REQUEST_URI'])); } switch ($_GET['act']) { default: if (!$this->user_id) { HTTP::redirect('/m/login/url-' . base64_encode($_SERVER['REQUEST_URI'])); } break; case 'index': case 'explore': case 'login': case 'question': case 'register': case 'topic': case 'search': case 'people': case 'article': case 'find_password': case 'find_password_success': case 'find_password_modify': // Public page.. break; } TPL::import_clean(); TPL::import_css(array('mobile/css/mobile.css')); TPL::import_js(array('js/jquery.2.js', 'js/jquery.form.js', 'mobile/js/framework.js', 'mobile/js/aws-mobile.js', 'mobile/js/app.js', 'mobile/js/aw-mobile-template.js')); }
public function bind_action() { if (AWS_APP::session()->weibo_user) { $weibo_user_info = AWS_APP::session()->weibo_user; unset(AWS_APP::session()->weibo_user); } if ($_GET['error'] == 'access_denied') { H::redirect_msg(AWS_APP::lang()->_t('授权失败'), '/account/login/'); } if ($this->user_id) { $weibo_user = $this->model('openid_weibo_oauth')->get_weibo_user_by_uid($this->user_id); if ($weibo_user) { H::redirect_msg(AWS_APP::lang()->_t('此账号已绑定微博账号'), '/account/login/'); } } $callback_url = '/account/openid/weibo/bind/'; if ($_GET['return_url']) { $callback_url .= 'return_url-' . $_GET['return_url']; } if ($_GET['code']) { if ($_GET['code'] != $weibo_user_info['authorization_code']) { $this->model('openid_weibo_oauth')->authorization_code = $_GET['code']; $this->model('openid_weibo_oauth')->redirect_url = $callback_url; if (!$this->model('openid_weibo_oauth')->oauth2_login()) { H::redirect_msg($this->model('openid_weibo_oauth')->error_msg, '/account/login/'); } $weibo_user_info = $this->model('openid_weibo_oauth')->user_info; } if (!$weibo_user_info) { H::redirect_msg(AWS_APP::lang()->_t('微博登录失败,用户信息不存在'), '/account/login/'); } $weibo_user = $this->model('openid_weibo_oauth')->get_weibo_user_by_id($weibo_user_info['id']); if ($this->user_id) { if ($weibo_user) { H::redirect_msg(AWS_APP::lang()->_t('此微博账号已被绑定'), '/account/login/'); } $this->model('openid_weibo_oauth')->bind_account($weibo_user_info, $this->user_id); if (!$this->model('integral')->fetch_log($this->user_id, 'BIND_OPENID')) { $this->model('integral')->process($this->user_id, 'BIND_OPENID', round(get_setting('integral_system_config_profile') * 0.2), '绑定 OPEN ID'); } HTTP::redirect('/account/setting/openid/'); } else { if ($weibo_user) { $user = $this->model('account')->get_user_info_by_uid($weibo_user['uid']); if (!$user) { $this->model('openid_weibo_oauth')->unbind_account($weibo_user['uid']); H::redirect_msg(AWS_APP::lang()->_t('本地用户不存在'), '/account/login/'); } $this->model('openid_weibo_oauth')->update_user_info($weibo_user['id'], $weibo_user_info); if (get_setting('register_valid_type') == 'approval' and $user['group_id'] == 3) { $redirect_url = '/account/valid_approval/'; } else { if ($_GET['state']) { $state = base64_url_decode($_GET['state']); } if (get_setting('ucenter_enabled') == 'Y') { $redirect_url = '/account/sync_login/'; if ($state['return_url']) { $redirect_url .= 'url-' . base64_encode($state['return_url']); } } else { if ($state['return_url']) { $redirect_url = $state['return_url']; } else { $redirect_url = '/'; } } HTTP::set_cookie('_user_login', get_login_cookie_hash($user['user_name'], $user['password'], $user['salt'], $user['uid'], false)); if (get_setting('register_valid_type') == 'email' and !$user['valid_email']) { AWS_APP::session()->valid_email = $user['email']; } } HTTP::redirect($redirect_url); } else { switch (get_setting('register_type')) { case 'close': H::redirect_msg(AWS_APP::lang()->_t('本站目前关闭注册'), '/account/login/'); break; case 'invite': H::redirect_msg(AWS_APP::lang()->_t('本站只能通过邀请注册'), '/account/login/'); break; case 'weixin': H::redirect_msg(AWS_APP::lang()->_t('本站只能通过微信注册'), '/account/login/'); break; } AWS_APP::session()->weibo_user = $weibo_user_info; $this->crumb(AWS_APP::lang()->_t('完善资料'), '/account/login/'); TPL::assign('register_url', 'account/ajax/weibo/register/'); $user_name = str_replace('-', '', AWS_APP::session()->weibo_user['screen_name']); while ($this->model('account')->check_username($user_name) || !$this->model('account')->is_valid_username($user_name) || $this->model('account')->check_username_sensitive_words($user_name)) { $user_name = $this->model('account')->random_username(); } TPL::assign('user_name', $user_name); TPL::assign('sns_type', 'weibo'); TPL::import_css('css/register.css'); TPL::output('account/openid/callback'); } } } else { $state = $_GET['return_url'] ? base64_url_encode(array('return_url' => base64_decode($_GET['return_url']))) : null; HTTP::redirect($this->model('openid_weibo_oauth')->get_redirect_url('/account/openid/weibo/bind/', $state)); } }
public function register_action() { if ($_GET['code'] and get_setting('weixin_app_id')) { if (!($access_token = $this->model('openid_weixin_weixin')->get_sns_access_token_by_authorization_code($_GET['code']))) { H::redirect_msg('远程服务器忙,请稍后再试, Code: ' . htmlspecialchars($_GET['code'])); } if ($access_token['errcode']) { H::redirect_msg('授权失败: Register ' . $access_token['errcode'] . ' ' . $access_token['errmsg'] . ', Code: ' . htmlspecialchars($_GET['code'])); } if (!($access_user = $this->model('openid_weixin_weixin')->get_user_info_by_oauth_openid($access_token['access_token'], $access_token['openid']))) { H::redirect_msg('远程服务器忙,请稍后再试, Code: get_user_info'); } if ($access_user['errcode']) { H::redirect_msg('获取用户信息失败: ' . $access_user['errcode'] . ' ' . $access_user['errmsg']); } if (!$access_user['nickname']) { H::redirect_msg(AWS_APP::lang()->_t('获取用户信息失败')); } if ($weixin_user = $this->model('openid_weixin_weixin')->get_user_info_by_openid($access_token['openid'])) { $user_info = $this->model('account')->get_user_info_by_uid($weixin_user['uid']); HTTP::set_cookie('_user_login', get_login_cookie_hash($user_info['user_name'], $user_info['password'], $user_info['salt'], $user_info['uid'], false)); if ($_GET['redirect']) { HTTP::redirect(base64_decode($_GET['redirect'])); } } if ($user_info = $this->model('openid_weixin_weixin')->weixin_auto_register($access_token, $access_user)) { if ($_GET['redirect']) { HTTP::redirect(base64_decode($_GET['redirect'])); } else { H::redirect_msg(AWS_APP::lang()->_t('绑定微信成功'), '/m/'); } } else { H::redirect_msg(AWS_APP::lang()->_t('注册失败,请返回重新操作')); } } else { H::redirect_msg('授权失败, 请返回重新操作, URI: ' . $_SERVER['REQUEST_URI']); } }
function synlogout($get, $post) { if (!API_SYNLOGOUT) { return API_RETURN_FORBIDDEN; } header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"'); HTTP::set_cookie("_user_login", '', -31536000); }
public function register_action() { if ($this->user_id) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('您已登录'))); } switch (get_setting('register_type')) { case 'close': H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('本站目前关闭注册'))); break; case 'invite': H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('本站只能通过邀请注册'))); break; case 'weixin': H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('本站只能通过微信注册'))); break; } if (!AWS_APP::session()->google_user) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('Google 账号信息不存在'))); } if ($this->model('openid_google')->get_google_user_by_id(AWS_APP::session()->google_user['id'])) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('此 Google 账号已被绑定'))); } if ($this->model('account')->check_email($_POST['email'])) { H::ajax_json_output(AWS_APP::RSM(array('input' => 'email'), -1, AWS_APP::lang()->_t('E-Mail 已经被使用, 或格式不正确'))); } if (strlen($_POST['password']) < 6 or strlen($_POST['password']) > 16) { H::ajax_json_output(AWS_APP::RSM(array('input' => 'userPassword'), -1, AWS_APP::lang()->_t('密码长度不符合规则'))); } if (!$_POST['agreement_chk']) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('你必需同意用户协议才能继续'))); } if (get_setting('ucenter_enabled') == 'Y') { $result = $this->model('ucenter')->register($_POST['user_name'], $_POST['password'], $_POST['email']); if (!is_array($result)) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('UCenter 同步失败,错误为:%s', $result))); } $uid = $result['user_info']['uid']; $redirect_url = '/account/sync_login/'; } else { $uid = $this->model('account')->user_register($_POST['user_name'], $_POST['password'], $_POST['email']); if (get_setting('register_valid_type') != 'approval') { $this->model('active')->active_user_by_uid($uid); } if (AWS_APP::session()->google_user['email'] == $_POST['email'] and AWS_APP::session()->google_user['verified_email'] == true) { $this->model('active')->set_user_email_valid_by_uid($uid); } else { if (get_setting('register_valid_type') == 'email') { $this->model('active')->new_valid_email($uid); } } $redirect_url = '/'; } if (!$uid) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('注册失败'))); } $this->model('openid_google')->bind_account(AWS_APP::session()->google_user, $uid); if (AWS_APP::session()->google_user['picture']) { $this->model('account')->associate_remote_avatar($uid, AWS_APP::session()->google_user['picture']); } if (get_setting('register_valid_type') == 'approval') { $redirect_url = '/account/valid_approval/'; } else { $user_info = $this->model('account')->get_user_info_by_uid($uid); HTTP::set_cookie('_user_login', get_login_cookie_hash($user_info['user_name'], $user_info['password'], $user_info['salt'], $user_info['uid'], false)); if (get_setting('register_valid_type') == 'email') { AWS_APP::session()->valid_email = $user_info['email']; } } unset(AWS_APP::session()->google_user); H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url($redirect_url)), 1, null)); }
public function setup() { if ($_GET['ignore_ua_check'] == 'FALSE') { HTTP::set_cookie('_ignore_ua_check', 'FALSE'); } if (!is_mobile()) { switch ($_GET['act']) { default: HTTP::redirect('/'); break; case 'home': HTTP::redirect('/home/'); break; case 'login': HTTP::redirect('/account/login/'); break; case 'question': HTTP::redirect('/question/' . $_GET['id']); break; case 'register': HTTP::redirect('/account/register/'); break; case 'topic': HTTP::redirect('/topic/' . $_GET['id']); break; case 'people': HTTP::redirect('/people/' . $_GET['id']); break; case 'article': HTTP::redirect('/article/' . $_GET['id']); break; } } if (!$this->user_id and !$this->user_info['permission']['visit_site'] and $_GET['act'] != 'login' and $_GET['act'] != 'register') { HTTP::redirect('/m/login/url-' . base64_encode($_SERVER['REQUEST_URI'])); } switch ($_GET['act']) { default: if (!$this->user_id) { HTTP::redirect('/m/login/url-' . base64_encode($_SERVER['REQUEST_URI'])); } break; case 'index': case 'explore': case 'login': case 'question': case 'register': case 'topic': case 'search': case 'people': case 'article': case 'find_password': case 'find_password_success': case 'find_password_modify': // Public page.. break; } TPL::import_clean(); TPL::import_css(array('mobile/css/mobile.css')); TPL::import_js(array('js/jquery.2.js', 'js/jquery.form.js', 'mobile/js/framework.js', 'mobile/js/aws-mobile.js', 'mobile/js/app.js', 'mobile/js/aw-mobile-template.js')); if (in_weixin()) { $noncestr = mt_rand(1000000000, 9999999999.0); TPL::assign('weixin_noncestr', $noncestr); $jsapi_ticket = $this->model('openid_weixin_weixin')->get_jsapi_ticket($this->model('openid_weixin_weixin')->get_access_token(get_setting('weixin_app_id'), get_setting('weixin_app_secret'))); $url = ($_SERVER['HTTPS'] and !in_array(strtolower($_SERVER['HTTPS']), array('off', 'no'))) ? 'https' : 'http'; $url .= '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; TPL::assign('weixin_signature', $this->model('openid_weixin_weixin')->generate_jsapi_ticket_signature($jsapi_ticket, $noncestr, TIMESTAMP, $url)); } }
public function bind_action() { if (AWS_APP::session()->twitter_request_token) { $twitter_request_token = AWS_APP::session()->twitter_request_token; unset(AWS_APP::session()->twitter_request_token); } if (AWS_APP::session()->twitter_user) { $twitter_user_info = AWS_APP::session()->twitter_user; unset(AWS_APP::session()->twitter_user); } if ($_GET['denied']) { H::redirect_msg(AWS_APP::lang()->_t('授权失败'), '/account/login/'); } if ($this->user_id) { $twitter_user = $this->model('openid_twitter')->get_twitter_user_by_uid($this->user_id); if ($twitter_user) { H::redirect_msg(AWS_APP::lang()->_t('此账号已绑定 Twitter 账号'), '/account/login/'); } } if ($_GET['oauth_token']) { if (!$twitter_user_info) { if ($_GET['oauth_token'] != $twitter_request_token['oauth_token']) { H::redirect_msg(AWS_APP::lang()->_t('oauth token 不一致'), '/account/login/'); } if (!$_GET['oauth_verifier']) { H::redirect_msg(AWS_APP::lang()->_t('oauth verifier 为空'), '/account/login/'); } $this->model('openid_twitter')->request_token = $twitter_request_token; $this->model('openid_twitter')->request_token['oauth_verifier'] = $_GET['oauth_verifier']; if (!$this->model('openid_twitter')->get_user_info()) { H::redirect_msg($this->model('openid_twitter')->error_msg, '/account/login/'); } $twitter_user_info = $this->model('openid_twitter')->user_info; } if (!$twitter_user_info) { H::redirect_msg(AWS_APP::lang()->_t('Twitter 登录失败,用户信息不存在'), '/account/login/'); } $twitter_user = $this->model('openid_twitter')->get_twitter_user_by_id($twitter_user_info['id']); if ($this->user_id) { if ($twitter_user) { H::redirect_msg(AWS_APP::lang()->_t('此 Twitter 账号已被绑定'), '/account/login/'); } $this->model('openid_twitter')->bind_account($twitter_user_info, $this->user_id); if (!$this->model('integral')->fetch_log($this->user_id, 'BIND_OPENID')) { $this->model('integral')->process($this->user_id, 'BIND_OPENID', round(get_setting('integral_system_config_profile') * 0.2), '绑定 OPEN ID'); } HTTP::redirect('/account/setting/openid/'); } else { if ($twitter_user) { $user = $this->model('account')->get_user_info_by_uid($twitter_user['uid']); if (!$user) { $this->model('openid_twitter')->unbind_account($twitter_user['uid']); H::redirect_msg(AWS_APP::lang()->_t('本地用户不存在'), '/account/login/'); } $this->model('openid_twitter')->update_user_info($twitter_user['id'], $twitter_user_info); if (get_setting('register_valid_type') == 'approval' and $user['group_id'] == 3) { $redirect_url = '/account/valid_approval/'; } else { if (get_setting('ucenter_enabled') == 'Y') { $redirect_url = '/account/sync_login/'; if ($_GET['return_url']) { $redirect_url .= 'url-' . $_GET['return_url']; } } else { if ($state['return_url']) { $redirect_url = $state['return_url']; } else { $redirect_url = '/'; } } HTTP::set_cookie('_user_login', get_login_cookie_hash($user['user_name'], $user['password'], $user['salt'], $user['uid'], false)); if (get_setting('register_valid_type') == 'email' and !$user['valid_email']) { AWS_APP::session()->valid_email = $user['email']; } } HTTP::redirect($redirect_url); } else { switch (get_setting('register_type')) { case 'close': H::redirect_msg(AWS_APP::lang()->_t('本站目前关闭注册'), '/account/login/'); break; case 'invite': H::redirect_msg(AWS_APP::lang()->_t('本站只能通过邀请注册'), '/account/login/'); break; case 'weixin': H::redirect_msg(AWS_APP::lang()->_t('本站只能通过微信注册'), '/account/login/'); break; } AWS_APP::session()->twitter_user = $twitter_user_info; $this->crumb(AWS_APP::lang()->_t('完善资料'), '/account/login/'); TPL::assign('register_url', '/account/ajax/twitter/register/'); TPL::assign('user_name', AWS_APP::session()->twitter_user['name']); TPL::import_css('css/register.css'); TPL::output('account/openid/callback'); } } } else { $this->model('openid_twitter')->oauth_callback = '/account/openid/twitter/bind/'; if ($_GET['return_url']) { $this->model('openid_twitter')->oauth_callback .= 'return_url-' . $_GET['return_url']; } if (!$this->model('openid_twitter')->oauth_redirect()) { H::redirect_msg($this->model('openid_twitter')->error_msg, '/account/login/'); } AWS_APP::session()->twitter_request_token = $this->model('openid_twitter')->request_token; HTTP::redirect($this->model('openid_twitter')->redirect_url); } }
public function qq_login_callback_action() { if ($this->is_post() and AWS_APP::session()->qq_profile and AWS_APP::session()->QQConnect) { if (get_setting('register_type') == 'close') { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('本站目前关闭注册'))); } else { if (get_setting('register_type') == 'invite') { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('本站只能通过邀请注册'))); } else { if (get_setting('register_type') == 'weixin') { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('本站只能通过微信注册'))); } } } if (trim($_POST['user_name']) == '') { H::ajax_json_output(AWS_APP::RSM(array('input' => 'user_name'), -1, AWS_APP::lang()->_t('请输入真实姓名'))); } else { if ($this->model('account')->check_username($_POST['user_name'])) { H::ajax_json_output(AWS_APP::RSM(array('input' => 'user_name'), -1, AWS_APP::lang()->_t('真实姓名已经存在'))); } else { if ($check_rs = $this->model('account')->check_username_char($_POST['user_name'])) { H::ajax_json_output(AWS_APP::RSM(array('input' => 'user_name'), -1, $check_rs)); } else { if ($this->model('account')->check_username_sensitive_words($_POST['user_name'])) { H::ajax_json_output(AWS_APP::RSM(array('input' => 'user_name'), -1, AWS_APP::lang()->_t('真实姓名中包含敏感词或系统保留字'))); } } } } if ($this->model('account')->check_email($_POST['email'])) { H::ajax_json_output(AWS_APP::RSM(array('input' => 'email'), -1, AWS_APP::lang()->_t('E-Mail 已经被使用, 或格式不正确'))); } if (strlen($_POST['password']) < 6 or strlen($_POST['password']) > 16) { H::ajax_json_output(AWS_APP::RSM(array('input' => 'userPassword'), -1, AWS_APP::lang()->_t('密码长度不符合规则'))); } if (!$_POST['agreement_chk']) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('你必需同意用户协议才能继续'))); } if (get_setting('ucenter_enabled') == 'Y') { $result = $this->model('ucenter')->register($_POST['user_name'], $_POST['password'], $_POST['email'], true); if (is_array($result)) { $uid = $result['user_info']['uid']; } else { H::ajax_json_output(AWS_APP::RSM(null, -1, $result)); } } else { $uid = $this->model('account')->user_register($_POST['user_name'], $_POST['password'], $_POST['email']); if (get_setting('register_valid_type') == 'email') { $this->model('active')->new_valid_email($uid); } if (get_setting('register_valid_type') != 'approval') { $this->model('active')->active_user_by_uid($uid); } } if ($uid) { $this->model('openid_qq')->bind_account(AWS_APP::session()->qq_profile, null, $uid, true); if (AWS_APP::session()->qq_profile['figureurl_2']) { $this->model('account')->associate_remote_avatar($uid, AWS_APP::session()->qq_profile['figureurl_2']); } H::ajax_json_output(AWS_APP::RSM(null, 1, null)); } else { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('与 QQ 通信出错 (Register), 请重新登录'))); } } else { if (!$_GET['code']) { H::redirect_msg(AWS_APP::lang()->_t('与 QQ 通信出错, 请重新登录'), "/account/login/"); } if (!AWS_APP::session()->QQConnect['access_token']) { if (!$this->model('openid_qq')->request_access_token(get_js_url('/account/openid/qq_login_callback/'))) { H::redirect_msg(AWS_APP::lang()->_t('与 QQ 通信出错, 请重新登录'), "/account/login/"); } } if (!AWS_APP::session()->QQConnect['access_token'] or !($uinfo = $this->model('openid_qq')->request_user_info())) { H::redirect_msg(AWS_APP::lang()->_t('与 QQ 通信出错, 请重新登录'), "/account/login/"); } AWS_APP::session()->qq_profile = $uinfo; if ($qq_user = $this->model('openid_qq')->get_user_info_by_open_id(load_class('Services_Tencent_QQConnect_V2')->get_openid())) { $user_info = $this->model('account')->get_user_info_by_uid($qq_user['uid']); HTTP::set_cookie('_user_login', get_login_cookie_hash($user_info['user_name'], $user_info['password'], $user_info['salt'], $user_info['uid'], false)); $this->model('openid_qq')->update_token($qq_user['name'], AWS_APP::session()->QQConnect['access_token']); HTTP::redirect('/'); } else { if ($this->user_id) { $this->model('openid_qq')->bind_account($this->model('openid_qq')->request_user_info(), '/', $this->user_id); } else { if (get_setting('register_type') == 'close') { H::redirect_msg(AWS_APP::lang()->_t('本站目前关闭注册')); } else { if (get_setting('register_type') == 'invite') { H::redirect_msg(AWS_APP::lang()->_t('本站只能通过邀请注册')); } else { $this->crumb(AWS_APP::lang()->_t('完善资料'), '/account/login/'); TPL::assign('user_name', str_replace(' ', '_', AWS_APP::session()->qq_profile['nickname'])); TPL::import_css('css/register.css'); TPL::output('account/openid/callback'); } } } } } }