function handleResults(&$data) { if (empty($data) || !is_array($data) || !is_array($data[1])) { return; } foreach ($data[1] as $entry) { $newData = array(); foreach ($entry->mismatch as $k => $m) { $newData[$k] = $m[0]; } // We have new file if ($entry->reason == 'new') { parent::handleLog('file_integrity_new', $entry->file, $newData, 'New file', 'new'); } else { if ($entry->reason == 'changed') { // Get the new filename $status = 'changed'; $issue = array_keys($newData); foreach ($issue as $k => $v) { $issue[$k] = JText::_($v); } parent::handleLog('file_integrity_changed', $entry->file, $newData, implode(', ', $issue), $status); } } } }
function handleResults(&$data) { if (empty($data) || !is_array($data)) { return; } // Check JEXEC warnings if (is_array($data[1])) { foreach ($data[1] as $file) { $newData = array(); $status = 'insecure'; parent::handleLog('file_integrity_php_jexec', $file, $newData, JText::_('No _JEXEC check'), $status); } } // Check For Bad Function entries if (is_array($data[2])) { foreach ($data[2] as $entry) { if (is_array($entry->functions)) { $issue = implode("\n", $entry->functions); } else { $issue = $entry->functions; } $status = 'bad_functions'; parent::handleLog('file_integrity_php_bad_functions', $entry->file, false, $issue, $status); } } }
function handleResults(&$data) { if (empty($data) || !is_array($data)) { return; } // proccess directories if (is_array($data[1])) { foreach ($data[1] as $entry) { $newData = array(); $target = $entry->dir; $status = 'bad_permissions'; $issue = $entry->permission; $newData['permissions'] = $entry->permission; parent::handleLog('permission', $target, $newData, decoct($issue), $status); } } // Process files if (is_array($data[2])) { foreach ($data[2] as $entry) { $newData = array(); $target = $entry->file; $status = 'bad_permissions'; $issue = $entry->permission; $newData['permissions'] = $entry->permission; parent::handleLog('permission', $target, $newData, decoct($issue), $status); } } }
function handleResults(&$results) { if ($results !== false) { return; } $value['type'] = 'ftp'; parent::handleLog('options', 'FTP mode disabled', $value, JText::_('Ftp mode is not enabled'), $status = 'disabled'); }
/** * Returns new instance of JD_Handler. * @param $type string * @static * @return JD_Handler */ function getInstance($type, $family) { JD_Handler::loadHandlers($family); $className = 'JD_' . ucfirst($type) . '_Handler'; if (class_exists($className)) { return new $className(); } return null; }
function scan($doLog = false) { global $mainframe; $session =& JFactory::getSession(); $confModel =& JModel::getInstance('Configuration', 'JDefenderModel'); $componentConfig = $confModel->getData(false); // Turn off error reporting JD_Error::unsetErrorHandlers(); jimport('joomla.error.log'); jimport('joomla.filesystem.file'); // choose scan type $filesystemScanned = $session->get('filesystem.scanned', false, 'jdefender'); $optionsScanned = $session->get('options.scanned', false, 'jdefender'); // Scan now $scanModel =& JModel::getInstance('Scan', 'JDefenderModel'); $scanModel->setState('filesystem.scanned', $filesystemScanned); $scanModel->setState('options.scanned', $optionsScanned); $scanData = $scanModel->getScanData('', $doLog); if ($doLog) { JD_Vars_Helper::setVar('status', 'jdefender_scan', JText::_('Processing Scan Results')); } foreach ($scanData as $family => $data) { // skip empty data if (!$data) { continue; } if ($family == 'filesystem') { if ($scanModel->_isFirstScan()) { // The handler for the first scan which does not write logs for new files. $firstScanHandler = JD_Handler::getInstance('first_scan', 'filesystem'); $firstScanHandler->handleResults($data); $firstScanHandler->flushLogs(); } } foreach ($data as $type => $results) { $handler = JD_Handler::getInstance($type, $family); if ($handler) { if ($doLog) { $titles = JD_Log_Helper::readableLogType($type); if ($titles) { JD_Vars_Helper::setVar('status', 'jdefender_scan', JText::_('Processing Scan Results') . ': ' . $titles->title); } } $handler->handleResults($results); $handler->flushLogs(); } } } // Turn on error reporting JD_Error::putErrorHandlersBack(); $state = array($scanModel->getState('filesystem.scanned'), $scanModel->getState('options.scanned')); // save scan state to session $session->set('filesystem.scanned', $state[0], 'jdefender'); $session->set('options.scanned', $state[1], 'jdefender'); return $state; }
function handleResults(&$data) { if (empty($data) || !is_array($data)) { return; } if (is_array($data[1])) { foreach ($data[1] as $folder) { $status = 'no_index_file'; parent::handleLog('folder_safety_index', $folder, false, JText::_('Missing index file'), $status); } } }
function handleResults(&$results) { if (empty($results) || !is_array($results)) { return; } if ($results[0] && $results[1] && version_compare($results[0], $results[1], '<')) { $issue = JText::_('Joomla update available') . ': ' . @$results[1]; $value['type'] = 'joomlaversion'; $value['value'] = $results; parent::handleLog('options', 'Joomla outdated', $value, $issue, $status = 'joomla outdated'); } }
function handleResults(&$results) { if (empty($results) || !is_array($results)) { return; } $admins = array(); foreach ($results as $admin) { $admins[] = $admin->id . ' - ' . $admin->username; } $issue = JText::_('Default admin usernames are being used') . ': ' . implode(' | ', $admins); $value['type'] = 'admins'; $value['value'] = $admins; parent::handleLog('options', 'Default admin usernames', $value, $issue, $status = 'default usernames in use'); }
function handleResults(&$results) { foreach ($results[1] as $file) { parent::handleLog('missing_file', $file, null, 'missing file', 'missing'); } }
function __construct() { parent::__construct(); }