source: companies/serpro/expressoAdmin1_2/controller.php @ 903

Revision 903, 1.6 KB checked in by niltonneto, 15 years ago (diff)

Importacao inicial do Expresso do Serpro

Line 
1<?php
2        //      Explode action from cExecuteForm function
3        $cExecuteFormReturn = false;
4        if($_POST['_action']) {                 
5                if($_FILES) {
6                        $count_files = $_POST['countFiles'];
7                        $array_files = array();                 
8                        for($idx = 1; $idx <= $count_files; $idx++) {           
9                                if($_FILES['file_'.$idx] && !$_FILES['file_'.$idx]['error'])
10                                        $array_files[] = $_FILES['file_'.$idx];                                         
11                        }
12                        $_POST['FILES'] = $array_files;
13                }                               
14                list($app,$class,$method) = explode('.',@$_POST['_action']);
15                $cExecuteFormReturn = true;
16        }
17        //      Explode action from cExecute function
18        else if($_GET['action'])
19                list($app,$class,$method) = explode('.',@$_GET['action']);
20        // NO ACTION
21        else
22                return $_SESSION['response'] = 'false';
23       
24        // Load dinamically class file.
25        if($app == '$this')
26                $filename = 'inc/class.'.$class.'.inc.php';
27        else
28                $filename = '../'.$app.'/inc/class.'.$class.'.inc.php';
29               
30        include_once($filename);       
31       
32        // Create new Object  (class loaded).   
33        $obj = new $class;
34       
35        // Prepare parameters for execution.   
36        $params = array();
37       
38        // If array $_POST is not null , the submit method is POST.
39        if($_POST) {
40                $params = $_POST;
41        }
42        // If array $_POST is null , and the array $_GET > 1, the submit method is GET.
43        else if(count($_GET) > 1)       {               
44                array_shift($_GET);
45                $params = $_GET;
46        }
47
48        $result = array();
49       
50       
51        // if params is not empty, then class method with parameters.   
52        if($params)
53                $result = $obj -> $method($params);
54        else           
55                $result = $obj -> $method();
56               
57        // Return result serialized.   
58       
59
60        if(!$cExecuteFormReturn)
61                echo serialize($result);
62        else
63                $_SESSION['response'] = $result;
64?>
Note: See TracBrowser for help on using the repository browser.