getDebugInformation(); $debugSessionErrorsCount = $debug->getSessionErrorsCount(); $NL = "\n"; $logHTML = '' . $NL . $NL; // DB PROFILER function log_iconv(&$array) { foreach ($array as $key => &$element) { if (is_string($element)) { $from = mb_detect_encoding($element, mb_detect_order(), true); if ($from) { $element = htmlspecialchars(iconv($from, 'UTF-8', $element)); } } } return true; } $logHTML .= '
' . $NL; $logHTML .= '
' . $NL; $config = Zend_Registry::get('config'); $db = Qs_Db::getInstance($config); $profiler = $db->getProfiler(); if ($profiler->getEnabled()) { $list = $profiler->getQueryProfiles(); $profilerHtml = ''; if (is_array($list) && !empty($list)) { $maxQueryDuration = defined('MAX_QUERY_DURATION') && MAX_QUERY_DURATION ? MAX_QUERY_DURATION : 0.5; $countHardQueries = 0; $profilerHtml .= ''; foreach ($list as $k => $v) { /** @var $v Qs\Db\Profiler\Query */ $params = $v->getQueryParams(); $color = ($k % 2 == 0) ? 'white' : '#EFEFEF'; if ($v->getElapsedSecs() >= $maxQueryDuration) { $countHardQueries++; $color = '#FFAAAA'; } $profilerHtml .= ''; $profilerHtml .= ''; $profilerHtml .= ''; $profilerHtml .= ''; $profilerHtml .= '' . $NL; } $profilerHtml .= '
' . ($k + 1) . '' . number_format($v->getElapsedSecs(), 3, '.', ',') . ' sec'; if (($source = $v->getSource())) { $fileFullName = str_replace($_SERVER['DOCUMENT_ROOT'], '', $source['fileFullName']); $profilerHtml .= '' . $source['file'] . ':' . $source['line'] . '
'; $profilerHtml .= $source['class'] . $source['type'] . $source['function']; } $profilerHtml .= '
'; $profilerHtml .= '
'; $profilerHtml .= '+' . Qs_SqlFormatter::getHighlightedCode($v->getQuery()) . '
'; $profilerHtml .= '
'; $profilerHtml .= '-' . Qs_SqlFormatter::format($v->getQuery()) . '
'; if (!empty($params)) { log_iconv($params); $profilerHtml .= '
   ' . $NL . 'params' . $NL . '' . $NL; } $profilerHtml .= '
'; $logHTML .= '
' . '
' . $NL . '' . 'DB PROFILER' . $NL . '
' . $NL . ($countHardQueries ? 'Hard Queries: ' . $countHardQueries . '
' : '') . 'Total Number of Queries: ' . $profiler->getTotalNumQueries() . '
' . $NL . 'Total Elapsed Seconds: ' . number_format($profiler->getTotalElapsedSecs(), 3, '.', '') . '
' . $NL . '' . $NL . '
' . $NL; } } if (!empty($debugList) || !empty($debugSessionErrorsCount)) { $debugHtml = Qs\Html::renderTag('hr'); $text = 'PHP ERRORS: ' . count($debugList); if (!empty($debugList)) { $debugHtml .= Qs\Html::renderContainer('a', $text , [ 'style' => 'color:black; background-color:white; text-align:left;', 'href' => '#', 'onclick' => 'var el = document.getElementById(\'debug_info\'); ' . 'el.style.display = (el.style.display == \'none\') ? \'\' : \'none\'; return false;' ]); } else { $debugHtml .= $text . ' '; } $debugHtml .= '/ '; $debugHtml .= Qs\Html::renderContainer('a', $debugSessionErrorsCount, [ 'href' => Qs_SiteMap::findFirst(null, ['type' => 'SystemLog_'], null, 'url') . '?idSession=' . session_id(), 'target' => '_blank', 'style' => 'color:red' ]); $debugHtml = Qs\Html::renderContainer('div', $debugHtml, [ 'style' => 'color:black; background-color:white; text-align:left;' ]); if ($debugList) { $phpErrorsHtml = ''; foreach ($debugList as $k => $v) { $fileFullName = PROJECT_PATH . '/' . $v['file']; $phpErrorsHtml .= ($k + 1) . ') ' . $v['errorType'] . ': ' . iconv('UTF-8', 'UTF-8', $v['message']) . ' ' . 'in the ' . $v['file'] . ':' . $v['line'] . '
'; } $debugHtml .= Qs\Html::renderContainer('div', $phpErrorsHtml, [ 'id' => 'debug_info', 'style' => 'border:solid black 1px; padding:10px;' ]); } $logHTML .= $debugHtml; } // page items started if (Zend_Registry::isRegistered('_pageItems')) { $tableColumns = array( array('name' => 'id', 'title' => 'ID', 'type' => 'text'), array('name' => 'groupName', 'title' => 'Group', 'type' => 'text'), array('name' => 'type', 'title' => 'Type', 'type' => 'text'), array('name' => 'executed', 'title' => 'Executed', 'type' => 'bool'), array('name' => 'duration', 'title' => 'Duration', 'type' => 'text', 'unit' => 'ms'), array('name' => 'config', 'title' => 'Config', 'type' => 'array'), ); $pageItems = (array) Zend_Registry::get('_pageItems'); $logHTML .= '
' . $NL; $logHTML .= 'PAGE ITEMS' . $NL; $logHTML .= '' . $NL; $logHTML .= ''; foreach ($tableColumns as $column) { $logHTML .= ''; } $logHTML .= '' . $NL; if (!empty($pageItems)) { foreach ($pageItems as $i) { $logHTML .= '' . $NL; foreach ($tableColumns as $column) { $value = ' '; switch ($column['type']) { case 'bool': $value = (isset($i[$column['name']]) && $i[$column['name']]) ? 'Yes' : 'No'; break; case 'array': $value = (isset($i[$column['name']])) ? json_encode($i[$column['name']]) : ' '; break; case 'text': // break omitted default: $value = (isset($i[$column['name']])) ? $i[$column['name']] : ' '; if (!empty($column['unit'])) { $value .= ' ' . $column['unit']; } } $logHTML .= ''; } $logHTML .= '' . $NL; } } else { $logHTML .= '' . $NL; } $logHTML .= '
' . htmlspecialchars($column['title']) . '
' . htmlspecialchars($value) . '
No items found
' . $NL; } // page items finished // side blocks started if (Zend_Registry::isRegistered('_pageSideBlocks')) { $sideBlocks = (array) Zend_Registry::get('_pageSideBlocks'); $logHTML .= '
' . $NL; $logHTML .= 'SIDE BLOCKS' . $NL; $logHTML .= '' . $NL; $logHTML .= '' . $NL; if (!empty($sideBlocks)) { foreach ($sideBlocks as $b) { $logHTML .= '' . '' . '' . '' . '' . '' . '' . '' . $NL; } } else { $logHTML .= '' . $NL; } $logHTML .= '
IDTypeTitlePagesLink TypeLink URL
' . $b['id'] . '' . ucfirst($b['blockType']) . '' . htmlspecialchars($b['title']) . '' . ucfirst($b['pageType']) . '' . ucfirst($b['linkType']) . '' . (($b['linkType'] == 'none') ? ' ' : htmlspecialchars($b['linkUrl'])) . '
No blocks found
' . $NL; } // side blocks finished $logHTML .= '
' . '
SCRIPT DURATION: ' . number_format((microtime(true) - SCRIPT_START), 3, '.', '') . '
'; $logHTML .= '
'; // end of qsf-debug-container return $logHTML;