本文整理汇总了PHP中uc_authcode函数的典型用法代码示例。如果您正苦于以下问题:PHP uc_authcode函数的具体用法?PHP uc_authcode怎么用?PHP uc_authcode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uc_authcode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notifyAction
public function notifyAction(Request $request)
{
$this->initUcenter();
$_DCACHE = $get = $post = array();
$code = @$_GET['code'];
parse_str(uc_authcode($code, 'DECODE', UC_KEY), $get);
if (MAGIC_QUOTES_GPC) {
$get = $this->stripslashes($get);
}
$timestamp = time();
if ($timestamp - $get['time'] > 3600) {
return new Response('Authracation has expiried');
}
if (empty($get)) {
return new Response('Invalid Request');
}
// $action = $get['action'];
$this->requireClientFile('lib/xml.class.php');
$xml = file_get_contents('php://input');
$post = xml_unserialize($xml);
if (!in_array($get['action'], array('test', 'deleteuser', 'renameuser', 'gettag', 'synlogin', 'synlogout', 'updatepw', 'updatebadwords', 'updatehosts', 'updateapps', 'updateclient', 'updatecredit', 'getcreditsettings', 'updatecreditsettings'))) {
return new Response(API_RETURN_FAILED);
}
$method = 'do' . ucfirst($get['action']);
$result = $this->{$method}($request, $get, $post);
return new Response($result);
}
示例2: 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;
}
示例3: getSynuserUid
function getSynuserUid($cookie_key = 'hk8_auth')
{
if (isset($_COOKIE[$cookie_key])) {
$code = $_COOKIE[$cookie_key];
$uinfo = uc_authcode($code, $operation = 'DECODE');
$info = array();
list($info['uname'], $info['uid']) = explode("\t", $uinfo);
// $info['uname'] = mb_convert_encoding($info['uname'],'UTF-8','GBK');
return $info;
}
return false;
}
示例4: 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}");
}
示例5: index
public function index()
{
$get = $post = array();
$code = @$_GET['code'];
parse_str(uc_authcode($code, 'DECODE', UC_KEY), $get);
if (get_magic_quotes_gpc()) {
$get = uc_stripslashes($get);
}
$timestamp = time();
if ($timestamp - $get['time'] > 3600) {
exit('Authracation has expiried');
}
if (empty($get)) {
exit('Invalid Request');
}
$action = $get['action'];
include_once APP_PATH . 'uc_client/lib/xml.class.php';
$post = xml_unserialize(file_get_contents('php://input'));
if (in_array($get['action'], array('test', 'deleteuser', 'renameuser', 'gettag', 'synlogin', 'synlogout', 'updatepw', 'updatebadwords', 'updatehosts', 'updateapps', 'updateclient', 'updatecredit', 'getcreditsettings', 'updatecreditsettings'))) {
exit($this->{$get}['action']($get, $post));
} else {
exit(API_RETURN_FAILED);
}
}
示例6: list
/**
* UCenter Application Development Example
*
* UCenter simple application, the application without database
* Use the interface function:
* uc_authcode() - optional function to use user centered Cookie encryption
* uc_pm_checknew() - optional, for the global determine whether there is a new short message, to return $newpm variable
*/
include './config.inc.php';
include './uc_client/client.php';
/**
* Get the current user UID and user name
* Cookie decryption directly by uc_authcode function, users use their own functions
*/
if (!empty($_COOKIE['Example_auth'])) {
list($Example_uid, $Example_username) = explode("\t", uc_authcode($_COOKIE['Example_auth'], 'DECODE'));
} else {
$Example_uid = $Example_username = '';
}
/**
* Get the latest PMs
*/
$newpm = uc_pm_checknew($Example_uid);
/**
* Example code for each function
*/
switch (@$_GET['example']) {
case 'login':
//Example code UCenter User login
include 'code/login_nodb.php';
break;
示例7: indexAction
/**
* 登录
*/
public function indexAction()
{
if (!$this->isLogin(1)) {
$this->memberMsg(lang('m-log-0', array('1' => $this->memberinfo['username'])), url('index'));
}
if ($this->isPostForm()) {
$data = $this->post('data');
if ($this->memberconfig['logincode'] && !$this->checkCode($this->post('code'))) {
$this->memberMsg(lang('m-log-1'));
}
if (empty($data['username']) || empty($data['password'])) {
$this->memberMsg(lang('m-log-2'));
}
$member = $this->db->where('username', $data['username'])->get('member')->row_array();
$time = empty($data['cookie']) ? 24 * 3600 : 360 * 24 * 3600;
//会话保存时间。
$backurl = $data['back'] ? urldecode($data['back']) : url('index');
if ($this->memberconfig['uc_use'] == 1) {
list($uid, $username, $password, $email) = uc_user_login($data['username'], $data['password']);
if ($uid > 0) {
if (empty($member)) {
$auth = rawurlencode(uc_authcode("{$username}\t" . time(), 'ENCODE'));
$this->memberMsg(lang('m-log-3'), url('member/register/active', array('auth' => $auth)) . '&back=' . urlencode($backurl), 1);
}
$ucsynlogin = uc_user_synlogin($uid);
$nickname = $member['nickname'] ? $member['nickname'] : $member['username'];
$this->update_login_info($member);
set_cookie('member_id', $member['id'], $time);
set_cookie('member_code', substr(md5(SITE_MEMBER_COOKIE . $member['id']), 5, 20), $time);
$this->memberMsg(lang('m-log-4') . $ucsynlogin, $backurl, 1);
} elseif ($uid == -1) {
if ($member) {
//注册Ucenter
$uid = uc_user_register($member['username'], $data['password'], $member['email']);
if ($uid > 0) {
$ucsynlogin = uc_user_synlogin($uid);
$nickname = $member['nickname'] ? $member['nickname'] : $member['username'];
$this->update_login_info($member);
set_cookie('member_id', $member['id'], $time);
set_cookie('member_code', substr(md5(SITE_MEMBER_COOKIE . $member['id']), 5, 20), $time);
$this->memberMsg(lang('m-log-4') . $ucsynlogin, $backurl, 1);
} elseif ($uid == -1) {
$this->memberMsg(lang('m-log-5'));
} elseif ($uid == -2) {
$this->memberMsg(lang('m-log-6'));
} else {
$this->memberMsg(lang('m-log-7'));
}
}
$this->memberMsg(lang('m-log-5'));
} elseif ($uid == -2) {
$this->memberMsg(lang('m-log-6'));
} else {
$this->memberMsg(lang('m-log-7'));
}
}
if (empty($member)) {
$this->memberMsg(lang('m-log-8'));
}
if ($member['password'] != md5(md5($data['password']) . $member['salt'] . md5($data['password']))) {
$this->memberMsg(lang('m-log-6'));
}
$this->update_login_info($member);
set_cookie('member_id', $member['id'], $time);
set_cookie('member_code', substr(md5(SITE_MEMBER_COOKIE . $member['id']), 5, 20), $time);
$this->memberMsg(lang('m-log-4'), $backurl, 1);
}
$backurl = $this->get('back') ? $this->get('back') : (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : url('member/'));
$this->view->assign(array('meta_title' => lang('m-log-9') . '-' . $this->site['SITE_NAME'], 'backurl' => urlencode($backurl)));
$this->view->display('member/login');
}
示例8: get_url_code
function get_url_code($operation, $getdata, $appid)
{
$app = $this->apps[$appid];
$authkey = $this->db->result_first("SELECT authkey FROM " . UC_DBTABLEPRE . "applications WHERE appid='{$appid}'");
$url = $app['url'];
$action = $this->operations[$operation][1];
$code = urlencode(uc_authcode("{$action}&" . ($getdata ? "{$getdata}&" : '') . "time=" . $this->base->time, 'ENCODE', $authkey));
return $url . "/api/uc.php?code={$code}";
}
示例9: trustExternal
/**
* Do all authentication [ OPTIONAL ]
*
* Set $this->cando['external'] = true when implemented
*
* If this function is implemented it will be used to
* authenticate a user - all other DokuWiki internals
* will not be used for authenticating, thus
* implementing the checkPass() function is not needed
* anymore.
*
* The function can be used to authenticate against third
* party cookies or Apache auth mechanisms and replaces
* the auth_login() function
*
* The function will be called with or without a set
* username. If the Username is given it was called
* from the login form and the given credentials might
* need to be checked. If no username was given it
* the function needs to check if the user is logged in
* by other means (cookie, environment).
*
* The function needs to set some globals needed by
* DokuWiki like auth_login() does.
*
* @see auth_login()
*
* @param string $user Username
* @param string $pass Cleartext Password
* @param bool $sticky Cookie should not expire
* @return bool true on successful auth
*/
function trustExternal($user, $pass, $sticky = false)
{
global $USERINFO;
global $conf;
global $lang;
// global $auth;
global $ACT;
$sticky ? $sticky = true : ($sticky = false);
//sanity check
// if (!$auth) return false;
$uid = '';
$username = '';
$password = '';
$email = '';
$checked = false;
if (!empty($user)) {
list($uid, $username, $password, $email) = $this->_uc_user_login($user, $pass);
setcookie($this->cnf['cookie'], '', -86400);
if ($uid > 0) {
$_SERVER['REMOTE_USER'] = $username;
$user_info = $this->_uc_get_user_full($uid, 1);
$this->_uc_setcookie($this->cnf['cookie'], uc_authcode($uid . "\t" . $user_info['password'] . "\t" . $this->_convert_charset($username), 'ENCODE'));
$synlogin = uc_user_synlogin($uid);
// echo uc_user_synlogin($uid);
// echo does not send the output correctly, but function msg() can store the messages in session and output them even the page refreshes.
msg($synlogin, 0);
$checked = true;
} else {
if (!$silent) {
$msg = '';
switch ($login_uid) {
case -1:
$msg = '用户名不存在或者被删除';
break;
case -2:
default:
$msg = $lang['badlogin'];
break;
}
msg($msg, -1);
}
// auth_logoff();
// return false;
$checked = false;
}
} else {
$cookie = $_COOKIE[$this->cnf['cookie']];
if (!empty($cookie)) {
// use password check instead of username check.
list($uid, $password, $username) = explode("\t", uc_authcode($cookie, 'DECODE'));
$username = $this->_convert_charset($username, 0);
if ($password && $uid && $username) {
// get session info
$session = $_SESSION[DOKU_COOKIE]['auth'];
if (isset($session) && $session['user'] == $username && $session['pass'] == $password && $session['buid'] == auth_browseruid()) {
$user_info = $session['info'];
$checked = true;
} else {
$user_info = $this->_uc_get_user_full($uid, 1);
if ($uid == $user_info['uid'] && $password == $user_info['password']) {
// he has logged in from other uc apps
$checked = true;
}
}
}
}
}
if ($checked == true) {
//.........这里部分代码省略.........
示例10: authcode
function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0)
{
return uc_authcode($string, $operation, $key, $expiry);
}
示例11: uc_authcode
/**
* 加解密算法.
*
* @$string:加解密原字串
* @$operation:操作,decode为解密;encode为加密
* @$key:加密密钥
* @return:返回加解密后字串
*/
public static function uc_authcode($string, $operation = 'DECODE', $key = '', $expiry = 0)
{
if (!function_exists('uc_authcode')) {
require_once LITHIUM_APP_PATH . '/libraries/uc_client/client.php';
}
return uc_authcode($string, $operation, $key, $expiry);
}
示例12: define
//更新域名解析缓存 开关
define('API_UPDATEAPPS', 1);
//更新应用列表 开关
define('API_UPDATECLIENT', 0);
//更新客户端缓存 开关
define('API_UPDATECREDIT', 0);
//更新用户积分 开关
define('API_GETCREDITSETTINGS', 0);
//向 UCenter 提供积分设置 开关
define('API_UPDATECREDITSETTINGS', 0);
//更新应用积分设置 开关
define('API_RETURN_SUCCEED', '1');
define('API_RETURN_FAILED', '-1');
define('API_RETURN_FORBIDDEN', '-2');
$code = $_GET['code'];
parse_str(uc_authcode($code, 'DECODE', UC_KEY), $get);
if (MAGIC_QUOTES_GPC) {
$get = dstripslashes($get);
}
if (time() - $get['time'] > 3600) {
exit('Authracation has expiried');
}
if (empty($get)) {
exit('Invalid Request');
}
$action = $get['action'];
if ($action == 'test') {
exit(API_RETURN_SUCCEED);
} elseif ($action == 'deleteuser') {
!API_DELETEUSER && exit(API_RETURN_FORBIDDEN);
//用户删除 API 接口
示例13: list
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 '未定义';
}
}
示例14: list
* uc_user_login() Must, to judge the effectiveness of the logged on user
* uc_authcode() Optionally, the user center to use encryption and decryption functions Cookie
* uc_user_synlogin() Optional, generate the code synchronization log
*/
if (empty($_POST['submit'])) {
//Login Form
echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?example=login">';
echo 'Login:';
echo '<dl><dt>User name</dt><dd><input name="username"></dd>';
echo '<dt>Password</dt><dd><input name="password" type="password"></dd></dl>';
echo '<input name="submit" type="submit"> ';
echo '</form>';
} else {
//Login account through the interface to check the correctness of the return value is an array
list($uid, $username, $password, $email) = uc_user_login($_POST['username'], $_POST['password']);
setcookie('Example_auth', '', -86400);
if ($uid > 0) {
//User login successfully, setting Cookie, encryption directly uc_authcode function, users use their own functions
setcookie('Example_auth', uc_authcode($uid . "\t" . $username, 'ENCODE'));
//The code generated synchronization log
$ucsynlogin = uc_user_synlogin($uid);
echo 'Login Successful ' . $ucsynlogin . '<br><a href="' . $_SERVER['PHP_SELF'] . '">Continue</a>';
exit;
} elseif ($uid == -1) {
echo 'The user does not exist, or deleted';
} elseif ($uid == -2) {
echo 'Password wrong';
} else {
echo 'Undefined';
}
}
示例15: getUserByCookie
static function getUserByCookie()
{
if (!empty($_COOKIE[self::$authPre . 'auth'])) {
list(self::$uid, self::$username, self::$password, self::$email) = explode("\t", uc_authcode($_COOKIE[self::$authPre . 'auth'], 'DECODE'));
return array('uid' => self::$uid, 'username' => self::$username, 'password' => self::$password, 'email' => self::$email);
} else {
return FALSE;
}
}