├── css ├── dashboard.css └── styles.css ├── js ├── scripts.js ├── dashboard.js └── raphael.helper.js ├── inc ├── columns.class.php └── gui.class.php ├── readme.txt ├── LICENSE.txt ├── CHANGELOG.md └── antispam_bee.php /css/dashboard.css: -------------------------------------------------------------------------------- 1 | #ab_chart { 2 | color: #a7aaad; 3 | height: 140px; 4 | margin: 0 -4px; 5 | text-align: center; 6 | } 7 | 8 | #ab_chart_data { 9 | display: none; 10 | } 11 | 12 | #ab_widget .inside { 13 | height: 1%; 14 | margin: 0; 15 | padding-bottom: 0; 16 | overflow: hidden; 17 | position: relative; 18 | white-space: nowrap; 19 | } 20 | -------------------------------------------------------------------------------- /js/scripts.js: -------------------------------------------------------------------------------- 1 | jQuery( document ).ready( 2 | function( $ ) { 3 | function ab_flag_spam() { 4 | var $$ = $( '#ab_flag_spam' ), 5 | nextAll = $$.parent( 'li' ).nextAll( '.ab_flag_spam_child' ); 6 | 7 | nextAll.css( 8 | 'display', 9 | ( $$.is( ':checked' ) ? 'list-item' : 'none' ) 10 | ); 11 | } 12 | 13 | $( '#ab_flag_spam' ).on( 14 | 'change', 15 | ab_flag_spam 16 | ); 17 | 18 | ab_flag_spam(); 19 | } 20 | ); 21 | -------------------------------------------------------------------------------- /js/dashboard.js: -------------------------------------------------------------------------------- 1 | ( function() { 2 | // Grab the data 3 | var labels = [], 4 | data = []; 5 | jQuery( '#ab_chart_data tfoot th' ).each( function() { 6 | labels.push( jQuery( this ).text() ); 7 | } ); 8 | jQuery( '#ab_chart_data tbody td' ).each( function() { 9 | data.push( jQuery( this ).text() ); 10 | } ); 11 | 12 | // Draw 13 | var width = jQuery( '#ab_chart' ).parent().width() + 8, 14 | height = 140, 15 | leftgutter = 0, 16 | bottomgutter = 22, 17 | topgutter = 22, 18 | color = '#135e96', 19 | r = Raphael( 'ab_chart', width, height ), 20 | txt = { font: 'bold 12px "Open Sans", sans-serif', fill: '#1d2327' }, 21 | X = ( width - leftgutter * 2 ) / labels.length, 22 | max = Math.max.apply( Math, data ), 23 | Y = ( height - bottomgutter - topgutter ) / max; 24 | 25 | // Max value 26 | r 27 | .text( 16, 16, max ) 28 | .attr( 29 | { 30 | font: 'normal 10px "Open Sans", sans-serif', 31 | fill: '#a7aaad', 32 | } 33 | ); 34 | 35 | var path = r.path().attr( { stroke: color, 'stroke-width': 2, 'stroke-linejoin': 'round' } ), 36 | bgp = r.path().attr( { stroke: 'none', opacity: .3, fill: color } ), 37 | label = r.set(), 38 | lx = 0, 39 | ly = 0, 40 | is_label_visible = false, 41 | leave_timer, 42 | blanket = r.set(); 43 | label.push( r.text( 60, 12, '' ).attr( txt ) ); 44 | label.push( r.text( 60, 27, '' ).attr( txt ).attr( { fill: color } ) ); 45 | label.hide(); 46 | var frame = r.popup( 100, 100, label, 'right' ).attr( { fill: '#fff', stroke: '#444', 'stroke-width': 1 } ).hide(); 47 | 48 | var p, bgpp; 49 | for ( var i = 0, ii = labels.length; i < ii; i++ ) { 50 | var y = Math.round( height - bottomgutter - Y * data[i] ), 51 | x = Math.round( leftgutter + X * ( i + .5 ) ); 52 | if ( ! i ) { 53 | p = [ 'M', x, y, 'C', x, y ]; 54 | bgpp = [ 'M', leftgutter + X * .5, height - bottomgutter, 'L', x, y, 'C', x, y ]; 55 | } 56 | if ( i && i < ii - 1 ) { 57 | var Y0 = Math.round( height - bottomgutter - Y * data[i - 1] ), 58 | X0 = Math.round( leftgutter + X * ( i - .5 ) ), 59 | Y2 = Math.round( height - bottomgutter - Y * data[i + 1] ), 60 | X2 = Math.round( leftgutter + X * ( i + 1.5 ) ); 61 | var a = getAnchors( X0, Y0, x, y, X2, Y2 ); 62 | p = p.concat( [ a.x1, a.y1, x, y, a.x2, a.y2 ] ); 63 | bgpp = bgpp.concat( [ a.x1, a.y1, x, y, a.x2, a.y2 ] ); 64 | } 65 | var dot = r.circle( x, y, 4 ).attr( { fill: '#fff', stroke: color, 'stroke-width': 1 } ); 66 | blanket.push( r.rect( leftgutter + X * i, 0, X, height - bottomgutter ).attr( { stroke: 'none', fill: '#fff', opacity: .2 } ) ); 67 | var rect = blanket[blanket.length - 1]; 68 | ( function( x, y, data, date, dot ) { 69 | var timer, 70 | i = 0; 71 | rect.hover( function() { 72 | clearTimeout( leave_timer ); 73 | var side = 'right'; 74 | if ( x + frame.getBBox().width > width ) { 75 | side = 'left'; 76 | } 77 | // set label content to determine correct dimensions 78 | label[0].attr( { text: date } ); 79 | label[1].attr( { text: data + '× Spam' } ); 80 | var ppp = r.popup( x, y, label, side, 1 ), 81 | anim = Raphael.animation( { 82 | path: ppp.path, 83 | transform: [ 't', ppp.dx, ppp.dy ], 84 | }, 200 * is_label_visible ); 85 | lx = label[0].transform()[0][1] + ppp.dx; 86 | ly = label[0].transform()[0][2] + ppp.dy; 87 | frame.show().stop().animate( anim ); 88 | 89 | label[0].show().stop().animateWith( frame, anim, { transform: [ 't', lx, ly ] }, 200 * is_label_visible ); 90 | label[1].show().stop().animateWith( frame, anim, { transform: [ 't', lx, ly ] }, 200 * is_label_visible ); 91 | dot.attr( 'r', 6 ); 92 | is_label_visible = true; 93 | }, function() { 94 | dot.attr( 'r', 4 ); 95 | leave_timer = setTimeout( function() { 96 | frame.hide(); 97 | label[0].hide(); 98 | label[1].hide(); 99 | is_label_visible = false; 100 | }, 1 ); 101 | } ); 102 | }( x, y, data[i], labels[i], dot ) ); 103 | } 104 | p = p.concat( [ x, y, x, y ] ); 105 | bgpp = bgpp.concat( [ x, y, x, y, 'L', x, height - bottomgutter, 'z' ] ); 106 | path.attr( { path: p } ); 107 | bgp.attr( { path: bgpp } ); 108 | frame.toFront(); 109 | label[0].toFront(); 110 | label[1].toFront(); 111 | blanket.toFront(); 112 | }() ); 113 | -------------------------------------------------------------------------------- /js/raphael.helper.js: -------------------------------------------------------------------------------- 1 | var tokenRegex = /\{([^\}]+)\}/g, 2 | objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g, 3 | replacer = function( all, key, obj ) { 4 | var res = obj; 5 | key.replace( objNotationRegex, function( all, name, quote, quotedName, isFunc ) { 6 | name = name || quotedName; 7 | if ( res ) { 8 | if ( name in res ) { 9 | res = res[name]; 10 | } 11 | typeof res === 'function' && isFunc && ( res = res() ); 12 | } 13 | } ); 14 | res = ( res == null || res == obj ? all : res ) + ''; 15 | return res; 16 | }, 17 | fill = function( str, obj ) { 18 | return String( str ).replace( tokenRegex, function( all, key ) { 19 | return replacer( all, key, obj ); 20 | } ); 21 | }; 22 | 23 | Raphael.fn.popup = function( X, Y, set, pos, ret ) { 24 | pos = String( pos || 'top-middle' ).split( '-' ); 25 | pos[1] = pos[1] || 'middle'; 26 | var r = 5, 27 | bb = set.getBBox(), 28 | w = Math.round( bb.width ), 29 | h = Math.round( bb.height ), 30 | x = Math.round( bb.x ) - r, 31 | y = Math.round( bb.y ) - r, 32 | gap = Math.min( h / 2, w / 2, 10 ), 33 | shapes = { 34 | top: 'M{x},{y}h{w4},{w4},{w4},{w4}a{r},{r},0,0,1,{r},{r}v{h4},{h4},{h4},{h4}a{r},{r},0,0,1,-{r},{r}l-{right},0-{gap},{gap}-{gap}-{gap}-{left},0a{r},{r},0,0,1-{r}-{r}v-{h4}-{h4}-{h4}-{h4}a{r},{r},0,0,1,{r}-{r}z', 35 | bottom: 'M{x},{y}l{left},0,{gap}-{gap},{gap},{gap},{right},0a{r},{r},0,0,1,{r},{r}v{h4},{h4},{h4},{h4}a{r},{r},0,0,1,-{r},{r}h-{w4}-{w4}-{w4}-{w4}a{r},{r},0,0,1-{r}-{r}v-{h4}-{h4}-{h4}-{h4}a{r},{r},0,0,1,{r}-{r}z', 36 | right: 'M{x},{y}h{w4},{w4},{w4},{w4}a{r},{r},0,0,1,{r},{r}v{h4},{h4},{h4},{h4}a{r},{r},0,0,1,-{r},{r}h-{w4}-{w4}-{w4}-{w4}a{r},{r},0,0,1-{r}-{r}l0-{bottom}-{gap}-{gap},{gap}-{gap},0-{top}a{r},{r},0,0,1,{r}-{r}z', 37 | left: 'M{x},{y}h{w4},{w4},{w4},{w4}a{r},{r},0,0,1,{r},{r}l0,{top},{gap},{gap}-{gap},{gap},0,{bottom}a{r},{r},0,0,1,-{r},{r}h-{w4}-{w4}-{w4}-{w4}a{r},{r},0,0,1-{r}-{r}v-{h4}-{h4}-{h4}-{h4}a{r},{r},0,0,1,{r}-{r}z', 38 | }, 39 | offset = { 40 | hx0: X - ( x + r + w - gap * 2 ), 41 | hx1: X - ( x + r + w / 2 - gap ), 42 | hx2: X - ( x + r + gap ), 43 | vhy: Y - ( y + r + h + r + gap ), 44 | '^hy': Y - ( y - gap ), 45 | 46 | }, 47 | mask = [ { 48 | x: x + r, 49 | y: y, 50 | w: w, 51 | w4: w / 4, 52 | h4: h / 4, 53 | right: 0, 54 | left: w - gap * 2, 55 | bottom: 0, 56 | top: h - gap * 2, 57 | r: r, 58 | h: h, 59 | gap: gap, 60 | }, { 61 | x: x + r, 62 | y: y, 63 | w: w, 64 | w4: w / 4, 65 | h4: h / 4, 66 | left: w / 2 - gap, 67 | right: w / 2 - gap, 68 | top: h / 2 - gap, 69 | bottom: h / 2 - gap, 70 | r: r, 71 | h: h, 72 | gap: gap, 73 | }, { 74 | x: x + r, 75 | y: y, 76 | w: w, 77 | w4: w / 4, 78 | h4: h / 4, 79 | left: 0, 80 | right: w - gap * 2, 81 | top: 0, 82 | bottom: h - gap * 2, 83 | r: r, 84 | h: h, 85 | gap: gap, 86 | } ][pos[1] == 'middle' ? 1 : ( pos[1] == 'top' || pos[1] == 'left' ) * 2]; 87 | var dx = 0, 88 | dy = 0, 89 | out = this.path( fill( shapes[pos[0]], mask ) ).insertBefore( set ); 90 | switch ( pos[0] ) { 91 | case 'top': 92 | dx = X - ( x + r + mask.left + gap ); 93 | dy = Y - ( y + r + h + r + gap ); 94 | break; 95 | case 'bottom': 96 | dx = X - ( x + r + mask.left + gap ); 97 | dy = Y - ( y - gap ); 98 | break; 99 | case 'left': 100 | dx = X - ( x + r + w + r + gap ); 101 | dy = Y - ( y + r + mask.top + gap ); 102 | break; 103 | case 'right': 104 | dx = X - ( x - gap ); 105 | dy = Y - ( y + r + mask.top + gap ); 106 | break; 107 | } 108 | out.translate( dx, dy ); 109 | if ( ret ) { 110 | ret = out.attr( 'path' ); 111 | out.remove(); 112 | return { 113 | path: ret, 114 | dx: dx, 115 | dy: dy, 116 | }; 117 | } 118 | set.translate( dx, dy ); 119 | return out; 120 | }; 121 | 122 | function getAnchors( p1x, p1y, p2x, p2y, p3x, p3y ) { 123 | var l1 = ( p2x - p1x ) / 2, 124 | l2 = ( p3x - p2x ) / 2, 125 | a = Math.atan( ( p2x - p1x ) / Math.abs( p2y - p1y ) ), 126 | b = Math.atan( ( p3x - p2x ) / Math.abs( p2y - p3y ) ); 127 | a = p1y < p2y ? Math.PI - a : a; 128 | b = p3y < p2y ? Math.PI - b : b; 129 | var alpha = Math.PI / 2 - ( ( a + b ) % ( Math.PI * 2 ) ) / 2, 130 | dx1 = l1 * Math.sin( alpha + a ), 131 | dy1 = l1 * Math.cos( alpha + a ), 132 | dx2 = l2 * Math.sin( alpha + b ), 133 | dy2 = l2 * Math.cos( alpha + b ); 134 | return { 135 | x1: p2x - dx1, 136 | y1: p2y + dy1, 137 | x2: p2x + dx2, 138 | y2: p2y + dy2, 139 | }; 140 | } 141 | -------------------------------------------------------------------------------- /css/styles.css: -------------------------------------------------------------------------------- 1 | /* @group General */ 2 | 3 | .ab-main *, 4 | .ab-main *::after, 5 | .ab-main *::before { 6 | border: 0; 7 | margin: 0; 8 | padding: 0; 9 | outline: 0; 10 | -webkit-box-sizing: border-box; 11 | -moz-box-sizing: border-box; 12 | box-sizing: border-box; 13 | } 14 | 15 | /* @end group */ 16 | 17 | /* @group Columns */ 18 | 19 | .ab-wrap { 20 | margin: 0 0 0 -10px; 21 | padding: 20px 0 0 0; 22 | text-rendering: optimizeLegibility; /* stylelint-disable-line value-keyword-case */ 23 | } 24 | 25 | .ab-column { 26 | float: left; 27 | margin: 0 0 0 10px; 28 | position: relative; 29 | } 30 | 31 | /* @end group */ 32 | 33 | /* @group Headlines + Icons */ 34 | 35 | .ab-column h3 { 36 | margin: 0; 37 | font-size: 18px; 38 | font-weight: normal; 39 | line-height: 20px; 40 | color: #1d2327; 41 | } 42 | 43 | .ab-column h3.icon::before { 44 | font: normal 30px/30px Dashicons; 45 | top: 4px; 46 | right: 20px; 47 | speak: none; 48 | width: 1em; 49 | color: #8c8f94; 50 | position: absolute; 51 | text-align: center; 52 | -webkit-font-smoothing: antialiased; 53 | -moz-osx-font-smoothing: grayscale; 54 | } 55 | 56 | .ab-column.ab-arrow h3.icon::before { 57 | content: "\f536"; 58 | } 59 | 60 | .ab-column.ab-join h3.icon::before { 61 | content: "\f108"; 62 | } 63 | 64 | .ab-column.ab-diff h3.icon::before { 65 | content: "\f237"; 66 | } 67 | 68 | .ab-column h6 { 69 | clear: both; 70 | color: #3c434a; 71 | margin: 0 0 20px; 72 | font-weight: normal; 73 | font-size: 13px; 74 | } 75 | 76 | /* @end group */ 77 | 78 | /* @group Form */ 79 | 80 | .ab-column input[type="text"], 81 | .ab-column input[type="number"], 82 | .ab-column select { 83 | font-size: 13px; 84 | text-align: center; 85 | background: #f6f7f7; 86 | } 87 | 88 | .ab-column input[type="number"] { 89 | padding: 0; 90 | } 91 | 92 | .ab-column select[multiple] { 93 | width: 175px; 94 | min-height: 60px; 95 | } 96 | 97 | .ab-column select[multiple][name="ab_ignore_reasons[]"] { 98 | width: auto; 99 | } 100 | 101 | .ab-column input.ab-mini-field { 102 | width: 40px; 103 | } 104 | 105 | .ab-column .ab-medium-field { 106 | width: 100%; 107 | max-width: 285px; 108 | } 109 | 110 | .ab-column input[type="text"] + label, 111 | .ab-column select + label { 112 | color: #8c8f94; 113 | margin: 0 0 0 7px; 114 | display: inline-block; 115 | text-transform: uppercase; 116 | } 117 | 118 | /* @end group */ 119 | 120 | /* @group Column contents */ 121 | 122 | .ab-column > ul { 123 | padding: 0 20px 0 0; 124 | } 125 | 126 | .ab-column:last-of-type > ul { 127 | border: 0; 128 | } 129 | 130 | .ab-column > ul > li { 131 | width: 330px; 132 | margin: 0 0 36px; 133 | padding: 10px 0 12px 12px; 134 | position: relative; 135 | background: #fff; 136 | } 137 | 138 | .ab-column > ul > li a { 139 | text-decoration: underline; 140 | } 141 | 142 | .ab-column > ul > li a:hover { 143 | border-color: inherit; 144 | } 145 | 146 | .ab-column > ul > li label { 147 | cursor: default; 148 | display: inline-block; 149 | font-size: 14px; 150 | max-width: 286px; 151 | color: #1d2327; 152 | } 153 | 154 | .ab-column > ul > li label span { 155 | color: #3c434a; 156 | display: block; 157 | font-size: 13px; 158 | line-height: 16px; 159 | margin-top: 5px; 160 | } 161 | 162 | /* @end group */ 163 | 164 | /* @group Separator */ 165 | 166 | .ab-column > ul > li::after, 167 | .ab-column > ul > li::before { 168 | width: 0; 169 | content: ""; 170 | position: absolute; 171 | } 172 | 173 | .ab-column.ab-arrow > ul > li::before, 174 | .ab-column.ab-arrow > ul > li::after { 175 | left: 157px; 176 | border-width: 10px 10px 0; 177 | border-style: solid; 178 | } 179 | 180 | .ab-column.ab-arrow > ul > li::before { 181 | bottom: -24px; 182 | border-color: #fff transparent; 183 | } 184 | 185 | .ab-column.ab-arrow > ul > li::after { 186 | bottom: -22px; 187 | border-color: #f0f0f1 transparent; 188 | } 189 | 190 | .ab-column.ab-join > ul > li::before { 191 | left: 171px; 192 | bottom: -27px; 193 | height: 18px; 194 | border-right: 2px solid #fff; 195 | } 196 | 197 | .ab-column.ab-diff > ul > li::before { 198 | left: 162px; 199 | bottom: -19px; 200 | width: 18px; 201 | height: 0; 202 | border-bottom: 2px solid #fff; 203 | } 204 | 205 | /* @end group */ 206 | 207 | /* @group Submit & Service */ 208 | 209 | .ab-column--submit-service { 210 | width: 342px; 211 | margin-top: 20px; 212 | padding-right: 20px; 213 | } 214 | 215 | .ab-column--submit-service p { 216 | padding: 5px 0; 217 | margin: 0; 218 | text-align: center; 219 | width: 100%; 220 | } 221 | 222 | .ab-column--submit-service p:first-of-type { 223 | border-top: 1px solid #dcdcde; 224 | } 225 | 226 | .ab-column--submit-service p:last-of-type { 227 | border-bottom: 1px solid #dcdcde; 228 | } 229 | 230 | .ab-column--submit-service .button { 231 | width: 100%; 232 | margin: 35px 0 10px; 233 | } 234 | 235 | /* @end group */ 236 | 237 | /* @group 2nd level */ 238 | 239 | .ab-column > ul > li:last-of-type::after, 240 | .ab-column > ul > li:last-of-type::before { 241 | display: none; 242 | } 243 | 244 | .ab-column > ul > li > ul { 245 | margin: 10px 10px 0 26px; 246 | display: none; 247 | } 248 | 249 | .ab-column > ul > li > ul li { 250 | padding: 2px 0; 251 | } 252 | 253 | .ab-column > ul > li > ul label { 254 | margin: 0 0 0 7px; 255 | } 256 | 257 | .ab-column > ul > li > ul label[for="ab_ignore_reasons"] { 258 | margin: 0 0 5px 0; 259 | } 260 | 261 | .ab-column > ul > li > input[type="checkbox"]:checked ~ ul { 262 | display: block; 263 | } 264 | 265 | /* @end group */ 266 | -------------------------------------------------------------------------------- /inc/columns.class.php: -------------------------------------------------------------------------------- 1 | esc_html__( 'Spam Reason', 'antispam-bee' ), 29 | ) 30 | ); 31 | } 32 | 33 | /** 34 | * Display plugin column values on comments screen 35 | * 36 | * @since 2.6.0 37 | * @change 2.6.0 38 | * 39 | * @param string $column Currently selected column. 40 | * @param integer $comment_id Comment ID. 41 | */ 42 | public static function print_plugin_column( $column, $comment_id ) { 43 | if ( 'antispam_bee_reason' !== $column ) { 44 | return; 45 | } 46 | 47 | $spam_reason = get_comment_meta( $comment_id, $column, true ); 48 | $spam_reasons = Antispam_Bee::$defaults['reasons']; 49 | 50 | if ( empty( $spam_reason ) || empty( $spam_reasons[ $spam_reason ] ) ) { 51 | return; 52 | } 53 | 54 | echo esc_html( $spam_reasons[ $spam_reason ] ); 55 | } 56 | 57 | /** 58 | * Register plugin sortable columns on comments screen 59 | * 60 | * @since 2.6.3 61 | * @change 2.6.3 62 | * 63 | * @param array $columns Registered columns. 64 | * @return array $columns Columns with AB field. 65 | */ 66 | public static function register_sortable_columns( $columns ) { 67 | $columns['antispam_bee_reason'] = 'antispam_bee_reason'; 68 | 69 | return $columns; 70 | } 71 | 72 | // phpcs:disable WordPress.VIP.SlowDBQuery.slow_db_query_meta_key 73 | // phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification 74 | /** 75 | * Adjust orderby query 76 | * 77 | * @since 2.6.3 78 | * @change 2.6.3 79 | * 80 | * @param \WP_Comment_Query $query Current WordPress query. 81 | */ 82 | public static function set_orderby_query( $query ) { 83 | $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( wp_unslash( $_GET['orderby'] ) ) : ''; 84 | 85 | if ( empty( $orderby ) || 'antispam_bee_reason' !== $orderby ) { 86 | return; 87 | } 88 | 89 | $query->query_vars['meta_key'] = 'antispam_bee_reason'; 90 | $query->query_vars['orderby'] = 'meta_value'; 91 | } 92 | // phpcs:enable WordPress.VIP.SlowDBQuery.slow_db_query_meta_key 93 | // phpcs:enable WordPress.CSRF.NonceVerification.NoNonceVerification 94 | 95 | //phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification 96 | /** 97 | * Filter comments by the spam reason 98 | * 99 | * @global \wpdb $wpdb 100 | */ 101 | public static function filter_columns() { 102 | global $wpdb; 103 | ?> 104 | 105 | 120 | query_vars['meta_key'] = 'antispam_bee_reason'; 139 | $query->query_vars['meta_value'] = $spam_reason; 140 | } 141 | //phpcs:enable WordPress.VIP.SlowDBQuery.slow_db_query_meta_key 142 | //phpcs:enable WordPress.VIP.SlowDBQuery.slow_db_query_meta_value 143 | //phpcs:enable WordPress.CSRF.NonceVerification.NoNonceVerification 144 | 145 | /** 146 | * Print CSS for the plugin column 147 | * 148 | * @since 2.6.1 149 | * @change 2.6.1 150 | */ 151 | public static function print_column_styles() { 152 | ?> 153 | 158 | if (req.restarts == 0) { 88 | > set req.http.X-Forwarded-For = client.ip; 89 | > } 90 | 91 | ### Are there some paid services or limitations? ### 92 | No, Antispam Bee is free forever, for both private and commercial projects. You can use it on as many sites as you want. There is no limitation to the number of sites you use the plugin on. 93 | 94 | A complete documentation is available on [pluginkollektiv.org](https://antispambee.pluginkollektiv.org/documentation/). 95 | 96 | ### How can I report security bugs? ### 97 | You can report security bugs through the Patchstack Vulnerability Disclosure Program. The Patchstack team helps validate, triage and handle any security vulnerabilities. [Report a security vulnerability.](https://patchstack.com/database/vdp/445425e4-f5dd-4404-80a7-690999f5bcb3) 98 | 99 | ## Changelog ## 100 | 101 | ### 2.11.8 ### 102 | * Tweak: Minor code changes and housekeeping 103 | * Tweak: Add link to Patchstack in readme 104 | * Maintenance: Tested up to WordPress 6.8 105 | 106 | ### 2.11.7 ### 107 | * Tweak: Use SCRIPT_NAME instead of REQUEST_URI to check path 108 | * Fix: Remove `add_reasons_to_defaults()` from general initialization for better WordPress 6.7 compatibility 109 | * Maintenance: Tested up to WordPress 6.7 110 | 111 | ### 2.11.6 ### 112 | * Fix: Delete missed out option on uninstall (Thanks @okvee!) 113 | * Tweak: Minor i18n improvements (Thanks Pedro!) 114 | * Tweak: Minor code changes and housekeeping 115 | * Tweak: Updated dependencies 116 | 117 | ### 2.11.5 ### 118 | IMPORTANT: If you use the country check and are behind a proxy or similar, you need to use the `antispam_bee_trusted_ip` filter to get the correct IP from a header like `HTTP_X_FORWARDED` (don’t return an empty value here, otherwise all comments are marked as spam). 119 | 120 | * Fix: Usage of core filter `pre_comment_user_ip` breaks ASB if the IP address is removed for GDPR compliance 121 | 122 | ### 2.11.4 ### 123 | IMPORTANT: If you use the country check and are behind a proxy or similar, you need to use the `pre_comment_user_ip` filter to get the correct IP from a header like `HTTP_X_FORWARDED`. 124 | 125 | * Fix: Read client IP for country check from `REMOTE_ADDR` only (filterable via `pre_comment_user_ip`) 126 | * Fix: No spam reason in spam notification email, and related PHP warning 127 | * Fix: Remove outdated info from readme 128 | * Enhancement: Show upgrade notice on plugin overview page 129 | * Maintenance: Tested up to WordPress 6.3 130 | 131 | ### 2.11.3 ### 132 | * Fix: Multiselect for "Delete comments by spam reasons" was not saving values 133 | * Fix: Fix broken link for ISO country codes 134 | * Maintenance: Added test for PHP 8.2 135 | * Maintenance: Tested up to WordPress 6.2 136 | 137 | ### 2.11.2 ### 138 | * Tweak: remove superfluous translations 139 | * Tweak: make FAQ link an anchor link 140 | * Fix: spam counter no longer raises a warning with PHP 8.1 if no spam is present yet 141 | * Fix: spam reasons are now localized correctly 142 | * Fix: Translations were loaded twice on some admin pages 143 | * Maintenance: Tested up to WordPress 6.1 144 | 145 | ### 2.11.1 ### 146 | * Tweak: remove superfluous type attribute from inline script tag 147 | * Maintenance: Tested up to WordPress 6.0 148 | 149 | ### 2.11.0 ### 150 | * Fix: Allow empty comments if `allow_empty_comment` is set to true 151 | * Fix: Add `aria-label` to work around bug in a11y testing tools 152 | * Fix: Change priority for `comment_form_field_comment` from 10 to 99 153 | * Tweak: Updated some FAQ entries 154 | * Tweak: Updated build tooling 155 | 156 | ### 2.10.0 ### 157 | * Fix: Switch from ip2country.info to iplocate.io for country check 158 | * Enhancement: Use filter to add the honeypot field instead of output buffering for new installations and added option to switch between the both ways 159 | * Tweak: Added comment user agent to regex pattern check 160 | * Tweak: Make the ping detection filterable to support new comment types 161 | * Tweak: Updated internal documentation links 162 | * Tweak: Several updates and optimizations in the testing process 163 | * Tweak: Adjust color palette to recent WP version 164 | * Tweak: Adjust wording in variables and option names 165 | * Readme: Add new contributor and clean up unused code 166 | 167 | 168 | ### 2.9.4 ### 169 | * Enhancement: Add filter to allow ajax calls 170 | * Tweak: Better wording for BBCode feature in plugin description 171 | * Tweak: Better screenshots in the plugin directory 172 | * Maintenance: Tested up to WordPress 5.7 173 | 174 | ### 2.9.3 ### 175 | * Fixed: Compatibility with WordPress 5.5 176 | * Fixed: Undefined index on spam list page 177 | * Tweak: Better wording on settings page 178 | * Tweak: AMP compatibility 179 | * Tweak: Protect CSS from overwrite through bad themes 180 | 181 | ### 2.9.2 ### 182 | * Fix: Delete comment meta for deleted old spam. For the cleanup of older orphaned comment meta we suggest the usage of [WP Sweep](https://wordpress.org/plugins/wp-sweep/) 183 | * Fix: Statistic in dashboard showed wrong value 184 | * Tweak: Change autocomplete attribute to "new-password" 185 | * Tweak: Autoptimize compatibility improved 186 | * Tweak: Renamed blacklist/whitelist to a better phrase 187 | * Tweak: Added new pattern 188 | * Tweak: UI and text optimizations 189 | * Tweak: Better compatibility with some server configurations 190 | * Tweak: Make spam reason sortable and filterable 191 | * Tweak: Add spam reason for manually marked spam 192 | * Maintenance: Deleted unused code 193 | * Maintenance: Removed Fake IP check (unreliable and producing false positives) 194 | * Maintenance: Fix some coding standard issues 195 | * Maintenance: Tested up to WordPress 5.4 196 | * Maintenance: Tested up to PHP 7.4 197 | 198 | ### 2.9.1 ### 199 | * Improved backend accessibility 200 | * Prefilled comment textareas do now work with the honeypot 201 | * Compatible with the AMP plugin (https://wordpress.org/plugins/amp/) 202 | * Improved dashboard tooltips 203 | * Improvements for the language detection API 204 | * Scalable IP look up for local spam database 205 | 206 | ### 2.9.0 ### 207 | * Introduction of coding standards. 208 | * Switch to franc language detection API for the language check. 209 | * Do not longer overwrite the IP address WordPress saves with the comment by using `pre_comment_user_ip`. 210 | * Do not show "Trust commenters with a Gravatar" if the "Show Gravatar" option is not set. 211 | * Skip the checks, when I ping myself. 212 | * Fixes some wrong usages of the translation functions. 213 | * Use the regular expressions check also for trackbacks. 214 | * Add option to delete Antispam Bee related data when plugin gets deleted via the admin interface. 215 | * Save a hashed + salted IP for every comment 216 | * New check for incoming trackbacks. 217 | * Introduction of behat tests. 218 | * Updates the used JavaScript library for the statistics widget. 219 | * Bugfix in the "Comment form used outside of posts" option. 220 | 221 | ### 2.8.1 ### 222 | * PHP 5.3 compatibility 223 | * Bugfix where a spam trackback produced a fatal error 224 | * For more details see https://github.com/pluginkollektiv/antispam-bee/milestone/8?closed=1 225 | 226 | ### 2.8.0 ### 227 | * Removed stopforumspam.com to avoid potential GDPR violation 228 | * Improves IP handling to comply with GDPR 229 | * Improves PHP7.2 compatibility 230 | * Fixes small bug on mobile views 231 | * Allow more than one language in language check 232 | * Minor interface improvements 233 | * Remove old russian and Dutch translation files 234 | * For more details see https://github.com/pluginkollektiv/antispam-bee/milestone/4?closed=1 235 | 236 | ### 2.7.1 ### 237 | * Fixes an incompatibility with Chrome autofill 238 | * Fixes some incompatibilities with other plugins/themes where the comment field was left empty 239 | * Support for RTL 240 | * Solve some translation/language issues 241 | * A new filter to add languages to the language check 242 | * For more details see https://github.com/pluginkollektiv/antispam-bee/milestone/6?closed=1 243 | 244 | ### 2.7.0 ### 245 | * Country check is back again (thanks to Sergej Müller for his amazing work and the service page) 246 | * Improved Honeypot 247 | * Language check through Google Translate API is back again (thanks to Simon Kraft of https://moenus.net/ for offering to cover the costs) 248 | * More default Regexes 249 | * Unit Test Framework 250 | * Accessibility and GUI improvements 251 | * An [english documentation](https://github.com/pluginkollektiv/antispam-bee/wiki) is now available, too. Some corrections in the german documentation. 252 | * Some bugfixes - Among other things for WPML compatibility 253 | * For more details see https://github.com/pluginkollektiv/antispam-bee/milestone/3?closed=1 254 | 255 | ### 2.6.9 ### 256 | * Updates donation links throughout the plugin 257 | * Fixes an error were JavaScript on the dashboard was erroneously being enqueued 258 | * Ensures compatibility with the latest WordPress version 259 | 260 | ### 2.6.8 ### 261 | * added a POT file 262 | * updated German translation, added formal version 263 | * updated plugin text domain to include a dash instead of an underscore 264 | * updated, translated + formatted README.md 265 | * updated expired link URLs in plugin and languages files 266 | * updated [plugin authors](https://pluginkollektiv.org/hello-world/) 267 | 268 | ### 2.6.7 ### 269 | * Removal of functions *Block comments from specific countries* and *Allow comments only in certain language* for financial reasons - [more information](https://antispambee.pluginkollektiv.org/news/2015/removal-of-allow-comments-only-in-certain-language/) 270 | 271 | ### 2.6.6 ### 272 | * Switch to the official Google Translation API 273 | * *Release time investment (Development & QA): 2.5 h* 274 | 275 | ### 2.6.5 ### 276 | * Fix: Return parameters on `dashboard_glance_items` callback / thx [@toscho](https://twitter.com/toscho) 277 | * New function: Trust commenters with a Gravatar / thx [@glueckpress](https://twitter.com/glueckpress) 278 | * Additional plausibility checks and filters 279 | * *Release time investment (Development & QA): 12 h* 280 | 281 | ### 2.6.4 ### 282 | * Consideration of the comment time (Spam if a comment was written in less than 5 seconds) - [more information](https://antispambee.pluginkollektiv.org/news/2014/antispam-bee-2-6-4/) 283 | * *Release time investment (Development & QA): 6.25 h* 284 | 285 | ### 2.6.3 ### 286 | * Sorting for the Antispam Bee column in the spam comments overview 287 | * Code refactoring around the use of REQUEST_URI 288 | * *Release time investment (Development & QA): 2.75 h* 289 | 290 | ### 2.6.2 ### 291 | * Improving detection of fake IPs 292 | * *Release time investment (Development & QA): 11 h* 293 | 294 | ### 2.6.1 ### 295 | * Code refactoring of options management 296 | * Support for `HTTP_FORWARDED_FOR` header 297 | * *Release time investment (Development & QA): 8.5 h* 298 | 299 | ### 2.6.0 ### 300 | * Optimizations for WordPress 3.8 301 | * Clear invalid UTF-8 characters in comment fields 302 | * Spam reason as a column in the table with spam comments 303 | 304 | For the complete changelog, check out our [GitHub repository](https://github.com/pluginkollektiv/antispam-bee). 305 | 306 | == Upgrade Notice == 307 | 308 | = 2.11.5 = 309 | Instead of pre_comment_user_ip you need to use our new filter antispam_bee_trusted_ip to send the correct IP address 310 | 311 | = 2.11.3 = 312 | The multiselect field for "Delete comments by spam reasons" did not store any values in the last version - please check the setting after the update! 313 | 314 | = 2.8.0 = 315 | This update makes sure your spam check is GDPR compliant, no matter the options you choose. Please make sure to update before May 25th! 316 | 317 | ## Screenshots ## 318 | 1. Block or allow comments from specific countries. 319 | 2. Allow comments only in certain languages. 320 | 3. Add useful spam stats to your dashboard. 321 | 4. Tailor WordPress' spam management to your workflow. 322 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /inc/gui.class.php: -------------------------------------------------------------------------------- 1 | (int) ( ! empty( $_POST['ab_flag_spam'] ) ), 50 | 'email_notify' => (int) ( ! empty( $_POST['ab_email_notify'] ) ), 51 | 'cronjob_enable' => (int) ( ! empty( $_POST['ab_cronjob_enable'] ) ), 52 | 'cronjob_interval' => (int) self::get_key( $_POST, 'ab_cronjob_interval' ), 53 | 54 | 'no_notice' => (int) ( ! empty( $_POST['ab_no_notice'] ) ), 55 | 56 | 'dashboard_count' => (int) ( ! empty( $_POST['ab_dashboard_count'] ) ), 57 | 'dashboard_chart' => (int) ( ! empty( $_POST['ab_dashboard_chart'] ) ), 58 | 'regexp_check' => (int) ( ! empty( $_POST['ab_regexp_check'] ) ), 59 | 'spam_ip' => (int) ( ! empty( $_POST['ab_spam_ip'] ) ), 60 | 'already_commented' => (int) ( ! empty( $_POST['ab_already_commented'] ) ), 61 | 'time_check' => (int) ( ! empty( $_POST['ab_time_check'] ) ), 62 | 63 | 'ignore_pings' => (int) ( ! empty( $_POST['ab_ignore_pings'] ) ), 64 | 'ignore_filter' => (int) ( ! empty( $_POST['ab_ignore_filter'] ) ), 65 | 'ignore_type' => (int) self::get_key( $_POST, 'ab_ignore_type' ), 66 | 67 | 'reasons_enable' => (int) ( ! empty( $_POST['ab_reasons_enable'] ) ), 68 | 'ignore_reasons' => (array) self::get_key( $_POST, 'ab_ignore_reasons' ), 69 | 70 | 'bbcode_check' => (int) ( ! empty( $_POST['ab_bbcode_check'] ) ), 71 | 'gravatar_check' => (int) ( ! empty( $_POST['ab_gravatar_check'] ) ), 72 | 'country_code' => (int) ( ! empty( $_POST['ab_country_code'] ) ), 73 | 'country_denied' => sanitize_text_field( wp_unslash( self::get_key( $_POST, 'ab_country_denied' ) ) ), 74 | 'country_allowed' => sanitize_text_field( wp_unslash( self::get_key( $_POST, 'ab_country_allowed' ) ) ), 75 | 76 | 'translate_api' => (int) ( ! empty( $_POST['ab_translate_api'] ) ), 77 | 'translate_lang' => $selected_languages, 78 | 79 | 'delete_data_on_uninstall' => (int) ( ! empty( $_POST['delete_data_on_uninstall'] ) ), 80 | 81 | 'use_output_buffer' => (int) ( ! empty( $_POST['ab_use_output_buffer'] ) ), 82 | 83 | ); 84 | 85 | foreach ( $options['ignore_reasons'] as $key => $val ) { 86 | if ( ! isset( self::$defaults['reasons'][ $val ] ) ) { 87 | unset( $options['ignore_reasons'][ $key ] ); 88 | } 89 | } 90 | 91 | if ( empty( $options['cronjob_interval'] ) ) { 92 | $options['cronjob_enable'] = 0; 93 | } 94 | 95 | if ( empty( $options['translate_lang'] ) ) { 96 | $options['translate_api'] = 0; 97 | } 98 | 99 | if ( empty( $options['reasons_enable'] ) ) { 100 | $options['ignore_reasons'] = array(); 101 | } 102 | 103 | if ( ! empty( $options['country_denied'] ) ) { 104 | $options['country_denied'] = preg_replace( 105 | '/[^A-Z ,;]/', 106 | '', 107 | strtoupper( $options['country_denied'] ) 108 | ); 109 | } 110 | 111 | if ( ! empty( $options['country_allowed'] ) ) { 112 | $options['country_allowed'] = preg_replace( 113 | '/[^A-Z ,;]/', 114 | '', 115 | strtoupper( $options['country_allowed'] ) 116 | ); 117 | } 118 | 119 | if ( empty( $options['country_denied'] ) && empty( $options['country_allowed'] ) ) { 120 | $options['country_code'] = 0; 121 | } 122 | 123 | if ( $options['cronjob_enable'] && ! self::get_option( 'cronjob_enable' ) ) { 124 | self::init_scheduled_hook(); 125 | } elseif ( ! $options['cronjob_enable'] && self::get_option( 'cronjob_enable' ) ) { 126 | self::clear_scheduled_hook(); 127 | } 128 | 129 | self::update_options( $options ); 130 | 131 | wp_safe_redirect( 132 | add_query_arg( 133 | array( 134 | 'updated' => 'true', 135 | ), 136 | wp_get_referer() 137 | ) 138 | ); 139 | 140 | die(); 141 | } 142 | 143 | /** 144 | * Generation of a selectbox 145 | * 146 | * @since 2.4.5 147 | * 148 | * @param string $name Name of the Selectbox. 149 | * @param array $data Array with values. 150 | * @param string $selected Selected value. 151 | * @return string $html Generated HTML. 152 | */ 153 | private static function _build_select( $name, $data, $selected ) { 154 | $html = ''; 159 | 160 | return $html; 161 | } 162 | 163 | 164 | /** 165 | * Display the GUI 166 | * 167 | * @since 0.1 168 | * @since 2.7.0 169 | * @since 2.10.0 Change documentation links, change country option name, and add option to parse complete markup for comment forms 170 | */ 171 | public static function options_page() { 172 | ?> 173 |
174 |

175 | Antispam Bee 176 |

177 | 178 |
179 | 180 | 181 | 182 | 183 | 184 |
185 | 186 |
187 |

188 | 189 |

190 |
191 | 192 |
193 | 194 |
    195 |
  • 196 | /> 197 | 201 |
  • 202 | 203 | 204 |
  • 205 | /> 206 | 226 |
  • 227 | 228 | 229 |
  • 230 | /> 231 | 235 |
  • 236 | 237 |
  • 238 | /> 239 | 243 |
  • 244 | 245 | 246 |
  • 247 | /> 248 | 252 |
  • 253 | 254 |
  • 255 | /> 256 | 260 |
  • 261 | 262 |
  • 263 | /> 264 | 284 | 285 |
      286 | ', 289 | 'https://www.iso.org/obp/ui/#search/code/' 290 | ); 291 | ?> 292 |
    • 293 | 294 | 306 |
    • 307 |
    • 308 | 309 | 321 |
    • 322 |
    323 |
  • 324 | 325 |
  • 326 | /> 327 | 348 | 349 |
      350 |
    • 351 | 361 | 364 |
    • 365 |
    366 |
  • 367 |
368 |
369 | 370 |
371 |

372 | 373 |

374 |
375 | 376 |
377 | 378 |
    379 |
  • 380 | /> 381 | 385 |
  • 386 | 387 |
  • 388 | /> 389 | 393 |
  • 394 | 395 |
  • 396 | /> 397 | 401 |
  • 402 | 403 |
  • 404 | /> 405 | 415 |
  • 416 | 417 |
  • 418 | /> 419 | 439 |
  • 440 | 441 |
  • 442 | /> 443 | 447 | 448 |
      449 |
    • 450 | 453 | 458 |
    • 459 |
    460 |
  • 461 | 462 |
  • 463 | /> 464 | 468 |
  • 469 |
470 | 471 |
472 | 473 | 474 |
475 |

476 | 477 |

478 |
479 | 480 |
481 | 482 |
    483 |
  • 484 | /> 485 | 489 |
  • 490 | 491 |
  • 492 | /> 493 | 497 |
  • 498 | 499 |
  • 500 | /> 501 | 505 |
  • 506 | 507 |
  • 508 | /> 509 | 520 |
  • 521 |
522 |
523 | 524 |
525 |

526 | 527 |

528 |

529 | 530 |

531 |

532 | 533 |

534 |

535 | 536 |

537 | 538 | 539 |
540 |
541 |
542 |
543 | __( 'German', 'antispam-bee' ), 556 | 'en' => __( 'English', 'antispam-bee' ), 557 | 'fr' => __( 'French', 'antispam-bee' ), 558 | 'it' => __( 'Italian', 'antispam-bee' ), 559 | 'es' => __( 'Spanish', 'antispam-bee' ), 560 | ); 561 | 562 | /** 563 | * Filter the possible languages for the language spam test 564 | * 565 | * @since 2.7.1 566 | * @param (array) $lang The languages 567 | * @return (array) 568 | */ 569 | return apply_filters( 'ab_get_allowed_translate_languages', $lang ); 570 | } 571 | } 572 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## Changelog ## 2 | 3 | ### 2.11.8 ### 4 | * **English** 5 | * Tweak: Minor code changes and housekeeping 6 | * Tweak: Add link to Patchstack in readme 7 | * Maintenance: Tested up to WordPress 6.8 8 | 9 | * **Deutsch** 10 | * Tweak: Kleinere Code-Änderungen und Aufräumarbeiten 11 | * Tweak: Link zu Patchstack in readme hinzugefügt 12 | * Wartung: Getestet mit WordPress 6.8 13 | 14 | ### 2.11.7 ### 15 | * **English** 16 | * Tweak: Use SCRIPT_NAME instead of REQUEST_URI to check path 17 | * Fix: Remove `add_reasons_to_defaults()` from general initialization for better WordPress 6.7 compatibility 18 | * Maintenance: Tested up to WordPress 6.7 19 | 20 | * **Deutsch** 21 | * Tweak: Verwende SCRIPT_NAME anstelle von REQUEST_URI, um den Pfad zu prüfen 22 | * Fix: Entfernen von `add_reasons_to_defaults()` von der allgemeinen Initialisierung für bessere WordPress 6.7 Kompatibilität 23 | * Wartung: Getestet mit WordPress 6.7 24 | 25 | ### 2.11.6 ### 26 | * **English** 27 | * Fix: Delete missed out option on uninstall (Thanks @okvee!) 28 | * Tweak: Minor i18n improvements (Thanks Pedro!) 29 | * Tweak: Minor code changes and housekeeping 30 | * Tweak: Updated dependencies 31 | 32 | * **Deutsch** 33 | * Fix: Bei Deinstallation wurde eine Option nicht korrekt gelöscht (Danke @okvee!) 34 | * Tweak: Kleinere i18n-Verbesserungen (Danke Pedro!) 35 | * Tweak: Kleinere Code-Änderungen und Aufräumarbeiten 36 | * Tweak: Aktualisierte Abhängigkeiten 37 | 38 | ### 2.11.5 ### 39 | IMPORTANT: If you use the country check and are behind a proxy or similar, you need to use the `antispam_bee_trusted_ip` filter to get the correct IP from a header like `HTTP_X_FORWARDED` (don’t return an empty value here, otherwise all comments are marked as spam). 40 | WICHTIG: Wenn du den Spam-Check für bestimmte Länder verwendest und hinter einem Proxy oder ähnlich bist, musst du den `antispam_bee_trusted_ip`-Filter verwenden, um die richtige Adresse des Users von einem Header wie `HTTP_X_FORWARDED` zu bekommen (hier darfst du keinen leeren String zurückgeben, sonst werden alle Kommentare als Spam markiert). 41 | * **English** 42 | * Fix: Usage of core filter `pre_comment_user_ip` breaks ASB if the IP address is removed for GDPR compliance 43 | 44 | * **Deutsch** 45 | * Fix: Die Verwendung des Core-Filters `pre_comment_user_ip` sorgt für Fehler, wenn die IP-Adresse für die Einhaltung der DSGVO entfernt wird 46 | 47 | ### 2.11.4 ### 48 | IMPORTANT: If you use the country check and are behind a proxy or similar, you need to use the `pre_comment_user_ip` filter to get the correct IP from a header like `HTTP_X_FORWARDED`. 49 | WICHTIG: Wenn du den Spam-Check für bestimmte Länder verwendest und hinter einem Proxy oder ähnlich bist, musst du den `pre_comment_user_ip`-Filter verwenden, um die richtige Adresse des Users von einem Header wie `HTTP_X_FORWARDED` zu bekommen. 50 | * **English** 51 | * Fix: Read client IP for country check from `REMOTE_ADDR` only (filterable via `pre_comment_user_ip`) 52 | * Fix: No spam reason in spam notification email, and related PHP warning 53 | * Fix: Remove outdated info from readme 54 | * Enhancement: Show upgrade notice on plugin overview page 55 | * Maintenance: Tested up to WordPress 6.3 56 | 57 | * **Deutsch** 58 | * Fix: Client-IP wird nur noch aus `REMOTE_ADDR` ermittelt (filterbar über `pre_comment_user_ip`) 59 | * Fix: Der Spam-Grund wird wieder korrekt in der Benachrichtigungs-E-Mail zu Spam angezeigt und die damit zusammenhängende PHP-Warning behoben 60 | * Fix: Veraltete Infos aus der Readme wurden entfernt 61 | * Verbesserung: Upgrade-Hinweis wird auch in der Plugin-Übersicht angezeigt 62 | * Wartung: Getestet mit WordPress 6.3 63 | 64 | ### 2.11.3 ### 65 | * **English** 66 | * Fix: Multiselect for "Delete comments by spam reasons" was not saving values 67 | * Fix: Fix broken link for ISO country codes 68 | * Maintenance: Added test for PHP 8.2 69 | * Maintenance: Tested up to WordPress 6.2 70 | 71 | * **Deutsch** 72 | * Behoben: Multiselect für "Kommentare aus Spamgründen löschen" speicherte keine Werte 73 | * Fix: Fehlerhafter Link für ISO-Ländercodes behoben 74 | * Wartung: Test für PHP 8.2 hinzugefügt 75 | * Wartung: Getestet mit WordPress 6.2 76 | 77 | ### 2.11.2 ### 78 | * **English** 79 | * Tweak: remove superfluous translations 80 | * Tweak: make FAQ link an anchor link 81 | * Fix: spam counter no longer raises a warning with PHP 8.1 if no spam is present yet 82 | * Fix: spam reasons are now localized correctly 83 | * Fix: Translations were loaded twice on some admin pages 84 | * Maintenance: Tested up to WordPress 6.1 85 | 86 | * **Deutsch** 87 | * Tweak: Überflüssige Übersetzungen entfernt 88 | * Tweak: Link zu den FAQ ist jetzt ein Anker-Link 89 | * Fix: Der Spam-Zähler erzeugt mit PHP 8.1 keine Warnung mehr, wenn noch kein Spam vorhanden ist 90 | * Fix: Spam-Gründe werden nun korrekt übersetzt 91 | * Fix: Übersetzungen wurden auf einzelnen Adminseiten doppelt geladen 92 | * Wartung: Getestet mit WordPress 6.1 93 | 94 | ### 2.11.1 ### 95 | * **English** 96 | * Tweak: remove superfluous type attribute from inline script tag 97 | * Maintenance: Tested up to WordPress 6.0 98 | 99 | * **Deutsch** 100 | * Tweak: Überflüssiges type-Attribut von script-Tag entfernt 101 | * Wartung: Getestet mit WordPress 6.0 102 | 103 | ### 2.11.0 ### 104 | * **English** 105 | * Fix: Allow empty comments if `allow_empty_comment` is set to true 106 | * Fix: Add `aria-label` to work around bug in a11y testing tools 107 | * Fix: Change priority for `comment_form_field_comment` from 10 to 99 108 | * Tweak: Updated some FAQ entries 109 | * Tweak: Updated build tooling 110 | 111 | * **Deutsch** 112 | * Fix: Leere Kommentare erlauben, wenn der Filter `allow_empty_comment` gesetzt ist 113 | * Fix: Ein `aria-label` hinzugefügt, um einen bekannten Fehler bei Tests zu umgehen 114 | * Fix: Änderung der Priorität vom Filter `comment_form_field_comment` von 10 auf 99 115 | * Tweak: Aktualisierungen in der FAQ 116 | * Tweak: Optimierungen am Build-Prozess 117 | 118 | ### 2.10.0 ### 119 | * **English** 120 | * Fix: Switch from ip2country.info to iplocate.io for country check 121 | * Enhancement: Use filter to add the honeypot field instead of output buffering for new installations and added option to switch between the both ways 122 | * Tweak: Added comment user agent to regex pattern check 123 | * Tweak: Make the ping detection filterable to support new comment types 124 | * Tweak: Updated internal documentation links 125 | * Tweak: Several updates and optimizations in the testing process 126 | * Tweak: Adjust color palette to recent WP version 127 | * Tweak: Adjust wording in variables and option names 128 | * Readme: Add new contributor and clean up unused code 129 | 130 | * **Deutsch** 131 | * Fix: Wechsel von ip2country.info zu iplocate.io für die Länderprüfung 132 | * Verbesserung: Bei neuen Installationen wird ein Filter zum Hinzufügen des Honeypot-Felds genutzt statt Output-Buffering. Es wurde eine Option hinzugefügt, zwischen den beiden Wegen zu wechseln 133 | * Tweak: Kommentar User-Agent zu Regex-Pattern hinzugefügt 134 | * Tweak: Die Ping-Erkennung ist jetzt filterbar, um neue Kommentartypen zu unterstützen 135 | * Tweak: Aktualisierte Links zur internen Dokumentation 136 | * Tweak: Verschiedene Aktualisierungen und Optimierungen im Testprozess 137 | * Tweak: Farbpalette an aktuelle WP-Version anpassen 138 | * Tweak: Wortlaut in Variablen und Optionsnamen wurden angepasst 139 | * Readme: Neuer Contributor hinzugefügt und unbenutzten Code bereinigt 140 | 141 | ### 2.9.4 ### 142 | * **English** 143 | * Enhancement: Add filter to allow ajax calls 144 | * Tweak: Better wording for BBCode feature in plugin description 145 | * Tweak: Better screenshots in the plugin directory 146 | * Maintenance: Tested up to WordPress 5.7 147 | 148 | * **Deutsch** 149 | * Verbesserung: Filter hinzugefügt, um Ajax-Aufrufe zuzulassen 150 | * Tweak: Bessere Formulierung für BBCode-Funktion in Plugin-Beschreibung 151 | * Tweak: Bessere Screenshots im Plugin-Verzeichnis 152 | * Wartung: Getestet mit WordPress 5.7 153 | 154 | ### 2.9.3 ### 155 | * **English** 156 | * Fixed: Compatibility with WordPress 5.5 157 | * Fixed: Undefined index on spam list page 158 | * Tweak: Better wording on settings page 159 | * Tweak: AMP compatibility 160 | * Tweak: Protect CSS from overwrite through bad themes 161 | 162 | * **Deutsch** 163 | * Fix: Kompatibilität mit WordPress 5.5 164 | * Fix: Undefined index in Spamliste 165 | * Tweak: Inklusivere Sprache unter Einstellungen 166 | * Tweak: AMP-Kompatibilität 167 | * Tweak: Schütze CSS besser vor Überschreiben durch schlechte Themes 168 | 169 | ### 2.9.2 ### 170 | * **English** 171 | * Fix: Delete comment meta for deleted old spam. For the cleanup of older orphaned comment meta we suggest the usage of [WP Sweep](https://wordpress.org/plugins/wp-sweep/) 172 | * Fix: Statistic in dashboard showed wrong value 173 | * Tweak: Change autocomplete attribute to "new-password" 174 | * Tweak: Autoptimize compatibility improved 175 | * Tweak: Renamed blacklist/whitelist to a better phrase 176 | * Tweak: Added new pattern 177 | * Tweak: UI and text optimizations 178 | * Tweak: Better compatibility with some server configurations 179 | * Tweak: Make spam reason sortable and filterable 180 | * Tweak: Add spam reason for manually marked spam 181 | * Maintenance: Deleted unused code 182 | * Maintenance: Removed Fake IP check (unreliable and producing false positives) 183 | * Maintenance: Fix some coding standard issues 184 | * Maintenance: Tested up to WordPress 5.4 185 | * Maintenance: Tested up to PHP 7.4 186 | 187 | 188 | * **Deutsch** 189 | * Fix: Lösche Kommentarmeta beim Löschen von Spamkommentaren. Für das Aufräumen alter verwaister Kommentarmetas empfehlen wir die Verwendung von [WP Sweep](https://de.wordpress.org/plugins/wp-sweep/) 190 | * Fix: Dashboard Statistiken zeigten falschen Wert 191 | * Tweak: Änderung des autocomplete Attributs zu "new-password" 192 | * Tweak: Kompatibilität mit Autoptimize verbessert 193 | * Tweak: "Blacklist/Whitelist" umbenannt 194 | * Tweak: Neue Spamerkennungsmuster hinzugefügt 195 | * Tweak: UI und Textverbesserungen 196 | * Tweak: Erhöhte Kompatibilität mit einigen Serverkonfigurationen 197 | * Tweak: Kommentare nach Spamgrund sortier- und filterbar gemacht 198 | * Tweak: Neuer Spamgrund für manuell markierten Spam eingeführt 199 | * Maintenance: Ungenutzter Code wurde gelöscht 200 | * Maintenance: Der Fake IP check wurde entfernt. Dieser war unzuverlässig und produzierte falsche Ergebnisse 201 | * Maintenance: Einige Probleme mit unseren Coding standards wurden gefixt 202 | * Maintenance: Getestet bis WordPress 5.4 203 | * Maintenance: Getestet bis PHP 7.4 204 | 205 | ### 2.9.1 ### 206 | * **English** 207 | * Improved backend accessibility 208 | * Prefilled comment textareas do now work with the honeypot 209 | * Compatible with the AMP plugin (https://wordpress.org/plugins/amp/) 210 | * Improved dashboard tooltips 211 | * Improvements for the language detection API 212 | * Scalable IP look up for local spam database 213 | 214 | 215 | * **Deutsch** 216 | * Verbesserte Barrierefreiheit im Backend 217 | * Vorausgefüllte Kommentarfelder arbeiten jetzt mit dem Honeypot zusammen 218 | * Kompatibel mit dem AMP Plugin (https://wordpress.org/plugins/amp/) 219 | * Verbesserte Tooltips im Dashboard 220 | * Verbesserte Kommunikation mit der Spracherkennungs-API 221 | * Skalierbarer IP-Abgleich für den lokalen Datenbank-Check. 222 | 223 | ### 2.9.0 ### 224 | * **English** 225 | * Introduction of coding standards. 226 | * Switch to franc language detection API for the language check. 227 | * Do not longer overwrite the IP address WordPress saves with the comment by using `pre_comment_user_ip`. 228 | * Do not show "Trust commenters with a Gravatar" if the "Show Gravatar" option is not set. 229 | * Skip the checks, when I ping myself. 230 | * Fixes some wrong usages of the translation functions. 231 | * Use the regular expressions check also for trackbacks. 232 | * Add option to delete Antispam Bee related data when plugin gets deleted via the admin interface. 233 | * Save a hashed + salted IP for every comment 234 | * New check for incoming Trackbacks. 235 | * Introduction of behat tests. 236 | * Updates the used JavaScript library for the statistics widget. 237 | * Bugfix in the "Comment form used outside of posts" option. 238 | 239 | * **Deutsch** 240 | * Einführung von Coding Standards. 241 | * Wechsel auf die Franc Spracherkennungs API für den Sprach-Check. 242 | * Beendet das Überschreiben der IP Adresse via `pre_comment_user_ip`, welche WordPress mit dem Kommentar speichert. 243 | * Zeige die Option "Vertraue Kommentaren mit Gravatar" nur an wenn die Option "Zeige Gravatar" aktiviert ist. 244 | * Überspringe die Filter, wenn ich mich selbst anpinge. 245 | * Repariert einige falsche Verwendungsweisen der Übersetzungsfunktionalitäten. 246 | * Wende den reguläre Ausdrücke Check auch auf Trackbacks an. 247 | * Option hinzugefügt, dass Daten von Antispam Bee gelöscht werden, wenn das Plugin über das Admin Interface gelöscht wird. 248 | * Speichere für jeden Kommentar eine salted Hash der IP Adresse. 249 | * Ein neuer Check für eingehende Trackbacks. 250 | * Einführung von Behat tests. 251 | * Aktualisiert die genutzte JavaScript Bibliothek für das Statistik Widget. 252 | * Bugfix in der "Kommentarformular wird außerhalb von Beiträgen verwendet" Einstellung 253 | 254 | ### 2.8.1 ### 255 | 256 | * **English** 257 | * PHP 5.3 compatibility 258 | * Bugfix where a spam trackback produced a fatal error 259 | * For more details see https://github.com/pluginkollektiv/antispam-bee/milestone/8?closed=1 260 | 261 | * **Deutsch** 262 | * PHP 5.3 Kompatibilität wieder hergestellt 263 | * Bugfix: Ein Spam Trackback produzierte einen Fatal Error 264 | * Mehr Details: https://github.com/pluginkollektiv/antispam-bee/milestone/8?closed=1 265 | 266 | ### 2.8.0 ### 267 | 268 | * **English** 269 | * Removed stopforumspam.com to avoid potential GDPR violation 270 | * Improves IP handling to comply with GDPR 271 | * Improves PHP7.2 compatibility 272 | * Fixes small bug on mobile views 273 | * Allow more than one language in language check 274 | * Minor interface improvements 275 | * Remove old russian and Dutch translation files 276 | * For more details see https://github.com/pluginkollektiv/antispam-bee/milestone/4?closed=1 277 | 278 | * **Deutsch** 279 | - Entfernt stopforumspam.com zur Vorbeugung möglicher DSGVO-Verletzungen 280 | - Verändert den Umgang mit IP-Adressen um der DSGVO zu entsprechen 281 | - Verbessert PHP7.2-Kompatibilität 282 | - Behebt einen CSS-Bugfix der mobilen Darstellung 283 | - Erlaube mehr als eine Sprache im Sprachencheck 284 | - Verberesserungen an der Benutzeroberfläche 285 | - Entfernt alte russische und holländische Sprachversionen 286 | - Mehr Details: https://github.com/pluginkollektiv/antispam-bee/milestone/4?closed=1 287 | 288 | ### 2.7.1 ### 289 | 290 | * **English** 291 | * Fixes an incompatibility with Chrome autofill 292 | * Fixes some incompatibilities with other plugins/themes where the comment field was left empty 293 | * Support for RTL 294 | * Solve some translation/language issues 295 | * A new filter to add languages to the language check 296 | * For more details see https://github.com/pluginkollektiv/antispam-bee/milestone/6?closed=1 297 | * **Deutsch** 298 | - Behebt eine Inkompatibilität mit Chromes Autofill-Funktion 299 | - Behebt einige Inkompatibilitäten mit anderen Plugins/Themes, wo das Kommentarfeld leer bliebt 300 | - Unterstützt RTL-Sprachen 301 | - Behebt einige Probleme im Bereich Sprache/Übersetzung 302 | - Bietet einen neuen Filter zum HInzufügen von Sprachen zum Sprach-Check 303 | - Mehr Details: https://github.com/pluginkollektiv/antispam-bee/milestone/6?closed=1 304 | 305 | ### 2.7.0 ### 306 | * **English** 307 | * Country check is back again (thanks to Sergej Müller for his amazing work and the service page) 308 | * Improved Honeypot 309 | * Language check through Google Translate API is back again (thanks to [Simon Kraft](https://simonkraft.de/) for offering to cover the costs) 310 | * More default Regexes 311 | * Unit Test Framework 312 | * Accessibility and GUI improvements 313 | * An [english documentation](https://github.com/pluginkollektiv/antispam-bee/wiki) is now available, too. Some corrections in the german documentation. 314 | * Some bugfixes - Among other things for WPML compatibility 315 | * For more details see https://github.com/pluginkollektiv/antispam-bee/milestone/3?closed=1 316 | 317 | * **Deutsch** 318 | * Die Länderprüfung ist wieder zurück (dank an Sergej Müller für seine fantastische Arbeit und die Service-Seite) 319 | * Der Honeypot wurde verbessert 320 | * Die Sprachenprüfung über die Google Translate API ist wieder zurück (Dank an [Simon Kraft](https://simonkraft.de/), der sich angeboten hat, die Kosten zu übernehmen) 321 | * Mehr Standard-Regexe 322 | * Verbesserungen an Barrierefreiheit und Benutzer-Oberfläche 323 | * Eine [englische Dokumentation](https://github.com/pluginkollektiv/antispam-bee/wiki) ist jetzt verfügbar. Einige Korrekturen in der deutschen Dokumentation. 324 | * Einige Fehlerkorrekturen - Unter anderem für WPML-Kompatibilität 325 | * Mehr Details: https://github.com/pluginkollektiv/antispam-bee/milestone/3?closed=1 326 | 327 | ### 2.6.9 ### 328 | * **English** 329 | * Updates donation links throughout the plugin 330 | * Fixes an error were JavaScript on the dashboard was erroneously being enqueued 331 | * Ensures compatibility with the latest WordPress version 332 | * **Deutsch** 333 | * Aktualisierung der Spenden Links im gesamten Plugin 334 | * Behebt einen Fehler, durch den auf dem Dashboard fälschlicherweise JavaScript geladen wird 335 | * Gewährleistet die Kompatibilität mit der neuesten WordPress-Version 336 | 337 | ### 2.6.8 ### 338 | * **English** 339 | * added a POT file 340 | * updated German translation, added formal version 341 | * updated plugin text domain to include a dash instead of an underscore 342 | * updated, translated + formatted README.md 343 | * updated expired link URLs in plugin and languages files 344 | * updated [plugin authors](https://gist.github.com/glueckpress/f058c0ab973d45a72720) 345 | * **Deutsch** 346 | * eine POT-Datei hinzugefügt 347 | * deutsche Übersetzung aktualisiert, formale Version hinzugefügt 348 | * Die Text Domain des Plugins in der ReadMe aktualisiert. Statt einem Unterstrich enthält der Name nun ein Bindestrich. 349 | * README.md aktualisiert, übersetzt und formatiert 350 | * verwaiste Link-Adressen in dem Plugin und den Sprachdateien aktualisiert 351 | * [Plugin Autor](https://gist.github.com/glueckpress/f058c0ab973d45a72720) aktualisiert 352 | 353 | ### 2.6.7 ### 354 | * **English** 355 | * Removal of functions *Block comments from specific countries* and *Allow comments only in certain language* for financial reasons 356 | * **Deutsch** 357 | * Entfernung der Funktionen *Kommentare nur in einer Sprache zulassen* und *Bestimmte Länder blockieren bzw. erlauben* aus finanziellen Gründen - [Hintergrund-Informationen](https://antispambee.pluginkollektiv.org/news/2015/removal-of-allow-comments-only-in-certain-language/) 358 | 359 | ### 2.6.6 ### 360 | * **English** 361 | * Switch to the official Google Translation API 362 | * *Release time investment (Development & QA): 2.5 h* 363 | * **Deutsch** 364 | * (Testweise) Umstellung auf die offizielle Google Translation API 365 | * *Release-Zeitaufwand (Development & QA): 2,5 Stunden* 366 | 367 | ### 2.6.5 ### 368 | * **English** 369 | * Fix: Return parameters on `dashboard_glance_items` callback / thx [@toscho](https://twitter.com/toscho) 370 | * New function: [Trust commenters with a Gravatar](https://antispambee.pluginkollektiv.org/documentation#gravatar) / thx [@glueckpress](https://twitter.com/glueckpress) 371 | * Additional plausibility checks and filters 372 | * *Release time investment (Development & QA): 12 h* 373 | * **Deutsch** 374 | * Fix: Parameter-Rückgabe bei `dashboard_glance_items` / thx [@toscho](https://twitter.com/toscho) 375 | * Neue Funktion: [Kommentatoren mit Gravatar vertrauen](https://antispambee.pluginkollektiv.org/de/dokumentation#gravatar) / thx [@glueckpress](https://twitter.com/glueckpress) 376 | * Zusätzliche Plausibilitätsprüfungen und Filter 377 | * *Release-Zeitaufwand (Development & QA): 12 Stunden* 378 | 379 | ### 2.6.4 ### 380 | * **English** 381 | * Consideration of the comment time (Spam if a comment was written in less than 5 seconds) 382 | * *Release time investment (Development & QA): 6.25 h* 383 | * **Deutsch** 384 | * Berücksichtigung der Kommentarzeit (Spam, wenn ein Kommentar in unter 5 Sekunden verfasst) - [Hintergrund-Informationen](https://antispambee.pluginkollektiv.org/news/2014/antispam-bee-2-6-4/) 385 | * *Release-Zeitaufwand (Development & QA): 6,25 Stunden* 386 | 387 | ### 2.6.3 ### 388 | * **English** 389 | * Sorting for the Antispam Bee column in the spam comments overview 390 | * Code refactoring around the use of REQUEST_URI 391 | * *Release time investment (Development & QA): 2.75 h* 392 | * **Deutsch** 393 | * Sortierung für die Antispam Bee Spalte in der Spam-Übersicht 394 | * Code-Refactoring rund um die Nutzung von REQUEST_URI 395 | * *Release-Zeitaufwand (Development & QA): 2,75 Stunden* 396 | 397 | ### 2.6.2 ### 398 | * **English** 399 | * Improving detection of fake IPs 400 | * *Release time investment (Development & QA): 11 h* 401 | * **Deutsch** 402 | * Überarbeitung der Erkennung von gefälschten IPs 403 | * *Release-Zeitaufwand (Development & QA): 11 Stunden* 404 | 405 | ### 2.6.1 ### 406 | * **English** 407 | * Code refactoring of options management 408 | * Support for `HTTP_FORWARDED_FOR` header 409 | * *Release time investment (Development & QA): 8.5 h* 410 | * **Deutsch** 411 | * Überarbeitung der Optionen-Verwaltung 412 | * Berücksichtigung der Header `HTTP_FORWARDED_FOR` 413 | * *Release-Zeitaufwand (Development & QA): 8,5 Stunden* 414 | 415 | ### 2.6.0 ### 416 | * **English** 417 | * Optimizations for WordPress 3.8 418 | * Clear invalid UTF-8 characters in comment fields 419 | * Spam reason as a column in the table with spam comments 420 | * **Deutsch** 421 | * Optimierungen für WordPress 3.8 422 | * Zusatzprüfung auf Nicht-UTF-8-Zeichen in Kommentardaten 423 | * Spamgrund als Spalte in der Übersicht mit Spamkommentaren 424 | 425 | ### 2.5.9 ### 426 | * **English** 427 | * Dashboard widget changes to work with [Statify](http://statify.de) 428 | * **Deutsch** 429 | * Anpassung des Dashboard-Skriptes für die Zusammenarbeit mit [Statify](http://statify.de) 430 | 431 | ### 2.5.8 ### 432 | * **English** 433 | * Switch from TornevallDNSBL to [Stop Forum Spam](http://www.stopforumspam.com) 434 | * New JS library for the Antispam Bee dashboard chart 435 | * **Deutsch** 436 | * Umstellung von TornevallDNSBL zu [Stop Forum Spam](http://www.stopforumspam.com) 437 | * Neue JS-Bibliothek für das Dashboard-Widget 438 | 439 | ### 2.5.7 ### 440 | * **English** 441 | * Optional logfile with spam entries e.g. for [Fail2Ban](https://help.ubuntu.com/community/Fail2ban) 442 | * Filter `antispam_bee_notification_subject` for a custom subject in notifications 443 | * **Deutsch** 444 | * Optionale Spam-Logdatei z.B. für [Fail2Ban](https://wiki.ubuntuusers.de/fail2ban/) 445 | * Filter `antispam_bee_notification_subject` für eigenen Betreff in Benachrichtigungen 446 | 447 | ### 2.5.6 ### 448 | * **English** 449 | * [Added new detection/patterns for spam comments](https://antispambee.pluginkollektiv.org/news/2013/new-patterns-in-antispam-bee-2-5-6/) 450 | * **Deutsch** 451 | * [Neue Erkennungsmuster für Spam hinzugefügt](https://antispambee.pluginkollektiv.org/de/news/2013/neue-erkennungsmuster-in-antispam-bee-2-5-6/) 452 | 453 | ### 2.5.5 ### 454 | * **English** 455 | * Detection and filtering of spam comments that try to exploit the latest [W3 Total Cache and WP Super Cache Vulnerability](http://blog.sucuri.net/2013/05/w3-total-cache-and-wp-super-cache-vulnerability-being-targeted-in-the-wild.html). 456 | * **Deutsch** 457 | * Erkennung und Ausfilterung von Spam-Kommentaren, die versuchen, [Sicherheitslücken von W3 Total Cache und WP Super Cache](http://blog.sucuri.net/2013/05/w3-total-cache-and-wp-super-cache-vulnerability-being-targeted-in-the-wild.html) auszunutzen. [Ausführliche Informationen](https://antispambee.pluginkollektiv.org/de/news/2013/antispam-bee-nun-auch-als-antimalware-plugin/). 458 | 459 | ### 2.5.4 ### 460 | * **English** 461 | * Jubilee edition 462 | * New mascot for Antispam Bee 463 | * Advanced Scanning on IP, URL and e-mail address of incoming comments in local blog spam database 464 | * **Deutsch** 465 | * Jubiläumsausgabe: [Details zum Update](https://plus.googlehttps://antispambee.pluginkollektiv.org/de/news/2013/jubilaeumsausgabe-antispam-bee-2-5-4/) 466 | * Neues Maskottchen für Antispam Bee 467 | * Erweiterte Prüfung eingehender Kommentare in lokaler Blog-Spamdatenbank auf IP, URL und E-Mail-Adresse 468 | 469 | ### 2.5.3 ### 470 | * **English** 471 | * Optimization of regular expression 472 | * **Deutsch** 473 | * Optimierung des Regulären Ausdrucks 474 | 475 | ### 2.5.2 ### 476 | * **English** 477 | * New: Use of regular expressions with predefined and own identification patterns 478 | * Change the filter order 479 | * Improvements to the language file 480 | * **Deutsch** 481 | * Neu: [Reguläre Ausdrücke anwenden](hhttps://antispambee.pluginkollektiv.org/de/dokumentation#regex) mit vordefinierten und eigenen Erkennungsmustern 482 | * Änderung der Filter-Reihenfolge 483 | * Verbesserungen an der Sprachdatei 484 | 485 | ### 2.5.1 ### 486 | * **English** 487 | * Treat BBCode as spam 488 | * IP anonymization in the country evaluation 489 | * More transparency by added Privacy Policy 490 | * PHP 5.2.4 as a requirement (is also the prerequisite for WP 3.4) 491 | * **Deutsch** 492 | * [BBCode im Kommentar als Spamgrund](hhttps://antispambee.pluginkollektiv.org/de/dokumentation#bbcode) 493 | * IP-Anonymisierung bei der Länderprüfung 494 | * [Mehr Transparenz](https://antispambee.pluginkollektiv.org/de/news/2012/datenschutz-update/) durch hinzugefügte Datenschutzhinweise 495 | * PHP 5.2.4 als Voraussetzung (ist zugleich die Voraussetzung für WP 3.4) 496 | 497 | ### 2.5.0 ### 498 | * **English** 499 | * [Edition 2012](https://antispambee.pluginkollektiv.org/news/2012/edition-2012/) 500 | * **Deutsch** 501 | * [Edition 2012](https://antispambee.pluginkollektiv.org/de/news/2012/edition-2012/) 502 | 503 | ### 2.4.6 ### 504 | * **English** 505 | * Russian translation 506 | * Change the secret string 507 | * **Deutsch** 508 | * Russische Übersetzung 509 | * Veränderung der Secret-Zeichenfolge 510 | 511 | ### 2.4.5 ### 512 | * **English** 513 | * Revised layout settings 514 | * Deletion of Project Honey Pot 515 | * TornevallNET as new DNSBL service 516 | * WordPress 3.4 as a minimum requirement 517 | * WordPress 3.5 support 518 | * Recast of the online manual 519 | * **Deutsch** 520 | * Überarbeitetes Layout der Einstellungen 521 | * Streichung von Project Honey Pot 522 | * TornevallNET als neuer DNSBL-Dienst 523 | * WordPress 3.4 als Mindestvoraussetzung 524 | * WordPress 3.5 Unterstützung 525 | * Neufassung des Online-Handbuchs 526 | 527 | ### 2.4.4 ### 528 | * **English** 529 | * Technical and visual support for WordPress 3.5 530 | * Modification of the file structure: from `xyz.dev.css` to `xyz.min.css` 531 | * Retina screenshot 532 | * **Deutsch** 533 | * Technische und optische Unterstützung für WordPress 3.5 534 | * Änderung der Dateistruktur: von `xyz.dev.css` zu `xyz.min.css` 535 | * Retina Bildschirmfoto 536 | 537 | ### 2.4.3 ### 538 | * **English** 539 | * Check for basic requirements 540 | * Remove the sidebar plugin icon 541 | * Set the Google API calls to SSL 542 | * Compatibility with WordPress 3.4 543 | * Add retina plugin icon on options 544 | * Depending on WordPress settings: anonymous comments allowed 545 | * **Deutsch** 546 | * Mindestvoraussetzungen werden nun überprüft 547 | * Entfernung des Plugin Icons in der Sidebar 548 | * Google API Aufrufe auf SSL umgestellt 549 | * Kompatibilität mit WordPress 3.4 550 | * Retina Plugin Icon in den Einstellungen hinzugefügt 551 | * In Abhängigkeit zu den Wordpress-Einstellungen: anonyme Kommentare erlauben 552 | 553 | ### 2.4.2 ### 554 | * **English** 555 | * New geo ip location service (without the api key) 556 | * Code cleanup: Replacement of `@` characters by a function 557 | * JS-Fallback for missing jQuery UI 558 | * **Deutsch** 559 | * Neuer IP-Geolocation-Dienst (ohne api key) 560 | * Quelltext aufgeräumt: Austausch von `@` Zeichen durch eine Funktion 561 | * S-Fallback für fehlende jQuery UI 562 | 563 | ### 2.4.1 ### 564 | * **English** 565 | * Add russian translation 566 | * Fix for the textarea replace 567 | * Detect and hide admin notices 568 | * **Deutsch** 569 | * Russian Übersetzung hinzugefügt 570 | * Fehlerbehebung bei dem ersetzten Textfeld 571 | * Erkennen und verstecken von Admin-Mitteilungen 572 | 573 | ### 2.4 ### 574 | * **English** 575 | * Support for IPv6 576 | * Source code revision 577 | * Delete spam by reason 578 | * Changing the user interface 579 | * Requirements: PHP 5.1.2 and WordPress 3.3 580 | * **Deutsch** 581 | * Unterstützung für IPv6 582 | * Quellcode Überarbeitung 583 | * Spam mit Begründung löschen 584 | * Änderung der Benutzeroberfläche 585 | * Voraussetzungen: PHP 5.1.2 und WordPress 3.3 586 | 587 | ### 2.3 ### 588 | * **English** 589 | * Xmas Edition 590 | * **Deutsch** 591 | * Weihnachtsausgabe 592 | 593 | ### 2.2 ### 594 | * **English** 595 | * Interactive Dashboard Stats 596 | * **Deutsch** 597 | * Interaktive Dashboard Statistik 598 | 599 | ### 2.1 ### 600 | * **English** 601 | * Remove Google Translate API support 602 | * **Deutsch** 603 | * Google Translate API Unterstützung entfernt 604 | 605 | ### 2.0 ### 606 | * **English** 607 | * Allow comments only in certain language (English/German) 608 | * Consider comments which are already marked as spam 609 | * Dashboard Stats: Change from canvas to image format 610 | * System requirements: WordPress 2.8 611 | * Removal of the migration script 612 | * Increase plugin security 613 | * **Deutsch** 614 | * Kommentare nur in bestimmten Sprachen erlauben (Englisch/Deutsch) 615 | * Das Plugin kann nun Kommentare berücksichtigen, die bereits als Spam markiert wurden 616 | * Dashboard-Statistik: Wechsel von canvas zu einem Bildformat 617 | * Systemvoraussetzungen: WordPress 2.8 618 | * Entfernung des Migrationsscriptes 619 | * Plugin Sicherheit verbessert 620 | 621 | ### 1.9 ### 622 | * **English** 623 | * Dashboard History Stats (HTML5 Canvas) 624 | * **Deutsch** 625 | * Dashboard Statistiken (HTML5 Canvas) 626 | 627 | ### 1.8 ### 628 | * **English** 629 | * Support for the new IPInfoDB API (including API Key) 630 | * **Deutsch** 631 | * Unterstützung der neuen IPInfoDB API (einschließlich API-Key) 632 | 633 | ### 1.7 ### 634 | * **English** 635 | * Black and whitelisting for specific countries 636 | * "Project Honey Pot" as a optional spammer source 637 | * Spam reason in the notification email 638 | * Visual refresh of the notification email 639 | * Advanced GUI changes + Fold-out options 640 | * **Deutsch** 641 | * Schwarze und weiße Liste für bestimmte Länder 642 | * "Project Honey Pot" als optionale Spammer-Quelle 643 | * Spam-Begründung in der E-Mail-Benachrichtigung 644 | * Visuelle Überarbeitung der E-Mail-Benachrichtigung 645 | * Erweiterte Benutzeroberflächenanpassungen + ausklappbare Einstellungen 646 | 647 | ### 1.6 ### 648 | * **English** 649 | * Support for WordPress 3.0 650 | * System requirements: WordPress 2.7 651 | * Code optimization 652 | * **Deutsch** 653 | * Unterstützung für WordPress 3.0 654 | * Systemvoraussetzungen: WordPress 2.7 655 | * Quelltext optimiert 656 | 657 | ### 1.5 ### 658 | * **English** 659 | * Compatibility with WPtouch 660 | * Add support for do_action 661 | * Translation to Portuguese of Brazil 662 | * **Deutsch** 663 | * Kompatibilität mit WPtouch 664 | * Unterstützung für do_action hinzugefügt 665 | * Übersetzung auf brasilianisches Portugiesisch 666 | 667 | ### 1.4 ### 668 | * **English** 669 | * Enable stricter inspection for incomming comments 670 | * Do not check if the author has already commented and approved 671 | * **Deutsch** 672 | * strengere Kontrolle für eingehende Kommentare aktiviert 673 | * Nicht auf Spam überprüfen, wenn der Autor bereits kommentiert hat und freigegeben wurde 674 | 675 | ### 1.3 ### 676 | * **English** 677 | * New code structure 678 | * Email notifications about new spam comments 679 | * Novel Algorithm: Advanced spam checking 680 | * **Deutsch** 681 | * Neue Quelltextstruktur 682 | * E-Mail-Benachrichtigungen über neue Spam-Kommentare 683 | * Neuartiger Algorithmus: Erweiterte Spamprüfung 684 | 685 | ### 1.2 ### 686 | * **English** 687 | * Antispam Bee spam counter on dashboard 688 | * **Deutsch** 689 | * Antispam Bee Spam-Zähler auf dem Dashboard 690 | 691 | ### 1.1 ### 692 | * **English** 693 | * Adds support for WordPress new changelog readme.txt standard 694 | * Various changes for more speed, usability and security 695 | * **Deutsch** 696 | * Unterstützung des neuen readme.txt Standards für das Änderungsprotokoll hinzugefügt 697 | * Verschiedene Änderungen für mehr Geschwindigkeit, Benutzerfreundlichkeit und Sicherheit 698 | 699 | ### 1.0 ### 700 | * **English** 701 | * Adds WordPress 2.8 support 702 | * **Deutsch** 703 | * WordPress 2.8 Unterstützung hinzugefügt 704 | 705 | ### 0.9 ### 706 | * **English** 707 | * Mark as spam only comments or only pings 708 | * **Deutsch** 709 | * nur Kommentare oder nur Pings als Spam markieren 710 | 711 | ### 0.8 ### 712 | * **English** 713 | * Optical adjustments of the settings page 714 | * Translation for Simplified Chinese, Spanish and Catalan 715 | * **Deutsch** 716 | * Optische Anpassungen der Einstellungsseite 717 | * Übersetzung für vereinfachtes Chinesisch, Spanisch und Katalanisch 718 | 719 | ### 0.7 ### 720 | * **English** 721 | * Spam folder cleanup after X days 722 | * Optional hide the "MARKED AS SPAM" note 723 | * Language support for Italian and Turkish 724 | * **Deutsch** 725 | * Spam-Ordner Bereinigung nach n Tagen 726 | * Optionales verstecken des "als Spam markiert" Hinweises 727 | * Übersetzungen für Italienisch und Türkisch 728 | 729 | ### 0.6 ### 730 | * **English** 731 | * Language support for English, German, Russian 732 | * **Deutsch** 733 | * Übersetzungen für Englisch, Deutsch und Russisch 734 | 735 | ### 0.5 ### 736 | * **English** 737 | * Workaround for empty comments 738 | * **Deutsch** 739 | * Problembehebung für leere Kommentare 740 | 741 | ### 0.4 ### 742 | * **English** 743 | * Option for trackback and pingback protection 744 | * **Deutsch** 745 | * Einstellung für den Trackback- und Pingback-Schutz 746 | 747 | ### 0.3 ### 748 | * **English** 749 | * Trackback and Pingback spam protection 750 | * **Deutsch** 751 | * Trackback und Pingback Spam-Schutz 752 | -------------------------------------------------------------------------------- /antispam_bee.php: -------------------------------------------------------------------------------- 1 | 0, 374 | ), 375 | '', 376 | 'no' 377 | ); 378 | 379 | if ( self::get_option( 'cronjob_enable' ) ) { 380 | self::init_scheduled_hook(); 381 | } 382 | } 383 | 384 | 385 | /** 386 | * Action to deactivate the plugin 387 | * 388 | * @since 0.1 389 | * @since 2.4 390 | */ 391 | public static function deactivate() { 392 | self::clear_scheduled_hook(); 393 | } 394 | 395 | 396 | /** 397 | * Action deleting the plugin 398 | * 399 | * @since 2.4 400 | */ 401 | public static function uninstall() { 402 | if ( ! self::get_option( 'delete_data_on_uninstall' ) ) { 403 | return; 404 | } 405 | global $wpdb; 406 | 407 | delete_option( 'antispam_bee' ); 408 | delete_option( 'antispambee_db_version' ); 409 | $wpdb->query( 'OPTIMIZE TABLE `' . $wpdb->options . '`' ); 410 | 411 | //phpcs:disable WordPress.DB.PreparedSQL.NotPrepared 412 | $sql = 'delete from `' . $wpdb->commentmeta . '` where `meta_key` IN ("antispam_bee_iphash", "antispam_bee_reason")'; 413 | $wpdb->query( $sql ); 414 | //phpcs:enable WordPress.DB.PreparedSQL.NotPrepared 415 | } 416 | 417 | 418 | 419 | /* 420 | * ############################ 421 | * ######## INTERNAL ######## 422 | * ############################ 423 | */ 424 | 425 | /** 426 | * Initialization of the internal variables 427 | * 428 | * @since 2.4 429 | * @since 2.7.0 430 | * @since 2.10.0 Change renamed country option names in options array 431 | */ 432 | private static function _init_internal_vars() { 433 | self::$_base = plugin_basename( __FILE__ ); 434 | 435 | $salt = defined( 'NONCE_SALT' ) ? NONCE_SALT : ABSPATH; 436 | self::$_salt = substr( sha1( $salt ), 0, 10 ); 437 | 438 | self::$defaults = array( 439 | 'options' => array( 440 | 'regexp_check' => 1, 441 | 'spam_ip' => 1, 442 | 'already_commented' => 1, 443 | 'gravatar_check' => 0, 444 | 'time_check' => 0, 445 | 'ignore_pings' => 0, 446 | 447 | 'dashboard_chart' => 0, 448 | 'dashboard_count' => 0, 449 | 450 | 'country_code' => 0, 451 | 'country_denied' => '', 452 | 'country_allowed' => '', 453 | 454 | 'translate_api' => 0, 455 | 'translate_lang' => array(), 456 | 457 | 'bbcode_check' => 1, 458 | 459 | 'flag_spam' => 1, 460 | 'email_notify' => 0, 461 | 'no_notice' => 0, 462 | 'cronjob_enable' => 0, 463 | 'cronjob_interval' => 0, 464 | 465 | 'ignore_filter' => 0, 466 | 'ignore_type' => 0, 467 | 468 | 'reasons_enable' => 0, 469 | 'ignore_reasons' => array(), 470 | 471 | 'delete_data_on_uninstall' => 1, 472 | ), 473 | ); 474 | } 475 | 476 | /** 477 | * Adds spam reason labels to the `$defaults` array. 478 | * 479 | * That is done in an extra method instead of `_init_internal_vars` 480 | * so that the translations are loaded before. 481 | * 482 | * @since 2.11.2 483 | */ 484 | public static function add_reasons_to_defaults() { 485 | self::$defaults['reasons'] = array( 486 | 'css' => esc_attr__( 'Honeypot', 'antispam-bee' ), 487 | 'time' => esc_attr__( 'Comment time', 'antispam-bee' ), 488 | 'empty' => esc_attr__( 'Empty Data', 'antispam-bee' ), 489 | 'localdb' => esc_attr__( 'Local DB Spam', 'antispam-bee' ), 490 | 'server' => esc_attr__( 'Fake IP', 'antispam-bee' ), 491 | 'country' => esc_attr__( 'Country Check', 'antispam-bee' ), 492 | 'bbcode' => esc_attr__( 'BBCode', 'antispam-bee' ), 493 | 'lang' => esc_attr__( 'Comment Language', 'antispam-bee' ), 494 | 'regexp' => esc_attr__( 'Regular Expression', 'antispam-bee' ), 495 | 'title_is_name' => esc_attr__( 'Identical Post title and blog title', 'antispam-bee' ), 496 | 'manually' => esc_attr__( 'Manually', 'antispam-bee' ), 497 | ); 498 | } 499 | 500 | /** 501 | * Check and return an array key 502 | * 503 | * @since 2.4.2 504 | * @since 2.10.0 Only return `null` if option does not exist. 505 | * 506 | * @param array $array Array with values. 507 | * @param string $key Name of the key. 508 | * @return mixed Value of the requested key. 509 | */ 510 | public static function get_key( $array, $key ) { 511 | if ( empty( $array ) || empty( $key ) || ! isset( $array[ $key ] ) ) { 512 | return null; 513 | } 514 | 515 | return $array[ $key ]; 516 | } 517 | 518 | /** 519 | * Check if comment is a ping (pingback, trackback or something similar) 520 | * 521 | * @since 2.10.0 522 | * 523 | * @param array $comment Treated commentary data. 524 | * @return boolean `true` if ping and `false` if classic comment 525 | */ 526 | public static function is_ping( $comment ) { 527 | $types = array( 'pingback', 'trackback', 'pings' ); 528 | $is_ping = false; 529 | 530 | if ( in_array( self::get_key( $comment, 'comment_type' ), $types, true ) ) { 531 | $is_ping = true; 532 | } 533 | 534 | return apply_filters( 'antispam_bee_is_ping', $is_ping, $comment ); 535 | } 536 | 537 | /** 538 | * Localization of the admin pages 539 | * 540 | * @since 0.1 541 | * @since 2.4 542 | * 543 | * @param string $page Mark the page. 544 | * @return boolean True on success. 545 | */ 546 | private static function _current_page( $page ) { 547 | // phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification 548 | switch ( $page ) { 549 | case 'dashboard': 550 | return ( empty( $GLOBALS['pagenow'] ) || ( ! empty( $GLOBALS['pagenow'] ) && 'index.php' === $GLOBALS['pagenow'] ) ); 551 | 552 | case 'options': 553 | return ( ! empty( $_GET['page'] ) && 'antispam_bee' === $_GET['page'] ); 554 | 555 | case 'plugins': 556 | return ( ! empty( $GLOBALS['pagenow'] ) && 'plugins.php' === $GLOBALS['pagenow'] ); 557 | 558 | case 'admin-post': 559 | return ( ! empty( $GLOBALS['pagenow'] ) && 'admin-post.php' === $GLOBALS['pagenow'] ); 560 | 561 | case 'edit-comments': 562 | return ( ! empty( $GLOBALS['pagenow'] ) && 'edit-comments.php' === $GLOBALS['pagenow'] ); 563 | 564 | default: 565 | return false; 566 | } 567 | // phpcs:enable WordPress.CSRF.NonceVerification.NoNonceVerification 568 | } 569 | 570 | 571 | /** 572 | * Add the link to the settings 573 | * 574 | * @since 1.1 575 | * 576 | * @param array $data The action link array. 577 | * @return array $data The action link array. 578 | */ 579 | public static function init_action_links( $data ) { 580 | if ( ! current_user_can( 'manage_options' ) ) { 581 | return $data; 582 | } 583 | 584 | return array_merge( 585 | $data, 586 | array( 587 | sprintf( 588 | '%s', 589 | add_query_arg( 590 | array( 591 | 'page' => 'antispam_bee', 592 | ), 593 | admin_url( 'options-general.php' ) 594 | ), 595 | esc_attr__( 'Settings', 'antispam-bee' ) 596 | ), 597 | ) 598 | ); 599 | } 600 | 601 | /** 602 | * Meta links of the plugin 603 | * 604 | * @since 0.1 605 | * @since 2.6.2 606 | * 607 | * @param array $input Existing links. 608 | * @param string $file Current page. 609 | * @return array $data Modified links. 610 | */ 611 | public static function init_row_meta( $input, $file ) { 612 | if ( $file !== self::$_base ) { 613 | return $input; 614 | } 615 | 616 | return array_merge( 617 | $input, 618 | array( 619 | '' . esc_html__( 'Donate', 'antispam-bee' ) . '', 620 | '' . esc_html__( 'Support', 'antispam-bee' ) . '', 621 | ) 622 | ); 623 | } 624 | 625 | /* 626 | * ############################ 627 | * ####### RESOURCES ######## 628 | * ############################ 629 | */ 630 | 631 | /** 632 | * Registration of resources (CSS & JS) 633 | * 634 | * @since 1.6 635 | * @since 2.4.5 636 | */ 637 | public static function init_plugin_sources() { 638 | $plugin = get_plugin_data( __FILE__ ); 639 | 640 | wp_register_script( 641 | 'ab_script', 642 | plugins_url( 'js/scripts.min.js', __FILE__ ), 643 | array( 'jquery' ), 644 | $plugin['Version'] 645 | ); 646 | 647 | wp_register_style( 648 | 'ab_style', 649 | plugins_url( 'css/styles.min.css', __FILE__ ), 650 | array( 'dashicons' ), 651 | $plugin['Version'] 652 | ); 653 | } 654 | 655 | 656 | /** 657 | * Initialization of the option page 658 | * 659 | * @since 0.1 660 | * @since 2.4.3 661 | */ 662 | public static function add_sidebar_menu() { 663 | $page = add_options_page( 664 | 'Antispam Bee', 665 | 'Antispam Bee', 666 | 'manage_options', 667 | 'antispam_bee', 668 | array( 669 | 'Antispam_Bee_GUI', 670 | 'options_page', 671 | ) 672 | ); 673 | 674 | add_action( 675 | 'admin_print_scripts-' . $page, 676 | array( 677 | __CLASS__, 678 | 'add_options_script', 679 | ) 680 | ); 681 | 682 | add_action( 683 | 'admin_print_styles-' . $page, 684 | array( 685 | __CLASS__, 686 | 'add_options_style', 687 | ) 688 | ); 689 | 690 | add_action( 691 | 'load-' . $page, 692 | array( 693 | __CLASS__, 694 | 'init_options_page', 695 | ) 696 | ); 697 | } 698 | 699 | 700 | /** 701 | * Initialization of JavaScript 702 | * 703 | * @since 1.6 704 | * @since 2.4 705 | */ 706 | public static function add_options_script() { 707 | wp_enqueue_script( 'ab_script' ); 708 | } 709 | 710 | 711 | /** 712 | * Initialization of Stylesheets 713 | * 714 | * @since 1.6 715 | * @since 2.4 716 | */ 717 | public static function add_options_style() { 718 | wp_enqueue_style( 'ab_style' ); 719 | } 720 | 721 | 722 | /** 723 | * Integration of the GUI 724 | * 725 | * @since 2.4 726 | */ 727 | public static function init_options_page() { 728 | require_once dirname( __FILE__ ) . '/inc/gui.class.php'; 729 | } 730 | 731 | 732 | 733 | /* 734 | * ############################ 735 | * ####### DASHBOARD ######## 736 | * ############################ 737 | */ 738 | 739 | /** 740 | * Display the spam counter on the dashboard 741 | * 742 | * @since 0.1 743 | * @since 2.6.5 744 | * 745 | * @param array $items Initial array with dashboard items. 746 | * @return array $items Merged array with dashboard items. 747 | */ 748 | public static function add_dashboard_count( $items = array() ) { 749 | if ( ! current_user_can( 'manage_options' ) || ! self::get_option( 'dashboard_count' ) ) { 750 | return $items; 751 | } 752 | 753 | echo ''; 754 | 755 | $items[] = '' . esc_html( 756 | sprintf( 757 | // translators: The number of spam comments Antispam Bee blocked so far. 758 | _n( 759 | '%s Blocked', 760 | '%s Blocked', 761 | self::_get_spam_count(), 762 | 'antispam-bee' 763 | ), 764 | self::_get_spam_count() 765 | ) 766 | ) . ''; 767 | 768 | return $items; 769 | } 770 | 771 | /** 772 | * Initialize the dashboard chart 773 | * 774 | * @since 1.9 775 | * @since 2.5.6 776 | */ 777 | public static function add_dashboard_chart() { 778 | if ( ! current_user_can( 'publish_posts' ) || ! self::get_option( 'dashboard_chart' ) ) { 779 | return; 780 | } 781 | 782 | wp_add_dashboard_widget( 783 | 'ab_widget', 784 | 'Antispam Bee', 785 | array( 786 | __CLASS__, 787 | 'show_spam_chart', 788 | ) 789 | ); 790 | 791 | add_action( 792 | 'admin_head', 793 | array( 794 | __CLASS__, 795 | 'add_dashboard_style', 796 | ) 797 | ); 798 | } 799 | 800 | /** 801 | * Print dashboard styles 802 | * 803 | * @since 1.9.0 804 | * @since 2.5.8 805 | */ 806 | public static function add_dashboard_style() { 807 | $plugin = get_plugin_data( __FILE__ ); 808 | 809 | wp_register_style( 810 | 'ab_chart', 811 | plugins_url( 'css/dashboard.min.css', __FILE__ ), 812 | array(), 813 | $plugin['Version'] 814 | ); 815 | 816 | wp_print_styles( 'ab_chart' ); 817 | } 818 | 819 | 820 | /** 821 | * Print dashboard scripts 822 | * 823 | * @since 1.9.0 824 | * @since 2.5.8 825 | */ 826 | public static function add_dashboard_script() { 827 | if ( ! self::get_option( 'daily_stats' ) ) { 828 | return; 829 | } 830 | 831 | $plugin = get_plugin_data( __FILE__ ); 832 | 833 | wp_enqueue_script( 834 | 'raphael', 835 | plugins_url( 'js/raphael.min.js', __FILE__ ), 836 | array(), 837 | '2.1.0', 838 | true 839 | ); 840 | 841 | wp_enqueue_script( 842 | 'ab-raphael', 843 | plugins_url( 'js/raphael.helper.min.js', __FILE__ ), 844 | array( 'raphael' ), 845 | $plugin['Version'], 846 | true 847 | ); 848 | 849 | wp_enqueue_script( 850 | 'ab_chart_js', 851 | plugins_url( 'js/dashboard.min.js', __FILE__ ), 852 | array( 'jquery', 'ab-raphael' ), 853 | $plugin['Version'], 854 | true 855 | ); 856 | } 857 | 858 | /** 859 | * Print dashboard html 860 | * 861 | * @since 1.9.0 862 | * @since 2.5.8 863 | */ 864 | public static function show_spam_chart() { 865 | $items = (array) self::get_option( 'daily_stats' ); 866 | 867 | if ( empty( $items ) ) { 868 | printf( 869 | '

%s

', 870 | esc_html__( 'No data available.', 'antispam-bee' ) 871 | ); 872 | 873 | return; 874 | } 875 | 876 | self::add_dashboard_script(); 877 | 878 | ksort( $items, SORT_NUMERIC ); 879 | 880 | $html = "\n"; 881 | 882 | $html .= "\n"; 883 | foreach ( $items as $date => $count ) { 884 | $html .= '\n"; 885 | } 886 | $html .= "\n"; 887 | 888 | $html .= "\n"; 889 | foreach ( $items as $date => $count ) { 890 | $html .= '\n"; 891 | } 892 | $html .= "\n"; 893 | 894 | $html .= "
' . date_i18n( 'j. F Y', $date ) . "
' . (int) $count . "
\n"; 895 | 896 | echo wp_kses_post( '
' . $html . '
' ); 897 | } 898 | 899 | /* 900 | * ############################ 901 | * ######## OPTIONS ######### 902 | * ############################ 903 | */ 904 | 905 | /** 906 | * Get all plugin options 907 | * 908 | * @since 2.4 909 | * @since 2.6.1 910 | * 911 | * @return array $options Array with option fields. 912 | */ 913 | public static function get_options() { 914 | $options = wp_cache_get( 'antispam_bee' ); 915 | if ( ! $options ) { 916 | wp_cache_set( 917 | 'antispam_bee', 918 | $options = get_option( 'antispam_bee' ) 919 | ); 920 | } 921 | 922 | if ( null === self::$defaults ) { 923 | self::_init_internal_vars(); 924 | } 925 | 926 | return wp_parse_args( 927 | $options, 928 | self::$defaults['options'] 929 | ); 930 | } 931 | 932 | /** 933 | * Get single option field 934 | * 935 | * @since 0.1 936 | * @since 2.4.2 937 | * 938 | * @param string $field Field name. 939 | * @return mixed Field value. 940 | */ 941 | public static function get_option( $field ) { 942 | $options = self::get_options(); 943 | 944 | return self::get_key( $options, $field ); 945 | } 946 | 947 | 948 | /** 949 | * Update single option field 950 | * 951 | * @since 0.1 952 | * @since 2.4 953 | * 954 | * @param string $field Field name. 955 | * @param mixed $value The Field value. 956 | */ 957 | private static function _update_option( $field, $value ) { 958 | self::update_options( 959 | array( 960 | $field => $value, 961 | ) 962 | ); 963 | } 964 | 965 | 966 | /** 967 | * Update multiple option fields 968 | * 969 | * @since 0.1 970 | * @since 2.6.1 971 | * 972 | * @param array $data Array with plugin option fields. 973 | */ 974 | public static function update_options( $data ) { 975 | $options = get_option( 'antispam_bee' ); 976 | 977 | if ( is_array( $options ) ) { 978 | $options = array_merge( 979 | $options, 980 | $data 981 | ); 982 | } else { 983 | $options = $data; 984 | } 985 | 986 | update_option( 987 | 'antispam_bee', 988 | $options 989 | ); 990 | 991 | wp_cache_set( 992 | 'antispam_bee', 993 | $options 994 | ); 995 | } 996 | 997 | 998 | 999 | /* 1000 | * ############################ 1001 | * ######## CRONJOBS ######## 1002 | * ############################ 1003 | */ 1004 | 1005 | /** 1006 | * Execution of the daily cronjobs 1007 | * 1008 | * @since 0.1 1009 | * @since 2.4 1010 | */ 1011 | public static function start_daily_cronjob() { 1012 | if ( ! self::get_option( 'cronjob_enable' ) ) { 1013 | return; 1014 | } 1015 | 1016 | self::_update_option( 1017 | 'cronjob_timestamp', 1018 | time() 1019 | ); 1020 | 1021 | self::_delete_old_spam(); 1022 | } 1023 | 1024 | 1025 | /** 1026 | * Delete old spam comments 1027 | * 1028 | * @since 0.1 1029 | * @since 2.4 1030 | */ 1031 | private static function _delete_old_spam() { 1032 | $days = (int) self::get_option( 'cronjob_interval' ); 1033 | 1034 | if ( empty( $days ) ) { 1035 | return false; 1036 | } 1037 | 1038 | global $wpdb; 1039 | 1040 | $wpdb->query( 1041 | $wpdb->prepare( 1042 | "DELETE c, cm FROM `$wpdb->comments` AS c LEFT JOIN `$wpdb->commentmeta` AS cm ON (c.comment_ID = cm.comment_id) WHERE c.comment_approved = 'spam' AND SUBDATE(NOW(), %d) > c.comment_date_gmt", 1043 | $days 1044 | ) 1045 | ); 1046 | 1047 | $wpdb->query( "OPTIMIZE TABLE `$wpdb->comments`" ); 1048 | } 1049 | 1050 | 1051 | /** 1052 | * Initialization of the cronjobs 1053 | * 1054 | * @since 0.1 1055 | * @since 2.4 1056 | */ 1057 | public static function init_scheduled_hook() { 1058 | if ( ! wp_next_scheduled( 'antispam_bee_daily_cronjob' ) ) { 1059 | wp_schedule_event( 1060 | time(), 1061 | 'daily', 1062 | 'antispam_bee_daily_cronjob' 1063 | ); 1064 | } 1065 | } 1066 | 1067 | 1068 | /** 1069 | * Deletion of the cronjobs 1070 | * 1071 | * @since 0.1 1072 | * @since 2.4 1073 | */ 1074 | public static function clear_scheduled_hook() { 1075 | if ( wp_next_scheduled( 'antispam_bee_daily_cronjob' ) ) { 1076 | wp_clear_scheduled_hook( 'antispam_bee_daily_cronjob' ); 1077 | } 1078 | } 1079 | 1080 | /** 1081 | * Shows plugin update notice 1082 | * 1083 | * @since 2.11.4 1084 | * 1085 | * @param array $data An array of plugin metadata. See get_plugin_data() 1086 | * and the {@see 'plugin_row_meta'} filter for the list 1087 | * of possible values. 1088 | * 1089 | * @return void 1090 | */ 1091 | public static function upgrade_notice( $data ) { 1092 | if ( isset( $data['upgrade_notice'] ) ) { 1093 | printf( 1094 | '
%s
', 1095 | wp_kses( 1096 | wpautop( $data['upgrade_notice '] ), 1097 | array( 1098 | 'p' => array(), 1099 | 'a' => array( 'href', 'title' ), 1100 | 'strong' => array(), 1101 | 'em' => array(), 1102 | ) 1103 | ) 1104 | ); 1105 | } 1106 | } 1107 | 1108 | 1109 | /* 1110 | * ############################ 1111 | * ###### SPAM CHECK ######## 1112 | * ############################ 1113 | */ 1114 | 1115 | /** 1116 | * Check POST values 1117 | * 1118 | * @since 0.1 1119 | * @since 2.6.3 1120 | * @since 2.11.7 Switching from REQUEST_URI to SCRIPT_NAME for the check 1121 | */ 1122 | public static function precheck_incoming_request() { 1123 | // phpcs:disable WordPress.Security.NonceVerification.Missing 1124 | if ( is_feed() || is_trackback() || empty( $_POST ) || self::_is_mobile() ) { 1125 | return; 1126 | } 1127 | 1128 | $request_uri = self::get_key( $_SERVER, 'SCRIPT_NAME' ); 1129 | $request_path = self::parse_url( $request_uri, 'path' ); 1130 | 1131 | if ( strpos( $request_path, 'wp-comments-post.php' ) === false ) { 1132 | return; 1133 | } 1134 | 1135 | $post_id = (int) self::get_key( $_POST, 'comment_post_ID' ); 1136 | $hidden_field = self::get_key( $_POST, 'comment' ); 1137 | $plugin_field = self::get_key( $_POST, self::get_secret_name_for_post( $post_id ) ); 1138 | 1139 | if ( ! empty( $hidden_field ) ) { 1140 | $_POST['ab_spam__hidden_field'] = 1; 1141 | } else { 1142 | $_POST['comment'] = $plugin_field; 1143 | unset( $_POST[ self::get_secret_name_for_post( $post_id ) ] ); 1144 | } 1145 | // phpcs:enable WordPress.Security.NonceVerification.Missing 1146 | } 1147 | 1148 | 1149 | /** 1150 | * Check incoming requests for spam 1151 | * 1152 | * @since 0.1 1153 | * @since 2.6.3 1154 | * @since 2.10.0 Refactoring of code if pings are allowed and if is ping 1155 | * @since 2.11.7 Switching from REQUEST_URI to SCRIPT_NAME for the check 1156 | * 1157 | * @param array $comment Untreated comment. 1158 | * @return array $comment Treated comment. 1159 | */ 1160 | public static function handle_incoming_request( $comment ) { 1161 | $comment['comment_author_IP'] = self::get_client_ip(); 1162 | 1163 | $request_uri = self::get_key( $_SERVER, 'SCRIPT_NAME' ); 1164 | $request_path = self::parse_url( $request_uri, 'path' ); 1165 | 1166 | if ( empty( $request_path ) ) { 1167 | return self::_handle_spam_request( 1168 | $comment, 1169 | 'empty' 1170 | ); 1171 | } 1172 | 1173 | $pings_allowed = ! self::get_option( 'ignore_pings' ); 1174 | 1175 | // phpcs:disable WordPress.Security.NonceVerification.Missing 1176 | // Everybody can post. 1177 | if ( strpos( $request_path, 'wp-comments-post.php' ) !== false && ! empty( $_POST ) ) { 1178 | // phpcs:enable WordPress.Security.NonceVerification.Missing 1179 | $status = self::_verify_comment_request( $comment ); 1180 | 1181 | if ( ! empty( $status['reason'] ) ) { 1182 | return self::_handle_spam_request( 1183 | $comment, 1184 | $status['reason'] 1185 | ); 1186 | } 1187 | } elseif ( self::is_ping( $comment ) && $pings_allowed ) { 1188 | $status = self::_verify_trackback_request( $comment ); 1189 | 1190 | if ( ! empty( $status['reason'] ) ) { 1191 | return self::_handle_spam_request( 1192 | $comment, 1193 | $status['reason'], 1194 | true 1195 | ); 1196 | } 1197 | } 1198 | 1199 | return $comment; 1200 | } 1201 | 1202 | /** 1203 | * Prepares the replacement of the comment field with output buffering. 1204 | * 1205 | * @since 2.10.0 1206 | */ 1207 | public static function prepare_comment_field_output_buffering() { 1208 | if ( is_feed() || is_trackback() || is_robots() || self::_is_mobile() ) { 1209 | return; 1210 | } 1211 | 1212 | ob_start( 1213 | array( 1214 | 'Antispam_Bee', 1215 | 'prepare_comment_field', 1216 | ) 1217 | ); 1218 | } 1219 | 1220 | 1221 | /** 1222 | * Prepares the replacement of the comment field 1223 | * 1224 | * @since 0.1 1225 | * @since 2.4 1226 | * @since 2.10.0 Changes needed because of new way to add the honeypot field via filter instead of output buffering 1227 | * 1228 | * @param string $data Markup of the comment field or whole page (depending on ob option). 1229 | */ 1230 | public static function prepare_comment_field( $data ) { 1231 | if ( empty( $data ) ) { 1232 | return $data; 1233 | } 1234 | 1235 | if ( ! preg_match( '# (?# match the whole textarea tag ) 1241 | '; 1305 | 1306 | $output .= $id_script; 1307 | $output .= $init_time_field; 1308 | 1309 | return $output; 1310 | } 1311 | 1312 | 1313 | /** 1314 | * Check the trackbacks 1315 | * 1316 | * @since 2.4 1317 | * @since 2.7.0 1318 | * 1319 | * @param array $comment Trackback data. 1320 | * @return array Array with suspected reason. 1321 | */ 1322 | private static function _verify_trackback_request( $comment ) { 1323 | $ip = self::get_key( $comment, 'comment_author_IP' ); 1324 | $url = self::get_key( $comment, 'comment_author_url' ); 1325 | $body = self::get_key( $comment, 'comment_content' ); 1326 | $post_id = self::get_key( $comment, 'comment_post_ID' ); 1327 | $type = self::get_key( $comment, 'comment_type' ); 1328 | $blog_name = self::get_key( $comment, 'comment_author' ); 1329 | 1330 | if ( empty( $url ) || empty( $body ) ) { 1331 | return array( 1332 | 'reason' => 'empty', 1333 | ); 1334 | } 1335 | 1336 | if ( empty( $ip ) ) { 1337 | return array( 1338 | 'reason' => 'empty', 1339 | ); 1340 | } 1341 | 1342 | if ( 'pingback' === $type && self::_pingback_from_myself( $url, $post_id ) ) { 1343 | return; 1344 | } 1345 | 1346 | if ( self::is_trackback_post_title_blog_name_spam( $body, $blog_name ) ) { 1347 | return array( 1348 | 'reason' => 'title_is_name', 1349 | ); 1350 | } 1351 | 1352 | $options = self::get_options(); 1353 | 1354 | if ( $options['bbcode_check'] && self::_is_bbcode_spam( $body ) ) { 1355 | return array( 1356 | 'reason' => 'bbcode', 1357 | ); 1358 | } 1359 | 1360 | if ( $options['spam_ip'] && self::_is_db_spam( $ip, $url ) ) { 1361 | return array( 1362 | 'reason' => 'localdb', 1363 | ); 1364 | } 1365 | 1366 | if ( $options['country_code'] && self::_is_country_spam( $ip ) ) { 1367 | return array( 1368 | 'reason' => 'country', 1369 | ); 1370 | } 1371 | 1372 | if ( $options['translate_api'] && self::_is_lang_spam( $body ) ) { 1373 | return array( 1374 | 'reason' => 'lang', 1375 | ); 1376 | } 1377 | 1378 | if ( $options['regexp_check'] && self::_is_regexp_spam( 1379 | array( 1380 | 'ip' => $ip, 1381 | 'rawurl' => $url, 1382 | 'host' => self::parse_url( $url, 'host' ), 1383 | 'body' => $body, 1384 | 'email' => '', 1385 | 'author' => '', 1386 | ) 1387 | ) ) { 1388 | return array( 1389 | 'reason' => 'regexp', 1390 | ); 1391 | } 1392 | } 1393 | 1394 | /** 1395 | * Check, if I pinged myself. 1396 | * 1397 | * @since 2.8.2 1398 | * 1399 | * @param string $url The URL from where the ping came. 1400 | * @param int $target_post_id The post ID which has been pinged. 1401 | * 1402 | * @return bool 1403 | */ 1404 | private static function _pingback_from_myself( $url, $target_post_id ) { 1405 | 1406 | if ( 0 !== strpos( $url, home_url() ) ) { 1407 | return false; 1408 | } 1409 | 1410 | $original_post_id = (int) url_to_postid( $url ); 1411 | if ( ! $original_post_id ) { 1412 | return false; 1413 | } 1414 | 1415 | $post = get_post( $original_post_id ); 1416 | if ( ! $post ) { 1417 | return false; 1418 | } 1419 | 1420 | $urls = wp_extract_urls( $post->post_content ); 1421 | $url_to_find = get_permalink( $target_post_id ); 1422 | if ( ! $url_to_find ) { 1423 | return false; 1424 | } 1425 | foreach ( $urls as $url ) { 1426 | if ( strpos( $url, $url_to_find ) === 0 ) { 1427 | return true; 1428 | } 1429 | } 1430 | return false; 1431 | } 1432 | 1433 | /** 1434 | * Check the comment 1435 | * 1436 | * @since 2.4 1437 | * @since 2.7.0 1438 | * @since 2.10.0 Add useragent as data to regex check 1439 | * 1440 | * @param array $comment Data of the comment. 1441 | * @return array|void Array with suspected reason 1442 | */ 1443 | private static function _verify_comment_request( $comment ) { 1444 | $ip = self::get_key( $comment, 'comment_author_IP' ); 1445 | $url = self::get_key( $comment, 'comment_author_url' ); 1446 | $body = self::get_key( $comment, 'comment_content' ); 1447 | $email = self::get_key( $comment, 'comment_author_email' ); 1448 | $author = self::get_key( $comment, 'comment_author' ); 1449 | $useragent = self::get_key( $comment, 'comment_agent' ); 1450 | 1451 | // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound 1452 | $allow_empty_comment = apply_filters( 'allow_empty_comment', false, $comment ); 1453 | 1454 | if ( empty( $body ) && ! $allow_empty_comment ) { 1455 | return array( 1456 | 'reason' => 'empty', 1457 | ); 1458 | } 1459 | 1460 | if ( empty( $ip ) ) { 1461 | return array( 1462 | 'reason' => 'empty', 1463 | ); 1464 | } 1465 | 1466 | if ( get_option( 'require_name_email' ) && ( empty( $email ) || empty( $author ) ) ) { 1467 | return array( 1468 | 'reason' => 'empty', 1469 | ); 1470 | } 1471 | 1472 | $options = self::get_options(); 1473 | 1474 | if ( $options['already_commented'] && ! empty( $email ) && self::_is_approved_email( $email ) ) { 1475 | return; 1476 | } 1477 | 1478 | if ( $options['gravatar_check'] && ! empty( $email ) && 1 === (int) get_option( 'show_avatars', 0 ) && self::_has_valid_gravatar( $email ) ) { 1479 | return; 1480 | } 1481 | 1482 | // phpcs:disable WordPress.Security.NonceVerification.Missing 1483 | if ( ! empty( $_POST['ab_spam__hidden_field'] ) ) { 1484 | return array( 1485 | 'reason' => 'css', 1486 | ); 1487 | } 1488 | // phpcs:enable WordPress.Security.NonceVerification.Missing 1489 | 1490 | if ( $options['time_check'] && self::_is_shortest_time() ) { 1491 | return array( 1492 | 'reason' => 'time', 1493 | ); 1494 | } 1495 | 1496 | if ( $options['bbcode_check'] && self::_is_bbcode_spam( $body ) ) { 1497 | return array( 1498 | 'reason' => 'bbcode', 1499 | ); 1500 | } 1501 | 1502 | if ( $options['regexp_check'] && self::_is_regexp_spam( 1503 | array( 1504 | 'ip' => $ip, 1505 | 'rawurl' => $url, 1506 | 'host' => self::parse_url( $url, 'host' ), 1507 | 'body' => $body, 1508 | 'email' => $email, 1509 | 'author' => $author, 1510 | 'useragent' => $useragent, 1511 | ) 1512 | ) ) { 1513 | return array( 1514 | 'reason' => 'regexp', 1515 | ); 1516 | } 1517 | 1518 | if ( $options['spam_ip'] && self::_is_db_spam( $ip, $url, $email ) ) { 1519 | return array( 1520 | 'reason' => 'localdb', 1521 | ); 1522 | } 1523 | 1524 | if ( $options['country_code'] && self::_is_country_spam( $ip ) ) { 1525 | return array( 1526 | 'reason' => 'country', 1527 | ); 1528 | } 1529 | 1530 | if ( $options['translate_api'] && self::_is_lang_spam( $body ) ) { 1531 | return array( 1532 | 'reason' => 'lang', 1533 | ); 1534 | } 1535 | } 1536 | 1537 | 1538 | /** 1539 | * Check for a Gravatar image 1540 | * 1541 | * @since 2.6.5 1542 | * 1543 | * @param string $email Input email. 1544 | * @return boolean Check status (true = Gravatar available). 1545 | */ 1546 | private static function _has_valid_gravatar( $email ) { 1547 | $response = wp_safe_remote_get( 1548 | sprintf( 1549 | 'https://www.gravatar.com/avatar/%s?d=404', 1550 | md5( strtolower( trim( $email ) ) ) 1551 | ) 1552 | ); 1553 | 1554 | if ( is_wp_error( $response ) ) { 1555 | return null; 1556 | } 1557 | 1558 | if ( wp_remote_retrieve_response_code( $response ) === 200 ) { 1559 | return true; 1560 | } 1561 | 1562 | return false; 1563 | } 1564 | 1565 | 1566 | /** 1567 | * Check for comment action time 1568 | * 1569 | * @since 2.6.4 1570 | * 1571 | * @return boolean TRUE if the action time is less than 5 seconds 1572 | */ 1573 | private static function _is_shortest_time() { 1574 | // phpcs:disable WordPress.Security.NonceVerification.Missing 1575 | // Everybody can Post. 1576 | $init_time = (int) self::get_key( $_POST, 'ab_init_time' ); 1577 | // phpcs:enable WordPress.Security.NonceVerification.Missing 1578 | if ( 0 === $init_time ) { 1579 | return false; 1580 | } 1581 | 1582 | if ( time() - $init_time < apply_filters( 'ab_action_time_limit', 5 ) ) { 1583 | return true; 1584 | } 1585 | 1586 | return false; 1587 | } 1588 | 1589 | /** 1590 | * Check if the blog name and the title of the blog post from which the trackback originates are equal. 1591 | * 1592 | * @since 2.6.4 1593 | * 1594 | * @param string $body The comment body. 1595 | * @param string $blog_name The name of the blog. 1596 | * 1597 | * @return bool 1598 | */ 1599 | private static function is_trackback_post_title_blog_name_spam( $body, $blog_name ) { 1600 | preg_match( '/(.*)<\/strong>\\n\\n/', $body, $matches ); 1601 | if ( ! isset( $matches[1] ) ) { 1602 | return false; 1603 | } 1604 | return trim( $matches[1] ) === trim( $blog_name ); 1605 | } 1606 | 1607 | 1608 | /** 1609 | * Usage of regexp, also custom 1610 | * 1611 | * @since 2.5.2 1612 | * @since 2.5.6 1613 | * @since 2.10.0 Use useragent in check 1614 | * 1615 | * @param array $comment Array with commentary data. 1616 | * @return boolean True for suspicious comment. 1617 | */ 1618 | private static function _is_regexp_spam( $comment ) { 1619 | $fields = array( 1620 | 'ip', 1621 | 'host', 1622 | 'body', 1623 | 'email', 1624 | 'author', 1625 | 'useragent', 1626 | ); 1627 | 1628 | $patterns = array( 1629 | array( 1630 | 'host' => '^(www\.)?\d+\w+\.com$', 1631 | 'body' => '^\w+\s\d+$', 1632 | 'email' => '@gmail.com$', 1633 | ), 1634 | array( 1635 | 'body' => '\b[a-z]{30}\b', 1636 | 'author' => '\b[a-z]{10}\b', 1637 | 'host' => '\b[a-z]{10}\b', 1638 | ), 1639 | array( 1640 | 'body' => '\<\!.+?mfunc.+?\>', 1641 | ), 1642 | array( 1643 | 'author' => 'moncler|north face|vuitton|handbag|burberry|outlet|prada|cialis|viagra|maillot|oakley|ralph lauren|ray ban|iphone|プラダ', 1644 | ), 1645 | array( 1646 | 'host' => '^(www\.)?fkbook\.co\.uk$|^(www\.)?nsru\.net$|^(www\.)?goo\.gl$|^(www\.)?bit\.ly$', 1647 | ), 1648 | array( 1649 | 'body' => 'target[t]?ed (visitors|traffic)|viagra|cialis', 1650 | ), 1651 | array( 1652 | 'body' => 'purchase amazing|buy amazing|luxurybrandsale', 1653 | ), 1654 | array( 1655 | 'body' => 'dating|sex|lotto|pharmacy', 1656 | 'email' => '@mail\.ru|@yandex\.', 1657 | ), 1658 | ); 1659 | 1660 | $quoted_author = preg_quote( $comment['author'], '/' ); 1661 | if ( $quoted_author ) { 1662 | $patterns[] = array( 1663 | 'body' => sprintf( 1664 | '%s<\/a>$', 1665 | $quoted_author 1666 | ), 1667 | ); 1668 | $patterns[] = array( 1669 | 'body' => sprintf( 1670 | '%s https?:.+?$', 1671 | $quoted_author 1672 | ), 1673 | ); 1674 | $patterns[] = array( 1675 | 'email' => '@gmail.com$', 1676 | 'author' => '^[a-z0-9-\.]+\.[a-z]{2,6}$', 1677 | 'host' => sprintf( 1678 | '^%s$', 1679 | $quoted_author 1680 | ), 1681 | ); 1682 | } 1683 | 1684 | $patterns = apply_filters( 1685 | 'antispam_bee_patterns', 1686 | $patterns 1687 | ); 1688 | 1689 | if ( ! $patterns ) { 1690 | return false; 1691 | } 1692 | 1693 | foreach ( $patterns as $pattern ) { 1694 | $hits = array(); 1695 | 1696 | foreach ( $pattern as $field => $regexp ) { 1697 | if ( empty( $field ) || ! in_array( $field, $fields, true ) || empty( $regexp ) ) { 1698 | continue; 1699 | } 1700 | 1701 | $comment[ $field ] = ( function_exists( 'iconv' ) ? iconv( 'utf-8', 'utf-8//TRANSLIT', $comment[ $field ] ) : $comment[ $field ] ); 1702 | 1703 | if ( empty( $comment[ $field ] ) ) { 1704 | continue; 1705 | } 1706 | 1707 | if ( preg_match( '/' . $regexp . '/isu', $comment[ $field ] ) ) { 1708 | $hits[ $field ] = true; 1709 | } 1710 | } 1711 | 1712 | if ( count( $hits ) === count( $pattern ) ) { 1713 | return true; 1714 | } 1715 | } 1716 | 1717 | return false; 1718 | } 1719 | 1720 | 1721 | /** 1722 | * Review a comment on its existence in the local spam 1723 | * 1724 | * @since 2.0.0 1725 | * @since 2.5.4 1726 | * 1727 | * @param string $ip Comment IP. 1728 | * @param string $url Comment URL (optional). 1729 | * @param string $email Comment Email (optional). 1730 | * @return boolean True for suspicious comment. 1731 | */ 1732 | private static function _is_db_spam( $ip, $url = '', $email = '' ) { 1733 | global $wpdb; 1734 | 1735 | $params = array(); 1736 | $filter = array(); 1737 | if ( ! empty( $url ) ) { 1738 | $filter[] = '`comment_author_url` = %s'; 1739 | $params[] = wp_unslash( $url ); 1740 | } 1741 | if ( ! empty( $ip ) ) { 1742 | $filter[] = '`comment_author_IP` = %s'; 1743 | $params[] = wp_unslash( $ip ); 1744 | } 1745 | 1746 | if ( ! empty( $email ) ) { 1747 | $filter[] = '`comment_author_email` = %s'; 1748 | $params[] = wp_unslash( $email ); 1749 | } 1750 | if ( empty( $params ) ) { 1751 | return false; 1752 | } 1753 | 1754 | // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared 1755 | // phpcs:disable WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber 1756 | $filter_sql = implode( ' OR ', $filter ); 1757 | 1758 | $result = $wpdb->get_var( 1759 | $wpdb->prepare( 1760 | sprintf( 1761 | "SELECT `comment_ID` FROM `$wpdb->comments` WHERE `comment_approved` = 'spam' AND (%s) LIMIT 1", 1762 | $filter_sql 1763 | ), 1764 | $params 1765 | ) 1766 | ); 1767 | // phpcs:enable WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber 1768 | // phpcs:enable WordPress.DB.PreparedSQL.NotPrepared 1769 | 1770 | return ! empty( $result ); 1771 | } 1772 | 1773 | 1774 | /** 1775 | * Check for country spam by (anonymized) IP 1776 | * 1777 | * @since 2.6.9 1778 | * @since 2.10.0 Make country check API filterable and use iplocate.io instead of ip2country.info 1779 | * 1780 | * @param string $ip IP address. 1781 | * @return boolean True if the comment is spam based on country filter. 1782 | */ 1783 | private static function _is_country_spam( $ip ) { 1784 | $options = self::get_options(); 1785 | 1786 | $allowed = preg_split( 1787 | '/[\s,;]+/', 1788 | $options['country_allowed'], 1789 | -1, 1790 | PREG_SPLIT_NO_EMPTY 1791 | ); 1792 | $denied = preg_split( 1793 | '/[\s,;]+/', 1794 | $options['country_denied'], 1795 | -1, 1796 | PREG_SPLIT_NO_EMPTY 1797 | ); 1798 | 1799 | if ( empty( $allowed ) && empty( $denied ) ) { 1800 | return false; 1801 | } 1802 | 1803 | /** 1804 | * Filter to hook into the `_is_country_spam` functionality, to implement for example a custom IP check. 1805 | * 1806 | * @since 2.10.0 1807 | * 1808 | * @param null $is_country_spam The `is_country_spam` result. 1809 | * @param string $ip The IP address. 1810 | * @param array $allowed The list of allowed country codes. 1811 | * @param array $denied The list of denied country codes. 1812 | * 1813 | * @return null|boolean The `is_country_spam` result or null. 1814 | */ 1815 | $is_country_spam = apply_filters( 'antispam_bee_is_country_spam', null, $ip, $allowed, $denied ); 1816 | 1817 | if ( is_bool( $is_country_spam ) ) { 1818 | return $is_country_spam; 1819 | } 1820 | 1821 | /** 1822 | * Filters the IPLocate API key. With this filter, you can add your own IPLocate API key. 1823 | * 1824 | * @since 2.10.0 1825 | * 1826 | * @param string The current IPLocate API key. Default is `null`. 1827 | * 1828 | * @return string The changed IPLocate API key or null. 1829 | */ 1830 | $apikey = apply_filters( 'antispam_bee_country_spam_apikey', '' ); 1831 | 1832 | $response = wp_safe_remote_get( 1833 | esc_url_raw( 1834 | sprintf( 1835 | 'https://www.iplocate.io/api/lookup/%s?apikey=%s', 1836 | self::_anonymize_ip( $ip ), 1837 | $apikey 1838 | ), 1839 | 'https' 1840 | ) 1841 | ); 1842 | 1843 | if ( is_wp_error( $response ) ) { 1844 | return false; 1845 | } 1846 | 1847 | if ( wp_remote_retrieve_response_code( $response ) !== 200 ) { 1848 | return false; 1849 | } 1850 | 1851 | $body = (string) wp_remote_retrieve_body( $response ); 1852 | 1853 | $json = json_decode( $body, true ); 1854 | 1855 | // Check if response is valid json. 1856 | if ( ! is_array( $json ) ) { 1857 | return false; 1858 | } 1859 | 1860 | if ( empty( $json['country_code'] ) ) { 1861 | return false; 1862 | } 1863 | 1864 | $country = strtoupper( $json['country_code'] ); 1865 | 1866 | if ( empty( $country ) || strlen( $country ) !== 2 ) { 1867 | return false; 1868 | } 1869 | 1870 | if ( ! empty( $denied ) ) { 1871 | return ( in_array( $country, $denied, true ) ); 1872 | } 1873 | 1874 | return ( ! in_array( $country, $allowed, true ) ); 1875 | } 1876 | 1877 | 1878 | /** 1879 | * Check for BBCode spam 1880 | * 1881 | * @since 2.5.1 1882 | * 1883 | * @param string $body Content of a comment. 1884 | * @return boolean True for BBCode in content 1885 | */ 1886 | private static function _is_bbcode_spam( $body ) { 1887 | return (bool) preg_match( '/\[url[=\]].*\[\/url\]/is', $body ); 1888 | } 1889 | 1890 | 1891 | /** 1892 | * Check for an already approved e-mail address 1893 | * 1894 | * @since 2.0 1895 | * @since 2.5.1 1896 | * 1897 | * @param string $email E-mail address. 1898 | * @return boolean True for a found entry. 1899 | */ 1900 | private static function _is_approved_email( $email ) { 1901 | global $wpdb; 1902 | 1903 | $result = $wpdb->get_var( 1904 | $wpdb->prepare( 1905 | "SELECT `comment_ID` FROM `$wpdb->comments` WHERE `comment_approved` = '1' AND `comment_author_email` = %s LIMIT 1", 1906 | wp_unslash( $email ) 1907 | ) 1908 | ); 1909 | 1910 | if ( $result ) { 1911 | return true; 1912 | } 1913 | 1914 | return false; 1915 | } 1916 | 1917 | /** 1918 | * Check for unwanted languages 1919 | * 1920 | * @since 2.0 1921 | * @since 2.6.6 1922 | * @since 2.8.2 1923 | * 1924 | * @param string $comment_content Content of the comment. 1925 | * 1926 | * @return boolean TRUE if it is spam. 1927 | */ 1928 | private static function _is_lang_spam( $comment_content ) { 1929 | $allowed_lang = (array) self::get_option( 'translate_lang' ); 1930 | 1931 | $comment_text = wp_strip_all_tags( $comment_content ); 1932 | 1933 | if ( empty( $allowed_lang ) || empty( $comment_text ) ) { 1934 | return false; 1935 | } 1936 | 1937 | /** 1938 | * Filters the detected language. With this filter, other detection methods can skip in and detect the language. 1939 | * 1940 | * @since 2.8.2 1941 | * 1942 | * @param null $detected_lang The detected language. 1943 | * @param string $comment_text The text, to detect the language. 1944 | * 1945 | * @return null|string The detected language or null. 1946 | */ 1947 | $detected_lang = apply_filters( 'antispam_bee_detected_lang', null, $comment_text ); 1948 | if ( null !== $detected_lang ) { 1949 | return ! in_array( $detected_lang, $allowed_lang, true ); 1950 | } 1951 | 1952 | $word_count = 0; 1953 | $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $comment_text ), ' ' ); 1954 | 1955 | /* 1956 | * translators: If your word count is based on single characters (e.g. East Asian characters), 1957 | * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'. 1958 | * Do not translate into your own language. 1959 | */ 1960 | if ( strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { // phpcs:ignore WordPress.WP.I18n.MissingArgDomain 1961 | preg_match_all( '/./u', $text, $words_array ); 1962 | if ( isset( $words_array[0] ) ) { 1963 | $word_count = count( $words_array[0] ); 1964 | } 1965 | } else { 1966 | $words_array = preg_split( "/[\n\r\t ]+/", $text, -1, PREG_SPLIT_NO_EMPTY ); 1967 | $word_count = count( $words_array ); 1968 | } 1969 | 1970 | if ( $word_count < 10 ) { 1971 | return false; 1972 | } 1973 | 1974 | $response = wp_safe_remote_post( 1975 | 'https://api.pluginkollektiv.org/language/v1/', 1976 | array( 'body' => wp_json_encode( array( 'body' => $comment_text ) ) ) 1977 | ); 1978 | 1979 | if ( is_wp_error( $response ) 1980 | || wp_remote_retrieve_response_code( $response ) !== 200 ) { 1981 | return false; 1982 | } 1983 | 1984 | $detected_lang = wp_remote_retrieve_body( $response ); 1985 | if ( ! $detected_lang ) { 1986 | return false; 1987 | } 1988 | 1989 | $detected_lang = json_decode( $detected_lang ); 1990 | if ( ! $detected_lang || ! isset( $detected_lang->code ) ) { 1991 | return false; 1992 | } 1993 | 1994 | return ! in_array( self::_map_lang_code( $detected_lang->code ), $allowed_lang, true ); 1995 | } 1996 | 1997 | /** 1998 | * Map franc language codes 1999 | * 2000 | * @since 2.9.0 2001 | * 2002 | * @param string $franc_code The franc code, received from the service. 2003 | * 2004 | * @return string Mapped ISO code 2005 | */ 2006 | private static function _map_lang_code( $franc_code ) { 2007 | $codes = array( 2008 | 'zha' => 'za', 2009 | 'zho' => 'zh', 2010 | 'zul' => 'zu', 2011 | 'yid' => 'yi', 2012 | 'yor' => 'yo', 2013 | 'xho' => 'xh', 2014 | 'wln' => 'wa', 2015 | 'wol' => 'wo', 2016 | 'ven' => 've', 2017 | 'vie' => 'vi', 2018 | 'vol' => 'vo', 2019 | 'uig' => 'ug', 2020 | 'ukr' => 'uk', 2021 | 'urd' => 'ur', 2022 | 'uzb' => 'uz', 2023 | 'tah' => 'ty', 2024 | 'tam' => 'ta', 2025 | 'tat' => 'tt', 2026 | 'tel' => 'te', 2027 | 'tgk' => 'tg', 2028 | 'tgl' => 'tl', 2029 | 'tha' => 'th', 2030 | 'tir' => 'ti', 2031 | 'ton' => 'to', 2032 | 'tsn' => 'tn', 2033 | 'tso' => 'ts', 2034 | 'tuk' => 'tk', 2035 | 'tur' => 'tr', 2036 | 'twi' => 'tw', 2037 | 'sag' => 'sg', 2038 | 'san' => 'sa', 2039 | 'sin' => 'si', 2040 | 'slk' => 'sk', 2041 | 'slv' => 'sl', 2042 | 'sme' => 'se', 2043 | 'smo' => 'sm', 2044 | 'sna' => 'sn', 2045 | 'snd' => 'sd', 2046 | 'som' => 'so', 2047 | 'sot' => 'st', 2048 | 'spa' => 'es', 2049 | 'sqi' => 'sq', 2050 | 'srd' => 'sc', 2051 | 'srp' => 'sr', 2052 | 'ssw' => 'ss', 2053 | 'sun' => 'su', 2054 | 'swa' => 'sw', 2055 | 'swe' => 'sv', 2056 | 'roh' => 'rm', 2057 | 'ron' => 'ro', 2058 | 'run' => 'rn', 2059 | 'rus' => 'ru', 2060 | 'que' => 'qu', 2061 | 'pan' => 'pa', 2062 | 'pli' => 'pi', 2063 | 'pol' => 'pl', 2064 | 'por' => 'pt', 2065 | 'pus' => 'ps', 2066 | 'oci' => 'oc', 2067 | 'oji' => 'oj', 2068 | 'ori' => 'or', 2069 | 'orm' => 'om', 2070 | 'oss' => 'os', 2071 | 'nau' => 'na', 2072 | 'nav' => 'nv', 2073 | 'nbl' => 'nr', 2074 | 'nde' => 'nd', 2075 | 'ndo' => 'ng', 2076 | 'nep' => 'ne', 2077 | 'nld' => 'nl', 2078 | 'nno' => 'nn', 2079 | 'nob' => 'nb', 2080 | 'nor' => 'no', 2081 | 'nya' => 'ny', 2082 | 'mah' => 'mh', 2083 | 'mal' => 'ml', 2084 | 'mar' => 'mr', 2085 | 'mkd' => 'mk', 2086 | 'mlg' => 'mg', 2087 | 'mlt' => 'mt', 2088 | 'mon' => 'mn', 2089 | 'mri' => 'mi', 2090 | 'msa' => 'ms', 2091 | 'mya' => 'my', 2092 | 'lao' => 'lo', 2093 | 'lat' => 'la', 2094 | 'lav' => 'lv', 2095 | 'lim' => 'li', 2096 | 'lin' => 'ln', 2097 | 'lit' => 'lt', 2098 | 'ltz' => 'lb', 2099 | 'lub' => 'lu', 2100 | 'lug' => 'lg', 2101 | 'kal' => 'kl', 2102 | 'kan' => 'kn', 2103 | 'kas' => 'ks', 2104 | 'kat' => 'ka', 2105 | 'kau' => 'kr', 2106 | 'kaz' => 'kk', 2107 | 'khm' => 'km', 2108 | 'kik' => 'ki', 2109 | 'kin' => 'rw', 2110 | 'kir' => 'ky', 2111 | 'kom' => 'kv', 2112 | 'kon' => 'kg', 2113 | 'kor' => 'ko', 2114 | 'kua' => 'kj', 2115 | 'kur' => 'ku', 2116 | 'jav' => 'jv', 2117 | 'jpn' => 'ja', 2118 | 'ibo' => 'ig', 2119 | 'ido' => 'io', 2120 | 'iii' => 'ii', 2121 | 'iku' => 'iu', 2122 | 'ile' => 'ie', 2123 | 'ina' => 'ia', 2124 | 'ind' => 'id', 2125 | 'ipk' => 'ik', 2126 | 'isl' => 'is', 2127 | 'ita' => 'it', 2128 | 'hat' => 'ht', 2129 | 'hau' => 'ha', 2130 | 'hbs' => 'sh', 2131 | 'heb' => 'he', 2132 | 'her' => 'hz', 2133 | 'hin' => 'hi', 2134 | 'hmo' => 'ho', 2135 | 'hrv' => 'hr', 2136 | 'hun' => 'hu', 2137 | 'hye' => 'hy', 2138 | 'gla' => 'gd', 2139 | 'gle' => 'ga', 2140 | 'glg' => 'gl', 2141 | 'glv' => 'gv', 2142 | 'grn' => 'gn', 2143 | 'guj' => 'gu', 2144 | 'fao' => 'fo', 2145 | 'fas' => 'fa', 2146 | 'fij' => 'fj', 2147 | 'fin' => 'fi', 2148 | 'fra' => 'fr', 2149 | 'fry' => 'fy', 2150 | 'ful' => 'ff', 2151 | 'ell' => 'el', 2152 | 'eng' => 'en', 2153 | 'epo' => 'eo', 2154 | 'est' => 'et', 2155 | 'eus' => 'eu', 2156 | 'ewe' => 'ee', 2157 | 'dan' => 'da', 2158 | 'deu' => 'de', 2159 | 'div' => 'dv', 2160 | 'dzo' => 'dz', 2161 | 'cat' => 'ca', 2162 | 'ces' => 'cs', 2163 | 'cha' => 'ch', 2164 | 'che' => 'ce', 2165 | 'chu' => 'cu', 2166 | 'chv' => 'cv', 2167 | 'cor' => 'kw', 2168 | 'cos' => 'co', 2169 | 'cre' => 'cr', 2170 | 'cym' => 'cy', 2171 | 'bak' => 'ba', 2172 | 'bam' => 'bm', 2173 | 'bel' => 'be', 2174 | 'ben' => 'bn', 2175 | 'bis' => 'bi', 2176 | 'bod' => 'bo', 2177 | 'bos' => 'bs', 2178 | 'bre' => 'br', 2179 | 'bul' => 'bg', 2180 | 'aar' => 'aa', 2181 | 'abk' => 'ab', 2182 | 'afr' => 'af', 2183 | 'aka' => 'ak', 2184 | 'amh' => 'am', 2185 | 'ara' => 'ar', 2186 | 'arg' => 'an', 2187 | 'asm' => 'as', 2188 | 'ava' => 'av', 2189 | 'ave' => 'ae', 2190 | 'aym' => 'ay', 2191 | 'aze' => 'az', 2192 | 'nds' => 'de', 2193 | ); 2194 | 2195 | if ( array_key_exists( $franc_code, $codes ) ) { 2196 | return $codes[ $franc_code ]; 2197 | } 2198 | 2199 | return $franc_code; 2200 | } 2201 | 2202 | /** 2203 | * Trim IP addresses 2204 | * 2205 | * @since 0.1 2206 | * @since 2.5.1 2207 | * 2208 | * @param string $ip Original IP. 2209 | * @param boolean $cut_end Shortening the end. 2210 | * @return string Shortened IP. 2211 | */ 2212 | private static function _cut_ip( $ip, $cut_end = true ) { 2213 | $separator = ( self::_is_ipv4( $ip ) ? '.' : ':' ); 2214 | 2215 | return str_replace( 2216 | ( $cut_end ? strrchr( $ip, $separator ) : strstr( $ip, $separator ) ), 2217 | '', 2218 | $ip 2219 | ); 2220 | } 2221 | 2222 | 2223 | /** 2224 | * Anonymize the IP addresses 2225 | * 2226 | * @since 2.5.1 2227 | * 2228 | * @param string $ip Original IP. 2229 | * @return string Anonymous IP. 2230 | */ 2231 | private static function _anonymize_ip( $ip ) { 2232 | if ( self::_is_ipv4( $ip ) ) { 2233 | return self::_cut_ip( $ip ) . '.0'; 2234 | } 2235 | 2236 | return self::_cut_ip( $ip, false ) . ':0:0:0:0:0:0:0'; 2237 | } 2238 | 2239 | 2240 | /** 2241 | * Check for an IPv4 address 2242 | * 2243 | * @since 2.4 2244 | * @since 2.6.4 2245 | * 2246 | * @param string $ip IP to validate. 2247 | * @return integer TRUE if IPv4. 2248 | */ 2249 | private static function _is_ipv4( $ip ) { 2250 | if ( function_exists( 'filter_var' ) ) { 2251 | return filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) !== false; 2252 | } else { 2253 | return preg_match( '/^\d{1,3}(\.\d{1,3}){3}$/', $ip ); 2254 | } 2255 | } 2256 | 2257 | 2258 | /** 2259 | * Testing on mobile devices 2260 | * 2261 | * @since 0.1 2262 | * @since 2.4 2263 | * 2264 | * @return boolean TRUE if "wptouch" is active 2265 | */ 2266 | private static function _is_mobile() { 2267 | return strpos( get_template_directory(), 'wptouch' ); 2268 | } 2269 | 2270 | /** 2271 | * Testing if we are on an AMP site. 2272 | * 2273 | * Starting with v2.0, amp_is_request() is the preferred method to check, 2274 | * but we fall back to the then deprecated is_amp_endpoint() as needed. 2275 | * 2276 | * @return bool 2277 | */ 2278 | private static function _is_amp() { 2279 | return ( function_exists( 'amp_is_request' ) && amp_is_request() ) || ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ); 2280 | } 2281 | 2282 | 2283 | 2284 | /* 2285 | * ############################ 2286 | * ##### SPAM-TREATMENT ##### 2287 | * ############################ 2288 | */ 2289 | 2290 | /** 2291 | * Execution of the delete/marking process 2292 | * 2293 | * @since 0.1 2294 | * @since 2.6.0 2295 | * 2296 | * @param array $comment Untreated commentary data. 2297 | * @param string $reason Reason for suspicion. 2298 | * @param boolean $is_ping Ping (optional). 2299 | * @return array $comment Treated commentary data. 2300 | */ 2301 | private static function _handle_spam_request( $comment, $reason, $is_ping = false ) { 2302 | 2303 | $options = self::get_options(); 2304 | 2305 | $spam_remove = ! $options['flag_spam']; 2306 | $spam_notice = ! $options['no_notice']; 2307 | 2308 | // Filter settings. 2309 | $ignore_filter = $options['ignore_filter']; 2310 | $ignore_type = $options['ignore_type']; 2311 | $ignore_reason = in_array( $reason, (array) $options['ignore_reasons'], true ); 2312 | 2313 | // Remember spam. 2314 | self::_update_spam_log( $comment ); 2315 | self::_update_spam_count(); 2316 | self::_update_daily_stats(); 2317 | 2318 | // Delete spam. 2319 | if ( $spam_remove ) { 2320 | self::_go_in_peace(); 2321 | } 2322 | 2323 | if ( $ignore_filter && ( ( 1 === (int) $ignore_type && $is_ping ) || ( 2 === (int) $ignore_type && ! $is_ping ) ) ) { 2324 | self::_go_in_peace(); 2325 | } 2326 | 2327 | // Spam reason. 2328 | if ( $ignore_reason ) { 2329 | self::_go_in_peace(); 2330 | } 2331 | self::$_reason = $reason; 2332 | 2333 | // Mark spam. 2334 | add_filter( 2335 | 'pre_comment_approved', 2336 | array( 2337 | __CLASS__, 2338 | 'return_spam', 2339 | ) 2340 | ); 2341 | 2342 | // Send e-mail. 2343 | add_action( 2344 | 'comment_post', 2345 | array( 2346 | __CLASS__, 2347 | 'send_mail_notification', 2348 | ) 2349 | ); 2350 | 2351 | // Spam reason as comment meta. 2352 | if ( $spam_notice ) { 2353 | add_action( 2354 | 'comment_post', 2355 | array( 2356 | __CLASS__, 2357 | 'add_spam_reason_to_comment', 2358 | ) 2359 | ); 2360 | } 2361 | 2362 | return $comment; 2363 | } 2364 | 2365 | 2366 | /** 2367 | * Logfile with detected spam 2368 | * 2369 | * @since 2.5.7 2370 | * @since 2.6.1 2371 | * 2372 | * @param array $comment Array with commentary data. 2373 | * @return mixed FALSE in case of error 2374 | */ 2375 | private static function _update_spam_log( $comment ) { 2376 | if ( ! defined( 'ANTISPAM_BEE_LOG_FILE' ) || ! ANTISPAM_BEE_LOG_FILE || ! is_writable( ANTISPAM_BEE_LOG_FILE ) || validate_file( ANTISPAM_BEE_LOG_FILE ) === 1 ) { 2377 | return false; 2378 | } 2379 | 2380 | $entry = sprintf( 2381 | '%s comment for post=%d from host=%s marked as spam%s', 2382 | current_time( 'mysql' ), 2383 | $comment['comment_post_ID'], 2384 | $comment['comment_author_IP'], 2385 | PHP_EOL 2386 | ); 2387 | 2388 | file_put_contents( 2389 | ANTISPAM_BEE_LOG_FILE, 2390 | $entry, 2391 | FILE_APPEND | LOCK_EX 2392 | ); 2393 | } 2394 | 2395 | 2396 | /** 2397 | * Sends the 403 header and terminates the connection 2398 | * 2399 | * @since 2.5.6 2400 | */ 2401 | private static function _go_in_peace() { 2402 | status_header( 403 ); 2403 | die( 'Spam deleted.' ); 2404 | } 2405 | 2406 | 2407 | /** 2408 | * Return real client IP 2409 | * 2410 | * @since 2.6.1 2411 | * @since 2.11.4 Only use `REMOTE_ADDR` to get the IP, make it filterable with `pre_comment_user_ip` 2412 | * @since 2.11.5 Switch to own filter `antispam_bee_trusted_ip` 2413 | * 2414 | * @hook string pre_comment_user_ip The Client IP 2415 | * 2416 | * @return string $ip Client IP 2417 | */ 2418 | public static function get_client_ip() { 2419 | /** 2420 | * Hook for allowing to modify the client IP used by Antispam Bee. Default value is the `REMOTE_ADDR`. 2421 | * IMPORTANT: Don’t return an empty string here, otherwise all comments are marked as spam. 2422 | * 2423 | * @link https://developer.wordpress.org/reference/hooks/pre_comment_user_ip/ 2424 | * 2425 | * @return string 2426 | */ 2427 | // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound 2428 | // phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotValidated 2429 | // phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized 2430 | return self::_sanitize_ip( (string) apply_filters( 'antispam_bee_trusted_ip', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) ); 2431 | // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound 2432 | // phpcs:enable WordPress.Security.ValidatedSanitizedInput.InputNotValidated 2433 | // phpcs:enable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized 2434 | } 2435 | 2436 | /** 2437 | * Sanitize an IP string. 2438 | * 2439 | * @param string $raw_ip The raw IP. 2440 | * 2441 | * @return string The sanitized IP or an empty string. 2442 | */ 2443 | private static function _sanitize_ip( $raw_ip ) { 2444 | 2445 | if ( strpos( $raw_ip, ',' ) !== false ) { 2446 | $ips = explode( ',', $raw_ip ); 2447 | $raw_ip = trim( $ips[0] ); 2448 | } 2449 | if ( function_exists( 'filter_var' ) ) { 2450 | return (string) filter_var( 2451 | $raw_ip, 2452 | FILTER_VALIDATE_IP 2453 | ); 2454 | } 2455 | 2456 | return (string) preg_replace( 2457 | '/[^0-9a-f:. ]/si', 2458 | '', 2459 | $raw_ip 2460 | ); 2461 | } 2462 | 2463 | 2464 | /** 2465 | * Add spam reason as comment data 2466 | * 2467 | * @since 2.6.0 2468 | * 2469 | * @param integer $comment_id Comment ID. 2470 | */ 2471 | public static function add_spam_reason_to_comment( $comment_id ) { 2472 | add_comment_meta( 2473 | $comment_id, 2474 | 'antispam_bee_reason', 2475 | self::$_reason 2476 | ); 2477 | } 2478 | 2479 | 2480 | /** 2481 | * Delete spam reason as comment data 2482 | * 2483 | * @since 2.6.0 2484 | * 2485 | * @param integer $comment_id Comment ID. 2486 | */ 2487 | public static function delete_spam_reason_by_comment( $comment_id ) { 2488 | delete_comment_meta( 2489 | $comment_id, 2490 | 'antispam_bee_reason' 2491 | ); 2492 | } 2493 | 2494 | /** 2495 | * Updates the Antispam Bee reason for manual transitions 2496 | * 2497 | * @since 2.9.2 2498 | * @param WP_Comment $comment Comment Object. 2499 | */ 2500 | public static function update_antispam_bee_reason( $comment ) { 2501 | update_comment_meta( $comment->comment_ID, 'antispam_bee_reason', 'manually' ); 2502 | } 2503 | 2504 | 2505 | /** 2506 | * Get the current post ID. 2507 | * 2508 | * @since 2.7.1 2509 | */ 2510 | public static function populate_post_id() { 2511 | 2512 | if ( null === self::$_current_post_id ) { 2513 | self::$_current_post_id = get_the_ID(); 2514 | } 2515 | } 2516 | 2517 | 2518 | /** 2519 | * Send notification via e-mail 2520 | * 2521 | * @since 0.1 2522 | * @since 2.5.7 2523 | * @since 2.10.0 Change plugin website URL 2524 | * 2525 | * @hook string antispam_bee_notification_subject Custom subject for notification mails 2526 | * 2527 | * @param int $id ID of the comment. 2528 | * @return int $id ID of the comment. 2529 | */ 2530 | public static function send_mail_notification( $id ) { 2531 | $options = self::get_options(); 2532 | 2533 | if ( ! $options['email_notify'] ) { 2534 | return $id; 2535 | } 2536 | 2537 | $comment = get_comment( $id, ARRAY_A ); 2538 | 2539 | if ( empty( $comment ) ) { 2540 | return $id; 2541 | } 2542 | 2543 | $post = get_post( $comment['comment_post_ID'] ); 2544 | if ( ! $post ) { 2545 | return $id; 2546 | } 2547 | 2548 | $subject = sprintf( 2549 | '[%s] %s', 2550 | stripslashes_deep( 2551 | // phpcs:ignore PHPCompatibility.ParameterValues.NewHTMLEntitiesEncodingDefault.NotSet 2552 | html_entity_decode( 2553 | get_bloginfo( 'name' ), 2554 | ENT_QUOTES 2555 | ) 2556 | ), 2557 | esc_html__( 'Comment marked as spam', 'antispam-bee' ) 2558 | ); 2559 | 2560 | // Content. 2561 | $content = strip_tags( stripslashes( $comment['comment_content'] ) ); 2562 | if ( ! $content ) { 2563 | $content = sprintf( 2564 | '-- %s --', 2565 | esc_html__( 'Content removed by Antispam Bee', 'antispam-bee' ) 2566 | ); 2567 | } 2568 | 2569 | // Prepare Comment Type. 2570 | $comment_name = __( 'Comment', 'antispam-bee' ); 2571 | if ( 'trackback' === $comment['comment_type'] ) { 2572 | $comment_name = __( 'Trackback', 'antispam-bee' ); 2573 | } 2574 | if ( 'pingback' === $comment['comment_type'] ) { 2575 | $comment_name = __( 'Pingback', 'antispam-bee' ); 2576 | } 2577 | 2578 | // Body. 2579 | $body = sprintf( 2580 | "%s \"%s\"\r\n\r\n", 2581 | esc_html__( 'New spam comment on your post', 'antispam-bee' ), 2582 | strip_tags( $post->post_title ) 2583 | ) . sprintf( 2584 | "%s: %s\r\n", 2585 | esc_html__( 'Author', 'antispam-bee' ), 2586 | ( empty( $comment['comment_author'] ) ? '' : strip_tags( $comment['comment_author'] ) ) 2587 | ) . sprintf( 2588 | "URL: %s\r\n", 2589 | // empty check exists. 2590 | esc_url( $comment['comment_author_url'] ) 2591 | ) . sprintf( 2592 | "%s: %s\r\n", 2593 | esc_html__( 'Type', 'antispam-bee' ), 2594 | esc_html( $comment_name ) 2595 | ) . sprintf( 2596 | "Whois: http://whois.arin.net/rest/ip/%s\r\n", 2597 | $comment['comment_author_IP'] 2598 | ) . sprintf( 2599 | "%s: %s\r\n\r\n", 2600 | esc_html__( 'Spam Reason', 'antispam-bee' ), 2601 | esc_html( self::$defaults['reasons'][ self::$_reason ] ) 2602 | ) . sprintf( 2603 | "%s\r\n\r\n\r\n", 2604 | $content 2605 | ) . ( 2606 | EMPTY_TRASH_DAYS ? ( 2607 | sprintf( 2608 | "%s: %s\r\n", 2609 | esc_html__( 'Trash it', 'antispam-bee' ), 2610 | admin_url( 'comment.php?action=trash&c=' . $id ) 2611 | ) 2612 | ) : ( 2613 | sprintf( 2614 | "%s: %s\r\n", 2615 | esc_html__( 'Delete it', 'antispam-bee' ), 2616 | admin_url( 'comment.php?action=delete&c=' . $id ) 2617 | ) 2618 | ) 2619 | ) . sprintf( 2620 | "%s: %s\r\n", 2621 | esc_html__( 'Approve it', 'antispam-bee' ), 2622 | admin_url( 'comment.php?action=approve&c=' . $id ) 2623 | ) . sprintf( 2624 | "%s: %s\r\n\r\n", 2625 | esc_html__( 'Spam list', 'antispam-bee' ), 2626 | admin_url( 'edit-comments.php?comment_status=spam' ) 2627 | ) . sprintf( 2628 | "%s\r\n%s\r\n", 2629 | esc_html__( 'Notify message by Antispam Bee', 'antispam-bee' ), 2630 | esc_html__( 'https://antispambee.pluginkollektiv.org/', 'antispam-bee' ) 2631 | ); 2632 | 2633 | wp_mail( 2634 | /** 2635 | * Filters the recipients of the spam notification. 2636 | * 2637 | * @param array The recipients array. 2638 | */ 2639 | apply_filters( 2640 | 'antispam_bee_notification_recipients', 2641 | array( get_bloginfo( 'admin_email' ) ) 2642 | ), 2643 | /** 2644 | * Filters the subject of the spam notification. 2645 | * 2646 | * @param string $subject subject line. 2647 | */ 2648 | apply_filters( 2649 | 'antispam_bee_notification_subject', 2650 | $subject 2651 | ), 2652 | $body 2653 | ); 2654 | 2655 | return $id; 2656 | } 2657 | 2658 | 2659 | 2660 | /* 2661 | * ############################ 2662 | * ####### STATISTICS ####### 2663 | * ############################ 2664 | */ 2665 | 2666 | /** 2667 | * Return the number of spam comments 2668 | * 2669 | * @since 0.1 2670 | * @since 2.4 2671 | */ 2672 | private static function _get_spam_count() { 2673 | // Init. 2674 | $count = intval( self::get_option( 'spam_count' ) ); 2675 | 2676 | // Fire. 2677 | return ( get_locale() === 'de_DE' ? number_format( $count, 0, '', '.' ) : number_format_i18n( $count ) ); 2678 | } 2679 | 2680 | 2681 | /** 2682 | * Output the number of spam comments 2683 | * 2684 | * @since 0.1 2685 | * @since 2.4 2686 | */ 2687 | public static function the_spam_count() { 2688 | echo esc_html( self::_get_spam_count() ); 2689 | } 2690 | 2691 | 2692 | /** 2693 | * Update the number of spam comments 2694 | * 2695 | * @since 0.1 2696 | * @since 2.6.1 2697 | */ 2698 | private static function _update_spam_count() { 2699 | // Skip if not enabled. 2700 | if ( ! self::get_option( 'dashboard_count' ) ) { 2701 | return; 2702 | } 2703 | 2704 | self::_update_option( 2705 | 'spam_count', 2706 | intval( self::get_option( 'spam_count' ) + 1 ) 2707 | ); 2708 | } 2709 | 2710 | /** 2711 | * Update statistics 2712 | * 2713 | * @since 1.9 2714 | * @since 2.6.1 2715 | */ 2716 | private static function _update_daily_stats() { 2717 | // Skip if not enabled. 2718 | if ( ! self::get_option( 'dashboard_chart' ) ) { 2719 | return; 2720 | } 2721 | 2722 | // Init. 2723 | $stats = (array) self::get_option( 'daily_stats' ); 2724 | $today = (int) strtotime( 'today' ); 2725 | 2726 | // Count up. 2727 | if ( array_key_exists( $today, $stats ) ) { 2728 | $stats[ $today ]++; 2729 | } else { 2730 | $stats[ $today ] = 1; 2731 | } 2732 | 2733 | // Sort. 2734 | krsort( $stats, SORT_NUMERIC ); 2735 | 2736 | // Save. 2737 | self::_update_option( 2738 | 'daily_stats', 2739 | array_slice( $stats, 0, 31, true ) 2740 | ); 2741 | } 2742 | 2743 | /** 2744 | * Returns the secret of a post used in the textarea name attribute. 2745 | * 2746 | * @since 2.10.0 Modify secret generation because `always_allowed` option not longer exists 2747 | * 2748 | * @param int $post_id The Post ID. 2749 | * 2750 | * @return string 2751 | */ 2752 | public static function get_secret_name_for_post( $post_id ) { 2753 | $secret = substr( sha1( md5( 'comment-id' . self::$_salt ) ), 0, 10 ); 2754 | 2755 | $secret = self::ensure_secret_starts_with_letter( $secret ); 2756 | 2757 | /** 2758 | * Filters the secret for a post, which is used in the textarea name attribute. 2759 | * 2760 | * @param string $secret The secret. 2761 | * @param int $post_id The post ID. 2762 | * @param bool $always_allowed Whether the comment form is used outside of the single post view or not. 2763 | */ 2764 | return apply_filters( 2765 | 'ab_get_secret_name_for_post', 2766 | $secret, 2767 | (int) $post_id, 2768 | (bool) self::get_option( 'always_allowed' ) 2769 | ); 2770 | } 2771 | 2772 | /** 2773 | * Returns the secret of a post used in the textarea id attribute. 2774 | * 2775 | * @since 2.10.0 Modify secret generation because `always_allowed` option not longer exists 2776 | * 2777 | * @param int $post_id The post ID. 2778 | * 2779 | * @return string 2780 | */ 2781 | public static function get_secret_id_for_post( $post_id ) { 2782 | 2783 | $secret = substr( sha1( md5( 'comment-id' . self::$_salt ) ), 0, 10 ); 2784 | 2785 | $secret = self::ensure_secret_starts_with_letter( $secret ); 2786 | 2787 | /** 2788 | * Filters the secret for a post, which is used in the textarea id attribute. 2789 | * 2790 | * @param string $secret The secret. 2791 | * @param int $post_id The post ID. 2792 | * @param bool $always_allowed Whether the comment form is used outside of the single post view or not. 2793 | */ 2794 | return apply_filters( 2795 | 'ab_get_secret_id_for_post', 2796 | $secret, 2797 | (int) $post_id, 2798 | (bool) self::get_option( 'always_allowed' ) 2799 | ); 2800 | } 2801 | 2802 | /** 2803 | * Ensures that the secret starts with a letter. 2804 | * 2805 | * @param string $secret The secret. 2806 | * 2807 | * @return string 2808 | */ 2809 | public static function ensure_secret_starts_with_letter( $secret ) { 2810 | 2811 | $first_char = substr( $secret, 0, 1 ); 2812 | if ( is_numeric( $first_char ) ) { 2813 | return chr( $first_char + 97 ) . substr( $secret, 1 ); 2814 | } else { 2815 | return $secret; 2816 | } 2817 | } 2818 | 2819 | /** 2820 | * Returns 'spam' 2821 | * 2822 | * @since 2.7.3 2823 | * 2824 | * @return string 2825 | */ 2826 | public static function return_spam() { 2827 | 2828 | return 'spam'; 2829 | } 2830 | 2831 | /** 2832 | * A wrapper around wp_parse_url(). 2833 | * 2834 | * @since 2.8.2 2835 | * 2836 | * @param string $url The URL to parse. 2837 | * @param string $component The component to get back. 2838 | * 2839 | * @return string 2840 | */ 2841 | private static function parse_url( $url, $component = 'host' ) { 2842 | 2843 | $parts = wp_parse_url( $url ); 2844 | return ( is_array( $parts ) && isset( $parts[ $component ] ) ) ? $parts[ $component ] : ''; 2845 | } 2846 | 2847 | /** 2848 | * Updates the database structure if necessary 2849 | * 2850 | * @since 2.10.0 Add update routine for country option names 2851 | */ 2852 | public static function update_database() { 2853 | if ( self::db_version_is_current() ) { 2854 | return; 2855 | } 2856 | 2857 | $version_from_db = floatval( get_option( 'antispambee_db_version', 0 ) ); 2858 | if ( $version_from_db < 1.01 ) { 2859 | global $wpdb; 2860 | 2861 | /** 2862 | * In Version 2.9 the IP of the commenter was saved as a hash. We reverted this solution. 2863 | * Therefore, we need to delete this unused data. 2864 | */ 2865 | //phpcs:disable WordPress.DB.PreparedSQL.NotPrepared 2866 | $sql = 'delete from `' . $wpdb->commentmeta . '` where `meta_key` IN ("antispam_bee_iphash")'; 2867 | $wpdb->query( $sql ); 2868 | //phpcs:enable WordPress.DB.PreparedSQL.NotPrepared 2869 | } 2870 | 2871 | // DB version was raised in ASB 2.10.0 to 1.02. 2872 | if ( $version_from_db < 1.02 ) { 2873 | // Update option names. 2874 | $options = self::get_options(); 2875 | if ( isset( $options['country_black'] ) ) { 2876 | $options['country_denied'] = $options['country_black']; 2877 | unset( $options['country_black'] ); 2878 | } 2879 | if ( isset( $options['country_white'] ) ) { 2880 | $options['country_allowed'] = $options['country_white']; 2881 | unset( $options['country_white'] ); 2882 | } 2883 | 2884 | update_option( 2885 | 'antispam_bee', 2886 | $options 2887 | ); 2888 | 2889 | wp_cache_set( 2890 | 'antispam_bee', 2891 | $options 2892 | ); 2893 | } 2894 | 2895 | update_option( 'antispambee_db_version', self::$db_version ); 2896 | } 2897 | 2898 | /** 2899 | * Whether the database structure is up to date. 2900 | * 2901 | * @since 2.10.0 Return a float instead of int 2902 | * 2903 | * @return bool 2904 | */ 2905 | private static function db_version_is_current() { 2906 | $current_version = floatval( get_option( 'antispambee_db_version', 0 ) ); 2907 | 2908 | return $current_version === self::$db_version; 2909 | } 2910 | 2911 | /** 2912 | * Runs after upgrades are completed. 2913 | * 2914 | * @since 2.10.0 2915 | * 2916 | * @param \WP_Upgrader $wp_upgrader WP_Upgrader instance. 2917 | * @param array $hook_extra Array of bulk item update data. 2918 | */ 2919 | public static function upgrades_completed( $wp_upgrader, $hook_extra ) { 2920 | if ( ! $wp_upgrader instanceof Plugin_Upgrader || ! isset( $hook_extra['plugins'] ) ) { 2921 | return; 2922 | } 2923 | 2924 | $updated_plugins = $hook_extra['plugins']; 2925 | $asb_updated = false; 2926 | foreach ( $updated_plugins as $updated_plugin ) { 2927 | if ( $updated_plugin !== self::$_base ) { 2928 | continue; 2929 | } 2930 | $asb_updated = true; 2931 | } 2932 | 2933 | if ( false === $asb_updated ) { 2934 | return; 2935 | } 2936 | 2937 | self::asb_updated(); 2938 | } 2939 | 2940 | /** 2941 | * Runs after an upgrade via an uploaded ZIP package was completed. 2942 | * 2943 | * @since 2.10.0 2944 | * 2945 | * @param string $package The package file. 2946 | * @param array $data The new plugin or theme data. 2947 | * @param string $package_type The package type. 2948 | */ 2949 | public static function uploaded_upgrade_completed( $package, $data, $package_type ) { 2950 | if ( 'plugin' !== $package_type ) { 2951 | return; 2952 | } 2953 | 2954 | $text_domain = isset( $data['TextDomain'] ) ? $data['TextDomain'] : ''; 2955 | 2956 | if ( 'antispam-bee' !== $text_domain ) { 2957 | return; 2958 | } 2959 | 2960 | self::asb_updated(); 2961 | } 2962 | 2963 | /** 2964 | * Runs after ASB was updated. 2965 | * 2966 | * @since 2.10.0 2967 | * 2968 | * @return void 2969 | */ 2970 | private static function asb_updated() { 2971 | self::update_database(); 2972 | } 2973 | } 2974 | 2975 | 2976 | // Fire. 2977 | add_action( 2978 | 'plugins_loaded', 2979 | array( 2980 | 'Antispam_Bee', 2981 | 'init', 2982 | ) 2983 | ); 2984 | 2985 | // Activation. 2986 | register_activation_hook( 2987 | __FILE__, 2988 | array( 2989 | 'Antispam_Bee', 2990 | 'activate', 2991 | ) 2992 | ); 2993 | 2994 | // Deactivation. 2995 | register_deactivation_hook( 2996 | __FILE__, 2997 | array( 2998 | 'Antispam_Bee', 2999 | 'deactivate', 3000 | ) 3001 | ); 3002 | 3003 | // Uninstall. 3004 | register_uninstall_hook( 3005 | __FILE__, 3006 | array( 3007 | 'Antispam_Bee', 3008 | 'uninstall', 3009 | ) 3010 | ); 3011 | 3012 | // Upgrade notice. 3013 | add_action( 3014 | 'in_plugin_update_message-' . __FILE__, 3015 | array( 3016 | 'Antispam_Bee', 3017 | 'upgrade_notice', 3018 | ) 3019 | ); 3020 | --------------------------------------------------------------------------------