Plugin Directory

Changeset 3420136


Ignore:
Timestamp:
12/15/2025 12:45:40 PM (4 months ago)
Author:
kasuga16
Message:

1.3.0

  • Added a new option to block non-Japanese comments.
Location:
tiny-comment-spam-blocker
Files:
9 added
5 edited

Legend:

Unmodified
Added
Removed
  • tiny-comment-spam-blocker/trunk/languages/tiny-comment-spam-blocker-ja.po

    r3397677 r3420136  
    11msgid ""
    22msgstr ""
    3 "Project-Id-Version: Tiny Comment Spam Blocker 1.2.0\n"
     3"Project-Id-Version: Tiny Comment Spam Blocker 1.3.0\n"
    44"Report-Msgid-Bugs-To: \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"
     5"POT-Creation-Date: 2025-12-15 12:25:28+0000\n"
     6"PO-Revision-Date: 2025-12-15 12:33:45+0000\n"
    77"Last-Translator: Kasuga\n"
    88"Language-Team: \n"
     
    6868msgstr "NOTE: 禁止語リストは、コメント本文、メールアドレス、および IP アドレスに適用されます。"
    6969
     70msgid "Block No Japanese Comments"
     71msgstr "日本語なしコメントをブロック"
     72
     73msgid "If enabled, Comments without Japanese characters (Hiragana, Katakana, Kanji) will be blocked."
     74msgstr "有効化すると、日本語文字(ひらがな/カタカナ/漢字)を含まないコメントをブロックします。"
     75
    7076msgid "Detection Log Output"
    7177msgstr "検知ログ"
     
    9298msgstr "禁止語が検出されました: %1$s: %2$s"
    9399
     100msgid "Blocked: Comment contains no Japanese characters."
     101msgstr "ブロックしました: コメントに日本語が含まれていません。"
     102
    94103msgid "Unknown Page"
    95104msgstr "不明なページ"
  • tiny-comment-spam-blocker/trunk/languages/tiny-comment-spam-blocker.pot

    r3397677 r3420136  
    11msgid ""
    22msgstr ""
    3 "Project-Id-Version: Tiny Comment Spam Blocker 1.2.0\n"
     3"Project-Id-Version: Tiny Comment Spam Blocker 1.3.0\n"
    44"Report-Msgid-Bugs-To: \n"
    5 "POT-Creation-Date: 2025-11-18 00:05:58+0000\n"
     5"POT-Creation-Date: 2025-12-15 12:25:28+0000\n"
    66"PO-Revision-Date: \n"
    77"Last-Translator: \n"
     
    6868msgstr ""
    6969
     70msgid "Block No Japanese Comments"
     71msgstr ""
     72
     73msgid "If enabled, Comments without Japanese characters (Hiragana, Katakana, Kanji) will be blocked."
     74msgstr ""
     75
    7076msgid "Detection Log Output"
    7177msgstr ""
     
    9298msgstr ""
    9399
     100msgid "Blocked: Comment contains no Japanese characters."
     101msgstr ""
     102
    94103msgid "Unknown Page"
    95104msgstr ""
  • tiny-comment-spam-blocker/trunk/readme.txt

    r3418599 r3420136  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.2.1
     7Stable tag: 1.3.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    19194. **User Agent Validation** – Detects suspicious User-Agent strings and blocks them.
    20205. **Forbidden Word Filtering** – Blocks submissions containing words or phrases from a configurable list within the **comment body, email address, or IP address.**
     216. **(Option) Block Non-Japanese Comments** – Blocks comments that do not contain Japanese characters (Hiragana, Katakana, or Han/Kanji), primarily targeting machine-translated or foreign spam.
    2122
    2223These 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.
     
    5960 `spam@email.com`
    6061 `164.138.205.72`
     62* **Block No Japanese Comments** - If enabled, this becomes the final check: Comments that contain Japanese characters (Hiragana, Katakana, or Kanji) will be automatically accepted after passing other security checks. **Comments without Japanese characters will be blocked.**
    6163
    6264---
     
    8587
    8688== Changelog ==
     89= 1.3.0 =
     90* Added a new option to block non-Japanese comments.
     91
    8792= 1.2.1 =
    8893* Fix a minor bug
  • tiny-comment-spam-blocker/trunk/tiny-comment-spam-blocker.php

    r3404807 r3420136  
    33 * Plugin Name: Tiny Comment Spam Blocker
    44 * 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.2.1
     5 * Version: 1.3.0
    66 * Author: Kasuga
    77 * License: GPLv2 or later
     
    9090    add_option( 'tcsb_time_threshold', 5 );
    9191    add_option( 'tcsb_badwords_list', TCSB_DEFAULT_BADWORDS );
     92    // NEW: Add default option for skipping spam check for Japanese comments.
     93    add_option( 'tcsb_enable_japanese_skip', false );
    9294}
    9395
     
    155157            'sanitize_callback' => 'sanitize_textarea_field',
    156158            'default'           => TCSB_DEFAULT_BADWORDS,
     159        )
     160    );
     161    // NEW: Register setting for Japanese comment skip.
     162    register_setting(
     163        'tcsb_settings_group',
     164        'tcsb_enable_japanese_skip',
     165        array(
     166            'type'              => 'boolean',
     167            'sanitize_callback' => 'rest_sanitize_boolean',
     168            'default'           => false,
    157169        )
    158170    );
     
    267279                    <th scope="row"><?php esc_html_e( 'Forbidden Words List', 'tiny-comment-spam-blocker' ); ?></th>
    268280                    <td>
    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>
     281                        <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>
    270282                        <p class="description"><?php esc_html_e( 'Enter one forbidden word or phrase per line. Case is not sensitive.', 'tiny-comment-spam-blocker' ); ?></p>
    271283                        <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>
     284                    </td>
     285                </tr>
     286                <tr valign="top">
     287                    <th scope="row"><?php esc_html_e( 'Block No Japanese Comments', 'tiny-comment-spam-blocker' ); ?></th>
     288                    <td>
     289                        <input type="checkbox" name="tcsb_enable_japanese_skip" value="1" <?php checked( 1, get_option( 'tcsb_enable_japanese_skip', false ) ); ?> />
     290                        <p class="description"><?php esc_html_e( 'If enabled, Comments without Japanese characters (Hiragana, Katakana, Kanji) will be blocked.', 'tiny-comment-spam-blocker' ); ?></p>
    272291                    </td>
    273292                </tr>
     
    357376 * 4. Suspicious User-Agent check
    358377 * 5. Forbidden word list check
     378 * 6. Japanese language check (New)
    359379 *
    360380 * @param array $commentdata The comment data to validate.
     
    437457                    $email_addr
    438458                );
     459            }
     460        }
     461    }
     462
     463    // 6. Japanese language check (NEW)
     464    $enable_japanese_skip = get_option( 'tcsb_enable_japanese_skip', false );
     465
     466    if ( $enable_japanese_skip ) {
     467        // Checks for Japanese characters (Hiragana, Katakana, Kanji) in the comment content.
     468        if ( isset( $commentdata['comment_content'] ) ) {
     469            if ( preg_match( '/[\p{Hiragana}\p{Katakana}\p{Han}]/u', $commentdata['comment_content'] ) ) {
     470                return $commentdata;
     471            } elseif ( ! empty( $commentdata['comment_content'] ) ) {
     472                    tcsb_handle_spam(
     473                        __( 'Blocked: Comment contains no Japanese characters.', 'tiny-comment-spam-blocker' ),
     474                        $remote_addr,
     475                        $email_addr
     476                    );
    439477            }
    440478        }
     
    482520    }
    483521
    484     // wp_die( esc_html( $message ) );
    485522    wp_die( esc_html__( 'The comment submission was blocked.', 'tiny-comment-spam-blocker' ) );
    486523}
     
    550587    delete_option( 'tcsb_time_threshold' );
    551588    delete_option( 'tcsb_badwords_list' );
     589    delete_option( 'tcsb_enable_japanese_skip' ); // NEW: Delete Japanese skip option.
    552590
    553591    // Delete log file and directory.
Note: See TracChangeset for help on using the changeset viewer.