Changeset 1335121
- Timestamp:
- 01/24/2016 08:36:38 PM (10 years ago)
- Location:
- question-antispam-for-comment-and-signup/trunk
- Files:
-
- 2 edited
-
question-antispam-for-comment-and-signup.php (modified) (12 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
question-antispam-for-comment-and-signup/trunk/question-antispam-for-comment-and-signup.php
r1334667 r1335121 6 6 Author: Dinar Qurbanov 7 7 Author URI: http://qdb.wp.kukmara-rayon.ru/ 8 Version: 0. 0.68 Version: 0.1.0 9 9 10 10 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 … … 67 67 } 68 68 */ 69 $options['moderation'] = 's pam';69 $options['moderation'] = 'stop'; 70 70 71 71 // logging 72 $options['logging'] = true; 72 // $options['logging'] = true; 73 // counting 74 $options['count'] = $options['count'] || 'off'; 73 75 74 76 //question and answer … … 105 107 $signups_ratio = wpmsqas_get_spam_ratio( $signups_ham, $signups_spam ); 106 108 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% of your comments are spam!').'</span></li>',$spam,$ham,$ratio); 108 110 109 111 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% of your signups are spam!').'</span></li>',$signups_spam,$signups_ham,$signups_ratio); 111 113 112 114 return $msg; … … 131 133 } 132 134 }*/ 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'); 134 136 } 135 137 … … 164 166 165 167 $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'])); 167 169 $options['question'] = strip_tags(stripslashes($_POST['wpmsqas-question'])); 168 170 $options['answer'] = strip_tags(stripslashes($_POST['wpmsqas-answer'])); 171 $options['count'] = strip_tags(stripslashes($_POST['wpmsqas-count'])); 169 172 wpmsqas_option($options); 170 173 } … … 223 226 // moderation options 224 227 $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> '; 226 229 echo '<select id="wpmsqas-moderation" name="wpmsqas-moderation">'; 227 230 //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>'; 230 233 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">'; 231 238 echo '</p>'; 232 239 //question and answer … … 289 296 290 297 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 } 293 302 $result['errors']->add( 'captcha_wrong', __('Incorrect answer to the antispam question.') ); 294 303 //echo '<p class="error">OK</p>'; 295 304 } 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 } 298 309 } 299 310 … … 350 361 351 362 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 } 354 367 355 368 switch($options['moderation']){ 356 case ' delete':369 case 'stop': 357 370 //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\');')); 358 371 header("Content-Type: text/html; charset=utf-8"); … … 360 373 break; 361 374 case 'spam': 362 add_filter('pre_comment_approved', create_function(' $a', 'return \'spam\';'));375 add_filter('pre_comment_approved', create_function('', 'return \'spam\';')); 363 376 break; 364 377 /*case 'moderate': … … 368 381 } 369 382 } 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 } 373 388 } 374 389 … … 379 394 380 395 add_action('preprocess_comment', 'wpmsqas_check_comment_antispam_answer'); 396 381 397 382 398 … … 407 423 mb_strtolower($options['answer']) 408 424 ); 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 } 412 430 $errors->add( 'wpmsqas_answer_error', __( 'Incorrect answer to the antispam question.' ) ); 413 431 } 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 } 416 436 } 417 437 -
question-antispam-for-comment-and-signup/trunk/readme.txt
r1334667 r1335121 5 5 Requires at least: 4.4.1 6 6 Tested up to: 4.4.1 7 Stable tag: 0. 0.67 Stable tag: 0.1.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 93 93 i have fixed position in comment form. 94 94 95 version 0.1.0 96 i have added translation possibility to some strings , which were fogotten; 97 i have added option to turn counting of spam requests on or off; 98 i have changed text of "delete" or "move to spam" option, made it more informative; 99 i have set "stop" ("delete") as default; 100 i have fixed 2 bugs of spam ratio widget. 95 101 96 102 … … 100 106 101 107 102 103
Note: See TracChangeset
for help on using the changeset viewer.