source: sandbox/2.5.1-evolucao/expressoAdmin1_2/controller.php @ 8236

Revision 8236, 2.9 KB checked in by angelo, 11 years ago (diff)

Ticket #3491 - Compatibilizar Expresso com novas versoes do PHP

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2                /***************************************************************************
3                * Expresso Livre                                                           *
4                * http://www.expressolivre.org                                             *
5                * --------------------------------------------                             *
6                *  This program is free software; you can redistribute it and/or modify it *
7                *  under the terms of the GNU General Public License as published by the   *
8                *  Free Software Foundation; either version 2 of the License, or (at your  *
9                *  option) any later version.                                              *
10                \**************************************************************************/
11               
12if(!isset($GLOBALS['phpgw_info'])){
13        $GLOBALS['phpgw_info']['flags'] = array(
14                'currentapp' => 'expressoAdmin1_2',
15                'nonavbar'   => true,
16                'noheader'   => true
17        );
18}
19require_once '../header.session.inc.php';
20require_once '../services/class.servicelocator.php';
21
22        //      Explode action from cExecuteForm function
23        $cExecuteFormReturn = false;
24        if(isset($_POST['_action'])) {         
25                if($_FILES) {
26                        $count_files = $_POST['countFiles'];
27                        $array_files = array();                 
28                        for($idx = 1; $idx <= $count_files; ++$idx) {
29                                if(isset($_FILES['file_'.$idx]) && $_FILES['file_'.$idx] && !$_FILES['file_'.$idx]['error'])
30                                        $array_files[] = $_FILES['file_'.$idx];                                         
31                        }
32                        $_POST['FILES'] = $array_files;
33                }                               
34                list($app,$class,$method) = explode('.',@$_POST['_action']);
35                $cExecuteFormReturn = true;
36        }
37        //      Explode action from cExecute function
38        else if($_GET['action']){
39                $exp = explode('.',@$_GET['action']);
40                //avoiding undefined offsets
41                if (count($exp) > 1)
42                        list($app,$class,$method) = explode('.',@$_GET['action']);
43                else
44                        $app = $exp[0];
45        }
46        // NO ACTION
47        else
48                return $_SESSION['response'] = 'false';
49        // Load dinamically class file.
50        if($app == '$this')
51                $filename = 'inc/class.'.$class.'.inc.php';
52        else if( strpos($app, '$this/') !== false)
53        {
54                $filename = str_replace('$this/','',$app) . '.php';
55                include_once($filename);
56                exit;
57        }
58        else
59                $filename = '../'.$app.'/inc/class.'.$class.'.inc.php';
60               
61        include_once($filename);
62       
63        // Create new Object  (class loaded).   
64        $obj = new $class;
65       
66        // Prepare parameters for execution.   
67        $params = array();
68       
69        // If array $_POST is not null , the submit method is POST.
70        if($_POST) {
71                $params = $_POST;
72        }
73        // If array $_POST is null , and the array $_GET > 1, the submit method is GET.
74        else if(count($_GET) > 1)       {               
75                array_shift($_GET);
76                $params = $_GET;
77        }
78
79        $result = array();
80       
81        // if params is not empty, then class method with parameters.   
82        if($params)
83                $result = $obj -> $method($params);
84        else           
85                $result = $obj -> $method();
86
87    $_SESSION['response'] = $result;
88
89    // Return result serialized.
90        if(!$cExecuteFormReturn)
91                echo serialize($result);
92?>
Note: See TracBrowser for help on using the repository browser.