Changeset 646559
- Timestamp:
- 01/01/2013 02:32:42 AM (13 years ago)
- Location:
- wp-no-bot-question/trunk
- Files:
-
- 5 edited
-
readme.txt (modified) (3 diffs)
-
wp_nobot_question-fr_FR.mo (modified) (previous)
-
wp_nobot_question-fr_FR.po (modified) (1 diff)
-
wp_nobot_question.php (modified) (13 diffs)
-
wp_nobot_question.pot (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-no-bot-question/trunk/readme.txt
r556402 r646559 4 4 Tags: anti-bot, anti-spam, comments, question, captcha, anti-bot question, anti-spam question, bots 5 5 Requires at least: 3.1 6 Tested up to: 3. 46 Tested up to: 3.6 7 7 Stable tag: trunk 8 8 … … 11 11 == Description == 12 12 13 This plugin is just a very effective yet simple plugin which adds a question to the comment form that blocks most automated spam-bots by making them answer a common sense question. For optimal effectiveness, you might want to consider changing the question periodically so that the spambots can't "memorize" the question and answer. Multiple answers can be addedto account for variances in answers. (e.g. "five", "Five", "5")13 This plugin is just a very effective yet simple plugin which adds a question to the comment form that blocks most automated spam-bots by making them answer a common sense question. For optimal effectiveness, you should add multiple questions so that the spambots can't "memorize" the question and answer. The plugin will display questions at random to prevent the aformentioned memorization. Multiple answers can be added per question to account for variances in answers. (e.g. "five", "Five", "5") 14 14 15 15 Plugin homepage: http://www.compdigitec.com/apps/wpnobot … … 38 38 39 39 == Changelog == 40 = 0.1.2 = 41 * c911cc4 Update fr-FR translation 42 * e84f760 Bump the version to 0.1.2 43 * ce4d073 Implement addition/deletion of multiple questions 44 * 2823060 Support multiple questions in the database 45 * 01bcabd Factorize question template 46 * b07ce93 Don't store empty answers 40 47 41 48 = 0.1.1 = -
wp-no-bot-question/trunk/wp_nobot_question-fr_FR.po
r556402 r646559 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: WP No-Bot Question 0.1. 1\n"5 "Project-Id-Version: WP No-Bot Question 0.1.2\n" 6 6 "Report-Msgid-Bugs-To: http://wordpress.org/tag/wp_nobot_question\n" 7 "POT-Creation-Date: 2012-06-12 00:42:33+00:00\n" 7 "POT-Creation-Date: 2013-01-01 01:55:10+00:00\n" 8 "PO-Revision-Date: 2012-12-31 21:01-0500\n" 9 "Last-Translator: \n" 10 "Language-Team: French\n" 11 "Language: French\n" 8 12 "MIME-Version: 1.0\n" 9 13 "Content-Type: text/plain; charset=UTF-8\n" 10 14 "Content-Transfer-Encoding: 8bit\n" 11 "PO-Revision-Date: 2012-06-11 20:50-0500\n"12 "Last-Translator: \n"13 "Language-Team: LANGUAGE <LL@li.org>\n"14 15 15 #: wp_nobot_question.php: 9716 #: wp_nobot_question.php:113 16 17 msgid "Required" 17 18 msgstr "Obligatoire" 18 19 19 #: wp_nobot_question.php:1 1720 #: wp_nobot_question.php:135 20 21 msgid "Error: Please fill in the required question." 21 22 msgstr "Erreur: S'il vous plaît compléter le question obligatoire." 22 23 23 #: wp_nobot_question.php:1 2324 #: wp_nobot_question.php:145 24 25 msgid "Error: Please fill in the correct answer to the question." 25 26 msgstr "Erreur: S'il vous plaît remplir dans la réponse exacte à la question." 26 27 27 #: wp_nobot_question.php:157 28 #: wp_nobot_question.php:175 29 msgid "Question to present to bot" 30 msgstr "Question de présenter au bot" 31 32 #: wp_nobot_question.php:177 33 msgid "Type here to add a new question" 34 msgstr "Tapez ici pour ajouter une nouvelle question" 35 36 #: wp_nobot_question.php:177 37 msgid "Delete Question" 38 msgstr "Supprimez Cette Question" 39 40 #: wp_nobot_question.php:181 41 msgid "Possible Answers" 42 msgstr "Réponses Possibles" 43 44 #: wp_nobot_question.php:188 45 #: wp_nobot_question.php:270 46 msgid "Delete" 47 msgstr "Supprimez" 48 49 #: wp_nobot_question.php:194 50 msgid "Add New" 51 msgstr "Ajoutez" 52 53 #: wp_nobot_question.php:222 28 54 msgid "WP No-Bot Question settings updated." 29 55 msgstr "WP No-Bot Question paramètres mis à jour." 30 56 31 #: wp_nobot_question.php: 17257 #: wp_nobot_question.php:238 32 58 msgid "Enable WP No-Bot Question" 33 59 msgstr "Activer" 34 60 35 #: wp_nobot_question.php: 17561 #: wp_nobot_question.php:241 36 62 msgid "Yes" 37 63 msgstr "Oui" 38 64 39 #: wp_nobot_question.php: 17665 #: wp_nobot_question.php:242 40 66 msgid "No" 41 67 msgstr "Non" 42 68 43 #: wp_nobot_question.php: 18169 #: wp_nobot_question.php:247 44 70 msgid "Protect the registration page too?" 45 71 msgstr "Protéger la page d'enregistrement aussi?" 46 72 47 #: wp_nobot_question.php: 18948 msgid "Question to present to bot"49 msgstr "Question deprésenter au bot"73 #: wp_nobot_question.php:256 74 msgid "Questions to present to bot" 75 msgstr "Question à présenter au bot" 50 76 51 #: wp_nobot_question.php:195 52 msgid "Possible Answers" 53 msgstr "Réponses possibles" 54 55 #: wp_nobot_question.php:200 56 msgid "Delete" 57 msgstr "Supprimez" 58 59 #: wp_nobot_question.php:205 60 msgid "Add New" 61 msgstr "Ajoutez" 77 #: wp_nobot_question.php:270 78 msgid "Enter a new answer here" 79 msgstr "Tapez une nouvelle reponse ici" 62 80 63 81 #. Plugin Name of the plugin/theme -
wp-no-bot-question/trunk/wp_nobot_question.php
r556402 r646559 4 4 Plugin URI: http://www.compdigitec.com/apps/wpnobot/ 5 5 Description: Simple question that blocks most spambots (and paid robots) by making them answer a common sense question 6 Version: 0.1. 16 Version: 0.1.2 7 7 Author: Compdigitec 8 8 Author URI: http://www.compdigitec.com/ … … 10 10 Text Domain: wp_nobot_question 11 11 */ 12 define('wp_nobot_question_version','0.1. 1');12 define('wp_nobot_question_version','0.1.2'); 13 13 /* 14 14 * Redistribution and use in source and binary forms, with or without … … 39 39 */ 40 40 41 // Database version 42 define('wp_nobot_question_current_db_version',2); 43 41 44 register_activation_hook( __FILE__, 'wp_nobot_question_activate' ); 42 45 register_deactivation_hook( __FILE__, 'wp_nobot_question_deactivate' ); … … 54 57 55 58 function wp_nobot_question_activate() { 59 if(get_option('wp_nobot_question_db_version') === false) add_option('wp_nobot_question_db_version', wp_nobot_question_current_db_version); 56 60 if(get_option('wp_nobot_question_enable') === false) add_option('wp_nobot_question_enable',true); 57 if(get_option('wp_nobot_question_question ') === false) add_option('wp_nobot_question_question','What is the sum of 2 and 3?');58 if(get_option('wp_nobot_question_answers') === false) add_option('wp_nobot_question_answers',Array( 'five','Five','5'));61 if(get_option('wp_nobot_question_questions') === false) add_option('wp_nobot_question_questions',Array('What is the sum of 2 and 7?')); 62 if(get_option('wp_nobot_question_answers') === false) add_option('wp_nobot_question_answers',Array(Array('nine','Nine','9'))); 59 63 if(get_option('wp_nobot_question_registration') === false) add_option('wp_nobot_question_registration',false); 60 64 } … … 65 69 66 70 function wp_nobot_question_remove() { 71 delete_option('wp_nobot_question_db_version'); 67 72 delete_option('wp_nobot_question_enable'); 68 delete_option('wp_nobot_question_question ');73 delete_option('wp_nobot_question_questions'); 69 74 delete_option('wp_nobot_question_answers'); 70 75 delete_option('wp_nobot_question_registration'); … … 78 83 function wp_nobot_question_admin_init() { 79 84 add_submenu_page( 'options-general.php', 'WP No-bot Question → Edit Question', 'WP No-bot Question', 'moderate_comments', 'wp_nobot_question_page', 'wp_nobot_question_admin' ); 85 if(get_option('wp_nobot_question_question') !== false) { /* database version 1 */ 86 // we now support multiple questions 87 add_option('wp_nobot_question_questions',Array(strval(get_option('wp_nobot_question_question')))); 88 delete_option('wp_nobot_question_question'); 89 update_option('wp_nobot_question_answers',Array(get_option('wp_nobot_question_answers'))); 90 add_option('wp_nobot_question_db_version', wp_nobot_question_current_db_version); 91 } 80 92 } 81 93 … … 95 107 ?> 96 108 <p class="comment-form-wp_nobot_question"> 97 <label for="wp_nobot_answer"><?php echo wp_nobot_question_get_option('question'); ?> (<?php _e('Required','wp_nobot_question'); ?>)</label> 109 <?php 110 $questions = wp_nobot_question_get_option('questions'); 111 $selected_id = rand(0,count($questions)-1); 112 ?> 113 <label for="wp_nobot_answer"><?php echo htmlspecialchars($questions[$selected_id]); ?> (<?php _e('Required','wp_nobot_question'); ?>)</label> 98 114 <input 99 115 id="wp_nobot_answer" … … 103 119 size="30" 104 120 <?php if($context == 'registration') { ?> tabindex="25" <?php }; ?> 105 /></p> 121 /> 122 <input type="hidden" name="wp_nobot_answer_question" value="<?php echo $selected_id; ?>" /> 123 </p> 106 124 <?php 107 125 } … … 117 135 wp_die(__('Error: Please fill in the required question.','wp_nobot_question')); 118 136 } 119 $answers = get_option('wp_nobot_question_answers'); 120 foreach($answers as $answer) { 121 if(trim($_POST['wp_nobot_answer']) == $answer) return $x; 137 $question_id = intval($_POST['wp_nobot_answer_question']); 138 $answers_all = wp_nobot_question_get_option('answers'); 139 if($question_id < count($answers_all)) { 140 $answers = $answers_all[$question_id]; 141 foreach($answers as $answer) { 142 if(trim($_POST['wp_nobot_answer']) == $answer) return $x; 143 } 122 144 } 123 145 wp_die(__('Error: Please fill in the correct answer to the question.','wp_nobot_question')); … … 129 151 return (bool)get_option('wp_nobot_question_enable'); 130 152 break; 131 case 'question': 132 return strval(get_option('wp_nobot_question_question')); 153 case 'questions': 154 $tmp = get_option('wp_nobot_question_questions'); 155 if( $tmp === false ) return Array(); 156 else return $tmp; 133 157 break; 134 158 case 'answers': … … 145 169 } 146 170 171 function wp_nobot_question_template($id_,$question,$answers) { 172 $id = intval($id_); 173 ?> 174 <tr valign="top" class="wp_nobot_question_row_<?php echo $id; ?>"> 175 <th scope="row"><?php _e('Question to present to bot','wp_nobot_question'); ?></th> 176 <td> 177 <input type="input" name="wp_nobot_question_question_<?php echo $id; ?>" size="70" value="<?php echo $question; ?>" placeholder="<?php _e('Type here to add a new question','wp_nobot_question'); ?>" /><a href="javascript:void(0)" onclick="wp_nobot_question_delete_entire_question("<?php echo $id ?>")"><?php echo __('Delete Question'); ?></a> 178 </td> 179 </tr> 180 <tr valign="top" class="wp_nobot_question_row_<?php echo $id; ?>"> 181 <th scope="row"><?php _e('Possible Answers','wp_nobot_question'); ?></th> 182 <td> 183 <?php 184 $i = 0; 185 foreach($answers as $value) { 186 echo "<span id=\"wp_nobot_question_line_{$id}_$i\">"; 187 printf('<input type="input" id="wp_nobot_question_answer_%1$d_%2$d" name="wp_nobot_question_answers_%1$d[]" size="70" value="%3$s" />', $id, $i, $value); 188 echo "<a href=\"javascript:void(0)\" onclick=\"wp_nobot_question_delete("$id", "$i")\">" . __('Delete') . "</a>"; 189 echo "<br /></span>\n"; 190 $i++; 191 } 192 echo "<script id=\"wp_nobot_question_placeholder_$id\">ct[$id] = $i;</script>"; 193 ?> 194 <button onclick="return wp_nobot_question_add_newitem(<?php echo $id; ?>)"><?php _e('Add New','wp_nobot_question'); ?></button> 195 </td> 196 </tr> 197 <?php 198 } 199 147 200 function wp_nobot_question_admin() { 148 201 if(!current_user_can('moderate_comments')) return; 149 202 if(isset($_POST['submit'])) { 203 $questions = Array(); 204 $answers = Array(); 205 foreach($_POST as $key => $value) { 206 if(strpos($key, 'wp_nobot_question_question_') === 0) { 207 // value starts with wp_nobot_question_question_ 208 $q_id = str_replace('wp_nobot_question_question_','',$key); 209 if(trim(strval($value)) != '') { // if not empty 210 $questions[] = trim(strval($value)); 211 $answers[] = array_filter($_POST['wp_nobot_question_answers_' . $q_id]); 212 } 213 } 214 } 150 215 update_option('wp_nobot_question_enable',(bool)$_POST['wp_nobot_question_enabled']); 151 update_option('wp_nobot_question_question ',(string)$_POST['wp_nobot_question_question']);152 update_option('wp_nobot_question_answers', $_POST['wp_nobot_question_answers']);216 update_option('wp_nobot_question_questions', $questions); 217 update_option('wp_nobot_question_answers', $answers); 153 218 if(array_key_exists( 'wp_nobot_question_registration', $_POST )) 154 219 update_option('wp_nobot_question_registration', true); … … 157 222 add_settings_error('wp_nobot_question', 'wp_nobot_question_updated', __('WP No-Bot Question settings updated.','wp_nobot_question'), 'updated'); 158 223 } 224 159 225 $wp_nobot_question_enabled = wp_nobot_question_get_option('enable'); 160 $wp_nobot_question_question = wp_nobot_question_get_option('question');226 $wp_nobot_question_questions = wp_nobot_question_get_option('questions'); 161 227 $wp_nobot_question_answers = wp_nobot_question_get_option('answers'); 162 228 $wp_nobot_question_registration = wp_nobot_question_get_option('registration'); … … 186 252 </td> 187 253 </tr> 188 <tr valign="top"> 189 <th scope="row"><?php _e('Question to present to bot','wp_nobot_question'); ?></th> 190 <td> 191 <input type="input" name="wp_nobot_question_question" size="70" value="<?php echo $wp_nobot_question_question; ?>" /> 192 </td> 193 </tr> 194 <tr valign="top"> 195 <th scope="row"><?php _e('Possible Answers','wp_nobot_question'); ?></th> 196 <td> 197 <?php 198 $i = 0; 199 foreach($wp_nobot_question_answers as $value) { 200 echo "<span id=\"wp_nobot_question_line_$i\"><input type=\"input\" id=\"wp_nobot_question_answer_$i\" name=\"wp_nobot_question_answers[]\" size=\"70\" value=\"$value\" /><a href=\"javascript:void(0)\" onclick=\"wp_nobot_question_delete("$i")\">" . __('Delete') . "</a><br /></span>"; 201 $i++; 202 } 203 echo "<script id=\"wp_nobot_question_placeholder\">ct = $i;</script>"; 204 ?> 205 <button onclick="return wp_nobot_question_add_newitem()"><?php _e('Add New','wp_nobot_question'); ?></button> 254 <tr colspan="2"> 255 <td> 256 <b><?php _e('Questions to present to bot','wp_nobot_question'); ?></b> 257 </td> 258 </tr> 206 259 <script type="text/javascript"> 207 function wp_nobot_question_delete(x) { 208 jQuery("#wp_nobot_question_line_" + x).remove(); 209 } 210 211 function wp_nobot_question_add_newitem() { 212 jQuery("#wp_nobot_question_placeholder").before("<span id=\"wp_nobot_question_line_" + ct + "\"><input type=\"input\" id=\"wp_nobot_question_answer_" + ct + "\" name=\"wp_nobot_question_answers[]\" size=\"70\" value=\"\" placeholder=\"Enter a new answer here\" /><a href=\"javascript:void(0)\" onclick=\"wp_nobot_question_delete("" + ct + "")\"><?php echo __('Delete'); ?></a><br /></span>"); 213 ct++; 260 var ct = Array(); 261 function wp_nobot_question_delete(id, x) { 262 jQuery("#wp_nobot_question_line_" + id + "_" + x).remove(); 263 } 264 265 function wp_nobot_question_delete_entire_question(id) { 266 jQuery("tr.wp_nobot_question_row_" + id).remove(); 267 } 268 269 function wp_nobot_question_add_newitem(id) { 270 jQuery("#wp_nobot_question_placeholder_" + id).before("<span id=\"wp_nobot_question_line_" + id + "_" + ct[id] + "\"><input type=\"input\" id=\"wp_nobot_question_answer_" + id + "_" + ct + "\" name=\"wp_nobot_question_answers_" + id + "[]\" size=\"70\" value=\"\" placeholder=\"<?php _e('Enter a new answer here','wp_nobot_question'); ?>\" /><a href=\"javascript:void(0)\" onclick=\"wp_nobot_question_delete("" + id + "", "" + ct[id] + "")\"><?php echo __('Delete'); ?></a><br /></span>"); 271 ct[id]++; 214 272 return false; 215 273 } 216 274 </script> 217 </td> 218 </tr> 275 <?php 276 $i = 0; 277 foreach($wp_nobot_question_questions as $question) { 278 wp_nobot_question_template($i, $question, $wp_nobot_question_answers[$i]); 279 $i++; 280 } 281 wp_nobot_question_template($i, '', Array()); 282 ?> 219 283 </table> 220 284 -
wp-no-bot-question/trunk/wp_nobot_question.pot
r556402 r646559 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: WP No-Bot Question 0.1. 1\n"5 "Project-Id-Version: WP No-Bot Question 0.1.2\n" 6 6 "Report-Msgid-Bugs-To: http://wordpress.org/tag/wp_nobot_question\n" 7 "POT-Creation-Date: 201 2-06-12 00:42:33+00:00\n"7 "POT-Creation-Date: 2013-01-01 01:55:10+00:00\n" 8 8 "MIME-Version: 1.0\n" 9 9 "Content-Type: text/plain; charset=UTF-8\n" … … 13 13 "Language-Team: LANGUAGE <LL@li.org>\n" 14 14 15 #: wp_nobot_question.php: 9715 #: wp_nobot_question.php:113 16 16 msgid "Required" 17 17 msgstr "" 18 18 19 #: wp_nobot_question.php:1 1719 #: wp_nobot_question.php:135 20 20 msgid "Error: Please fill in the required question." 21 21 msgstr "" 22 22 23 #: wp_nobot_question.php:1 2323 #: wp_nobot_question.php:145 24 24 msgid "Error: Please fill in the correct answer to the question." 25 25 msgstr "" 26 26 27 #: wp_nobot_question.php:157 27 #: wp_nobot_question.php:175 28 msgid "Question to present to bot" 29 msgstr "" 30 31 #: wp_nobot_question.php:177 32 msgid "Type here to add a new question" 33 msgstr "" 34 35 #: wp_nobot_question.php:177 36 msgid "Delete Question" 37 msgstr "" 38 39 #: wp_nobot_question.php:181 40 msgid "Possible Answers" 41 msgstr "" 42 43 #: wp_nobot_question.php:188 wp_nobot_question.php:270 44 msgid "Delete" 45 msgstr "" 46 47 #: wp_nobot_question.php:194 48 msgid "Add New" 49 msgstr "" 50 51 #: wp_nobot_question.php:222 28 52 msgid "WP No-Bot Question settings updated." 29 53 msgstr "" 30 54 31 #: wp_nobot_question.php: 17255 #: wp_nobot_question.php:238 32 56 msgid "Enable WP No-Bot Question" 33 57 msgstr "" 34 58 35 #: wp_nobot_question.php: 17559 #: wp_nobot_question.php:241 36 60 msgid "Yes" 37 61 msgstr "" 38 62 39 #: wp_nobot_question.php: 17663 #: wp_nobot_question.php:242 40 64 msgid "No" 41 65 msgstr "" 42 66 43 #: wp_nobot_question.php: 18167 #: wp_nobot_question.php:247 44 68 msgid "Protect the registration page too?" 45 69 msgstr "" 46 70 47 #: wp_nobot_question.php: 18948 msgid "Question to present to bot"71 #: wp_nobot_question.php:256 72 msgid "Questions to present to bot" 49 73 msgstr "" 50 74 51 #: wp_nobot_question.php:195 52 msgid "Possible Answers" 53 msgstr "" 54 55 #: wp_nobot_question.php:200 56 msgid "Delete" 57 msgstr "" 58 59 #: wp_nobot_question.php:205 60 msgid "Add New" 75 #: wp_nobot_question.php:270 76 msgid "Enter a new answer here" 61 77 msgstr "" 62 78
Note: See TracChangeset
for help on using the changeset viewer.