Index: trunk/core/kernel/globals.php
===================================================================
diff -u -N -r4216 -r4243
--- trunk/core/kernel/globals.php (.../globals.php) (revision 4216)
+++ trunk/core/kernel/globals.php (.../globals.php) (revision 4243)
@@ -37,51 +37,51 @@
return $return;
}
- if (!function_exists('print_pre')) {
- /**
- * Same as print_r, budet designed for viewing in web page
- *
- * @param Array $data
- * @param string $label
- */
- function print_pre($data, $label='')
+ /**
+ * Same as print_r, budet designed for viewing in web page
+ *
+ * @param Array $data
+ * @param string $label
+ */
+ function print_pre($data, $label='')
+ {
+ $is_debug = false;
+ if (class_exists('kApplication')) {
+ $application =& kApplication::Instance();
+ $is_debug = $application->isDebugMode();
+ }
+
+ if ($is_debug) {
+ if ($label) $application->Debugger->appendHTML(''.$label.'');
+ $application->Debugger->dumpVars($data);
+ }
+ else
{
- if( constOn('DEBUG_MODE') )
- {
- global $debugger;
- if($label) $debugger->appendHTML(''.$label.'');
- $debugger->dumpVars($data);
- }
- else
- {
- if($label) echo '',$label,'
';
- echo '
',print_r($data,true),''; - } + if ($label) echo '', $label, '
', print_r($data, true), ''; } } - if (!function_exists('getArrayValue')) { - /** - * Returns array value if key exists - * - * @param Array $array searchable array - * @param int $key array key - * @return string - * @access public - */ - // - function getArrayValue(&$array,$key) - { - $ret = isset($array[$key]) ? $array[$key] : false; - if ($ret && func_num_args() > 2) { - for ($i = 2; $i < func_num_args(); $i++) { - $cur_key = func_get_arg($i); - $ret = getArrayValue( $ret, $cur_key ); - if ($ret === false) break; - } + /** + * Returns array value if key exists + * + * @param Array $array searchable array + * @param int $key array key + * @return string + * @access public + */ + // + function getArrayValue(&$array, $key) + { + $ret = isset($array[$key]) ? $array[$key] : false; + if ($ret && func_num_args() > 2) { + for ($i = 2; $i < func_num_args(); $i++) { + $cur_key = func_get_arg($i); + $ret = getArrayValue( $ret, $cur_key ); + if ($ret === false) break; } - return $ret; } + return $ret; } /** @@ -101,19 +101,16 @@ $array = $new_array; } - if( !function_exists('safeDefine') ) + /** + * Define constant if it was not already defined before + * + * @param string $const_name + * @param string $const_value + * @access public + */ + function safeDefine($const_name, $const_value) { - /** - * Define constant if it was not already defined before - * - * @param string $const_name - * @param string $const_value - * @access public - */ - function safeDefine($const_name, $const_value) - { - if(!defined($const_name)) define($const_name,$const_value); - } + if(!defined($const_name)) define($const_name,$const_value); } if( !function_exists('parse_portal_ini') ) @@ -315,6 +312,18 @@ $ch = curl_init($url); + $dbg = false; + if (defined('DEBUG_MODE') && DEBUG_MODE && dbg_ConstOn('DBG_CURL')) { + $dbg = true; + safeDefine('DBG_CURL_LOGFILE', '/curl.log'); + $log = fopen(FULL_PATH.DBG_CURL_LOGFILE, 'a'); + + curl_setopt($ch, CURLOPT_FILE, $log); + curl_setopt($ch, CURLOPT_VERBOSE, TRUE); + curl_setopt($ch, CURLOPT_STDERR, $log); + //curl_setopt($ch, CURLOPT_WRITEHEADER, $log); + } + if (!is_null($headers)) { curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); } @@ -330,6 +339,12 @@ $ret = curl_exec($ch); curl_close($ch); + + if ($dbg) { + fwrite($log, "\n".$ret); + fclose($log); + } + return $ret; } } @@ -375,18 +390,15 @@ return $result; } - if( !function_exists('constOn') ) + /** + * Checks if constant is defined and has positive value + * + * @param string $const_name + * @return bool + */ + function constOn($const_name) { - /** - * Checks if constant is defined and has positive value - * - * @param string $const_name - * @return bool - */ - function constOn($const_name) - { - return defined($const_name) && constant($const_name); - } + return defined($const_name) && constant($const_name); } function Kg2Pounds($kg)