├── CHANGELOG.md ├── LICENSE.txt ├── antispam_bee.php ├── css ├── dashboard.css └── styles.css ├── inc ├── columns.class.php └── gui.class.php ├── js ├── dashboard.js ├── raphael.helper.js ├── raphael.min.js └── scripts.js └── readme.txt /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## Changelog ## 2 | 3 | ### 2.11.7 ### 4 | 5 | * **English** 6 | * Tweak: Use SCRIPT_NAME instead of REQUEST_URI to check path 7 | * Fix: Remove `add_reasons_to_defaults()` from general initialization for better WordPress 6.7 compatibility 8 | * Maintenance: Tested up to WordPress 6.7 9 | 10 | * **Deutsch** 11 | * Tweak: Verwende SCRIPT_NAME anstelle von REQUEST_URI, um den Pfad zu prüfen 12 | * Fix: Entfernen von `add_reasons_to_defaults()` von der allgemeinen Initialisierung für bessere WordPress 6.7 Kompatibilität 13 | * Wartung: Getestet mit WordPress 6.7 14 | 15 | ### 2.11.6 ### 16 | * **English** 17 | * Fix: Delete missed out option on uninstall (Thanks @okvee!) 18 | * Tweak: Minor i18n improvements (Thanks Pedro!) 19 | * Tweak: Minor code changes and housekeeping 20 | * Tweak: Updated dependencies 21 | 22 | * **Deutsch** 23 | * Fix: Bei Deinstallation wurde eine Option nicht korrekt gelöscht (Danke @okvee!) 24 | * Tweak: Kleinere i18n-Verbesserungen (Danke Pedro!) 25 | * Tweak: Kleinere Code-Änderungen und Aufräumarbeiten 26 | * Tweak: Aktualisierte Abhängigkeiten 27 | 28 | ### 2.11.5 ### 29 | 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). 30 | 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). 31 | * **English** 32 | * Fix: Usage of core filter `pre_comment_user_ip` breaks ASB if the IP address is removed for GDPR compliance 33 | 34 | * **Deutsch** 35 | * 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 36 | 37 | ### 2.11.4 ### 38 | 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`. 39 | 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. 40 | * **English** 41 | * Fix: Read client IP for country check from `REMOTE_ADDR` only (filterable via `pre_comment_user_ip`) 42 | * Fix: No spam reason in spam notification email, and related PHP warning 43 | * Fix: Remove outdated info from readme 44 | * Enhancement: Show upgrade notice on plugin overview page 45 | * Maintenance: Tested up to WordPress 6.3 46 | 47 | * **Deutsch** 48 | * Fix: Client-IP wird nur noch aus `REMOTE_ADDR` ermittelt (filterbar über `pre_comment_user_ip`) 49 | * Fix: Der Spam-Grund wird wieder korrekt in der Benachrichtigungs-E-Mail zu Spam angezeigt und die damit zusammenhängende PHP-Warning behoben 50 | * Fix: Veraltete Infos aus der Readme wurden entfernt 51 | * Verbesserung: Upgrade-Hinweis wird auch in der Plugin-Übersicht angezeigt 52 | * Wartung: Getestet mit WordPress 6.3 53 | 54 | ### 2.11.3 ### 55 | * **English** 56 | * Fix: Multiselect for "Delete comments by spam reasons" was not saving values 57 | * Fix: Fix broken link for ISO country codes 58 | * Maintenance: Added test for PHP 8.2 59 | * Maintenance: Tested up to WordPress 6.2 60 | 61 | * **Deutsch** 62 | * Behoben: Multiselect für "Kommentare aus Spamgründen löschen" speicherte keine Werte 63 | * Fix: Fehlerhafter Link für ISO-Ländercodes behoben 64 | * Wartung: Test für PHP 8.2 hinzugefügt 65 | * Wartung: Getestet mit WordPress 6.2 66 | 67 | ### 2.11.2 ### 68 | * **English** 69 | * Tweak: remove superfluous translations 70 | * Tweak: make FAQ link an anchor link 71 | * Fix: spam counter no longer raises a warning with PHP 8.1 if no spam is present yet 72 | * Fix: spam reasons are now localized correctly 73 | * Fix: Translations were loaded twice on some admin pages 74 | * Maintenance: Tested up to WordPress 6.1 75 | 76 | * **Deutsch** 77 | * Tweak: Überflüssige Übersetzungen entfernt 78 | * Tweak: Link zu den FAQ ist jetzt ein Anker-Link 79 | * Fix: Der Spam-Zähler erzeugt mit PHP 8.1 keine Warnung mehr, wenn noch kein Spam vorhanden ist 80 | * Fix: Spam-Gründe werden nun korrekt übersetzt 81 | * Fix: Übersetzungen wurden auf einzelnen Adminseiten doppelt geladen 82 | * Wartung: Getestet mit WordPress 6.1 83 | 84 | ### 2.11.1 ### 85 | * **English** 86 | * Tweak: remove superfluous type attribute from inline script tag 87 | * Maintenance: Tested up to WordPress 6.0 88 | 89 | * **Deutsch** 90 | * Tweak: Überflüssiges type-Attribut von script-Tag entfernt 91 | * Wartung: Getestet mit WordPress 6.0 92 | 93 | ### 2.11.0 ### 94 | * **English** 95 | * Fix: Allow empty comments if `allow_empty_comment` is set to true 96 | * Fix: Add `aria-label` to work around bug in a11y testing tools 97 | * Fix: Change priority for `comment_form_field_comment` from 10 to 99 98 | * Tweak: Updated some FAQ entries 99 | * Tweak: Updated build tooling 100 | 101 | * **Deutsch** 102 | * Fix: Leere Kommentare erlauben, wenn der Filter `allow_empty_comment` gesetzt ist 103 | * Fix: Ein `aria-label` hinzugefügt, um einen bekannten Fehler bei Tests zu umgehen 104 | * Fix: Änderung der Priorität vom Filter `comment_form_field_comment` von 10 auf 99 105 | * Tweak: Aktualisierungen in der FAQ 106 | * Tweak: Optimierungen am Build-Prozess 107 | 108 | ### 2.10.0 ### 109 | * **English** 110 | * Fix: Switch from ip2country.info to iplocate.io for country check 111 | * Enhancement: Use filter to add the honeypot field instead of output buffering for new installations and added option to switch between the both ways 112 | * Tweak: Added comment user agent to regex pattern check 113 | * Tweak: Make the ping detection filterable to support new comment types 114 | * Tweak: Updated internal documentation links 115 | * Tweak: Several updates and optimizations in the testing process 116 | * Tweak: Adjust color palette to recent WP version 117 | * Tweak: Adjust wording in variables and option names 118 | * Readme: Add new contributor and clean up unused code 119 | 120 | * **Deutsch** 121 | * Fix: Wechsel von ip2country.info zu iplocate.io für die Länderprüfung 122 | * 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 123 | * Tweak: Kommentar User-Agent zu Regex-Pattern hinzugefügt 124 | * Tweak: Die Ping-Erkennung ist jetzt filterbar, um neue Kommentartypen zu unterstützen 125 | * Tweak: Aktualisierte Links zur internen Dokumentation 126 | * Tweak: Verschiedene Aktualisierungen und Optimierungen im Testprozess 127 | * Tweak: Farbpalette an aktuelle WP-Version anpassen 128 | * Tweak: Wortlaut in Variablen und Optionsnamen wurden angepasst 129 | * Readme: Neuer Contributor hinzugefügt und unbenutzten Code bereinigt 130 | 131 | ### 2.9.4 ### 132 | * **English** 133 | * Enhancement: Add filter to allow ajax calls 134 | * Tweak: Better wording for BBCode feature in plugin description 135 | * Tweak: Better screenshots in the plugin directory 136 | * Maintenance: Tested up to WordPress 5.7 137 | 138 | * **Deutsch** 139 | * Verbesserung: Filter hinzugefügt, um Ajax-Aufrufe zuzulassen 140 | * Tweak: Bessere Formulierung für BBCode-Funktion in Plugin-Beschreibung 141 | * Tweak: Bessere Screenshots im Plugin-Verzeichnis 142 | * Wartung: Getestet mit WordPress 5.7 143 | 144 | ### 2.9.3 ### 145 | * **English** 146 | * Fixed: Compatibility with WordPress 5.5 147 | * Fixed: Undefined index on spam list page 148 | * Tweak: Better wording on settings page 149 | * Tweak: AMP compatibility 150 | * Tweak: Protect CSS from overwrite through bad themes 151 | 152 | * **Deutsch** 153 | * Fix: Kompatibilität mit WordPress 5.5 154 | * Fix: Undefined index in Spamliste 155 | * Tweak: Inklusivere Sprache unter Einstellungen 156 | * Tweak: AMP-Kompatibilität 157 | * Tweak: Schütze CSS besser vor Überschreiben durch schlechte Themes 158 | 159 | ### 2.9.2 ### 160 | * **English** 161 | * 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/) 162 | * Fix: Statistic in dashboard showed wrong value 163 | * Tweak: Change autocomplete attribute to "new-password" 164 | * Tweak: Autoptimize compatibility improved 165 | * Tweak: Renamed blacklist/whitelist to a better phrase 166 | * Tweak: Added new pattern 167 | * Tweak: UI and text optimizations 168 | * Tweak: Better compatibility with some server configurations 169 | * Tweak: Make spam reason sortable and filterable 170 | * Tweak: Add spam reason for manually marked spam 171 | * Maintenance: Deleted unused code 172 | * Maintenance: Removed Fake IP check (unreliable and producing false positives) 173 | * Maintenance: Fix some coding standard issues 174 | * Maintenance: Tested up to WordPress 5.4 175 | * Maintenance: Tested up to PHP 7.4 176 | 177 | 178 | * **Deutsch** 179 | * 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/) 180 | * Fix: Dashboard Statistiken zeigten falschen Wert 181 | * Tweak: Änderung des autocomplete Attributs zu "new-password" 182 | * Tweak: Kompatibilität mit Autoptimize verbessert 183 | * Tweak: "Blacklist/Whitelist" umbenannt 184 | * Tweak: Neue Spamerkennungsmuster hinzugefügt 185 | * Tweak: UI und Textverbesserungen 186 | * Tweak: Erhöhte Kompatibilität mit einigen Serverkonfigurationen 187 | * Tweak: Kommentare nach Spamgrund sortier- und filterbar gemacht 188 | * Tweak: Neuer Spamgrund für manuell markierten Spam eingeführt 189 | * Maintenance: Ungenutzter Code wurde gelöscht 190 | * Maintenance: Der Fake IP check wurde entfernt. Dieser war unzuverlässig und produzierte falsche Ergebnisse 191 | * Maintenance: Einige Probleme mit unseren Coding standards wurden gefixt 192 | * Maintenance: Getestet bis WordPress 5.4 193 | * Maintenance: Getestet bis PHP 7.4 194 | 195 | ### 2.9.1 ### 196 | * **English** 197 | * Improved backend accessibility 198 | * Prefilled comment textareas do now work with the honeypot 199 | * Compatible with the AMP plugin (https://wordpress.org/plugins/amp/) 200 | * Improved dashboard tooltips 201 | * Improvements for the language detection API 202 | * Scalable IP look up for local spam database 203 | 204 | 205 | * **Deutsch** 206 | * Verbesserte Barrierefreiheit im Backend 207 | * Vorausgefüllte Kommentarfelder arbeiten jetzt mit dem Honeypot zusammen 208 | * Kompatibel mit dem AMP Plugin (https://wordpress.org/plugins/amp/) 209 | * Verbesserte Tooltips im Dashboard 210 | * Verbesserte Kommunikation mit der Spracherkennungs-API 211 | * Skalierbarer IP-Abgleich für den lokalen Datenbank-Check. 212 | 213 | ### 2.9.0 ### 214 | * **English** 215 | * Introduction of coding standards. 216 | * Switch to franc language detection API for the language check. 217 | * Do not longer overwrite the IP address WordPress saves with the comment by using `pre_comment_user_ip`. 218 | * Do not show "Trust commenters with a Gravatar" if the "Show Gravatar" option is not set. 219 | * Skip the checks, when I ping myself. 220 | * Fixes some wrong usages of the translation functions. 221 | * Use the regular expressions check also for trackbacks. 222 | * Add option to delete Antispam Bee related data when plugin gets deleted via the admin interface. 223 | * Save a hashed + salted IP for every comment 224 | * New check for incoming Trackbacks. 225 | * Introduction of behat tests. 226 | * Updates the used JavaScript library for the statistics widget. 227 | * Bugfix in the "Comment form used outside of posts" option. 228 | 229 | * **Deutsch** 230 | * Einführung von Coding Standards. 231 | * Wechsel auf die Franc Spracherkennungs API für den Sprach-Check. 232 | * Beendet das Überschreiben der IP Adresse via `pre_comment_user_ip`, welche WordPress mit dem Kommentar speichert. 233 | * Zeige die Option "Vertraue Kommentaren mit Gravatar" nur an wenn die Option "Zeige Gravatar" aktiviert ist. 234 | * Überspringe die Filter, wenn ich mich selbst anpinge. 235 | * Repariert einige falsche Verwendungsweisen der Übersetzungsfunktionalitäten. 236 | * Wende den reguläre Ausdrücke Check auch auf Trackbacks an. 237 | * Option hinzugefügt, dass Daten von Antispam Bee gelöscht werden, wenn das Plugin über das Admin Interface gelöscht wird. 238 | * Speichere für jeden Kommentar eine salted Hash der IP Adresse. 239 | * Ein neuer Check für eingehende Trackbacks. 240 | * Einführung von Behat tests. 241 | * Aktualisiert die genutzte JavaScript Bibliothek für das Statistik Widget. 242 | * Bugfix in der "Kommentarformular wird außerhalb von Beiträgen verwendet" Einstellung 243 | 244 | ### 2.8.1 ### 245 | 246 | * **English** 247 | * PHP 5.3 compatibility 248 | * Bugfix where a spam trackback produced a fatal error 249 | * For more details see https://github.com/pluginkollektiv/antispam-bee/milestone/8?closed=1 250 | 251 | * **Deutsch** 252 | * PHP 5.3 Kompatibilität wieder hergestellt 253 | * Bugfix: Ein Spam Trackback produzierte einen Fatal Error 254 | * Mehr Details: https://github.com/pluginkollektiv/antispam-bee/milestone/8?closed=1 255 | 256 | ### 2.8.0 ### 257 | 258 | * **English** 259 | * Removed stopforumspam.com to avoid potential GDPR violation 260 | * Improves IP handling to comply with GDPR 261 | * Improves PHP7.2 compatibility 262 | * Fixes small bug on mobile views 263 | * Allow more than one language in language check 264 | * Minor interface improvements 265 | * Remove old russian and Dutch translation files 266 | * For more details see https://github.com/pluginkollektiv/antispam-bee/milestone/4?closed=1 267 | 268 | * **Deutsch** 269 | - Entfernt stopforumspam.com zur Vorbeugung möglicher DSGVO-Verletzungen 270 | - Verändert den Umgang mit IP-Adressen um der DSGVO zu entsprechen 271 | - Verbessert PHP7.2-Kompatibilität 272 | - Behebt einen CSS-Bugfix der mobilen Darstellung 273 | - Erlaube mehr als eine Sprache im Sprachencheck 274 | - Verberesserungen an der Benutzeroberfläche 275 | - Entfernt alte russische und holländische Sprachversionen 276 | - Mehr Details: https://github.com/pluginkollektiv/antispam-bee/milestone/4?closed=1 277 | 278 | ### 2.7.1 ### 279 | 280 | * **English** 281 | * Fixes an incompatibility with Chrome autofill 282 | * Fixes some incompatibilities with other plugins/themes where the comment field was left empty 283 | * Support for RTL 284 | * Solve some translation/language issues 285 | * A new filter to add languages to the language check 286 | * For more details see https://github.com/pluginkollektiv/antispam-bee/milestone/6?closed=1 287 | * **Deutsch** 288 | - Behebt eine Inkompatibilität mit Chromes Autofill-Funktion 289 | - Behebt einige Inkompatibilitäten mit anderen Plugins/Themes, wo das Kommentarfeld leer bliebt 290 | - Unterstützt RTL-Sprachen 291 | - Behebt einige Probleme im Bereich Sprache/Übersetzung 292 | - Bietet einen neuen Filter zum HInzufügen von Sprachen zum Sprach-Check 293 | - Mehr Details: https://github.com/pluginkollektiv/antispam-bee/milestone/6?closed=1 294 | 295 | ### 2.7.0 ### 296 | * **English** 297 | * Country check is back again (thanks to Sergej Müller for his amazing work and the service page) 298 | * Improved Honeypot 299 | * Language check through Google Translate API is back again (thanks to [Simon Kraft](https://simonkraft.de/) for offering to cover the costs) 300 | * More default Regexes 301 | * Unit Test Framework 302 | * Accessibility and GUI improvements 303 | * An [english documentation](https://github.com/pluginkollektiv/antispam-bee/wiki) is now available, too. Some corrections in the german documentation. 304 | * Some bugfixes - Among other things for WPML compatibility 305 | * For more details see https://github.com/pluginkollektiv/antispam-bee/milestone/3?closed=1 306 | 307 | * **Deutsch** 308 | * Die Länderprüfung ist wieder zurück (dank an Sergej Müller für seine fantastische Arbeit und die Service-Seite) 309 | * Der Honeypot wurde verbessert 310 | * 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) 311 | * Mehr Standard-Regexe 312 | * Verbesserungen an Barrierefreiheit und Benutzer-Oberfläche 313 | * Eine [englische Dokumentation](https://github.com/pluginkollektiv/antispam-bee/wiki) ist jetzt verfügbar. Einige Korrekturen in der deutschen Dokumentation. 314 | * Einige Fehlerkorrekturen - Unter anderem für WPML-Kompatibilität 315 | * Mehr Details: https://github.com/pluginkollektiv/antispam-bee/milestone/3?closed=1 316 | 317 | ### 2.6.9 ### 318 | * **English** 319 | * Updates donation links throughout the plugin 320 | * Fixes an error were JavaScript on the dashboard was erroneously being enqueued 321 | * Ensures compatibility with the latest WordPress version 322 | * **Deutsch** 323 | * Aktualisierung der Spenden Links im gesamten Plugin 324 | * Behebt einen Fehler, durch den auf dem Dashboard fälschlicherweise JavaScript geladen wird 325 | * Gewährleistet die Kompatibilität mit der neuesten WordPress-Version 326 | 327 | ### 2.6.8 ### 328 | * **English** 329 | * added a POT file 330 | * updated German translation, added formal version 331 | * updated plugin text domain to include a dash instead of an underscore 332 | * updated, translated + formatted README.md 333 | * updated expired link URLs in plugin and languages files 334 | * updated [plugin authors](https://gist.github.com/glueckpress/f058c0ab973d45a72720) 335 | * **Deutsch** 336 | * eine POT-Datei hinzugefügt 337 | * deutsche Übersetzung aktualisiert, formale Version hinzugefügt 338 | * Die Text Domain des Plugins in der ReadMe aktualisiert. Statt einem Unterstrich enthält der Name nun ein Bindestrich. 339 | * README.md aktualisiert, übersetzt und formatiert 340 | * verwaiste Link-Adressen in dem Plugin und den Sprachdateien aktualisiert 341 | * [Plugin Autor](https://gist.github.com/glueckpress/f058c0ab973d45a72720) aktualisiert 342 | 343 | ### 2.6.7 ### 344 | * **English** 345 | * Removal of functions *Block comments from specific countries* and *Allow comments only in certain language* for financial reasons 346 | * **Deutsch** 347 | * 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/) 348 | 349 | ### 2.6.6 ### 350 | * **English** 351 | * Switch to the official Google Translation API 352 | * *Release time investment (Development & QA): 2.5 h* 353 | * **Deutsch** 354 | * (Testweise) Umstellung auf die offizielle Google Translation API 355 | * *Release-Zeitaufwand (Development & QA): 2,5 Stunden* 356 | 357 | ### 2.6.5 ### 358 | * **English** 359 | * Fix: Return parameters on `dashboard_glance_items` callback / thx [@toscho](https://twitter.com/toscho) 360 | * New function: [Trust commenters with a Gravatar](https://antispambee.pluginkollektiv.org/documentation#gravatar) / thx [@glueckpress](https://twitter.com/glueckpress) 361 | * Additional plausibility checks and filters 362 | * *Release time investment (Development & QA): 12 h* 363 | * **Deutsch** 364 | * Fix: Parameter-Rückgabe bei `dashboard_glance_items` / thx [@toscho](https://twitter.com/toscho) 365 | * Neue Funktion: [Kommentatoren mit Gravatar vertrauen](https://antispambee.pluginkollektiv.org/de/dokumentation#gravatar) / thx [@glueckpress](https://twitter.com/glueckpress) 366 | * Zusätzliche Plausibilitätsprüfungen und Filter 367 | * *Release-Zeitaufwand (Development & QA): 12 Stunden* 368 | 369 | ### 2.6.4 ### 370 | * **English** 371 | * Consideration of the comment time (Spam if a comment was written in less than 5 seconds) 372 | * *Release time investment (Development & QA): 6.25 h* 373 | * **Deutsch** 374 | * 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/) 375 | * *Release-Zeitaufwand (Development & QA): 6,25 Stunden* 376 | 377 | ### 2.6.3 ### 378 | * **English** 379 | * Sorting for the Antispam Bee column in the spam comments overview 380 | * Code refactoring around the use of REQUEST_URI 381 | * *Release time investment (Development & QA): 2.75 h* 382 | * **Deutsch** 383 | * Sortierung für die Antispam Bee Spalte in der Spam-Übersicht 384 | * Code-Refactoring rund um die Nutzung von REQUEST_URI 385 | * *Release-Zeitaufwand (Development & QA): 2,75 Stunden* 386 | 387 | ### 2.6.2 ### 388 | * **English** 389 | * Improving detection of fake IPs 390 | * *Release time investment (Development & QA): 11 h* 391 | * **Deutsch** 392 | * Überarbeitung der Erkennung von gefälschten IPs 393 | * *Release-Zeitaufwand (Development & QA): 11 Stunden* 394 | 395 | ### 2.6.1 ### 396 | * **English** 397 | * Code refactoring of options management 398 | * Support for `HTTP_FORWARDED_FOR` header 399 | * *Release time investment (Development & QA): 8.5 h* 400 | * **Deutsch** 401 | * Überarbeitung der Optionen-Verwaltung 402 | * Berücksichtigung der Header `HTTP_FORWARDED_FOR` 403 | * *Release-Zeitaufwand (Development & QA): 8,5 Stunden* 404 | 405 | ### 2.6.0 ### 406 | * **English** 407 | * Optimizations for WordPress 3.8 408 | * Clear invalid UTF-8 characters in comment fields 409 | * Spam reason as a column in the table with spam comments 410 | * **Deutsch** 411 | * Optimierungen für WordPress 3.8 412 | * Zusatzprüfung auf Nicht-UTF-8-Zeichen in Kommentardaten 413 | * Spamgrund als Spalte in der Übersicht mit Spamkommentaren 414 | 415 | ### 2.5.9 ### 416 | * **English** 417 | * Dashboard widget changes to work with [Statify](http://statify.de) 418 | * **Deutsch** 419 | * Anpassung des Dashboard-Skriptes für die Zusammenarbeit mit [Statify](http://statify.de) 420 | 421 | ### 2.5.8 ### 422 | * **English** 423 | * Switch from TornevallDNSBL to [Stop Forum Spam](http://www.stopforumspam.com) 424 | * New JS library for the Antispam Bee dashboard chart 425 | * **Deutsch** 426 | * Umstellung von TornevallDNSBL zu [Stop Forum Spam](http://www.stopforumspam.com) 427 | * Neue JS-Bibliothek für das Dashboard-Widget 428 | 429 | ### 2.5.7 ### 430 | * **English** 431 | * Optional logfile with spam entries e.g. for [Fail2Ban](https://help.ubuntu.com/community/Fail2ban) 432 | * Filter `antispam_bee_notification_subject` for a custom subject in notifications 433 | * **Deutsch** 434 | * Optionale Spam-Logdatei z.B. für [Fail2Ban](https://wiki.ubuntuusers.de/fail2ban/) 435 | * Filter `antispam_bee_notification_subject` für eigenen Betreff in Benachrichtigungen 436 | 437 | ### 2.5.6 ### 438 | * **English** 439 | * [Added new detection/patterns for spam comments](https://antispambee.pluginkollektiv.org/news/2013/new-patterns-in-antispam-bee-2-5-6/) 440 | * **Deutsch** 441 | * [Neue Erkennungsmuster für Spam hinzugefügt](https://antispambee.pluginkollektiv.org/de/news/2013/neue-erkennungsmuster-in-antispam-bee-2-5-6/) 442 | 443 | ### 2.5.5 ### 444 | * **English** 445 | * 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). 446 | * **Deutsch** 447 | * 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/). 448 | 449 | ### 2.5.4 ### 450 | * **English** 451 | * Jubilee edition 452 | * New mascot for Antispam Bee 453 | * Advanced Scanning on IP, URL and e-mail address of incoming comments in local blog spam database 454 | * **Deutsch** 455 | * Jubiläumsausgabe: [Details zum Update](https://plus.googlehttps://antispambee.pluginkollektiv.org/de/news/2013/jubilaeumsausgabe-antispam-bee-2-5-4/) 456 | * Neues Maskottchen für Antispam Bee 457 | * Erweiterte Prüfung eingehender Kommentare in lokaler Blog-Spamdatenbank auf IP, URL und E-Mail-Adresse 458 | 459 | ### 2.5.3 ### 460 | * **English** 461 | * Optimization of regular expression 462 | * **Deutsch** 463 | * Optimierung des Regulären Ausdrucks 464 | 465 | ### 2.5.2 ### 466 | * **English** 467 | * New: Use of regular expressions with predefined and own identification patterns 468 | * Change the filter order 469 | * Improvements to the language file 470 | * **Deutsch** 471 | * Neu: [Reguläre Ausdrücke anwenden](hhttps://antispambee.pluginkollektiv.org/de/dokumentation#regex) mit vordefinierten und eigenen Erkennungsmustern 472 | * Änderung der Filter-Reihenfolge 473 | * Verbesserungen an der Sprachdatei 474 | 475 | ### 2.5.1 ### 476 | * **English** 477 | * Treat BBCode as spam 478 | * IP anonymization in the country evaluation 479 | * More transparency by added Privacy Policy 480 | * PHP 5.2.4 as a requirement (is also the prerequisite for WP 3.4) 481 | * **Deutsch** 482 | * [BBCode im Kommentar als Spamgrund](hhttps://antispambee.pluginkollektiv.org/de/dokumentation#bbcode) 483 | * IP-Anonymisierung bei der Länderprüfung 484 | * [Mehr Transparenz](https://antispambee.pluginkollektiv.org/de/news/2012/datenschutz-update/) durch hinzugefügte Datenschutzhinweise 485 | * PHP 5.2.4 als Voraussetzung (ist zugleich die Voraussetzung für WP 3.4) 486 | 487 | ### 2.5.0 ### 488 | * **English** 489 | * [Edition 2012](https://antispambee.pluginkollektiv.org/news/2012/edition-2012/) 490 | * **Deutsch** 491 | * [Edition 2012](https://antispambee.pluginkollektiv.org/de/news/2012/edition-2012/) 492 | 493 | ### 2.4.6 ### 494 | * **English** 495 | * Russian translation 496 | * Change the secret string 497 | * **Deutsch** 498 | * Russische Übersetzung 499 | * Veränderung der Secret-Zeichenfolge 500 | 501 | ### 2.4.5 ### 502 | * **English** 503 | * Revised layout settings 504 | * Deletion of Project Honey Pot 505 | * TornevallNET as new DNSBL service 506 | * WordPress 3.4 as a minimum requirement 507 | * WordPress 3.5 support 508 | * Recast of the online manual 509 | * **Deutsch** 510 | * Überarbeitetes Layout der Einstellungen 511 | * Streichung von Project Honey Pot 512 | * TornevallNET als neuer DNSBL-Dienst 513 | * WordPress 3.4 als Mindestvoraussetzung 514 | * WordPress 3.5 Unterstützung 515 | * Neufassung des Online-Handbuchs 516 | 517 | ### 2.4.4 ### 518 | * **English** 519 | * Technical and visual support for WordPress 3.5 520 | * Modification of the file structure: from `xyz.dev.css` to `xyz.min.css` 521 | * Retina screenshot 522 | * **Deutsch** 523 | * Technische und optische Unterstützung für WordPress 3.5 524 | * Änderung der Dateistruktur: von `xyz.dev.css` zu `xyz.min.css` 525 | * Retina Bildschirmfoto 526 | 527 | ### 2.4.3 ### 528 | * **English** 529 | * Check for basic requirements 530 | * Remove the sidebar plugin icon 531 | * Set the Google API calls to SSL 532 | * Compatibility with WordPress 3.4 533 | * Add retina plugin icon on options 534 | * Depending on WordPress settings: anonymous comments allowed 535 | * **Deutsch** 536 | * Mindestvoraussetzungen werden nun überprüft 537 | * Entfernung des Plugin Icons in der Sidebar 538 | * Google API Aufrufe auf SSL umgestellt 539 | * Kompatibilität mit WordPress 3.4 540 | * Retina Plugin Icon in den Einstellungen hinzugefügt 541 | * In Abhängigkeit zu den Wordpress-Einstellungen: anonyme Kommentare erlauben 542 | 543 | ### 2.4.2 ### 544 | * **English** 545 | * New geo ip location service (without the api key) 546 | * Code cleanup: Replacement of `@` characters by a function 547 | * JS-Fallback for missing jQuery UI 548 | * **Deutsch** 549 | * Neuer IP-Geolocation-Dienst (ohne api key) 550 | * Quelltext aufgeräumt: Austausch von `@` Zeichen durch eine Funktion 551 | * S-Fallback für fehlende jQuery UI 552 | 553 | ### 2.4.1 ### 554 | * **English** 555 | * Add russian translation 556 | * Fix for the textarea replace 557 | * Detect and hide admin notices 558 | * **Deutsch** 559 | * Russian Übersetzung hinzugefügt 560 | * Fehlerbehebung bei dem ersetzten Textfeld 561 | * Erkennen und verstecken von Admin-Mitteilungen 562 | 563 | ### 2.4 ### 564 | * **English** 565 | * Support for IPv6 566 | * Source code revision 567 | * Delete spam by reason 568 | * Changing the user interface 569 | * Requirements: PHP 5.1.2 and WordPress 3.3 570 | * **Deutsch** 571 | * Unterstützung für IPv6 572 | * Quellcode Überarbeitung 573 | * Spam mit Begründung löschen 574 | * Änderung der Benutzeroberfläche 575 | * Voraussetzungen: PHP 5.1.2 und WordPress 3.3 576 | 577 | ### 2.3 ### 578 | * **English** 579 | * Xmas Edition 580 | * **Deutsch** 581 | * Weihnachtsausgabe 582 | 583 | ### 2.2 ### 584 | * **English** 585 | * Interactive Dashboard Stats 586 | * **Deutsch** 587 | * Interaktive Dashboard Statistik 588 | 589 | ### 2.1 ### 590 | * **English** 591 | * Remove Google Translate API support 592 | * **Deutsch** 593 | * Google Translate API Unterstützung entfernt 594 | 595 | ### 2.0 ### 596 | * **English** 597 | * Allow comments only in certain language (English/German) 598 | * Consider comments which are already marked as spam 599 | * Dashboard Stats: Change from canvas to image format 600 | * System requirements: WordPress 2.8 601 | * Removal of the migration script 602 | * Increase plugin security 603 | * **Deutsch** 604 | * Kommentare nur in bestimmten Sprachen erlauben (Englisch/Deutsch) 605 | * Das Plugin kann nun Kommentare berücksichtigen, die bereits als Spam markiert wurden 606 | * Dashboard-Statistik: Wechsel von canvas zu einem Bildformat 607 | * Systemvoraussetzungen: WordPress 2.8 608 | * Entfernung des Migrationsscriptes 609 | * Plugin Sicherheit verbessert 610 | 611 | ### 1.9 ### 612 | * **English** 613 | * Dashboard History Stats (HTML5 Canvas) 614 | * **Deutsch** 615 | * Dashboard Statistiken (HTML5 Canvas) 616 | 617 | ### 1.8 ### 618 | * **English** 619 | * Support for the new IPInfoDB API (including API Key) 620 | * **Deutsch** 621 | * Unterstützung der neuen IPInfoDB API (einschließlich API-Key) 622 | 623 | ### 1.7 ### 624 | * **English** 625 | * Black and whitelisting for specific countries 626 | * "Project Honey Pot" as a optional spammer source 627 | * Spam reason in the notification email 628 | * Visual refresh of the notification email 629 | * Advanced GUI changes + Fold-out options 630 | * **Deutsch** 631 | * Schwarze und weiße Liste für bestimmte Länder 632 | * "Project Honey Pot" als optionale Spammer-Quelle 633 | * Spam-Begründung in der E-Mail-Benachrichtigung 634 | * Visuelle Überarbeitung der E-Mail-Benachrichtigung 635 | * Erweiterte Benutzeroberflächenanpassungen + ausklappbare Einstellungen 636 | 637 | ### 1.6 ### 638 | * **English** 639 | * Support for WordPress 3.0 640 | * System requirements: WordPress 2.7 641 | * Code optimization 642 | * **Deutsch** 643 | * Unterstützung für WordPress 3.0 644 | * Systemvoraussetzungen: WordPress 2.7 645 | * Quelltext optimiert 646 | 647 | ### 1.5 ### 648 | * **English** 649 | * Compatibility with WPtouch 650 | * Add support for do_action 651 | * Translation to Portuguese of Brazil 652 | * **Deutsch** 653 | * Kompatibilität mit WPtouch 654 | * Unterstützung für do_action hinzugefügt 655 | * Übersetzung auf brasilianisches Portugiesisch 656 | 657 | ### 1.4 ### 658 | * **English** 659 | * Enable stricter inspection for incomming comments 660 | * Do not check if the author has already commented and approved 661 | * **Deutsch** 662 | * strengere Kontrolle für eingehende Kommentare aktiviert 663 | * Nicht auf Spam überprüfen, wenn der Autor bereits kommentiert hat und freigegeben wurde 664 | 665 | ### 1.3 ### 666 | * **English** 667 | * New code structure 668 | * Email notifications about new spam comments 669 | * Novel Algorithm: Advanced spam checking 670 | * **Deutsch** 671 | * Neue Quelltextstruktur 672 | * E-Mail-Benachrichtigungen über neue Spam-Kommentare 673 | * Neuartiger Algorithmus: Erweiterte Spamprüfung 674 | 675 | ### 1.2 ### 676 | * **English** 677 | * Antispam Bee spam counter on dashboard 678 | * **Deutsch** 679 | * Antispam Bee Spam-Zähler auf dem Dashboard 680 | 681 | ### 1.1 ### 682 | * **English** 683 | * Adds support for WordPress new changelog readme.txt standard 684 | * Various changes for more speed, usability and security 685 | * **Deutsch** 686 | * Unterstützung des neuen readme.txt Standards für das Änderungsprotokoll hinzugefügt 687 | * Verschiedene Änderungen für mehr Geschwindigkeit, Benutzerfreundlichkeit und Sicherheit 688 | 689 | ### 1.0 ### 690 | * **English** 691 | * Adds WordPress 2.8 support 692 | * **Deutsch** 693 | * WordPress 2.8 Unterstützung hinzugefügt 694 | 695 | ### 0.9 ### 696 | * **English** 697 | * Mark as spam only comments or only pings 698 | * **Deutsch** 699 | * nur Kommentare oder nur Pings als Spam markieren 700 | 701 | ### 0.8 ### 702 | * **English** 703 | * Optical adjustments of the settings page 704 | * Translation for Simplified Chinese, Spanish and Catalan 705 | * **Deutsch** 706 | * Optische Anpassungen der Einstellungsseite 707 | * Übersetzung für vereinfachtes Chinesisch, Spanisch und Katalanisch 708 | 709 | ### 0.7 ### 710 | * **English** 711 | * Spam folder cleanup after X days 712 | * Optional hide the "MARKED AS SPAM" note 713 | * Language support for Italian and Turkish 714 | * **Deutsch** 715 | * Spam-Ordner Bereinigung nach n Tagen 716 | * Optionales verstecken des "als Spam markiert" Hinweises 717 | * Übersetzungen für Italienisch und Türkisch 718 | 719 | ### 0.6 ### 720 | * **English** 721 | * Language support for English, German, Russian 722 | * **Deutsch** 723 | * Übersetzungen für Englisch, Deutsch und Russisch 724 | 725 | ### 0.5 ### 726 | * **English** 727 | * Workaround for empty comments 728 | * **Deutsch** 729 | * Problembehebung für leere Kommentare 730 | 731 | ### 0.4 ### 732 | * **English** 733 | * Option for trackback and pingback protection 734 | * **Deutsch** 735 | * Einstellung für den Trackback- und Pingback-Schutz 736 | 737 | ### 0.3 ### 738 | * **English** 739 | * Trackback and Pingback spam protection 740 | * **Deutsch** 741 | * Trackback und Pingback Spam-Schutz 742 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | (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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | # Antispam Bee # 2 | * Contributors: pluginkollektiv, websupporter, schlessera, zodiac1978, swissspidy, krafit, kau-boy, florianbrinkmann, pfefferle 3 | * Tags: anti-spam, antispam, comments, spam filter, spam protection 4 | * Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=TD4AMD2D8EMZW 5 | * Requires at least: 4.6 6 | * Tested up to: 6.7 7 | * Requires PHP: 5.2 8 | * Stable tag: 2.11.7 9 | * License: GPLv2 or later 10 | * License URI: https://www.gnu.org/licenses/gpl-2.0.html 11 | 12 | Sophisticated antispam plugin for effective daily comment and trackback spam-fighting. Built with data protection and privacy in mind. 13 | 14 | ## Description ## 15 | Say Goodbye to comment spam on your WordPress blog or website. *Antispam Bee* blocks spam comments and trackbacks effectively, without captchas and without sending personal information to third party services. It is free of charge, ad-free and 100% GDPR compliant. 16 | 17 | ### Feature/Settings Overview ### 18 | * Trust approved commenters. 19 | * Trust commenters with a Gravatar. 20 | * Consider the comment time. 21 | * Allow comments only in a certain language. 22 | * Block or allow commenters from certain countries. 23 | * Treat BBCode links as spam. 24 | * Use regular expressions. 25 | * Search local spam database for commenters previously marked as spammers. 26 | * Notify admins by e-mail about incoming spam. 27 | * Delete existing spam after n days. 28 | * Limit approval to comments/pings (will delete other comment types). 29 | * Select spam indicators to send comments to deletion directly. 30 | * Optionally exclude trackbacks and pingbacks from spam detection. 31 | * Optionally spam-check comment forms on archive pages. 32 | * Display spam statistics on the dashboard, including daily updates of spam detection rate and a total of blocked spam comments. 33 | 34 | ### Support ### 35 | * Community support via the [support forums on wordpress.org](https://wordpress.org/support/plugin/antispam-bee) 36 | * Read [the documentation](https://antispambee.pluginkollektiv.org/documentation/) 37 | * We don’t handle support via e-mail, Twitter, GitHub issues etc. 38 | 39 | ### Contribute ### 40 | * Active development of this plugin is handled [on GitHub](https://github.com/pluginkollektiv/antispam-bee). 41 | * Pull requests for documented bugs are highly appreciated. 42 | * If you think you’ve found a bug (e.g. you’re experiencing unexpected behavior), please post at the [support forums](https://wordpress.org/support/plugin/antispam-bee) first. 43 | * If you want to help us translate this plugin you can do so [on WordPress Translate](https://translate.wordpress.org/projects/wp-plugins/antispam-bee). 44 | 45 | ### Credits ### 46 | * Author: [Sergej Müller](https://sergejmueller.github.io/) 47 | * Maintainers: [pluginkollektiv](https://pluginkollektiv.org) 48 | 49 | ## Installation ## 50 | * If you don’t know how to install a plugin for WordPress, [here’s how](https://wordpress.org/documentation/article/manage-plugins/#automatic-plugin-installation-1). 51 | 52 | ### Requirements ### 53 | * PHP 5.2.4 or greater 54 | * WordPress 4.5 or greater 55 | 56 | ### Settings ### 57 | After you have activated *Antispam Bee* the plugin will block spam comments out of the box. However, you may want to visit *Settings → Antispam Bee* to configure your custom set of anti-spam options that works best for your site. 58 | 59 | ## Frequently Asked Questions ## 60 | 61 | ### Does Antispam Bee prevents spam registrations or protects form plugins? ### 62 | Antispam Bee works best with default WordPress comments. It does not help to protect form plugins and does not prevent spam registrations. Hopefully we can provide better hooks for third party plugins to use Antispam Bee to fill this gap in the forthcoming new major version. 63 | 64 | ### Does Antispam Bee work with Jetpack, wpDiscuz, Disqus Comments and similar comment plugins? 65 | Antispam Bee works best with default WordPress comments. It is not compatible with Jetpack, wpDiscuz or Disqus Comments as those plugins load a new comment form within an iframe. Thus Antispam Bee can not access the comment form directly. 66 | 67 | ### Does Antispam Bee work with AJAX comment plugins or similar theme features? 68 | Whether Antispam Bee works with a comment form submitted via AJAX depends on how the AJAX request is made. If the request goes to the file that usually also receives the comments, Antispam Bee could work with it out of the box (the [WP Ajaxify Comments](https://wordpress.org/plugins/wp-ajaxify-comments/) plugin does this, for example). 69 | 70 | If the comments are sent to the `admin-ajax.php`, the `antispam_bee_disallow_ajax_calls` filter must be used to run ASB for requests to that file as well. If the script does not send all form data to the file, but only some selected ones, further customization is probably necessary, as [exemplified in this post by Torsten Landsiedel](https://torstenlandsiedel.de/2020/10/04/ajaxifizierte-kommentare-und-antispam-bee/) (in German). 71 | 72 | ### Does Antispam Bee store any private user data, and is it compliant with GDPR? ### 73 | Antispam Bee is developed in Europe. You might have heard we can be a bit nitpicky over here when it comes to privacy. The plugin does not save private user data and is 100% compliant with GDPR. 74 | 75 | ### Will I have to edit any theme templates to get Antispam Bee to work? ### 76 | No, the plugin works as is. You may want to configure your favorite settings, though. 77 | 78 | ### Does Antispam Bee work with shortened IPs? ### 79 | Generally yes. However, commissioning the Antispam Bee plugin for canceled or shortened IP addresses in comment metadata is not recommended. Because the name and the e-mail address of the comments are not unique, an IP address is the only reliable measure. The more complete the stored IP addresses, the more reliable the assignment or detection of spam. 80 | 81 | ### How can I submit undetected spam? ### 82 | If the antispam plugin has passed some spam comments, these comments can be reported for analysis. A [Google table](http://goo.gl/forms/ITzVHXkLVL) was created for this purpose. 83 | 84 | ### Antispam Bee with Varnish? ### 85 | If WordPress is operated with Apache + Varnish, the actual IP address of the visitors does not appear in WordPress. Accordingly the Antispam-Plugin lacks the base for the correct functionality. An adaptation in the Varnish configuration file /etc/varnish/default.vcl provides a remedy and forwards the original (not from Apache) IP address in the HTTP header X-Forwarded-For: 86 | 87 | > 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 | ## Changelog ## 97 | 98 | ### 2.11.7 ### 99 | * Tweak: Use SCRIPT_NAME instead of REQUEST_URI to check path 100 | * Fix: Remove `add_reasons_to_defaults()` from general initialization for better WordPress 6.7 compatibility 101 | * Maintenance: Tested up to WordPress 6.7 102 | 103 | ### 2.11.6 ### 104 | * Fix: Delete missed out option on uninstall (Thanks @okvee!) 105 | * Tweak: Minor i18n improvements (Thanks Pedro!) 106 | * Tweak: Minor code changes and housekeeping 107 | * Tweak: Updated dependencies 108 | 109 | ### 2.11.5 ### 110 | 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). 111 | 112 | * Fix: Usage of core filter `pre_comment_user_ip` breaks ASB if the IP address is removed for GDPR compliance 113 | 114 | ### 2.11.4 ### 115 | 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`. 116 | 117 | * Fix: Read client IP for country check from `REMOTE_ADDR` only (filterable via `pre_comment_user_ip`) 118 | * Fix: No spam reason in spam notification email, and related PHP warning 119 | * Fix: Remove outdated info from readme 120 | * Enhancement: Show upgrade notice on plugin overview page 121 | * Maintenance: Tested up to WordPress 6.3 122 | 123 | ### 2.11.3 ### 124 | * Fix: Multiselect for "Delete comments by spam reasons" was not saving values 125 | * Fix: Fix broken link for ISO country codes 126 | * Maintenance: Added test for PHP 8.2 127 | * Maintenance: Tested up to WordPress 6.2 128 | 129 | ### 2.11.2 ### 130 | * Tweak: remove superfluous translations 131 | * Tweak: make FAQ link an anchor link 132 | * Fix: spam counter no longer raises a warning with PHP 8.1 if no spam is present yet 133 | * Fix: spam reasons are now localized correctly 134 | * Fix: Translations were loaded twice on some admin pages 135 | * Maintenance: Tested up to WordPress 6.1 136 | 137 | ### 2.11.1 ### 138 | * Tweak: remove superfluous type attribute from inline script tag 139 | * Maintenance: Tested up to WordPress 6.0 140 | 141 | ### 2.11.0 ### 142 | * Fix: Allow empty comments if `allow_empty_comment` is set to true 143 | * Fix: Add `aria-label` to work around bug in a11y testing tools 144 | * Fix: Change priority for `comment_form_field_comment` from 10 to 99 145 | * Tweak: Updated some FAQ entries 146 | * Tweak: Updated build tooling 147 | 148 | ### 2.10.0 ### 149 | * Fix: Switch from ip2country.info to iplocate.io for country check 150 | * Enhancement: Use filter to add the honeypot field instead of output buffering for new installations and added option to switch between the both ways 151 | * Tweak: Added comment user agent to regex pattern check 152 | * Tweak: Make the ping detection filterable to support new comment types 153 | * Tweak: Updated internal documentation links 154 | * Tweak: Several updates and optimizations in the testing process 155 | * Tweak: Adjust color palette to recent WP version 156 | * Tweak: Adjust wording in variables and option names 157 | * Readme: Add new contributor and clean up unused code 158 | 159 | 160 | ### 2.9.4 ### 161 | * Enhancement: Add filter to allow ajax calls 162 | * Tweak: Better wording for BBCode feature in plugin description 163 | * Tweak: Better screenshots in the plugin directory 164 | * Maintenance: Tested up to WordPress 5.7 165 | 166 | ### 2.9.3 ### 167 | * Fixed: Compatibility with WordPress 5.5 168 | * Fixed: Undefined index on spam list page 169 | * Tweak: Better wording on settings page 170 | * Tweak: AMP compatibility 171 | * Tweak: Protect CSS from overwrite through bad themes 172 | 173 | ### 2.9.2 ### 174 | * 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/) 175 | * Fix: Statistic in dashboard showed wrong value 176 | * Tweak: Change autocomplete attribute to "new-password" 177 | * Tweak: Autoptimize compatibility improved 178 | * Tweak: Renamed blacklist/whitelist to a better phrase 179 | * Tweak: Added new pattern 180 | * Tweak: UI and text optimizations 181 | * Tweak: Better compatibility with some server configurations 182 | * Tweak: Make spam reason sortable and filterable 183 | * Tweak: Add spam reason for manually marked spam 184 | * Maintenance: Deleted unused code 185 | * Maintenance: Removed Fake IP check (unreliable and producing false positives) 186 | * Maintenance: Fix some coding standard issues 187 | * Maintenance: Tested up to WordPress 5.4 188 | * Maintenance: Tested up to PHP 7.4 189 | 190 | ### 2.9.1 ### 191 | * Improved backend accessibility 192 | * Prefilled comment textareas do now work with the honeypot 193 | * Compatible with the AMP plugin (https://wordpress.org/plugins/amp/) 194 | * Improved dashboard tooltips 195 | * Improvements for the language detection API 196 | * Scalable IP look up for local spam database 197 | 198 | ### 2.9.0 ### 199 | * Introduction of coding standards. 200 | * Switch to franc language detection API for the language check. 201 | * Do not longer overwrite the IP address WordPress saves with the comment by using `pre_comment_user_ip`. 202 | * Do not show "Trust commenters with a Gravatar" if the "Show Gravatar" option is not set. 203 | * Skip the checks, when I ping myself. 204 | * Fixes some wrong usages of the translation functions. 205 | * Use the regular expressions check also for trackbacks. 206 | * Add option to delete Antispam Bee related data when plugin gets deleted via the admin interface. 207 | * Save a hashed + salted IP for every comment 208 | * New check for incoming trackbacks. 209 | * Introduction of behat tests. 210 | * Updates the used JavaScript library for the statistics widget. 211 | * Bugfix in the "Comment form used outside of posts" option. 212 | 213 | ### 2.8.1 ### 214 | * PHP 5.3 compatibility 215 | * Bugfix where a spam trackback produced a fatal error 216 | * For more details see https://github.com/pluginkollektiv/antispam-bee/milestone/8?closed=1 217 | 218 | ### 2.8.0 ### 219 | * Removed stopforumspam.com to avoid potential GDPR violation 220 | * Improves IP handling to comply with GDPR 221 | * Improves PHP7.2 compatibility 222 | * Fixes small bug on mobile views 223 | * Allow more than one language in language check 224 | * Minor interface improvements 225 | * Remove old russian and Dutch translation files 226 | * For more details see https://github.com/pluginkollektiv/antispam-bee/milestone/4?closed=1 227 | 228 | ### 2.7.1 ### 229 | * Fixes an incompatibility with Chrome autofill 230 | * Fixes some incompatibilities with other plugins/themes where the comment field was left empty 231 | * Support for RTL 232 | * Solve some translation/language issues 233 | * A new filter to add languages to the language check 234 | * For more details see https://github.com/pluginkollektiv/antispam-bee/milestone/6?closed=1 235 | 236 | ### 2.7.0 ### 237 | * Country check is back again (thanks to Sergej Müller for his amazing work and the service page) 238 | * Improved Honeypot 239 | * Language check through Google Translate API is back again (thanks to Simon Kraft of https://moenus.net/ for offering to cover the costs) 240 | * More default Regexes 241 | * Unit Test Framework 242 | * Accessibility and GUI improvements 243 | * An [english documentation](https://github.com/pluginkollektiv/antispam-bee/wiki) is now available, too. Some corrections in the german documentation. 244 | * Some bugfixes - Among other things for WPML compatibility 245 | * For more details see https://github.com/pluginkollektiv/antispam-bee/milestone/3?closed=1 246 | 247 | ### 2.6.9 ### 248 | * Updates donation links throughout the plugin 249 | * Fixes an error were JavaScript on the dashboard was erroneously being enqueued 250 | * Ensures compatibility with the latest WordPress version 251 | 252 | ### 2.6.8 ### 253 | * added a POT file 254 | * updated German translation, added formal version 255 | * updated plugin text domain to include a dash instead of an underscore 256 | * updated, translated + formatted README.md 257 | * updated expired link URLs in plugin and languages files 258 | * updated [plugin authors](https://pluginkollektiv.org/hello-world/) 259 | 260 | ### 2.6.7 ### 261 | * 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/) 262 | 263 | ### 2.6.6 ### 264 | * Switch to the official Google Translation API 265 | * *Release time investment (Development & QA): 2.5 h* 266 | 267 | ### 2.6.5 ### 268 | * Fix: Return parameters on `dashboard_glance_items` callback / thx [@toscho](https://twitter.com/toscho) 269 | * New function: Trust commenters with a Gravatar / thx [@glueckpress](https://twitter.com/glueckpress) 270 | * Additional plausibility checks and filters 271 | * *Release time investment (Development & QA): 12 h* 272 | 273 | ### 2.6.4 ### 274 | * 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/) 275 | * *Release time investment (Development & QA): 6.25 h* 276 | 277 | ### 2.6.3 ### 278 | * Sorting for the Antispam Bee column in the spam comments overview 279 | * Code refactoring around the use of REQUEST_URI 280 | * *Release time investment (Development & QA): 2.75 h* 281 | 282 | ### 2.6.2 ### 283 | * Improving detection of fake IPs 284 | * *Release time investment (Development & QA): 11 h* 285 | 286 | ### 2.6.1 ### 287 | * Code refactoring of options management 288 | * Support for `HTTP_FORWARDED_FOR` header 289 | * *Release time investment (Development & QA): 8.5 h* 290 | 291 | ### 2.6.0 ### 292 | * Optimizations for WordPress 3.8 293 | * Clear invalid UTF-8 characters in comment fields 294 | * Spam reason as a column in the table with spam comments 295 | 296 | For the complete changelog, check out our [GitHub repository](https://github.com/pluginkollektiv/antispam-bee). 297 | 298 | == Upgrade Notice == 299 | 300 | = 2.11.5 = 301 | Instead of pre_comment_user_ip you need to use our new filter antispam_bee_trusted_ip to send the correct IP address 302 | 303 | = 2.11.3 = 304 | 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! 305 | 306 | = 2.8.0 = 307 | This update makes sure your spam check is GDPR compliant, no matter the options you choose. Please make sure to update before May 25th! 308 | 309 | ## Screenshots ## 310 | 1. Block or allow comments from specific countries. 311 | 2. Allow comments only in certain languages. 312 | 3. Add useful spam stats to your dashboard. 313 | 4. Tailor WordPress' spam management to your workflow. 314 | --------------------------------------------------------------------------------