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 chmod($permission) { $permission = (int) $permission & 0777; // First, try simple chmod if (@chmod($this->_filename, $permission)) { return true; } else { // try FTP $ftp =& JD_Ftp::getFtpHandle(); // FTP Mode enabled if ($ftp) { $file = JD_Ftp::translatePath($this->_filename); // ignore ftp errors messages JD_Error::unsetErrorHandlers(); $result = $ftp->chmod($file, $permission); JD_Error::putErrorHandlersBack(); if (false === $result) { $this->setError($this->_getPersmissionError($permission)); return false; } return true; } else { // Return the error $error = $this->_getPersmissionError($permission); $this->setError($error); return false; } } }