本文整理汇总了PHP中is_weixin函数的典型用法代码示例。如果您正苦于以下问题:PHP is_weixin函数的具体用法?PHP is_weixin怎么用?PHP is_weixin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_weixin函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
if (!$this->customer->isLogged()) {
$data['qq_login_url'] = $this->url->link('extension/module/qq_login/login', '', true);
$this->load->language('extension/module/qq_login');
$data['text_qq_login'] = $this->language->get('text_qq_login');
if ($this->customer->isLogged()) {
$data['logged'] = 1;
} else {
$data['logged'] = 0;
}
if (isset($this->session->data['qq_login_openid'])) {
$data['qq_login_authorized'] = 1;
} else {
$data['qq_login_authorized'] = 0;
}
$this->load->helper('mobile');
if (is_weixin()) {
$data['is_weixin'] = 1;
} else {
$data['is_weixin'] = 0;
}
return $this->load->view('extension/module/qq_login', $data);
}
}
开发者ID:brunoxu,项目名称:mycncart,代码行数:25,代码来源:qq_login.php
示例2: __construct
public function __construct()
{
check_shop_auth();
if (is_weixin()) {
m('member')->checkMember();
}
}
开发者ID:ChainBoy,项目名称:wxfx,代码行数:7,代码来源:core1.php
示例3: __construct
public function __construct()
{
if (is_weixin() === true) {
header('Location: http://m.renrenlie.com/');
}
parent::__construct();
if (!empty($_SESSION['username']) || !empty($_SESSION['cusername'])) {
$username = $_SESSION['username'] ? $_SESSION['username'] : $_SESSION['cusername'];
$decide = M('userinfo')->where("username='" . $username . "'")->select();
if (!empty($decide)) {
$table = array();
foreach ($decide as $key => $val) {
$table = $decide[$key];
}
//判断是企业or推荐人 1企业用户 0推荐人
if ($table["flag"] == "0") {
$data['url'] = U('Login/userinfo');
$data['logout'] = U('Login/logout');
$data['savepass'] = U('Login/savepass');
} else {
if ($table["flag"] == "1") {
$data['url'] = U('Company/EnterpriseInformation');
$data['logout'] = U('Login/logout');
$data['savepass'] = U('Login/savepass');
}
}
$this->assign("data", $data);
}
}
}
开发者ID:xiaoyueer98,项目名称:pc.rrl.com,代码行数:30,代码来源:IndexController.class.php
示例4: index
public function index()
{
$this->load->model('account/customer');
$this->load->language('extension/module/weixin_login');
$this->document->setTitle($this->language->get('heading_title'));
$data['text_weixin_login'] = $this->language->get('text_weixin_login');
if ($this->customer->isLogged()) {
$data['logged'] = 1;
} else {
$data['logged'] = 0;
}
if (isset($this->session->data['weixin_login_unionid'])) {
$data['weixin_login_authorized'] = 1;
} else {
$data['weixin_login_authorized'] = 0;
}
$this->load->helper('mobile');
if (is_weixin()) {
$data['is_weixin'] = 1;
} else {
$data['is_weixin'] = 0;
}
if (is_mobile()) {
$data['is_mobile'] = 1;
} else {
$data['is_mobile'] = 0;
}
$appid = $this->config->get('weixin_login_appid');
$appkey = $this->config->get('weixin_login_appkey');
$data['weixin_login'] = $this->url->link('extension/module/weixin_login/login', '', 'SSL');
$weixin_pclogin_redirect_uri = HTTPS_SERVER . 'index.php?route=extension/module/weixin_login/weixin_pclogin_code';
$data['wxpclogin_url'] = 'https://open.weixin.qq.com/connect/qrconnect?appid=' . $appid . '&redirect_uri=' . urlencode($weixin_pclogin_redirect_uri) . '&response_type=code&scope=snsapi_login&state=STATE#wechat_redirect';
return $this->load->view('extension/module/weixin_login', $data);
}
开发者ID:brunoxu,项目名称:mycncart,代码行数:34,代码来源:weixin_login.php
示例5: index
public function index()
{
if (!$this->customer->isLogged()) {
$appkey = $this->config->get('weibo_login_appkey');
$appsecret = $this->config->get('weibo_login_appsecret');
$callback_url = $this->url->link('extension/module/weibo_login/callback', '', true);
$this->load->language('extension/module/weibo_login');
$data['text_weibo_login'] = $this->language->get('text_weibo_login');
include_once DIR_SYSTEM . 'library/weibo/saetv2.ex.class.php';
$o = new SaeTOAuthV2($appkey, $appsecret);
$data['code_url'] = $o->getAuthorizeURL($callback_url);
if ($this->customer->isLogged()) {
$data['logged'] = 1;
} else {
$data['logged'] = 0;
}
if (isset($this->session->data['weibo_login_access_token']) && isset($this->session->data['weibo_login_uid'])) {
$data['weibo_login_authorized'] = 1;
} else {
$data['weibo_login_authorized'] = 0;
unset($this->session->data['weibo_login_access_token']);
unset($this->session->data['weibo_login_uid']);
}
$this->load->helper('mobile');
if (is_weixin()) {
$data['is_weixin'] = 1;
} else {
$data['is_weixin'] = 0;
}
return $this->load->view('extension/module/weibo_login', $data);
}
}
开发者ID:brunoxu,项目名称:mycncart,代码行数:32,代码来源:weibo_login.php
示例6: getMethod
public function getMethod($address, $total)
{
$this->load->language('extension/payment/alipay_wap');
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int) $this->config->get('alipay_wap_geo_zone_id') . "' AND country_id = '" . (int) $address['country_id'] . "' AND (zone_id = '" . (int) $address['zone_id'] . "' OR zone_id = '0')");
if ($this->config->get('alipay_wap_total') > $total) {
$status = false;
} elseif (!$this->config->get('alipay_wap_geo_zone_id')) {
$status = true;
} elseif ($query->num_rows) {
$status = true;
} else {
$status = false;
}
//判断是否移动设备访问
$this->load->helper('mobile');
if (is_mobile()) {
if (is_weixin()) {
$status = false;
} else {
$status = true;
}
} else {
$status = false;
}
$currencies = array('CNY');
if (!in_array(strtoupper($this->session->data['currency']), $currencies)) {
$status = false;
}
$method_data = array();
if ($status) {
$method_data = array('code' => 'alipay_wap', 'title' => $this->language->get('text_title'), 'terms' => '', 'sort_order' => $this->config->get('alipay_wap_sort_order'));
}
return $method_data;
}
开发者ID:brunoxu,项目名称:mycncart,代码行数:34,代码来源:alipay_wap.php
示例7: __construct
public function __construct()
{
global $_W;
$this->autoFinishOrders();
if (is_weixin()) {
m('member')->checkMember();
}
}
开发者ID:noikiy,项目名称:mygit,代码行数:8,代码来源:core.php
示例8: __construct
public function __construct()
{
if (is_weixin() === true) {
header('Location: http://m.renrenlie.com/');
}
parent::__construct();
$linkArr = M("friendlink")->where("status=0")->order("orderid desc,id asc")->select();
$this->assign("linkArr", $linkArr);
}
开发者ID:xiaoyueer98,项目名称:pc.rrl.com,代码行数:9,代码来源:ActiveController.class.php
示例9: get_user_wecha_id_new
function get_user_wecha_id_new()
{
$rt = $this->action('common', '_get_appid_appsecret');
if (is_weixin() == false || $rt['is_oauth'] == '0') {
unset($rt);
return "";
}
unset($rt);
$t = Common::_return_px();
$cache = Import::ajincache();
$cache->SetFunction(__FUNCTION__);
$cache->SetMode('user' . $t);
$uid = $this->Session->read('User.uid');
$fn = $cache->fpath(array('0' => $uid));
if (file_exists($fn) && !$cache->GetClose() && !isset($_GET['code'])) {
include $fn;
} else {
if (!isset($_GET['code'])) {
$this->action('common', 'get_user_code');
//授权跳转
}
$code = isset($_GET['code']) ? $_GET['code'] : '';
if (!empty($code)) {
$rr = $this->action('common', '_get_appid_appsecret');
$appid = $rr['appid'];
$appsecret = $rr['appsecret'];
$access_token = $this->action('common', '_get_access_token');
$url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=' . $appid . '&secret=' . $appsecret . '&code=' . $code . '&grant_type=authorization_code';
$con = $this->action('common', 'curlGet', $url);
$json = json_decode($con);
if (empty($access_token)) {
$access_token = $json->access_token;
}
$wecha_id = $json->openid;
$refresh_token = $json->refresh_token;
//获取 refresh_token
if (!empty($refresh_token) && !empty($access_token)) {
if (empty($wecha_id)) {
$url = 'https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=' . $appid . '&grant_type=refresh_token&refresh_token=' . $refresh_token;
$con = $this->action('common', 'curlGet', $url);
$json = json_decode($con);
$wecha_id = $json->openid;
//获取 openid
}
}
}
$cache->write($fn, $wecha_id, 'wecha_id');
}
return $wecha_id;
}
开发者ID:jasonhzy,项目名称:wxfx,代码行数:50,代码来源:controller.php
示例10: index
public function index()
{
if ($this->customer->isLogged()) {
$this->customer->logout();
unset($this->session->data['shipping_address']);
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_address']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
unset($this->session->data['comment']);
unset($this->session->data['order_id']);
unset($this->session->data['coupon']);
unset($this->session->data['reward']);
unset($this->session->data['voucher']);
unset($this->session->data['vouchers']);
unset($this->session->data['qq_nickname']);
unset($this->session->data['weixin_login_openid']);
unset($this->session->data['weixin_login_unionid']);
unset($this->session->data['weixin_pclogin_openid']);
unset($this->session->data['weixin_pclogin_unionid']);
//remember weixin click logout
$this->load->helper('mobile');
if (is_weixin()) {
$this->session->data['weixin_logout_status'] = 1;
}
$this->response->redirect($this->url->link('account/logout', '', true));
}
$this->load->language('account/logout');
$this->document->setTitle($this->language->get('heading_title'));
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'));
$data['breadcrumbs'][] = array('text' => $this->language->get('text_account'), 'href' => $this->url->link('account/account', '', true));
$data['breadcrumbs'][] = array('text' => $this->language->get('text_logout'), 'href' => $this->url->link('account/logout', '', true));
$data['heading_title'] = $this->language->get('heading_title');
$data['text_message'] = $this->language->get('text_message');
$data['button_continue'] = $this->language->get('button_continue');
$data['continue'] = $this->url->link('common/home');
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('common/success', $data));
}
开发者ID:brunoxu,项目名称:mycncart,代码行数:46,代码来源:logout.php
示例11: __construct
public function __construct($name = '')
{
parent::__construct();
$this->modulename = 'ewei_shop';
$this->pluginname = $name;
$this->loadModel();
if (strexists($_SERVER['REQUEST_URI'], '/web/')) {
cpa($this->pluginname);
} else {
if (strexists($_SERVER['REQUEST_URI'], '/app/')) {
if (is_weixin()) {
$this->setFooter();
}
}
}
$this->module['title'] = pdo_fetchcolumn('select title from ' . tablename('modules') . " where name='ewei_shop' limit 1");
}
开发者ID:ChainBoy,项目名称:wxfx,代码行数:17,代码来源:plugin.php
示例12: _initialize
function _initialize()
{
$is_weixin = is_weixin();
if ($is_weixin) {
$code = $_REQUEST["code"];
if (!empty($code)) {
$this->_welogin($code);
}
}
$auth_id = session(C('USER_AUTH_KEY'));
if (!isset($auth_id)) {
//跳转到认证网关
redirect(U(C('USER_AUTH_GATEWAY')));
}
$this->assign('js_file', 'js/' . ACTION_NAME);
$this->_assign_menu();
$this->_assign_new_count();
}
开发者ID:zqstudio2015,项目名称:smeoa,代码行数:18,代码来源:CommonAction.class.php
示例13: php_self
$php_self = php_self();
////////////////////////////////////
$wap_user = !empty($_SESSION['wap_user']) ? $_SESSION['wap_user'] : array();
//检测分销商是否存在
if (!empty($_SESSION['wap_drp_store']) && $_SESSION['wap_drp_store']['store_id'] != $tmp_store_id) {
$store_exists = D('Store')->where(array('store_id' => $_SESSION['wap_drp_store']['store_id'], 'status' => 1))->find();
if (empty($store_exists)) {
//店铺不存在或已删除
unset($_SESSION['wap_drp_store']);
//删除保存在session中分销商
}
}
/*是否移动端*/
$is_mobile = is_mobile();
/*是否微信端*/
$is_weixin = is_weixin();
//热门关键词
$hot_keyword = D('Search_hot')->where('1')->order('sort DESC')->limit(8)->select();
//合并SESSION和UID的购物车、订单、收货地址等信息
function mergeSessionUserInfo($sessionid, $uid)
{
//购物车
D('User_cart')->where(array('uid' => 0, 'session_id' => $sessionid))->data(array('uid' => $uid, 'session_id' => ''))->save();
//订单
$edit_rows = D('Order')->where(array('uid' => 0, 'session_id' => $sessionid))->data(array('uid' => $uid, 'session_id' => ''))->save();
if ($edit_rows && $_COOKIE['wap_store_id']) {
//分销订单
D('Fx_order')->where(array('uid' => 0, 'session_id' => $sessionid))->data(array('uid' => $uid, 'session_id' => ''))->save();
M('Store_user_data')->updateData($_COOKIE['wap_store_id'], $uid);
}
//收货地址
开发者ID:fkssei,项目名称:pigcms10,代码行数:31,代码来源:global.php
示例14: getGET
/**
* Created by PhpStorm.
* User: apple
* Date: 15/9/16
* Time: 下午2:04
*/
include 'library/init.inc.php';
$code = getGET('code');
$log->record_array($_GET);
if ($code != '') {
$code = $db->escape($code);
$url = $db->fetchOne('select `url` from ' . $db->table('short_link') . ' where `hash`=\'' . $code . '\'');
$log->record($url . ',' . $_SERVER['REQUEST_URI']);
$url = 'http://' . $_SERVER['HTTP_HOST'] . preg_replace('/d\\/[a-zA-Z].*$/', $url, $_SERVER['REQUEST_URI']);
$log->record('target url:' . $url);
if (is_weixin() && $_SESSION['openid'] == '') {
$oathor_url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_userinfo&state=2048#wechat_redirect';
$url = sprintf($oathor_url, $config['appid'], urlencode($url));
redirect($url);
} else {
redirect($url);
}
exit;
}
$opera = getPOST('opera');
if ($opera == 'get_url') {
$response = array('error' => 1, 'msg' => '');
if (true || !check_cross_domain()) {
$url = getPOST('url');
$account = getPOST('account');
if ($url == '') {
开发者ID:Winsen1990,项目名称:easyilife,代码行数:31,代码来源:index.php
示例15: __construct
public function __construct()
{
if (is_weixin() === true) {
header('Location: http://m.renrenlie.com/');
}
parent::__construct();
$linkArr = M("friendlink")->where("status=0")->order("orderid desc,id asc")->select();
$this->assign("linkArr", $linkArr);
import('ORG.Util.Page');
$model2 = M('userinfo', 'stj_', 'DB_CONFIG1');
$model = M('casclist', 'stj_', 'DB_CONFIG1');
$model3 = M('member', 'stj_', 'DB_CONFIG1');
$username = $_SESSION['username'];
$userinfo = M('member')->where("username='" . $username . "'")->find();
$this->userinfo = $userinfo;
if (!empty($_SESSION['username']) || !empty($_SESSION['cusername'])) {
$username = $_SESSION['username'] ? $_SESSION['username'] : $_SESSION['cusername'];
$decide = $model2->where("username='" . $username . "'")->select();
if (!empty($decide)) {
$table = array();
foreach ($decide as $key => $val) {
$table = $decide[$key];
}
$cUserInfo = $this->getCompanyInfo();
//判断基本资料是否填写完整
if ($cUserInfo['cpname'] && isset($cUserInfo['mobile'])) {
$leftNavCompleted['userinfo_completed'] = true;
} else {
$leftNavCompleted['userinfo_completed'] = false;
}
//判断合同
if (isset($cUserInfo['contract']) && $cUserInfo['checkcontract'] == 1) {
$leftNavCompleted['contract_completed'] = true;
} else {
$leftNavCompleted['contract_completed'] = false;
}
$isJob = M("job")->where("cpid='" . $cUserInfo['id'] . "'")->find();
if (!empty($isJob)) {
$leftNavCompleted['job_completed'] = true;
} else {
$leftNavCompleted['job_completed'] = false;
}
$sql = "select r.id from stj_record as r left join stj_job as j on r.j_id=j.id where j.cpid='{$cUserInfo['id']}'";
$jlist = M("record")->query($sql);
if (!empty($jlist)) {
$leftNavCompleted['record_completed'] = true;
} else {
$leftNavCompleted['record_completed'] = false;
}
$this->assign("leftNavCompleted", $leftNavCompleted);
//判断是企业or推荐人 1企业用户 0推荐人
if ($table["flag"] == "0") {
$data['url'] = U('Login/userinfo');
$data['logout'] = U('Login/logout');
$data['savepass'] = U('Login/savepass');
} else {
if ($table["flag"] == "1") {
$data['url'] = U('Company/EnterpriseInformation');
$data['logout'] = U('Login/logout');
$data['savepass'] = U('Login/savepass');
}
}
$this->assign("data", $data);
}
} else {
$this->error("您长时间未操作,已登录超时,若想继续操作,请重新登录!", U('Index/index'));
}
}
开发者ID:xiaoyueer98,项目名称:pc.rrl.com,代码行数:68,代码来源:CompanyController.class.php
示例16: content_5656ce9706c355_65233174
function content_5656ce9706c355_65233174($_smarty_tpl)
{
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<title><?php
echo $_smarty_tpl->tpl_vars['config']->value['site_name'];
?>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, width=device-width">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="application-name" content="<?php
echo $_smarty_tpl->tpl_vars['config']->value['site_name'];
?>
">
<link rel="apple-touch-icon-precomposed" href="<?php
echo $_smarty_tpl->tpl_vars['template_dir']->value;
?>
images/touch/touch-icon-iphone.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="<?php
echo $_smarty_tpl->tpl_vars['template_dir']->value;
?>
images/touch/touch-icon-ipad.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="<?php
echo $_smarty_tpl->tpl_vars['template_dir']->value;
?>
images/touch/touch-icon-iphone4.png">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="www.kwanson.com">
<meta name="version" content="v.1.0.0">
<meta http-equiv="Cache-Control" content="no-cache">
<meta name="format-detection" content="telephone=no, address=no">
<link rel="stylesheet" href="<?php
echo $_smarty_tpl->tpl_vars['template_dir']->value;
?>
css/common.css">
<link rel="stylesheet" href="<?php
echo $_smarty_tpl->tpl_vars['template_dir']->value;
?>
css/app.css">
<link rel="stylesheet" href="<?php
echo $_smarty_tpl->tpl_vars['template_dir']->value;
?>
css/index.css">
<link rel="stylesheet" href="<?php
echo $_smarty_tpl->tpl_vars['template_dir']->value;
?>
css/fonts.css">
<script type="text/javascript" src="<?php
echo $_smarty_tpl->tpl_vars['template_dir']->value;
?>
js/jquery-1.11.0.min.js"></script>
<?php
if (is_weixin()) {
?>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
<?php
}
?>
</head>
<body>
<!-- 首页头部 -->
<header class="header">
<div class="logo">
<a href="#"><?php
echo $_smarty_tpl->tpl_vars['config']->value['site_name'];
?>
</a>
</div>
<div class="search_box" style="text-align: center">
<?php
echo $_smarty_tpl->tpl_vars['config']->value['site_name'];
?>
<!--
<a href="#" >
<div class="search">
<form method="get" action="">
<div class="text_box">
<input id="keyword" name="keyword" type="text" placeholder="搜索商品/店铺" class="keyword text" onkeydown="this.style.color='#404040'" autocomplete="off">
</div>
<input type="submit" value="" class="submit" dd_name="搜索">
</form>
</div>
</a>
-->
</div>
</header>
<!-- 广告轮播区 -->
<section id="focus" class="focus">
<div class="hd">
<ul></ul>
</div>
//.........这里部分代码省略.........
开发者ID:Winsen1990,项目名称:direct-sale,代码行数:101,代码来源:a73117c7bc791a162d0449c049d0c7927d14b94d.file.index.phtml.php
示例17: wap_getStore
public function wap_getStore($store_id)
{
$store = $this->db->where(array('store_id' => $store_id, 'status' => 1))->find();
if (!empty($store)) {
$_SESSION['tmp_store_id'] = $store_id;
//解决用户访问不同店铺重复授权生成新用户问题
/*if (empty($_SESSION['wap_user']) && !empty($_COOKIE['uid'])) { //COOKIE中有用户信息
$tmp_user = M('User')->checkUser(array('uid' => $_COOKIE['uid']));
if (!empty($tmp_user)) {
$_SESSION['wap_user'] = $tmp_user;
$tmp_seller = D('Store')->where(array('drp_supplier_id' => $store_id, 'uid' => $_COOKIE['uid'], 'status' => 1))->find();
if (!empty($tmp_seller)) {
$_SESSION['wap_drp_store'] = $tmp_seller;
if (!empty($tmp_seller['oauth_url'])) { //对接微店
$_SESSION['sync_user'] = true;
}
}
setcookie('uid', $_COOKIE['uid'], $_SERVER['REQUEST_TIME']+10000000, '/'); //延长cookie有效期
} else {
unset($_SESSION['sync_user']); //删除同步标识
unset($_SESSION['wap_user']); //删除用户登录状态
}
}*/
//判断是否为对接微店
if (!empty($store['oauth_url'])) {
if (!empty($_SESSION['wap_user']) && $_SESSION['wap_user']['store_id'] != $store_id) {
//非当前店铺粉丝,重新授权登陆
unset($_SESSION['sync_user']);
//删除同步标识
unset($_SESSION['wap_user']);
//删除用户登录状态
}
} else {
unset($_SESSION['sync_user']);
//非对接店铺 删除同步标识
}
//对接网站用户授权登陆
//授权条件:非对接同步用户,是对接店铺,店铺管理后台未登录(不加此条件,店铺管理后台的所有链接无法在pc端打开,都会跳转授权)
if (empty($_SESSION['sync_user']) && !empty($store['oauth_url']) && empty($_SESSION['sync_store'])) {
$return_url = urlencode('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
if (!empty($store['oauth_url'])) {
if (stripos($store['oauth_url'], '?') === false) {
redirect($store['oauth_url'] . '?return_url=' . $return_url . '&store_id=' . $store_id . '&token=' . $store['token']);
} else {
redirect($store['oauth_url'] . '&return_url=' . $return_url . '&store_id=' . $store_id . '&token=' . $store['token']);
}
}
} else {
if (empty($_SESSION['sync_user']) && empty($store['oauth_url']) && empty($_SESSION['store'])) {
//默认授权
//授权条件:非对接同步用户,非对接店铺,店铺管理后台未登录(不加此条件,店铺管理后台的所有链接无法在pc端打开,都会跳转授权)
/*是否移动端*/
$is_mobile = is_mobile();
/*是否微信端*/
$is_weixin = is_weixin();
//调试 清除登录信息
//setcookie('pigcms_sessionid','',$_SERVER['REQUEST_TIME']-10000000,'/');
//$_SESSION = null;
//session_destroy();
/*如果是微信端,且配置文件中配置了微信信息,得到openid*/
if ($is_weixin && (empty($_SESSION['openid']) || empty($_SESSION['wap_user']))) {
//openid存在 通过openid查找用户
if (!empty($_SESSION['openid'])) {
$userinfo = M('User')->get_user('openid', $_SESSION['openid']);
$_SESSION['wap_user'] = $userinfo['user'];
mergeSessionUserInfo(session_id(), $userinfo['user']['uid']);
unset($_SESSION['wap_drp_store']);
}
//用户未登录 调用授权获取openid, 通过openid查找用户,如果已经存在,设置登录,如果不存在,添加一个新用户和openid关联
if (empty($_SESSION['wap_user'])) {
$customeUrl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
//判断店铺是否绑定过认证服务号
$wx_bind = D('Weixin_bind')->where(array('store_id' => $store['store_id']))->find();
if (empty($_GET['code'])) {
$_SESSION['weixin']['state'] = md5(uniqid());
if (!empty($wx_bind) && $wx_bind['service_type_info'] == 2 && $wx_bind['verify_type_info'] == 0) {
$oauthUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . $wx_bind['authorizer_appid'] . '&redirect_uri=' . urlencode($customeUrl) . '&response_type=code&scope=snsapi_userinfo&state=' . $_SESSION['weixin']['state'] . '&component_appid=' . option('config.wx_appid') . '#wechat_redirect';
} else {
//店铺非认证服务号走总后台授权
$oauthUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . option('config.wechat_appid') . '&redirect_uri=' . urlencode($customeUrl) . '&response_type=code&scope=snsapi_userinfo&state=' . $_SESSION['weixin']['state'] . '#wechat_redirect';
}
redirect($oauthUrl);
exit;
} else {
if (isset($_GET['code']) && isset($_GET['state']) && $_GET['state'] == $_SESSION['weixin']['state']) {
unset($_SESSION['weixin']);
import('Http');
$http = new Http();
if (!empty($wx_bind) && $wx_bind['service_type_info'] == 2 && $wx_bind['verify_type_info'] == 0) {
$component_token = M('Weixin_bind')->get_access_token($store['store_id'], true);
$tokenUrl = 'https://api.weixin.qq.com/sns/oauth2/component/access_token?appid=' . $wx_bind['authorizer_appid'] . '&code=' . $_GET['code'] . '&grant_type=authorization_code&component_appid=' . option('config.wx_appid') . '&component_access_token=' . $component_token;
} else {
$tokenUrl = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=' . option('config.wechat_appid') . '&secret=' . option('config.wechat_appsecret') . '&code=' . $_GET['code'] . '&grant_type=authorization_code';
}
$return = $http->curlGet($tokenUrl);
$jsonrt = json_decode($return, true);
if ($jsonrt['errcode']) {
$error_msg_class = new GetErrorMsg();
exit('授权发生错误:' . $jsonrt['errcode']);
}
//.........这里部分代码省略.........
开发者ID:fkssei,项目名称:pigcms10,代码行数:101,代码来源:store_model.php
示例18: index
public function index()
{
$wechat_url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER["REQUEST_URI"];
$this->load->helper('mobile');
if (is_weixin()) {
if (!$this->customer->isLogged()) {
if ($this->config->get('weixin_login_status')) {
if ($this->config->get('wxpay_status')) {
if (isset($this->session->data['weixin_login_openid']) && isset($this->session->data['weixin_login_unionid'])) {
if (isset($this->session->data['weixin_logout_status'])) {
if ($this->session->data['weixin_logout_status'] == 0) {
if ($this->customer->login_weixin($this->session->data['weixin_login_unionid'])) {
unset($this->session->data['guest']);
// Default Shipping Address
$this->load->model('account/address');
if ($this->config->get('config_tax_customer') == 'payment') {
$this->session->data['payment_address'] = $this->model_account_address->getAddress($this->customer->getAddressId());
}
if ($this->config->get('config_tax_customer') == 'shipping') {
$this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->customer->getAddressId());
}
} else {
}
}
} else {
if ($this->customer->login_weixin($this->session->data['weixin_login_unionid'])) {
unset($this->session->data['guest']);
// Default Shipping Address
$this->load->model('account/address');
if ($this->config->get('config_tax_customer') == 'payment') {
$this->session->data['payment_address'] = $this->model_account_address->getAddress($this->customer->getAddressId());
}
if ($this->config->get('config_tax_customer') == 'shipping') {
$this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->customer->getAddressId());
}
$this->response->redirect($wechat_url);
} else {
}
}
} elseif (isset($this->request->get['code'])) {
$appid = $this->config->get('wxpay_appid');
$appsecret = $this->config->get('wxpay_appsecret');
$openid_result = getOpenid($appid, $appsecret, $this->request->get['code']);
$unionid_result = getWeiXinUserInfo($appid, $appsecret, $openid_result['openid']);
if ($openid_result && $unionid_result) {
$this->session->data['weixin_login_openid'] = $openid_result['openid'];
$this->session->data['weixin_openid'] = $openid_result['openid'];
$this->session->data['weixin_login_unionid'] = $unionid_result['unionid'];
} else {
$this->session->data['weixin_login_openid'] = '';
$this->session->data['weixin_openid'] = '';
$this->session->data['weixin_login_unionid'] = '';
}
header('Location: ' . $wechat_url);
} else {
$appid = $this->config->get('wxpay_appid');
header('Location: https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . $appid . '&redirect_uri=' . $wechat_url . '&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect');
}
}
} else {
//if weixin login disabled
if ($this->config->get('wxpay_status')) {
if (isset($this->session->data['weixin_login_openid'])) {
} elseif (isset($this->request->get['code'])) {
$appid = $this->config->get('wxpay_appid');
$appsecret = $this->config->get('wxpay_appsecret');
$openid_result = getOpenid($appid, $appsecret, $this->request->get['code']);
$this->session->data['weixin_login_openid'] = '';
$this->session->data['weixin_openid'] = $openid_result['openid'];
$this->session->data['weixin_login_unionid'] = '';
} else {
$appid = $this->config->get('wxpay_appid');
header('Location: https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . $appid . '&redirect_uri=' . $wechat_url . '&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect');
}
}
}
}
}
}
开发者ID:brunoxu,项目名称:mycncart,代码行数:79,代码来源:weixin.php
示例19: user_auto_login
function user_auto_login()
{
$rt = $this->_get_appid_appsecret();
if (is_weixin() == false || $rt['is_oauth'] == '0') {
return;
}
//一下用于测试
/* if($GLOBALS['LANG']['is_cache']=='1'&&!isset($_GET['code'])){
|
请发表评论