Skip to content

Commit afb6ee2

Browse files
committed
Version 2.1.1
1 parent 71087c9 commit afb6ee2

File tree

7 files changed

+144
-64
lines changed

7 files changed

+144
-64
lines changed

ANLEITUNG/index.html

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@
6060
<div class="mobile-menu-closer"></div>
6161
<div class="content-menu">
6262
<div class="content-infos">
63-
<div class="info"><b>Version:</b> 2.0.8</div>
63+
<div class="info"><b>Version:</b> 2.1.1</div>
6464
<div class="info"><b>Autor:</b> <a href="https://www.webchills.at" target="_blank">webchills</a></div>
65-
<div class="info"><b>last Update:</b> 31. Mai 2023</div>
65+
<div class="info"><b>last Update:</b> 24. Juni 2023</div>
6666
</div>
6767
<ul>
6868
<li class="scroll-to-link active" data-target="content-zweck">
@@ -150,8 +150,7 @@ <h1>Copyright, Lizenz</h1>
150150
<strong>Änderungen gegenüber dem Originalmodul:</strong>
151151
<br>
152152
- Deutsche Sprachfiles, deutsche Konfiguration und deutsche Anleitung hinzugefügt<br>
153-
- Installer auf Standard Modul Installer der deutschen Zen Cart Version umgestellt<br>
154-
- Weiterleitung geblockter IPs auf 403 Forbidden statt auf index.php?main_page=page_not_found<br>
153+
- Installer auf Standard Modul Installer der deutschen Zen Cart Version umgestellt<br>
155154
- unnötige Dateien entfernt
156155
<br>
157156
<br>
@@ -229,6 +228,7 @@ <h1>Verwendung</h1>
229228
c. IP-Prüfung für bekannte Spider überspringen: Wenn die IP als bekannter Spider identifiziert wird und die Einstellung Spider eraluben aktiviert ist, werden die IP-Prüfung und die Protokollierungsschritte für Spider übersprungen. <br>
230229
d. Spider-Protokollierung: Wenn die Spider-Protokollierung aktiviert ist, wird für Spider, die eine IP-Prüfung umgangen haben, eine separate Protokolldatei erstellt.</li>
231230
<li>Bereinigung der Datenbank: Die Skriptfunktion entfernt bei Auslösung regelmäßig alte IP-Datensätze aus der Datenbank, wenn die Bereinigungsfunktion aktiviert ist. Dieser Vorgang wird nur einmal pro Tag durchgeführt, was durch die Aktualisierung des Wartungszeitstempels angezeigt wird.</li>
231+
<li>Zusätzliche IP-Blacklist-Dateioption: Das Modul bietet eine erweiterte IP-Blacklist-Funktion. Administratoren können diese Funktion über die Einstellung "Textdatei für IP Blacklist aktivieren" in der Zen Cart-Administrationsoberfläche aktivieren oder deaktivieren. Sobald diese Funktion aktiviert ist, prüft das Modul eine bestimmte Blacklist-Datei für jede eingehende IP-Adresse. Die Blacklist-Datei sollte eine vollständige oder teilweise IP-Adresse pro Zeile auflisten. Bei einer Übereinstimmung wird die entsprechende IP-Adresse sofort blockiert, wobei alle anderen Prüfungen oder Bewertungsmethoden umgangen werden. Mit dieser Funktion haben Administratoren eine bessere Kontrolle über die Sperrung bestimmter IP-Adressen, indem sie vollständige oder teilweise Übereinstimmungen aus der Blacklist-Datei verwenden. </li>
232232
<li>API-Protokollierung: Wenn die API-Protokollierung aktiviert ist, wird eine separate Protokolldatei für API-Aufrufe erstellt.</li>
233233
<li>IP-Blockierung: Wenn der Missbrauchswert über dem Schwellenwert liegt oder sich die IP im Testmodus befindet, wird die IP-Adresse als blockiert protokolliert (entweder vom API-Aufruf oder vom Cache) und eine entsprechende Protokolldatei erstellt.</li>
234234
<li>Sichere IP: Wenn keine der oben genannten Bedingungen eine Sperrung auslöst, gilt die IP als sicher, und das Skript wird ohne weitere Maßnahmen fortgesetzt.</li>
@@ -249,8 +249,8 @@ <h1>Modul deinstallieren</h1>
249249
<div class="overflow-hidden content-section" id="content-download">
250250
<h1>Download</h1>
251251
<p>Dieses Modul steht kostenlos auf Github zum Download bereit.</p>
252-
<p>Aktuelle Version: 2.0.8 vom 31.05.2023:</p>
253-
<p><a class="downloadbutton" title="Download AbuseIPDB 2.0.8 für Zen Cart 1.5.7 deutsch" href="https://github.com/zencartpro/157-modul-abuseipdb/archive/refs/tags/v2.0.8.zip">Download (.zip)</a></p>
252+
<p>Aktuelle Version: 2.1.1 vom 24.06.2023:</p>
253+
<p><a class="downloadbutton" title="Download AbuseIPDB 2.1.1 für Zen Cart 1.5.7 deutsch" href="https://github.com/zencartpro/157-modul-abuseipdb/archive/refs/tags/v2.1.1.zip">Download (.zip)</a></p>
254254
<p>Der Downloadbutton liefert immer direkt von Github das .zip Archiv der neuesten Version.<br>
255255
Ältere Versionen sind auf Github unter Releases archiviert:<br>
256256
<a href="https://github.com/zencartpro/157-modul-abuseipdb/releases" target="_blank">https://github.com/zencartpro/157-modul-abuseipdb/releases</a><br><br>
@@ -260,6 +260,13 @@ <h1>Download</h1>
260260
<h1>Changelog</h1>
261261

262262
<br>
263+
<p>Version 2.1.1 - 2023-06-24</p>
264+
<ul>
265+
<li>Neue Konfigurationsoption für Weiterleitung 404 oder 403</li>
266+
<li>Neue Konfigurationsoptionen für Dateinamensformat der Logfiles</li>
267+
<li>Spidererkennung auf Zen Cart Standardfunktionalität umgestellt</li>
268+
<li>Anleitung aktualisiert</li>
269+
</ul>
263270
<p>Version 2.0.8 - 2023-05-31</p>
264271
<ul>
265272
<li>Neue zusätzliche IP-Blacklist-Datei Option</li>

NEUE DATEIEN/DEINADMIN/includes/auto_loaders/config.abuseipdb.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
* Copyright 2023 marcopolo
66
* see https://github.com/CcMarc/AbuseIPDB
77
* license GNU General Public License (GPL)
8-
* version $Id: config.abuseipdb.php 2023-05-30 08:34:16Z webchills $
8+
* version $Id: config.abuseipdb.php 2023-06-24 20:10:16Z webchills $
99
*/
1010

1111
if (!defined('IS_ADMIN_FLAG')) {
1212
die('Illegal Access');
1313
}
1414

15-
$autoLoadConfig[999][] = array(
15+
$autoLoadConfig[200][] = array(
1616
'autoType' => 'init_script',
1717
'loadFile' => 'init_abuseipdb.php'
1818
);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* AbuseIPDB for Zen Cart German 1.5.7
4+
* Zen Cart German Version - www.zen-cart-pro.at
5+
* Copyright 2023 marcopolo
6+
* see https://github.com/CcMarc/AbuseIPDB
7+
* license GNU General Public License (GPL)
8+
* version $Id: 2.0.9.php 2023-06-24 20:21:16Z webchills $
9+
*/
10+
11+
$db->Execute(" SELECT @gid:=configuration_group_id
12+
FROM ".TABLE_CONFIGURATION_GROUP."
13+
WHERE configuration_group_title= 'AbuseIPDB'
14+
LIMIT 1;");
15+
16+
$db->Execute("INSERT IGNORE INTO " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, date_added, sort_order, use_function, set_function) VALUES
17+
('Redirect URL', 'ABUSEIPDB_REDIRECT_OPTION', 'forbidden', 'The option for redirecting the user if their IP is found to be abusive. <br><br><b>Option 1:</b> Page Not Found - If selected, the user will be redirected to the Page Not Found page on your website if their IP is found to be abusive. This provides a generic error page to the user.<br><br><b>Option 2:</b> 403 Forbidden - If selected, the user will be shown a 403 Forbidden error message if their IP is found to be abusive. This is the default option and provides a more explicit message indicating that the user is forbidden from accessing the website due to their IP being flagged as abusive.', @gid, now(), 22, NULL, 'zen_cfg_select_option(array(\'page_not_found\', \'forbidden\'),')");
18+
19+
$db->Execute("REPLACE INTO ".TABLE_CONFIGURATION_LANGUAGE." (configuration_title, configuration_key, configuration_description, configuration_language_id) VALUES
20+
('AbuseIPDB - Weiterleitung für gesperrte IPs', 'ABUSEIPDB_REDIRECT_OPTION', 'Wohin sollen gesperrte IPs weitergeleitet werden?<br><br><b>Option 1:</b> Seite nicht gefunden - Wenn diese Option ausgewählt ist, wird der Benutzer auf die Seite page_not_found (404) auf Ihrer Website umgeleitet, wenn seine IP als missbräuchlich eingestuft wird. Dies bietet dem Benutzer eine allgemeine Fehlerseite.<br><br><b>Option 2:</b> 403 Forbidden - Wenn ausgewählt, wird dem Benutzer eine 403 Forbidden-Fehlermeldung angezeigt, wenn seine IP als missbräuchlich eingestuft wird. Dies ist die Standardoption und bietet eine explizitere Meldung, die darauf hinweist, dass dem Benutzer der Zugriff auf die Website untersagt ist, da seine IP als missbräuchlich eingestuft wurde.<br><br>', 43)");
21+
22+
$db->Execute("UPDATE " . TABLE_CONFIGURATION . " SET configuration_value = '2.0.9' WHERE configuration_key = 'ABUSEIPDB_MODUL_VERSION';");
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* AbuseIPDB for Zen Cart German 1.5.7
4+
* Zen Cart German Version - www.zen-cart-pro.at
5+
* Copyright 2023 marcopolo
6+
* see https://github.com/CcMarc/AbuseIPDB
7+
* license GNU General Public License (GPL)
8+
* version $Id: 2.1.1.php 2023-06-24 20:21:16Z webchills $
9+
*/
10+
11+
$db->Execute(" SELECT @gid:=configuration_group_id
12+
FROM ".TABLE_CONFIGURATION_GROUP."
13+
WHERE configuration_group_title= 'AbuseIPDB'
14+
LIMIT 1;");
15+
16+
$db->Execute("INSERT IGNORE INTO " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, date_added, sort_order, use_function, set_function) VALUES
17+
('Log File Format Block', 'ABUSEIPDB_LOG_FILE_FORMAT', 'abuseipdb_blocked_%Y_%m.log', 'The log file format for blocked IP addresses.', @gid, now(), 40, NULL, NULL),
18+
('Log File Format Cache', 'ABUSEIPDB_LOG_FILE_FORMAT_CACHE', 'abuseipdb_blocked_cache_%Y_%m.log', 'The log file format for cache logging.', @gid, now(), 41, NULL, NULL),
19+
('Log File Format API', 'ABUSEIPDB_LOG_FILE_FORMAT_API', 'abuseipdb_api_call_%Y_%m_%d.log', 'The log file format for api logging.', @gid, now(), 42, NULL, NULL),
20+
('Log File Format Spiders', 'ABUSEIPDB_LOG_FILE_FORMAT_SPIDERS', 'abuseipdb_spiders_%Y_%m_%d.log', 'The log file format for spider logging.', @gid, now(), 43, NULL, NULL)");
21+
22+
$db->Execute("REPLACE INTO ".TABLE_CONFIGURATION_LANGUAGE." (configuration_title, configuration_key, configuration_description, configuration_language_id) VALUES
23+
('AbuseIPDB - Logfile Format für Blocking', 'ABUSEIPDB_LOG_FILE_FORMAT', 'Wie soll der Dateiname für das Logfile aussehen, in dem geblockte IPs protokolliert werden?<br><br>', 43),
24+
('AbuseIPDB - Logfile Format für Caching', 'ABUSEIPDB_LOG_FILE_FORMAT_CACHE', 'Wie soll der Dateiname für das Logfile aussehen, in dem gecachte IPs protokolliert werden?<br><br>', 43),
25+
('AbuseIPDB - Logfile Format für API Zugriff', 'ABUSEIPDB_LOG_FILE_FORMAT_API', 'Wie soll der Dateiname für das Logfile aussehen, in dem Zugriffe auf die AbuseIPDB API protokolliert werden?<br><br>', 43),
26+
('AbuseIPDB - Logfile Format für Spider Protokollierung', 'ABUSEIPDB_LOG_FILE_FORMAT_SPIDERS', 'Wie soll der Dateiname für das Logfile aussehen, in dem Spider protokolliert werden?<br><br>', 43)");
27+
28+
$db->Execute("UPDATE " . TABLE_CONFIGURATION . " SET configuration_value = '2.1.1' WHERE configuration_key = 'ABUSEIPDB_MODUL_VERSION';");

NEUE DATEIEN/includes/classes/observers/class.abuseipdb_observer.php

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Copyright 2023 marcopolo
66
* see https://github.com/CcMarc/AbuseIPDB
77
* License: GNU General Public License (GPL)
8-
* version $Id: class.abuseipdb_observer.php 2023-05-31 22:12:16Z webchills $
8+
* version $Id: class.abuseipdb_observer.php 2023-06-24 20:06:16Z webchills $
99
*/
1010

1111
class abuseipdb_observer extends base {
@@ -50,16 +50,9 @@ protected function runCleanup() {
5050
}
5151

5252
protected function checkAbusiveIP() {
53-
global $current_page_base, $_SESSION, $db;
54-
55-
// Do not execute the check for the 'page_not_found' page or for known spiders
56-
if ($current_page_base == 'page_not_found' || (isset($spider_flag) && $spider_flag === true && ABUSEIPDB_SPIDER_ALLOW == 'true')) {
57-
return;
58-
}
53+
global $current_page_base, $_SESSION, $db, $spider_flag;
5954

60-
$abuseipdb_enabled = (int)ABUSEIPDB_ENABLED;
61-
62-
if (defined('ABUSEIPDB_ENABLED') && ABUSEIPDB_ENABLED == 'true') {
55+
if (ABUSEIPDB_ENABLED == 'true') {
6356
require_once 'includes/functions/abuseipdb_custom.php';
6457

6558
$api_key = ABUSEIPDB_API_KEY;
@@ -69,14 +62,19 @@ protected function checkAbusiveIP() {
6962
$test_ips = array_map('trim', explode(',', ABUSEIPDB_TEST_IP));
7063
$enable_logging = ABUSEIPDB_ENABLE_LOGGING === 'true';
7164
$enable_api_logging = ABUSEIPDB_ENABLE_LOGGING_API === 'true';
65+
$log_file_name = formatLogFileName(ABUSEIPDB_LOG_FILE_FORMAT);
66+
$log_file_name_cache = formatLogFileName(ABUSEIPDB_LOG_FILE_FORMAT_CACHE);
67+
$log_file_name_api = formatLogFileName(ABUSEIPDB_LOG_FILE_FORMAT_API);
68+
$log_file_name_spiders = formatLogFileName(ABUSEIPDB_LOG_FILE_FORMAT_SPIDERS);
7269
$log_file_path = ABUSEIPDB_LOG_FILE_PATH;
7370
$whitelisted_ips = explode(',', ABUSEIPDB_WHITELISTED_IPS);
7471
$blocked_ips = explode(',', ABUSEIPDB_BLOCKED_IPS);
7572
$debug_mode = ABUSEIPDB_DEBUG === 'true';
76-
$spider_allow = ABUSEIPDB_SPIDER_ALLOW;
77-
$spider_log_enabled = ABUSEIPDB_SPIDER_ALLOW_LOG;
78-
$blacklist_enable = ABUSEIPDB_BLACKLIST_ENABLE === 'true';
79-
$blacklist_file_path = ABUSEIPDB_BLACKLIST_FILE_PATH;
73+
$spider_allow = ABUSEIPDB_SPIDER_ALLOW;
74+
$spider_log_enabled = ABUSEIPDB_SPIDER_ALLOW_LOG;
75+
$blacklist_enable = ABUSEIPDB_BLACKLIST_ENABLE === 'true';
76+
$blacklist_file_path = ABUSEIPDB_BLACKLIST_FILE_PATH;
77+
$redirect_option = ABUSEIPDB_REDIRECT_OPTION;
8078

8179
if ($debug_mode == true) {
8280
error_log('API Key: ' . $api_key);
@@ -86,10 +84,28 @@ protected function checkAbusiveIP() {
8684
error_log('Test IPs: ' . implode(',', $test_ips));
8785
error_log('Enable Logging: ' . ($enable_logging ? 'true' : 'false'));
8886
error_log('Enable API Logging: ' . ($enable_api_logging ? 'true' : 'false'));
87+
error_log('Log File Format Block: ' . $log_file_name);
88+
error_log('Log File Format Cache: ' . $log_file_name_cache);
89+
error_log('Log File Format Api: ' . $log_file_name_api);
90+
error_log('Log File Format Spiders: ' . $log_file_name_spiders);
8991
error_log('Log File Path: ' . $log_file_path);
9092
error_log('Whitelisted IPs: ' . implode(',', $whitelisted_ips));
9193
error_log('Blocked IPs: ' . implode(',', $blocked_ips));
94+
error_log('Spider Allow: ' . $spider_allow);
95+
error_log('Spider Log Enabled: ' . ($spider_log_enabled ? 'true' : 'false'));
96+
error_log('Blacklist Enable: ' . ($blacklist_enable ? 'true' : 'false'));
97+
error_log('Blacklist File Path: ' . $blacklist_file_path);
98+
error_log('Redirect Option: ' . $redirect_option);
9299
}
100+
101+
// Do not execute the check for the 'page_not_found' page
102+
if ($redirect_option === 'page_not_found') {
103+
if ($current_page_base == 'page_not_found') {
104+
return;
105+
}
106+
}
107+
108+
$abuseipdb_enabled = (int)ABUSEIPDB_ENABLED;
93109

94110
$ip = $_SERVER['REMOTE_ADDR'];
95111

@@ -124,25 +140,28 @@ protected function checkAbusiveIP() {
124140

125141
if ($ip_blocked) {
126142
if ($debug_mode == true) {
127-
error_log('IP ' . $ip . ' blocked from cache');
143+
error_log('IP ' . $ip . ' blocked by blacklist');
128144
}
129145

130-
$log_file_name = 'abuseipdb_blocked_' . date('Y_m') . '.log';
131146
$log_file_path = ABUSEIPDB_LOG_FILE_PATH . $log_file_name;
132147
$log_message_cache = date('Y-m-d H:i:s') . ' IP address ' . $ip . ' blocked by blacklist: ' . $abuseScore . PHP_EOL;
133148

134149
if ($enable_logging) {
135150
file_put_contents($log_file_path, $log_message_cache, FILE_APPEND);
136151
}
137-
header('HTTP/1.0 403 Forbidden');
138-
zen_exit();
152+
if ($redirect_option === 'page_not_found') {
153+
header('Location: /index.php?main_page=page_not_found');
154+
exit();
155+
} elseif ($redirect_option === 'forbidden') {
156+
header('HTTP/1.0 403 Forbidden');
157+
exit();
158+
}
139159
}
140160

141161
// Skip API call for known spiders if enabled
142-
if (checkSpiderFlag() && $spider_allow == 'true') {
162+
if ((isset($spider_flag) && $spider_flag === true && $spider_allow == 'true')) {
143163

144164
// Check if logging is enabled for allowed spiders
145-
$log_file_name_spiders = 'abuseipdb_spiders_' . date('Y_m_d') . '.log'; // Changed to daily log file
146165
$log_file_path_spiders = $log_file_path . $log_file_name_spiders;
147166
$log_message = date('Y-m-d H:i:s') . ' IP address ' . $ip . ' is identified as a Spider. AbuseIPDB API check was bypassed.' . PHP_EOL;
148167

@@ -166,16 +185,20 @@ protected function checkAbusiveIP() {
166185
}
167186

168187
if ($abuseScore >= $threshold || ($test_mode && in_array($ip, $test_ips))) {
169-
$log_file_name = 'abuseipdb_blocked_cache_' . date('Y_m') . '.log';
170-
$log_file_path = ABUSEIPDB_LOG_FILE_PATH . $log_file_name;
188+
$log_file_path = ABUSEIPDB_LOG_FILE_PATH . $log_file_name_cache;
171189
$log_message_cache = date('Y-m-d H:i:s') . ' IP address ' . $ip . ' blocked from database cache with score: ' . $abuseScore . PHP_EOL;
172190

173191
if ($enable_logging) {
174192
file_put_contents($log_file_path, $log_message_cache, FILE_APPEND);
175193
}
176194

177-
header('HTTP/1.0 403 Forbidden');
178-
zen_exit();
195+
if ($redirect_option === 'page_not_found') {
196+
header('Location: /index.php?main_page=page_not_found');
197+
exit();
198+
} elseif ($redirect_option === 'forbidden') {
199+
header('HTTP/1.0 403 Forbidden');
200+
exit();
201+
}
179202
}
180203
} else {
181204
// Make the API call
@@ -189,8 +212,6 @@ protected function checkAbusiveIP() {
189212
$query = "INSERT INTO " . TABLE_ABUSEIPDB_CACHE . " (ip, score, timestamp) VALUES ('" . zen_db_input($ip) . "', " . (int)$abuseScore . ", NOW()) ON DUPLICATE KEY UPDATE score = VALUES(score), timestamp = VALUES(timestamp)";
190213
$db->Execute($query);
191214
}
192-
193-
$log_file_name_api = 'abuseipdb_api_call_' . date('Y_m_d') . '.log'; // Changed to daily log file
194215
$log_file_path_api = $log_file_path . $log_file_name_api;
195216
$log_message = date('Y-m-d H:i:s') . ' IP address ' . $ip . ' API call. Score: ' . $abuseScore . PHP_EOL;
196217

@@ -203,16 +224,20 @@ protected function checkAbusiveIP() {
203224
}
204225

205226
if ($abuseScore >= $threshold) {
206-
$log_file_name = 'abuseipdb_blocked_' . date('Y_m') . '.log';
207227
$log_file_path = ABUSEIPDB_LOG_FILE_PATH . $log_file_name;
208228
$log_message = date('Y-m-d H:i:s') . ' IP address ' . $ip . ' blocked by AbuseIPDB from API call with score: ' . $abuseScore . PHP_EOL;
209229

210230
if ($enable_logging) {
211231
file_put_contents($log_file_path, $log_message, FILE_APPEND);
212232
}
213233

214-
header('HTTP/1.0 403 Forbidden');
215-
zen_exit();
234+
if ($redirect_option === 'page_not_found') {
235+
header('Location: /index.php?main_page=page_not_found');
236+
exit();
237+
} elseif ($redirect_option === 'forbidden') {
238+
header('HTTP/1.0 403 Forbidden');
239+
exit();
240+
}
216241
}
217242
}
218243
}

0 commit comments

Comments
 (0)