-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImbaAjaxFacade.php
50 lines (42 loc) · 1.2 KB
/
ImbaAjaxFacade.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
<?php
/**
* Single point of Ajax entry
*
*/
require_once ("Controller/Include.php");
require_once ("Shared/Include.php");
require_once ("View/Ajax/AjaxBase.php");
session_start();
header('Access-Control-Allow-Origin: *');
try {
// Check if module and ajaxmethod is set
if (empty($_POST["module"])) {
throw new Exception("No Module");
}
if (empty($_POST["ajaxmethod"])) {
throw new Exception("No Ajax Method");
}
// setting variables
$module = $_POST["module"];
$submodule = (!empty($_POST["submodule"])) ? $_POST["submodule"] . "/" : "";
$method = $_POST["ajaxmethod"];
if (!empty($_POST["params"]) && $_POST["params"] != "" && is_string($_POST["params"])) {
$params = json_decode($_POST["params"]);
if ($params == null) {
throw new Exception("Wrong JSON input");
}
}
// create a callback object
require_once ("View/Ajax/" . $submodule . $module . ".php");
$ajaxCallback = new $module();
// execute the call
echo $ajaxCallback->$method($params);
} catch (Exception $ex) {
// Logging
echo $ex->getMessage();
echo "\n\n";
echo "POST Data:";
echo "\n\n";
var_dump($_POST);
}
?>