public function hookCheckForBlockedHost() { if (!Cgi::getMode()) { $ipFilter = new IpFilter(); if ($ipFilter->isBlocked()) { throw new IPBlockedException("This host is blocked!"); } } }
/** * Record current request in requests log */ public function recordRequest($ip = null) { if (Cgi::getMode()) { return; } if ($ip === null) { $ip = $_SERVER['REMOTE_ADDR']; } $this->query->exec("INSERT INTO `" . Tbl::get('TBL_SECURITY_REQUESTS_LOG') . "` (`ip`) \n\t\t\t\t\t\t\t\tVALUES ('{$ip}')\n\t\t\t\t\t\t\t\tON DUPLICATE KEY UPDATE `count` = `count` + 1"); }
/** * Record current request in requests log */ public function recordRequest($ip = null) { if (Cgi::getMode()) { return; } if ($ip === null) { $ip = $_SERVER['REMOTE_ADDR']; } $qb = new QueryBuilder(); $qb->insert(Tbl::get('TBL_SECURITY_REQUESTS_LOG'))->values(array('ip' => $ip))->onDuplicateKeyUpdate()->set(new Field('count'), $qb->expr()->sum(new Field('count'), 1)); $this->query->exec($qb->getSQL()); }
/** * Check if remote IP is blocked by our system * * @return boolean */ public function isBlocked($cacheMinutes = null) { if (Cgi::getMode()) { return true; } $isBlocked = $this->isBlockedByIP($cacheMinutes) || $this->isBlockedByCountry($cacheMinutes); $isWhiteListed = $this->isWhitelistedIP($cacheMinutes); if ($isBlocked and !$isWhiteListed) { return true; } return false; }
/** * * * @param protocol $protocol * @return unknown */ public static function pageURL() { $hostConfig = ConfigManager::getConfig("Host")->AuxConfig; if (Cgi::getMode()) { return $hostConfig->cgiHost; } if (empty($_SERVER["SERVER_NAME"])) { $_SERVER["SERVER_NAME"] = $hostConfig->cgiHost; } $page_url = ""; if (isset($_SERVER["SERVER_PORT"]) and $_SERVER["SERVER_PORT"] != "80") { $page_url .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $page_url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } return $page_url; }