NAVIGATION
A small enhancement for the guest book to make the the still missing “banned IP feature” possible.
Docu: –
Forum: –
Autor: K.Heermann (flip-flop) http://planmatrix.de
CMS version: >= 1.4
Version: V1.0
Tag (in guestbook template): <!–BAN_IP_START–> xxx.yyy.zzz.uuu xxx.yyy.zzz.* xxx.yyy.*.* <!–BAN_IP_END–>
Example:
<!--BAN_IP_START//--> 192.168.0.0 92.241.154.* 125.116.*.* 91.191.*.* <!--BAN_IP_END//-->
file name: cnt18.article.inc.php
location: include/inc_front/content/
Enhancement of the file include/inc_front/content/cnt18.article.inc.php for instance starting from line 330 directly forwards
// Captcha check if(empty($guestbook['captcha'])) { ........
insert this
// Banned IP ================= +kh 24.10.09 if( !empty($guestbook['ban_ip']) ) { $_ip = getRemoteIP(); $_ipex = explode('.', $_ip); //exampl.IP 123.456.678.901 // $_ipex [0] [1] [2] [3] $_ipex[3] = '*'; // 123.456.678.* $_ip01 = implode ('.',$_ipex); $_ipex[2] = '*'; // 123.456.*.* $_ip02 = implode ('.',$_ipex); if ( strpos($guestbook['ban_ip'], $_ip01) OR // xxx.yyy.zzz.* strpos($guestbook['ban_ip'], $_ip02) OR // xxx.yyy.*.* strpos($guestbook['ban_ip'], $_ip) ) { $guestbook['flooding'] = 1; $guestbook['readform'] = 1; // $guestbook['spamalert'] = '<div class="spamFormAlert">Your IP '.getRemoteIP().' is not allowed to send form (Blacklist)!</div>'; $guestbook['spamalert'] = '<div class="spamFormAlert"><br /><hr><strong>Sorry, your are not allowed to send form!</strong><hr><br /></div>'; } } // ===============================
In template now the exclusion of individual IPs or IP ranges is also possible:
E.g.:
<!--BAN_IP_START//--> 192.168.0.0 92.241.*.* 125.116.15.* 91.191.*.* <!--BAN_IP_END//-->
<note important> Be carefull by using a placeholder in the third position (xxx.yyy.*.*)!!! Often the two first places of the IP are used from several countries. </note>
Place the file PATCH-DOC.php into the folder include/inc_front/content/. (Or at another place and/or with other name - however always with the extend *.php)
include/inc_front/content/PATCH-DOC.php
<?php /* ======================================================== // 24.10.09 KH // Banned IP // Around line 331, before Captcha check // Insert the following snipped: // Banned IP ================= +kh 24.10.09 if( !empty($guestbook['ban_ip']) ) { $_ip = getRemoteIP(); $_ipex = explode('.', $_ip); //exampl.IP 123.456.678.901 // $_ipex [0] [1] [2] [3] $_ipex[3] = '*'; // 123.456.678.* $_ip01 = implode ('.',$_ipex); $_ipex[2] = '*'; // 123.456.*.* $_ip02 = implode ('.',$_ipex); if ( strpos($guestbook['ban_ip'], $_ip01) OR // xxx.yyy.zzz.* strpos($guestbook['ban_ip'], $_ip02) OR // xxx.yyy.*.* strpos($guestbook['ban_ip'], $_ip) ) { $guestbook['flooding'] = 1; $guestbook['readform'] = 1; // $guestbook['spamalert'] = '<div class="spamFormAlert">Your IP '.getRemoteIP().' is not allowed to send form (Blacklist)!</div>'; $guestbook['spamalert'] = '<div class="spamFormAlert"><br /><hr><strong>Sorry, your are not allowed to send form!</strong><hr><br /></div>'; } } // =============================== // Captcha check if(empty($guestbook['captcha'])) { ........... ======================================================== */ ?>
E.g.