3 Star 13 Fork 1

pkkgu/培训机构学员签到系统

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
oauth2.php 3.24 KB
一键复制 编辑 原始数据 按行查看 历史
pkkgu 提交于 2017-09-15 09:25 . oauth2.php更新
<?php
require("e/class/connect.php");
require("e/class/db_sql.php");
require("e/extend/wechat/wechat.config.php");
require("e/extend/wechat/wechat.class.php");
require("e/extend/wechat/wechat.fun.php");
$link = db_connect();
$empire = new mysqlquery();
$WeiXin = new Wechat($options);
if(isset($_GET['code'])&&isset($_GET['state']))
{
$code = $_GET['code'];//前端传来的code值
$result = $WeiXin->getOauthAccessToken();
if($result===false)
{
echo 'errCode:'.$WeiXin->errCode.'#errMsg:'.$WeiXin->errMsg;
}
else
{
$userinfo = $WeiXin->getUserInfo($result["openid"]);
//强制关注
if($userinfo['subscribe']==0)
{
header('Location:http://'.$_SERVER["HTTP_HOST"].'/e/message/subscribeErrMsg.php');
db_close();
$empire=null;
exit;
}
else
{
}
$openid = $result["openid"];//从返回json结果中读出openid
$GuserInfo = array();
$GuserInfo['enews'] = 'ShowMemberInfo';
$GuserInfo['username'] = $openid;
$GuserInfo['ok'] = 'pkkgu';
$u = ECMS_Infor_Curl($GuserInfo,1); //用户是否本地化
$userid = $u['userid'];
$groupid = 1;
if(empty($u['userid'])) //注册用户信息
{
//$accessToken = $result["access_token"];//从返回json结果中读出openid
//$userInfo = $WeiXin->getOauthUserinfo($accessToken,$openid);
$add = $userInfo;
$add['ok'] = 'pkkgu';
$add['enews'] = 'register';
$add['groupid'] = $groupid ;
$add['password'] = $openid.'ok';
$add['repassword'] = $openid.'ok';
$add['email'] = time().no_make_password(6).'@qq.com';
$add['wxgroupid'] = $userInfo['groupid'];
$add['username'] = $openid;
$add['userpic'] = $userInfo['headimgurl'];
$add['truename'] = $userInfo['nickname'];
$ret = ECMS_Infor_Curl($add,1);
$userid = $ret['userid'];
}
else
{
//更新用户信息
$empire->query("update {$dbtbpre}enewsmemberadd set userpic='".$userinfo['headimgurl']."',truename='".addslashes(base64_encode($userinfo['nickname']))."',saytext='".date("Y-m-d H:i:s")."' where userid='$userid'");
}
//登录
$cookieTime = time()+864000;
$rnd = make_password(20);//取得随机密码
$usql = $empire->query("update {$dbtbpre}enewsmember set rnd='$rnd' where userid='$userid'");
$set1 = esetcookie("mlusername",$openid,$cookieTime,0);
$set2 = esetcookie("mluserid",$userid,$cookieTime,0);
$set3 = esetcookie("mlgroupid",$groupid ,$cookieTime,0);
$set4 = esetcookie("mlrnd",$rnd,$cookieTime,0);
$checkpass=md5(md5($rnd.'-'.$userid.'-'.$openid.'-'.$groupid).'-#empire.cms!-'.$ecms_config['cks']['ckrndtwo']);
$set5 = esetcookie('mlauth',$checkpass,$cookieTime);
//echo 'http://'.$_SERVER["HTTP_HOST"].PHPSELFVAR($_GET['PHP_SELF'],1).'?'.$_SERVER['QUERY_STRING'];
//exit;
header('Location:http://'.$_SERVER["HTTP_HOST"].PHPSELFVAR($_GET['PHP_SELF'],1).'?'.$_SERVER['QUERY_STRING']);
db_close();
$empire=null;
exit;
}
}
else
{
parse_str(htmlspecialchars_decode($_SERVER['QUERY_STRING']),$data);
$callback = 'http://'.$_SERVER["HTTP_HOST"].'/oauth2.php?'.http_build_query($data);
header("Location:".$WeiXin->getOauthRedirect($callback,'STATE','snsapi_base'));
}
db_close();
$empire=null;
exit;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/pkkgu/peixunsys.git
git@gitee.com:pkkgu/peixunsys.git
pkkgu
peixunsys
培训机构学员签到系统
master

搜索帮助