source: trunk/controller.php @ 2481

Revision 2481, 3.5 KB checked in by amuller, 14 years ago (diff)

Ticket #1026 - corrigindo problema

  • 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
13        if(!isset($GLOBALS['phpgw_info'])){
14                $GLOBALS['phpgw_info']['flags'] = array(
15                        'nonavbar'   => true,
16                        'currentapp' => $_SESSION['phpgw_info']['expresso']['currentapp'],
17                        'noheader'   => true
18                );
19        }
20        require_once './header.session.inc.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($_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                list($app,$class,$method) = explode('.',@$_GET['action']);
40        // NO ACTION
41        else
42                return $_SESSION['response'] = 'Post-Content-Length';
43
44        // Load dinamically class file.
45        if ( $app == '$this' )
46        {
47                $url = parse_url( $_SERVER[ 'HTTP_REFERER' ] );
48                if ( ( $pos = strpos( $url[ 'query' ], 'menuaction' ) ) !== false )
49                        $app = strstr( substr( $url[ 'query' ], $pos + 11 ), '.', true );
50                else
51                {
52                        $app = dirname( $_SERVER[ 'PHP_SELF' ] );
53                        if ( $app[ 0 ] != '/' )
54                                $app = "/{$app}";
55                        if ( $app[ strlen( $app ) - 1 ] != '/' )
56                                $app = "{$app}/";
57                        $app = $_SERVER[ 'SERVER_NAME' ] . $app;
58                        $app = dirname( substr( $_SERVER[ 'HTTP_REFERER' ], strpos( $_SERVER[ 'HTTP_REFERER' ], $app ) + strlen( $app ) ) );
59                }
60        }
61        else
62                if( strpos($app, '$this/') === 0 )
63                {
64                        $_app = '';
65                        $url = parse_url( $_SERVER[ 'HTTP_REFERER' ] );
66                        if ( ( $pos = strpos( $url[ 'query' ], 'menuaction' ) ) !== false )
67                                $_app = strstr( substr( $url[ 'query' ], $pos + 11 ), '.', true ) . '/';
68                        $filename = str_replace( '$this/', $_app, $app ) . '.php';
69                        include_once($filename);
70                        exit;
71                }
72        $filename = $app.'/inc/class.'.$class.'.inc.php';
73
74        include_once($filename);
75
76        // Create new Object  (class loaded).   
77        $obj = new $class;
78       
79        // Prepare parameters for execution.   
80        $params = array();
81       
82        // If array $_POST is not null , the submit method is POST.
83        if($_POST) {
84                $params = $_POST;
85        }
86        // If array $_POST is null , and the array $_GET > 1, the submit method is GET.
87        else if(count($_GET) > 1)       {               
88                array_shift($_GET);
89                $params = $_GET;
90        }
91
92        $result = array();
93       
94       
95        // if params is not empty, then class method with parameters.   
96        if($params)
97                $result = $obj -> $method($params);
98        else           
99                $result = $obj -> $method();
100               
101        // Return result serialized.   
102       
103
104        if(!$cExecuteFormReturn)
105                echo serialize($result);
106        else
107        {
108                @session_start();
109                $_SESSION['response'] = $result;
110        }
111?>
Note: See TracBrowser for help on using the repository browser.