本文整理汇总了PHP中authcode函数的典型用法代码示例。如果您正苦于以下问题:PHP authcode函数的具体用法?PHP authcode怎么用?PHP authcode使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了authcode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: met_cooike_start
/**
* 判断COOKIE是否超过一个小时,如果没有超过则更新$_M['user']['cookie']中的信息
*/
function met_cooike_start()
{
global $_M;
$_M['user']['cookie'] = array();
$met_webkeys = $_M['config']['met_webkeys'];
list($username, $password) = explode("\t", authcode($_M['form']['met_auth'], 'DECODE', $met_webkeys . $_COOKIE['met_key']));
$username = sqlinsert($username);
$query = "SELECT * from {$_M['table']['admin_table']} WHERE admin_id = '{$username}'";
$user = DB::get_one($query);
$usercooike = json_decode($user['cookie']);
if (md5($user['admin_pass']) == $password && time() - $usercooike->time < 3600) {
foreach ($usercooike as $key => $val) {
$_M['user']['cookie'][$key] = $val;
}
if (defined('IN_ADMIN')) {
$_M['user']['admin_name'] = get_met_cookie('metinfo_admin_name');
$_M['user']['admin_id'] = $_M['user']['cookie']['metinfo_admin_id'];
$privilege = background_privilege();
$_M['user']['langok'] = $privilege['langok'];
}
$_M['user']['cookie']['time'] = time();
$json = json_encode($_M['user']['cookie']);
$query = "update {$_M['table']['admin_table']} set cookie = '{$json}' WHERE admin_id = '{$username}'";
$user = DB::query($query);
}
}
示例2: respond
public function respond()
{
global $_W;
$rid = $this->rule;
$reply = pdo_fetch("SELECT * FROM " . tablename('vote_reply') . " WHERE `rid`=:rid LIMIT 1", array(':rid' => $rid));
if ($reply == false) {
return $this->respText('活动已经取消...');
}
$nowtime = time();
$endtime = $reply['endtime'] + 86399;
if ($reply['status'] == 0) {
return $this->respText("投票已暂停,请等待...");
}
if ($reply['votelimit'] == 1) {
if ($reply['votetotal'] > 0 && $reply['votenum'] >= $reply['votetotal']) {
return $this->respText("投票人数已满,活动结束...");
}
} else {
if ($reply['starttime'] > $nowtime) {
return $this->respText("投票未开始,请等待...");
} elseif ($endtime < $nowtime) {
return $this->respText("投票已结束...");
} else {
// if ($reply['status'] != 1) {
// return $this->respText("投票已暂停,请等待...");
// }
}
}
return $this->respNews(array('Title' => $reply['title'], 'Description' => $reply['description'], 'PicUrl' => img_url($reply['thumb']), 'Url' => $this->createMobileUrl("index", array("id" => $rid, 'from_user' => base64_encode(authcode($this->message['from'], 'ENCODE'))))));
}
示例3: confirm
public function confirm()
{
if (IS_POST) {
if ($this->redis->get($this->wx_numberid_name . intval(I('post.numberid'))) && I('post.confirm') == 'true') {
$this->redis->setex($this->wx_auth_name . intval(I('post.numberid')), 150, ACPopedom::getID());
//提示登陆成功
header("HTTP/1.1 200");
exit;
} else {
header("HTTP/1.1 400");
exit;
}
}
$nmberid = authcode(base64_decode(trim(I('get.token'))), "DECODE", SESSION_AUTH);
if (!intval($nmberid)) {
//解析不成功
$this->ajaxReturn(array('status' => false, 'msg' => '无效的二维码'));
}
if (!$this->redis->get($this->wx_numberid_name . $nmberid)) {
//解析不成功
$this->ajaxReturn(array('status' => false, 'msg' => '此二维码已过期,请刷新页面再扫!'));
}
//生成扫码通过标识,并绑定扫码带来的numberid
$this->redis->setex($this->wx_login_name . $nmberid, 150, ACPopedom::getAvator());
$this->ajaxReturn(array('status' => true, 'numberid' => $nmberid));
}
示例4: _initialize
/**
* 前期执行
*/
public function _initialize(){
//配置
$configs = getCache('Config:list');
$this->configs = $configs;
$this->assign('configs',$configs);
//dump($configs);exit;
//购物车
/*
$shopcart= session('shopcart');
$this->shopcartnum = count($shopcart);
$this->assign('shopcartnum', count($shopcart));
*/
//上级
if($_GET['r']){
cookie('r',$_GET['r']);
}
//会员信息
$member_msg = session('member_msg');
$user = unserialize(authcode($member_msg,'DECODE'));
$user['id'] = 107;//模拟用户
if($user){
if($user['openid'] && !$user['id']){
$to_url = C('MEMBER_SITE_URL').'/Member/message';
header("location:".$to_url);exit;
}
$model = D('Member');
$data['a.id'] = $user['id'];
$db_pre = C('DB_PREFIX');
$user = $model->alias('a')->join('`'.$db_pre.'member_wallet` as b on a.id=b.member_id')->join('`'.$db_pre.'member_msg` as c on a.id=c.member_id')->field('a.id,a.pid,a.nickname,logo,lv,lv_name,email,utype,username,realname,mobile,password,salt,pv_id,ct_id,province,city,create_time,last_login_time,balance,frozen,c.sex')->where($data)->find();
//echo $model->getlastsql();exit;
if($user['balance']==null){
$data['update_time'] = time();
$model->add($data);
$user['balance'] = 0;
$user['frozen'] = 0;
$user['update_time'] = time();
}
//dump($user);
$user['username'] = $user['username'] ? $user['username'] : $user['mobile'];
$this->user = $user;
$this->assign('user',$user);
}
$this->iswx = isWeixin();//是否微信浏览器
$this->login_url = C('SITE_URL').'/index.php/Public/login';
$this->register_url = C('SITE_URL').'/index.php/Public/register';
if(!IS_AJAX){
if($_SERVER['QUERY_STRING']){
$from_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
}else{
$from_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
}
$from_url_except = array('login','register','reg_do','verify','checkLogin','check_username','check_email','get_city');
if(array_search(ACTION_NAME,$from_url_except)===false && CONTROLLER_NAME!='Public'){
$_SESSION['self_url'] = $from_url;
}
}
$this->assign('self_url',$_SESSION['self_url']);
}
示例5: check
public function check()
{
$this->json = new JSON();
$key = ForceStringFrom('key');
$code = ForceStringFrom('code');
$decode = authcode($code, 'DECODE', $key);
$cookievalue = ForceCookieFrom(COOKIE_SAFE);
$email = ForceStringFrom('email');
if (!$email) {
$this->ajax['i'] = '请输入Email地址!';
} elseif (!IsEmail($email)) {
$this->ajax['i'] = 'Email地址非法!';
} elseif ($decode != md5(WEBSITE_KEY)) {
$this->ajax['i'] = '验证码超时! 请刷新页面后重新提交.';
} elseif ($cookievalue != md5(WEBSITE_KEY . $key . APP::$_CFG['KillRobotCode'])) {
$this->ajax['i'] = '安全验证Cookie错误!';
} elseif (!($user = APP::$DB->getOne("SELECT u.aid, u.password, u.fullname FROM " . TABLE_PREFIX . "admin u WHERE u.email = '{$email}' AND u.activated = 1"))) {
$this->ajax['i'] = 'Email地址不存在!';
} else {
$subject = '管理员找回密码 -- ' . APP::$_CFG['Title'];
$verifycode = PassGen(8);
$verify_url = BASEURL . ADMINDIR . '/index.php?c=getpass&a=verify&key=' . base64_encode($email) . '&sid=' . md5($user['fullname'] . WEBSITE_KEY . $user['password'] . $verifycode);
$content = "{$user['fullname']}:<br><br>您好! 请点击以下链接重设密码:<br><br>";
$content .= "<a href=\"{$verify_url}\" target=\"_blank\">{$verify_url}</a><br><br>";
APP::$DB->exe("UPDATE " . TABLE_PREFIX . "admin SET verifycode = '{$verifycode}' WHERE aid = '{$user['aid']}'");
if (SendMail($email, $subject, $content) === true) {
$this->ajax['s'] = 1;
$this->ajax['i'] = '重设密码的邮件已发送到您的信箱, 请查收!';
} else {
$this->ajax['i'] = '发送邮件失败!';
}
}
die($this->json->encode($this->ajax));
}
示例6: index
public function index()
{
$data = I('post.');
if (!empty($data['username']) && !empty($data['password']) && !empty($data['verify'])) {
if ($this->Verify->check($data['verify'])) {
$user = M('user');
$userdata = $user->where("username='%s' and state=0", $data['username'])->find();
if ($userdata && $userdata['password'] === md5(C('SECURE_CODE') . md5($data['password']))) {
unset($userdata['password']);
$userdata['ip'] = get_client_ip();
$user->where('id=' . $userdata['id'])->save(array('logintime' => time()));
$user_auth = json_encode($userdata);
$user_auth_cookie = authcode($user_auth, ENCODE);
cookie('auth', $user_auth_cookie, 3600);
$this->success('登陆成功', U('index/index'));
exit;
} else {
$this->error("用户名或密码错误");
}
} else {
$this->error("验证码填写错误");
}
}
$this->display();
}
示例7: ModifyAvator
/**
* 修改截取后的头像
*/
public function ModifyAvator()
{
$ShearPhoto["config"] = array("proportional" => 0);
import('Vendor.ShearPhoto.ShearPhoto');
$Shear = new \ShearPhoto(ACPopedom::mixPass(ACPopedom::getID()));
$tmp_name = $Shear->run(json_decode(trim(stripslashes($_POST["JSdate"])), true), $ShearPhoto["config"]);
//传入参数运行
if (!$tmp_name) {
$this->ajaxReturn(array('erro' => '头像保存失败'));
}
$filename = $Shear->filename . $Shear->imagesuffix;
//又拍云上传
import('Vendor.Upyun.UpYunApi');
$upYunApi = new \UpYunApi(UPYUN_BUCKET, UPYUN_USERNAME, UPYUN_PASSWORD);
$upYunApi->debug = false;
$upYunApi->setApiDomain(UPYUN_HOST);
$fh = fopen($tmp_name, 'rb');
$rsp = $upYunApi->writeFile('/Attachment/face/' . $filename, $fh, true);
if (file_exists(ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . $Shear->filename)) {
unlink(ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . $filename);
}
fclose($fh);
if ($rsp) {
$result = M('Users')->where('userid = ' . ACPopedom::getID())->save(array('avator' => UPYUN_BASIC_URL . '/Attachment/face/' . $filename));
if ($result !== false) {
$userinfo = ACPopedom::getUserInfo();
cookie("__info__", authcode(serialize(array('nickname' => $userinfo['nickname'], 'userid' => $userinfo['userid'], 'avator' => UPYUN_BASIC_URL . '/Attachment/face/' . $filename)), "ENCODE", SESSION_AUTH, C('COOKIE_EXPIRE')));
$this->ajaxReturn(array('success' => '截图成功!如不能立即显示,请多刷新两次', 'url' => U('Web/UserCenter/index')));
} else {
$this->ajaxReturn(array('erro' => '头像更新失败'));
}
} else {
$this->ajaxReturn(array('erro' => '头像更新失败'));
}
}
示例8: register_header
function register_header()
{
global $_G;
$inputemail = 'gp_' . $this->regemail['email'];
$_G['gp_email'] = $_G[$inputemail];
if ($_POST) {
$_G['gp_activationauth'] = strip_tags(str_replace(" ", "+", $_G['gp_activationauth']));
$activationinfo = authcode($_G['gp_activationauth'], $operation = 'DECODE');
$activationinfoname = preg_replace("/\\s.+/i", "", $activationinfo);
if ($activationinfoname) {
loaducenter();
if ($data = uc_get_user($activationinfoname)) {
list($uid, $username, $email) = $data;
}
$_G['gp_email'] = getEmail(strip_tags($email));
} else {
$_G['gp_email'] = getEmail(strip_tags($_G['gp_email']));
}
$_G['gp_rid'] = strip_tags($_G['gp_rid']);
if (!$_G['gp_rid']) {
showmessage('dsu_amufzc:1', '');
}
if (!$_G['gp_email']) {
showmessage('dsu_amufzc:5', '');
}
$amutb = DB::table("plugin_dsuamfzc");
$query = DB::fetch_first("SELECT * FROM {$amutb} WHERE rid = '" . $_G['gp_rid'] . "'");
if (!$query || $query['yes'] == '1') {
showmessage('dsu_amufzc:2', '');
}
if ($_G['gp_email'] != $query['email']) {
showmessage('dsu_amufzc:11', '');
}
}
}
示例9: avatar
public function avatar()
{
if ($_POST['dosubmit']) {
$_POST['id'] = $this->_userid;
if (!$this->dao->create($_POST)) {
$this->error($this->dao->getError());
}
$this->dao->update_time = time();
$this->dao->last_ip = get_client_ip();
$result = $this->dao->save();
if (false !== $result) {
if ($_POST['aid']) {
$Attachment = M('Attachment');
$aids = implode(',', $_POST['aid']);
$data['userid'] = $this->_userid;
$data['catid'] = 0;
$data['status'] = '1';
$Attachment->where("aid in (" . $aids . ")")->save($data);
}
$this->success(L('do_success'));
} else {
$this->error(L('do_error'));
}
exit;
}
$yourphp_auth_key = sysmd5(C('ADMIN_ACCESS') . $_SERVER['HTTP_USER_AGENT']);
$yourphp_auth = authcode('0-1-0-1-jpeg,jpg,png,gif-3-0', 'ENCODE', $yourphp_auth_key);
$this->assign('yourphp_auth', $yourphp_auth);
$this->display();
}
示例10: getCurrUser
/**
* 判断是否登录及获取当前管理员信息
*/
protected function getCurrUser()
{
$currUser = Session("system_curr_user");
if (empty($currUser)) {
return;
}
$currUser = unserialize(authcode($currUser));
if (!isset($currUser['id'])) {
return;
}
$user = D("SysUser")->selectOne($currUser['id']);
if (!$user) {
return;
}
if (!$user['status']) {
return;
}
// 帐号禁用
$this->isLogined = true;
unset($user['password']);
$user['auth'] = unserialize($user['auth']);
$user['upTime'] = $currUser['lastTime'];
$user['upIp'] = $currUser['lastIp'];
$this->currUser = $user;
}
示例11: setloginstatus
function setloginstatus($member, $cookietime)
{
global $_G;
$_G['uid'] = intval($member['uid']);
$_G['username'] = $member['username'];
$_G['adminid'] = $member['adminid'];
$_G['groupid'] = $member['groupid'];
$_G['formhash'] = formhash();
$_G['session']['invisible'] = getuserprofile('invisible');
$_G['member'] = $member;
loadcache('usergroup_' . $_G['groupid']);
C::app()->session->isnew = true;
C::app()->session->updatesession();
dsetcookie('auth', authcode("{$member['password']}\t{$member['uid']}", 'ENCODE'), $cookietime, 1, true);
dsetcookie('loginuser');
dsetcookie('activationauth');
dsetcookie('pmnum');
include_once libfile('function/stat');
updatestat('login', 1);
if (defined('IN_MOBILE')) {
updatestat('mobilelogin', 1);
}
if ($_G['setting']['connect']['allow'] && $_G['member']['conisbind']) {
updatestat('connectlogin', 1);
}
$rule = updatecreditbyaction('daylogin', $_G['uid']);
if (!$rule['updatecredit']) {
checkusergroup($_G['uid']);
}
}
示例12: checkUserLogin
function checkUserLogin($uname, $upass, $set = true)
{
$uname = trim($uname);
$upass = trim($upass);
$_this =& Members::getInstance();
if (empty($uname) || empty($upass)) {
return -1;
}
$sql = "SELECT m.id,m.username,m.userpass,af.first_name,af.last_name,af.expired FROM {$this->table_prefix}adminfields af LEFT JOIN {$this->table_prefix}members m ON af.member_id=m.id WHERE m.username='{$uname}'";
$tmpUser = $this->dbstuff->GetRow($sql);
if (!$_this->checkUserExist($uname)) {
$this->error = L("member_not_exists");
return -2;
} elseif ($tmpUser['expired'] != 0 && $tmpUser['expired'] < $this->timestamp) {
$this->error = L("account_expired");
return;
} elseif (!pb_strcomp($tmpUser['userpass'], $_this->authPasswd($upass))) {
$this->error = L("login_pwd_wrong");
return -3;
} else {
$this->dbstuff->Execute("UPDATE {$this->table_prefix}adminfields SET last_login=" . $this->timestamp . ",last_ip='" . pb_get_client_ip("str") . "' WHERE member_id=" . $tmpUser['id']);
$tAuth = $tmpUser['id'] . "\n" . $tmpUser['username'] . "\n" . $tmpUser['userpass'];
usetcookie("admin", authcode($tAuth, "ENCODE"));
return true;
}
}
示例13: loginAct
/**
* 登录页
*/
public function loginAct()
{
$loginNum = session("system_login_num");
$loginNum = $loginNum === null ? 5 : $loginNum;
if (!IS_POST) {
$this->display();
} else {
$loginNum--;
session("system_login_num", $loginNum);
if ($loginNum <= 0) {
$this->error("由于您输入错误过多,请30分钟后再试!");
}
$name = I('userName', '');
$password = I('password', '');
if (empty($name) || empty($password)) {
$this->error("用户名或密码错误!您还有 {$loginNum} 次机会。");
}
$user = D('SysUser')->login($name, $password);
if (!$user) {
$this->error("用户名或密码错误!您还有 {$loginNum} 次机会。");
}
$currUser = authcode(serialize(array('id' => $user['id'], 'lastTime' => $user['lastTime'], 'lastIp' => $user['lastIp'])), 'ENCODE');
session('system_curr_user', $currUser);
session('system_login_num', null);
$this->success($name . ",您好!点击确定按钮进入系统。", U("Index/index"));
}
}
示例14: login
public function login()
{
$nmberid = authcode(base64_decode(trim(I('get.token'))), "DECODE", SESSION_AUTH);
$startTime = time();
while ($this->redis->get($this->wx_numberid_name . $nmberid)) {
if (time() >= $startTime + 27) {
// 超时重新轮询
header("HTTP/1.1 204");
return;
}
if ($avator = $this->redis->get($this->wx_login_name . $nmberid)) {
//存在跳出,返回返回给浏览器同时删除标志
$this->redis->del($this->wx_login_name . $nmberid);
header("HTTP/1.1 201");
$this->ajaxReturn(array('avator' => $avator));
}
if ($userid = $this->redis->get($this->wx_auth_name . $nmberid)) {
//存在跳出,返回返回给浏览器同时删除标志
session(array("name" => SESSION_ID, 'path' => "/", "expire" => C('COOKIE_EXPIRE')));
$userinfo = M('Users')->where('userid = ' . intval($userid))->find();
session(SESSION_ID, $userinfo['userid']);
session(array("name" => SESSION_TOKEN, 'path' => "/", "expire" => C('COOKIE_EXPIRE')));
session(SESSION_TOKEN, $userinfo['userid']);
cookie("__info__", authcode(serialize(array('nickname' => $userinfo['nickname'], 'userid' => $userinfo['userid'], 'avator' => $userinfo['avator'])), "ENCODE", SESSION_AUTH, C('COOKIE_EXPIRE')));
$this->redis->del($this->wx_auth_name . $nmberid);
$this->redis->del($this->wx_numberid_name . $nmberid);
header("HTTP/1.1 200");
$this->ajaxReturn(array('url' => U('Web/UserCenter/index')));
}
}
header("HTTP/1.1 400");
}
示例15: auth
public function auth()
{
$this->_wechat->checkAuth();
$token = $this->_wechat->getOauthAccessToken();
$userinfo = $this->_wechat->getUserInfo($token['openid']);
$result = M('Users')->where('openid = "' . $token['openid'] . '"')->find();
if ($result) {
//用户已存在,更新信息,,暂时不更新
cookie('__WX_UID__', authcode($result['userid'], "ENCODE", SESSION_AUTH), C('COOKIE_EXPIRE'));
cookie('__WX_AVATOR__', authcode($result['avator'], "ENCODE", SESSION_AUTH), C('COOKIE_EXPIRE'));
cookie('__WX_NICKNAME__', authcode($result['nickname'], "ENCODE", SESSION_AUTH), C('COOKIE_EXPIRE'));
cookie('__WX_AUTH_TOKEN__', authcode($token['openid'], "ENCODE", SESSION_AUTH), C('COOKIE_EXPIRE'));
} else {
$data['username'] = '';
$data['nickname'] = $userinfo['nickname'] ? $userinfo['nickname'] : '';
//此处头像应该做本地化处理。。。。。
$data['avator'] = $userinfo['headimgurl'] ? $userinfo['headimgurl'] : '';
$data['address'] = '';
$data['salt'] = '';
$data['passwd'] = '';
$data['posttime'] = time();
$data['openid'] = $token['openid'];
$data['unionid'] = $userinfo['unionid'] ? $userinfo['unionid'] : '';
$data['ip'] = get_client_ip();
$rs = M('Users')->add($data);
if ($rs) {
cookie('__WX_UID__', authcode($rs, "ENCODE", SESSION_AUTH), C('COOKIE_EXPIRE'));
cookie('__WX_AVATOR__', authcode($userinfo['headimgurl'], "ENCODE", SESSION_AUTH), C('COOKIE_EXPIRE'));
cookie('__WX_NICKNAME__', authcode($userinfo['nickname'], "ENCODE", SESSION_AUTH), C('COOKIE_EXPIRE'));
cookie('__WX_AUTH_TOKEN__', authcode($token['openid'], "ENCODE", SESSION_AUTH), C('COOKIE_EXPIRE'));
}
}
//
header("Location:" . authcode(cookie('__refer__'), "DECODE", SESSION_AUTH));
}