Plugin Directory

Changeset 646559


Ignore:
Timestamp:
01/01/2013 02:32:42 AM (13 years ago)
Author:
edwardw
Message:

0.1.2

Location:
wp-no-bot-question/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • wp-no-bot-question/trunk/readme.txt

    r556402 r646559  
    44Tags: anti-bot, anti-spam, comments, question, captcha, anti-bot question, anti-spam question, bots
    55Requires at least: 3.1
    6 Tested up to: 3.4
     6Tested up to: 3.6
    77Stable tag: trunk
    88
     
    1111== Description ==
    1212
    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 added to account for variances in answers. (e.g. "five", "Five", "5")
     13This 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")
    1414
    1515Plugin homepage: http://www.compdigitec.com/apps/wpnobot
     
    3838
    3939== 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
    4047
    4148= 0.1.1 =
  • wp-no-bot-question/trunk/wp_nobot_question-fr_FR.po

    r556402 r646559  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: WP No-Bot Question 0.1.1\n"
     5"Project-Id-Version: WP No-Bot Question 0.1.2\n"
    66"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"
    812"MIME-Version: 1.0\n"
    913"Content-Type: text/plain; charset=UTF-8\n"
    1014"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"
    1415
    15 #: wp_nobot_question.php:97
     16#: wp_nobot_question.php:113
    1617msgid "Required"
    1718msgstr "Obligatoire"
    1819
    19 #: wp_nobot_question.php:117
     20#: wp_nobot_question.php:135
    2021msgid "Error: Please fill in the required question."
    2122msgstr "Erreur: S'il vous plaît compléter le question obligatoire."
    2223
    23 #: wp_nobot_question.php:123
     24#: wp_nobot_question.php:145
    2425msgid "Error: Please fill in the correct answer to the question."
    2526msgstr "Erreur: S'il vous plaît remplir dans la réponse exacte à la question."
    2627
    27 #: wp_nobot_question.php:157
     28#: wp_nobot_question.php:175
     29msgid "Question to present to bot"
     30msgstr "Question de présenter au bot"
     31
     32#: wp_nobot_question.php:177
     33msgid "Type here to add a new question"
     34msgstr "Tapez ici pour ajouter une nouvelle question"
     35
     36#: wp_nobot_question.php:177
     37msgid "Delete Question"
     38msgstr "Supprimez Cette Question"
     39
     40#: wp_nobot_question.php:181
     41msgid "Possible Answers"
     42msgstr "Réponses Possibles"
     43
     44#: wp_nobot_question.php:188
     45#: wp_nobot_question.php:270
     46msgid "Delete"
     47msgstr "Supprimez"
     48
     49#: wp_nobot_question.php:194
     50msgid "Add New"
     51msgstr "Ajoutez"
     52
     53#: wp_nobot_question.php:222
    2854msgid "WP No-Bot Question settings updated."
    2955msgstr "WP No-Bot Question paramètres mis à jour."
    3056
    31 #: wp_nobot_question.php:172
     57#: wp_nobot_question.php:238
    3258msgid "Enable WP No-Bot Question"
    3359msgstr "Activer"
    3460
    35 #: wp_nobot_question.php:175
     61#: wp_nobot_question.php:241
    3662msgid "Yes"
    3763msgstr "Oui"
    3864
    39 #: wp_nobot_question.php:176
     65#: wp_nobot_question.php:242
    4066msgid "No"
    4167msgstr "Non"
    4268
    43 #: wp_nobot_question.php:181
     69#: wp_nobot_question.php:247
    4470msgid "Protect the registration page too?"
    4571msgstr "Protéger la page d'enregistrement aussi?"
    4672
    47 #: wp_nobot_question.php:189
    48 msgid "Question to present to bot"
    49 msgstr "Question de présenter au bot"
     73#: wp_nobot_question.php:256
     74msgid "Questions to present to bot"
     75msgstr "Question à présenter au bot"
    5076
    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
     78msgid "Enter a new answer here"
     79msgstr "Tapez une nouvelle reponse ici"
    6280
    6381#. Plugin Name of the plugin/theme
  • wp-no-bot-question/trunk/wp_nobot_question.php

    r556402 r646559  
    44Plugin URI: http://www.compdigitec.com/apps/wpnobot/
    55Description: Simple question that blocks most spambots (and paid robots) by making them answer a common sense question
    6 Version: 0.1.1
     6Version: 0.1.2
    77Author: Compdigitec
    88Author URI: http://www.compdigitec.com/
     
    1010Text Domain: wp_nobot_question
    1111*/
    12 define('wp_nobot_question_version','0.1.1');
     12define('wp_nobot_question_version','0.1.2');
    1313/*
    1414 *      Redistribution and use in source and binary forms, with or without
     
    3939 */
    4040
     41// Database version
     42define('wp_nobot_question_current_db_version',2);
     43
    4144register_activation_hook( __FILE__, 'wp_nobot_question_activate' );
    4245register_deactivation_hook( __FILE__, 'wp_nobot_question_deactivate' );
     
    5457
    5558function 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);
    5660    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')));
    5963    if(get_option('wp_nobot_question_registration') === false) add_option('wp_nobot_question_registration',false);
    6064}
     
    6569
    6670function wp_nobot_question_remove() {
     71    delete_option('wp_nobot_question_db_version');
    6772    delete_option('wp_nobot_question_enable');
    68     delete_option('wp_nobot_question_question');
     73    delete_option('wp_nobot_question_questions');
    6974    delete_option('wp_nobot_question_answers');
    7075    delete_option('wp_nobot_question_registration');
     
    7883function wp_nobot_question_admin_init() {
    7984    add_submenu_page( 'options-general.php', 'WP No-bot Question &rarr; 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    }
    8092}
    8193
     
    95107?>
    96108<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>
    98114    <input
    99115        id="wp_nobot_answer"
     
    103119        size="30"
    104120        <?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>
    106124<?php
    107125}
     
    117135        wp_die(__('Error: Please fill in the required question.','wp_nobot_question'));
    118136    }
    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        }
    122144    }
    123145    wp_die(__('Error: Please fill in the correct answer to the question.','wp_nobot_question'));
     
    129151            return (bool)get_option('wp_nobot_question_enable');
    130152        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;
    133157        break;
    134158        case 'answers':
     
    145169}
    146170
     171function 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(&quot;<?php echo $id ?>&quot;)"><?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;
     185foreach($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(&quot;$id&quot;, &quot;$i&quot;)\">" . __('Delete') . "</a>";
     189    echo "<br /></span>\n";
     190    $i++;
     191}
     192echo "<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
    147200function wp_nobot_question_admin() {
    148201    if(!current_user_can('moderate_comments')) return;
    149202    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        }
    150215        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);
    153218        if(array_key_exists( 'wp_nobot_question_registration', $_POST ))
    154219            update_option('wp_nobot_question_registration', true);
     
    157222        add_settings_error('wp_nobot_question', 'wp_nobot_question_updated', __('WP No-Bot Question settings updated.','wp_nobot_question'), 'updated');
    158223    }
     224
    159225    $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');
    161227    $wp_nobot_question_answers = wp_nobot_question_get_option('answers');
    162228    $wp_nobot_question_registration = wp_nobot_question_get_option('registration');
     
    186252    </td>
    187253    </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(&quot;$i&quot;)\">" . __('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>
    206259    <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(&quot;" + ct + "&quot;)\"><?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(&quot;" + id + "&quot;, &quot;" + ct[id] + "&quot;)\"><?php echo __('Delete'); ?></a><br /></span>");
     271        ct[id]++;
    214272        return false;
    215273    }
    216274    </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    ?>
    219283</table>
    220284
  • wp-no-bot-question/trunk/wp_nobot_question.pot

    r556402 r646559  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: WP No-Bot Question 0.1.1\n"
     5"Project-Id-Version: WP No-Bot Question 0.1.2\n"
    66"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"
    88"MIME-Version: 1.0\n"
    99"Content-Type: text/plain; charset=UTF-8\n"
     
    1313"Language-Team: LANGUAGE <LL@li.org>\n"
    1414
    15 #: wp_nobot_question.php:97
     15#: wp_nobot_question.php:113
    1616msgid "Required"
    1717msgstr ""
    1818
    19 #: wp_nobot_question.php:117
     19#: wp_nobot_question.php:135
    2020msgid "Error: Please fill in the required question."
    2121msgstr ""
    2222
    23 #: wp_nobot_question.php:123
     23#: wp_nobot_question.php:145
    2424msgid "Error: Please fill in the correct answer to the question."
    2525msgstr ""
    2626
    27 #: wp_nobot_question.php:157
     27#: wp_nobot_question.php:175
     28msgid "Question to present to bot"
     29msgstr ""
     30
     31#: wp_nobot_question.php:177
     32msgid "Type here to add a new question"
     33msgstr ""
     34
     35#: wp_nobot_question.php:177
     36msgid "Delete Question"
     37msgstr ""
     38
     39#: wp_nobot_question.php:181
     40msgid "Possible Answers"
     41msgstr ""
     42
     43#: wp_nobot_question.php:188 wp_nobot_question.php:270
     44msgid "Delete"
     45msgstr ""
     46
     47#: wp_nobot_question.php:194
     48msgid "Add New"
     49msgstr ""
     50
     51#: wp_nobot_question.php:222
    2852msgid "WP No-Bot Question settings updated."
    2953msgstr ""
    3054
    31 #: wp_nobot_question.php:172
     55#: wp_nobot_question.php:238
    3256msgid "Enable WP No-Bot Question"
    3357msgstr ""
    3458
    35 #: wp_nobot_question.php:175
     59#: wp_nobot_question.php:241
    3660msgid "Yes"
    3761msgstr ""
    3862
    39 #: wp_nobot_question.php:176
     63#: wp_nobot_question.php:242
    4064msgid "No"
    4165msgstr ""
    4266
    43 #: wp_nobot_question.php:181
     67#: wp_nobot_question.php:247
    4468msgid "Protect the registration page too?"
    4569msgstr ""
    4670
    47 #: wp_nobot_question.php:189
    48 msgid "Question to present to bot"
     71#: wp_nobot_question.php:256
     72msgid "Questions to present to bot"
    4973msgstr ""
    5074
    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
     76msgid "Enter a new answer here"
    6177msgstr ""
    6278
Note: See TracChangeset for help on using the changeset viewer.