//处理微信登录
if(isset($_REQUEST['code'])&&isset($_REQUEST['state']))
{
include_once(ROOT_PATH . 'includes/website/jntoo.php');
$c = &website('wechat');
if($c)
{
if(!$c->DO_CHECK($_REQUEST['state']))
{
show_message('非法访问或请求超时!' , '首页',$ecs->url() , 'error');
}
$access = $c->Code2Token($_REQUEST['code']);
if(!$access)
show_message('非法访问或请求超时!' , '首页',$ecs->url() , 'error');
$access = $c->GetRefreshToken($access['refresh_token']);
if(!$access)
show_message('非法访问或请求超时!' , '首页',$ecs->url() , 'error');
$info = $c->Getinfo($access['access_token'],$access['openid']);
if(!$info)
show_message('非法访问或请求超时!' , '首页',$ecs->url() , 'error');
//获取微信传递过来的微信用户信息
$nickname = $info['nickname'];
$sex = $info['sex'];
$openid = $info['openid'];
$headimgurl = $info['headimgurl'];
$unionid = $info['unionid'];
$info_user_id = 'wx_'.$info['unionid'];
if(!$info['openid'])
show_message($c->get_error() , '首页' , $ecs->url() , 'error' , false);
$sql = 'SELECT user_name,password,aite_id FROM '.$ecs->table('users').' WHERE aite_id = "'.$info_user_id.'" or wxid = "'.$openid.'"';
$count = $db->getAll($sql);
if(!$count)
{
//如果没有记录,则新建微信用户并提示绑定
$smarty->assign('wechatid', $info_user_id);
$smarty->assign('openid', $openid);
$smarty->assign('wx_name', $nickname);
$smarty->assign('headimg', $headimgurl);
$smarty->assign('unionid', $unionid);
$smarty->assign('sex', $sex);
$smarty->assign('action', 'wechat_ready');
$smarty->display('user_passport.dwt');
$url = $c->login($ecs->url().'user.php?act=wechatbd&callblock='.urlencode($back_act).'&open='.$open);
if(!$url)
{
show_message( $c->get_error() , '首页', $ecs->url() , 'error');
}
header('Location: '.$url);
}
else
{
//如果没有信息
for($i=0;$i<count($count);$i++) {
if($count[$i]['aite_id'] == $info_user_id) {
$user_name = $count[$i]['user_name'];
break;
}
else
{
$sql = 'UPDATE '.$ecs->table('users')." SET aite_id = '$info_user_id' WHERE user_id = '$count[$i][user_id]'";
$db->query($sql);
$user_name = $count[$i]['user_name'];
break;
}
}
}
$user->set_session($user_name);
$user->set_cookie($user_name);
update_user_info();
recalculate_price();
show_message($_LANG['login_success'] . $ucdata , array($_LANG['back_up_page'], $_LANG['profile_lnk']), array('index.php','user.php'), 'info');
}
else
show_message('服务器尚未注册该插件!' , '首页',$ecs->url() , 'error');
}
/* by tiandi 微信绑定用户 */
elseif($action == 'wechatbd') {
if(isset($_REQUEST['wechatid']) && $_REQUEST['wechatid'] != '')
$wechatid = mysql_real_escape_string($_REQUEST['wechatid']);
if(isset($_REQUEST['openid']) && $_REQUEST['openid'] != '')
$wechatid = mysql_real_escape_string($_REQUEST['openid']);
if(isset($_REQUEST['username']) && $_REQUEST['username'] != '')
$username = mysql_real_escape_string($_REQUEST['username']);
if(isset($_REQUEST['password']) && $_REQUEST['password'] != '')
$password = mysql_real_escape_string($_REQUEST['password']);
if(isset($_REQUEST['wx_name']) && $_REQUEST['wx_name'] != '')
$wx_name = mysql_real_escape_string($_REQUEST['wx_name']);
if(isset($_REQUEST['headimg']) && $_REQUEST['headimg'] != '')
$headimg = mysql_real_escape_string($_REQUEST['headimg']);
if(isset($_REQUEST['unionid']) && $_REQUEST['unionid'] != '')
$unionid = mysql_real_escape_string($_REQUEST['unionid']);
if(isset($_REQUEST['sex']) && $_REQUEST['sex'] != '')
$sex = mysql_real_escape_string($_REQUEST['sex']);
//用户不绑定账号
if(!$wechatid || !$username || !$password)
{
$username = $wx_name;
$password = $user->compile_password(array('password'=>$unionid));
$sql = 'INSERT INTO '.$ecs->table('users').'(user_name , password, nickname,aite_id , sex ,reg_time , user_rank , is_validated, wxid, headimg) VALUES '.
"('$username' , '$password' , '$wx_name' ,'$wechatid' , '$sex' , '".gmtime()."' , '99' , '0' , '$openid' , '$headimg')" ;
$db->query($sql);
$sql = "INSERT INTO '".$ecs->table('wechat_user')."' ('nickname' , 'subscribe' , 'openid' , 'subscribe_time' , 'headimgurl' , 'unionid') VALUES ('$wx_name','1','$openid','$time','$headimg','$unionid')";
$db->query($sql);
$user->set_session($username);
$user->set_cookie($username);
update_user_info();
recalculate_price();
show_message($_LANG['login_success'] . $ucdata , array($_LANG['back_up_page'], $_LANG['profile_lnk']), array($back_act,'user.php'), 'info');
}
//用户绑定账号
if ($user->login($username, $password,isset($_POST['remember'])))
{
//不考虑用户是否已经绑定过微信
$sql = "UPDATE ".$ecs->table('users')." SET aite_id = '$wechatid' ,headimg = '$headimg' ,wxid = '$openid', wxch_bd = 'ok' WHERE user_name = '$username'";
$db->query($sql);
show_message('已经成功的将您的微信号与'.$username.'绑定!' , array($_LANG['back_up_page'], $_LANG['profile_lnk']), array($back_act,'user.php'), 'info');
}
show_message('用户名和密码不正确,绑定失败!');
}
// 第三方登录接口
elseif($action == 'oath')
{
$type = empty($_REQUEST['type']) ? '' : $_REQUEST['type'];
if($type == "taobao"){
header("location:includes/website/tb_index.php");exit;
}
include_once(ROOT_PATH . 'includes/website/jntoo.php');
$c = &website($type);
if($c)
{
if (empty($_REQUEST['callblock']))
{
if (empty($_REQUEST['callblock']) && isset($GLOBALS['_SERVER']['HTTP_REFERER']))
{
$back_act = strpos($GLOBALS['_SERVER']['HTTP_REFERER'], 'user.php') ? 'index.php' : $GLOBALS['_SERVER']['HTTP_REFERER'];
}
else
{
$back_act = 'index.php';
}
}
else
{
$back_act = trim($_REQUEST['callblock']);
}
if($back_act[4] != ':') $back_act = $ecs->url().$back_act;
$open = empty($_REQUEST['open']) ? 0 : intval($_REQUEST['open']);
if($type == "wechat")
{
$url = $c->wxlogin($ecs->url().'user.php?callblock='.urlencode($back_act).'&open='.$open);
}
else
{
$url = $c->login($ecs->url().'user.php?act=oath_login&type='.$type.'&callblock='.urlencode($back_act).'&open='.$open);
}
if(!$url)
{
show_message( $c->get_error() , '首页', $ecs->url() , 'error');
}
header('Location: '.$url);
}
else
{
show_message('服务器尚未注册该插件!' , '首页',$ecs->url() , 'error');
}
}
// 处理第三方登录接口
elseif($action == 'oath_login')
{
$type = empty($_REQUEST['type']) ? '' : $_REQUEST['type'];
include_once(ROOT_PATH . 'includes/website/jntoo.php');
$c = &website($type);
if($c)
{
$access = $c->getAccessToken();
if(!$access)
{
show_message( $c->get_error() , '首页', $ecs->url() , 'error');
}
$c->setAccessToken($access);
$info = $c->getMessage();
if(!$info)
{
show_message($c->get_error() , '首页' , $ecs->url() , 'error' , false);
}
if(!$info['user_id'])
show_message($c->get_error() , '首页' , $ecs->url() , 'error' , false);
$info_user_id = $type .'_'.$info['user_id']; // 加个标识!!!防止 其他的标识 一样 // 以后的ID 标识 将以这种形式 辨认
$info['name'] = str_replace("'" , "" , $info['name']); // 过滤掉 逗号 不然出错 很难处理 不想去 搞什么编码的了
if(!$info['user_id'])
show_message($c->get_error() , '首页' , $ecs->url() , 'error' , false);
$sql = 'SELECT user_name,password,aite_id FROM '.$ecs->table('users').' WHERE aite_id = \''.$info_user_id.'\' OR aite_id=\''.$info['user_id'].'\'';
$count = $db->getRow($sql);
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ECShop PC端第三方登录插件--微信QQ微博淘宝支付宝--五合一有后台版-UTF-8.zip (39个子文件)
ECShop PC端第三方登录插件--微信QQ微博淘宝支付宝--五合一有后台版-UTF-8
默认模板安装说明.txt 3KB
admin
templates
website_view.htm 685B
website_install.htm 2KB
website.htm 4KB
website.php 8KB
images
wechat_login_logo.gif 2KB
alipay_login.png 5KB
alipay_logo_16.gif 1KB
sina_login.gif 2KB
qq_logins_24.png 3KB
sina_login_24.png 6KB
taobao_login_logo.gif 2KB
qq_login_18.png 2KB
qq_login_16.png 3KB
taobao_logo_16.gif 13KB
alipaysmall.gif 1KB
sina_logo_16.png 3KB
alipay_login_20.png 5KB
sina_login_logo.gif 2KB
sina_login_16.png 3KB
sina_login_18.png 5KB
qq_logo_16.png 2KB
taobao_login.gif 2KB
qq_login.gif 2KB
taobao_login_24.png 4KB
qq_login_24.png 4KB
调用代码-2.7.3.txt 11KB
languages
zh_cn
admin
website.php 2KB
安装配置说明文档.txt 4KB
includes
website
config
alipay.php 6KB
weibo.php 3KB
tb_index.php 1KB
wechat.php 3KB
jntoo.php 963B
cls_http.php 8KB
qq.php 4KB
oath2.class.php 4KB
taobao.php 4KB
tb_callback.php 3KB
共 39 条
- 1
资源评论
Mr.公子
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功