mirror of
https://github.com/WerySkok/nativegallery.git
synced 2024-12-22 08:30:59 +03:00
add geoblock for instances
This commit is contained in:
parent
3f20a0e963
commit
74b309f6eb
4 changed files with 48 additions and 0 deletions
14
index.php
14
index.php
|
@ -20,6 +20,20 @@ class App
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (NGALLERY['root']['maintenance'] === false) {
|
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();
|
DB::connect();
|
||||||
Routes::init();
|
Routes::init();
|
||||||
} else {
|
} else {
|
||||||
|
|
BIN
static/img/403.jpg
Normal file
BIN
static/img/403.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
28
views/pages/Errors/ForbiddenCountry.php
Normal file
28
views/pages/Errors/ForbiddenCountry.php
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Services\{Router, Auth, DB, Date};
|
||||||
|
?>
|
||||||
|
<html lang="ru">
|
||||||
|
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/LoadHead.php'); ?>
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<style>
|
||||||
|
body,h1 {
|
||||||
|
font-family: Tahoma, Geneva, Verdana, sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<center><h1>Сервер <?=NGALLERY['root']['title']?> недоступен в вашей стране</h1></center>
|
||||||
|
<center><img src="/static/img/403.jpg"></center>
|
||||||
|
<center><p>Вы можете связаться с администратором сервера, если считаете, что это ошибка.</p></center>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -74,6 +74,12 @@ if ($photo->i('id') !== null) {
|
||||||
<div id="underphoto_frame">
|
<div id="underphoto_frame">
|
||||||
<div id="ph_frame">
|
<div id="ph_frame">
|
||||||
<img class="nozoom" id="ph" src="<?= $photo->i('photourl') ?>" alt="" title="Фотография">
|
<img class="nozoom" id="ph" src="<?= $photo->i('photourl') ?>" alt="" title="Фотография">
|
||||||
|
<?php
|
||||||
|
if ($photo->i('priority') === 1) { ?>
|
||||||
|
<div class="underphoto s17" style="cursor:help" title="Фотография не удовлетворяет действующим на момент публикации критериям качества снимков."><i style="position:relative; top:1px" class="fas fa-info-circle"></i> <b class="dot">Условная публикация</b></div>
|
||||||
|
<?php } else if ($photo->i('priority') === 2) { ?>
|
||||||
|
<div class="underphoto s19" style="cursor:help" title="Изображение будет удалено с сайта через некоторое время"><i style="position:relative; top:1px" class="fas fa-clock"></i> <b class="dot">Временная публикация</b></div>
|
||||||
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue