Changeset 3397677
- Timestamp:
- 11/18/2025 12:38:37 AM (5 months ago)
- Location:
- tiny-comment-spam-blocker
- Files:
-
- 9 added
- 5 edited
-
tags/1.2.0 (added)
-
tags/1.2.0/languages (added)
-
tags/1.2.0/languages/tiny-comment-spam-blocker-ja.mo (added)
-
tags/1.2.0/languages/tiny-comment-spam-blocker-ja.po (added)
-
tags/1.2.0/languages/tiny-comment-spam-blocker.pot (added)
-
tags/1.2.0/readme.txt (added)
-
tags/1.2.0/screenshot-1.png (added)
-
tags/1.2.0/screenshot-2.png (added)
-
tags/1.2.0/tiny-comment-spam-blocker.php (added)
-
trunk/languages/tiny-comment-spam-blocker-ja.mo (modified) (previous)
-
trunk/languages/tiny-comment-spam-blocker-ja.po (modified) (3 diffs)
-
trunk/languages/tiny-comment-spam-blocker.pot (modified) (4 diffs)
-
trunk/readme.txt (modified) (5 diffs)
-
trunk/tiny-comment-spam-blocker.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tiny-comment-spam-blocker/trunk/languages/tiny-comment-spam-blocker-ja.po
r3394305 r3397677 1 1 msgid "" 2 2 msgstr "" 3 "Project-Id-Version: Tiny Comment Spam Blocker 1. 1.0\n"3 "Project-Id-Version: Tiny Comment Spam Blocker 1.2.0\n" 4 4 "Report-Msgid-Bugs-To: \n" 5 "POT-Creation-Date: 2025-11-1 1 11:53:32+0000\n"6 "PO-Revision-Date: 2025-11-1 1 11:56:35+0000\n"5 "POT-Creation-Date: 2025-11-18 00:05:58+0000\n" 6 "PO-Revision-Date: 2025-11-18 00:09:23+0000\n" 7 7 "Last-Translator: Kasuga\n" 8 8 "Language-Team: \n" … … 65 65 msgstr "禁止する単語またはフレーズを1行に1つずつ入力してください。大文字と小文字は区別されません。" 66 66 67 msgid "NOTE: The badwords list applies to the comment content, email address, and IP address." 68 msgstr "NOTE: 禁止語リストは、コメント本文、メールアドレス、および IP アドレスに適用されます。" 69 67 70 msgid "Detection Log Output" 68 71 msgstr "検知ログ" … … 95 98 msgstr "[TCSB] %1$s にスパムコメントを検出しました – %2$s" 96 99 97 msgid "A spam comment attempt was detected.\n\nDate: %1\$s\n\nDetected Message:\n%2\$s\n\n--- Source (Spam Origin) ---\nIP Address: %3\$s\n\n--- Target (Attacked Site) ---\nSite URL: %4\$s\nSource Page: %5\$s\n\nThis comment attempt has been blocked by Tiny Comment Spam Blocker." 98 msgstr "スパムコメントの試行が検出されました。\n\n日付: %1\$s\n\n検出されたメッセージ:\n%2\$s\n\n--- 送信元(スパム発生源) ---\nIPアドレス: %3\$s\n\n--- 標的(攻撃されたサイト) ---\nサイトURL: %4\$s\nページ: %5\$s\n\nこのコメントの試行は Tiny Comment Spam Blocker によってブロックされました。" 100 msgid "A spam comment attempt was detected.\n\nDate: %1\$s\n\nDetected Message:\n%2\$s\n\n--- Source (Spam Origin) ---\nIP Address: %3\$s\nEmail Address: %4\$s\n\n--- Target (Attacked Site) ---\nSite URL: %5\$s\nSource Page: %6\$s\n\nThis comment attempt has been blocked by Tiny Comment Spam Blocker." 101 msgstr "スパムコメントの試行が検出されました。\n\n日時: %1\$s\n\n検出されたメッセージ:\n%2\$s\n\n--- 送信元 (スパム発信元) ---\nIPアドレス: %3\$s\nメールアドレス: %4\$s\n\n--- ターゲット (攻撃されたサイト) ---\nサイトURL: %5\$s\n送信元ページ: %6\$s\n\nこのコメントの試行は、Tiny Comment Spam Blocker によってブロックされました。" 102 103 msgid "The comment submission was blocked." 104 msgstr "コメントの送信はブロックされました。" 99 105 100 106 msgid "### This log is recorded up to %.1f MB. ###" 101 107 msgstr "### このログは最大 %.1f MB まで記録されます。 ###" 102 108 103 msgid "\n[%1\$s] %2\$s | Origin IP: %3\$s | Target: %4\$s | Page: %5\$s"104 msgstr "\n[%1\$s] %2\$s | 送信元 IP: %3\$s | 標的サイト: %4\$s | ページ: %5\$s"109 msgid "\n[%1\$s] %2\$s | Origin IP: %3\$s | Email: %4\$s | Target: %5\$s | Page: %6\$s" 110 msgstr "\n[%1\$s] %2\$s | 送信元IP: %3\$s | メールアドレス: %4\$s | ターゲット: %5\$s | ページ: %6\$s" 105 111 -
tiny-comment-spam-blocker/trunk/languages/tiny-comment-spam-blocker.pot
r3394305 r3397677 1 1 msgid "" 2 2 msgstr "" 3 "Project-Id-Version: Tiny Comment Spam Blocker 1. 1.0\n"3 "Project-Id-Version: Tiny Comment Spam Blocker 1.2.0\n" 4 4 "Report-Msgid-Bugs-To: \n" 5 "POT-Creation-Date: 2025-11-1 1 11:53:32+0000\n"5 "POT-Creation-Date: 2025-11-18 00:05:58+0000\n" 6 6 "PO-Revision-Date: \n" 7 7 "Last-Translator: \n" … … 65 65 msgstr "" 66 66 67 msgid "NOTE: The badwords list applies to the comment content, email address, and IP address." 68 msgstr "" 69 67 70 msgid "Detection Log Output" 68 71 msgstr "" … … 95 98 msgstr "" 96 99 97 msgid "A spam comment attempt was detected.\n\nDate: %1\$s\n\nDetected Message:\n%2\$s\n\n--- Source (Spam Origin) ---\nIP Address: %3\$s\n\n--- Target (Attacked Site) ---\nSite URL: %4\$s\nSource Page: %5\$s\n\nThis comment attempt has been blocked by Tiny Comment Spam Blocker." 100 msgid "A spam comment attempt was detected.\n\nDate: %1\$s\n\nDetected Message:\n%2\$s\n\n--- Source (Spam Origin) ---\nIP Address: %3\$s\nEmail Address: %4\$s\n\n--- Target (Attacked Site) ---\nSite URL: %5\$s\nSource Page: %6\$s\n\nThis comment attempt has been blocked by Tiny Comment Spam Blocker." 101 msgstr "" 102 103 msgid "The comment submission was blocked." 98 104 msgstr "" 99 105 … … 101 107 msgstr "" 102 108 103 msgid "\n[%1\$s] %2\$s | Origin IP: %3\$s | Target: %4\$s | Page: %5\$s"109 msgid "\n[%1\$s] %2\$s | Origin IP: %3\$s | Email: %4\$s | Target: %5\$s | Page: %6\$s" 104 110 msgstr "" 105 111 -
tiny-comment-spam-blocker/trunk/readme.txt
r3394305 r3397677 1 1 === Tiny Comment Spam Blocker === 2 2 Contributors: Kasuga16 3 Donate Link:4 3 Tags: comments, spam protection, anti-spam, security, honeypot 5 4 Requires at least: 6.3 6 5 Tested up to: 6.8 7 6 Requires PHP: 7.4 8 Stable tag: 1. 1.07 Stable tag: 1.2.0 9 8 License: GPLv2 or later 10 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 19 18 3. **Honeypot Field** – Hidden field that traps automated spam bots. 20 19 4. **User Agent Validation** – Detects suspicious User-Agent strings and blocks them. 21 5. **Forbidden Word Filtering** – Blocks comments and email addresses that contain words or phrases from a configurable list.20 5. **Forbidden Word Filtering** – Blocks submissions containing words or phrases from a configurable list within the **comment body, email address, or IP address.** 22 21 23 22 These filters are applied in order: if a comment passes the first check, it proceeds to the second, and so on, until all checks are applied or the comment is blocked. … … 41 40 – Download the plugin's zip file and extract it. 42 41 – Connect to your server via FTP and navigate to the "wp-content/plugins/" directory. 43 – Upload the extracted " tiny-comment-spam-blocker" folder to this directory.42 – Upload the extracted "quick-translate-pot-po-mo" folder to this directory. 44 43 – Go to 'Plugins' in your WordPress dashboard and activate the plugin. 45 44 – Go to **Settings → Tiny Spam Blocker** to configure options. … … 54 53 * **Notification Email Address** – Enter an email address to receive notifications when spam is detected. Leave blank to disable email notifications. 55 54 * **Minimum Submission Time (seconds)** – Set the minimum allowed time between loading the comment form and submitting a comment. Comments submitted faster than this threshold are considered spam. 56 * **Forbidden Words List** – Enter one forbidden word or phrase per line. Comments and email addresses containing these words will be blocked. Case is not sensitive. Example: `viagra`, `online pharmacy`, `free download`. 55 * **Forbidden Words List** – Enter one forbidden word, phrase, or IP address per line. Submissions containing these entries in the comment body, **email address**, or **IP address** will be blocked. **Case is insensitive.** 56 * **Example:** `viagra`, `online pharmacy`, `free download`, `spam@email.com`, `164.138.205.72` 57 57 58 58 --- 59 59 60 60 == Frequently Asked Questions == 61 62 = Can I customize the list of forbidden words? =63 Yes. Go to the plugin settings page and enter one forbidden word or phrase per line. Case is not sensitive.64 61 65 62 = What is the "Submission Time Check"? … … 84 81 85 82 == Changelog == 83 = 1.2.0 = 84 * Added IP address to forbidden word checks. 85 * The detection message has been modified. 86 86 87 = 1.1.0 = 87 88 * Extend forbidden word checks from comments to email addresses as well. -
tiny-comment-spam-blocker/trunk/tiny-comment-spam-blocker.php
r3394305 r3397677 3 3 * Plugin Name: Tiny Comment Spam Blocker 4 4 * Description: Lightweight but robust. Blocks comment spam with five techniques: nonce, submission time checks, honeypot fields, user agent validation, and forbidden word filtering. 5 * Version: 1. 1.05 * Version: 1.2.0 6 6 * Author: Kasuga 7 7 * License: GPLv2 or later … … 269 269 <textarea name="tcsb_badwords_list" rows="10" cols="50" style="font-family: monospace;"><?php echo esc_textarea( get_option( 'tcsb_badwords_list', TCSB_DEFAULT_BADWORDS ) ); // ★定数を使用 ?></textarea> 270 270 <p class="description"><?php esc_html_e( 'Enter one forbidden word or phrase per line. Case is not sensitive.', 'tiny-comment-spam-blocker' ); ?></p> 271 <p class="description"><?php esc_html_e( 'NOTE: The badwords list applies to the comment content, email address, and IP address.', 'tiny-comment-spam-blocker' ); ?></p> 271 272 </td> 272 273 </tr> … … 366 367 } 367 368 368 $remote_addr = tcsb_get_remote_ip(); 369 $remote_addr = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ?? '' ) ); 370 $email_addr = sanitize_text_field( wp_unslash( $commentdata['comment_author_email'] ?? '' ) ); 369 371 370 372 // 1. Nonce verification 371 373 if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'tcsb_comment_nonce' ) ) { 372 tcsb_handle_spam( __( 'Invalid nonce.', 'tiny-comment-spam-blocker' ), $remote_addr );374 tcsb_handle_spam( __( 'Invalid nonce.', 'tiny-comment-spam-blocker' ), $remote_addr, $email_addr ); 373 375 } 374 376 … … 379 381 if ( $elapsed < $threshold ) { 380 382 // translators: %d is the number of seconds elapsed since the previous comment. 381 tcsb_handle_spam( sprintf( __( 'Too-fast comment: %ds', 'tiny-comment-spam-blocker' ), $elapsed ), $remote_addr );383 tcsb_handle_spam( sprintf( __( 'Too-fast comment: %ds', 'tiny-comment-spam-blocker' ), $elapsed ), $remote_addr, $email_addr ); 382 384 } 383 385 } … … 385 387 // 3. Honeypot check 386 388 if ( ! empty( $_POST['honeypot'] ) ) { 387 tcsb_handle_spam( __( 'Honeypot detected.', 'tiny-comment-spam-blocker' ), $remote_addr );389 tcsb_handle_spam( __( 'Honeypot detected.', 'tiny-comment-spam-blocker' ), $remote_addr, $email_addr ); 388 390 } 389 391 … … 394 396 // translators: %s is the suspicious User-Agent string that was blocked. 395 397 sprintf( __( 'Blocked User-Agent: %s', 'tiny-comment-spam-blocker' ), esc_html( $ua ) ), 396 $remote_addr 398 $remote_addr, 399 $email_addr 397 400 ); 398 401 } … … 404 407 $check_targets = array( 405 408 'content' => strtolower( $commentdata['comment_content'] ), 406 'email' => strtolower( $commentdata['comment_author_email'] ), 409 'email' => strtolower( $email_addr ), 410 'ip' => strtolower( $remote_addr ), 407 411 ); 408 412 … … 415 419 foreach ( $check_targets as $type => $target ) { 416 420 if ( stripos( $target, $word ) !== false ) { 417 $message_type = ( 'email' === $type ) ? 'Email' : 'Content'; 421 422 $message_type = 'Content'; 423 if ( 'email' === $type ) { 424 $message_type = 'Email'; 425 } elseif ( 'ip' === $type ) { 426 $message_type = 'IP'; 427 } 418 428 419 429 tcsb_handle_spam( 420 430 // translators: %1$s is the detected field (Email/Content), %2$s is the forbidden word detected in the comment. 421 431 sprintf( __( 'Forbidden word detected in %1$s: %2$s', 'tiny-comment-spam-blocker' ), esc_html( $message_type ), esc_html( $word ) ), 422 $remote_addr 432 $remote_addr, 433 $email_addr 423 434 ); 424 435 } … … 433 444 * Handle detected spam by logging or other actions. 434 445 * 435 * @param string $message The spam message to log. 436 * @param string $ip_address The IP address associated with the spam. 437 */ 438 function tcsb_handle_spam( $message, $ip_address ) { 446 * @param string $message The spam message to log. 447 * @param string $ip_address The IP address associated with the spam. 448 * @param string $email_address Client email address. 449 */ 450 function tcsb_handle_spam( $message, $ip_address, $email_address ) { 439 451 $date = wp_date( 'Y-m-d H:i:s' ); 440 452 $site_name = get_bloginfo( 'name' ); … … 443 455 444 456 if ( get_option( 'tcsb_enable_logging' ) ) { 445 tcsb_log_spam( $date, $message, $ip_address, $ site_url, $referer_url );457 tcsb_log_spam( $date, $message, $ip_address, $email_address, $site_url, $referer_url ); 446 458 } 447 459 … … 455 467 ); 456 468 $body = sprintf( 457 __( "A spam comment attempt was detected.\n\nDate: %1\$s\n\nDetected Message:\n%2\$s\n\n--- Source (Spam Origin) ---\nIP Address: %3\$s\n \n--- Target (Attacked Site) ---\nSite URL: %4\$s\nSource Page: %5\$s\n\nThis comment attempt has been blocked by Tiny Comment Spam Blocker.", 'tiny-comment-spam-blocker' ),469 __( "A spam comment attempt was detected.\n\nDate: %1\$s\n\nDetected Message:\n%2\$s\n\n--- Source (Spam Origin) ---\nIP Address: %3\$s\nEmail Address: %4\$s\n\n--- Target (Attacked Site) ---\nSite URL: %5\$s\nSource Page: %6\$s\n\nThis comment attempt has been blocked by Tiny Comment Spam Blocker.", 'tiny-comment-spam-blocker' ), 458 470 sanitize_text_field( $date ), 459 471 sanitize_text_field( $message ), 460 472 sanitize_text_field( $ip_address ), 473 sanitize_email( $email_address ), 461 474 sanitize_text_field( $site_url ), 462 475 sanitize_text_field( $referer_url ) … … 464 477 wp_mail( $notify, $subject, $body ); 465 478 } 466 wp_die( esc_html( $message ) ); 479 480 // wp_die( esc_html( $message ) ); 481 wp_die( esc_html__( 'The comment submission was blocked.', 'tiny-comment-spam-blocker' ) ); 467 482 } 468 483 … … 470 485 * Record spam logs. 471 486 * 472 * @param string $date Date string. 473 * @param string $message Log message. 474 * @param string $ip_address Client IP address. 475 * @param string $site_url Site URL. 476 * @param string $referer_url Site Page. 477 */ 478 function tcsb_log_spam( $date, $message, $ip_address, $site_url, $referer_url ) { 487 * @param string $date Date string. 488 * @param string $message Log message. 489 * @param string $ip_address Client IP address. 490 * @param string $email_address Client Mail address. 491 * @param string $site_url Site URL. 492 * @param string $referer_url Site Page. 493 */ 494 function tcsb_log_spam( $date, $message, $ip_address, $email_address, $site_url, $referer_url ) { 479 495 $logfile = tcsb_get_log_file_path(); 480 496 $max_size = 1048576; // 1MB … … 498 514 499 515 $log = sprintf( 500 __( "\n[%1\$s] %2\$s | Origin IP: %3\$s | Target: %4\$s | Page: %5\$s", 'tiny-comment-spam-blocker' ),516 __( "\n[%1\$s] %2\$s | Origin IP: %3\$s | Email: %4\$s | Target: %5\$s | Page: %6\$s", 'tiny-comment-spam-blocker' ), 501 517 sanitize_text_field( $date ), 502 518 sanitize_text_field( $message ), 503 519 sanitize_text_field( $ip_address ), 520 sanitize_email( $email_address ), 504 521 sanitize_text_field( $site_url ), 505 522 sanitize_text_field( $referer_url ) … … 512 529 error_log( 'Tiny Comment Spam Blocker: Failed to write log.' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log 513 530 } 514 }515 516 /**517 * Retrieve the visitor's IP address.518 *519 * @return string The remote IP address, or 'unknown' if not available.520 */521 function tcsb_get_remote_ip() {522 return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ?? '' ) );523 531 } 524 532
Note: See TracChangeset
for help on using the changeset viewer.