コード例 #1
0
ファイル: scan.php プロジェクト: alphashuro/audeprac
 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;
 }
コード例 #2
0
 /**
  * Returns array with tabular data. 
  */
 function getTables()
 {
     $actual = $this->read($this->_logRecord);
     $current = $this->readCurrentState($this->_filesystemState);
     $keys = array_keys($actual);
     $data = array();
     foreach ($keys as $k) {
         $row = array();
         $row[] = '<b>' . $this->_decorateWord($k) . '</b>';
         if ($k == 'size') {
             if (!empty($actual[$k])) {
                 $actual[$k] = JD_Log_Helper::formatSize($actual[$k]);
             }
             if (!empty($current[$k])) {
                 $current[$k] = JD_Log_Helper::formatSize($current[$k]);
             }
         } elseif (in_array($k, array('ctime', 'mtime'))) {
             if (!empty($actual[$k])) {
                 $actual[$k] = JD_Log_Helper::formatDate($actual[$k]);
             }
             if (!empty($current[$k])) {
                 $current[$k] = JD_Log_Helper::formatDate($current[$k]);
             }
         }
         if (empty($actual[$k])) {
             $row[] = '&nbsp;';
         } else {
             $row[] = $actual[$k];
         }
         if (empty($current[$k])) {
             if ($current) {
                 $row[] = '&nbsp;';
             }
         } else {
             $row[] = $current[$k];
         }
         $data[] = $row;
     }
     if (count($data)) {
         $toAdd = array('&nbsp;', '<b>' . JText::_('Current') . '</b>');
         if (!empty($this->_filesystemState)) {
             $toAdd[] = '<b>' . JText::_('Last Scan') . '</b>';
         }
         array_unshift($data, $toAdd);
     }
     unset($this->_logRecord->url);
     //		unset($this->_logRecord->status);
     return array($data);
 }
コード例 #3
0
ファイル: xajax.php プロジェクト: alphashuro/audeprac
function jdGetScanStatus()
{
    require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'log.php';
    $objResponse = new xajaxResponse();
    $controller = new JDefenderControllerScan();
    $scanStatus = $controller->scan($doLog = JD_Scan_Helper::isLogging());
    $scanInfo = JD_Vars_Helper::getGroup('jdefender_scan');
    if (empty($scanInfo)) {
        $scanInfo = array();
    }
    unset($scanInfo['status']);
    $progress = 0;
    if (!empty($scanInfo['total'])) {
        $scanned = 0;
        $scanned += @$scanInfo['files'];
        $scanned += @$scanInfo['dirs'];
        $progress = (int) floor($scanned / $scanInfo['total'] * 100);
    }
    $objResponse->assign('scanstatus', 'innerHTML', JText::_('Progress') . ': ' . $progress . '%');
    $objResponse->script('setProgress(' . $progress . ');');
    $objResponse->script('blink("scanstatus", 2);');
    $js = array();
    foreach ($scanInfo as $k => $v) {
        if ($k == 'last_scan_date') {
            continue;
        }
        $titles = JD_Log_Helper::readableLogType($k);
        if ($titles) {
            $js[] = '"' . addslashes(JHTML::link('index.php?option=com_jdefender&controller=log&task=showLog&cid[]=' . $k, $titles->title, 'target="_blank"')) . '" : ' . (int) $v;
        } else {
            $js[] = $k . ': ' . (int) $v;
        }
    }
    $js = '{' . implode(', ', $js) . '}';
    $objResponse->script('onInfoUpdated("' . addslashes($js) . '")');
    // Check scan status.
    if ($scanStatus && is_array($scanStatus) && count($scanStatus) == 2) {
        list($filesystemScanComplete, $optionScanComplete) = $scanStatus;
        if ($filesystemScanComplete && $optionScanComplete) {
            $objResponse->script('onScanComplete()');
        }
    }
    return $objResponse;
}
コード例 #4
0
ファイル: view.html.php プロジェクト: alphashuro/audeprac
 function _decorateLogGroup(&$logRecord)
 {
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'log.php';
     $r = JD_Log_Helper::readableLogType($logRecord->type);
     $logRecord->title = $r->title;
     $logRecord->description = $r->description;
     if ($logRecord->type == 'file_integrity_php_bad_functions' && !empty($logRecord->issue)) {
         $logRecord->issue = JText::_('Occurences') . ': ' . count(explode("\n", $logRecord->issue));
     }
 }
コード例 #5
0
ファイル: log.php プロジェクト: alphashuro/audeprac
 function logSmartly($type, $status, $issue = '', $opts = false)
 {
     $db =& JFactory::getDBO();
     $user =& JFactory::getUser();
     $user_id = $user->get('id');
     $UserIp = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : getenv("REMOTE_ADDR");
     $ref = isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : getenv("HTTP_REFERER");
     $post = JRequest::get('post', 2);
     if ($opts) {
         $post['__mighty_defender_info'] = $opts;
     }
     $post = serialize($post);
     $uri =& JURI::getInstance();
     $q = "SELECT `id` FROM #__jdefender_log WHERE `ip` = " . $db->Quote($UserIp) . " AND `url` = " . $db->Quote($uri->toString()) . ' AND `type` = ' . $db->Quote($type) . ' AND status = ' . $db->Quote($status) . ' AND `post` = ' . $db->Quote($post) . " AND `issue` = " . $db->Quote($issue) . ' AND `ctime` + INTERVAL 1 HOUR > NOW()';
     $db->setQuery($q);
     $id = $db->loadResult();
     if ($id) {
         $db->setQuery("UPDATE #__jdefender_log SET `ctime` = NOW(), `total` = `total` + 1 WHERE `id` = " . (int) $id);
         $db->query();
     } else {
         JD_Log_Helper::log($type, $status, $issue, $opts);
     }
 }
コード例 #6
0
ファイル: view.html.php プロジェクト: alphashuro/audeprac
 function display($tpl = null)
 {
     global $mainframe, $option;
     $document =& JFactory::getDocument();
     $document->addStyleSheet(JURI::base() . 'components/com_jdefender/css/main.css');
     $document->addStyleSheet(JURI::base() . 'components/com_jdefender/css/toolbar.css');
     JToolBarHelper::title(JText::_("Block List"), 'blocklist.png');
     JToolBarHelper::addNew();
     JToolBarHelper::editList('add');
     JToolBarHelper::publishList();
     JToolBarHelper::unpublishList();
     JToolBarHelper::deleteList();
     $filter_order = $mainframe->getUserStateFromRequest($option . '.rules.filter_order', 'filter_order', 'type');
     $filter_order_Dir = $mainframe->getUserStateFromRequest($option . '.rules.filter_order_Dir', 'filter_order_Dir', '');
     $type = $mainframe->getUserStateFromRequest($option . '.rules.filter_type', 'type', '');
     $published = $mainframe->getUserStateFromRequest($option . '.rules.filter_published', 'published', null);
     $limitstart = $mainframe->getUserStateFromRequest($option . '.rules.filter_limitstart', 'limitstart', '');
     $limit = $mainframe->getUserStateFromRequest($option . '.rules.filter_limit', 'limit', '');
     $state = $mainframe->getUserStateFromRequest($option . '.rules.filter_state', 'state', null);
     $search = $mainframe->getUserStateFromRequest($option . '.rules.filter_search', 'search', '');
     $lists = array();
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     $lists['state'] = $state;
     $lists['search'] = $search;
     $lists['type'] = $type;
     $lists['published'] = $published;
     $model =& JModel::getInstance('Rule', 'JDefenderModel');
     $model->setState('state', $state);
     $model->setState('type', $type);
     $model->setState('search', $search);
     $model->setState('order', $filter_order);
     $model->setState('orderDir', $filter_order_Dir);
     $model->setState('published', $published);
     if ($limit) {
         $model->setState('limit', $limit);
         $model->setState('limitstart', $limitstart);
     }
     $filters = $this->_getFilters($lists);
     $rules = $model->getData();
     $pagination = $model->getPagination();
     foreach ($rules as $k => $v) {
         switch ($v->origin) {
             case 0:
                 $rules[$k]->origin = JText::_('Mighty Defender');
                 break;
             case 1:
                 $rules[$k]->origin = JText::_('Custom');
                 break;
             case 2:
                 $rules[$k]->origin = JText::_('Third party');
                 break;
         }
         $rules[$k]->type = $this->_beautifyRuleType($rules[$k]->type);
         $res = JD_Log_Helper::readableLogType($v->family);
         $rules[$k]->familyTitle = $res->title;
         $rules[$k]->actionTitle = JHTML::link('index.php?option=com_jdefender&controller=rules&view=rules&layout=rule&id=' . $v->id . '&tmpl=component', JD_Log_Helper::beautifyString($v->action, true), array('rel' => '{handler: \'iframe\', size: {x: 800, y: 600}}', 'class' => 'modal'));
         $rules[$k]->editLink = JHTML::link('index.php?option=com_jdefender&controller=rules&view=rules&layout=form&id=' . $v->id, JHTML::image(JURI::base() . 'components/com_jdefender/images/toolbar/icon-16-edit.png', JText::_('Edit')));
         $rules[$k]->viewLink = JHTML::link('index.php?option=com_jdefender&controller=rules&view=rules&layout=rule&id=' . $v->id . '&tmpl=component', JHTML::image(JURI::base() . 'components/com_jdefender/images/toolbar/icon-16-preview.png', JText::_('View')), array('rel' => '{handler: \'iframe\', size: {x: 800, y: 600}}', 'class' => 'modal'));
     }
     $this->assignRef('items', $rules);
     $this->assignRef('lists', $lists);
     $this->assignRef('pagination', $pagination);
     JHTML::_('behavior.modal');
     JHTML::_('behavior.tooltip');
     JD_Admin_Menu_Helper::decorate();
     return parent::display($tpl);
 }