[2] | 1 | <?php |
---|
[2364] | 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 | \**************************************************************************/ |
---|
[2012] | 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'; |
---|
[1059] | 20 | |
---|
[2] | 21 | // Explode action from cExecuteForm function |
---|
| 22 | $cExecuteFormReturn = false; |
---|
[1738] | 23 | if( isset( $_POST['_action'] ) ) { |
---|
[2] | 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 |
---|
[504] | 41 | return $_SESSION['response'] = 'Post-Content-Length'; |
---|
[2341] | 42 | |
---|
[2] | 43 | // Load dinamically class file. |
---|
[2331] | 44 | if ( $app == '$this' ) |
---|
[2030] | 45 | { |
---|
[2341] | 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 | { |
---|
[2346] | 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; |
---|
[2341] | 57 | $app = dirname( substr( $_SERVER[ 'HTTP_REFERER' ], strpos( $_SERVER[ 'HTTP_REFERER' ], $app ) + strlen( $app ) ) ); |
---|
| 58 | } |
---|
[2030] | 59 | } |
---|
[2331] | 60 | else |
---|
[2426] | 61 | if( strpos($app, '$this/') === 0 ) |
---|
[2331] | 62 | { |
---|
| 63 | $filename = str_replace('$this/','',$app) . '.php'; |
---|
| 64 | include_once($filename); |
---|
| 65 | exit; |
---|
| 66 | } |
---|
[2032] | 67 | $filename = $app.'/inc/class.'.$class.'.inc.php'; |
---|
[2012] | 68 | |
---|
| 69 | include_once($filename); |
---|
| 70 | |
---|
[2] | 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; |
---|
[1036] | 103 | ?> |
---|