Guestbook ban IP

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–>

  • The last two places of the IP can be masked by the substitute symbol *
  • Siehe zu IP auch IP-address
  • Decollator of the IPs is a blank or a line-feed.

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

Code snipped

Banned IP

    // 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>';
        }
    }
    // ===============================


Template

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>


Documentation

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'])) { ...........
 ======================================================== */
?>


Whois call

E.g.

english/other-enhancements/hacks/guestbook-ban-ip.txt · Last modified: 2018/06/03 18:09 (external edit)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0