1 | <?php
|
---|
2 | if(!isset($GLOBALS['phpgw_info'])){
|
---|
3 | $GLOBALS['phpgw_info']['flags'] = array(
|
---|
4 | 'currentapp' => 'reports',
|
---|
5 | 'nonavbar' => true,
|
---|
6 | 'noheader' => true
|
---|
7 | );
|
---|
8 | }
|
---|
9 | require_once '../header.session.inc.php';
|
---|
10 |
|
---|
11 | // Explode action from cExecuteForm function
|
---|
12 | $cExecuteFormReturn = false;
|
---|
13 | if($_POST['_action']) {
|
---|
14 | if($_FILES) {
|
---|
15 | $count_files = $_POST['countFiles'];
|
---|
16 | $array_files = array();
|
---|
17 | for($idx = 1; $idx <= $count_files; $idx++) {
|
---|
18 | if($_FILES['file_'.$idx] && !$_FILES['file_'.$idx]['error'])
|
---|
19 | $array_files[] = $_FILES['file_'.$idx];
|
---|
20 | }
|
---|
21 | $_POST['FILES'] = $array_files;
|
---|
22 | }
|
---|
23 | list($app,$class,$method) = explode('.',@$_POST['_action']);
|
---|
24 | $cExecuteFormReturn = true;
|
---|
25 | }
|
---|
26 | // Explode action from cExecute function
|
---|
27 | else if($_GET['action'])
|
---|
28 | list($app,$class,$method) = explode('.',@$_GET['action']);
|
---|
29 | // NO ACTION
|
---|
30 | else
|
---|
31 | return $_SESSION['response'] = 'false';
|
---|
32 |
|
---|
33 | // Load dinamically class file.
|
---|
34 | if($app == '$this')
|
---|
35 | $filename = 'inc/class.'.$class.'.inc.php';
|
---|
36 | else if( strpos($app, '$this/') !== false)
|
---|
37 | {
|
---|
38 | $filename = str_replace('$this/','',$app) . '.php';
|
---|
39 | include_once($filename);
|
---|
40 | exit;
|
---|
41 | }
|
---|
42 | else
|
---|
43 | $filename = '../'.$app.'/inc/class.'.$class.'.inc.php';
|
---|
44 |
|
---|
45 | include_once($filename);
|
---|
46 |
|
---|
47 | // Create new Object (class loaded).
|
---|
48 | $obj = new $class;
|
---|
49 |
|
---|
50 | // Prepare parameters for execution.
|
---|
51 | $params = array();
|
---|
52 |
|
---|
53 | // If array $_POST is not null , the submit method is POST.
|
---|
54 | if($_POST) {
|
---|
55 | $params = $_POST;
|
---|
56 | }
|
---|
57 | // If array $_POST is null , and the array $_GET > 1, the submit method is GET.
|
---|
58 | else if(count($_GET) > 1) {
|
---|
59 | array_shift($_GET);
|
---|
60 | $params = $_GET;
|
---|
61 | }
|
---|
62 |
|
---|
63 | $result = array();
|
---|
64 |
|
---|
65 |
|
---|
66 | // if params is not empty, then class method with parameters.
|
---|
67 | if($params)
|
---|
68 | $result = $obj -> $method($params);
|
---|
69 | else
|
---|
70 | $result = $obj -> $method();
|
---|
71 |
|
---|
72 | // Return result serialized.
|
---|
73 |
|
---|
74 |
|
---|
75 | if(!$cExecuteFormReturn)
|
---|
76 | echo serialize($result);
|
---|
77 | else
|
---|
78 | $_SESSION['response'] = $result;
|
---|
79 | ?> |
---|