[ Index ]
 

Code source de Dotclear 2.0-beta6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/plugins/antispam/inc/ -> class.dc.spamfilter.php (source)

   1  <?php
   2  # ***** BEGIN LICENSE BLOCK *****
   3  # This is Antispam, a plugin for DotClear. 
   4  # Copyright (c) 2007 Alain Vagner and contributors. All rights
   5  # reserved.
   6  #
   7  # DotClear is free software; you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation; either version 2 of the License, or
  10  # (at your option) any later version.
  11  # 
  12  # DotClear is distributed in the hope that it will be useful,
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  # GNU General Public License for more details.
  16  #
  17  # You should have received a copy of the GNU General Public License
  18  # along with DotClear; if not, write to the Free Software
  19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20  #
  21  # ***** END LICENSE BLOCK *****
  22  
  23  class dcSpamFilter
  24  {
  25      public $name;
  26      public $description;
  27      public $active = true;
  28      public $order = 100;
  29      
  30      protected $has_gui = false;
  31      protected $gui_url = null;
  32      
  33      protected $core;
  34      
  35      /**
  36      Object constructor
  37      
  38      @param    core        <b>dcCore</b>        Dotclear core object
  39      */
  40  	public function __construct(&$core)
  41      {
  42          $this->core =& $core;
  43          $this->setInfo();
  44          
  45          if (!$this->name) {
  46              $this->name = get_class($this);
  47          }
  48          
  49          $this->gui_url = 'plugin.php?p=antispam&f='.get_class($this);
  50      }
  51      
  52      /**
  53      This method is called by the constructor and allows you to change some
  54      object properties without overloading object constructor.
  55      */
  56  	protected function setInfo()
  57      {
  58          $this->description = __('No description');
  59      }
  60      
  61      /**
  62      This method should return if a comment is a spam or not. If it returns true
  63      or false, execution of next filters will be stoped. If should return nothing
  64      to let next filters apply.
  65      
  66      Your filter should also fill $status variable with its own information if
  67      comment is a spam.
  68      
  69      @param        type        <b>string</b>        Comment type (comment or trackback)
  70      @param        author    <b>string</b>        Comment author
  71      @param        email    <b>string</b>        Comment author email
  72      @param        site        <b>string</b>        Comment author website
  73      @param        ip        <b>string</b>        Comment author IP address
  74      @param        content    <b>string</b>        Comment content
  75      @param        post_id    <b>integer</b>        Comment post_id
  76      @param[out]    status    <b>integer</b>        Comment status
  77      @return    <b>boolean</b>
  78      */
  79  	public function isSpam($type,$author,$email,$site,$ip,$content,$post_id,&$status)
  80      {
  81      }
  82      
  83      /**
  84      This method is called when a non-spam (ham) comment becomes spam or when a
  85      spam becomes a ham.
  86      
  87      @param    type        <b>string</b>        Comment type (comment or trackback)
  88      @param    filter    <b>string</b>        Filter name
  89      @param    author    <b>string</b>        Comment author
  90      @param    email    <b>string</b>        Comment author email
  91      @param    site        <b>string</b>        Comment author website
  92      @param    ip        <b>string</b>        Comment author IP address
  93      @param    content    <b>string</b>        Comment content
  94      @param    post_url    <b>string</b>        Post URL
  95      @param    rs        <b>record</b>        Comment record
  96      @return    <b>boolean</b>
  97      */
  98  	public function trainFilter($status,$filter,$type,$author,$email,$site,$ip,$content,$rs)
  99      {
 100      }
 101      
 102      /**
 103      This method returns filter status message. You can overload this method to
 104      return a custom message. Message is shown in comment details and in
 105      comments list.
 106      
 107      @param    status        <b>string</b>        Filter status.
 108      @param    comment_id    <b>record</b>        Comment record
 109      @return    <b>string</b>
 110      */
 111  	public function getStatusMessage($status,$comment_id)
 112      {
 113          return sprintf(__('Filtered by %1$s (%2$s)'),$this->guiLink(),$status);
 114      }
 115      
 116      /**
 117      This method is called when you enter filter configuration. Your class should
 118      have $has_gui property set to "true" to enable GUI.
 119      
 120      In this method you should put everything related to filter configuration.
 121      $url variable is the URL of GUI <i>unescaped</i>.
 122      
 123      @param    url        <b>string</b>        GUI URL.
 124      */
 125  	public function gui($url)
 126      {
 127      }
 128      
 129  	public function hasGUI()
 130      {
 131          if (!$this->core->auth->check('admin',$this->core->blog->id)) {
 132              return false;
 133          }
 134          
 135          if (!$this->has_gui) {
 136              return false;
 137          }
 138          
 139          return true;
 140      }
 141      
 142  	public function guiURL()
 143      {
 144          if (!$this->hasGui()) {
 145              return false;
 146          }
 147          
 148          return $this->gui_url;
 149      }
 150      
 151      /**
 152      Returns a link to filter GUI if exists or only filter name if has_gui
 153      property is false.
 154      
 155      @return    <b>string</b>
 156      */
 157  	public function guiLink()
 158      {
 159          if (($url = $this->guiURL()) !== false) {
 160              $url = html::escapeHTML($url);
 161              $link = '<a href="%2$s">%1$s</a>';
 162          } else {
 163              $link = '%1$s';
 164          }
 165          
 166          return sprintf($link,$this->name,$url);
 167      }
 168  }
 169  ?>


Généré le : Fri Feb 23 22:16:06 2007 par Balluche grâce à PHPXref 0.7