-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.php
59 lines (55 loc) · 1.73 KB
/
api.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
55
56
57
58
59
<?php
/**
* API CALL
*
* @package SHER
* @subpackage actions
*
* @copyright HAMAD ALI (ali sher)
*/
include_once('configs/config.inc.php');
header('Pragma: no-cache');
header('Cache-Control: max-age=1, s-maxage=1, no-store, no-cache, post-check=0, pre-check=0, must-revalidate, proxy-revalidate');
$aValid = array('_');
$guestRoutes = [
'register',
'login',
];
if(ctype_alpha(str_replace($aValid, '', @$_REQUEST['action'])) && ((isset($_SESSION['user_data']['logged_in']) && $_SESSION['user_data']['logged_in']) || in_array($_REQUEST['action'], $guestRoutes))) {
if(trim(@$_REQUEST['action']) != '') {
$available_actions = io_search_directory('[(.*)\.inc\.php]', 'src/actions');
foreach($available_actions as $idx => $item) {
$available_actions[$idx] = basename($item);
}
if(in_array($_REQUEST['action'].'.inc.php', $available_actions)) {
$action_file = 'src/actions/'.$_REQUEST['action'].'.inc.php';
if(file_exists($action_file)) {
$output = array();
include_once($action_file);
exit;
} else {
$output = array(
'Error' => true,
'error_message' => 'Invalid action'
);
}
} else {
$output = array(
'Error' => true,
'error_message' => 'Invalid action'
);
}
} else {
$output = array(
'Error' => true,
'error_message' => 'Invalid action'
);
}
} else {
$output = array(
'Error' => true,
'error_message' => 'Session expired'
);
}
echo json_encode($output);
?>