[ Index ]
 

Code source de GeekLog 1.4.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/plugins/spamx/ -> MassDelete.Admin.class.php (source)

   1  <?php
   2  
   3  /**
   4  * file:  MassDelete.Admin.class.php
   5  * Mass delete comment spam
   6  *
   7  * Copyright (C) 2004-2006 by the following authors:
   8  *
   9  * @ Author        Tom Willett        tomw AT pigstye DOT net
  10  *
  11  * Licensed under GNU General Public License
  12  *
  13  * $Id: MassDelete.Admin.class.php,v 1.17 2006/12/02 16:35:23 dhaun Exp $
  14  */
  15  
  16  if (strpos ($_SERVER['PHP_SELF'], 'MassDelete.Admin.class.php') !== false) {
  17      die ('This file can not be used on its own!');
  18  }
  19  
  20  require_once($_CONF['path'] . 'plugins/spamx/BaseAdmin.class.php');
  21  require_once($_CONF['path_system'] . 'lib-comment.php');
  22  
  23  
  24  class MassDelete extends BaseAdmin {
  25      /**
  26      * Constructor
  27      *
  28      */
  29      function display()
  30      {
  31          global $_CONF, $_TABLES, $LANG_SX00;
  32  
  33          $display = $LANG_SX00['masshead'];
  34  
  35          $act = '';
  36          if (isset ($_POST['action'])) {
  37              $act = COM_applyFilter ($_POST['action']);
  38          }
  39          $lmt = 0;
  40          if (isset ($_POST['limit'])) {
  41              $lmt = COM_applyFilter ($_POST['limit'], true);
  42          }
  43  
  44          if (($act == $LANG_SX00['deletespam']) && ($lmt>0)) {
  45              $numc = 0;
  46              $spamx_path = $_CONF['path'] . 'plugins/spamx/';
  47  
  48              if ($dir = @opendir($spamx_path)) {
  49                  while(($file = readdir($dir)) !== false) {
  50                      if (is_file($spamx_path . $file)) {
  51                          if (substr($file, -18) == '.Examine.class.php') {
  52                              $tmp = str_replace('.Examine.class.php', '', $file);
  53                              $Spamx_Examine[] = $tmp;
  54  
  55                              require_once ($spamx_path . $file);
  56                          }
  57                      }
  58                  }
  59                  closedir($dir);
  60              }
  61  
  62              $result = DB_query("SELECT comment,cid,sid,type,UNIX_TIMESTAMP(date) as date,ipaddress FROM {$_TABLES['comments']} ORDER BY date DESC LIMIT $lmt");
  63              $nrows = DB_numRows($result);
  64              for ($i = 0; $i < $nrows; $i++) {
  65                  $A = DB_fetchArray($result);
  66                  foreach($Spamx_Examine as $Examine) {
  67                      $EX = new $Examine;
  68                      if(method_exists($EX, 'reexecute'))
  69                      {
  70                          $res = $EX->reexecute($A['comment'], $A['date'], $A['ipaddress'], $A['type']);
  71                      } else {
  72                          $res = $EX->execute ($A['comment']);
  73                      }
  74                      if ($res == 1) {
  75                          break;
  76                      }
  77                  }
  78                  if ($res == 1) {
  79                      $this->delcomment($A['cid'], $A['sid'], $A['type']);
  80                      $numc = $numc + 1;
  81                  }
  82              }
  83              $display .= $numc . $LANG_SX00['comdel'];
  84          } else {
  85              $display .= '<form method="post" action="' . $_CONF['site_admin_url'] . '/plugins/spamx/index.php?command=MassDelete">';
  86              $display .= $LANG_SX00['numtocheck'] . "&nbsp;&nbsp&nbsp" . ' <select name="limit">';
  87              $display .= '<option value = "10">10</option><option value="50">50</option>';
  88              $display .= '<option value = "100" selected="selected">100</option><option value="200">200</option>';
  89              $display .= '<option value = "300">300</option><option value="400">400</option>';
  90              $display .= '</select>';
  91              $display .= $LANG_SX00['note1'];
  92              $display .= $LANG_SX00['note2'];
  93              $display .= $LANG_SX00['note3'];
  94              $display .= $LANG_SX00['note4'];
  95              $display .= $LANG_SX00['note5'];
  96              $display .= $LANG_SX00['note6'];
  97              $display .= '<input type = "Submit" name="action" value="' . $LANG_SX00['deletespam'] . '">';
  98              $display .= '</form>';
  99          }
 100  
 101          return $display;
 102      }
 103  
 104      function link()
 105      {
 106          global $LANG_SX00;
 107  
 108          return "Mass Delete Spam Comments";
 109      }
 110  
 111      /**
 112      * Deletes a given comment
 113      * (lifted from comment.php)
 114      * @param    int         $cid    Comment ID
 115      * @param    string      $sid    ID of object comment belongs to
 116      * @param    string      $type   Comment type (e.g. article, poll, etc)
 117      * @return   string      Returns string needed to redirect page to right place
 118      *
 119      */
 120      function delcomment ($cid, $sid, $type)
 121      {
 122          global $_CONF, $_TABLES, $LANG_SX00;
 123  
 124          $type = COM_applyFilter ($type);
 125          $sid = COM_applyFilter ($sid);
 126          switch ( $type ) {
 127              case 'article':
 128                  $has_editPermissions = SEC_hasRights ('story.edit');
 129                  $result = DB_query ("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['stories']} WHERE sid = '$sid'");
 130                  $A = DB_fetchArray ($result);
 131  
 132                  if ($has_editPermissions && SEC_hasAccess ($A['owner_id'],
 133                          $A['group_id'], $A['perm_owner'], $A['perm_group'],
 134                          $A['perm_members'], $A['perm_anon']) == 3) {
 135                      CMT_deleteComment(COM_applyFilter($cid, true), $sid, 'article');
 136                      $comments = DB_count ($_TABLES['comments'],
 137                              array ('sid', 'type'), array ($sid, 'article'));
 138                      DB_change ($_TABLES['stories'], 'comments', $comments,
 139                                 'sid', $sid);
 140                  } else {
 141                      COM_errorLog ("User {$_USER['username']} (IP: {$_SERVER['REMOTE_ADDR']}) tried to illegally delete comment $cid from $type $sid");
 142                  }
 143                  break;
 144              default: // assume plugin
 145                  PLG_commentDelete($type, COM_applyFilter ($cid, true), $sid);
 146                  break;
 147          }
 148          SPAMX_log($LANG_SX00['spamdeleted']);
 149      }
 150  }
 151  
 152  ?>


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