function __construct($app) { $this->app = $app; if (app::get('site')->getConf('desktop.whitelist.enabled')) { $remote_ip = base_request::get_remote_addr(); $ips = app::get('site')->getConf('desktop.whitelist.ips'); $error_code = app::get('site')->getConf('desktop.whitelist.error_code'); $forbidden = true; foreach ($ips as $ip) { $ip = trim($ip); if (!$ip) { continue; } if (base_request::ip_in_range($remote_ip, $ip)) { $forbidden = false; break; } } if ($forbidden) { switch ($error_code) { case '403': header("HTTP/1.1 403 Forbidden"); break; case '404': header("HTTP/1.1 404 Not Found"); break; default: header("HTTP/1.1 403 Forbidden"); } exit; } } }
private function check_blacklist() { if (app::get('site')->getConf('site.blacklist.enabled')) { $remote_ip = base_request::get_remote_addr(); $ips = app::get('site')->getConf('site.blacklist.ips'); $error_code = app::get('site')->getConf('site.blacklist.error_code'); $forbidden = false; foreach ($ips as $ip) { if (base_request::ip_in_range($remote_ip, $ip)) { $forbidden = true; break; } } if ($forbidden) { switch ($error_code) { case '403': header('HTTP/1.1 403 Forbidden'); break; case '404': header('HTTP/1.1 404 Not Found'); break; default: header('HTTP/1.1 403 Forbidden'); } exit; } } return; }