AAAA.htaccess000066600000000177151373024370006360 0ustar00 Order allow,deny Deny from all debug.xml000066600000007537151373024370006401 0ustar00 plg_system_debug Joomla! Project December 2006 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL admin@joomla.org www.joomla.org 2.5.0 PLG_DEBUG_XML_DESCRIPTION debug.php index.html en-GB.plg_system_debug.ini en-GB.plg_system_debug.sys.ini
debug.php000066600000041120151373024370006352 0ustar00params->get('log-deprecated')) { JLog::addLogger(array('text_file' => 'deprecated.php'), JLog::ALL, array('deprecated')); } // Only if debugging or language debug is enabled if (JDEBUG || JFactory::getApplication()->getCfg('debug_lang')) { JFactory::getConfig()->set('gzip', 0); ob_start(); ob_implicit_flush(false); } $this->linkFormat = ini_get('xdebug.file_link_format'); } /** * Add the CSS for debug. We can't do this in the constructor because * stuff breaks. * * @return void * * @since 2.5 */ public function onAfterDispatch() { // Only if debugging or language debug is enabled if (JDEBUG || JFactory::getApplication()->getCfg('debug_lang')) { JHtml::_('stylesheet', 'cms/debug.css', array(), true); } } /** * Show the debug info * * @since 1.6 */ public function __destruct() { // Do not render if debugging or language debug is not enabled if (!JDEBUG && !JFactory::getApplication()->getCfg('debug_lang')) { return; } // Load the language $this->loadLanguage(); // Capture output $contents = ob_get_contents(); if ($contents) { ob_end_clean(); } // No debug for Safari and Chrome redirection if (strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'webkit') !== false && substr($contents, 0, 50) == ''; if (JDEBUG) { if (JError::getErrors()) { $html .= $this->display('errors'); } $html .= $this->display('session'); if ($this->params->get('profile', 1)) { $html .= $this->display('profile_information'); } if ($this->params->get('memory', 1)) { $html .= $this->display('memory_usage'); } if ($this->params->get('queries', 1)) { $html .= $this->display('queries'); } } if (JFactory::getApplication()->getCfg('debug_lang')) { if ($this->params->get('language_errorfiles', 1)) { $languageErrors = JFactory::getLanguage()->getErrorFiles(); $html .= $this->display('language_files_in_error', $languageErrors); } if ($this->params->get('language_files', 1)) { $html .= $this->display('language_files_loaded'); } if ($this->params->get('language_strings')) { $html .= $this->display('untranslated_strings'); } } $html .= ''; echo str_replace('', $html . '', $contents); } /** * General display method. * * @param string $item The item to display * @param array $errors Errors occured during execution * * @return string * * @since 2.5 */ protected function display($item, array $errors = array()) { $title = JText::_('PLG_DEBUG_' . strtoupper($item)); $status = ''; if (count($errors)) { $status = ' dbgerror'; } $fncName = 'display' . ucfirst(str_replace('_', '', $item)); if (!method_exists($this, $fncName)) { return __METHOD__ . ' -- Unknown method: ' . $fncName . '
'; } $html = ''; $js = "toggleContainer('dbgContainer" . $item . "');"; $class = 'dbgHeader' . $status; $html .= '

' . $title . '

'; // @todo set with js.. ? $style = ' style="display: none;"'; $html .= '
'; $html .= $this->$fncName(); $html .= '
'; return $html; } /** * Display session information. * * Called recursive. * * @param string $key A session key * @param mixed $session The session array, initially null * @param integer $id The id is used for JS toggling the div * * @return string * * @since 2.5 */ protected function displaySession($key = '', $session = null, $id = 0) { if (!$session) { $session = $_SESSION; } static $html = ''; static $id; if (!is_array($session)) { $html .= $key . ' ⇒' . $session . PHP_EOL; } else { foreach ($session as $sKey => $entries) { $display = true; if (is_array($entries) && $entries) { $display = false; } if (is_object($entries)) { $o = JArrayHelper::fromObject($entries); if ($o) { $entries = $o; $display = false; } } if (!$display) { $js = "toggleContainer('dbgContainer_session" . $id . "');"; $html .= '

' . $sKey . '

'; // @todo set with js.. ? $style = ' style="display: none;"'; $html .= '
'; $id ++; // Recurse... $this->displaySession($sKey, $entries, $id); $html .= '
'; continue; } if (is_array($entries)) { $entries = implode($entries); } if (is_string($entries)) { $html .= ''; $html .= $sKey . ' ⇒ ' . $entries . '
'; $html .= '
'; } } } return $html; } /** * Display errors. * * @return string * * @since 2.5 */ protected function displayErrors() { $html = ''; $html .= '
    '; while ($error = JError::getError(true)) { $col = (E_WARNING == $error->get('level')) ? 'red' : 'orange'; $html .= '
  1. '; $html .= '' . $error->getMessage() . '
    '; $info = $error->get('info'); if ($info) { $html .= '
    ' . print_r($info, true) . '

    '; } $html .= $this->renderBacktrace($error); $html .= '
  2. '; } $html .= '
'; return $html; } /** * Display profile information. * * @return string * * @since 2.5 */ protected function displayProfileInformation() { $html = ''; foreach (JProfiler::getInstance('Application')->getBuffer() as $mark) { $html .= '
' . $mark . '
'; } return $html; } /** * Display memory usage * * @return string * * @since 2.5 */ protected function displayMemoryUsage() { $html = ''; $bytes = JProfiler::getInstance('Application')->getMemory(); $html .= ''; $html .= JHtml::_('number.bytes', $bytes); $html .= ' (' . number_format($bytes) . ' Bytes)'; $html .= ''; return $html; } /** * Display logged queries. * * @return string * * @since 2.5 */ protected function displayQueries() { $db = JFactory::getDbo(); $log = $db->getLog(); if ( ! $log) { return; } $html = ''; $html .= '

' . JText::sprintf('PLG_DEBUG_QUERIES_LOGGED', $db->getCount()) . '

'; $html .= '
    '; $selectQueryTypeTicker = array(); $otherQueryTypeTicker = array(); foreach ($log as $k => $sql) { // Start Query Type Ticker Additions $fromStart = stripos($sql, 'from'); $whereStart = stripos($sql, 'where', $fromStart); if ($whereStart === false) { $whereStart = stripos($sql, 'order by', $fromStart); } if ($whereStart === false) { $whereStart = strlen($sql) - 1; } $fromString = substr($sql, 0, $whereStart); $fromString = str_replace("\t", " ", $fromString); $fromString = str_replace("\n", " ", $fromString); $fromString = trim($fromString); // Initialize the select/other query type counts the first time: if (!isset($selectQueryTypeTicker[$fromString])) { $selectQueryTypeTicker[$fromString] = 0; } if (!isset($otherQueryTypeTicker[$fromString])) { $otherQueryTypeTicker[$fromString] = 0; } // Increment the count: if (stripos($sql, 'select') === 0) { $selectQueryTypeTicker[$fromString] = $selectQueryTypeTicker[$fromString] + 1; unset($otherQueryTypeTicker[$fromString]); } else { $otherQueryTypeTicker[$fromString] = $otherQueryTypeTicker[$fromString] + 1; unset($selectQueryTypeTicker[$fromString]); } $text = $this->highlightQuery($sql); $html .= '
  1. ' . $text . '
  2. '; } $html .= '
'; if (!$this->params->get('query_types', 1)) { return $html; } // Get the totals for the query types: $totalSelectQueryTypes = count($selectQueryTypeTicker); $totalOtherQueryTypes = count($otherQueryTypeTicker); $totalQueryTypes = $totalSelectQueryTypes + $totalOtherQueryTypes; $html .= '

' . JText::sprintf('PLG_DEBUG_QUERY_TYPES_LOGGED', $totalQueryTypes) . '

'; if ($totalSelectQueryTypes) { $html .= '
' . JText::sprintf('PLG_DEBUG_SELECT_QUERIES') . '
'; arsort($selectQueryTypeTicker); $html .= '
    '; foreach ($selectQueryTypeTicker as $query => $occurrences) { $html .= '
  1. ' . JText::sprintf('PLG_DEBUG_QUERY_TYPE_AND_OCCURRENCES', $this->highlightQuery($query), $occurrences) . '
  2. '; } $html .= '
'; } if ($totalOtherQueryTypes) { $html .= '
' . JText::sprintf('PLG_DEBUG_OTHER_QUERIES') . '
'; arsort($otherQueryTypeTicker); $html .= '
    '; foreach ($otherQueryTypeTicker as $query => $occurrences) { $html .= '
  1. ' . JText::sprintf('PLG_DEBUG_QUERY_TYPE_AND_OCCURRENCES', $this->highlightQuery($query), $occurrences) . '
  2. '; } $html .= '
'; } return $html; } /** * Displays errors in language files. * * @return string * * @since 2.5 */ protected function displayLanguageFilesInError() { $html = ''; $errorfiles = JFactory::getLanguage()->getErrorFiles(); if (!count($errorfiles)) { $html .= '

' . JText::_('JNONE') . '

'; return $html; } $html .= ''; return $html; } /** * Display loaded language files. * * @return string * * @since 2.5 */ protected function displayLanguageFilesLoaded() { $html = ''; $html .= ''; return $html; } /** * Display untranslated language strings. * * @return string * * @since 2.5 */ protected function displayUntranslatedStrings() { $stripFirst = $this->params->get('strip-first'); $stripPref = $this->params->get('strip-prefix'); $stripSuff = $this->params->get('strip-suffix'); $orphans = JFactory::getLanguage()->getOrphans(); $html = ''; if ( ! count($orphans)) { $html .= '

' . JText::_('JNONE') . '

'; return $html; } ksort($orphans, SORT_STRING); $guesses = array(); foreach ($orphans as $key => $occurance) { if (is_array($occurance) && isset($occurance[0])) { $info = $occurance[0]; $file = ($info['file']) ? $info['file'] : ''; if (!isset($guesses[$file])) { $guesses[$file] = array(); } // Prepare the key if (($pos = strpos($info['string'], '=')) > 0) { $parts = explode('=', $info['string']); $key = $parts[0]; $guess = $parts[1]; } else { $guess = str_replace('_', ' ', $info['string']); if ($stripFirst) { $parts = explode(' ', $guess); if (count($parts) > 1) { array_shift($parts); $guess = implode(' ', $parts); } } $guess = trim($guess); if ($stripPref) { $guess = trim(preg_replace(chr(1) . '^' . $stripPref . chr(1) . 'i', '', $guess)); } if ($stripSuff) { $guess = trim(preg_replace(chr(1) . $stripSuff . '$' . chr(1) . 'i', '', $guess)); } } $key = trim(strtoupper($key)); $key = preg_replace('#\s+#', '_', $key); $key = preg_replace('#\W#', '', $key); // Prepare the text $guesses[$file][] = $key . '="' . $guess . '"'; } } foreach ($guesses as $file => $keys) { $html .= "\n\n# " . ($file ? $this->formatLink($file) : JText::_('PLG_DEBUG_UNKNOWN_FILE')) . "\n\n"; $html .= implode("\n", $keys); } return '
' . $html . '
'; } /** * Simple highlight for SQL queries. * * @param string $sql The query to highlight * * @return string * * @since 2.5 */ protected function highlightQuery($sql) { $newlineKeywords = '#\b(FROM|LEFT|INNER|OUTER|WHERE|SET|VALUES|ORDER|GROUP|HAVING|LIMIT|ON|AND|CASE)\b#i'; $sql = htmlspecialchars($sql, ENT_QUOTES); $sql = preg_replace($newlineKeywords, '
  \\0', $sql); $regex = array( // Tables are identified by the prefix '/(=)/' => '$1', // All uppercase words have a special meaning '/(?)([A-Z_]{2,})(?!\w)/x' => '$1', // Tables are identified by the prefix '/(' . JFactory::getDbo()->getPrefix() . '[a-z_0-9]+)/' => '$1' ); $sql = preg_replace(array_keys($regex), array_values($regex), $sql); $sql = str_replace('*', '*', $sql); return $sql; } /** * Render the backtrace. * * Stolen from JError to prevent it's removal. * * @param integer $error The error * * @return string Contents of the backtrace * * @since 2.5 */ protected function renderBacktrace($error) { $backtrace = $error->getTrace(); $html = ''; if (is_array($backtrace)) { $j = 1; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; for ($i = count($backtrace) - 1; $i >= 0; $i--) { $link = ' '; if (isset($backtrace[$i]['file'])) { $link = $this->formatLink($backtrace[$i]['file'], $backtrace[$i]['line']); } $html .= ''; $html .= ''; if (isset($backtrace[$i]['class'])) { $html .= ''; } else { $html .= ''; } $html .= ''; $html .= ''; $j++; } $html .= '
Call stack
#FunctionLocation
' . $j . '' . $backtrace[$i]['class'] . $backtrace[$i]['type'] . $backtrace[$i]['function'] . '()' . $backtrace[$i]['function'] . '()' . $link . '
'; } return $html; } /** * Replaces the Joomla! root with "JROOT" to improve readability. * Formats a link with a special value xdebug.file_link_format * from the php.ini file. * * @param string $file The full path to the file. * @param string $line The line number. * * @return string * * @since 2.5 */ protected function formatLink($file, $line = '') { $link = str_replace(JPATH_ROOT, 'JROOT', $file); $link .= ($line) ? ':' . $line : ''; if ($this->linkFormat) { $href = $this->linkFormat; $href = str_replace('%f', $file, $href); $href = str_replace('%l', $line, $href); $html = '' . $link . ''; } else { $html = $link; } return $html; } } index.html000066600000000037151373024370006552 0ustar00