File: /var/www/dk/wp-content/themes/food/page-api-data.php
<?php
//Template Name: api-data
$origin = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : '';
// ini_set('display_errors', 1);
$allow_origin = array(
'http://120.79.165.149/',
'http://dk.smart1space.site/'
);
if (in_array($origin, $allow_origin)) {
header('Access-Control-Allow-Origin:' . $origin);
}
header("Access-Control-Allow-Credentials:true");
header("Access-Control-Allow-Headers: token, Origin, X-Requested-With, Content-Type, Accept, Authorization");
// require_once('JwtAuthClass.php');
// require_once('JwtAuth.php');
if (!function_exists("get_template_directory")) {
function get_template_directory()
{
}
}
date_default_timezone_set('UTC');
$rv = new stdClass();
$rc = 0;
$res = "";
$isAi_output = false;
$dir = get_template_directory();
include $dir . '/api/global/global.php';
if (isset($_REQUEST['action'])) {
$a = $_REQUEST['action'];
} else {
$rc = 1;
}
if (isset($_REQUEST['module'])) {
$c = $_REQUEST['module'];
} else {
$rc = 1;
}
if ($rc != 0) {
rt();
}
$file = $dir . '/api/' . $c . '/' . $a . '.php';
if (file_exists($file)) {
global $wpdb;
include $dir . '/api/' . $c . '/' . $a . '.php';
} else {
$rc = 404;
}
rt();
function rt()
{
global $rv;
global $rc;
global $res;
global $error;
global $isAi_output;
// echo '$ai_output -> '.$ai_output;
if($isAi_output){
}else{
$rv->res = $res;
$rv->rc = $rc;
$rv->msg = !empty($rv->msg) ? $rv->msg : $error[$rc];
exit(json_encode($rv));
}
}