diff --git a/index.php b/index.php index d9f7cb5..1ca56f0 100644 --- a/index.php +++ b/index.php @@ -20,6 +20,20 @@ class App } try { if (NGALLERY['root']['maintenance'] === false) { + $userIP = $_SERVER['REMOTE_ADDR']; + + function getCountryCodeByIP($ip) + { + $url = "http://ip-api.com/json/{$ip}?fields=countryCode"; + $response = file_get_contents($url); + $data = json_decode($response, true); + return $data['countryCode'] ?? null; + } + $countryCode = getCountryCodeByIP($userIP); + + if (in_array(strtolower($countryCode), explode(',', NGALLERY['root']['access']['countries']))) { + die(Page::set('Errors/ForbiddenCountry')); + } DB::connect(); Routes::init(); } else { diff --git a/static/img/403.jpg b/static/img/403.jpg new file mode 100644 index 0000000..9946e5b Binary files /dev/null and b/static/img/403.jpg differ diff --git a/views/pages/Errors/ForbiddenCountry.php b/views/pages/Errors/ForbiddenCountry.php new file mode 100644 index 0000000..c59b3f2 --- /dev/null +++ b/views/pages/Errors/ForbiddenCountry.php @@ -0,0 +1,28 @@ + + + + + + + + + + + + + +

Сервер недоступен в вашей стране

+
+

Вы можете связаться с администратором сервера, если считаете, что это ошибка.

+ + + + + \ No newline at end of file diff --git a/views/pages/Photo.php b/views/pages/Photo.php index 022f5c6..6d78aea 100644 --- a/views/pages/Photo.php +++ b/views/pages/Photo.php @@ -74,6 +74,12 @@ if ($photo->i('id') !== null) {
+ i('priority') === 1) { ?> +
Условная публикация
+ i('priority') === 2) { ?> +
Временная публикация
+