[2] | 1 | <?php |
---|
[5509] | 2 | /*************************************************************************** |
---|
| 3 | * Expresso Livre * |
---|
| 4 | * http://www.expressolivre.org * |
---|
| 5 | * -------------------------------------------- * |
---|
| 6 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 7 | * under the terms of the GNU General Public License as published by the * |
---|
| 8 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 9 | * option) any later version. * |
---|
| 10 | \**************************************************************************/ |
---|
| 11 | |
---|
[1417] | 12 | if(!isset($GLOBALS['phpgw_info'])){ |
---|
| 13 | $GLOBALS['phpgw_info']['flags'] = array( |
---|
| 14 | 'currentapp' => 'expressoAdmin1_2', |
---|
| 15 | 'nonavbar' => true, |
---|
| 16 | 'noheader' => true |
---|
| 17 | ); |
---|
| 18 | } |
---|
| 19 | require_once '../header.session.inc.php'; |
---|
[5399] | 20 | require_once '../services/class.servicelocator.php'; |
---|
[1417] | 21 | |
---|
[2] | 22 | // Explode action from cExecuteForm function |
---|
| 23 | $cExecuteFormReturn = false; |
---|
| 24 | if($_POST['_action']) { |
---|
| 25 | if($_FILES) { |
---|
| 26 | $count_files = $_POST['countFiles']; |
---|
| 27 | $array_files = array(); |
---|
[7655] | 28 | for($idx = 1; $idx <= $count_files; ++$idx) { |
---|
[2] | 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'] = 'false'; |
---|
[414] | 43 | |
---|
[2] | 44 | // Load dinamically class file. |
---|
| 45 | if($app == '$this') |
---|
| 46 | $filename = 'inc/class.'.$class.'.inc.php'; |
---|
[317] | 47 | else if( strpos($app, '$this/') !== false) |
---|
| 48 | { |
---|
| 49 | $filename = str_replace('$this/','',$app) . '.php'; |
---|
| 50 | include_once($filename); |
---|
| 51 | exit; |
---|
| 52 | } |
---|
[2] | 53 | else |
---|
| 54 | $filename = '../'.$app.'/inc/class.'.$class.'.inc.php'; |
---|
| 55 | |
---|
[317] | 56 | include_once($filename); |
---|
[2] | 57 | |
---|
| 58 | // Create new Object (class loaded). |
---|
| 59 | $obj = new $class; |
---|
| 60 | |
---|
| 61 | // Prepare parameters for execution. |
---|
| 62 | $params = array(); |
---|
| 63 | |
---|
| 64 | // If array $_POST is not null , the submit method is POST. |
---|
| 65 | if($_POST) { |
---|
| 66 | $params = $_POST; |
---|
| 67 | } |
---|
| 68 | // If array $_POST is null , and the array $_GET > 1, the submit method is GET. |
---|
| 69 | else if(count($_GET) > 1) { |
---|
| 70 | array_shift($_GET); |
---|
| 71 | $params = $_GET; |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | $result = array(); |
---|
| 75 | |
---|
| 76 | // if params is not empty, then class method with parameters. |
---|
| 77 | if($params) |
---|
| 78 | $result = $obj -> $method($params); |
---|
| 79 | else |
---|
| 80 | $result = $obj -> $method(); |
---|
| 81 | |
---|
[7194] | 82 | $_SESSION['response'] = $result; |
---|
| 83 | |
---|
| 84 | // Return result serialized. |
---|
[2] | 85 | if(!$cExecuteFormReturn) |
---|
| 86 | echo serialize($result); |
---|
| 87 | ?> |
---|