[ Index ]
 

Code source de GeekLog 1.4.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/plugins/spamx/ -> IP.Examine.class.php (source)

   1  <?php
   2  
   3  /**
   4  * File: IP.Examine.class.php
   5  * This is the IP 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  * $Id: IP.Examine.class.php,v 1.9 2006/09/06 05:31:00 ospiess Exp $
  13  */
  14  
  15  if (strpos ($_SERVER['PHP_SELF'], 'IP.Examine.class.php') !== false) {
  16      die ('This file can not be used on its own!');
  17  }
  18  
  19  /**
  20  * Include Abstract Examine Class
  21  */
  22  require_once($_CONF['path'] . 'plugins/spamx/' . 'BaseCommand.class.php');
  23  
  24  /**
  25  * Examines Comment according to Personal BLacklist
  26  *
  27  * @author Tom Willett tomw AT pigstye DOT net
  28  */
  29  
  30  class IP extends BaseCommand {
  31      /**
  32       * No Constructor Use BaseCommand constructor
  33       */
  34  
  35      /**
  36       * The execute method examines the IP address a comment is coming from,
  37       * comparing it against a blacklist of banned IP addresses.
  38       *
  39       * @param $comment string                 Comment text to examine
  40       */
  41      function execute($comment)
  42      {
  43          return $this->_process($_SERVER['REMOTE_ADDR']);
  44      }
  45  
  46      /**
  47       * The re-execute method is used to massdelete spam, essentially
  48       * it does the same as execute, but is called with recorded comments
  49       * in order to match them against new rules that were not in effect
  50       * at the time of posting. To do that, it uses the IP address logged
  51       * when the comment was saved.
  52       *
  53       * @param $comment string            Comment text to examine
  54       * @param $date       unixtimestamp  Date/time the comment was posted
  55       * @param $ip         string         IPAddress comment posted from
  56       * @param $type       string         Type of comment (article etc)
  57       */
  58      function reexecute($comment, $date, $ip, $type)
  59      {
  60              return $this->_process($ip);
  61      }
  62  
  63          /**
  64           * Private internal method, this actually processes a given ip
  65           * address against a blacklist of IP regular expressions.
  66           *
  67           * @param $ip    string    IP address of comment poster
  68           */
  69      function _process($ip)
  70      {
  71              global $_CONF, $_TABLES, $_USER, $LANG_SX00, $result;
  72  
  73          if (isset ($_USER['uid']) && ($_USER['uid'] > 1)) {
  74              $uid = $_USER['uid'];
  75          } else {
  76              $uid = 1;
  77          }
  78  
  79          /**
  80           * Include Blacklist Data
  81           */
  82          $result = DB_query("SELECT value FROM {$_TABLES['spamx']} WHERE name='IP'", 1);
  83          $nrows = DB_numRows($result);
  84  
  85          $ans = 0;
  86          for ($i = 1; $i <= $nrows; $i++) {
  87              list ($val) = DB_fetchArray ($result);
  88              if ( preg_match ("#$val#i", $ip)) {
  89                  $ans = 1; // quit on first positive match
  90                  SPAMX_log ($LANG_SX00['foundspam'] . $val .
  91                             $LANG_SX00['foundspam2'] . $uid .
  92                             $LANG_SX00['foundspam3'] . $ip);
  93                  break;
  94              }
  95          }
  96          return $ans;
  97      }
  98  }
  99  
 100  ?>


Généré le : Wed Nov 21 12:27:40 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics