本文整理汇总了PHP中es_session::start方法的典型用法代码示例。如果您正苦于以下问题:PHP es_session::start方法的具体用法?PHP es_session::start怎么用?PHP es_session::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类es_session
的用法示例。
在下文中一共展示了es_session::start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_fee
public function check_fee()
{
es_session::start();
$last_visit = intval(es_session::get("last_visit_smsbao"));
if (get_gmtime() - $last_visit > 10) {
$sms = new transport();
$params = array("u" => $this->sms['user_name'], "p" => md5($this->sms['password']));
$url = "http://www.smsbao.com/query";
$result = $sms->request($url, $params);
$match = explode(',', $result['body']);
if ($match[0] != '') {
$remain = (int) $match[1];
$str = sprintf('短信宝增值平台 剩余:%d 条', $remain);
} else {
$str = "短信宝增值平台 (<a href='http://www.smsbao.com/reg?r=5001' target='_blank'><font color='red'>还没账号?点击这免费注册</font></a>)";
}
es_session::set("smsbao_info", $str);
es_session::set("last_visit_smsbao", get_gmtime());
return $str;
} else {
$qxt_info = es_session::get("smsbao_info");
if ($smsbao_info) {
return $smsbao_info;
} else {
return "短信宝增值平台 (<a href='http://www.smsbao.com/reg?r=5001' target='_blank'><font color='red'>还没账号?点击这免费注册</font></a>)";
}
}
}
示例2: callback
public function callback()
{
es_session::start();
require_once APP_ROOT_PATH . "system/api_login/qqv2/qqConnectAPI.php";
$qc = new QC();
$access_token = $qc->qq_callback();
$openid = $qc->get_openid();
$use_info_keysArr = array("access_token" => $access_token, "openid" => $openid, "oauth_consumer_key" => $this->api['config']['app_key']);
$use_info_url = "https://graph.qq.com/user/get_user_info";
$graph_use_info_url = $qc->urlUtils->combineURL($use_info_url, $use_info_keysArr);
$response = $qc->urlUtils->get_contents($graph_use_info_url);
$arr = array();
$arr = json_decode($response, true);
$msg['field'] = 'qq_id';
$msg['id'] = $openid;
$msg['name'] = $arr["nickname"];
es_session::set("api_user_info", $msg);
$user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where qq_id = '" . $openid . "' and qq_id <> '' and is_effect=1 and is_delete=0");
if ($user_data) {
$user_current_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where id = " . intval($user_data['group_id']));
$user_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where score <=" . intval($user_data['score']) . " order by score desc");
if ($user_current_group['score'] < $user_group['score']) {
$user_data['group_id'] = intval($user_group['id']);
}
es_session::set("user_info", $user_data);
$GLOBALS['db']->query("update " . DB_PREFIX . "user set login_ip = '" . get_client_ip() . "',login_time= " . TIME_UTC . ",group_id=" . intval($user_data['group_id']) . " where id =" . $user_data['id']);
es_session::delete("api_user_info");
app_recirect_preview();
} else {
$this->create_user();
app_redirect(APP_ROOT . "/");
}
}
示例3: callback
public function callback()
{
es_session::start();
$aliapy_config['partner'] = $this->api['config']['app_key'];
$aliapy_config['key'] = $this->api['config']['app_secret'];
$aliapy_config['return_url'] = SITE_DOMAIN . APP_ROOT . "/api_callback.php?c=Taobao";
$aliapy_config['sign_type'] = 'MD5';
$aliapy_config['input_charset'] = 'utf-8';
$aliapy_config['transport'] = 'http';
require_once APP_ROOT_PATH . "system/api_login/taobao/alipay_notify.class.php";
unset($_GET['c']);
$alipayNotify = new AlipayNotify($aliapy_config);
$verify_result = $alipayNotify->verifyReturn();
if ($verify_result) {
//验证成功
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//请在这里加上商户的业务逻辑程序代码
//——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
//获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表
$user_id = $_GET['user_id'];
//支付宝用户id
$token = $_GET['token'];
//授权令牌
$real_name = $_GET['real_name'];
//执行商户的业务程序
$msg['id'] = $user_id;
$msg['name'] = $real_name;
$msg['field'] = 'taobao_id';
es_session::set("api_user_info", $msg);
$user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where taobao_id = '" . $msg['id'] . "' and taobao_id <> ''");
if ($user_data) {
$user_current_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where id = " . intval($user_data['group_id']));
$user_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where score <=" . intval($user_data['score']) . " order by score desc");
if ($user_current_group['score'] < $user_group['score']) {
$user_data['group_id'] = intval($user_group['id']);
}
es_session::set("user_info", $user_data);
$GLOBALS['db']->query("update " . DB_PREFIX . "user set login_ip = '" . CLIENT_IP . "',login_time= " . TIME_UTC . ",group_id=" . intval($user_data['group_id']) . " where id =" . $user_data['id']);
//$GLOBALS['db']->query("update ".DB_PREFIX."deal_cart set user_id = ".intval($user_data['id'])." where session_id = '".es_session::id()."'");
es_session::delete("api_user_info");
app_recirect_preview();
} else {
app_redirect(url("shop", "user#api_login"));
}
//——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
} else {
//验证失败
//如要调试,请看alipay_notify.php页面的return_verify函数,比对sign和mysign的值是否相等,或者检查$veryfy_result有没有返回true
echo "验证失败";
}
}
示例4: callback
public function callback()
{
require_once APP_ROOT_PATH . 'system/api_login/alipay/alipay_notify.php';
es_session::start();
//构造通知函数信息
$alipay = new alipay_notify($this->api['config']['app_key'], $this->api['config']['app_secret'], "MD5", "utf-8", "http");
//计算得出通知验证结果
$verify_result = $alipay->return_verify();
if ($verify_result) {
//验证成功
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//请在这里加上商户的业务逻辑程序代码
//——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
//获取支付宝的通知返回参数
$user_id = $_GET['user_id'];
//获取支付宝用户唯一ID号
//判断获取到的user_id的值是否在商户会员数据库中存在(即:是否曾经做过支付宝会员免注册登陆)
// 若不存在,则程序自动为会员快速注册一个会员,把信息插入商户网站会员数据表中,
// 且把该会员的在商户网站上的登录状态,更改成“已登录”状态。并记录在商家网站会员数据表中记录登陆信息,如登陆时间、次数、IP等。
// 若存在,判断该会员在商户网站上的登录状态是否是“已登录”状态
// 若不是,则把该会员的在商户网站上的登录状态,更改成“已登录”状态。并记录在商家网站会员数据表中记录登陆信息,如登陆时间、次数、IP等。
// 若是,则不做任何数据库业务逻辑处理。判定该次反馈信息为重复刷新返回链接导致。
//——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$msg['id'] = $user_id;
$msg['name'] = "ali_" . $user_id;
$msg['field'] = 'alipay_id';
es_session::set("api_user_info", $msg);
$user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where alipay_id = " . $msg['id'] . " and alipay_id <> 0");
if ($user_data) {
$user_current_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where id = " . intval($user_data['group_id']));
$user_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where score <=" . intval($user_data['score']) . " order by score desc");
if ($user_current_group['score'] < $user_group['score']) {
$user_data['group_id'] = intval($user_group['id']);
}
es_session::set("user_info", $user_data);
$GLOBALS['db']->query("update " . DB_PREFIX . "user set login_ip = '" . get_client_ip() . "',login_time= " . TIME_UTC . ",group_id=" . intval($user_data['group_id']) . " where id =" . $user_data['id']);
//$GLOBALS['db']->query("update ".DB_PREFIX."deal_cart set user_id = ".intval($_SESSION['user_info']['id'])." where session_id = '".es_session::id()."'");
es_session::delete("api_user_info");
app_recirect_preview();
} else {
app_redirect(url("shop", "user#api_login"));
}
} else {
//验证失败
//如要调试,请看alipay_notify.php页面的return_verify函数,比对sign和mysign的值是否相等,或者检查$veryfy_result有没有返回true
echo "fail";
}
exit;
}
示例5: callback
public function callback()
{
es_session::start();
$aliapy_config['partner'] = $this->api['config']['app_key'];
$aliapy_config['key'] = $this->api['config']['app_secret'];
$aliapy_config['return_url'] = get_domain() . APP_ROOT . "/api_callback.php?c=Taobao";
$aliapy_config['sign_type'] = 'MD5';
$aliapy_config['input_charset'] = 'utf-8';
$aliapy_config['transport'] = 'http';
require_once APP_ROOT_PATH . "system/api_login/taobao/alipay_notify.class.php";
unset($_GET['c']);
$alipayNotify = new AlipayNotify($aliapy_config);
$verify_result = $alipayNotify->verifyReturn();
if ($verify_result) {
//验证成功
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//请在这里加上商户的业务逻辑程序代码
//——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
//获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表
$user_id = $_GET['user_id'];
//支付宝用户id
$token = $_GET['token'];
//授权令牌
$real_name = $_GET['real_name'];
//执行商户的业务程序
$msg['id'] = $user_id;
$msg['name'] = $real_name;
$msg['field'] = 'taobao_id';
es_session::set("api_user_info", $msg);
if (!$msg['name']) {
app_redirect(url("index"));
}
$user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where taobao_id = '" . $msg['id'] . "' and taobao_id <> ''");
if ($user_data) {
require_once APP_ROOT_PATH . "system/libs/user.php";
auto_do_login_user($user_data['user_name'], $user_data['user_pwd'], $from_cookie = false);
es_session::delete("api_user_info");
app_recirect_preview();
} else {
$this->create_user();
app_redirect(url("shop", "user#stepone"));
}
//——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
} else {
//验证失败
//如要调试,请看alipay_notify.php页面的return_verify函数,比对sign和mysign的值是否相等,或者检查$veryfy_result有没有返回true
echo "验证失败";
}
}
示例6: USSina
function USSina()
{
es_session::start();
$sina_id = trim($GLOBALS['request']['sina_id']);
$access_token = trim($GLOBALS['request']['access_token']);
$r = $GLOBALS['request']['user_info'];
$r = json_decode($r, true);
$name = $r['screen_name'];
$user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where sina_id = '" . $sina_id . "' and sina_id <> '' and sina_id <> 0");
if ($user_data) {
if ($user_data['is_effect'] == 0 || $user_data['is_delete'] == 1) {
$result['resulttype'] = 0;
} else {
$user_current_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where id = " . intval($user_data['group_id']));
$user_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where score <=" . intval($user_data['score']) . " order by score desc");
if ($user_current_group['score'] < $user_group['score']) {
$user_data['group_id'] = intval($user_group['id']);
}
$GLOBALS['db']->query("update " . DB_PREFIX . "user set sina_token ='" . $access_token . "', login_ip = '" . get_client_ip() . "',login_time= " . get_gmtime() . ",group_id=" . intval($user_data['group_id']) . " where id =" . $user_data['id']);
$GLOBALS['db']->query("update " . DB_PREFIX . "deal_cart set user_id = " . intval($user_data['id']) . " where session_id = '" . es_session::id() . "'");
$result['user_pwd'] = $user_data['user_pwd'];
$result['uid'] = $user_data['id'];
$result['email'] = $user_data['email'];
$result['user_avatar'] = get_abs_img_root(get_muser_avatar($user_data['id'], "big"));
$name = $user_data['user_name'];
$result['resulttype'] = 1;
}
} else {
$result['email'] = "";
$result['user_pwd'] = md5(get_gmtime());
$result['user_name'] = $name;
$result['sina_token'] = $access_token;
$result['sina_id'] = $sina_id;
$result['uid'] = bind_add_user($result);
if ($result['uid'] > 0) {
$result['user_avatar'] = '';
$result['resulttype'] = 1;
} else {
$result['resulttype'] = -1;
}
}
$result['access_token'] = $access_token;
$result['sina_id'] = $sina_id;
$result['user_name'] = $name;
$result['act'] = "synclogin";
$result['login_type'] = "Sina";
output($result);
}
示例7: USSina
function USSina()
{
es_session::start();
$sina_id = trim($GLOBALS['request']['sina_id']);
$access_token = trim($GLOBALS['request']['access_token']);
if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where sina_id = '" . $sina_id . "'") == 0) {
$GLOBALS['db']->query("update " . DB_PREFIX . "user set sina_token ='" . $access_token . "', sina_id = '" . $sina_id . "' where id =" . intval($GLOBALS['user_info']['id']));
} elseif (intval($GLOBALS['db']->getOne("select id from " . DB_PREFIX . "user where sina_id = '" . $sina_id . "'")) == intval($GLOBALS['user_info']['id'])) {
$GLOBALS['db']->query("update " . DB_PREFIX . "user set sina_token ='" . $access_token . "', sina_id = '" . $sina_id . "' where id =" . intval($GLOBALS['user_info']['id']));
} else {
$root['return'] = 0;
$root['info'] = "该微博帐号已被其他会员绑定";
output($root);
}
$root['return'] = 1;
$root['info'] = "绑定成功";
$root['login_type'] = "Sina";
output($root);
}
示例8: get_bind_api_url_arr
/**
* 返回新浪绑定数组信息
* @return array("class","name","bicon",url);
*/
public function get_bind_api_url_arr()
{
require_once APP_ROOT_PATH . 'system/api_login/sina/saetv2.ex.class.php';
$o = new SaeTOAuthV2($this->api['config']['app_key'], $this->api['config']['app_secret']);
es_session::start();
//$keys = $o->getRequestToken();
if ($this->api['config']['app_url'] == "") {
$app_url = get_domain() . APP_ROOT . "/api_callback.php?c=Sina";
} else {
$app_url = $this->api['config']['app_url'];
}
$aurl = $o->getAuthorizeURL($app_url);
es_session::set("is_bind", 1);
$data['class'] = 'sina';
$data['name'] = $this->api['name'];
$data['bicon'] = $this->api['bicon'];
$data['url'] = $aurl;
return $data;
}
示例9: get_bind_api_url_arr
/**
* 返回腾讯绑定数组信息
* @return array("class","name","bicon",url);
*/
public function get_bind_api_url_arr()
{
es_session::start();
$inc = array();
$callback = SITE_DOMAIN . APP_ROOT . "/api_callback.php?c=Qqv2";
$scope = "get_user_info,add_share,list_album,add_album,upload_pic,add_topic,add_one_blog,add_weibo,check_page_fans,add_t,add_pic_t,del_t,get_repost_list,get_info,get_other_info,get_fanslist,get_idolist,add_idol,del_idol,get_tenpay_addr";
$inc['appid'] = $this->api['config']['app_key'];
$inc['appkey'] = $this->api['config']['app_secret'];
$inc['callback'] = $callback;
$inc['scope'] = $scope;
$inc['errorReport'] = 1;
$inc['storageType'] = "file";
$inc['host'] = SITE_DOMAIN;
$setting = json_encode($inc);
@file_put_contents(APP_ROOT_PATH . "/public/qqv2_inc.php", $setting);
@chmod(APP_ROOT_PATH . "/public/qqv2_inc.php", 0777);
$url = SITE_DOMAIN . APP_ROOT . "/system/api_login/qqv2/qq_login.php";
es_session::set("is_bind", 1);
$data['class'] = 'qqv2';
$data['name'] = $this->api['name'];
$data['bicon'] = $this->api['bicon'];
$data['url'] = $url;
return $data;
}
示例10: callback
public function callback()
{
es_session::start();
require_once APP_ROOT_PATH . 'system/api_login/Tencent/Tencent.php';
OAuth::init($this->api['config']['app_key'], $this->api['config']['app_secret']);
$code = trim(addslashes($_REQUEST['code']));
$openid = trim(addslashes($_REQUEST['openid']));
$openkey = trim(addslashes($_REQUEST['openkey']));
if ($this->api['config']['app_url'] == "") {
$app_url = get_domain() . APP_ROOT . "/api_callback.php?c=Tencent";
} else {
$app_url = $this->api['config']['app_url'];
}
$token_url = OAuth::getAccessToken($code, $app_url);
$result = Http::request($token_url);
$result = preg_replace('/[^\\x20-\\xff]*/', "", $result);
//清除不可见字符
$result = iconv("utf-8", "utf-8//ignore", $result);
//UTF-8转码
parse_str($result, $result_arr);
$access_token = $result_arr['access_token'];
$refresh_token = $result_arr['refresh_token'];
$name = $result_arr['name'];
$nick = $result_arr['nick'];
$is_bind = intval(es_session::get("is_bind"));
es_session::set("t_access_token", $access_token);
es_session::set("t_openid", $openid);
es_session::set("t_openkey", $openkey);
if (es_session::get("t_access_token") || es_session::get("t_openid") && es_session::get("t_openkey")) {
$msg['field'] = 'tencent_id';
$msg['id'] = $name;
$msg['name'] = $name;
$msg['t_access_token'] = $access_token;
$msg['t_openid'] = $access_token;
$msg['t_openkey'] = $openkey;
es_session::set("api_user_info", $msg);
if (!$msg['name']) {
app_redirect(url("index"));
}
$user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where tencent_id = '" . $name . "' and tencent_id <> ''");
if ($user_data) {
$user_current_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where id = " . intval($user_data['group_id']));
$user_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where score <=" . intval($user_data['score']) . " order by score desc");
if ($user_current_group['score'] < $user_group['score']) {
$user_data['group_id'] = intval($user_group['id']);
}
$GLOBALS['db']->query("update " . DB_PREFIX . "user set t_access_token ='" . $access_token . "',t_openkey = '" . $openkey . "',t_openid = '" . $openid . "', login_ip = '" . get_client_ip() . "',login_time= " . get_gmtime() . ",group_id=" . intval($user_data['group_id']) . " where id =" . $user_data['id']);
$GLOBALS['db']->query("update " . DB_PREFIX . "deal_cart set user_id = " . intval($user_data['id']) . " where session_id = '" . es_session::id() . "'");
require_once APP_ROOT_PATH . "system/libs/user.php";
auto_do_login_user($user_data['user_name'], $user_data['user_pwd'], $from_cookie = false);
es_session::delete("api_user_info");
app_recirect_preview();
} else {
$this->create_user();
app_redirect(url("shop", "user#stepone"));
}
}
}
示例11: define
<?php
if (!defined('APP_ROOT_PATH')) {
define('APP_ROOT_PATH', str_replace('system/api_login/taobao/redirect.php', '', str_replace('\\', '/', __FILE__)));
}
require_once APP_ROOT_PATH . 'system/utils/es_session.php';
es_session::start();
require_once "alipay_service.class.php";
$aliapy_config['partner'] = es_session::get('taobao_app_key');
$aliapy_config['key'] = es_session::get('taobao_app_secret');
$aliapy_config['return_url'] = es_session::get('taobao_callback');
$aliapy_config['sign_type'] = 'MD5';
$aliapy_config['input_charset'] = 'utf-8';
$aliapy_config['transport'] = 'http';
$anti_phishing_key = '';
$exter_invoke_ip = '';
$parameter = array("anti_phishing_key" => $anti_phishing_key, "exter_invoke_ip" => $exter_invoke_ip);
//构造快捷登录接口
$alipayService = new AlipayService($aliapy_config);
$html_text = $alipayService->alipay_auth_authorize($parameter);
echo $html_text;
示例12: buildImageVerify
/**
+----------------------------------------------------------
* 生成图像验证码
+----------------------------------------------------------
* @static
* @access public
+----------------------------------------------------------
* @param string $length 位数
* @param string $mode 类型
* @param string $type 图像格式
* @param string $width 宽度
* @param string $height 高度
+----------------------------------------------------------
* @return string
+----------------------------------------------------------
*/
static function buildImageVerify($length = 4, $mode = 1, $type = 'gif', $width = 48, $height = 22, $verifyName = 'verify')
{
import('ORG.Util.String');
$randval = String::rand_string($length, $mode);
es_session::start();
es_session::set($verifyName, md5($randval));
$width = $length * 10 + 10 > $width ? $length * 10 + 10 : $width;
if ($type != 'gif' && function_exists('imagecreatetruecolor')) {
$im = @imagecreatetruecolor($width, $height);
} else {
$im = @imagecreate($width, $height);
}
$r = array(225, 255, 255, 223);
$g = array(225, 236, 237, 255);
$b = array(225, 236, 166, 125);
$key = mt_rand(0, 3);
$backColor = imagecolorallocate($im, $r[$key], $g[$key], $b[$key]);
//背景色(随机)
$borderColor = imagecolorallocate($im, 100, 100, 100);
//边框色
$pointColor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
//点颜色
@imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $backColor);
@imagerectangle($im, 0, 0, $width - 1, $height - 1, $borderColor);
$stringColor = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
// 干扰
for ($i = 0; $i < 10; $i++) {
$fontcolor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
imagearc($im, mt_rand(-10, $width), mt_rand(-10, $height), mt_rand(30, 300), mt_rand(20, 200), 55, 44, $fontcolor);
}
for ($i = 0; $i < 25; $i++) {
$fontcolor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
imagesetpixel($im, mt_rand(0, $width), mt_rand(0, $height), $pointColor);
}
for ($i = 0; $i < $length; $i++) {
imagestring($im, 5, $i * 10 + 5, mt_rand(1, 8), $randval[$i], $stringColor);
}
// @imagestring($im, 5, 5, 3, $randval, $stringColor);
Image::output($im, $type);
}
示例13: callback
public function callback()
{
es_session::start();
require_once APP_ROOT_PATH . 'system/api_login/Tencent/Tencent.php';
OAuth::init($this->api['config']['app_key'], $this->api['config']['app_secret']);
$code = strim($_REQUEST['code']);
$openid = strim($_REQUEST['openid']);
$openkey = strim($_REQUEST['openkey']);
if ($this->api['config']['app_url'] == "") {
$app_url = get_domain() . APP_ROOT . "/api_callback.php?c=Tencent";
} else {
$app_url = $this->api['config']['app_url'];
}
$token_url = OAuth::getAccessToken($code, $app_url);
$result = Http::request($token_url);
$result = preg_replace('/[^\\x20-\\xff]*/', "", $result);
//清除不可见字符
$result = iconv("utf-8", "utf-8//ignore", $result);
//UTF-8转码
parse_str($result, $result_arr);
$access_token = $result_arr['access_token'];
$refresh_token = $result_arr['refresh_token'];
$name = $result_arr['name'];
$nick = $result_arr['nick'];
es_session::set("t_access_token", $access_token);
es_session::set("t_openid", $openid);
es_session::set("t_openkey", $openkey);
if (es_session::get("t_access_token") || es_session::get("t_openid") && es_session::get("t_openkey")) {
$r = Tencent::api('user/info');
$r = json_decode($r, true);
if ($r['errcode'] != 0) {
showErr("腾讯微博返回出错");
}
//name,url,province,city,avatar,token,field,token_field(授权的字段),sex,secret_field(授权密码的字段),scret,url_field(微博地址的字段)
$api_data['name'] = $r['data']['name'];
$api_data['url'] = "http://t.qq.com/" . $r['data']['name'];
$location = $r['data']['location'];
$location = explode(" ", $location);
$api_data['province'] = $location[1];
$api_data['city'] = $location[2];
$api_data['avatar'] = $r['data']['head'];
$api_data['field'] = 'tencent_id';
$api_data['token'] = $access_token;
$api_data['token_field'] = "tencent_token";
$api_data['secret'] = $openkey;
$api_data['secret_field'] = "tencent_secret";
$api_data['url_field'] = "tencent_url";
if ($r['data']['sex'] == '1') {
$api_data['sex'] = 1;
} else {
if ($r['data']['sex'] == '2') {
$api_data['sex'] = 0;
} else {
$api_data['sex'] = -1;
}
}
if ($api_data['name'] != "") {
es_session::set("api_user_info", $api_data);
}
$user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where tencent_id = '" . $openid . "' and tencent_id <> ''");
if ($user_data) {
es_session::delete("api_user_info");
$GLOBALS['db']->query("update " . DB_PREFIX . "user set tencent_token = '" . $api_data['token'] . "',tencent_secret = '" . $api_data['secret'] . "',login_ip = '" . get_client_ip() . "',login_time= " . get_gmtime() . ",tencent_url = '" . $api_data['url'] . "' where id =" . $user_data['id']);
update_user_weibo($user_data['id'], $api_data['url']);
//更新微博
es_session::set("user_info", $user_data);
app_redirect_preview();
} else {
if ($GLOBALS['user_info']) {
update_user_weibo($GLOBALS['user_info']['id'], $api_data['url']);
//更新微博
$GLOBALS['db']->query("update " . DB_PREFIX . "user set tencent_id = '" . $openid . "',tencent_token = '" . $api_data['token'] . "',tencent_secret = '" . $api_data['secret'] . "',tencent_url = '" . $api_data['url'] . "' where id =" . intval($GLOBALS['user_info']['id']));
app_redirect(url("settings#bind"));
} else {
app_redirect(url("user#api_register"));
}
}
}
}
示例14: callback
public function callback()
{
global_run();
es_session::start();
require_once APP_ROOT_PATH . 'system/api_login/Tencent/Tencent.php';
OAuth::init($this->api['config']['app_key'], $this->api['config']['app_secret']);
$code = strim($_REQUEST['code']);
$openid = strim($_REQUEST['openid']);
$openkey = strim($_REQUEST['openkey']);
if ($this->api['config']['app_url'] == "") {
$app_url = SITE_DOMAIN . APP_ROOT . "/api_callback.php?c=Tencent";
} else {
$app_url = $this->api['config']['app_url'];
}
$token_url = OAuth::getAccessToken($code, $app_url);
$result = Http::request($token_url);
$result = preg_replace('/[^\\x20-\\xff]*/', "", $result);
//清除不可见字符
$result = iconv("utf-8", "utf-8//ignore", $result);
//UTF-8转码
//过滤返回数据
parse_str($result, $result_arr);
$is_bind = intval(es_session::get("is_bind"));
if (intval($result_arr['errorCode']) != 0) {
showErr("授权失败,错误代码:" . $result_arr['errorMsg']);
die;
}
if (!$result_arr['name']) {
app_redirect(url("index"));
exit;
}
$msg['field'] = 'tencent_id';
$msg['id'] = $openid;
$msg['t_openid'] = $result_arr['openid'];
$msg['t_openkey'] = $openkey;
$msg['t_access_token'] = $result_arr['access_token'];
$msg['refresh_token'] = $result_arr['refresh_token'];
$msg['t_name'] = $result_arr['name'];
//没有登录用户无绑定情况下,创建用户时候使用到
es_session::set("api_user_info", $msg);
$user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where tencent_id = '" . $msg['id'] . "' and tencent_id <> 0");
$is_bind = intval(es_session::get("is_bind"));
//存在用户直接登录
if ($user_data) {
$GLOBALS['db']->query("update " . DB_PREFIX . "user set t_access_token = '" . $msg['t_access_token'] . "',login_ip = '" . CLIENT_IP . "',login_time= " . NOW_TIME . " where id =" . $user_data['id']);
es_session::delete("api_user_info");
if ($is_bind) {
if (intval($user_data['id']) != intval($GLOBALS['user_info']['id'])) {
showErr("该帐号已经被别的会员绑定过,请直接用帐号登录", 0, url("index", "uc_account"));
} else {
require_once APP_ROOT_PATH . "system/model/user.php";
load_user($user_data['id'], true);
es_session::set("user_info", $user_data);
app_redirect(url("index", "uc_account"));
}
} else {
require_once APP_ROOT_PATH . "system/model/user.php";
auto_do_login_user($user_data['user_name'], $user_data['user_pwd'], $from_cookie = false);
app_redirect(url("index", "index"));
}
} elseif ($is_bind == 1 && $GLOBALS['user_info']) {
//登录了站内用户,用户又不存在如果来自绑定就进行绑定
$GLOBALS['db']->query("update " . DB_PREFIX . "user set t_access_token ='" . $msg['t_access_token'] . "',t_openkey = '" . $msg['t_openkey'] . "',tencent_id = '" . $msg['id'] . "',t_name='" . $msg['t_name'] . "' where id =" . $GLOBALS['user_info']['id']);
require_once APP_ROOT_PATH . "system/model/user.php";
load_user($GLOBALS['user_info']['id'], true);
app_redirect(url("index", "uc_account"));
} else {
//没有登录站内用户,直接进行创建临时用户
$user_info = $this->create_user();
require_once APP_ROOT_PATH . "system/model/user.php";
auto_do_login_user($user_info['user_name'], $user_info['user_pwd'], $from_cookie = false);
app_redirect(url("index", "index"));
}
}
示例15: callback
public function callback()
{
es_session::start();
require_once APP_ROOT_PATH . "system/api_login/qqv2/qqConnectAPI.php";
$qc = new QC();
$access_token = $qc->qq_callback();
$openid = $qc->get_openid();
$use_info_keysArr = array("access_token" => $access_token, "openid" => $openid, "oauth_consumer_key" => $this->api['config']['app_key']);
$use_info_url = "https://graph.qq.com/user/get_user_info";
$graph_use_info_url = $qc->urlUtils->combineURL($use_info_url, $use_info_keysArr);
$response = $qc->urlUtils->get_contents($graph_use_info_url);
if ($response['ret'] != 0) {
showErr("授权失败,错误信息:" . $response['msg']);
die;
}
$msg = json_decode($response, 1);
//file_put_contents(APP_ROOT_PATH."/public/qqv2_user_info.php",print_r($msg,1));
//name,province,city,avatar,token,field,token_field(授权的字段),sex
$api_data['id'] = $openid;
$api_data['field'] = 'qq_id';
$api_data['token'] = $access_token;
$api_data['token_field'] = "qq_token";
$api_data['name'] = $msg['nickname'];
$api_data['province'] = $msg['province'];
$api_data['city'] = $msg['city'];
$api_data['avatar'] = $msg['figureurl_2'];
//100*100
if ($msg['gender'] == '女') {
$api_data['sex'] = 0;
} else {
if ($msg['gender'] == '男') {
$api_data['sex'] = 1;
} else {
$api_data['sex'] = -1;
}
}
if ($api_data['id'] != "") {
es_session::set("api_user_info", $api_data);
}
$user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where qq_id = '" . $openid . "' and qq_id <> '' and is_effect=1");
if ($user_data) {
es_session::delete("api_user_info");
$GLOBALS['db']->query("update " . DB_PREFIX . "user set qq_token = '" . $api_data['token'] . "',login_ip = '" . get_client_ip() . "',login_time= " . get_gmtime() . " where id =" . $user_data['id']);
es_session::set("user_info", $user_data);
app_redirect_preview();
} else {
if ($GLOBALS['user_info']) {
$GLOBALS['db']->query("update " . DB_PREFIX . "user set qq_token = '" . $api_data['id'] . "',qq_token = '" . $api_data['token'] . "' where id =" . intval($GLOBALS['user_info']['id']));
app_redirect(url("settings#bind"));
} else {
app_redirect(url("user#api_register"));
}
}
}