[pLog-svn] r4968 - in plugins/branches/lifetype-1.2: . hiddeninput hiddeninput/class/security hiddeninput/locale hiddeninput/templates unported

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Sat Mar 3 19:52:05 EST 2007


Author: jondaley
Date: 2007-03-03 19:52:05 -0500 (Sat, 03 Mar 2007)
New Revision: 4968

Added:
   plugins/branches/lifetype-1.2/hiddeninput/
Removed:
   plugins/branches/lifetype-1.2/unported/hiddeninput/
Modified:
   plugins/branches/lifetype-1.2/hiddeninput/class/security/hiddeninputfilter.class.php
   plugins/branches/lifetype-1.2/hiddeninput/locale/locale_en_UK.php
   plugins/branches/lifetype-1.2/hiddeninput/pluginhiddeninput.class.php
   plugins/branches/lifetype-1.2/hiddeninput/readme.txt
   plugins/branches/lifetype-1.2/hiddeninput/templates/hiddeninput.template
Log:
ported to 1.2.  Note change of field input now is required to be empty.  I have used this mechanism on other sites for a year or two, and have never had a spam get through

Copied: plugins/branches/lifetype-1.2/hiddeninput (from rev 4966, plugins/branches/lifetype-1.2/unported/hiddeninput)

Modified: plugins/branches/lifetype-1.2/hiddeninput/class/security/hiddeninputfilter.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/hiddeninput/class/security/hiddeninputfilter.class.php	2007-03-04 00:21:50 UTC (rev 4966)
+++ plugins/branches/lifetype-1.2/hiddeninput/class/security/hiddeninputfilter.class.php	2007-03-04 00:52:05 UTC (rev 4968)
@@ -41,8 +41,7 @@
             // we only have to filter the contents if the user is posting a comment
             // so there's no point in doing anything else if that's not the case
             if( $request->getValue( "op" ) != "AddComment" ) {
-            	$result = new PipelineResult();
-                return $result;
+            	return new PipelineResult();
             }
 
             // if this is already rejected, there is no reason to do anything here
@@ -54,7 +53,7 @@
             
             foreach( $hiddenFieldsList as $hiddenField ) {
             	$commentHiddenField = $request->getValue( trim($hiddenField) );
-            	if( empty($commentHiddenField) ) {
+            	if(!empty($commentHiddenField)) {
                 	// if there is a match, we can quit and reject this request
                     $result = new PipelineResult( false, HIDDEN_INPUT_MATCH_FOUND, $locale->tr("error_hiddeninput_field_missing"));
                     return $result;

Modified: plugins/branches/lifetype-1.2/hiddeninput/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/hiddeninput/locale/locale_en_UK.php	2007-03-04 00:21:50 UTC (rev 4966)
+++ plugins/branches/lifetype-1.2/hiddeninput/locale/locale_en_UK.php	2007-03-04 00:52:05 UTC (rev 4968)
@@ -2,13 +2,13 @@
 $messages["manageAntiSpamPlugins"] = "Anti Spam Management";
 $messages["ArticleReferers"] = "Hidden Input";
 
-$messages["hiddeninput_hiddenfields"] = 'Hidden fields for comment form, use "," to seperate different field name';
+$messages["hiddeninput_hiddenfields"] = 'Hidden fields for comment form, use "," to separate each field name';
 $messages["hiddeninput_plugin_enabled"] = "Enable this plugin";
 $messages["hiddeninput_plugin"] = "Hidden Input Plugin";
 
 $messages["hiddeninput_settings_saved_ok"] = "Hidden Input settings saved successfully!";
-$messages["hiddeninput_error_hiddenfields"] = "Fields name can not be empty, at least one field!";
-$messages["error_hiddeninput_field_missing"] = "You can not leave comment here, becasue lack of hidden fields.";
+$messages["hiddeninput_error_hiddenfields"] = "Field names cannot be empty, you must enter at least one field!";
+$messages["error_hiddeninput_field_missing"] = "You can not leave a comment here due to the spam trap.";
 
 $messages["label_configuration"] = "Configuration";
 $messages["label_enable"] = "Enable";

Modified: plugins/branches/lifetype-1.2/hiddeninput/pluginhiddeninput.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/hiddeninput/pluginhiddeninput.class.php	2007-03-04 00:21:50 UTC (rev 4966)
+++ plugins/branches/lifetype-1.2/hiddeninput/pluginhiddeninput.class.php	2007-03-04 00:52:05 UTC (rev 4968)
@@ -1,8 +1,6 @@
 <?php
 
     lt_include( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
-    lt_include( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
-	lt_include( PLOG_CLASS_PATH."plugins/hiddeninput/class/security/hiddeninputfilter.class.php" );
     
     /**
      * Plugin that offers hidden fields to comment form to prevent spammer post from spam robot
@@ -13,33 +11,42 @@
         var $pluginEnabled;
         var $hiddenFields;
            
-        function PluginHiddenInput()
+        function PluginHiddenInput($source = "")
         {
-            $this->PluginBase();
+            $this->PluginBase($source);
   
             $this->id = "hiddeninput";
             $this->author = "Mark Wu";
             $this->desc = "This plugin offers hidden fields to comment form to prevent spammer post from spam robot.";
-  
+            $this->version = "20070303";
+            
             $this->prefix = Db::getPrefix();
             
             $this->locales = Array( "en_UK" , "zh_TW" );
             
-            $this->init();            
+			if( $source == "admin" )
+				$this->initAdmin();
+			else
+				$this->init();
         }
 
 		function init()
 		{
-			// register the filter
+            lt_include( PLOG_CLASS_PATH."plugins/hiddeninput/class/security/hiddeninputfilter.class.php" );
 			$this->registerFilter( "HiddenInputFilter" );
+		}
 
+		function initAdmin()
+		{
+            lt_include( PLOG_CLASS_PATH."class/template/menu/menu.class.php" );
+
             $this->registerAdminAction( "hiddeninput", "PluginHiddenInputConfigAction" );
 			$this->registerAdminAction( "updateHiddenInputConfig", "PluginHiddenInputUpdateConfigAction" );
 			
 			$menu =& Menu::getMenu();
-			if( !$menu->entryExists( "/menu/controlCenter/manageAntiSpamPlugins" ))						
-				$this->addMenuEntry( "/menu/controlCenter", "manageAntiSpamPlugins", "", "", true, false );			
-            $this->addMenuEntry( "/menu/controlCenter/manageAntiSpamPlugins", "HiddenInput", "?op=hiddeninput", "" );            
+			if( !$menu->entryExists( "/menu/controlCenter/manageAntiSpamPlugins" ))
+				$this->addMenuEntry( "/menu/controlCenter", "manageAntiSpamPlugins", "", "", true, false );
+            $this->addMenuEntry( "/menu/controlCenter/manageAntiSpamPlugins", "HiddenInput", "?op=hiddeninput", "" );
 		}
 
 		function register()
@@ -56,13 +63,27 @@
 	    
 	    function getHiddenFields()
 	    {
-		    $hiddenFieldsList = explode(",", $this->hiddenFields);            
-            
             $commentHiddenFields = Array();
-            foreach( $hiddenFieldsList as $hiddenField ) {
-            	array_push($commentHiddenFields, trim($hiddenField));
+
+            if($this->isEnabled()){
+                $hiddenFieldsList = explode(",", $this->hiddenFields);
+                
+                foreach( $hiddenFieldsList as $hiddenField ) {
+                    array_push($commentHiddenFields, trim($hiddenField));
+                }
             }
             return $commentHiddenFields;
         }
+
+        function getPluginConfigurationKeys(){
+			lt_include(PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php");
+            return (Array(
+                        Array("name" => "plugin_hiddeninput_enabled",
+                              "type" => "boolean"),
+                        Array("name" => "plugin_hiddeninput_hiddenfields",
+                              "validator" => new StringValidator(),
+                              "type" => "integer"),
+                        ));
+        }
     }
 ?>
\ No newline at end of file

Modified: plugins/branches/lifetype-1.2/hiddeninput/readme.txt
===================================================================
--- plugins/branches/lifetype-1.2/unported/hiddeninput/readme.txt	2007-03-04 00:21:50 UTC (rev 4966)
+++ plugins/branches/lifetype-1.2/hiddeninput/readme.txt	2007-03-04 00:52:05 UTC (rev 4968)
@@ -1,20 +1,23 @@
 Plugin: Hidden Input
 Author: Mark Wu
 Release Date: 2005/03/13
-Version: 1.0
+Version: 1.2
 
 This plugin offers you add hidden fields to your comment form to prevent comment spam robot. Usage as followed:
 
 You can use:
-1. $hiddeninput->isEnabled() to check the plugin is enabled or not. 
-2. $hiddeninput->getHiddenFields() to get the hidden fields. 
+1. $hiddeninput->getHiddenFields() to get the hidden fields. 
 
 Example:
 Add the following code to commentform.template inside <form> ... </form>:
-{if !empty($hiddeninput)}
-{if $hiddeninput->isEnabled()}
-{foreach from=$hiddeninput->getHiddenFields() item=hiddenField}
-<input type="hidden" name="{$hiddenField}" value="GetOut!" />
-{/foreach}
+{if $hiddeninput}
+  {foreach from=$hiddeninput->getHiddenFields() item=hiddenField}
+    <input type="hidden" name="{$hiddenField}" value="" />
+  {/foreach}
 {/if}
-{/if}
\ No newline at end of file
+
+
+Note: for 1.2, you must set the value to "" rather than GetOut or
+whatever you might have used in previous versions.  This should work
+even better against spammers.
+

Modified: plugins/branches/lifetype-1.2/hiddeninput/templates/hiddeninput.template
===================================================================
--- plugins/branches/lifetype-1.2/unported/hiddeninput/templates/hiddeninput.template	2007-03-04 00:21:50 UTC (rev 4966)
+++ plugins/branches/lifetype-1.2/hiddeninput/templates/hiddeninput.template	2007-03-04 00:52:05 UTC (rev 4968)
@@ -9,7 +9,14 @@
    <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
    <span class="required"></span>
    <div class="formHelp">
-    <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1" />{$locale->tr("hiddeninput_plugin_enabled")}
+    <input class="checkbox" type="checkbox" name="pluginEnabled" 
+           id="pluginEnabled" {if $pluginEnabled} checked="checked"
+           {/if} 
+           {user_cannot_override
+              key=plugin_hiddeninput_enabled}disabled="disabled"
+           {/user_cannot_override}
+           value="1" />
+        {$locale->tr("hiddeninput_plugin_enabled")}
    </div>
   </div>
   
@@ -17,9 +24,14 @@
    <label for="hiddenFields">{$locale->tr("label_hiddenfields")}</label>
    <span class="required">*</span>
    <div class="formHelp">{$locale->tr("hiddeninput_hiddenfields")}</div>
-   <input class="text" type="text" name="hiddenFields" id="hiddenFields" value="{$hiddenFields}" width="10" />
+   <input class="text" type="text" name="hiddenFields"
+          id="hiddenFields" value="{$hiddenFields}" 
+          {user_cannot_override
+             key=plugin_hiddeninput_hiddenfields}disabled="disabled"
+          {/user_cannot_override}
+          width="10" />
   </div>
-  
+
  </fieldset>
 
  <div class="buttons"> 
@@ -29,4 +41,4 @@
  </div>
 </form>
 {include file="$admintemplatepath/footernavigation.template"}
-{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
+{include file="$admintemplatepath/footer.template"}



More information about the pLog-svn mailing list