[2935] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * eGroupWare * |
---|
| 4 | * http://www.egroupware.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 | |
---|
[3054] | 12 | |
---|
[2935] | 13 | /** |
---|
[3054] | 14 | * Redefines the apache_request_headers function if it was not done before by a phpmodule |
---|
| 15 | * This usually happens if php runs as cgi |
---|
| 16 | * @return array HTTP info presents in $_SERVER array |
---|
| 17 | * @package Workflow |
---|
| 18 | * @access public |
---|
| 19 | */ |
---|
| 20 | if( !function_exists('apache_request_headers') ) { |
---|
| 21 | /// |
---|
| 22 | function apache_request_headers() { |
---|
| 23 | $arh = array(); |
---|
| 24 | $rx_http = '/\AHTTP_/'; |
---|
| 25 | foreach($_SERVER as $key => $val) { |
---|
| 26 | if( preg_match($rx_http, $key) ) { |
---|
| 27 | $arh_key = preg_replace($rx_http, '', $key); |
---|
| 28 | $rx_matches = array(); |
---|
| 29 | // do some nasty string manipulations to restore the original letter case |
---|
| 30 | // this should work in most cases |
---|
| 31 | $rx_matches = explode('_', $arh_key); |
---|
| 32 | if( count($rx_matches) > 0 and strlen($arh_key) > 2 ) { |
---|
| 33 | foreach($rx_matches as $ak_key => $ak_val) $rx_matches[$ak_key] = ucfirst($ak_val); |
---|
| 34 | $arh_key = implode('-', $rx_matches); |
---|
| 35 | } |
---|
| 36 | $arh[$arh_key] = $val; |
---|
| 37 | } |
---|
| 38 | } |
---|
| 39 | return( $arh ); |
---|
| 40 | } |
---|
| 41 | /// |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | /** |
---|
[2935] | 45 | * Generates warning message of deprecated methods executing PHP function trigger_error |
---|
| 46 | * @author Anderson Tadayuki Saikawa |
---|
| 47 | * @param string $new_class The name of the class that has the method that replaces the deprecated one |
---|
| 48 | * @param string $new_method The name of the method that replaces the deprecated one |
---|
| 49 | * @return boolean |
---|
| 50 | * @license http://www.gnu.org/copyleft/gpl.html GPL |
---|
| 51 | * @package Workflow |
---|
| 52 | * @access public |
---|
| 53 | */ |
---|
| 54 | function wf_warn_deprecated_method($new_class = null, $new_method = null) |
---|
| 55 | { |
---|
| 56 | $caller = next(debug_backtrace()); |
---|
[2953] | 57 | $old_class = !empty($caller['class']) ? " of <strong>" . $caller['class'] . "</strong> object" : ""; |
---|
| 58 | $deprecated_msg = sprintf("Deprecated method <strong>%s</strong>%s was called in <strong>%s</strong> on line <strong>%s</strong>. It MUST be replaced by its equivalent", |
---|
| 59 | $caller['function'], $old_class, $caller['file'], $caller['line']); |
---|
| 60 | if(!empty($new_class) && !empty($new_method)){ |
---|
| 61 | $new_class = !empty($new_class) ? " of <strong>" . $new_class . "</strong> object" : ""; |
---|
| 62 | $deprecated_msg .= sprintf(' <strong>%s</strong>%s', $new_method, $new_class); |
---|
| 63 | } |
---|
[2935] | 64 | $error_msg = $deprecated_msg . ".\n<br>Error handler"; |
---|
| 65 | return trigger_error("[WORKFLOW WARNING]: " . $error_msg, E_USER_WARNING); |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | ?> |
---|