source: trunk/controller.php @ 2331

Revision 2331, 2.1 KB checked in by rodsouza, 14 years ago (diff)

Ticket #911 - Removendo o uso de na inclusão de arquivos, devido a inconsistência.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        if(!isset($GLOBALS['phpgw_info'])){
3                $GLOBALS['phpgw_info']['flags'] = array(
4                        'nonavbar'   => true,
5                        'currentapp' => $_SESSION['phpgw_info']['expresso']['currentapp'],
6                        'noheader'   => true
7                );
8        }
9        require_once './header.session.inc.php';
10
11        //      Explode action from cExecuteForm function
12        $cExecuteFormReturn = false;
13        if( isset( $_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'] = 'Post-Content-Length';
32       
33        // Load dinamically class file.
34        if ( $app == '$this' )
35        {
36                $app = dirname( $_SERVER[ 'PHP_SELF' ] ) . '/';
37                $app = dirname( substr( $_SERVER[ 'HTTP_REFERER' ], strpos( $_SERVER[ 'HTTP_REFERER' ], $app ) + strlen( $app ) ) );
38        }
39        else
40                if( strpos($app, '$this/') == 0 )
41                {
42                        $filename = str_replace('$this/','',$app) . '.php';
43                        include_once($filename);
44                        exit;
45                }
46        $filename = $app.'/inc/class.'.$class.'.inc.php';
47
48        include_once($filename);
49
50        // Create new Object  (class loaded).   
51        $obj = new $class;
52       
53        // Prepare parameters for execution.   
54        $params = array();
55       
56        // If array $_POST is not null , the submit method is POST.
57        if($_POST) {
58                $params = $_POST;
59        }
60        // If array $_POST is null , and the array $_GET > 1, the submit method is GET.
61        else if(count($_GET) > 1)       {               
62                array_shift($_GET);
63                $params = $_GET;
64        }
65
66        $result = array();
67       
68       
69        // if params is not empty, then class method with parameters.   
70        if($params)
71                $result = $obj -> $method($params);
72        else           
73                $result = $obj -> $method();
74               
75        // Return result serialized.   
76       
77
78        if(!$cExecuteFormReturn)
79                echo serialize($result);
80        else
81                $_SESSION['response'] = $result;
82?>
Note: See TracBrowser for help on using the repository browser.