Plugin Directory

Changeset 1335121


Ignore:
Timestamp:
01/24/2016 08:36:38 PM (10 years ago)
Author:
qdinar
Message:

make posssible to turn off counting, bugfixes

Location:
question-antispam-for-comment-and-signup/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • question-antispam-for-comment-and-signup/trunk/question-antispam-for-comment-and-signup.php

    r1334667 r1335121  
    66 Author: Dinar Qurbanov
    77 Author URI: http://qdb.wp.kukmara-rayon.ru/
    8  Version: 0.0.6
     8 Version: 0.1.0
    99
    1010 I have used WordPress Hashcash code, also I have looked at buhsl-Captcha, Cookies for Comments, Peter's Custom Anti-Spam codes, to learn and use their codes, and also copied something from them
     
    6767    }
    6868    */
    69     $options['moderation'] = 'spam';
     69    $options['moderation'] = 'stop';
    7070   
    7171    // logging
    72     $options['logging'] = true;
     72    // $options['logging'] = true;
     73    // counting
     74    $options['count'] = $options['count'] || 'off';
    7375
    7476    //question and answer
     
    105107    $signups_ratio = wpmsqas_get_spam_ratio( $signups_ham, $signups_spam );
    106108
    107     $msg = '<li><span>'.sprintf(__('%1$d spam comments are blocked out, %2$d comments are allowed.  %3$d% of your comments are spam!').'</span></li>',$spam,$ham,$ratio);
     109    $msg = '<li><span>'.sprintf(__('%1$d spam comments are blocked out, %2$d comments are allowed.  %3$d&#x25; of your comments are spam!').'</span></li>',$spam,$ham,$ratio);
    108110
    109111    if( $signups_ham && $signups_spam )
    110         $msg = '<li><span>'.sprintf(__('%1$d spam signups are blocked out, %2$d signups are allowed.  %3$d% of your signups are spam!').'</span></li>',$signups_spam,$signups_ham,$signups_ratio);
     112        $msg .= '<li><span>'.sprintf(__('%1$d spam signups are blocked out, %2$d signups are allowed.  %3$d&#x25; of your signups are spam!').'</span></li>',$signups_spam,$signups_ham,$signups_ratio);
    111113
    112114    return $msg;
     
    131133        }
    132134    }*/
    133     add_options_page('Question Antispam', 'Question Antispam', 'manage_options', 'wpmsqas_config', 'wpmsqas_admin_options');
     135    add_options_page(_x('Question Antispam','page title'), _x('Question Antispam','menu title'), 'manage_options', 'wpmsqas_config', 'wpmsqas_admin_options');
    134136}
    135137
     
    164166
    165167        $options['moderation'] = strip_tags(stripslashes($_POST['wpmsqas-moderation']));
    166         $options['logging'] = strip_tags(stripslashes($_POST['wpmsqas-logging']));
     168        // $options['logging'] = strip_tags(stripslashes($_POST['wpmsqas-logging']));
    167169        $options['question'] = strip_tags(stripslashes($_POST['wpmsqas-question']));
    168170        $options['answer'] = strip_tags(stripslashes($_POST['wpmsqas-answer']));
     171        $options['count'] = strip_tags(stripslashes($_POST['wpmsqas-count']));
    169172        wpmsqas_option($options);
    170173    }
     
    223226    // moderation options
    224227    $moderate = htmlspecialchars($options['moderation'], ENT_QUOTES);
    225     echo '<p><label for="wpmsqas-moderation">' . _x('What to do with spam:', 'question antispam admin page') . '</label>';
     228    echo '<p><label for="wpmsqas-moderation">' . _x('What to do on wrong answer:', 'question antispam admin page') . '</label> ';
    226229    echo '<select id="wpmsqas-moderation" name="wpmsqas-moderation">';
    227230    //echo '<option value="moderate"'.($moderate=='moderate'?' selected':'').'>Moderate</option>';
    228     echo '<option value="spam"'.($moderate=='spam'?' selected':'').'>'.__('Move to spam').'</option>';
    229     echo '<option value="delete"'.($moderate=='delete'?' selected':'').'>'.__('Delete').'</option>';
     231    echo '<option value="spam"'.($moderate=='spam'?' selected':'').'>'.__('Save to spam without any message').'</option>';
     232    echo '<option value="stop"'.($moderate=='stop'?' selected':'').'>'.__('Stop and propose to go back').'</option>';
    230233    echo '</select>';
     234    echo '</p>';
     235    // count or not
     236    echo '<p><label for="wpmsqas-count">' . __('Count spam and good requests') . '</label> ';
     237    echo '<input name="wpmsqas-count" type="checkbox" '.($options['count']=='on'?'checked':'').' value="on">';
    231238    echo '</p>';
    232239    //question and answer
     
    289296   
    290297    if($spam){
    291         $options['signups-spam'] = ((int) $options['signups-spam']) + 1;
    292         wpmsqas_option($options);
     298        if($options['count']=='on'){
     299            $options['signups-spam'] = ((int) $options['signups-spam']) + 1;
     300            wpmsqas_option($options);
     301        }
    293302        $result['errors']->add( 'captcha_wrong', __('Incorrect answer to the antispam question.') );
    294303    //echo '<p class="error">OK</p>';
    295304    } else {
    296         $options['signups-ham'] = ((int) $options['signups-ham']) + 1;
    297         wpmsqas_option($options);
     305        if($options['count']=='on'){
     306            $options['signups-ham'] = ((int) $options['signups-ham']) + 1;
     307            wpmsqas_option($options);
     308        }
    298309    }
    299310   
     
    350361
    351362    if($spam){ 
    352         $options['comments-spam'] = ((int) $options['comments-spam']) + 1;
    353         wpmsqas_option($options);
     363        if($options['count']=='on'){
     364            $options['comments-spam'] = ((int) $options['comments-spam']) + 1;
     365            wpmsqas_option($options);
     366        }
    354367           
    355368        switch($options['moderation']){
    356             case 'delete':
     369            case 'stop':
    357370                //add_filter('comment_post', create_function('$id', 'wp_delete_comment($id); die(\'Антиспам сорауга җавап дөрес түгел. Кире кайтыгыз.<br>Ответ на антиспамный вопрос неправилен. Вернитесь на предыдущую страницу<br>Your answer to antispam question is not correct. Go back to the previous page\');'));
    358371                header("Content-Type: text/html; charset=utf-8");
     
    360373                break;
    361374            case 'spam':
    362                 add_filter('pre_comment_approved', create_function('$a', 'return \'spam\';'));
     375                add_filter('pre_comment_approved', create_function('', 'return \'spam\';'));
    363376                break;
    364377            /*case 'moderate':
     
    368381        }
    369382    } else {
    370         add_filter('pre_comment_approved', create_function('$a', 'return 1;'));
    371         $options['comments-ham'] = ((int) $options['comments-ham']) + 1;
    372         wpmsqas_option($options);
     383        add_filter('pre_comment_approved', create_function('', 'return 1;'));
     384        if($options['count']=='on'){
     385            $options['comments-ham'] = ((int) $options['comments-ham']) + 1;
     386            wpmsqas_option($options);
     387        }
    373388    }
    374389   
     
    379394
    380395add_action('preprocess_comment', 'wpmsqas_check_comment_antispam_answer');
     396
    381397
    382398
     
    407423            mb_strtolower($options['answer'])
    408424        ); 
    409     if($spam){ 
    410         $options['signups-spam'] = ((int) $options['signups-spam']) + 1;
    411         wpmsqas_option($options);           
     425    if($spam){
     426        if($options['count']=='on'){
     427            $options['signups-spam'] = ((int) $options['signups-spam']) + 1;
     428            wpmsqas_option($options);
     429        }
    412430        $errors->add( 'wpmsqas_answer_error', __( 'Incorrect answer to the antispam question.' ) );
    413431    } else {
    414         $options['signups-ham'] = ((int) $options['signups-ham']) + 1;
    415         wpmsqas_option($options);
     432        if($options['count']=='on'){
     433            $options['signups-ham'] = ((int) $options['signups-ham']) + 1;
     434            wpmsqas_option($options);
     435        }
    416436    }
    417437
  • question-antispam-for-comment-and-signup/trunk/readme.txt

    r1334667 r1335121  
    55Requires at least: 4.4.1
    66Tested up to: 4.4.1
    7 Stable tag: 0.0.6
     7Stable tag: 0.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    9393i have fixed position in comment form.
    9494
     95version 0.1.0
     96i have added translation possibility to some strings , which were fogotten;
     97i have added option to turn counting of spam requests on or off;
     98i have changed text of "delete" or "move to spam" option, made it more informative;
     99i have set "stop" ("delete") as default;
     100i have fixed 2 bugs of spam ratio widget.
    95101
    96102
     
    100106
    101107
    102 
    103 
Note: See TracChangeset for help on using the changeset viewer.