plugins/spamx/IPofUrl.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: IPofUrl.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']), 'ipofurl.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 *
    30 * @package Spam-X
    31 *
    32 */
    33 class IPofUrl extends BaseCommand {
    34     /**
    35      * No Constructor Use BaseCommand constructor
    36      */
    37     /**
    38      * Here we do the work
    39      */
    40     function execute($comment)
    41     {
    42         global $_CONF, $_TABLES, $_USER, $LANG_SX00, $result;
    43 
    44         if (isset ($_USER['uid']) && ($_USER['uid'] > 1)) {
    45             $uid = $_USER['uid'];
    46         } else {
    47             $uid = 1;
    48         }
    49 
    50         /**
    51          * Check for IP of url in blacklist
    52          */
    53         /*
    54         * regex to find urls $2 = fqd
    55         */
    56         $regx = '(ftp|http|file)://([^/\\s]+)';
    57         $num = preg_match_all ("#{$regx}#", html_entity_decode ($comment), $urls);
    58 
    59         $result = DB_query ("SELECT value FROM {$_TABLES['spamx']} WHERE name='IPofUrl'", 1);
    60         $nrows = DB_numRows ($result);
    61 
    62         $ans = 0;
    63         for ($j = 1; $j <= $nrows; $j++) {
    64             list ($val) = DB_fetchArray ($result);
    65             for ($i = 0; $i < $num; $i++) {
    66               $ip = gethostbyname ($urls[2][$i]);
    67               if ($val == $ip) {
    68                 $ans = 1; // quit on first positive match
    69                 SPAMX_log ($LANG_SX00['foundspam'] . $urls[2][$i] .
    70                            $LANG_SX00['foundspam2'] . $uid .
    71                            $LANG_SX00['foundspam3'] . $_SERVER['REMOTE_ADDR']);
    72                 break;
    73               }
    74             }
    75             if ($ans == 1) {
    76               break;
    77             }
    78         }
    79         return $ans;
    80     }
    81 }
    82 
    83 ?>