/** * Returns a NEW log reader instance. * @param $type string type name * @static * @return JD_Log_Reader */ function &getInstance($type) { static $genericReader = 0; JD_Log_Reader::loadReaders(); $className = 'JD_' . ucfirst($type) . '_Log_Reader'; if (!class_exists($className)) { if (empty($genericReader)) { $genericReader = new JD_Log_Reader(); } return $genericReader; } $instance = new $className(); return $instance; }
function __construct() { parent::__construct(); }
function showOptions() { global $mainframe; require_once JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_jdefender' . DS . 'lib' . DS . 'utils' . DS . 'jd_extension_resolver.php'; $id = JRequest::getInt('id'); $fsModel =& JModel::getInstance('Filesystem', 'JDefenderModel'); $log =& JTable::getInstance('Log', 'Table'); $document =& JFactory::getDocument(); $document->addStyleSheet('templates/system/css/system.css'); $document->addStyleSheet('templates/khepri/css/template.css'); // Toolbar $toolbarHelper =& ME_Defender_Options_Toolbar_Helper::getInstance(); if ($showThatItemWasDeleted = JRequest::getInt('deleted')) { $toolbar =& $toolbarHelper->getToolbar(); $toolbar->closeRefresh('Close'); $this->assign('deleted', true); $this->assign('toolbar', $toolbar); return parent::display(); } if (!$log->load($id)) { return $mainframe->redirect('index.php?option=com_jdefender', JText::_('The log record does not exist')); } // Toolbar $extension = false; if (in_array($log->type, array('file_integrity_php_bad_functions', 'file_integrity_php_jexec')) && $log->extension && in_array($log->status, array('insecure', 'bad_functions'))) { $resolver = new JD_Extension_Resolver(); if ($resolver->getExtensionMetadata($log->url)) { $extension = $log->extension; } } if ($log->type == 'blocked_users_ips') { $oldRefresh = JRequest::setVar('refresh', 1); } $toolbarHelper->makeButtons($log->type, $extension, $log->status, $log->url); if ($log->type == 'blocked_users_ips') { JRequest::setVar('refresh', $oldRefresh); } // Load the log reader JD_Log_Reader::loadReaders(); $reader =& JD_Log_Reader::getInstance($log->type); if (empty($reader)) { JError::raiseError(500, JText::_('Log reader not found for type') . ': ' . $log->type); } $reader->setRecord($log); $isUrl = JString::substr($log->url, 0, 7) == 'http://'; // The last scan information from filesystem table $scanInfo = false; if ($log->url && !$isUrl) { $scanInfo = $fsModel->getFiles($log->url); $scanInfo = @reset($scanInfo); if (empty($scanInfo)) { $table =& JTable::getInstance('Filesystem', 'Table'); $table->loadFromFile($log->url); $scanInfo = $table; } } $reader->setCurrentState($scanInfo); // Get the data from log reader $tables = $reader->getTables(); // Labels: $labels = new stdClass(); if ($isUrl) { $labels->source = JText::_('URL'); } elseif (!empty($log->url)) { // Assume that it's file. $labels->source = JText::_("File"); if (is_dir($log->url)) { $labels->source = JText::_("Directory"); } else { jimport('joomla.filesystem.file'); if (!JFile::getExt($log->url)) { $labels->source = JText::_("Directory"); } } } $labels->statusTitle = JText::_('Status'); if ($log->type == 'blocked_users_ips') { $labels->statusTitle = JText::_('Action Applied'); } $dummy = new stdClass(); $dummy->type = $log->type; $this->_decorateLogGroup($dummy); $labels->title = $dummy->title; JHTML::_('behavior.tooltip'); $uri = JURI::getInstance(); $this->assign('url', $uri->toString()); $this->assign('toolbar', $toolbarHelper->getToolbar()); $this->assign('logRecord', $log); $this->assign('labels', $labels); $this->assign('scanInfo', $scanInfo); $this->assign('tables', $tables); return parent::display(); }