File: /var/www/html/wp-content/themes/ormedia/page-api-alert-data.php
<?php
//Template Name: api-alert-data
// ini_set('display_errors',1); //错误信息
// ini_set('display_startup_errors',1); //php启动错误信息
// error_reporting(E_ALL);
get_header('app');
session_start();
require_once 'key_alert_functions.php';
$user = wp_get_current_user();
$allheader = getallheaders();
$token = $allheader['token'];
if (isset($_REQUEST['action'])) {
$a = $_REQUEST['action'];
} else {
$a = "";
}
$dir = get_template_directory_uri();
if (!isset($_REQUEST['page'])) {
$first_separator = strpos($a, "_");
$c = substr($a, $first_separator + 1);
} else {
$c = "";
}
$rv->get_action = $_GET['action'];
$rv->post_action = $_POST['action'];
$rv = new stdClass();
if ($user->ID != 4 || $_REQUEST['debug'] != 1) {
$has_token = has_token($token);
if ($has_token) {
$uid = $has_token->id;
$varify_flag = JwtAuthClass::verifyToken($token);
if ($varify_flag == 1) {
} else if ($varify_flag == 0) {
$payload_new =
array(
'iss' => 'keylab',
'iat' => time(),
'exp' => time() + 3600*24*365*20,
'nbf' => time() + 3600*24*365*20,
// 'exp' => time() + 60*10,
// 'nbf' => time() + 60*10 + 3600 * 24 * 7,
'sub' => 'keylab.cc',
'jti' => md5(uniqid('JWT') . time())
);
$token_new = JwtAuthClass::getToken($payload_new);
u_token($uid, $token_new);
// 已刷新
$rv->token = $token_new;
insert_log($_REQUEST['uid'], $token_new, 1, get_request_string(), "token已刷新");
} else {
// 完全過期
$rv->rc = -100;
$rv->msg = 'token expired';
insert_log($_REQUEST['uid'], $token, -1, get_request_string(), "token已過期");
echo json_encode($rv);
exit();
}
} else {
$rv->rc = -100;
$rv->msg = 'error token';
insert_log($_REQUEST['uid'], $token, -2, get_request_string(), "token錯誤");
echo json_encode($rv);
exit();
}
}
$file = $dir . '/keyAlertData/' . $c . '/' . $a . '.php?checking_api_file=true';
$file_headers = @get_headers($file); //检测是否存在此文件
if (strpos($file_headers[0], 'OK') > -1) {
global $wpdb;
include 'keyAlertData/' . $c . '/' . $a . '.php';
exit();
} else {
$rv = new stdClass();
$rv->rc = -255;
$rv->msg = $file_headers[0];
$rv->file = $file;
echo json_encode($rv);
}