本文整理汇总了PHP中uc_user_synlogin函数的典型用法代码示例。如果您正苦于以下问题:PHP uc_user_synlogin函数的具体用法?PHP uc_user_synlogin怎么用?PHP uc_user_synlogin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uc_user_synlogin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dologin
public function dologin()
{
if ($this->user['id']) {
// $this->Redirect('','','',1);
}
$request_name = 'username';
$request_password = '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']);
}
}
示例2: register
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>');
}
}
示例3: authenticateUC
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;
}
示例4: index
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');
}
示例5: userLogin
/**
* 写入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 '';
}
示例6: syncLogin
/**
* 同步登陆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}");
}
示例7: show
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']);
}
}
示例8: zuitu_uc_synlogin
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;');
}
示例9: API_Login
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';
}
示例10: login
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;
}
}
示例11: UcenterLogin
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;
}
示例12: login
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;
}
示例13: create
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);
}
示例14: on_login
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']));
}
}
}
示例15: _do_email_login
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("用户名不存在!");
}
}