source: trunk/controller.php @ 2812

Revision 2812, 3.4 KB checked in by amuller, 14 years ago (diff)

Ticket #911 - Diminuindo a parte de código que inicia a sessão

  • 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                        'noheader'   => true
17                );
18        }
19
20        //      Explode action from cExecuteForm function
21        $cExecuteFormReturn = false;
22        if( isset( $_POST['_action'] ) ) {             
23                if($_FILES) {
24                        $count_files = $_POST['countFiles'];
25                        $array_files = array();                 
26                        for($idx = 1; $idx <= $count_files; $idx++) {           
27                                if($_FILES['file_'.$idx] && !$_FILES['file_'.$idx]['error'])
28                                        $array_files[] = $_FILES['file_'.$idx];                                         
29                        }
30                        $_POST['FILES'] = $array_files;
31                }                               
32                list($app,$class,$method) = explode('.',@$_POST['_action']);
33                $cExecuteFormReturn = true;
34        }
35        //      Explode action from cExecute function
36        else if($_GET['action'])
37                list($app,$class,$method) = explode('.',@$_GET['action']);
38        // NO ACTION
39        else{
40                require_once './header.session.inc.php';
41                return $_SESSION['response'] = 'Post-Content-Length';
42        }
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        require_once './header.session.inc.php';
78        $obj = new $class;
79       
80        // Prepare parameters for execution.   
81        $params = array();
82       
83        // If array $_POST is not null , the submit method is POST.
84        if($_POST) {
85                $params = $_POST;
86        }
87        // If array $_POST is null , and the array $_GET > 1, the submit method is GET.
88        else if(count($_GET) > 1)       {               
89                array_shift($_GET);
90                $params = $_GET;
91        }
92
93        $result = array();
94       
95       
96        // if params is not empty, then class method with parameters.   
97        if($params)
98                $result = $obj -> $method($params);
99        else           
100                $result = $obj -> $method();
101               
102        // Return result serialized.   
103       
104
105        if(!$cExecuteFormReturn)
106                echo serialize($result);
107        else
108        {
109                @session_start();
110                $_SESSION['response'] = $result;
111        }
112?>
Note: See TracBrowser for help on using the repository browser.