-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
requests.php
54 lines (47 loc) · 1.56 KB
/
requests.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
// +------------------------------------------------------------------------+
// | @author Oscar Garcés (SoyVillareal)
// | @author_url 1: https://soyvillareal.com
// | @author_url 2: https://github.com/soyvillareal
// | @author_email: [email protected]
// +------------------------------------------------------------------------+
// | PHP Magazine - The best digital magazine for newspapers or bloggers
// | Licensed under the MIT License. Copyright (c) 2022 PHP Magazine.
// +------------------------------------------------------------------------+
require_once('./assets/init.php');
if(empty($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest'){
header("Location: " . Functions::Url('home'));
exit();
}
$deliver = array();
$one = Functions::Filter($_GET['one']);
$token = Functions::Filter($_POST['token']);
if (!empty($_GET['token'])) {
$token = Functions::Filter($_GET['token']);
}
if (empty($token) || $token != $_SESSION['_LOGIN_TOKEN']) {
$deliver = array(
'S' => 400,
'E' => "*{$TEMP['#word']['invalid_request']}"
);
} else if (!empty($_GET['request-name'])) {
$req = Functions::Filter($_GET['request-name']);
if (file_exists('./requests/'.$req.'.php')) {
require_once('./requests/'.$req.'.php');
} else {
$deliver = array(
'S' => 404,
'E' => "*{$TEMP['#word']['request_not_found']}"
);
}
}
if(empty($deliver)){
$deliver = array(
'S' => 400,
'E' => "*{$TEMP['#word']['oops_error_has_occurred']}"
);
}
header('Content-Type: application/json');
echo json_encode($deliver);
exit();
?>