-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathajaxCalls.php
49 lines (37 loc) · 1.11 KB
/
ajaxCalls.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
<?php
/*
This script handles ajax calls for the server.
*/
function __autoload($class_name) {
require_once strtolower($class_name . '.class.php');
}
//We need the configuration
if(file_exists("config.php")){
require_once("config.php");
}
/*
Previously, we were passing an empty array if args were not provided, by setting args to the $_REQUEST array, we can pass
information from defined forms or non-ajax made calls.
*/
if(!isset($_REQUEST['args'])){
$_REQUEST['args'] = $_REQUEST;
}
$instance = new $_REQUEST['interact']();
if(!isset($_REQUEST['args']['nodb'])){
//Create new instance of the
$instance->dbhost = $dbhost;
$instance->dbname = $dbname;
$instance->dbuser = $dbuser;
$instance->dbpass = $dbpass;
$instance->options = $options;
}
/*
We provide a flag for non-db calls. Ideally anything not done with the DB is done client-side,
but for some setup items, we need to have server-side stuff happening.
*/
if(!isset($_REQUEST['args']['nodb'])){
$instance->dbConnect();
}
//encode and return whatever the class method returned.
print json_encode($instance->$_REQUEST['action']($_REQUEST['args']));
?>