This repository has been archived by the owner on Sep 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbbpress-antispam.php
793 lines (670 loc) · 41.2 KB
/
bbpress-antispam.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
<?php
/**
* Plugin Name: bbPress Antispam
* Plugin URI: http://danielhuesken.de/portfolio/bbpress-antispam
* Description: Antispam for bbPress 2.x
* Author: Daniel Hüsken
* Version: 1.1
* Author URI: http://danielhuesken.de
* Text Domain: bbpress-antispam
* Domain Path: /lang/
* License: GPLv3
*/
/**
* Copyright 2011-2012 Daniel Hüsken (email: [email protected])
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
if ( ! class_exists( 'bbPress_Antispam' ) ) {
//Start Plugin after bbPress
if ( function_exists( 'add_filter' ) ) {
if ( defined( 'BBPRESS_LATE_LOAD' ) )
add_action( 'plugins_loaded', array( 'bbPress_Antispam', 'get_object' ), (int) BBPRESS_LATE_LOAD + 1 );
else
add_action( 'plugins_loaded', array( 'bbPress_Antispam', 'get_object' ), 11 );
}
final class bbPress_Antispam {
private $key = '890abcdef123';
private $today = '0000-00-00';
private $plugin_base_name = 'bbpress-antispam';
private $spamcount = 0;
private $spamchart = array();
private $spamtypes = array( 'csshack', 'dnsbl', 'fakeip', 'referrer', 'ipspam', 'contentspam', 'authorspam' );
public function __construct() {
if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) or ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) or ( defined( 'DOING_CRON' ) && DOING_CRON ) )
return;
//do not load if bbPress not installed
if ( ! class_exists( 'bbPress' ) )
return;
//set vars correctly
$this->key = substr( md5( md5( AUTH_KEY ) ), 7, 8 );
$this->today = date_i18n( 'Y-m-d' );
$this->plugin_base_name = untrailingslashit( dirname( plugin_basename( __FILE__ ) ) );
$this->spamcount = get_option( 'bbpress_antispam_spamcount', $this->spamcount );
$this->spamchart = get_option( 'bbpress_antispam_spamchart', $this->spamchart );
//call spam chart
$this->spam_chart();
//load text domain
load_plugin_textdomain( 'bbpress-antispam', FALSE, $this->plugin_base_name . '/lang' );
//add filter and actions
//css hack before bbPress 2.1 and without existing editor
if ( version_compare( bbp_get_version(), '2.1.0', '<' ) ) {
if ( get_option( 'bbpress_antispam_cfg_checkcsshack', 'block' ) != 'off')
add_action('bbp_head', array( $this, 'ob_start_bbp_head' ), 100);
}
//css hack for bbPress 2.1 and above
else {
if ( get_option( 'bbpress_antispam_cfg_checkcsshack', 'block' ) != 'off' )
if ( ! function_exists( 'wp_editor' ) )
add_action('bbp_head', array( $this, 'ob_start_bbp_head' ), 100);
else
add_filter( 'bbp_get_the_content',array( $this, 'get_the_content' ), 1, 3);
}
add_action( 'admin_head-settings_page_bbpress', array( $this, 'add_help_tab' ) );
add_filter( 'bbp_new_topic_pre_content', array( $this, 'post_pre_content' ), 1 );
add_filter( 'bbp_new_reply_pre_content', array( $this, 'post_pre_content' ), 1 );
add_filter( 'bbp_new_topic_pre_insert', array( $this, 'post_pre_insert' ), 1 );
add_filter( 'bbp_new_reply_pre_insert', array( $this, 'post_pre_insert' ), 1 );
if ( get_option( 'bbpress_antispam_cfg_sendmail', 'off' ) != 'off' ) {
add_action( 'bbp_new_topic', array( $this, 'send_mail_topic' ), 100, 1 );
add_action( 'bbp_new_reply', array( $this, 'send_mail_reply' ), 100, 2 );
}
add_action( 'bbp_dashboard_widget_right_now_content_table_end', array( $this, 'add_blocked_on_table_end' ) );
if ( get_option( 'bbpress_antispam_cfg_schowdashboardchart', TRUE ) )
add_action( 'wp_dashboard_setup', array( $this, 'init_dashboard_chart' ) );
add_action( 'bbp_register_admin_settings', array( $this, 'register_admin_settings' ), 11 );
add_filter( 'plugin_row_meta', array( $this, 'plugin_links' ), 10, 2 );
}
/**
* @static
* @return \bbPress_Antispam
*/
public static function get_object() {
return new self;
}
public function ob_start_bbp_head() {
if ( get_option('bbpress_antispam_cfg_disableloggedinuser', FALSE) && is_user_logged_in() )
return;
if ( bbp_is_reply_edit() || bbp_is_topic_edit() )
return;
ob_start(array( $this, 'ob_callback_bbp_content' ));
}
public function ob_callback_bbp_content( $buffer ) {
$buffer = preg_replace("#<textarea(.*?)name=([\"\'])bbp_topic_content([\"\'])(.+?)</textarea>#i", "<textarea id=\"bbp_topic_content_css\" name=\"bbp_topic_content\" style=\"display:none;width:1px;height:1px;\" rows=\"6\" cols=\"2\"></textarea><textarea$1name=$2bbp_topic_content-" . $this->key . "$3$4</textarea>", $buffer, 1);
$buffer = preg_replace("#<textarea(.*?)name=([\"\'])bbp_reply_content([\"\'])(.+?)</textarea>#i", "<textarea id=\"bbp_reply_content_css\" name=\"bbp_reply_content\" style=\"display:none;width:1px;height:1px;\" rows=\"6\"></textarea><textarea$1name=$2bbp_reply_content-" . $this->key . "$3$4</textarea>", $buffer, 1);
return $buffer;
}
public function get_the_content( $output, $args, $post_content ) {
if ( bbp_is_reply_edit() || bbp_is_topic_edit() )
return $output;
if ( get_option('bbpress_antispam_cfg_disableloggedinuser', FALSE) && is_user_logged_in() )
return $output;
if ( $args[ 'context' ] != 'topic' && $args[ 'context' ] != 'reply' )
return $output;
$new_output = '<textarea id="bbp_' . esc_attr( $args[ 'context' ] ) . '_content_css" class="bbp-the-content" name="bbp_' . esc_attr( $args[ 'context' ] ) . '_content" cols="60" rows="12" style="display:none;width:1px;height:1px;"></textarea>';
$new_output .= str_replace( array( 'name="bbp_' . esc_attr( $args[ 'context' ] ) . '_content"' ), array( 'name="bbp_' . esc_attr( $args[ 'context' ] ) . '_content-' . $this->key .'"' ), $output );
return $new_output;
}
public function post_pre_content( $content ) {
if ( get_option( 'bbpress_antispam_cfg_disableloggedinuser', FALSE ) && is_user_logged_in() )
return $content;
if ( get_option('bbpress_antispam_cfg_checkcsshack', 'block') == 'block' ) {
if ( !empty($content) ) {
bbp_add_error('bbp_reply_content', __('<strong>bbPress ANTISPAM</strong>: CSS Hack!', 'bbpress-antispam'));
$this->count_spam('csshack');
return $content;
}
//get real content
if ( current_filter() == 'bbp_new_topic_pre_content' ) {
$contentname = 'bbp_topic_content-' . $this->key;
if ( !empty($_POST[$contentname]) )
$content = $_POST[$contentname];
}
if ( current_filter() == 'bbp_new_reply_pre_content' ) {
$contentname = 'bbp_reply_content-' . $this->key;
if ( !empty($_POST[$contentname]) )
$content = $_POST[$contentname];
}
}
//Filter spam
$dnsbl = $this->is_dnsbl_spam();
if ( get_option( 'bbpress_antispam_cfg_checkdnsbl', 'block' ) == 'block' && $dnsbl ) {
bbp_add_error( 'bbp_topic_content', sprintf( __( '<strong>bbPress ANTISPAM</strong>: DNSBL (%s)!', 'bbpress-antispam' ), $dnsbl ) );
$this->count_spam( 'dnsbl' );
return $content;
}
if ( get_option( 'bbpress_antispam_cfg_checkfakeip', 'off' ) == 'block' && $this->is_fake_ip() ) {
bbp_add_error( 'bbp_topic_content', __( '<strong>bbPress ANTISPAM</strong>: Fake IP!', 'bbpress-antispam' ) );
$this->count_spam( 'fakeip' );
return $content;
}
if ( get_option( 'bbpress_antispam_cfg_checkreferrer', 'spam' ) == 'block' && $this->is_false_referrer() ) {
bbp_add_error( 'bbp_reply_content', __( '<strong>bbPress ANTISPAM</strong>: Referrer!', 'bbpress-antispam' ) );
$this->count_spam( 'referrer' );
return $content;
}
if ( get_option( 'bbpress_antispam_cfg_checkipspam', 'block' ) == 'block' && $this->is_ip_spam() ) {
bbp_add_error( 'bbp_reply_content', __( '<strong>bbPress ANTISPAM</strong>: Spam IP!', 'bbpress-antispam' ) );
$this->count_spam( 'ipspam' );
return $content;
}
if ( get_option( 'bbpress_antispam_cfg_checkcontentspam', 'block' ) == 'block' && $this->is_content_spam( $content ) ) {
bbp_add_error( 'bbp_reply_content', __( '<strong>bbPress ANTISPAM</strong>: Spam content!', 'bbpress-antispam' ) );
$this->count_spam( 'contentspam' );
return $content;
}
return $content;
}
public function post_pre_insert( $post_data ) {
if ( get_option( 'bbpress_antispam_cfg_disableloggedinuser', FALSE ) && is_user_logged_in() )
return $post_data;
$dnsbl = $this->is_dnsbl_spam();
if ( get_option( 'bbpress_antispam_cfg_checkdnsbl', 'block' ) == 'spam' && $dnsbl ) {
if ( get_option( 'bbpress_antispam_cfg_prependspamtitle', TRUE ) )
$post_data[ 'post_content' ] = sprintf( __( 'bbPress ANTISPAM: DNSBL (%s):', 'bbpress-antispam' ), $dnsbl ) . " " . $post_data[ 'post_content' ];
$post_data[ 'post_status' ] = bbp_get_spam_status_id();
$this->count_spam( 'dnsbl' );
return $post_data;
}
if ( get_option( 'bbpress_antispam_cfg_checkfakeip', 'off' ) == 'spam' && $this->is_fake_ip() ) {
if ( get_option( 'bbpress_antispam_cfg_prependspamtitle', TRUE ) )
$post_data[ 'post_content' ] = __( 'bbPress ANTISPAM: Fake IP:', 'bbpress-antispam' ) . " " . $post_data[ 'post_content' ];
$post_data[ 'post_status' ] = bbp_get_spam_status_id();
$this->count_spam( 'fakeip' );
return $post_data;
}
if ( get_option( 'bbpress_antispam_cfg_checkreferrer', 'spam' ) == 'spam' && $this->is_false_referrer() ) {
if ( get_option( 'bbpress_antispam_cfg_prependspamtitle', TRUE ) )
$post_data[ 'post_content' ] = __( 'bbPress ANTISPAM: Referrer:', 'bbpress-antispam' ) . " " . $post_data[ 'post_content' ];
$post_data[ 'post_status' ] = bbp_get_spam_status_id();
$this->count_spam( 'referrer' );
return $post_data;
}
if ( get_option( 'bbpress_antispam_cfg_checkipspam', 'block' ) == 'spam' && $this->is_ip_spam() ) {
if ( get_option( 'bbpress_antispam_cfg_prependspamtitle', TRUE ) )
$post_data[ 'post_content' ] = __( 'bbPress ANTISPAM: Spam IP:', 'bbpress-antispam' ) . " " . $post_data[ 'post_content' ];
$post_data[ 'post_status' ] = bbp_get_spam_status_id();
$this->count_spam( 'ipspam' );
return $post_data;
}
if ( get_option( 'bbpress_antispam_cfg_checkcontentspam', 'block' ) == 'spam' && $this->is_content_spam( $post_data[ 'post_content' ] ) ) {
if ( get_option( 'bbpress_antispam_cfg_prependspamtitle', TRUE ) )
$post_data[ 'post_content' ] = __( 'bbPress ANTISPAM: Spam content:', 'bbpress-antispam' ) . " " . $post_data[ 'post_content' ];
$post_data[ 'post_status' ] = bbp_get_spam_status_id();
$this->count_spam( 'contentspam' );
return $post_data;
}
if ( get_option( 'bbpress_antispam_cfg_checkauthorspam', 'spam' ) == 'spam' && $this->is_author_spam( $post_data[ 'post_author' ] ) ) {
if ( get_option( 'bbpress_antispam_cfg_prependspamtitle', TRUE ) )
$post_data[ 'post_content' ] = __( 'bbPress ANTISPAM: Spam author:', 'bbpress-antispam' ) . " " . $post_data[ 'post_content' ];
$post_data[ 'post_status' ] = bbp_get_spam_status_id();
$this->count_spam( 'authorspam' );
return $post_data;
}
return $post_data;
}
private function count_spam( $type ) {
$type = strtolower( $type );
if ( in_array( $type, $this->spamtypes ) )
$this->spamchart[ $this->today ][ $type ] ++;
$this->spamcount ++;
update_option( 'bbpress_antispam_spamchart', $this->spamchart );
update_option( 'bbpress_antispam_spamcount', $this->spamcount );
}
public function send_mail_reply( $reply_id, $topic_id ) {
if ( ( get_option( 'bbpress_antispam_cfg_sendmail', 'off' ) == 'spam' && bbp_get_reply_status( $reply_id ) != bbp_get_spam_status_id() ) )
return;
$author_mail = bbp_get_reply_author_email( $reply_id );
$author_name = bbp_get_reply_author_display_name( $reply_id );
if ( $author_mail == get_option( 'bbpress_antispam_cfg_sendmailto', get_bloginfo( 'admin_email' ) ) )
return;
if ( bbp_get_reply_status( $reply_id ) == bbp_get_spam_status_id() ) {
$subject = sprintf( __( '[%1$s] SPAM reply to: "%2$s"', 'bbpress-antispam' ), html_entity_decode( get_option( 'blogname' ), ENT_QUOTES, get_option( 'blog_charset' ) ), html_entity_decode( bbp_get_topic_title( $topic_id ), ENT_QUOTES, get_option( 'blog_charset' ) ) );
$notify_message = sprintf( __( 'New "marked as SPAM" reply to "%s"', 'bbpress-antispam' ), html_entity_decode( bbp_get_topic_title( $topic_id ), ENT_QUOTES, get_option( 'blog_charset' ) ) ) . "\r\n";
}
else {
$subject = sprintf( __( '[%1$s] Reply to: "%2$s"', 'bbpress-antispam' ), html_entity_decode( get_option( 'blogname' ), ENT_QUOTES, get_option( 'blog_charset' ) ), html_entity_decode( bbp_get_topic_title( $topic_id ), ENT_QUOTES, get_option( 'blog_charset' ) ) );
$notify_message = sprintf( __( 'New reply to "%s"', 'bbpress-antispam' ), html_entity_decode( bbp_get_topic_title( $topic_id ), ENT_QUOTES ), get_option( 'blog_charset' ) ) . "\r\n";
}
$notify_message .= sprintf( __( 'Author : %1$s (IP: %2$s , %3$s)', 'bbpress-antispam' ), $author_name, bbp_current_author_ip(), @gethostbyaddr( bbp_current_author_ip() ) ) . "\r\n";
$notify_message .= sprintf( __( 'E-mail : %s', 'bbpress-antispam' ), $author_mail ) . "\r\n";
$notify_message .= sprintf( __( 'URL : %s', 'bbpress-antispam' ), bbp_reply_author_url( $reply_id ) ) . "\r\n";
$notify_message .= sprintf( __( 'Whois : http://whois.arin.net/rest/ip/%s', 'bbpress-antispam' ), bbp_current_author_ip() ) . "\r\n";
$notify_message .= __( 'Reply text: ', 'bbpress-antispam' ) . "\r\n" . strip_tags( html_entity_decode( bbp_get_reply_content( $reply_id ), ENT_QUOTES, get_option( 'blog_charset' ) ) ) . "\r\n\r\n";
$notify_message .= sprintf( __( 'Permalink: %s', 'bbpress-antispam' ), bbp_get_reply_url( $reply_id ) ) . "\r\n";
$wp_email = 'bbPress@' . preg_replace( '#^www\.#', '', strtolower( $_SERVER[ 'SERVER_NAME' ] ) );
if ( '' == $author_name ) {
$from = "From: \"" . html_entity_decode( get_option( 'blogname' ), ENT_QUOTES, get_option( 'blog_charset' ) ) . "\" <$wp_email>";
if ( '' != $author_mail )
$reply_to = "Reply-To: $author_mail";
}
else {
$from = "From: \"$author_name\" <$wp_email>";
if ( '' != $author_mail )
$reply_to = "Reply-To: $author_mail";
}
$message_headers = "$from\n" . "Content-Type: text/plain; charset=\"" . get_option( 'blog_charset' ) . "\"\n";
if ( isset( $reply_to ) )
$message_headers .= $reply_to . "\n";
@wp_mail( get_option( 'bbpress_antispam_cfg_sendmailto', get_bloginfo( 'admin_email' ) ), $subject, $notify_message, $message_headers );
}
public function send_mail_topic( $topic_id ) {
if ( ( get_option( 'bbpress_antispam_cfg_sendmail', 'off' ) == 'spam' && bbp_get_topic_status( $topic_id ) != bbp_get_spam_status_id() ) )
return;
$author_mail = bbp_get_topic_author_email( $topic_id );
$author_name = bbp_get_topic_author_display_name( $topic_id );
if ( $author_mail == get_option( 'bbpress_antispam_cfg_sendmailto', get_bloginfo( 'admin_email' ) ) )
return;
if ( bbp_get_reply_status( $topic_id ) == bbp_get_spam_status_id() ) {
$subject = sprintf( __( '[%1$s] SPAM topic: "%2$s"', 'bbpress-antispam' ), html_entity_decode( get_option( 'blogname' ), ENT_QUOTES, get_option( 'blog_charset' ) ), html_entity_decode( bbp_get_topic_title( $topic_id ), ENT_QUOTES, get_option( 'blog_charset' ) ) );
$notify_message = sprintf( __( 'New "marked as SPAM" topic "%s"', 'bbpress-antispam' ), html_entity_decode( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES, get_option( 'blog_charset' ) ) . "\r\n";
}
else {
$subject = sprintf( __( '[%1$s] Topic: "%2$s"', 'bbpress-antispam' ), html_entity_decode( get_option( 'blogname' ), ENT_QUOTES, get_option( 'blog_charset' ) ), html_entity_decode( bbp_get_topic_title( $topic_id ), ENT_QUOTES, get_option( 'blog_charset' ) ) );
$notify_message = sprintf( __( 'New topic "%s"', 'bbpress-antispam' ), html_entity_decode( bbp_get_topic_title( $topic_id ), ENT_QUOTES, get_option( 'blog_charset' ) ) ) . "\r\n";
}
$notify_message .= sprintf( __( 'Author : %1$s (IP: %2$s , %3$s)', 'bbpress-antispam' ), $author_name, bbp_current_author_ip(), @gethostbyaddr( bbp_current_author_ip() ) ) . "\r\n";
$notify_message .= sprintf( __( 'E-mail : %s', 'bbpress-antispam' ), $author_mail ) . "\r\n";
$notify_message .= sprintf( __( 'URL : %s', 'bbpress-antispam' ), bbp_topic_author_url( $topic_id ) ) . "\r\n";
$notify_message .= sprintf( __( 'Whois : http://whois.arin.net/rest/ip/%s', 'bbpress-antispam' ), bbp_current_author_ip() ) . "\r\n";
$notify_message .= __( 'Topic text: ', 'bbpress-antispam' ) . "\r\n" . strip_tags( html_entity_decode( bbp_get_topic_content( $topic_id ), ENT_QUOTES, get_option( 'blog_charset' ) ) ) . "\r\n\r\n";
$notify_message .= sprintf( __( 'Permalink: %s', 'bbpress-antispam' ), bbp_get_topic_permalink( $topic_id ) ) . "\r\n";
$wp_email = 'bbPress@' . preg_replace( '#^www\.#', '', strtolower( $_SERVER[ 'SERVER_NAME' ] ) );
if ( '' == $author_name ) {
$from = "From: \"" . html_entity_decode( get_option( 'blogname' ), ENT_QUOTES, get_option( 'blog_charset' ) ) . "\" <$wp_email>";
if ( '' != $author_mail )
$reply_to = "Reply-To: $author_mail";
}
else {
$from = "From: \"$author_name\" <$wp_email>";
if ( '' != $author_mail )
$reply_to = "Reply-To: $author_mail";
}
$message_headers = "$from\n" . "Content-Type: text/plain; charset=\"" . get_option( 'blog_charset' ) . "\"\n";
if ( isset( $reply_to ) )
$message_headers .= $reply_to . "\n";
@wp_mail( get_option( 'bbpress_antispam_cfg_sendmailto', get_bloginfo( 'admin_email' ) ), $subject, $notify_message, $message_headers );
}
private function is_dnsbl_spam() {
if ( ! function_exists( 'dns_get_record' ) )
return FALSE;
$ip = bbp_current_author_ip();
if ( strstr( $ip, ':') ) {
//ipv6 (DNSxLs rfc5782)
$hex = unpack( "H*hex" , inet_pton( $ip ) );
$ip = substr( preg_replace( "/([A-f0-9]{4})/", "$1:", $hex[ 'hex' ] ), 0, -1);
$oktets = array_reverse( explode( ':', $ip ) );
foreach ($oktets as $key => $oktet) {
$oktets[ $key ] = implode( '.', array_reverse( str_split( $oktet ) ) );
}
$reverse_ip = implode( '.', $oktets);
} else {
//ipv4
$reverse_ip = implode( '.', array_reverse( explode( '.', $ip ) ) );
}
if ( $text = dns_get_record( $reverse_ip . '.opm.tornevall.org.', DNS_TXT ) )
return '[' . $text[0]['txt'] . ']';
if ( $text = dns_get_record( $reverse_ip . '.ix.dnsbl.manitu.net.', DNS_TXT ) )
return '[' . $text[0]['txt'] . ']';
if ( $text = dns_get_record( $reverse_ip . '.sbl.spamhaus.org.', DNS_TXT ) )
return '[' . $text[0]['txt'] . ']';
if ( $text = dns_get_record( $reverse_ip . '.xbl.spamhaus.org.', DNS_TXT ) )
return '[' . $text[0]['txt'] . ']';
return FALSE;
}
private function is_fake_ip() {
$ip = bbp_current_author_ip();
if ( $ip == '127.0.0.1' || $ip == '::1:' )
return FALSE;
$hostbyip = gethostbyaddr( $ip );
if ( strstr( $ip, ':') ) //ipv6
return $ip != $hostbyip;
if ( $hostbyip == $ip ) //check the host is get
return FALSE;
$hostbyname = gethostbyname( $hostbyip );
if ( $hostbyname == $hostbyip ) //check the host ip is get
return FALSE;
if ( $ip == $hostbyname )
return FALSE;
else
return TRUE;
}
private function is_false_referrer() {
$url = strtolower( home_url() );
$referer = strtolower( wp_get_referer() );
if ( ! strstr($referer, $url) ) {
return TRUE;
}
return FALSE;
}
private function is_ip_spam() {
global $wpdb;
$ip = bbp_current_author_ip();
if ( empty( $ip ) )
return TRUE;
$found = $wpdb->get_var( $wpdb->prepare( "SELECT `comment_ID` FROM `$wpdb->comments` WHERE `comment_approved` = 'spam' AND `comment_author_IP` = %s LIMIT 1", $ip ) );
if ( $found )
return TRUE;
$found = $wpdb->get_var( $wpdb->prepare( "SELECT p.ID FROM $wpdb->posts p LEFT JOIN $wpdb->postmeta m ON p.ID = m.post_id WHERE p.post_status = 'spam' AND (p.post_type ='reply' OR p.post_type ='topic') AND m.meta_key = '_bbp_author_ip' AND m.meta_value = %s LIMIT 1", $ip ) );
if ( $found )
return TRUE;
return FALSE;
}
private function is_content_spam( $content ) {
global $wpdb;
$found = $wpdb->get_var( $wpdb->prepare( "SELECT `ID` FROM `$wpdb->posts` WHERE `post_status` = 'spam' AND (`post_type` ='reply' OR `post_type` ='topic') AND `post_content` = %s LIMIT 1", $content ) );
if ( $found )
return TRUE;
$found = $wpdb->get_var( $wpdb->prepare( "SELECT `comment_ID` FROM `$wpdb->comments` WHERE `comment_approved` = 'spam' AND `comment_content` = %s LIMIT 1", $content ) );
if ( $found )
return TRUE;
return FALSE;
}
private function is_author_spam( $author ) {
global $wpdb;
$userdata = get_userdata( $author );
$anonymous_data = bbp_filter_anonymous_post_data();
if ( ! empty( $anonymous_data ) ) {
$user_data[ 'name' ] = $anonymous_data[ 'bbp_anonymous_name' ];
}
elseif ( ! empty( $userdata ) ) {
$user_data[ 'name' ] = $userdata->display_name;
}
else {
return TRUE;
}
$found = $wpdb->get_var( $wpdb->prepare( "SELECT `comment_ID` FROM `$wpdb->comments` WHERE `comment_approved` = 'spam' AND `comment_author` = %s LIMIT 1", $user_data[ 'name' ] ) );
if ( $found )
return TRUE;
$found = $wpdb->get_var( $wpdb->prepare( "SELECT p.ID FROM $wpdb->posts p LEFT JOIN $wpdb->postmeta m ON p.ID = m.post_id WHERE p.post_status = 'spam' AND (p.post_type ='reply' OR p.post_type ='topic') AND m.meta_key = '_bbp_anonymous_name' AND m.meta_value = %s LIMIT 1", $user_data[ 'name' ] ) );
if ( $found )
return TRUE;
return FALSE;
}
public function add_blocked_on_table_end() {
echo sprintf( '<tr><td class="b b-spam" style="font-size:18px">%s</td><td class="last t b-spam">%s</td></tr>', esc_html( $this->spamcount ), esc_html__( 'Blocked', 'bbpress-antispam' ) );
}
public function init_dashboard_chart() {
if ( ! current_user_can( 'administrator' ) )
return FALSE;
wp_add_dashboard_widget( 'bbpress_antispam', 'bbPress Antispam', array( $this, 'dashboard_show_spam_chart' ) );
add_action( 'admin_head-index.php', array( $this, 'add_dashboard_head' ) );
}
public function add_dashboard_head() {
?>
<style type="text/css" media="screen">
/*<![CDATA[*/
#bbpress_antispam_chart {
height: 175px;
}
/*]]>*/
</style>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChartbbPressAntispam);
function drawChartbbPressAntispam() {
var data = new google.visualization.DataTable();
data.addColumn('string', '<?PHP _e( 'Date', 'bbpress-antispam' ); ?>');
data.addColumn('number', '<?PHP _e( 'Summary', 'bbpress-antispam' ); ?>');
data.addColumn('number', '<?PHP _e( 'CSS Hack', 'bbpress-antispam' ); ?>');
data.addColumn('number', '<?PHP _e( 'DNSBL', 'bbpress-antispam' ); ?>');
data.addColumn('number', '<?PHP _e( 'Fake IP', 'bbpress-antispam' ); ?>');
data.addColumn('number', '<?PHP _e( 'Referrer', 'bbpress-antispam' ); ?>');
data.addColumn('number', '<?PHP _e( 'Spam IP', 'bbpress-antispam' ); ?>');
data.addColumn('number', '<?PHP _e( 'Spam content', 'bbpress-antispam' ); ?>');
data.addColumn('number', '<?PHP _e( 'Spam author', 'bbpress-antispam' ); ?>');
data.addRows([<?php
$data = '';
foreach ( $this->spamchart as $day => $dayvalue ) {
$count = 0;
if ( ! is_array( $dayvalue ) )
continue;
foreach ( $dayvalue as $key => $value )
$count = $count + $value;
$data .= "['" . $day . "'," . $count;
foreach ( $this->spamtypes as $type ) {
$data .= "," . $dayvalue[ $type ];
}
$data .= "],";
}
echo substr( $data, 0, - 1 );
?>]);
var chart = new google.visualization.AreaChart(document.getElementById('bbpress_antispam_chart'));
chart.draw(data, {width:parseInt(jQuery("#bbpress_antispam_chart").parent().width(), 10), height:175,
legend:'none', pointSize:4, lineWidth:2, gridlineColor:'#ececec', focusTarget:'category', fontSize:9,
colors:['black', 'red', 'blue', 'green', 'yellow', 'Brown', 'Aquamarine', 'DarkViolet'], chartArea:{width:'100%', height:'100%'},
backgroundColor:'transparent', vAxis:{baselineColor:'transparent', textPosition:'in'}});
}
</script>
<?php
}
public function dashboard_show_spam_chart() {
echo '<div id="bbpress_antispam_chart"></div>';
}
public function plugin_links( $links, $file ) {
if ( ! current_user_can( 'install_plugins' ) )
return $links;
if ( $file == $this->plugin_base_name . '/bbpress-antispam.php' ) {
$links[ ] = __( '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CS7BVQ6TTCRYU" target="_blank">Donate</a>', 'bbpress-antispam' );
$links[ ] = __( '<a href="https://flattr.com/donation/give/to/danielhuesken" target="_blank">Flattr</a>', 'bbpress-antispam' );
}
return $links;
}
public function add_help_tab() {
if ( method_exists( get_current_screen(), 'add_help_tab' ) ) {
get_current_screen()->add_help_tab( array(
'id' => 'antispam',
'title' => __( 'Antispam', 'bbpress-antispam' ),
'content' =>
'<p><a href="http://danielhuesken.de/portfolio/bbpress-antispam" target="_blank">bbPress Antispam</a>, <a href="http://www.gnu.org/licenses/gpl-3.0" target="_blank">GPLv3</a> © 2011-' . date( 'Y' ) . ' <a href="http://danielhuesken.de" target="_blank">Daniel Hüsken</a></p><p>' . __( 'bbPress Antispam comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.', 'bbpress-antispam' ) . '</p>' .
'<p><strong>' . __( 'For more information:', 'bbpress-antispam' ) . '</strong></p><p>' .
' ' . __( '<a href="http://wordpress.org/extend/plugins/bbpress-antispam/" target="_blank">Wordpress Plugin Site</a>', 'bbpress-antispam' ) . ' |' .
' ' . __( '<a href="http://danielhuesken.de/portfolio/bbpress-antispam/" target="_blank">Plugin Site</a>', 'bbpress-antispam' ) . ' |' .
' ' . __( '<a href="http://wordpress.org/extend/plugins/bbpress-antispam/faq/" target="_blank">FAQ</a>', 'bbpress-antispam' ) . ' |' .
' ' . __( '<a href="http://wordpress.org/tags/bbpress-antispam/" target="_blank">Support Forums</a>', 'bbpress-antispam' ) . ' |' .
' ' . __( '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CS7BVQ6TTCRYU" target="_blank">Donate</a>', 'bbpress-antispam' ) . ' |' .
' ' . __( '<a href="https://flattr.com/donation/give/to/danielhuesken" target="_blank">Flattr</a>', 'bbpress-antispam' ) . ' |' .
' ' . __( '<a href="https://plus.google.com/109825920160870159805/" target="_blank">Google+</a>', 'bbpress-antispam' ) . ' ' .
'</p>'
) );
}
}
public function register_admin_settings() {
add_settings_section( 'bbpress_antispam', __( 'Antispam', 'bbpress-antispam' ), array( $this, 'callback_main_section' ), 'bbpress' );
add_settings_field( 'bbpress_antispam_cfg_generl', __( 'Generel Settings', 'bbpress-antispam' ), array( $this, 'option_callback_generel' ), 'bbpress', 'bbpress_antispam' );
register_setting( 'bbpress', 'bbpress_antispam_cfg_schowdashboardchart', 'intval' );
register_setting( 'bbpress', 'bbpress_antispam_cfg_prependspamtitle', 'intval' );
register_setting( 'bbpress', 'bbpress_antispam_cfg_disableloggedinuser', 'intval' );
register_setting( 'bbpress', 'bbpress_antispam_cfg_sendmailto', 'strval' );
register_setting( 'bbpress', 'bbpress_antispam_cfg_sendmail', 'strval' );
add_settings_field( 'bbpress_antispam_cfg_checkcsshack', __('Use and check with CSS Hack', 'bbpress-antispam'), array( $this, 'option_callback_checkcsshack' ), 'bbpress', 'bbpress_antispam' );
register_setting( 'bbpress', 'bbpress_antispam_cfg_checkcsshack', 'strval' );
add_settings_field( 'bbpress_antispam_cfg_checkdnsbl', __( 'Check DNSBL', 'bbpress-antispam' ), array( $this, 'option_callback_checkdnsbl' ), 'bbpress', 'bbpress_antispam' );
register_setting( 'bbpress', 'bbpress_antispam_cfg_checkdnsbl', 'strval' );
add_settings_field( 'bbpress_antispam_cfg_checkfakeip', __( 'Check for fake IP address', 'bbpress-antispam' ), array( $this, 'option_callback_checkfakeip' ), 'bbpress', 'bbpress_antispam' );
register_setting( 'bbpress', 'bbpress_antispam_cfg_checkfakeip', 'strval' );
add_settings_field( 'bbpress_antispam_cfg_checkreferrer', __( 'Check Referrer', 'bbpress-antispam' ), array( $this, 'option_callback_checkreferrer' ), 'bbpress', 'bbpress_antispam' );
register_setting( 'bbpress', 'bbpress_antispam_cfg_checkreferrer', 'strval' );
add_settings_field( 'bbpress_antispam_cfg_checkipspam', __( 'Is IP already marked as Spam IP', 'bbpress-antispam' ), array( $this, 'option_callback_checkipspam' ), 'bbpress', 'bbpress_antispam' );
register_setting( 'bbpress', 'bbpress_antispam_cfg_checkipspam', 'strval' );
add_settings_field( 'bbpress_antispam_cfg_checkcontentspam', __( 'Is content already marked as Spam', 'bbpress-antispam' ), array( $this, 'option_callback_checkcontentspam' ), 'bbpress', 'bbpress_antispam' );
register_setting( 'bbpress', 'bbpress_antispam_cfg_checkcontentspam', 'strval' );
add_settings_field( 'bbpress_antispam_cfg_checkauthorspam', __( 'Is Author already marked as Spam Author', 'bbpress-antispam' ), array( $this, 'option_callback_checkauthorspam' ), 'bbpress', 'bbpress_antispam' );
register_setting( 'bbpress', 'bbpress_antispam_cfg_checkauthorspam', 'strval' );
}
public function callback_main_section() {
?>
<p id="bbpress-antispam"><?php _e( 'Antispam Configuration', 'bbpress-antispam' ); ?></p>
<?php
}
public function option_callback_generel() {
?>
<input id="bbpress_antispam_cfg_generl_schowdashboardchart" name="bbpress_antispam_cfg_schowdashboardchart"
type="checkbox"
value="1" <?php checked( get_option( 'bbpress_antispam_cfg_schowdashboardchart', TRUE ) ); ?> />
<label
for="bbpress_antispam_cfg_generl_schowdashboardchart"><?php _e( 'Show chart in Dashboard', 'bbpress-antispam' ); ?></label>
<br/>
<input id="bbpress_antispam_cfg_generl_prependspamtitle" name="bbpress_antispam_cfg_prependspamtitle"
type="checkbox"
value="1" <?php checked( get_option( 'bbpress_antispam_cfg_prependspamtitle', TRUE ) ); ?> />
<label
for="bbpress_antispam_cfg_generl_prependspamtitle"><?php _e( 'Prepend content with SPAM message on move to Spam', 'bbpress-antispam' ); ?></label>
<br/>
<input id="bbpress_antispam_cfg_generl_disableloggedinuser" name="bbpress_antispam_cfg_disableloggedinuser"
type="checkbox"
value="1" <?php checked( get_option( 'bbpress_antispam_cfg_disableloggedinuser', FALSE ) ); ?> />
<label
for="bbpress_antispam_cfg_generl_disableloggedinuser"><?php _e( 'Do not scan logged in users', 'bbpress-antispam' ); ?></label>
<br/>
<label
for="bbpress_antispam_cfg_sendmail"><?php echo sprintf( __( 'Send mail to %s if new reply/topic ?', 'bbpress-antispam' ),
'<input class="text" name="bbpress_antispam_cfg_sendmailto" type="text" value="' . get_option( 'bbpress_antispam_cfg_sendmailto', get_bloginfo( 'admin_email' ) ) . '" />' ); ?></label>
<select id="bbpress_antispam_cfg_sendmail" name="bbpress_antispam_cfg_sendmail">
<option <?php selected( get_option( 'bbpress_antispam_cfg_sendmail' ) == 'ever' ); ?>><?php _e( 'Ever', 'bbpress-antispam' ); ?></option>
<option <?php selected( get_option( 'bbpress_antispam_cfg_sendmail' ) == 'spam' ); ?>><?php _e( 'Spam only', 'bbpress-antispam' ); ?></option>
<option <?php selected( get_option( 'bbpress_antispam_cfg_sendmail', 'off' ) == 'off' ); ?>><?php _e( 'Disable', 'bbpress-antispam' ); ?></option>
</select>
<br/>
<?php
}
public function option_callback_checkcsshack() {
?>
<input id="bbpress_antispam_cfg_checkcsshack_block" name="bbpress_antispam_cfg_checkcsshack" type="radio"
value="block" <?php checked(get_option('bbpress_antispam_cfg_checkcsshack', 'block') == 'block'); ?> />
<label for="bbpress_antispam_cfg_checkcsshack_block"><?php _e('Block', 'bbpress-antispam'); ?></label>
<br/>
<input id="bbpress_antispam_cfg_checkcsshack_off" name="bbpress_antispam_cfg_checkcsshack" type="radio"
value="off" <?php checked(get_option('bbpress_antispam_cfg_checkcsshack') == 'off'); ?> />
<label for="bbpress_antispam_cfg_checkcsshack_off"><?php _e('Disable', 'bbpress-antispam'); ?></label>
<?php
}
public function option_callback_checkdnsbl() {
?>
<input id="bbpress_antispam_cfg_checkdnsbl_block" name="bbpress_antispam_cfg_checkdnsbl" type="radio"
value="block" <?php checked( get_option( 'bbpress_antispam_cfg_checkdnsbl', 'block' ) == 'block' ); ?> />
<label for="bbpress_antispam_cfg_checkdnsbl_block"><?php _e( 'Block', 'bbpress-antispam' ); ?></label>
<br/>
<input id="bbpress_antispam_cfg_checkdnsbl_spam" name="bbpress_antispam_cfg_checkdnsbl" type="radio"
value="spam" <?php checked( get_option( 'bbpress_antispam_cfg_checkdnsbl' ) == 'spam' ); ?> />
<label for="bbpress_antispam_cfg_checkdnsbl_spam"><?php _e( 'Move to Spam', 'bbpress-antispam' ); ?></label>
<br/>
<input id="bbpress_antispam_cfg_checkdnsbl_off" name="bbpress_antispam_cfg_checkdnsbl" type="radio"
value="off" <?php checked( get_option( 'bbpress_antispam_cfg_checkdnsbl' ) == 'off' ); ?> />
<label for="bbpress_antispam_cfg_checkdnsbl_off"><?php _e( 'Disable', 'bbpress-antispam' ); ?></label>
<?php
}
public function option_callback_checkfakeip() {
?>
<input id="bbpress_antispam_cfg_checkfakeip_block" name="bbpress_antispam_cfg_checkfakeip" type="radio"
value="block" <?php checked( get_option( 'bbpress_antispam_cfg_checkfakeip' ) == 'block' ); ?> />
<label for="bbpress_antispam_cfg_checkfakeip_block"><?php _e( 'Block', 'bbpress-antispam' ); ?></label>
<br/>
<input id="bbpress_antispam_cfg_checkfakeip_spam" name="bbpress_antispam_cfg_checkfakeip" type="radio"
value="spam" <?php checked( get_option( 'bbpress_antispam_cfg_checkfakeip' ) == 'spam' ); ?> />
<label for="bbpress_antispam_cfg_checkfakeip_spam"><?php _e( 'Move to Spam', 'bbpress-antispam' ); ?></label>
<br/>
<input id="bbpress_antispam_cfg_checkfakeip_off" name="bbpress_antispam_cfg_checkfakeip" type="radio"
value="off" <?php checked( get_option( 'bbpress_antispam_cfg_checkfakeip', 'off' ) == 'off' ); ?> />
<label for="bbpress_antispam_cfg_checkfakeip_off"><?php _e( 'Disable', 'bbpress-antispam' ); ?></label>
<?php
}
public function option_callback_checkreferrer() {
?>
<input id="bbpress_antispam_cfg_checkreferrer_block" name="bbpress_antispam_cfg_checkreferrer" type="radio"
value="block" <?php checked( get_option( 'bbpress_antispam_cfg_checkreferrer' ) == 'block' ); ?> />
<label for="bbpress_antispam_cfg_checkreferrer_block"><?php _e( 'Block', 'bbpress-antispam' ); ?></label>
<br/>
<input id="bbpress_antispam_cfg_checkreferrer_spam" name="bbpress_antispam_cfg_checkreferrer" type="radio"
value="spam" <?php checked( get_option( 'bbpress_antispam_cfg_checkreferrer', 'spam' ) == 'spam' ); ?> />
<label for="bbpress_antispam_cfg_checkreferrer_spam"><?php _e( 'Move to Spam', 'bbpress-antispam' ); ?></label>
<br/>
<input id="bbpress_antispam_cfg_checkreferrer_off" name="bbpress_antispam_cfg_checkreferrer" type="radio"
value="off" <?php checked( get_option( 'bbpress_antispam_cfg_checkreferrer' ) == 'off' ); ?> />
<label for="bbpress_antispam_cfg_checkreferrer_off"><?php _e( 'Disable', 'bbpress-antispam' ); ?></label>
<?php
}
public function option_callback_checkipspam() {
?>
<input id="bbpress_antispam_cfg_checkipspam_block" name="bbpress_antispam_cfg_checkipspam" type="radio"
value="block" <?php checked( get_option( 'bbpress_antispam_cfg_checkipspam', 'block' ) == 'block' ); ?> />
<label for="bbpress_antispam_cfg_checkipspam_block"><?php _e( 'Block', 'bbpress-antispam' ); ?></label>
<br/>
<input id="bbpress_antispam_cfg_checkipspam_spam" name="bbpress_antispam_cfg_checkipspam" type="radio"
value="spam" <?php checked( get_option( 'bbpress_antispam_cfg_checkipspam' ) == 'spam' ); ?> />
<label for="bbpress_antispam_cfg_checkipspam_spam"><?php _e( 'Move to Spam', 'bbpress-antispam' ); ?></label>
<br/>
<input id="bbpress_antispam_cfg_checkipspam_off" name="bbpress_antispam_cfg_checkipspam" type="radio"
value="off" <?php checked( get_option( 'bbpress_antispam_cfg_checkipspam' ) == 'off' ); ?> />
<label for="bbpress_antispam_cfg_checkipspam_off"><?php _e( 'Disable', 'bbpress-antispam' ); ?></label>
<?php
}
public function option_callback_checkcontentspam() {
?>
<input id="bbpress_antispam_cfg_checkcontentspam_block" name="bbpress_antispam_cfg_checkcontentspam"
type="radio"
value="block" <?php checked( get_option( 'bbpress_antispam_cfg_checkcontentspam', 'block' ) == 'block' ); ?> />
<label for="bbpress_antispam_cfg_checkcontentspam_block"><?php _e( 'Block', 'bbpress-antispam' ); ?></label>
<br/>
<input id="bbpress_antispam_cfg_checkcontentspam_spam" name="bbpress_antispam_cfg_checkcontentspam" type="radio"
value="spam" <?php checked( get_option( 'bbpress_antispam_cfg_checkcontentspam' ) == 'spam' ); ?> />
<label for="bbpress_antispam_cfg_checkcontentspam_spam"><?php _e( 'Move to Spam', 'bbpress-antispam' ); ?></label>
<br/>
<input id="bbpress_antispam_cfg_checkcontentspam_off" name="bbpress_antispam_cfg_checkcontentspam" type="radio"
value="off" <?php checked( get_option( 'bbpress_antispam_cfg_checkcontentspam' ) == 'off' ); ?> />
<label for="bbpress_antispam_cfg_checkcontentspam_off"><?php _e( 'Disable', 'bbpress-antispam' ); ?></label>
<?php
}
public function option_callback_checkauthorspam() {
?>
<input id="bbpress_antispam_cfg_checkauthorspam_spam" name="bbpress_antispam_cfg_checkauthorspam" type="radio"
value="spam" <?php checked( get_option( 'bbpress_antispam_cfg_checkauthorspam', 'spam' ) == 'spam' ); ?> />
<label for="bbpress_antispam_cfg_checkauthorspam_spam"><?php _e( 'Move to Spam', 'bbpress-antispam' ); ?></label>
<br/>
<input id="bbpress_antispam_cfg_checkauthorspam_off" name="bbpress_antispam_cfg_checkauthorspam" type="radio"
value="off" <?php checked( get_option( 'bbpress_antispam_cfg_checkauthorspam' ) == 'off' ); ?> />
<label for="bbpress_antispam_cfg_checkauthorspam_off"><?php _e( 'Disable', 'bbpress-antispam' ); ?></label>
<?php
}
private function spam_chart() {
// add var to spam count
foreach ( $this->spamtypes as $type ) {
if ( !isset($this->spamchart[$this->today][$type]) )
$this->spamchart[$this->today][$type] = 0;
}
//remove old days from chart
if ( count($this->spamchart) > 30 ) {
$mustremoved = count($this->spamchart) - 30;
foreach ( $this->spamchart as $date => $values ) {
if ( $mustremoved <= 0 )
break;
unset($this->spamchart[$date]);
$mustremoved--;
}
}
//upgrade changed values
foreach( $this->spamchart as $date => $spams) {
//move key to a other
if ( isset( $spams[ 'honey' ] ) )
$this->spamchart[ $date ][ 'dnsbl' ] = $spams[ 'honey' ];
// delete not longer needed;
foreach ( $spams as $key => $value ) {
if ( ! in_array( $key, $this->spamtypes ) )
unset( $this->spamchart[ $date ][ $key ] );
}
}
}
}
}