source: trunk/controller.php @ 2426

Revision 2426, 3.2 KB checked in by amuller, 14 years ago (diff)

Ticket #911 - correção de bug, ao usar /

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