AAAAhome/academiac/www/plugins/system/debug/debug.php000064400000041120151374252030016101 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; } } home/academiac/www/administrator/components/com_users/helpers/debug.php000064400000007310151402040510022505 0ustar00getQuery(true); $query->select('name AS text, element AS value') ->from('#__extensions') ->where('enabled >= 1') ->where('type ='.$db->Quote('component')); $items = $db->setQuery($query)->loadObjectList(); if (count($items)) { $lang = JFactory::getLanguage(); foreach ($items as &$item) { // Load language $extension = $item->value; $source = JPATH_ADMINISTRATOR . '/components/' . $extension; $lang->load("$extension.sys", JPATH_ADMINISTRATOR, null, false, true) || $lang->load("$extension.sys", $source, null, false, true); // Translate component name $item->text = JText::_($item->text); } // Sort by component name JArrayHelper::sortObjects($items, 'text', 1, true, $lang->getLocale()); } return $items; } /** * Get a list of the actions for the component or code actions. * * @param string The name of the component. * * @return array * @since 1.6 */ public static function getDebugActions($component = null) { $actions = array(); // Try to get actions for the component if (!empty($component)) { $component_actions = JAccess::getActions($component); if (!empty($component_actions)) { foreach($component_actions as &$action) { $actions[$action->title] = array($action->name, $action->description); } } } // Use default actions from configuration if no component selected or component doesn't have actions if (empty($actions)) { $filename = JPATH_ADMINISTRATOR.'/components/com_config/models/forms/application.xml'; if (is_file($filename)) { $xml = simplexml_load_file($filename); foreach($xml->children()->fieldset as $fieldset) { if ('permissions' == (string) $fieldset['name']) { foreach ($fieldset->children() as $field) { if ('rules' == (string) $field['name']) { foreach ($field->children() as $action) { $actions[(string) $action['title']] = array( (string) $action['name'], (string) $action['description'] ); } break; break; break; } } } } // Load language $lang = JFactory::getLanguage(); $extension = 'com_config'; $source = JPATH_ADMINISTRATOR . '/components/' . $extension; $lang->load("$extension.sys", JPATH_ADMINISTRATOR, null, false, true) || $lang->load("$extension.sys", $source, null, false, true); } } return $actions; } /** * Get a list of filter options for the levels. * * @return array An array of JHtmlOption elements. */ static function getLevelsOptions() { // Build the filter options. $options = array(); $options[] = JHtml::_('select.option', '1', JText::sprintf('COM_USERS_OPTION_LEVEL_COMPONENT', 1)); $options[] = JHtml::_('select.option', '2', JText::sprintf('COM_USERS_OPTION_LEVEL_CATEGORY', 2)); $options[] = JHtml::_('select.option', '3', JText::sprintf('COM_USERS_OPTION_LEVEL_DEEPER', 3)); $options[] = JHtml::_('select.option', '4', '4'); $options[] = JHtml::_('select.option', '5', '5'); $options[] = JHtml::_('select.option', '6', '6'); return $options; } }