| Server IP : 119.36.225.67 / Your IP : 43.159.78.200 Web Server : nginx/1.28.0 System : Linux 1763701629066 6.8.0-53-generic #55-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 17 15:37:52 UTC 2025 x86_64 User : www ( 1001) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/www.lengcat.cn/wp-content/themes/onenav/inc/auth/ |
Upload File : |
<?php
/*
* @Author: iowen
* @Author URI: https://www.iowen.cn/
* @Date: 2021-03-01 10:19:02
* @LastEditors: iowen
* @LastEditTime: 2025-03-26 19:06:50
* @FilePath: /onenav/inc/auth/dyh-callback.php
* @Description:
*/
include_once('../../../../../wp-config.php');
if(!session_id()) session_start();
$config = io_get_option('open_weixin_gzh_key');
if (!empty($_REQUEST['echostr']) && !empty($_REQUEST['signature'])) {
header("Content-type:text/html;charset=utf-8");
//微信接口校验
$signature = $_GET["signature"];
$timestamp = $_GET["timestamp"];
$nonce = $_GET["nonce"];
$token = $config['token'];
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr, SORT_STRING);
$tmpStr = implode($tmpArr);
$tmpStr = sha1($tmpStr);
if ($tmpStr == $signature) {
echo $_REQUEST['echostr'];
}
exit();
}
$oauth = new ioLoginWechatGZH($config['appid'], $config['appkey'], 'dyh');
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'callback';
switch ($action) {
case 'callback':
$callback = $oauth->callback();
if ($callback) {
$oauth->responseMsg($config['auto_reply']);
}
exit;
case 'check_callback':
$code = $_REQUEST['code'];
$back_url = $_REQUEST['loginurl'];
$status = 0;
$wechat_dyh_event_data = get_option('wechat_dyh_event_data'); //读取临时数据
if (!isset($wechat_dyh_event_data[$code])) {
$title = get_current_user_id() ? __('绑定失败','i_theme') : __('登录失败','i_theme');
io_tips_error($title, false);
exit;
}
//删除已使用过的数据
$openId = $wechat_dyh_event_data[$code]['FromUserName'];
unset($wechat_dyh_event_data[$code]);
update_option('wechat_dyh_event_data', $wechat_dyh_event_data, false);
if($openId){
try {
$userInfo = $oauth->getUserInfo($openId); //第三方用户信息
} catch (Exception $err) {
io_tips_error($err->getMessage(), false);
exit;
}
if (!empty($userInfo)) {
$userInfo['name'] = isset($userInfo['nickname']) ? $userInfo['nickname'] : '';
$userInfo['avatar'] = isset($userInfo['headimgurl']) ? $userInfo['headimgurl'] : '';
$oauth_data = array(
'type' => 'wechat_dyh',
'openid' => $openId,
'name' => $userInfo['name'],
'avatar' => $userInfo['avatar'],
'description' => '',
'getUserInfo' => $userInfo,
'rurl' => $_SESSION['rurl'],
);
$oauth_result = io_oauth_update_user($oauth_data,true);
$execute = io_oauth_login_after_execute($oauth_result,false);
if($execute['status']){
$status = 1;
$back_url = $execute['rurl'];
}
}
}
$result = array(
'status' => $status,
'goto' => $back_url
);
io_error($result);
exit;
}
wp_safe_redirect(home_url());
exit;