OSDN Git Service

Spamfilter for editing
authorhenoheno <henoheno>
Sun, 17 Dec 2006 15:39:51 +0000 (00:39 +0900)
committerhenoheno <henoheno>
Sun, 17 Dec 2006 15:39:51 +0000 (00:39 +0900)
NOTE: Too low thresholds or too wide-and-rough BAN rules, may block you to modify your _existing_ contents

lib/pukiwiki.php
pukiwiki.ini.php

index 6e1492b..5307658 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // PukiWiki - Yet another WikiWikiWeb clone.
-// $Id: pukiwiki.php,v 1.13 2006/12/09 08:31:57 henoheno Exp $
+// $Id: pukiwiki.php,v 1.14 2006/12/17 15:39:51 henoheno Exp $
 //
 // PukiWiki 1.4.*
 //  Copyright (C) 2002-2006 by PukiWiki Developers Team
@@ -90,7 +90,7 @@ if (isset($vars['cmd'])) {
 // Spam filtering
 if ($spam && $method != 'GET') {
        // Adjustment
-       $_spam   = $spam;
+       $_spam   = ! empty($spam);
        $_plugin = strtolower($plugin);
        switch ($_plugin) {
                //case 'plugin-name':
@@ -101,14 +101,10 @@ if ($spam && $method != 'GET') {
                        $_spam = FALSE;
                   break;
                case 'edit':
-                       $_page = & $page;
                        if (isset($vars['add']) && $vars['add']) {
-                               $_spam   = TRUE;
                                $_plugin = 'add';
-                       } else {
-                               // TODO: Add some metrics (quantitiy, non_uniq, badhost etc)
-                               $_spam = FALSE;
                        }
+                       $_page = & $page;
                        break;
                case 'bugtrack': $_page = & $post['base'];  break;
                case 'tracker':  $_page = & $post['_base']; break;
@@ -122,7 +118,22 @@ if ($spam && $method != 'GET') {
 
        if ($_spam) {
                require(LIB_DIR . 'spam.php');
-               pkwk_spamfilter($method . ' to #' . $_plugin, $_page, $vars);
+
+               // Specific $method
+               if (isset($spam['method'][$_plugin])) {
+                       $_method = & $spam['method'][$_plugin];
+               } else if ($_plugin == 'edit' && isset($spam['method']['_edit'])) {
+                       $_method = & $spam['method']['_edit'];
+               } else if (isset($spam['method']['_default'])) {
+                       $_method = & $spam['method']['_default'];
+               } else {
+                       $_method = array(); // spam.php Default
+               }
+               if (! is_array($_method)) $_method = array();
+
+               $exitmode = isset($spam['exitmode']) ? $spam['exitmode'] : '';
+
+               pkwk_spamfilter($method . ' to #' . $_plugin, $_page, $vars, $_method, $exitmode);
        }
 }
 
index e0b5229..dfb5896 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // PukiWiki - Yet another WikiWikiWeb clone
-// $Id: pukiwiki.ini.php,v 1.144 2006/12/07 14:47:15 henoheno Exp $
+// $Id: pukiwiki.ini.php,v 1.145 2006/12/17 15:39:23 henoheno Exp $
 // Copyright (C)
 //   2002-2006 PukiWiki Developers Team
 //   2001-2002 Originally written by yu-ji
@@ -160,6 +160,37 @@ define('PKWK_ALLOW_JAVASCRIPT', 0);
 
 $spam = 1;     // 1 = On
 
+if ($spam) {
+       $spam = array();
+
+       // Threshold and rules for insertion (default)
+       $spam['method']['_default'] = array(
+               '_comment'    => '_default',
+               'quantity'    => 8,
+               'non_uniq'    => 3,
+               'area_anchor' => 0,
+               'area_bbcode' => 0,
+               'uniqhost'    => TRUE,
+               'badhost'     => TRUE,
+               //'asap'        => TRUE,
+       );
+
+       // For editing (default)
+       $spam['method']['_edit'] = array(
+               // Supposed(n) * Edit_form_spec(2) * Margin(2)
+               '_comment'    => '_edit',
+               'quantity'    => 60 * 4,
+               'non_uniq'    =>  5 * 4,
+               'area_anchor' => 30 * 4,
+               'area_bbcode' => 15 * 4,
+               'uniqhost'    => TRUE,
+               'badhost'     => TRUE,
+               //'asap'        => TRUE,
+       );
+
+       //$spam['exitmode'] = 'dump'; // Dump progress
+}
+
 /////////////////////////////////////////////////
 // TrackBack feature