function binding_callback_action() { $oauth = new Services_Weibo_WeiboOAuth(get_setting('sina_akey'), get_setting('sina_skey')); if ($_GET['uid'] and $this->user_info['permission']['is_administortar']) { $user_id = intval($_GET['uid']); $user_info = $this->model('account')->get_user_info_by_uid($user_id); if (empty($user_info)) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('本地用户不存在,无法绑定'))); } $sina_token = $oauth->getAccessToken('code', array('code' => $_GET['code'], 'redirect_uri' => get_js_url('/account/sina/binding_callback/uid-' . $user_id))); } else { $user_id = $this->user_id; AWS_APP::session()->sina_token = $oauth->getAccessToken('code', array('code' => $_GET['code'], 'redirect_uri' => get_js_url('/account/sina/binding_callback/'))); $sina_token = AWS_APP::session()->sina_token; $redirect = get_js_url('/account/setting/openid/'); } $client = new Services_Weibo_WeiboClient(get_setting('sina_akey'), get_setting('sina_skey'), $sina_token['access_token']); $uid_get = $client->get_uid(); $sina_profile = $client->show_user_by_id($uid_get['uid']); if ($sina_profile['error']) { H::redirect_msg(AWS_APP::lang()->_t('与微博通信出错, 错误代码: %s', $sina_profile['error']), "/account/setting/openid/"); } if (!$this->model('integral')->fetch_log($user_id, 'BIND_OPENID')) { $this->model('integral')->process($user_id, 'BIND_OPENID', round(get_setting('integral_system_config_profile') * 0.2), '绑定 OPEN ID'); } //$this->model('openid_weibo')->bind_account($sina_profile, get_js_url('/account/setting/openid/'), $user_id, $last_key['oauth_token'], $last_key['oauth_token_secret'], $sina_token); $this->model('openid_weibo')->bind_account($sina_profile, $redirect, $user_id, $sina_token); }
function set_human_valid($permission_tag) { if (!is_array(AWS_APP::session()->human_valid)) { return FALSE; } AWS_APP::session()->human_valid[$permission_tag][time()] = TRUE; return count(AWS_APP::session()->human_valid[$permission_tag]); }
public function valid_post_hash($hash) { if (in_array($hash, AWS_APP::session()->post_hash)) { $this->remove_post_hash($hash); return TRUE; } return FALSE; }
public function login_action() { if (!$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_moderator']) { H::redirect_msg(AWS_APP::lang()->_t('你没有访问权限, 请重新登录'), '/'); } else { if (AWS_APP::session()->admin_login) { HTTP::redirect('/admin/'); } } TPL::import_css('admin/css/login.css'); TPL::output('admin/login'); }
public function get_openid() { //-------请求参数列表 $keysArr = array("access_token" => AWS_APP::session()->QQConnect['access_token']); $graph_url = $this->urlUtils->combineURL(self::GET_OPENID_URL, $keysArr); $response = $this->urlUtils->get_contents($graph_url); //--------检测错误是否发生 if (strpos($response, "callback") !== false) { $lpos = strpos($response, "("); $rpos = strrpos($response, ")"); $response = substr($response, $lpos + 1, $rpos - $lpos - 1); } $user = json_decode($response); if (isset($user->error)) { die($user->error . ': ' . $user->error_description); } return $user->openid; }
public function bind_account($uinfo, $redirect, $uid, $is_ajax = false) { if (!($openid = load_class('Services_Tencent_QQConnect_V2')->get_openid())) { if ($is_ajax) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('与 QQ 通信出错, 请重新登录'))); } else { H::redirect_msg(AWS_APP::lang()->_t('与 QQ 通信出错, 请重新登录'), '/account/logout/'); } } if ($openid_info = $this->get_user_info_by_uid($uid)) { if ($openid_info['openid'] != $openid) { if ($is_ajax) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('QQ 账号已经被其他账号绑定'))); } else { H::redirect_msg(AWS_APP::lang()->_t('QQ 账号已经被其他账号绑定'), '/account/logout/'); } } } if (!($users_qq = $this->get_user_info_by_open_id($openid))) { if ($uinfo['gender'] == '男') { $uinfo['gender'] = 'm'; } else { if ($uinfo['gender'] == '女') { $uinfo['gender'] = 'f'; } else { $uinfo['gender'] = 'n'; } } $users_qq = $this->user_add($uid, $openid, $uinfo['nickname'], $uinfo['gender']); } else { if ($users_qq['uid'] != $uid) { if ($is_ajax) { H::ajax_json_output(AWS_APP::RSM(null, '-1', 'QQ 已经被其他账号绑定')); } else { H::redirect_msg(AWS_APP::lang()->_t('QQ 已经被其他账号绑定'), '/account/setting/openid/'); } } } $this->update_token($openid, AWS_APP::session()->QQConnect['access_token']); if ($redirect) { HTTP::redirect($redirect); } }
public function callback_qq_action() { if (get_setting('qq_login_enabled') != 'Y') { H::redirect_msg(AWS_APP::lang()->_t('QQ 帐号绑定功能已关闭'), '/'); } 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/qq/callback_qq/'))) { 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/'); } else { 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), AWS_APP::lang()->_t('绑定 OPEN ID')); } $this->model('openid_qq')->bind_account($uinfo, get_js_url('/account/setting/openid/'), $this->user_id); } }
public function process_success_action() { TPL::assign('email', AWS_APP::session()->find_password); TPL::output('account/find_password/process_success'); }
public function binding_action() { if (AWS_APP::session()->WXConnect['access_token']['openid']) { $this->model('openid_weixin_weixin')->bind_account(AWS_APP::session()->WXConnect['access_user'], AWS_APP::session()->WXConnect['access_token'], $this->user_id); if ($_GET['redirect']) { HTTP::redirect(base64_decode($_GET['redirect'])); } else { H::redirect_msg(AWS_APP::lang()->_t('绑定微信成功'), '/m/'); } } else { H::redirect_msg('授权失败, 请返回重新操作, URI: ' . $_SERVER['REQUEST_URI']); } }
public function register_process_action() { 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' and !$_POST['icode']) { 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 ($_POST['icode']) { if (!($invitation = $this->model('invitation')->check_code_available($_POST['icode'])) and $_POST['email'] == $invitation['invitation_email']) { 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(null, -1, AWS_APP::lang()->_t('请输入用户名'))); } else { if ($this->model('account')->check_username($_POST['user_name'])) { H::ajax_json_output(AWS_APP::RSM(null, -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(null, -1, AWS_APP::lang()->_t('用户名包含无效字符'))); } else { if ($this->model('account')->check_username_sensitive_words($_POST['user_name']) or trim($_POST['user_name']) != $_POST['user_name']) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('用户名中包含敏感词或系统保留字'))); } } } } if ($this->model('account')->check_email($_POST['email'])) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('E-Mail 已经被使用, 或格式不正确'))); } if (strlen($_POST['password']) < 6 or strlen($_POST['password']) > 16) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('密码长度不符合规则'))); } // if (! $_POST['agreement_chk']) // { // H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('你必需同意用户协议才能继续'))); // } // 检查验证码 // if (!AWS_APP::captcha()->is_validate($_POST['seccode_verify']) AND get_setting('register_seccode') == 'Y') // { // 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)) { $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 ($_POST['email'] == $invitation['invitation_email']) { $this->model('active')->set_user_email_valid_by_uid($uid); $this->model('active')->active_user_by_uid($uid); } $this->model('account')->setcookie_logout(); $this->model('account')->setsession_logout(); if ($_POST['icode']) { $follow_users = $this->model('invitation')->get_invitation_by_code($_POST['icode']); } else { if (HTTP::get_cookie('fromuid')) { $follow_users = $this->model('account')->get_user_info_by_uid(HTTP::get_cookie('fromuid')); } } if ($follow_users['uid']) { $this->model('follow')->user_follow_add($uid, $follow_users['uid']); $this->model('follow')->user_follow_add($follow_users['uid'], $uid); $this->model('integral')->process($follow_users['uid'], 'INVITE', get_setting('integral_system_config_invite'), '邀请注册: ' . $_POST['user_name'], $follow_users['uid']); } if ($_POST['icode']) { $this->model('invitation')->invitation_code_active($_POST['icode'], time(), fetch_ip(), $uid); } if (get_setting('register_valid_type') == 'N' or get_setting('register_valid_type') == 'email' and get_setting('register_type') == 'invite') { $this->model('active')->active_user_by_uid($uid); } $user_info = $this->model('account')->get_user_info_by_uid($uid); if (get_setting('register_valid_type') == 'N' or $user_info['group_id'] != 3 or $_POST['email'] == $invitation['invitation_email']) { $valid_email = 1; } else { AWS_APP::session()->valid_email = $user_info['email']; $this->model('active')->new_valid_email($uid); $valid_email = 0; } $this->model('account')->setcookie_login($user_info['uid'], $user_info['user_name'], $_POST['password'], $user_info['salt']); H::ajax_json_output(AWS_APP::RSM(array('uid' => $user_info['uid'], 'user_name' => $user_info['user_name'], 'valid_email' => $valid_email), 1, null)); }
/** * 系统初始化 */ private static function init() { set_exception_handler(array('AWS_APP', 'exception_handle')); self::$config = load_class('core_config'); self::$db = load_class('core_db'); self::$plugins = load_class('core_plugins'); self::$settings = self::model('setting')->get_settings(); if ((!defined('G_SESSION_SAVE') or G_SESSION_SAVE == 'db') and get_setting('db_version') > 20121123) { Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable(array('name' => get_table('sessions'), 'primary' => 'id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime'))); self::$session_type = 'db'; } Zend_Session::setOptions(array('name' => G_COOKIE_PREFIX . '_Session', 'cookie_domain' => G_COOKIE_DOMAIN)); if (G_SESSION_SAVE == 'file' and G_SESSION_SAVE_PATH) { Zend_Session::setOptions(array('save_path' => G_SESSION_SAVE_PATH)); } Zend_Session::start(); self::$session = new Zend_Session_Namespace(G_COOKIE_PREFIX . '_Anwsion'); if ($default_timezone = get_setting('default_timezone')) { date_default_timezone_set($default_timezone); } if ($img_url = get_setting('img_url')) { define('G_STATIC_URL', $img_url); } else { define('G_STATIC_URL', base_url() . '/static'); } if (self::config()->get('system')->debug) { if ($cornd_timer = self::cache()->getGroup('crond')) { foreach ($cornd_timer as $cornd_tag) { if ($cornd_runtime = self::cache()->get($cornd_tag)) { AWS_APP::debug_log('crond', 0, 'Tag: ' . str_replace('crond_timer_', '', $cornd_tag) . ', Last run time: ' . date('Y-m-d H:i:s', $cornd_runtime)); } } } } }
public function find_password_success_action() { TPL::assign('email', AWS_APP::session()->find_password); $this->crumb(AWS_APP::lang()->_t('找回密码'), '/m/find_password_success/'); TPL::output('m/find_password_success'); }
public function valid_email_action() { if (!AWS_APP::session()->valid_email) { HTTP::redirect('/'); } if (!($user_info = $this->model('account')->get_user_info_by_email(AWS_APP::session()->valid_email))) { HTTP::redirect('/'); } if ($user_info['valid_email']) { H::redirect_msg(AWS_APP::lang()->_t('邮箱已通过验证,请返回登录'), '/account/login/'); } $this->crumb(AWS_APP::lang()->_t('邮件验证'), '/account/valid_email/'); TPL::import_css('css/register.css'); TPL::assign('email', AWS_APP::session()->valid_email); TPL::output("account/valid_email"); }
/** * get_access_token * 获得access_token * @param void * @since 5.0 * @return string 返加access_token */ public function get_access_token() { return AWS_APP::session()->QQConnect['access_token']; }
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'); } } } } } }
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 admin_logout() { if (isset(AWS_APP::session()->admin_login)) { unset(AWS_APP::session()->admin_login); } }
public function setsession_logout() { if (isset(AWS_APP::session()->client_info)) { unset(AWS_APP::session()->client_info); } if (isset(AWS_APP::session()->permission)) { unset(AWS_APP::session()->permission); } }
public function find_password_modify_action() { $passowrd = "82737"; /* if (!AWS_APP::captcha()->is_validate($_POST['seccode_verify'])) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请填写正确的验证码'))); } */ $active_data = $this->model('active')->get_active_code($_POST['active_code'], 'FIND_PASSWORD'); if ($active_data) { if ($active_data['active_time'] or $active_data['active_ip']) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('链接已失效,请重新找回密码'))); } } else { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('链接已失效,请重新找回密码'))); } /* if (!$_POST['password']) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请输入密码'))); } if ($_POST['password'] != $_POST['re_password']) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('两次输入的密码不一致'))); } */ if (!($uid = $this->model('active')->active_code_active($_POST['active_code'], 'FIND_PASSWORD'))) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('链接已失效,请重新找回密码'))); } $user_info = $this->model('account')->get_user_info_by_uid($uid); # $this->model('account')->update_user_password_ingore_oldpassword($_POST['password'], $uid, $user_info['salt']); $uid1 = $_POST['theuid']; $this->model('account')->update_user_password_ingore_oldpassword($passowrd, $uid1, $user_info['salt']); # $this->model('account')->update_user_password_ingore_oldpassword($passowrd, $uid, $user_info['salt']); $this->model('active')->set_user_email_valid_by_uid($user_info['uid']); if ($user_info['group_id'] == 3) { $this->model('active')->active_user_by_uid($user_info['uid']); } $this->model('account')->setcookie_logout(); $this->model('account')->setsession_logout(); unset(AWS_APP::session()->find_password); H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/account/login/')), 1, AWS_APP::lang()->_t('密码修改成功, 请返回登录'))); }
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 get_info($key) { return AWS_APP::session()->client_info['__CLIENT_' . strtoupper($key)]; }
public function __construct() { parent::__construct(false); if ($_GET['app'] != 'admin') { return false; } TPL::import_clean(); if (defined('SYSTEM_LANG')) { TPL::import_js(base_url() . '/language/' . SYSTEM_LANG . '.js'); } if (HTTP::is_browser('ie', 8)) { TPL::import_js('js/jquery.js'); } else { TPL::import_js('js/jquery.2.js'); } TPL::import_js(array('admin/js/aws_admin.js', 'admin/js/aws_admin_template.js', 'js/jquery.form.js', 'admin/js/framework.js', 'admin/js/global.js')); TPL::import_css(array('admin/css/common.css')); if (in_array($_GET['act'], array('login', 'login_process'))) { return true; } if ($admin_info = H::decode_hash(AWS_APP::session()->admin_login)) { if ($admin_info['uid'] != $this->user_id or $admin_info['UA'] != $_SERVER['HTTP_USER_AGENT'] or !AWS_APP::session()->permission['is_administortar'] and !AWS_APP::session()->permission['is_moderator']) { unset(AWS_APP::session()->admin_login); if ($_POST['_post_type'] == 'ajax') { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('会话超时, 请重新登录'))); } else { H::redirect_msg(AWS_APP::lang()->_t('会话超时, 请重新登录'), '/admin/login/url-' . base64_encode($_SERVER['REQUEST_URI'])); } } } else { if ($_POST['_post_type'] == 'ajax') { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('会话超时, 请重新登录'))); } else { HTTP::redirect('/admin/login/url-' . base64_encode($_SERVER['REQUEST_URI'])); } } $this->setup(); }
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)); }
/** * 创建一个新的 hash 字符串,并写入 hash 队列, 用于表单提交验证 * * @return string */ function new_post_hash() { if (!AWS_APP::session()->client_info) { return false; } return AWS_APP::form()->new_post_hash(); }
public function request_find_password_action() { if (!H::valid_email($_POST['email'])) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('����д��ȷ�������ַ'))); } if (!AWS_APP::captcha()->is_validate($_POST['seccode_verify'])) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('����д��ȷ����֤��'))); } if (!($user_info = $this->model('account')->get_user_info_by_email($_POST['email']))) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('�����ַ������ʺŲ�����'))); } $this->model('active')->new_find_password($user_info['uid']); AWS_APP::session()->find_password = $user_info['email']; if (is_mobile()) { $url = get_js_url('/m/find_password_success/'); } else { $url = get_js_url('/account/find_password/process_success/'); } H::ajax_json_output(AWS_APP::RSM(array('url' => $url), 1, null)); }