本文整理汇总了PHP中uc_user_login函数的典型用法代码示例。如果您正苦于以下问题:PHP uc_user_login函数的具体用法?PHP uc_user_login怎么用?PHP uc_user_login使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uc_user_login函数的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: jieqi_logincheck
/**
* 验证登录账号、密码、验证码,同过的话进行登录处理
*
* @param string $username 用户名
* @param string $password 密码
* @param string $checkcode 验证码
* @param int $usecookie 是否记录到cookie,下次自动登录。0表示不记录,大于0表示cookie保存时间
* @param bool $encode 密码是否已经加密,默认否
* @param bool $needcheck 是否需要验证码,默认是
* @access public
* @return int 0 正常, -1 用户名为空 -2 密码为空 -3 用户名或者密码为空 -4 用户名不存在 -5 密码错误 -6 用户名或密码错误 -7 验证码错误 -8 帐号已经有人登陆 -9 用户属于游客组
*/
function jieqi_logincheck($username = '', $password = '', $checkcode = '', $usecookie = 0, $encode = false, $needcheck = true)
{
$ret = jieqi_loginpass($username, $password, $checkcode, $usecookie, $encode, $needcheck);
if (is_object($ret)) {
return jieqi_loginprocess($ret, $usecookie);
} elseif ($ret == -10) {
//临时用户,未设置密码,ucenter存在时候自动更新密码,否则返回密码错误
include_once JIEQI_ROOT_PATH . '/include/funuser.php';
if (function_exists('uc_user_login')) {
list($uid, $uname, $upass, $uemail) = uc_user_login($username, $password);
if ($uid > 0) {
include_once JIEQI_ROOT_PATH . '/class/users.php';
$users_handler =& JieqiUsersHandler::getInstance('JieqiUsersHandler');
$userobj = $users_handler->getByname($username);
if (is_object($userobj)) {
$userobj->setVar('pass', $users_handler->encryptPass($upass));
$userobj->setVar('email', $uemail);
$users_handler->insert($userobj);
return jieqi_loginprocess($userobj, $usecookie);
}
}
}
return -5;
} else {
return $ret;
}
}
示例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: login
/**
* 用户登录认证
* @param string $username 用户名
* @param string $password 用户密码
* @param integer $type 用户名类型 (1-用户名,2-邮箱,3-手机,4-UID)
* @return integer 登录成功-用户ID,登录失败-错误编号
*/
public function login($username, $password, $type = 1)
{
if (file_exists('./api/uc_login.lock')) {
include_once './api/uc_client/client.php';
if (strtolower(UC_CHARSET) == 'gbk') {
$username = iconv('UTF-8', 'GBK', $username);
}
$uc_user = uc_user_login($username, $password, 0);
if ($uc_user[0] == -2) {
return '密码错误';
} elseif ($uc_user[0] == -1) {
return '用户不存在,或者被删除';
} elseif ($uc_user[0] > 0) {
if (strtolower(UC_CHARSET) == 'gbk') {
$uc_user[1] = iconv('GBK', 'UTF-8', $uc_user[1]);
}
D('member')->where(array('uid' => $uc_user[0]))->setField('nickname', $uc_user[1]);
D('ucenter_member')->where(array('id' => $uc_user[0]))->setField('username', $uc_user[1]);
return $uc_user[0];
}
} else {
if (UC_SYNC && $username != get_username(1)) {
return $this->ucLogin($username, $password);
}
return $this->model->login($username, $password, $type);
}
}
示例5: login
function login($username, $password)
{
$tuser = $_ENV['user']->get_by_username($username);
$ucenter_user = uc_get_user($username);
if (!$ucenter_user && ($tuser['username'] == $username && $password == $tuser['password'])) {
$uid = uc_user_register($tuser['username'], $this->base->post['password'], $tuser['email']);
$this->db->query("UPDATE " . DB_TABLEPRE . "user SET uid={$uid} WHERE uid=" . $tuser['uid']);
}
//通过接口判断登录帐号的正确性,返回值为数组
list($uid, $username, $password, $email) = uc_user_login($username, $password);
if ($uid > 0) {
$user = $this->db->fetch_first("SELECT * FROM " . DB_TABLEPRE . "user WHERE uid='{$uid}'");
if (!$user) {
$_ENV['user']->add($username, $password, $email, $uid);
}
if ($user['password'] != $password) {
$this->db->query("UPDATE " . DB_TABLEPRE . "user SET password='{$password}' WHERE uid={$uid}");
}
$_ENV['user']->refresh($uid);
//生成同步登录的代码
$ucsynlogin = uc_user_synlogin($uid);
$this->base->message('登录成功!' . $ucsynlogin . '<br><a href="' . $_SERVER['PHP_SELF'] . '">继续</a>');
} elseif ($uid == -1) {
$this->base->message('用户不存在,或者被删除!');
} elseif ($uid == -2) {
$this->base->message('密码错误!');
} else {
$this->base->message('未定义!');
}
}
示例6: userlogin
function userlogin($username, $password, $questionid, $answer, $loginfield = 'username')
{
$return = array();
if ($loginfield == 'uid') {
$isuid = 1;
} elseif ($loginfield == 'email') {
$isuid = 2;
} elseif ($loginfield == 'auto') {
$isuid = 3;
} else {
$isuid = 0;
}
if (!function_exists('uc_user_login')) {
loaducenter();
}
if ($isuid == 3) {
if (preg_match('/^[1-9]\\d*$/', $username)) {
$return['ucresult'] = uc_user_login($username, $password, 1, 1, $questionid, $answer);
} elseif (isemail($username)) {
$return['ucresult'] = uc_user_login($username, $password, 2, 1, $questionid, $answer);
}
if ($return['ucresult'][0] <= 0) {
$return['ucresult'] = uc_user_login($username, $password, 0, 1, $questionid, $answer);
}
} else {
$return['ucresult'] = uc_user_login($username, $password, $isuid, 1, $questionid, $answer);
}
$tmp = array();
$duplicate = '';
list($tmp['uid'], $tmp['username'], $tmp['password'], $tmp['email'], $duplicate) = daddslashes($return['ucresult'], 1);
$return['ucresult'] = $tmp;
if ($duplicate && $return['ucresult']['uid'] > 0) {
if ($olduid = DB::result_first("SELECT uid FROM " . DB::table('common_member') . " WHERE username='" . addslashes($return['ucresult']['username']) . "'")) {
require_once libfile('function/membermerge');
if ($olduid != $return['ucresult']['uid']) {
membermerge($olduid, $return['ucresult']['uid']);
}
uc_user_merge_remove($return['ucresult']['username']);
} else {
$return['status'] = 0;
return $return;
}
}
if ($return['ucresult']['uid'] <= 0) {
$return['status'] = 0;
return $return;
}
$member = DB::fetch_first("SELECT * FROM " . DB::table('common_member') . " WHERE uid='" . $return['ucresult']['uid'] . "'");
if (!$member) {
$return['status'] = -1;
return $return;
}
$return['member'] = $member;
$return['status'] = 1;
if (addslashes($member['email']) != $return['ucresult']['email']) {
DB::query("UPDATE " . DB::table('common_member') . " SET email='" . $return['ucresult']['email'] . "' WHERE uid='" . $return['ucresult']['uid'] . "'");
}
return $return;
}
示例7: checkPassword
/**
* Check if the password is correct without logging in the user
*
* @param string $uid The username
* @param string $password The password
*
* @return true/false
*/
public function checkPassword($uid, $password)
{
$result = uc_user_login($uid, $password);
if ($result[0] > 0) {
$this->storeUser($uid);
return $uid;
} else {
return false;
}
}
示例8: userlogin
function userlogin()
{
global $db, $tablepre, $_DCACHE, $ucresult, $username, $password, $questionid, $answer, $loginfield;
require_once DISCUZ_ROOT . './uc_client/client.php';
if ($loginfield == 'uid') {
$isuid = 1;
} elseif ($loginfield == 'email') {
$isuid = 2;
} else {
$isuid = 0;
}
$ucresult = uc_user_login($username, $password, $isuid, 1, $questionid, $answer);
list($tmp['uid'], $tmp['username'], $tmp['password'], $tmp['email'], $duplicate) = daddslashes($ucresult, 1);
$ucresult = $tmp;
if ($duplicate && $ucresult['uid'] > 0) {
if ($olduid = $db->result_first("SELECT uid FROM {$tablepre}members WHERE username='" . addslashes($ucresult['username']) . "'")) {
require_once DISCUZ_ROOT . './include/membermerge.func.php';
membermerge($olduid, $ucresult['uid']);
uc_user_merge_remove($ucresult['username']);
} else {
return 0;
}
}
if ($ucresult['uid'] <= 0) {
return 0;
}
$member = $db->fetch_first("SELECT m.uid AS discuz_uid, m.username AS discuz_user, m.password AS discuz_pw, m.secques AS discuz_secques,\r\n\t\tm.email, m.adminid, m.groupid, m.styleid, m.lastvisit, m.lastpost, u.allowinvisible\r\n\t\tFROM {$tablepre}members m LEFT JOIN {$tablepre}usergroups u USING (groupid)\r\n\t\tWHERE m.uid='{$ucresult['uid']}'");
if (!$member) {
return -1;
}
$member['discuz_userss'] = $member['discuz_user'];
$member['discuz_user'] = addslashes($member['discuz_user']);
foreach ($member as $var => $value) {
$GLOBALS[$var] = $value;
}
if (addslashes($member['email']) != $ucresult['email']) {
$db->query("UPDATE {$tablepre}members SET email='{$ucresult['email']}' WHERE uid='{$ucresult['uid']}'");
}
if ($questionid > 0 && empty($member['discuz_secques'])) {
$GLOBALS['discuz_secques'] = random(8);
$db->query("UPDATE {$tablepre}members SET secques='{$GLOBALS['discuz_secques']}' WHERE uid='{$ucresult['uid']}'");
}
$GLOBALS['styleid'] = $member['styleid'] ? $member['styleid'] : $_DCACHE['settings']['styleid'];
$cookietime = intval(isset($_POST['cookietime']) ? $_POST['cookietime'] : 0);
dsetcookie('cookietime', $cookietime, 31536000);
dsetcookie('auth', authcode("{$member['discuz_pw']}\t{$member['discuz_secques']}\t{$member['discuz_uid']}", 'ENCODE'), $cookietime, 1, true);
dsetcookie('loginuser');
dsetcookie('activationauth');
dsetcookie('pmnum');
$GLOBALS['sessionexists'] = 0;
if ($_DCACHE['settings']['frameon'] && $_DCOOKIE['frameon'] == 'yes') {
$GLOBALS['extrahead'] .= '<script>if(top != self) {parent.leftmenu.location.reload();}</script>';
}
return 1;
}
示例9: userlogin
function userlogin($username, $password, $questionid, $answer, $loginfield = 'username', $ip = '') {
$return = array();
if($loginfield == 'uid' && getglobal('setting/uidlogin')) {
$isuid = 1;
} elseif($loginfield == 'email') {
$isuid = 2;
} elseif($loginfield == 'auto') {
$isuid = 3;
} else {
$isuid = 0;
}
if(!function_exists('uc_user_login')) {
loaducenter();
}
if($isuid == 3) {
if(!strcmp(dintval($username), $username) && getglobal('setting/uidlogin')) {
$return['ucresult'] = uc_user_login($username, $password, 1, 1, $questionid, $answer, $ip);
} elseif(isemail($username)) {
$return['ucresult'] = uc_user_login($username, $password, 2, 1, $questionid, $answer, $ip);
}
if($return['ucresult'][0] <= 0 && $return['ucresult'][0] != -3) {
$return['ucresult'] = uc_user_login(addslashes($username), $password, 0, 1, $questionid, $answer, $ip);
}
} else {
$return['ucresult'] = uc_user_login(addslashes($username), $password, $isuid, 1, $questionid, $answer, $ip);
}
$tmp = array();
$duplicate = '';
list($tmp['uid'], $tmp['username'], $tmp['password'], $tmp['email'], $duplicate) = $return['ucresult'];
$return['ucresult'] = $tmp;
if($duplicate && $return['ucresult']['uid'] > 0 || $return['ucresult']['uid'] <= 0) {
$return['status'] = 0;
return $return;
}
$member = getuserbyuid($return['ucresult']['uid'], 1);
if(!$member || empty($member['uid'])) {
$return['status'] = -1;
return $return;
}
$return['member'] = $member;
$return['status'] = 1;
if($member['_inarchive']) {
C::t('common_member_archive')->move_to_master($member['uid']);
}
if($member['email'] != $return['ucresult']['email']) {
C::t('common_member')->update($return['ucresult']['uid'], array('email' => $return['ucresult']['email']));
}
return $return;
}
示例10: login
/**
* 会员登陆
*
* @param string $username
* @param string $password
* @return array|string
*/
public function login($username, $password)
{
list($uid, $username, $password, $email) = uc_user_login($username, $password);
if ($uid > 0) {
return array('uid' => $uid, 'username' => $username, 'password' => $password, 'email' => $email);
} elseif ($uid == -1) {
return '用户不存在,或者被删除';
} elseif ($uid == -2) {
return '密码错误';
} elseif ($uid == -3) {
return '安全提问错误';
} else {
return '未定义';
}
}
示例11: 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;');
}
示例12: 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';
}
示例13: verify
/**
* 进行身份验证
* 请保证传参所用字符集和论坛字符集一致,否则请先自行转换再传参
* @param string $username
* @param string $password
* @param int $questionid
* @param string $answer
* @param boolen $isuid 使用UID验证么?
* @return array
* 第一个数组下标($return[0])若大于0,则表示验证成功的登录uid。否则为错误信息:
* -1:UC用户不存在,或者被删除
* -2:密码错
* -3:安全提问错
* -4:用户没有在dz注册
* 第二个数组下标($return[1])若大于等于0,则表示验证成功的adminid;
* 否则为-1,表示验证失败
*/
function verify($username, $password, $questionid = '', $answer = '', $isuid = 0)
{
$return = array(0 => -1, 1 => -1);
$ip = XWB_plugin::getIP();
/**
* 校验用户输入错误密码的次数
*/
$failedlogins = $this->db->fetch_first("select * from " . XWB_S_TBPRE . "failedlogins where `ip`='{$ip}'");
if ($failedlogins && $failedlogins['count'] >= 5) {
$return[0] = -5;
return $return;
}
/**
* 校验用户输入的用户名和密码是否正确
*/
if (true === UCENTER) {
//加载Ucenter客户端文件
include_once ROOT_PATH . './api/uc_client/client.php';
$uc_result = uc_user_login($username, $password, $isuid, 0, $questionid, $answer);
$ucuid = $uc_result[0];
if ($ucuid < 1) {
$return[0] = $ucuid;
return $return;
}
}
$member = $this->db->fetch_first("SELECT `uid`, `password`, `nickname`, `username`, `role_type`, `salt` FROM " . XWB_S_TBPRE . "members WHERE `nickname`='{$username}'");
if ($member) {
/**
* 在记事狗系统中比对用户输入的密码
*/
if ($member['password'] == jsg_member_password($password, $member['salt'])) {
$return[0] = (int) $member['uid'];
$return[1] = 'admin' == $member['role_type'] ? 1 : 0;
} else {
$return[0] = -2;
/**
* 更新密码输入错误的次数
*/
if ($failedlogins) {
$this->db->query("update " . XWB_S_TBPRE . "failedlogins set `count`='" . (max(1, (int) $failedlogins['count']) + 1) . "', `lastupdate`='" . time() . "' where `ip`='{$ip}'");
} else {
$this->db->query("insert into " . XWB_S_TBPRE . "failedlogins (`ip`,`count`,`lastupdate`) values ('{$ip}','1','" . time() . "')");
}
}
}
return $return;
}
示例14: 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;
}
}
示例15: authenticate
/**
* Authenticates a user.
* The example implementation makes sure if the username and password
* are both 'demo'.
* In practical applications, this should be changed to authenticate
* against some persistent user identity storage (e.g. database).
* @return boolean whether authentication succeeds.
*/
public function authenticate()
{
//Ucenter 登录
Yii::import('application.vendor.*');
require_once 'ucenter.php';
list($uid, $username, $password, $email) = uc_user_login($this->username, $this->password);
if ($uid > 0) {
$this->errorCode = self::ERROR_NONE;
} elseif ($uid == -1) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
} elseif ($uid == -2) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
} else {
$this->errorCode = self::ERROR_UNKNOWN_IDENTITY;
}
return !$this->errorCode;
}