Plugin Directory

Changeset 1256638


Ignore:
Timestamp:
09/30/2015 02:21:39 PM (11 years ago)
Author:
achbed
Message:

Fixed preg_match errors in DNS matching

Location:
botnet-blocker/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • botnet-blocker/trunk/botnet-blocker.php

    r1256133 r1256638  
    55Description: Free botnet IP blocker according to public DNSBL bases. Based on public DNSBL class.
    66Author: Dennis Wallace
    7 Version: 1.2.0
     7Version: 1.2.1
    88License: GPLv2 or later
    99*/
     
    317317         */
    318318        public function dnsmatch( $dns, $name ) {
    319             if ( empty( $name ) ) {
     319            if ( empty( $name ) || empty( $dns ) ) {
    320320                return false;
    321321            }
    322322           
    323             $regex = '';
    324             if ( substr( $name, 0, 1 ) == '/' ) {
    325                 if ( substr( $name, -1 ) == '/' ) {
    326                     // Regex format already.  Make sure it's not a completely empty match.
    327                     $n = str_replace( array( '/','$','.','^' ), '', $name );
    328                     if ( empty( $n ) ) {
    329                         return false;
    330                     }
    331                    
    332                     $regex = $name;
    333                 }
    334             }
    335            
    336             if ( empty( $regex ) ) {
    337                 $regex = '/' . str_replace( array( '.', '$', '^', '/' ) , array( '\.', '\$', '\^', '\/'), $name ) . '$/';
    338             }
    339            
    340             $r = preg_match( $regex, $dns );
    341             return ( $r == 1 );
     323            $match = strtolower( $dns );
     324            $len = strlen( $name );
     325            $match = substr( $match, -$len );
     326            return ( $match == $name );
    342327        }
    343328       
  • botnet-blocker/trunk/class.bnblocker-config.php

    r1256133 r1256638  
    135135        public function preplist( $list, $ip = true ) {
    136136            $a = $list;
     137            $a = str_replace( array("\r","\n","\t"," "), ";", $a );
    137138            if ( $ip ) {
    138139                $a = preg_replace( '/[^.0-9\/]+/', ";", $list );
     140            } else {
     141                $a = strtolower( $a );
    139142            }
    140143            $a = trim( $a );
     
    143146            $b = array();
    144147            foreach ( $a as $i ) {
    145                 $b[$i] = true;
    146             }
    147             return array_keys( $b );
     148                if ( ! empty ( $i ) ) {
     149                    $b[$i] = true;
     150                }
     151            }
     152            $array = array_keys( $b );
     153            if ( empty( $array ) ) {
     154                $array = array();
     155            }
     156            return $array;
    148157        }
    149158       
  • botnet-blocker/trunk/readme.txt

    r1256133 r1256638  
    44Requires at least: 4.0.0
    55Tested up to: 4.3.1
    6 Stable tag: 1.2.0
     6Stable tag: 1.2.1
    77License: GPLv2
    88
     
    3939== Upgrade Notice ==
    4040
     41= 1.2.1 =
     42Fixed preg_match errors in DNS matching
     43
    4144= 1.2.0 =
    4245Allows ignoring all RBLs
     
    5053
    5154== Changelog ==
     55
     56
     57= 1.2.1 =
     58* Fixed preg_match errors in DNS matching
    5259
    5360= 1.2.0 =
Note: See TracChangeset for help on using the changeset viewer.