getRow("SELECT * FROM pre_user WHERE qq_uid='$qq' LIMIT 1"); unset($_SESSION['findpwd_qq']); if($userrow){ $uid=$userrow['uid']; $key=$userrow['key']; if($islogin2==1){ exit('{"code":-1,"msg":"当前QQ已绑定商户ID:'.$uid.',请勿重复绑定!"}'); } $DB->insert('log', ['uid'=>$uid, 'type'=>'QQ快捷登录', 'date'=>'NOW()', 'ip'=>$clientip, 'city'=>$city]); $session=md5($uid.$key.$password_hash); $expiretime=time()+604800; $token=authcode("{$uid}\t{$session}\t{$expiretime}", 'ENCODE', SYS_KEY); setcookie("user_token", $token, time() + 604800); $DB->exec("update `pre_user` set `lasttime`=NOW() where `uid`='$uid'"); $result=array("code"=>0,"msg"=>"登录成功!正在跳转到用户中心","url"=>"./"); }elseif($islogin2==1){ $sds=$DB->exec("update `pre_user` set `qq_uid`='$qq' where `uid`='$uid'"); $result=array("code"=>0,"msg"=>"已成功绑定QQ账号!","url"=>"./editinfo.php"); }else{ $_SESSION['Oauth_qq_uid']=$openId; $result=array("code"=>0,"msg"=>"请输入商户ID和密钥完成绑定和登录","url"=>"./login.php?connect=true"); } }else{ $result=array("code"=>-1, "msg"=>"验证失败,请重新扫码"); } exit(json_encode($result)); } $QC_config['appid']=$conf['login_qq_appid']; $QC_config['appkey']=$conf['login_qq_appkey']; $QC_config['callback']=$siteurl.'user/connect.php'; $Oauth_config['apiurl']=$conf['login_apiurl']; $Oauth_config['appid']=$conf['login_appid']; $Oauth_config['appkey']=$conf['login_appkey']; $Oauth_config['callback']=$siteurl.'user/connect.php'; if($_GET['code'] && ($conf['login_qq']==1 || $conf['login_qq']==3 || $conf['login_wx']==-1 || $conf['login_alipay']==-1)){ if($conf['login_qq']==1 && !isset($_GET['type'])){ $QC=new \lib\QC($QC_config); $access_token=$QC->qq_callback(); $openid=$QC->get_openid($access_token); $typename = 'QQ'; $typecolumn = 'qq_uid'; }else{ $type = isset($_GET['type'])?$_GET['type']:exit('{"code":-1,"msg":"no type"}'); if($type == 'qq'){ $typename = 'QQ'; $typecolumn = 'qq_uid'; }elseif($type == 'wx'){ $typename = '微信'; $typecolumn = 'wx_uid'; }elseif($type == 'alipay'){ $typename = '支付宝'; $typecolumn = 'alipay_uid'; } $Oauth=new \lib\Oauth($Oauth_config); $arr = $Oauth->callback(); if(isset($arr['code']) && $arr['code']==0){ $openid=$arr['social_uid']; $access_token=$arr['access_token']; }elseif(isset($arr['code'])){ sysmsg($arr['msg']); }else{ sysmsg('获取登录数据失败'); } } $userrow=$DB->getRow("SELECT * FROM pre_user WHERE {$typecolumn}='{$openid}' limit 1"); if($userrow){ $uid=$userrow['uid']; $key=$userrow['key']; if($islogin2==1){ @header('Content-Type: text/html; charset=UTF-8'); exit(""); } $DB->insert('log', ['uid'=>$uid, 'type'=>$typename.'快捷登录', 'date'=>'NOW()', 'ip'=>$clientip, 'city'=>$city]); $session=md5($uid.$key.$password_hash); $expiretime=time()+604800; $token=authcode("{$uid}\t{$session}\t{$expiretime}", 'ENCODE', SYS_KEY); setcookie("user_token", $token, time() + 604800); $DB->exec("update `pre_user` set `lasttime`=NOW() where `uid`='$uid'"); exit(""); }elseif($islogin2==1){ $sds=$DB->exec("update `pre_user` set `{$typecolumn}`='$openid' where `uid`='$uid'"); @header('Content-Type: text/html; charset=UTF-8'); exit(""); }else{ $_SESSION['Oauth_'.$typecolumn]=$openid; @header('Content-Type: text/html; charset=UTF-8'); exit(""); } }elseif($islogin2==1 && isset($_GET['unbind'])){ $DB->exec("update `pre_user` set `qq_uid`=NULL where `uid`='$uid'"); @header('Content-Type: text/html; charset=UTF-8'); exit(""); }elseif($islogin2==1 && !isset($_GET['bind'])){ @header('Content-Type: text/html; charset=UTF-8'); exit(""); } ?>