/** * Return WAF events count for Admin's informer popup and Admin's gadget * @param string $pTimestamp - from date * @return integer */ public function getEventsCount($pTimestamp = '') { if (!$this->isDBEngineActive) { return 0; } /** * @global CCacheManager $CACHE_MANAGER * @global CDataBase $DB */ global $DB, $CACHE_MANAGER; $ttl = 3600; $cacheId = 'sec_events_count'; $cacheDir = '/security/events'; if ($CACHE_MANAGER->read($ttl, $cacheId, $cacheDir)) { $result = $CACHE_MANAGER->get($cacheId); } else { if (strlen($pTimestamp) <= 0) { $days = COption::getOptionInt("main", "event_log_cleanup_days", 7); if ($days > 7) { $days = 7; } $pTimestamp = convertTimeStamp(time() - $days * 24 * 3600 + CTimeZone::getOffset()); } $arAudits = array("SECURITY_FILTER_SQL", "SECURITY_FILTER_XSS", "SECURITY_FILTER_XSS2", "SECURITY_FILTER_PHP"); $strAuditsSql = implode("', '", $arAudits); $strSql = "\n\t\t\t\tSELECT COUNT(ID) AS COUNT\n\t\t\t\tFROM\n\t\t\t\t\tb_event_log\n\t\t\t\tWHERE\n\t\t\t\t\tAUDIT_TYPE_ID in ('" . $strAuditsSql . "')\n\t\t\t\tAND\n\t\t\t\t\t(MODULE_ID = 'security' and MODULE_ID is not null)\n\t\t\t\tAND\n\t\t\t\t\tTIMESTAMP_X >= " . $DB->charToDateFunction($DB->forSQL($pTimestamp)) . "\n\t\t\t"; $res = $DB->query($strSql, false, "FILE: " . __FILE__ . "<br>LINE: " . __LINE__); if ($arRes = $res->fetch()) { $result = $arRes["COUNT"]; } else { $result = 0; } $CACHE_MANAGER->set($cacheId, $result); } return $result; }
/** * @param $version * @return array */ protected function getSnapshotFromTrash($version) { CTimeZone::Disable(); $version = convertTimeStamp((int) $version, 'FULL'); $options = array('path' => '/' . $this->getWebDav()->meta_names['TRASH']['name'], 'depth' => '1'); $this->getWebDav()->meta_state = 'TRASH'; /** @noinspection PhpUndefinedVariableInspection */ $result = $this->getWebDav()->propFind($options, $files, array('COLUMNS' => array(), 'return' => 'array', 'FILTER' => array('timestamp_1' => $version, 'TIMESTAMP_X_1' => $version))); CTimeZone::Enable(); if (!is_array($result)) { return array(); } //file, folders format. This is not good. But it is not used. return $this->formatFilesToResponse($result['RESULT'] ?: array()); }