[ Index ]
 

Code source de GeekLog 1.4.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

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

   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  * $Id: IPofUrl.Examine.class.php,v 1.5 2006/06/25 08:40:54 dhaun Exp $
  13  */
  14  
  15  if (strpos ($_SERVER['PHP_SELF'], 'IPofUrl.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  * html_entity_decode is only available as of PHP 4.3.0
  26  */
  27  if (!function_exists ('html_entity_decode')) {
  28      require_once ('PHP/Compat.php');
  29  
  30      PHP_Compat::loadFunction ('html_entity_decode');
  31  }
  32  
  33  /**
  34  * Examines Comment according to Personal BLacklist
  35  *
  36  * @author Tom Willett tomw AT pigstye DOT net
  37  */
  38  
  39  class IPofUrl extends BaseCommand {
  40      /**
  41       * No Constructor Use BaseCommand constructor
  42       */
  43      /**
  44       * Here we do the work
  45       */
  46      function execute($comment)
  47      {
  48          global $_CONF, $_TABLES, $_USER, $LANG_SX00, $result;
  49  
  50          if (isset ($_USER['uid']) && ($_USER['uid'] > 1)) {
  51              $uid = $_USER['uid'];
  52          } else {
  53              $uid = 1;
  54          }
  55  
  56          /**
  57           * Check for IP of url in blacklist
  58           */
  59          /*
  60          * regex to find urls $2 = fqd
  61          */
  62          $regx = '(ftp|http|file)://([^/\\s]+)';
  63          $num = preg_match_all ("#{$regx}#", html_entity_decode ($comment), $urls);
  64  
  65          $result = DB_query ("SELECT value FROM {$_TABLES['spamx']} WHERE name='IPofUrl'", 1);
  66          $nrows = DB_numRows ($result);
  67  
  68          $ans = 0;
  69          for ($j = 1; $j <= $nrows; $j++) {
  70              list ($val) = DB_fetchArray ($result);
  71              for ($i = 0; $i < $num; $i++) {
  72                $ip = gethostbyname ($urls[2][$i]);
  73                if ($val == $ip) {
  74                  $ans = 1; // quit on first positive match
  75                  SPAMX_log ($LANG_SX00['foundspam'] . $urls[2][$i] .
  76                             $LANG_SX00['foundspam2'] . $uid .
  77                             $LANG_SX00['foundspam3'] . $_SERVER['REMOTE_ADDR']);
  78                  break;
  79                }
  80              }
  81              if ($ans == 1) {
  82                break;
  83              }
  84          }
  85          return $ans;
  86      }
  87  }
  88  
  89  ?>


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