[ Index ]
 

Code source de Dotclear 2.0-beta6

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

title

Body

[fermer]

/plugins/antispam/ -> index.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  if (!defined('DC_CONTEXT_ADMIN')) { exit; }
  24  dcPage::check('admin');
  25  
  26  dcAntispam::initFilters('co');
  27  $filters = dcAntispam::$filters->getFilters();
  28  
  29  $page_name = __('Antispam');
  30  $filter_gui = false;
  31  $default_tab = null;
  32  
  33  try
  34  {
  35      # Show filter configuration GUI
  36      if (!empty($_GET['f']))
  37      {
  38          if (!isset($filters[$_GET['f']])) {
  39              throw new Exception(__('Filter does not exists.'));
  40          }
  41          
  42          if (!$filters[$_GET['f']]->hasGUI()) {
  43              throw new Exception(__('Filter has no user interface.'));
  44          }
  45          
  46          $filter = $filters[$_GET['f']];
  47          $filter_gui = $filter->gui($filter->guiURL());
  48      }
  49      
  50      # Remove all spam
  51      if (!empty($_POST['delete_all']))
  52      {
  53          dcAntispam::delAllSpam($core);
  54          http::redirect($p_url.'&del=1');
  55      }
  56      
  57      # Update filters
  58      if (isset($_POST['filters_upd']))
  59      {
  60          $filters_opt = array();
  61          $i = 0;
  62          foreach ($filters as $fid => $f) {
  63              $filters_opt[$fid] = array(false,$i);
  64              $i++;
  65          }
  66          
  67          # Enable active filters
  68          if (isset($_POST['filters_active']) && is_array($_POST['filters_active'])) {
  69              foreach ($_POST['filters_active'] as $v) {
  70                  $filters_opt[$v][0] = true;
  71              }
  72          }
  73          
  74          # Order filters
  75          if (!empty($_POST['f_order']) && empty($_POST['filters_order']))
  76          {
  77              $order = $_POST['f_order'];
  78              asort($order);
  79              $order = array_keys($order);
  80          }
  81          elseif (!empty($_POST['filters_order']))
  82          {
  83              $order = explode(',',trim($_POST['filters_order'],','));
  84          }
  85          
  86          if (isset($order)) {
  87              foreach ($order as $i => $f) {
  88                  $filters_opt[$f][1] = $i;
  89              }
  90          }
  91          
  92          dcAntispam::$filters->saveFilterOpts($filters_opt);
  93          http::redirect($p_url.'&upd=1');
  94      }
  95  }
  96  catch (Exception $e)
  97  {
  98      $core->error->add($e->getMessage());
  99  }
 100  ?>
 101  <html>
 102  <head>
 103    <title><?php echo $page_name; ?></title>
 104    <?php
 105    echo
 106    dcPage::jsToolMan().
 107    dcPage::jsPageTabs($default_tab).
 108    dcPage::jsLoad('index.php?pf=antispam/antispam.js');
 109    ?>
 110    <link rel="stylesheet" type="text/css" href="index.php?pf=antispam/style.css" />
 111  </head>
 112  <body>
 113  <?php
 114  echo '<h2>'.html::escapeHTML($core->blog->name).' &gt; '.$page_name.'</h2>';
 115  
 116  if ($filter_gui !== false)
 117  {
 118      echo '<p><a href="'.$p_url.'">'.__('Return to filters').'</a></p>';
 119      printf('<h3>'.__('%s configuration').'</h3>',$filter->name);
 120      
 121      echo $filter_gui;
 122  }
 123  else
 124  {
 125      # Information
 126      $spam_count = dcAntispam::countSpam($core);
 127      $published_count = dcAntispam::countPublishedComments($core);
 128      
 129      echo
 130      '<form action="'.$p_url.'" method="post">'.
 131      '<fieldset><legend>'.__('Information').'</legend>';
 132      
 133      if (!empty($_GET['del'])) {
 134          echo '<p class="message">'.__('Spam comments have been successfully deleted.').'</p>';
 135      }
 136      
 137      echo
 138      '<ul class="spaminfo">'.
 139      '<li class="spamcount"><a href="comments.php?status=-2">'.__('Junk comments:').'</a> '.
 140      '<strong>'.$spam_count.'</strong></li>'.
 141      '<li class="hamcount"><a href="comments.php?status=1">'.__('Published comments:').'</a> '.
 142      $published_count.'</li>'.
 143      '</ul>';
 144      
 145      if ($spam_count > 0)
 146      {
 147          echo '<p><input name="delete_all" type="submit" value="'.__('Delete all spams').'" /></p>';
 148      }
 149      echo '</fieldset></form>';
 150      
 151      
 152      # Filters
 153      echo
 154      '<form action="'.$p_url.'" method="post">'.
 155      '<fieldset><legend>'.__('Available spam filters').'</legend>';
 156      
 157      if (!empty($_GET['upd'])) {
 158          echo '<p class="message">'.__('Filters configuration has been successfully saved.').'</p>';
 159      }
 160      
 161      echo
 162      '<table class="dragable">'.
 163      '<thead><tr>'.
 164      '<th>'.__('Order').'</th>'.
 165      '<th>'.__('Active').'</th>'.
 166      '<th class="nowrap">'.__('Filter name').'</th>'.
 167      '<th colspan="2">'.__('Description').'</th>'.
 168      '</tr></thead>'.
 169      '<tbody id="filters-list" >';
 170      
 171      $i = 0;
 172      foreach ($filters as $fid => $f)
 173      {
 174          $gui_link = '&nbsp;';
 175          if ($f->hasGUI()) {
 176              $gui_link =
 177              '<a href="'.html::escapeHTML($f->guiURL()).'">'.
 178              '<img src="images/edit-mini.png" alt="'.__('Filter configuration').'" '.
 179              'title="'.__('Filter configuration').'" /></a>';
 180          }
 181          
 182          echo
 183          '<tr class="line'.($f->active ? '' : ' offline').'" id="f_'.$fid.'">'.
 184          '<td class="handle">'.form::field(array('f_order['.$fid.']'),2,5,(string) $i).'</td>'.
 185          '<td class="nowrap">'.form::checkbox(array('filters_active[]'),$fid,$f->active).'</td>'.
 186          '<td class="nowrap">'.$f->name.'</td>'.
 187          '<td class="maximal">'.$f->description.'</td>'.
 188          '<td class="status">'.$gui_link.'</td>'.
 189          '</tr>';
 190          $i++;
 191      }
 192      echo
 193      '</tbody></table>'.
 194      '<p>'.form::hidden('filters_order','').'<input type="submit" name="filters_upd" value="'.__('Save').'" /></p>'.
 195      '</fieldset></form>';
 196      
 197      
 198      # Syndication
 199      if (DC_ADMIN_URL)
 200      {
 201          $ham_feed = $core->blog->url.$core->url->getBase('hamfeed').'/'.$code = dcAntispam::getUserCode($core); 
 202          $spam_feed = $core->blog->url.$core->url->getBase('spamfeed').'/'.$code = dcAntispam::getUserCode($core);
 203          
 204          echo
 205          '<fieldset><legend>'.__('Syndication').'</legend>'.
 206          '<ul class="spaminfo">'.
 207          '<li class="feed"><a href="'.$spam_feed.'">'.__('Junk comments RSS feed').'</a></li>'.
 208          '<li class="feed"><a href="'.$ham_feed.'">'.__('Published comments RSS feed').'</a></li>'.
 209          '</ul>'.
 210          '</fieldset>';
 211      }
 212  }
 213  ?>
 214  
 215  </body>
 216  </html>


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