Esempio n. 1
0
 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();
 }
Esempio n. 2
0
 function getExtensionMetadataForLogs($ids)
 {
     if (empty($ids)) {
         return null;
     }
     require_once JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_jdefender' . DS . 'lib' . DS . 'utils' . DS . 'jd_extension_resolver.php';
     settype($ids, 'array');
     JArrayHelper::toInteger($ids);
     $resolver = new JD_Extension_Resolver();
     $state = $this->getState();
     $this->_state = new JObject();
     $this->setState('id', $ids);
     $records = $this->getData();
     $this->_state = $state;
     $results = array();
     foreach ($records as $record) {
         $metadata = $resolver->getExtensionMetadata($record->url);
         if (empty($metadata)) {
             continue;
         }
         if (!empty($metadata->author) && !empty($metadata->authorEmail)) {
             $type = $metadata->jd_extension_info->type;
             $extension = $metadata->jd_extension_info->extension;
             if (empty($results[$type][$extension]['info'])) {
                 $results[$type][$extension]['info'] = array($metadata->author, $metadata->authorEmail);
                 $results[$type][$extension]['meta'] = $metadata;
             }
             if (empty($results[$type][$extension]['records'])) {
                 $results[$type][$extension]['records'] = array();
             }
             $results[$type][$extension]['records'][] = $record;
         }
     }
     return $results;
 }
Esempio n. 3
0
 /**
  * Logs the JDefender log message, and preforms automatic fixes
  * @param $logType
  * @param $url
  * @param $data
  * @param $status
  * @return unknown_type
  */
 function handleLog($logType, $url, $data, $issue = '', $status = '')
 {
     $log = new stdClass();
     $log->type = $logType;
     $log->url = $url;
     $log->post = serialize($data);
     $log->status = $status;
     $log->issue = $issue;
     $actionManager =& JD_Action_Manager::getInstance();
     $log = $actionManager->addActionFromLog($log);
     if (strpos($log->url, 'http://') === false && file_exists($log->url)) {
         $ext = JD_Extension_Resolver::resolveExtension($log->url);
         if ($ext) {
             $log->extension = $ext->type . '::' . $ext->group . '::' . $ext->extension;
         }
     }
     $this->_logData[] =& $log;
     if (count($this->_logData) >= $this->_maxLogBufferSize) {
         // Flush the log buffer
         if (!$this->flushLogs()) {
             JError::raiseError(1234, JText::_('Error writing log') . ' - ' . $this->getError());
             return false;
         }
         return true;
     }
 }