source: trunk/controller.php @ 2459

Revision 2459, 3.4 KB checked in by rodsouza, 14 years ago (diff)

Ticket #1009 - Permitindo que o ExpressoAdmin não realize reload de página.

  • 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                        $_app = '';
64                        $url = parse_url( $_SERVER[ 'HTTP_REFERER' ] );
65                        if ( ( $pos = strpos( $url[ 'query' ], 'menuaction' ) ) !== false )
66                                $_app = strstr( substr( $url[ 'query' ], $pos + 11 ), '.', true ) . '/';
67                        $filename = str_replace( '$this/', $_app, $app ) . '.php';
68                        include_once($filename);
69                        exit;
70                }
71        $filename = $app.'/inc/class.'.$class.'.inc.php';
72
73        include_once($filename);
74
75        // Create new Object  (class loaded).   
76        $obj = new $class;
77       
78        // Prepare parameters for execution.   
79        $params = array();
80       
81        // If array $_POST is not null , the submit method is POST.
82        if($_POST) {
83                $params = $_POST;
84        }
85        // If array $_POST is null , and the array $_GET > 1, the submit method is GET.
86        else if(count($_GET) > 1)       {               
87                array_shift($_GET);
88                $params = $_GET;
89        }
90
91        $result = array();
92       
93       
94        // if params is not empty, then class method with parameters.   
95        if($params)
96                $result = $obj -> $method($params);
97        else           
98                $result = $obj -> $method();
99               
100        // Return result serialized.   
101       
102
103        if(!$cExecuteFormReturn)
104                echo serialize($result);
105        else
106                $_SESSION['response'] = $result;
107?>
Note: See TracBrowser for help on using the repository browser.