'; if ($params) { foreach ($params as $k => $v) { $form_html .= $k.':
'; } } $form_html .= '
'; array_push(self::$form_table, array($label, $form_html, $times, $results, $caller)); } /** * @name fb * @desc 调用FirePHP函数 * @return mixed * @access public */ static public function fb() { $instance = FirePHP::getInstance(true); $args = func_get_args(); return call_user_func_array(array($instance,'fb'),$args); } /** * @name show * @desc 显示调试信息 * @todo 目前只实现了在FirePHP中显示结果.需要实现记录LOG日志形式 * @return null * @access public */ static public function show() { if (!defined('DEBUG_SHOW_LOG') || (defined('DEBUG_SHOW_LOG') && DEBUG_SHOW_LOG)) { //用户记录变量 self::fb(array('Custom Log Object', self::$log_table), FirePHP::TABLE ); } if (!defined('DEBUG_SHOW_TIME') || (defined('DEBUG_SHOW_TIME') && DEBUG_SHOW_TIME)) { //页面执行时间 self::fb(array('This Page Spend Times ' . self::getTime(), self::$time_table), FirePHP::TABLE ); } /*---------记录至日记文件中------------*/ /* if(count(self::$log_table) > 1 || count(self::$time_table) > 1) { if(isset($_SERVER['TERM'])) { $string = "PWD:" . $_SERVER['PWD'] . "\n"; $string .= "SCRIPT_NAME:" . $_SERVER['SCRIPT_NAME'] . "\n"; $string .= "ARGV:" . var_export($_SERVER['argv'], true) . "\n"; }else { $string = "HTTP_HOST:" . $_SERVER['HTTP_HOST'] . "\n"; $string .= "SCRIPT_NAME:" . $_SERVER['SCRIPT_NAME'] . "\n"; $string .= "QUERY_STRING:" . $_SERVER['QUERY_STRING'] . "\n"; } $string .= 'This Page Spend Times:' . self::getTime() . "\n"; array_shift(self::$log_table); array_shift(self::$time_table); if(!empty(self::$time_table)) { $string .= "\n"; foreach (self::$time_table as $v) { $string .= "|-- ".$v[0]." ".$v[1]." ".$v[2]." --|\n"; } } if(!empty(self::$log_table)) { $string .= "\n"; foreach (self::$log_table as $v) { $string .= "|---- ".$v[0]." ".$v[2]." ----|\n"; $string .= var_export($v[1], true) . "\n"; } } $filename = "debug_" . date("Ymd") . ".log"; Log::customLog($filename, $string); } */ //数据库执行时间 if(count(self::$db_table) > 0) { $i = 0 ; $db_total_times = 0 ; foreach (self::$db_table as $v) { $db_total_times += $v[2]; $i++; } array_unshift(self::$db_table, array('IP', 'Database', 'Time', 'SQL Statement','Results')); self::fb(array($i . ' SQL queries took '.$db_total_times.' seconds', self::$db_table), FirePHP::TABLE ); } //Cache执行时间 if(count(self::$cache_table) > 0) { $i = 0 ; $cache_total_times = 0 ; foreach (self::$cache_table as $v) { $cache_total_times += $v[2]; $i++; } array_unshift(self::$cache_table, array('Server', 'Cache Key', 'Time','Results', 'Method')); self::fb(array($i.' Cache queries took '.$cache_total_times.' seconds', self::$cache_table), FirePHP::TABLE ); } //sphinx执行时间 if(count(self::$sphinx_table) > 0) { $i = 0 ; $sphinx_total_times = 0 ; foreach (self::$sphinx_table as $v) { $sphinx_total_times += $v[1]; $i++; } array_unshift(self::$sphinx_table, array('Condition', 'Time','Results', 'Method')); self::fb(array($i.' Sphinx queries took '.$sphinx_total_times.' seconds', self::$sphinx_table), FirePHP::TABLE ); } //Form执行时间 if(self::$form_table) { $i = 0; $form_total_times = 0; foreach (self::$form_table as $v) { $form_total_times += $v[2]; $i++; } array_unshift(self::$form_table, array('Label', 'FormHtml', 'Times', 'Results', 'Caller')); self::fb(array($i.' Form action request took '.$form_total_times.' seconds', self::$form_table), FirePHP::TABLE ); } if (!defined('DEBUG_SHOW_UTILITY') || (defined('DEBUG_SHOW_UTILITY') && DEBUG_SHOW_UTILITY)) { //自定义函数 $functions = get_defined_functions(); //定义的常量 $constants = get_defined_constants(true); $sessions = isset($_SESSION) ? $_SESSION : array(); self::fb(array('Utility Variables', array( array('name', 'values'), array('GET Variables', $_GET), array('POST Variables', $_POST), array('Custom Defined Functions', $functions['user']), array('Include Files', get_included_files()), array('Defined Constants', $constants['user']), array('SESSION Variables', $sessions), array('SERVER Variables', $_SERVER), array('appConfigs', Config::all()) ) ), FirePHP::TABLE ); } } }