plugins/spamx/MTBlackList.Examine.class.php
author Dirk Haun <dirk@haun-online.de>
Thu, 29 Oct 2009 13:00:11 +0100
branchHEAD
changeset 7397 c27e9026f22a
parent 6838 cb1ba8d99085
permissions -rw-r--r--
Fixed inclusion protection
     1 <?php
     2 
     3 /**
     4  * File: MTBlackList.Examine.class.php
     5  * This module examines comments for entries on the MT-Blacklist
     6  * for the Geeklog Spam-X plugin
     7  * 
     8  * Copyright (C) 2004-2009 by the following authors:
     9  * Author   Tom Willett     tomw AT pigstye DOT net
    10  * 
    11  * Licensed under GNU General Public License
    12  * 
    13  * The MT-Blacklist was maintained by Jay Allen
    14  * http://www.jayallen.org/comment_spam/
    15  *
    16  * @package Spam-X
    17  * @subpackage Modules
    18  */
    19 
    20 if (strpos(strtolower($_SERVER['PHP_SELF']), 'mtblacklist.examine.class.php') !== false) {
    21     die('This file can not be used on its own!');
    22 }
    23 
    24 /**
    25  * Include Abstract Examine Class
    26  */
    27 require_once $_CONF['path'] . 'plugins/spamx/' . 'BaseCommand.class.php';
    28 
    29 /**
    30  * Examines Comment according to MT-BLacklist
    31  * 
    32  * @author Tom Willett tomw AT pigstye DOT net 
    33  *
    34  * @package Spam-X
    35  *
    36  */
    37 class MTBlackList extends BaseCommand {
    38     /**
    39      * No Constructor Use BaseCommand constructor
    40      */
    41     /**
    42      * Here we do the work
    43      */
    44     function execute ($comment)
    45     {
    46         global $_CONF, $_USER, $_TABLES, $LANG_SX00;
    47 
    48         if (isset ($_USER['uid']) && ($_USER['uid'] > 1)) {
    49             $uid = $_USER['uid'];
    50         } else {
    51             $uid = 1;
    52         }
    53 
    54         /**
    55          * Include Blacklist Data
    56          */
    57         $result = DB_query ("SELECT value FROM {$_TABLES['spamx']} WHERE name = 'MTBlacklist'", 1);
    58         $nrows = DB_numRows ($result);
    59 
    60         // named entities
    61         $comment = html_entity_decode ($comment);
    62         // decimal notation
    63         $comment = preg_replace ('/&#(\d+);/me', "chr(\\1)", $comment);
    64         // hex notation
    65         $comment = preg_replace ('/&#x([a-f0-9]+);/mei', "chr(0x\\1)", $comment);
    66         $ans = 0; // Found Flag
    67         for ($i = 1; $i <= $nrows; $i++) {
    68             list ($val) = DB_fetchArray ($result);
    69             if (@preg_match ("#$val#i", $comment)) {
    70                 $ans = 1; // quit on first positive match
    71                 SPAMX_log ($LANG_SX00['fsc'] . $val . $LANG_SX00['fsc1'] .
    72                            $uid . $LANG_SX00['fsc2'] . $_SERVER['REMOTE_ADDR']);
    73                 break;
    74             } 
    75         } 
    76         return $ans;
    77     } 
    78 } 
    79 
    80 ?>