Skip to content

Commit 302cfdf

Browse files
committed
Added "Fast Ban Check" (resolves the issue #129)
1 parent a2bff2d commit 302cfdf

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

web_upload/includes/system-functions.php

+32
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,23 @@ function EMail($to, $subject, $message, $headers) { // SendMail - registered in
13951395
return $func($to, $subject, $message, $headers);
13961396
}
13971397

1398+
function PrepareMailText($TemplateName, $Data = array()) {
1399+
global $theme;
1400+
1401+
$theme->assign($Data);
1402+
$Text = $theme->fetch("mail/{$TemplateName}.tpl", 'TMail');
1403+
$theme->clear_assign($Data);
1404+
1405+
return $Text;
1406+
}
1407+
1408+
function GetGenericMailHeaders() {
1409+
return 'From: sourcebans@' . $_SERVER['HTTP_HOST'] . "\n" .
1410+
'X-Mailer: PHP/' . phpversion() . "\n" .
1411+
'MIME-Version: 1.0' . "\n" .
1412+
'Content-Type: text/html; charset=UTF-8';
1413+
}
1414+
13981415
function decompress_tar($path, $output) {
13991416
try {
14001417
$phar = new PharData($path);
@@ -1508,4 +1525,19 @@ function FindConfig(&$cfg_path) {
15081525

15091526
$cfg_path = '';
15101527
return false;
1528+
}
1529+
1530+
function ReplaceArrayKeyNames($data, $what, $to) {
1531+
foreach ($data as $key => $value) {
1532+
$data[str_replace($what, $to, $key)] = $value;
1533+
unset($data[$key]);
1534+
}
1535+
1536+
return $data;
1537+
}
1538+
1539+
function GetRequesterIP() {
1540+
if(isset($_SERVER['HTTP_X_REAL_IP']))
1541+
return $_SERVER['HTTP_X_REAL_IP'];
1542+
return $_SERVER['REMOTE_ADDR'];
15111543
}

web_upload/pages/page.banlist.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,16 @@ function CommunityID($steamid_id){
787787

788788
unset($_SESSION['CountryFetchHndl']);
789789

790+
// BAN NOTIFY
791+
if (!$userbank->is_admin()) {
792+
$ReqIP = GetRequesterIP();
793+
$IsBanned = $GLOBALS['db']->GetOne("SELECT COUNT(*) FROM `" . DB_PREFIX . "_bans` WHERE `type` = 1 AND ip = ? AND (length = '0' OR ends > UNIX_TIMESTAMP()) AND RemoveType IS NULL", array($ReqIP));
794+
$theme->assign('UserIP', $ReqIP);
795+
$theme->assign('IsBanned', $IsBanned);
796+
$theme->display('page_bans_notify.tpl');
797+
}
798+
799+
// BANLIST
790800
$theme->assign('searchlink', $searchlink);
791801
$theme->assign('hidetext', $hidetext);
792802
$theme->assign('hidetext_darf', $hidetext_darf);
@@ -810,4 +820,3 @@ function CommunityID($steamid_id){
810820
$theme->assign('view_bans', ($userbank->HasAccess(ADMIN_OWNER|ADMIN_EDIT_ALL_BANS|ADMIN_EDIT_OWN_BANS|ADMIN_EDIT_GROUP_BANS|ADMIN_UNBAN|ADMIN_UNBAN_OWN_BANS|ADMIN_UNBAN_GROUP_BANS|ADMIN_DELETE_BAN)));
811821
$theme->assign('can_export',($userbank->HasAccess(ADMIN_OWNER) || (isset($GLOBALS['config']['config.exportpublic']) && $GLOBALS['config']['config.exportpublic'] == "1")));
812822
$theme->display('page_bans.tpl');
813-
?>

web_upload/theme/page_bans_notify.tpl

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{* Шаблон вывода информации о наличии или отсутствии бана по IP-адресу *}
2+
<div class="alert alert-{if $IsBanned > 0}danger{else}success{/if}" role="alert">
3+
<h4>Быстрый поиск бана</h4>
4+
<span class="p-l-10"><b>Ваш IP-адрес - {$UserIP}</b>.&nbsp;
5+
{if $IsBanned > 0}
6+
У Вас имеются активные баны, доступ на сервера Вам запрещён.
7+
{else}
8+
Всё хорошо, сегодня без нарушений.
9+
{/if}
10+
</span>
11+
</div>

0 commit comments

Comments
 (0)