plugins/spamx/BlackList.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: BlackList.Examine.class.php
     5  * This is the Personal BlackList Examine class for the Geeklog Spam-X plugin
     6  * 
     7  * Copyright (C) 2004-2006 by the following authors:
     8  * Author   Tom Willett     tomw AT pigstye DOT net
     9  * 
    10  * Licensed under GNU General Public License
    11  *
    12  * @package Spam-X
    13  * @subpackage Modules
    14  */
    15 
    16 if (strpos(strtolower($_SERVER['PHP_SELF']), 'blacklist.examine.class.php') !== false) {
    17     die('This file can not be used on its own!');
    18 }
    19 
    20 /**
    21  * Include Abstract Examine Class
    22  */
    23 require_once $_CONF['path'] . 'plugins/spamx/' . 'BaseCommand.class.php';
    24 
    25 /**
    26  * Examines Comment according to Personal BLacklist
    27  * 
    28  * @author Tom Willett tomw AT pigstye DOT net 
    29  * @package Spam-X
    30  *
    31  */
    32 class BlackList extends BaseCommand {
    33     /**
    34      * No Constructor Use BaseCommand constructor
    35      */
    36     /**
    37      * Here we do the work
    38      */
    39     function execute ($comment)
    40     {
    41         global $_CONF, $_TABLES, $_USER, $LANG_SX00;
    42 
    43         if (isset ($_USER['uid']) && ($_USER['uid'] > 1)) {
    44             $uid = $_USER['uid'];
    45         } else {
    46             $uid = 1;
    47         }
    48 
    49         /**
    50          * Include Blacklist Data
    51          */
    52         $result = DB_query ("SELECT value FROM {$_TABLES['spamx']} WHERE name='Personal'", 1);
    53         $nrows = DB_numRows ($result);
    54 
    55         // named entities
    56         $comment = html_entity_decode ($comment);
    57         // decimal notation
    58         $comment = preg_replace ('/&#(\d+);/me', "chr(\\1)", $comment);
    59         // hex notation
    60         $comment = preg_replace ('/&#x([a-f0-9]+);/mei', "chr(0x\\1)", $comment);
    61         $ans = 0;
    62         for ($i = 1; $i <= $nrows; $i++) {
    63             list ($val) = DB_fetchArray ($result);
    64             $val = str_replace ('#', '\\#', $val);
    65             if (preg_match ("#$val#i", $comment)) {
    66                 $ans = 1; // quit on first positive match
    67                 SPAMX_log ($LANG_SX00['foundspam'] . $val .
    68                            $LANG_SX00['foundspam2'] . $uid .
    69                            $LANG_SX00['foundspam3'] . $_SERVER['REMOTE_ADDR']);
    70                 break;
    71             }
    72         }
    73         return $ans;
    74     }
    75 }
    76 
    77 ?>