[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. * |
---|
[2480] | 11 | \**************************************************************************/ |
---|
[2481] | 12 | |
---|
[2012] | 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'; |
---|
[1059] | 21 | |
---|
[2] | 22 | // Explode action from cExecuteForm function |
---|
| 23 | $cExecuteFormReturn = false; |
---|
[1738] | 24 | if( isset( $_POST['_action'] ) ) { |
---|
[2] | 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 |
---|
[504] | 42 | return $_SESSION['response'] = 'Post-Content-Length'; |
---|
[2341] | 43 | |
---|
[2] | 44 | // Load dinamically class file. |
---|
[2331] | 45 | if ( $app == '$this' ) |
---|
[2030] | 46 | { |
---|
[2341] | 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 | { |
---|
[2346] | 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; |
---|
[2341] | 58 | $app = dirname( substr( $_SERVER[ 'HTTP_REFERER' ], strpos( $_SERVER[ 'HTTP_REFERER' ], $app ) + strlen( $app ) ) ); |
---|
| 59 | } |
---|
[2030] | 60 | } |
---|
[2331] | 61 | else |
---|
[2426] | 62 | if( strpos($app, '$this/') === 0 ) |
---|
[2331] | 63 | { |
---|
[2459] | 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'; |
---|
[2331] | 69 | include_once($filename); |
---|
| 70 | exit; |
---|
| 71 | } |
---|
[2032] | 72 | $filename = $app.'/inc/class.'.$class.'.inc.php'; |
---|
[2012] | 73 | |
---|
| 74 | include_once($filename); |
---|
| 75 | |
---|
[2] | 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 |
---|
[2480] | 107 | { |
---|
| 108 | @session_start(); |
---|
[2] | 109 | $_SESSION['response'] = $result; |
---|
[2480] | 110 | } |
---|
[1036] | 111 | ?> |
---|