public function dologin() { if ($this->user['id']) { // $this->Redirect('','','',1); } $request_name = 'username'; $request_password = '******'; $request_email = 'email'; $user_name = addslashes($this->input[$request_name]); $password = addslashes($this->input[$request_password]); if (!$user_name && !$password) { $this->ReportError($this->lang['nameerror']); } $email = addslashes($this->input[$request_email]); $member = uc_user_login($user_name, $password); $timestamp = TIMENOW; // uid 大于0 登录成功,-1 : 用户不存在,或者被删除 -2:密码错误 其他:未定义 if ($member[0] > 0) { //同步登录 $ucsynlogin = uc_user_synlogin($member[0]); hg_set_cookie('user', $member[1], $timestamp + 31536000); hg_set_cookie('pass', $member[4], $timestamp + 31536000); hg_set_cookie('member_id', $member[0], $timestamp + 31536000); $this->Redirect($this->lang['loginsucess'], '', 2, 0, $ucsynlogin); } else { $this->ReportError($this->lang['nameerror']); } }
function register() { $activeuser = uc_get_user($this->base->post['username']); if ($activeuser) { $this->base->message('该用户无需注册,请直接登录!', 'user/login'); } $uid = uc_user_register($this->base->post['username'], $this->base->post['password'], $this->base->post['email']); if ($uid <= 0) { if ($uid == -1) { $this->base->message('用户名不合法'); } elseif ($uid == -2) { $this->base->message('包含要允许注册的词语'); } elseif ($uid == -3) { $this->base->message('用户名已经存在'); } elseif ($uid == -4) { $this->base->message('Email 格式有误'); } elseif ($uid == -5) { $this->base->message('Email 不允许注册'); } elseif ($uid == -6) { $this->base->message('该 Email 已经被注册'); } else { $this->base->message('未定义'); } } else { $_ENV['user']->add($this->base->post['username'], $this->base->post['password'], $this->base->post['email'], $uid); $_ENV['user']->refresh($uid); $ucsynlogin = uc_user_synlogin($uid); $this->base->message('注册成功' . $ucsynlogin . '<br><a href="' . $_SERVER['PHP_SELF'] . '">继续</a>'); } }
public function authenticateUC() { //通过接口判断登录帐号的正确性,返回值为数组 list($uid, $username, $password, $email) = uc_user_login($this->username, $this->password); setcookie('Example_auth', '', -86400); if ($uid > 0) { //用户登陆成功,设置 Cookie,加密直接用 uc_authcode 函数,用户使用自己的函数 setcookie('Example_auth', uc_authcode($uid . "\t" . $username, 'ENCODE')); //生成同步登录的代码 $ucsynlogin = uc_user_synlogin($uid); $user = User::model()->findByPk($uid); $this->_id = $user->id; $this->setState('email', $user->email); //$this->setState('role', '管理员'); //保存登录记录 $arr = array('uid' => $user->id, 'login_time' => strtotime('NOW'), 'login_ip' => Yii::app()->request->userHostAddress); $model = new LoginRecord(); $model->attributes = $arr; $model->save(); $this->errorCode = self::ERROR_NONE; } elseif ($uid == -1) { $this->errorCode = self::ERROR_USERNAME_INVALID; } elseif ($uid == -2) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } return !$this->errorCode; }
public function index() { if ($_REQUEST['uc'] == 1) { @(include dirname(__FILE__) . '/../../config.inc.php'); if (UC_KEY == "" || UC_API == "") { exit("登陆失败,请检查uc配置文件config.inc.php"); } include dirname(__FILE__) . '/../../include/db_mysql.class.php'; include dirname(__FILE__) . '/../../uc_client/client.php'; if (isset($_SESSION['uc_uid'])) { $ucsynlogin = uc_user_synlogin($_SESSION['uc_uid']); $this->assign('ucsynclogin', $ucsynlogin); unset($_SESSION['uc_uid']); } } $user = daocall('user', 'getUser', array(getRole('user'))); $agents = daocall('agent', 'selectList', array()); foreach ($agents as $agent) { if ($agent['id'] == $user['agent_id']) { $user['agent_name'] = $agent['name']; } } $login_ip = $_SERVER['REMOTE_ADDR']; $this->_tpl->assign('login_ip', $login_ip); $this->_tpl->assign('user', $user); //$this->pageNewsByNumber(); return $this->_tpl->fetch('user/index.html'); }
/** * 写入UserCookie * @param int $userid 用户userid * @param string $username 用户名 * @param int $expire Cookie失效时间 * @param string $md5pass 经过md5加密后的密码(数据库中存储的),整合UC的时候无效 * @return void */ public function userLogin($userid, $expire) { //补充日期信息 global $king, $action; $user = $this->infoUser($userid); kc_setCookie('auth_' . $king->config('userpre', 'user'), $user['authcookie'], $expire); if ($this->isuc) { return uc_user_synlogin($user['uid']); } return ''; }
/** * 同步登陆ucenter * @param $event */ public static function syncLogin($event) { UcenterInterface::getInstance(); $user = $event->identity; $ucenterUser = self::getUser($user->username); //同步登陆ucenter setcookie('Example_auth', '', -86400); setcookie('Example_auth', uc_authcode($ucenterUser[0] . "\t" . $ucenterUser[1], 'ENCODE')); $ucsynlogin = uc_user_synlogin($ucenterUser[0]); //生成同步登录的代码 $script = '登录成功' . $ucsynlogin . '<br><a href="' . $_SERVER['PHP_SELF'] . '">继续</a>'; \Yii::$app->session->setFlash('syn-login-script', "{$script}"); }
public function dologin() { if ($this->user['id']) { $this->Redirect('', '', '', 1); } $url = $this->input['referto'] ? $this->input['referto'] : ""; $request_name = 'username'; $request_password = '******'; $request_email = 'email'; $user_name = addslashes($this->input[$request_name]); $password = addslashes($this->input[$request_password]); if (!$user_name && !$password) { $this->ReportError($this->lang['nameerror']); } $email = addslashes($this->input[$request_email]); $member = uc_user_login($user_name, $password); $timestamp = TIMENOW; // uid 大于0 登录成功,-1 : 用户不存在,或者被删除 -2:密码错误 其他:未定义 if ($member[0] > 0) { //同步登录 $ucsynlogin = uc_user_synlogin($member[0]); $user_name = $member[1]; $password = $member[4]; $user_id = $member[0]; $sql = "SELECT * FROM " . DB_PREFIX . "user WHERE username='******'"; $first = $this->db->query_first($sql); if (!$first) { include_once ROOT_PATH . 'lib/user/user.class.php'; $ucUser = new user(); $info = $ucUser->verify_user_exist($user_name, addslashes($this->input[$request_password])); $ip = hg_getip(); $sql = "INSERT INTO " . DB_PREFIX . "user(id,username,password,salt,email,avatar,register_time,ip) \r\n\t\t\t\tvalues(" . $info['id'] . ",'" . $info['username'] . "','" . $info['password'] . "','" . $info['salt'] . "','" . $info['email'] . "','" . $info['avatar'] . "'," . $info['join_time'] . ",'" . $ip . "')"; $this->db->query($sql); $id = $this->db->insert_id(); $sql = "INSERT INTO " . DB_PREFIX . "user_extra(user_id) \r\n\t\t\t\tvalues(" . $id . ")"; $this->db->query($sql); $user_name = $second['username']; $password = $second['password']; $user_id = $id; } //本地系统 hg_set_cookie('user', $user_name, $timestamp + 31536000); hg_set_cookie('pass', $password, $timestamp + 31536000); hg_set_cookie('userid', $user_id, $timestamp + 31536000); $this->Redirect($this->lang['loginsucess'], $url, 2, 0, $ucsynlogin); } else { $this->ReportError($this->lang['nameerror']); } }
public function show() { $graph_url = "https://graph.qq.com/oauth2.0/me?access_token=" . $_SESSION['access_token']; $str = get_url_contents($graph_url); if (strpos($str, "callback") !== false) { $lpos = strpos($str, "("); $rpos = strrpos($str, ")"); $str = substr($str, $lpos + 1, $rpos - $lpos - 1); } $user = json_decode($str); if (isset($user->error)) { echo "<h3>error:</h3>" . $user->error; echo "<h3>msg :</h3>" . $user->error_description; exit; } //debug //echo("Hello " . $user->openid); //set openid to session $_SESSION["openid"] = $user->openid; $get_user_info = "https://graph.qq.com/user/get_user_info?" . "access_token=" . $_SESSION['access_token'] . "&oauth_consumer_key=" . $_SESSION["appid"] . "&openid=" . $_SESSION["openid"] . "&format=json"; $info = get_url_contents($get_user_info); $arr = json_decode($info, true); $arr['openid'] = $_SESSION["openid"]; $arr['avatar'] = str_replace('100', '', $arr['figureurl_2']); /* $arr = array( 'nickname' => 'Yang', 'avatar' => str_replace('100','','http://qzapp.qlogo.cn/qzapp/206523/A2D8AE5184F0453A7F5502463CE6DD0C/100'), 'openid' => 'A2D8AE5184F0453A7F5502463CE6DD0C', );*/ $member = $this->mUser->qq_login($arr['nickname'], $arr['openid'], $arr['avatar']); $member['large_avatar'] = $member['avatar'] . '30'; $member['middle_avatar'] = $member['avatar'] . '50'; $member['small_avatar'] = $member['avatar'] . '100'; $timestamp = TIMENOW; // uid 大于0 登录成功,-1 : 用户不存在,或者被删除 -2:密码错误 其他:未定义 if ($member['id'] > 0) { //同步登录 $ucsynlogin = uc_user_synlogin($member['id']); //print_r($ucsynlogin);exit; hg_set_cookie('user', urldecode($member['username']), $timestamp + 31536000); hg_set_cookie('pass', $member['password'], $timestamp + 31536000); hg_set_cookie('member_id', $member['id'], $timestamp + 31536000); // hg_pre($_COOKIE);exit; $this->Redirect($this->lang['loginsucess'], '', 2, 0, $ucsynlogin); } else { $this->ReportError($this->lang['nameerror']); } }
function zuitu_uc_synlogin($email, $pass) { if (!function_exists('uc_user_login')) return array(); if (!defined('UC_API')) return array(); $isuid = strpos($email, '@') ? 2 : 0; if (strtolower(UC_CHARSET)!='utf-8') { $email = mb_convert_encoding($email, UC_CHARSET, 'UTF-8'); } $ucresult = uc_user_login($email, $pass, $isuid, 0); $uckey = array( 'uid', 'username', 'password', 'email', 'duplicate' ); $ucresult = array_combine($uckey, $ucresult); if ($ucresult['uid']>0 ) { $script_string = uc_user_synlogin($ucresult['uid']); Session::Set('script', $script_string); } DB::Query('SET NAMES UTF8;'); }
function API_Login($user, $pass) { global $db, $onlineip; include_once ONEZ_ROOT . './uc_client/client.php'; $api = uc_user_login($user, $pass, 0); list($uid, $username, $password, $email) = $api; if ($uid < 0) { if ($uid == -1) { return '用户不存在,或者被删除'; } elseif ($uid == -2) { return '用户名或密码不正确'; } elseif ($uid == -3) { return '安全提问错'; } } if (!$db) { include_once ONEZ_ROOT . './include/db_mysql.class.php'; db_local(); $db = new onez_db(); } $db->reset(); if ($db->rows("users", "uid='{$uid}'") == 0) { //创建本地用户 if ($data = uc_get_user($uid, 1)) { list($uid, $username, $email) = $data; $arr = array('uid' => $uid, 'username' => $username, 'password' => md5($pass), 'email' => $email, 'infoip' => $onlineip, 'infotime' => time()); $db->insert('users', $arr); } } $GLOBALS['cookiepre'] = 'onez_'; osetcookie('userid', $uid, 31536000); osetcookie('username', $username, 31536000); echo uc_user_synlogin($uid); echo <<<ONEZ <p align="center"><br /><br /><br /><br /> <a href="#" onclick="ReLoad()"><font size="2" color="#0000ff">正在同步登录中...</font></a> </p> <script type="text/javascript"> function ReLoad(){ top.location.reload(); } window.onload=ReLoad; </script> ONEZ; exit; return 'Y'; }
static function login($username, $password, $isuid = 0) { list($uid, $username, $password, $email) = uc_user_login($username, $password, $isuid); setcookie(self::$authPre . 'auth', '', -86400); if ($uid > 0) { self::$uid = $uid; self::$username = $username; self::$password = md5($password); self::$email = $email; setcookie(self::$authPre . 'auth', uc_authcode($uid . "\t" . $username . "\t" . md5($password) . "\t" . $email, 'ENCODE')); return array('uid' => $uid, 'username' => $username, 'password' => $password, 'email' => $email, 'synlogin' => uc_user_synlogin($uid)); } else { self::$lastAction = 'login'; self::$lastErrorCode = $uid; return FALSE; } }
public function UcenterLogin($data) { $db = new dbstuff(); $db->connect(UC_DBHOST, UC_DBUSER, UC_DBPW, UC_DBNAME, 0); list($uid, $username, $email) = uc_get_user($data['username']); if (is_null($uid)) { $_data['email'] = $data['email']; $_data['username'] = $data['username']; $_data['password'] = $data['password']; $_data['user_id'] = $data['user_id']; $uid = self::UcenterReg($_data); return self::UcenterLogin($data); } else { $ucsynlogin = uc_user_synlogin($uid); } //var_dump($uid); return $ucsynlogin; }
function login($username, $password, $type = 'g') { if (empty($username) || empty($password)) { return false; } $rt = uc_user_login($username . '#' . $type, $password); $uid = $rt[0]; if ($uid > 0) { return uc_user_synlogin($uid); } switch ($uid) { case -1: $return = array('result' => $uid, 'message' => 'user is not exist!!'); break; case -2: $return = array('result' => $uid, 'message' => 'wrong password!!'); break; } return $return; }
public function create() { $userInfo = array('email' => $this->input['email'], 'username' => $this->input['username'], 'password' => $this->input['password']); $ret = $this->info->createUser($userInfo); $user_name = addslashes($this->input['username']); $password = addslashes($this->input['password']); $email = addslashes($this->input['email']); include_once './uclient/client.php'; $member = uc_user_login($user_name, $password); // uid 大于0 登录成功,-1 : 用户不存在,或者被删除 -2:密码错误 其他:未定义 if ($member[0] > 0) { //同步登录 $ucsynlogin = uc_user_synlogin($member[0]); hg_set_cookie('user', $member[1], $timestamp + 31536000); hg_set_cookie('pass', $member[4], $timestamp + 31536000); hg_set_cookie('member_id', $member[0], $timestamp + 31536000); $ret['script'] = $ucsynlogin; } else { $this->ReportError($this->lang['nameerror']); } echo json_encode($ret); }
function on_login() { global $_G; empty($mrefreshtime) && ($mrefreshtime = 2000); if ($_G['uid']) { $ucsynlogin = uc_user_synlogin($_G['uid']); $param = array('username' => $_G['member']['username'], 'ucsynlogin' => $ucsynlogin, 'uid' => $_G['member']['uid']); showmessage('login_succeed', dreferer(), $param, array('showdialog' => 1, 'locationtime' => 1)); } if (!($_G['member_loginperm'] = logincheck())) { showmessage('login_strike'); } if (!submitcheck('loginsubmit', 1)) { $_G['referer'] = dreferer(); $cookietimecheck = !empty($_G['cookie']['cookietime']) ? 'checked="checked"' : ''; $username = !empty($_G['cookie']['loginuser']) ? htmlspecialchars($_G['cookie']['loginuser']) : ''; include template('member/login'); } else { $_G['uid'] = $_G['member']['uid'] = 0; $_G['username'] = $_G['member']['username'] = $_G['member']['password'] = ''; $result = userlogin($_G['gp_username'], $_G['gp_password'], null, null, 'auto'); if ($result['status'] > 0) { setloginstatus($result['member'], $_G['gp_cookietime'] ? 2592000 : 0); $ucsynlogin = uc_user_synlogin($_G['uid']); $message = 1; $param = array('username' => $_G['member']['username'], 'ucsynlogin' => $ucsynlogin, 'uid' => $_G['uid']); showmessage('login_succeed', dreferer(), $param, array('showdialog' => 1, 'locationtime' => 1)); } else { $password = preg_replace("/^(.{" . round(strlen($_G['gp_password']) / 4) . "})(.+?)(.{" . round(strlen($_G['gp_password']) / 6) . "})\$/s", "\\1***\\3", $_G['gp_password']); $errorlog = dhtmlspecialchars(TIMESTAMP . "\t" . ($result['ucresult']['username'] ? $result['ucresult']['username'] : dstripslashes($_G['gp_username'])) . "\t" . $password . "\t" . "Ques #" . intval($_G['gp_questionid']) . "\t" . $_G['clientip']); writelog('illegallog', $errorlog); loginfailed($_G['member_loginperm']); $fmsg = $result['ucresult']['uid'] == '-3' ? empty($_G['gp_questionid']) || $answer == '' ? 'login_question_empty' : 'login_question_invalid' : 'login_invalid'; showmessage($fmsg, '', array('loginperm' => $_G['member_loginperm'])); } } }
private function _do_email_login() { $username = $_POST['username']; $password = $_POST['password']; if (strpos($username, "@") > 0) { //邮箱登陆 $where['user_email'] = $username; } else { $where['user_login'] = $username; } $users_model = M('Users'); $result = $users_model->where($where)->find(); $ucenter_syn = C("UCENTER_ENABLED"); $ucenter_old_user_login = false; $ucenter_login_ok = false; if ($ucenter_syn) { setcookie("thinkcmf_auth", ""); include UC_CLIENT_ROOT . "client.php"; list($uc_uid, $username, $password, $email) = uc_user_login($username, $password); if ($uc_uid > 0) { if (!$result) { $data = array('user_login' => $username, 'user_email' => $email, 'user_pass' => sp_password($password), 'last_login_ip' => get_client_ip(0, true), 'create_time' => time(), 'last_login_time' => time(), 'user_status' => '1', 'user_type' => 2); $id = $users_model->add($data); $data['id'] = $id; $result = $data; } } else { switch ($uc_uid) { case "-1": //用户不存在,或者被删除 if ($result) { //本应用已经有这个用户 if (sp_compare_password($password, $result['user_pass'])) { //本应用已经有这个用户,且密码正确,同步用户 $uc_uid2 = uc_user_register($username, $password, $result['user_email']); if ($uc_uid2 < 0) { $uc_register_errors = array("-1" => "用户名不合法", "-2" => "包含不允许注册的词语", "-3" => "用户名已经存在", "-4" => "Email格式有误", "-5" => "Email不允许注册", "-6" => "该Email已经被注册"); $this->error("同步用户失败--" . $uc_register_errors[$uc_uid2]); } $uc_uid = $uc_uid2; } else { $this->error("密码错误1!"); } } break; case -2: //密码错 if ($result) { //本应用已经有这个用户 if (sp_compare_password($password, $result['user_pass'])) { //本应用已经有这个用户,且密码正确,同步用户 $uc_user_edit_status = uc_user_edit($username, "", $password, "", 1); if ($uc_user_edit_status <= 0) { $this->error("登陆错误3!"); } list($uc_uid2) = uc_get_user($username); $uc_uid = $uc_uid2; $ucenter_old_user_login = true; } else { $this->error("密码错误4!"); } } else { $this->error("密码错误1!"); } break; } } $ucenter_login_ok = true; echo uc_user_synlogin($uc_uid); } //exit(); if (!empty($result)) { if (sp_compare_password($password, $result['user_pass']) || $ucenter_login_ok) { $_SESSION["user"] = $result; //写入此次登录信息 $data = array('last_login_time' => date("Y-m-d H:i:s"), 'last_login_ip' => get_client_ip(0, true)); $users_model->where("id=" . $result["id"])->save($data); $redirect = empty($_SESSION['login_http_referer']) ? __ROOT__ . "/" : $_SESSION['login_http_referer']; $_SESSION['login_http_referer'] = ""; $ucenter_old_user_login_msg = ""; if ($ucenter_old_user_login) { //$ucenter_old_user_login_msg="老用户请在跳转后,再次登陆"; } $this->success("登录验证成功!", $redirect); } else { $this->error("密码错误7!"); } } else { $this->error("用户名不存在!"); } }
public function doLogin() { $aUsername = $username = I('post.username', '', 'op_t'); $aPassword = I('post.password', '', 'op_t'); $aVerify = I('post.verify', '', 'op_t'); $aRemember = I('post.remember', 0, 'intval'); /* 检测验证码 */ if (check_verify_open('login')) { if (!check_verify($aVerify)) { $res['info'] = "验证码输入错误。"; return $res; } } /* 调用UC登录接口登录 */ check_username($aUsername, $email, $mobile, $aUnType); if (!check_reg_type($aUnType)) { $res['info'] = "该类型未开放登录。"; } $uid = UCenterMember()->login($username, $aPassword, $aUnType); if (0 < $uid) { //UC登录成功 /* 登录用户 */ $Member = D('Member'); $args['uid'] = $uid; $args = array('uid' => $uid, 'nickname' => $username); check_and_add($args); if ($Member->login($uid, $aRemember == 1)) { //登录用户 //TODO:跳转到登录前页面 if (UC_SYNC && $uid != 1) { //同步登录到UC $ref = M('ucenter_user_link')->where(array('uid' => $uid))->find(); $html = ''; $html = uc_user_synlogin($ref['uc_uid']); } $oc_config = (include_once './OcApi/oc_config.php'); if ($oc_config['SSO_SWITCH']) { include_once './OcApi/OCenter/OCenter.php'; $OCApi = new \OCApi(); $html = $OCApi->ocSynLogin($uid); } $res['status'] = 1; $res['info'] = $html; //$this->success($html, get_nav_url(C('AFTER_LOGIN_JUMP_URL'))); } else { $res['info'] = $Member->getError(); } } else { //登录失败 switch ($uid) { case -1: $res['info'] = '用户不存在或被禁用!'; break; //系统级别禁用 //系统级别禁用 case -2: $res['info'] = '密码错误!'; break; default: $res['info'] = $uid; break; // 0-接口参数错误(调试阶段使用) } } return $res; }
public function actlogin() { setcookie('LoginCookie', '', time() - 10 * 60, "/"); //uc登陆 $loginconfig = FS("Webconfig/loginconfig"); $uc_mcfg = $loginconfig['uc']; if ($uc_mcfg['enable'] == 1) { require_once C('APP_ROOT') . "Lib/Uc/config.inc.php"; require C('APP_ROOT') . "Lib/Uc/uc_client/client.php"; } //uc登陆 if ($_SESSION['verify'] != md5($_POST['sVerCode'])) { ajaxmsg("验证码错误!", 0); } false !== strpos($_POST['sUserName'], "@") ? $data['user_email'] = text($_POST['sUserName']) : ($data['user_name'] = text($_POST['sUserName'])); $vo = M('members')->field('id,user_name,user_email,user_pass,is_ban')->where($data)->find(); if ($vo['is_ban'] == 1) { ajaxmsg("您的帐户已被冻结,请联系客服处理!", 0); } if (!is_array($vo)) { //本站登陆不成功,偿试uc登陆及注册本站 if ($uc_mcfg['enable'] == 1) { list($uid, $username, $password, $email) = uc_user_login(text($_POST['sUserName']), text($_POST['sPassword'])); if ($uid > 0) { $regdata['txtUser'] = text($_POST['sUserName']); $regdata['txtPwd'] = text($_POST['sPassword']); $regdata['txtEmail'] = $email; $newuid = $this->ucreguser($regdata); if (is_numeric($newuid) && $newuid > 0) { $logincookie = uc_user_synlogin($uid); //UC同步登陆 setcookie('LoginCookie', $logincookie, time() + 10 * 60, "/"); $this->_memberlogin($newuid); ajaxmsg(); //登陆成功 } else { ajaxmsg($newuid, 0); } } } //本站登陆不成功,偿试uc登陆及注册本站 ajaxmsg("用户名或者密码错误!", 0); } else { if ($vo['user_pass'] == md5($_POST['sPassword'])) { //本站登陆成功,uc登陆及注册UC //uc登陆及注册UC if ($uc_mcfg['enable'] == 1) { $dataUC = uc_get_user($vo['user_name']); if ($dataUC[0] > 0) { $logincookie = uc_user_synlogin($dataUC[0]); //UC同步登陆 setcookie('LoginCookie', $logincookie, time() + 10 * 60, "/"); } else { $uid = uc_user_register($vo['user_name'], $_POST['sPassword'], $vo['user_email']); if ($uid > 0) { $logincookie = uc_user_synlogin($dataUC[0]); //UC同步登陆 setcookie('LoginCookie', $logincookie, time() + 10 * 60, "/"); } } } //uc登陆及注册UC $this->_memberlogin($vo['id']); $url_referer = text($_POST['url_referer']); if (empty($url_referer)) { $url_referer = session("url_referer"); } if (empty($url_referer)) { $url_referer = __APP__ . "/member"; } session("url_referer", null); ajaxmsg(array("url_referer" => $url_referer)); } else { //本站登陆不成功 ajaxmsg("用户名或者密码错误!", 0); } } }
} else { $loginUrl = wsq::userloginUrl2($_G['uid']); } $referer .= '&loginUrl=' . urlencode($loginUrl); } C::t('#qqconnect#common_member_connect')->update($connect_member['uid'], !$_G['setting']['connect']['oauth2'] ? array('conuin' => $conuin, 'conuinsecret' => $conuinsecret, 'conopenid' => $conopenid, 'conisfeed' => 1) : array('conuintoken' => $conuintoken, 'conopenid' => $conopenid, 'conisfeed' => 1)); $params['mod'] = 'login'; connect_login($connect_member); loadcache('usergroups'); $usergroups = $_G['cache']['usergroups'][$_G['groupid']]['grouptitle']; $param = array('username' => $_G['member']['username'], 'usergroup' => $_G['group']['grouptitle']); C::t('common_member_status')->update($connect_member['uid'], array('lastip' => $_G['clientip'], 'lastvisit' => TIMESTAMP, 'lastactivity' => TIMESTAMP)); $ucsynlogin = ''; if ($_G['setting']['allowsynlogin']) { loaducenter(); $ucsynlogin = uc_user_synlogin($_G['uid']); } dsetcookie('stats_qc_login', 3, 86400); header('location: ' . $referer); exit; } else { header('location: ' . $referer . '&loginErr=1001'); exit; } } function connect_login($connect_member) { global $_G; if (!($member = getuserbyuid($connect_member['uid'], 1))) { return false; } else {
function handdl($username, $password, $fs = 1, $rid = 2) { $username = addslashes($username); if (isEmail($username)) { $dlfs = '2'; } else { $dlfs = '0'; } if ($fs == 1) { $res = uc_user_login($username, $password, $dlfs, 0); if ($res['0'] <= 0) { //RES if ($res['0'] == -1) { if ($rid != 1) { return "FALSE"; } else { $remsg['jg'] = "FALSE"; $remsg['username'] = $username; $remsg['txt'] = '用户不存在,或者被删除'; return $remsg; } } elseif ($res['0'] == -2) { if ($rid != 1) { return "FALSE"; } else { $remsg['jg'] = "FALSE"; $remsg['username'] = $username; $remsg['txt'] = '密码错'; return $remsg; } } else { if ($rid != 1) { return "FALSE"; } else { $remsg['jg'] = "FALSE"; $remsg['username'] = $username; $remsg['txt'] = '未定义'; return $remsg; } } //RES } else { $uid = $res['0']; $username = $res['1']; $uemail = $res['3']; echo uc_user_synlogin($uid); if ($rid != 1) { return 'TRUE'; } else { $remsg['jg'] = "TRUE"; $remsg['uid'] = $uid; $remsg['username'] = $username; $remsg['email'] = $uemail; $remsg['txt'] = '登陆成功'; return $remsg; } } } else { if ($fs == 2) { if ($dlfs == '2') { include "../BTSUHAND/dorun/Run_Mysql.php"; $sqluc = mysql_query("SELECT `uid`,`username` FROM `pre_ucenter_members` WHERE `email`='" . $username . "' ", $linka); if (empty($sqluc)) { $remsg['jg'] = "FALSE"; $remsg['username'] = $username; $remsg['txt'] = '用户不存在'; return $remsg; } $infouc = mysql_fetch_object($sqluc); if ($infouc == "") { $remsg['jg'] = "FALSE"; $remsg['username'] = $username; $remsg['txt'] = '用户不存在'; return $remsg; } if (!isset($infouc->uid)) { $remsg['jg'] = "FALSE"; $remsg['username'] = $username; $remsg['txt'] = '用户不存在'; return $remsg; } $username = $infouc->username; } if ($data = uc_get_user($username)) { //list($uid, $username, $email) = $data; $uid = $data['0']; echo uc_user_synlogin($uid); if ($rid != 1) { return "TRUE"; } else { $remsg['jg'] = "TRUE"; $remsg['uid'] = $uid; $remsg['username'] = $username; $remsg['email'] = 'cant'; $remsg['txt'] = '登陆成功'; return $remsg; } } else { if ($rid != 1) { return "FALSE"; } else { $remsg['jg'] = "FALSE"; $remsg['username'] = $username; $remsg['txt'] = '用户不存在'; return $remsg; } } } else { if ($fs == 3) { if ($dlfs == '2') { $umsgi = QCBDUser($username, 4, 'none'); $username = $umsgi['Iusername']; } if ($data = uc_get_user($username)) { //list($uid, $username, $email) = $data; $uid = $data['0']; echo uc_user_synlogin($uid); if ($rid != 1) { return $uid; } else { $remsg['jg'] = "TRUE"; $remsg['uid'] = $uid; $remsg['username'] = $username; $remsg['email'] = $uemail; $remsg['txt'] = '登陆成功'; return $remsg; } } else { if ($rid != 1) { return "FALSE"; } else { $remsg['jg'] = "FALSE"; $remsg['username'] = $username; $remsg['txt'] = '用户不存在'; return $remsg; } } } else { if ($rid != 1) { return "FALSE"; } else { $remsg['jg'] = "FALSE"; $remsg['username'] = $username; $remsg['txt'] = 'Faild!'; return $remsg; } } } } }
} if (!preg_match('/^[A-z]\\w+?$/', $_G['setting']['reginput']['password'])) { $_G['setting']['reginput']['password'] = '******'; } if (!preg_match('/^[A-z]\\w+?$/', $_G['setting']['reginput']['password2'])) { $_G['setting']['reginput']['password2'] = 'password2'; } if (!preg_match('/^[A-z]\\w+?$/', $_G['setting']['reginput']['email'])) { $_G['setting']['reginput']['email'] = 'email'; } $_G['gp_username'] = $_G['gp_' . $_G['setting']['reginput']['username']]; $_G['gp_password'] = $_G['gp_' . $_G['setting']['reginput']['password']]; $_G['gp_password2'] = $_G['gp_' . $_G['setting']['reginput']['password2']]; $_G['gp_email'] = $_G['gp_' . $_G['setting']['reginput']['email']]; if ($_G['uid']) { $ucsynlogin = $_G['setting']['allowsynlogin'] ? uc_user_synlogin($_G['uid']) : ''; showmessage('login_succeed', 'forum.php', array('username' => $_G['member']['username'], 'uid' => $_G['uid']), array('extrajs' => $ucsynlogin)); } elseif (!$_G['setting']['regstatus'] || !$_G['setting']['ucactivation']) { if ($_G['gp_action'] == 'activation' || $_G['gp_activationauth']) { if (!$_G['setting']['ucactivation'] && !$_G['setting']['closedallowactivation']) { showmessage('register_disable_activation'); } } elseif (!$_G['setting']['regstatus']) { showmessage(!$_G['setting']['regclosemessage'] ? 'register_disable' : str_replace(array("\r", "\n"), '', $_G['setting']['regclosemessage'])); } } $inviteconfig = array(); $query = DB::query("SELECT * FROM " . DB::table('common_setting') . " WHERE skey IN ('bbrules', 'bbrulesforce', 'bbrulestxt', 'welcomemsg', 'welcomemsgtitle', 'welcomemsgtxt', 'inviteconfig')"); while ($setting = DB::fetch($query)) { ${$setting}['skey'] = $setting['svalue']; }
function loginsave_action() { $username = yun_iconv("utf-8", "gbk", $_POST['username']); if ($this->uid > 0 && $_COOKIE['username'] != "") { if ($_COOKIE['usertype'] == '1') { $this->ajaxlogin("您现在是个人会员登录状态!"); } elseif ($_COOKIE['usertype'] == '2') { $this->ajaxlogin("您现在是企业会员登录状态!"); } } if ($_POST['path'] != "index") { if (strstr($this->config['code_web'], '前台登陆')) { session_start(); if (md5($_POST['authcode']) != $_SESSION['authcode']) { unset($_SESSION['authcode']); $this->ajaxlogin("验证码错误!"); } } } if (!$this->CheckRegUser($username) && !$this->CheckRegEmail($username)) { $this->ajaxlogin("无效的用户名!"); } if ($username != "") { $Member = $this->MODEL("userinfo"); if ($this->config['sy_uc_type'] == "uc_center") { $this->uc_open(); $uname = $username; list($uid, $username, $password, $email) = uc_user_login($username, $_POST['password']); if ($uid < 1) { $user = $Member->GetMemberOne(array("username" => $uname), array("field" => "username,email,uid,password,salt")); $pass = md5(md5($_POST['password']) . $user['salt']); if ($pass == $user['password']) { $uid = $user['uid']; uc_user_register($user['username'], $_POST['password'], $user['email']); list($uid, $username, $password, $email) = uc_user_login($uname, $_POST['password']); } else { $this->ajaxlogin("账户或密码错误!"); } } else { if ($uid > 0) { $ucsynlogin = uc_user_synlogin($uid); $msg = '登录成功!'; $user = $Member->GetMemberOne(array("username" => $username), array("field" => "`uid`,`usertype`,`email_status`")); if (!empty($user)) { if (session_id() == "") { session_start(); } if ($_SESSION['qq']['openid']) { $Member->UpdateMember(array("qqid" => $_SESSION['qq']['openid']), array("username" => $username)); unset($_SESSION['qq']); } if ($_SESSION['wx']['openid']) { $udate = array('wxopenid' => $_SESSION['wx']['openid']); if ($_SESSION['wx']['unionid']) { $udate['unionid'] = $_SESSION['wx']['unionid']; } $Member->UpdateMember($udate, array("username" => $username)); unset($_SESSION['wx']); } if ($_SESSION['sina']['openid']) { $Member->UpdateMember(array("sinaid" => $_SESSION['sina']['openid']), array("username" => $username)); unset($_SESSION['sina']); } if (!$user['usertype']) { $this->unset_cookie(); $this->addcookie("username", $username, time() + 3600); $this->addcookie("password", $_POST['password'], time() + 3600); $this->ajaxlogin($ucsynlogin, Url("login", array("c" => "utype"), "1"), '3'); } if ($this->config['user_status'] == "1") { if ($user['email_status'] != "1") { $this->ajaxlogin("您的账户还未激活,请先激活!", Url("activate", '', "1")); die; } } if ($_POST['loginname']) { setcookie("loginname", $username, time() + 8640000); } $this->autoupjob($user['uid'], $user['usertype']); } else { $this->unset_cookie(); $this->addcookie("username", $username, time() + 3600); $this->addcookie("password", $_POST['password'], time() + 3600); $this->ajaxlogin($ucsynlogin, Url("login", array("c" => "utype"), "1"), '3'); } $this->ajaxlogin($ucsynlogin, $this->config['sy_weburl'] . "/member", '2'); } elseif ($uid == -1) { $msg = '用户不存在,或者被删除'; } elseif ($uid == -2) { $msg = '密码错误'; } else { $msg = '该用户未定义!'; } } $this->ajaxlogin($ucsynlogin, Url("login", array("c" => "utype"), "1"), '3'); } else { $user = $Member->GetMemberOne(array("username" => $username), array("field" => "`pw_repeat`,`pwuid`,`uid`,`username`,`salt`,`email`,`password`,`usertype`,`status`,`email_status`")); if ($this->config['sy_pw_type'] == "pw_center") { if ($user['pw_repeat'] != "1") { include APP_PATH . "/api/pw_api/pw_client_class_phpapp.php"; $pw = new PwClientAPI($username, $_POST['password'], ""); $pwuser = $pw->user_login(); if ($pwuser['uid'] > 0) { if (empty($user)) { $user = $this->newuser($Member, $pwuser['username'], $pwuser['password'], $pwuser['email'], $user['usertype'], $pwuser['uid'], $qqid); } else { if ($pwuser['uid'] == $user['pwuid']) { $pwrows = $pw->login($pwuser['uid']); $this->add_cookie($user['uid'], $user['username'], $user['salt'], $user['email'], $user['password'], $user['usertype'], $_POST['loginname']); $time = strtotime(date("Y-m-d")); $row = $Member->GetPayinfoOne(array("`com_id`='" . $user['uid'] . "' and `pay_time`>'" . $time . "' and `pay_remark`='会员登录'")); if (empty($row)) { $this->get_integral_action($user['uid'], "integral_login", "会员登录"); } $this->ajaxlogin('登录成功', '', '2'); } else { $Member->UpdateMember(array("pw_repeat" => "1"), array("uid" => $user['uid'])); } } } } } if (is_array($user)) { $pass = md5(md5($_POST['password']) . $user['salt']); if ($user['password'] == $pass) { if ($user['status'] == "2") { $this->ajaxlogin("您的账号已被锁定!", Url("register", array("c" => "ok", "type" => 2), "1")); } if ($user['usertype'] == "2" && $this->config['com_status'] != "1" && $user['status'] != "1") { $this->ajaxlogin("您还没有通过审核!", Url("register", array("c" => "ok", "type" => 3), "1")); } if ($this->config['user_status'] == "1" && $user['usertype'] == "1" && $user['email_status'] != "1") { $this->ajaxlogin("您的账户还未激活,请先激活!", Url("activate", '', "1")); } if (session_id() == "") { session_start(); } if ($_SESSION['qq']['openid']) { $Member->UpdateMember(array("qqid" => $_SESSION['qq']['openid']), array("username" => $username)); unset($_SESSION['qq']); } if ($_SESSION['wx']['openid']) { $udate = array('wxopenid' => $_SESSION['wx']['openid']); if ($_SESSION['wx']['unionid']) { $udate['unionid'] = $_SESSION['wx']['unionid']; } $Member->UpdateMember($udate, array("username" => $username)); unset($_SESSION['wx']); } if ($_SESSION['sina']['openid']) { $Member->UpdateMember(array("sinaid" => $_SESSION['sina']['openid']), array("username" => $username)); unset($_SESSION['sina']); } $time = time(); $ip = fun_ip_get(); $Member->UpdateMember(array("login_ip" => $ip, "login_date" => $time, "login_hits" => "`login_hits`+1"), array("uid" => $user['uid'])); $this->unset_cookie(); $this->add_cookie($user['uid'], $user['username'], $user['salt'], $user['email'], $user['password'], $user['usertype'], $_POST['loginname']); $time = strtotime(date("Y-m-d")); $row = $Member->GetPayinfoOne(array("`com_id`='" . $user['uid'] . "' and `pay_time`>'" . $time . "' and `pay_remark`='会员登录'")); if (empty($row)) { $this->get_integral_action($user['uid'], "integral_login", "会员登录"); } if ($qqid) { $Member->UpdateMember(array("qqid" => $qqid, "username" => $username), array("uid" => $user['uid'])); } if ($user['usertype'] == '1') { $Resume = $this->MODEL("resume"); $info = $Resume->SelectResumeOne(array("uid" => $user['uid']), "`name`,`birthday`"); } else { if ($user['usertype'] == '2') { $Company = $this->MODEL("company"); $info = $Company->GetCompanyInfo(array("uid" => $user['uid']), array("field" => 'name')); $this->autoupjob($user['uid'], $user['usertype']); } } if ($info['name']) { $this->ajaxlogin('登录成功', $this->config['sy_weburl'] . "/member", '1'); } else { if ($info['name'] == '') { $this->ajaxlogin('登录成功', $this->config['sy_weburl'] . "/member/index.php?c=info", '1'); } } } else { $this->ajaxlogin("密码不正确!"); } } else { $this->ajaxlogin("该用户不存在!"); } } } else { $this->ajaxlogin("用户名不能为空!"); } }
//实名 realname_set($space['uid'], $space['username'], $space['name'], $space['namestatus']); //检索当前用户 $query = $_SGLOBAL['db']->query("SELECT password FROM " . tname('member') . " WHERE uid='{$setarr['uid']}'"); if ($value = $_SGLOBAL['db']->fetch_array($query)) { $setarr['password'] = addslashes($value['password']); } else { //更新本地用户库 inserttable('member', $setarr, 0, true); } //清理在线session insertsession($setarr); //同步登录 if ($_SCONFIG['uc_status']) { include_once S_ROOT . './uc_client/client.php'; $ucsynlogin = uc_user_synlogin($setarr['uid']); } else { $ucsynlogin = ''; } //好友邀请 if ($invitearr) { //成为好友 invite_update($invitearr['id'], $setarr['uid'], $setarr['username'], $invitearr['uid'], $invitearr['username'], $app); } $_SGLOBAL['supe_uid'] = $space['uid']; //判断用户是否设置了头像 $reward = $setarr = array(); $experience = $credit = 0; $avatar_exists = ckavatar($space['uid']); if ($avatar_exists) { if (!$space['avatar']) {
if (!empty($_GET['submit'])) { if (stripos($_POST['username'], "@")) { list($uid, $username, $password, $email) = uc_user_login($_POST['username'], $_POST['password'], 2); } else { //通过接口判断登录帐号的正确性,返回值为数组 list($uid, $username, $password, $email) = uc_user_login($_POST['username'], $_POST['password']); } setcookie('Cta_auth', '', -86400); if ($uid > 0) { if (!$db->result_first("SELECT count(*) FROM {$tablepre}members WHERE uid='{$uid}'")) { //判断用户是否存在于用户表,不存在则跳转到激活页面 $auth = rawurlencode(uc_authcode("{$username}\t" . time(), 'ENCODE')); echo '您需要需要激活该帐号,才能进入本应用程序<br><a href="' . $_SERVER['PHP_SELF'] . '?fun=register&action=activation&auth=' . $auth . '">继续</a>'; exit; } $imei = $db->result_first("SELECT imei FROM {$tablepre}members_imei WHERE uid='{$uid}'"); //用户登陆成功,设置 Cookie,加密直接用 uc_authcode 函数,用户使用自己的函数 // setcookie('Cta_auth', uc_authcode($uid . "\t" . $username . "\t" . $imei, 'ENCODE')); //生成同步登录的代码 $ucsynlogin = uc_user_synlogin($uid); echo '登录成功' . $ucsynlogin . '<br><a href="' . $_SERVER['PHP_SELF'] . '">继续</a>'; exit; } elseif ($uid == -1) { echo '用户不存在,或者被删除'; } elseif ($uid == -2) { echo '密码错'; } else { echo '未定义'; } }
/** * UC登录或者注册 * @param string $username * @param string $password * @param string $is_remember_me 是否记住登录 * @return bool */ private function ucLogin($username, $password, $is_remember_me) { //载入UC客户端SDK include_once SITE_PATH . '/api/uc_client/client.php'; //1. 获取UC信息. if ($this->isValidEmail($username)) { $use_email = true; $uc_login_type = 2; } else { $use_email = false; $uc_login_type = 0; } $uc_user = uc_user_login($username, $password, $uc_login_type); //2. 已经同步过的直接登录 $uc_user_ref = ts_get_ucenter_user_ref('', $uc_user['0'], ''); if ($uc_user_ref['uid'] && $uc_user_ref['uc_uid'] && $uc_user[0] > 0) { //登录本地帐号 $result = $uc_user_ref['uid'] > 0 ? $this->_recordLogin($uc_user_ref['uid'], $is_remember_me) : false; if ($result) { $this->success .= uc_user_synlogin($uc_user[0]); return true; } else { $this->error = '登录失败,请重试'; return false; } } //3. 关联表无、获取本地帐号信息. $ts_user = $this->getLocalUser($username, $password); // 调试用-写log // $log_message = "============================ \n " // .date('Y-m-d H:i:s')." \n ".$_SERVER['REQUEST_URI']." \n " // .var_export($uc_user,true)." \n " // .var_export($ts_user,true)." \n " // .var_export($uc_user_ref,true)." \n "; // $log_file = SITE_PATH."/ts_uc_log.txt"; // $result = error_log($log_message,3,$log_file); //4. 关联表无、UC有、本地有的 if ($uc_user[0] > 0 && $ts_user['uid'] > 0) { $result = ts_add_ucenter_user_ref($ts_user['uid'], $uc_user[0], $uc_user[1], $uc_user[3]); if (!$result) { $this->error = '用户不存在或密码错误'; return false; } //登录本地帐号 $result = $this->_recordLogin($ts_user['uid'], $is_remember_me); if ($result) { $this->success .= uc_user_synlogin($uc_user[0]); return true; } else { $this->error = '登录失败,请重试'; return false; } } //5. 关联表无、UC有、本地无的 if ($uc_user[0] > 0 && !$ts_user['uid']) { //写入本地系统 $login_salt = rand(11111, 99999); $map['uname'] = $uc_user[1]; $map['sex'] = 1; $map['login_salt'] = $login_salt; $map['password'] = md5(md5($uc_user[2]) . $login_salt); $map['login'] = $map['email'] = $uc_user[3]; $map['reg_ip'] = get_client_ip(); $map['ctime'] = time(); $map['is_audit'] = 1; $map['is_active'] = 1; $map['first_letter'] = getFirstLetter($uname); //如果包含中文将中文翻译成拼音 if (preg_match('/[\\x7f-\\xff]+/', $map['uname'])) { //昵称和呢称拼音保存到搜索字段 $map['search_key'] = $map['uname'] . ' ' . model('PinYin')->Pinyin($map['uname']); } else { $map['search_key'] = $map['uname']; } $ts_uid = model('User')->add($map); if (!$ts_uid) { $this->error = '本地用户注册失败,请联系管理员'; return false; } //写入关联表 $result = ts_add_ucenter_user_ref($ts_uid, $uc_user[0], $uc_user[1], $uc_user[3]); if (!$result) { $this->error = '用户不存在或密码错误'; return false; } // 添加至默认的用户组 $registerConfig = model('Xdata')->get('admin_Config:register'); $userGroup = empty($registerConfig['default_user_group']) ? C('DEFAULT_GROUP_ID') : $registerConfig['default_user_group']; model('UserGroupLink')->domoveUsergroup($ts_uid, implode(',', $userGroup)); // 添加双向关注用户 $eachFollow = $registerConfig['each_follow']; if (!empty($eachFollow)) { model('Follow')->eachDoFollow($ts_uid, $eachFollow); } // 添加默认关注用户 $defaultFollow = $registerConfig['default_follow']; $defaultFollow = array_diff(explode(',', $defaultFollow), explode(',', $eachFollow)); if (!empty($defaultFollow)) { model('Follow')->bulkDoFollow($ts_uid, $defaultFollow); } //登录本地帐号 $result = $this->_recordLogin($ts_uid, $is_remember_me); if ($result) { $this->success .= uc_user_synlogin($uc_user[0]); return true; } else { $this->error = '登录失败,请重试'; return false; } } //6. 关联表无、UC无、本地有 if ($uc_user[0] < 0 && $ts_user['uid'] > 0) { //写入UC $uc_uid = uc_user_register($ts_user['uname'], $password, $ts_user['email'], '', '', get_client_ip()); if ($uc_uid > 0) { $this->error = 'UC帐号注册失败,请联系管理员'; return false; } //写入关联表 $result = ts_add_ucenter_user_ref($ts_user['uid'], $uc_uid, $ts_user['uname'], $ts_user['email']); if (!$result) { $this->error = '用户不存在或密码错误'; return false; } //登录本地帐号 $result = $this->_recordLogin($ts_user['uid'], $is_remember_me); if ($result) { $this->success .= uc_user_synlogin($uc_uid); return true; } else { $this->error = '登录失败,请重试'; return false; } } //7. 关联表无、UC无、本地无的 $this->error = '用户不存在'; return false; }
function dologin() { if ($_SESSION['_verify_']['verify'] != strtolower($_POST['verify'])) { $this->error("验证码错误!"); } $users_model = M("Users"); $rules = array(array('terms', 'require', '您未同意服务条款!', 1), array('username', 'require', '用户名或者邮箱不能为空!', 1), array('password', 'require', '密码不能为空!', 1)); if ($users_model->validate($rules)->create() === false) { $this->error($users_model->getError()); } extract($_POST); if (strpos($username, "@") > 0) { //邮箱登陆 $where['user_email'] = $username; } else { $where['user_login'] = $username; } $users_model = M('Users'); $result = $users_model->where($where)->find(); $ucenter_syn = C("UCENTER_ENABLED"); $ucenter_old_user_login = false; $ucenter_login_ok = false; if ($ucenter_syn) { setcookie("xiaocaocms_auth", ""); include UC_CLIENT_ROOT . "client.php"; list($uc_uid, $username, $password, $email) = uc_user_login($username, $password); if ($uc_uid > 0) { if (!$result) { $data = array('user_login' => $username, 'user_email' => $email, 'user_pass' => sp_password($password), 'last_login_ip' => get_client_ip(), 'create_time' => time(), 'last_login_time' => time(), 'user_status' => '1'); $id = $users_model->add($data); $data['id'] = $id; $result = $data; } } else { switch ($uc_uid) { case "-1": //用户不存在,或者被删除 if ($result) { //本应用已经有这个用户 if ($result['user_pass'] == sp_password($password)) { //本应用已经有这个用户,且密码正确,同步用户 $uc_uid2 = uc_user_register($username, $password, $result['user_email']); if ($uc_uid2 < 0) { $uc_register_errors = array("-1" => "用户名不合法", "-2" => "包含不允许注册的词语", "-3" => "用户名已经存在", "-4" => "Email格式有误", "-5" => "Email不允许注册", "-6" => "该Email已经被注册"); $this->error("同步用户失败--" . $uc_register_errors[$uc_uid2]); } $uc_uid = $uc_uid2; } else { $this->error("密码错误!"); } } break; case -2: //密码错 if ($result) { //本应用已经有这个用户 if ($result['user_pass'] == sp_password($password)) { //本应用已经有这个用户,且密码正确,同步用户 $uc_user_edit_status = uc_user_edit($username, "", $password, "", 1); if ($uc_user_edit_status <= 0) { $this->error("登陆错误!"); } list($uc_uid2) = uc_get_user($username); $uc_uid = $uc_uid2; $ucenter_old_user_login = true; } else { $this->error("密码错误!"); } } else { $this->error("密码错误!"); } break; } } $ucenter_login_ok = true; echo uc_user_synlogin($uc_uid); } //exit(); if ($result != null) { if ($result['user_pass'] == sp_password($password) || $ucenter_login_ok) { $_SESSION["user"] = $result; //写入此次登录信息 $data = array('last_login_time' => date("Y-m-d H:i:s"), 'last_login_ip' => get_client_ip()); $users_model->where("id=" . $result["id"])->save($data); $redirect = empty($_SESSION['login_http_referer']) ? __ROOT__ . "/" : $_SESSION['login_http_referer']; $_SESSION['login_http_referer'] = ""; $ucenter_old_user_login_msg = ""; if ($ucenter_old_user_login) { //$ucenter_old_user_login_msg="老用户请在跳转后,再次登陆"; } $this->success("登录验证成功!", $redirect); } else { $this->error("密码错误!"); } } else { $this->error("用户名不存在!"); } }
function AuthCallback() { $this->_check_oauth2(); if (!$this->Code) { $this->Messager('未定义的操作', null); } $last_keys = $this->_get_last_keys(); if (!$last_keys) { $this->Messager("新浪微博返回内容为空,启用OAuth2.0接口,需要您的服务器支持OpenSSL,请检查……"); } if ($last_keys['error_code']) { $last_keys = array_iconv('UTF-8', $this->Config['charset'], $last_keys); $this->Messager("[{$last_keys['error_code']}]{$last_keys['error']}", null); } if (!$last_keys['access_token']) { $this->Messager('请求错误', null); } $rets = $this->_get_uid($last_keys['access_token']); if ($rets['error_code']) { $this->Messager("[{$rets['error_code']}]{$rets['error']}", null); } if (!$rets['uid']) { $this->Messager('获取用户信息失败', null); } $last_uid = $rets['uid']; $xwb_bind_info = DB::fetch_first("select * from " . DB::table('xwb_bind_info') . " where `sina_uid`='{$last_uid}'"); if ($xwb_bind_info) { if (false != ($user_info = $this->_user_login($xwb_bind_info['uid']))) { if ($xwb_bind_info['access_token'] != $last_keys['access_token'] || $xwb_bind_info['expires_in'] != $last_keys['expires_in']) { DB::query("update " . DB::table('xwb_bind_info') . " set\r\n \t\t\t`access_token`='{$last_keys['access_token']}',\r\n \t\t\t`expires_in`='{$last_keys['expires_in']}',\r\n \t\t\t`dateline`='" . TIMESTAMP . "'\r\n \t\t\twhere `sina_uid`='{$last_uid}'"); } if (true === UCENTER && ($ucuid = (int) $user_info['ucuid']) > 0) { include_once ROOT_PATH . './api/uc_client/client.php'; $uc_syn_html = uc_user_synlogin($ucuid); $this->Messager("登录成功,正在为您跳转到首页。{$uc_syn_html}", $this->Config['site_url'], 5); } $this->Messager(null, $this->Config['site_url']); } else { DB::query("delete from " . DB::table('xwb_bind_info') . " where `sina_uid`='{$last_uid}'"); $this->Messager("绑定的用户已经不存在了", $this->Config['site_url']); } } else { $bind_info = $this->_get_info($last_uid, $last_keys['access_token']); $bind_info = array_iconv('utf-8', $this->Config['charset'], $bind_info); $bind_info = array_merge($bind_info, $last_keys); if (MEMBER_ID > 0) { $this->_bind(MEMBER_ID, $bind_info, $last_keys); $this->Messager(null, $this->Config['site_url']); } else { $hash = authcode(md5($bind_info['id'] . $bind_info['access_token']), 'ENCODE'); $reg = array(); $reg['username'] = $bind_info['domain']; $reg['email'] = $bind_info['email']; $reg['nickname'] = $bind_info['screen_name']; if ($this->module_config['is_sync_face']) { $reg['face'] = $bind_info['avatar_large']; } $this->Title = '新浪微博帐号绑定'; include template('bind/bind_info_xwb'); } } }
} $password = md5($uid . '|' . random(8)); $groupid = 2; $dateline = $_SGLOBAL['timestamp']; $updatetime = $_SGLOBAL['timestamp']; } $insertsqlarr = array('uid' => $uid, 'username' => addslashes($members['username']), 'password' => $password, 'groupid' => $groupid, 'email' => $email, 'dateline' => $dateline, 'updatetime' => $updatetime, 'lastlogin' => $_SGLOBAL['timestamp'], 'ip' => $_SGLOBAL['onlineip']); if (empty($oldmember)) { inserttable('members', $insertsqlarr); } else { updatetable('members', $insertsqlarr, array('uid' => $_SGLOBAL['supe_uid'])); } $cookievalue = authcode("{$password}\t{$uid}", 'ENCODE'); ssetcookie('auth', $cookievalue, $cookietime); setcookie('_refer', ''); $msg = $lang['login_succeed'] . uc_user_synlogin($members['uid']); showmessage($msg, rawurldecode($refer)); } break; case 'logout': obclean(); sclearcookie(); setcookie('_refer', ''); $msg = $lang['logout_succeed'] . uc_user_synlogout(); $_SGLOBAL['db']->query("DELETE FROM " . tname('adminsession') . " WHERE uid='{$_SGLOBAL['supe_uid']}'"); showmessage($msg, rawurldecode($refer)); break; default: break; } setcookie('_refer', '');
function sync_login($uc_uid) { return uc_user_synlogin($uc_uid); }
/** * 注册会员 验证 * * @param array $data 会员数据 * @return int * int uid 注册成功 * int -1 会员名称已经存在 * int -2 Email格式有误 * int -3 Email已经被注册 * int -4 同一IP注册限制 * int -5 Ucenter 会员名不合法 * int -6 Ucenter 包含不允许注册的词语 * int -7 Ucenter Email 格式有误 * int -8 Ucenter Email 不允许注册 * int -9 Ucenter Email 已经被注册 */ public function register($data, $groupid = NULL, $uid = NULL) { $setting = $this->ci->get_cache('member', 'setting'); $this->ucsynlogin = $this->synlogin = ''; if (!IS_ADMIN && !$uid && $setting['regiptime'] && $this->db->where('regip', $this->input->ip_address())->where('regtime>', SYS_TIME - 3600 * $setting['regiptime'])->count_all_results('member')) { return -4; } if (!$data['email'] || !preg_match('/^[\\w\\-\\.]+@[\\w\\-\\.]+(\\.\\w+)+$/', $data['email'])) { return -2; } if ($this->db->where('email', $data['email'])->count_all_results('member')) { return -3; } if ($this->db->where('username', $data['username'])->count_all_results('member')) { return -1; } if ($setting['ucenter'] && uc_get_user($data['username'])) { return -1; } // Ucenter 注册判断 if ($setting['ucenter']) { $ucid = uc_user_register($data['username'], $data['password'], $data['email']); if ($ucid == -1) { return -5; } elseif ($ucid == -2) { return -6; } elseif ($ucid == -4) { return -7; } elseif ($ucid == -5) { return -8; } elseif ($ucid == -6) { return -9; } $this->ucsynlogin = uc_user_synlogin($ucid); } return $this->_register($data, NULL, $groupid, $uid); }