Throws SPAM Away - Version 2.8.2

Version Description

IP HTTP_X_FORWARDED_FOR JavaScript

Download this release

Release Info

Developer tsato
Plugin Icon wp plugin Throws SPAM Away
Version 2.8.2
Comparing to
See all releases

Code changes from version 2.7.1 to 2.8.2

bbpress_spam_away.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: bbPress SPAM Away
4
+ Plugin URI: https://gti.jp/throws-spam-away/
5
+ Description: コメント内に日本語の記述が存在しない場合はあたかも受け付けたように振る舞いながらも捨ててしまうプラグイン
6
+ Author: 株式会社ジーティーアイ さとう たけし
7
+ Version: 0.1
8
+ Author URI: https://gti.co.jp/
9
+ License: GPL2
10
+ */
11
+ /* Copyright 2016 Takeshi Satoh (http://gti.jp/)
12
+
13
+ This program is free software; you can redistribute it and/or modify
14
+ it under the terms of the GNU General Public License, version 2, as
15
+ published by the Free Software Foundation.
16
+
17
+ This program is distributed in the hope that it will be useful,
18
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ GNU General Public License for more details.
21
+
22
+ You should have received a copy of the GNU General Public License
23
+ along with this program; if not, write to the Free Software
24
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
+ */
26
+ require_once 'throws_spam_away.class.php';
27
+
28
+ /**
29
+ * 設定値一覧
30
+ * デフォルト設定
31
+ */
32
+
33
+ $tsa_spam_tbl_name = 'tsa_spam';
34
+
35
+ // Throws SPAM Awayバージョン
36
+ $tsa_version = '2.8.1';
37
+ // スパムデータベースバージョン
38
+ $tsa_db_version = 2.6; // 2.6からデータベース変更 [error_type]追加
39
+
40
+ /** 初期設定 */
41
+ /**
42
+ * 設定値変更 2.6.2から
43
+ */
44
+
45
+ // ダミー項目でのスパム判定をするか
46
+ $default_dummy_param_field_flg = '1'; // 1: する 2:しない
47
+
48
+ // 日本語が存在しない場合無視対象とするか
49
+ $default_on_flg = 1; // 1:する
50
+
51
+ // タイトルの文字列はカウントから排除するか since 2.6.4
52
+ $default_without_title_str = 1; // 1:する
53
+
54
+ // 日本語文字最小含有数
55
+ $default_japanese_string_min_count = 3;
56
+
57
+ // 無視後、元画面に戻る時間
58
+ $default_back_second = 0;
59
+
60
+ // コメント欄下に表示される注意文言(初期設定)
61
+ $default_caution_msg = '日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)';
62
+
63
+ // コメント欄下に表示する位置(初期設定)1:コメント送信ボタンの上 2:コメント送信フォームの下
64
+ $default_caution_msg_point = '1'; //1:"comment_form", 2:"comment_form_after"
65
+
66
+ // エラー時に表示されるエラー文言(初期設定)
67
+ $default_error_msg = '日本語を規定文字数以上含まない記事は投稿できませんよ。';
68
+
69
+ /** URL文字列除外 設定 */
70
+ // URL数の制限をするか
71
+ $default_url_count_check_flg = '1'; // 1:する
72
+
73
+ // URL数の制限数
74
+ $default_ok_url_count = 3; // 3つまで許容
75
+
76
+ // URL数制限値オーバーのエラー文言(初期設定)
77
+ $default_url_count_over_error_msg = '';
78
+
79
+ /** NGキーワード/必須キーワード 制御設定 */
80
+
81
+ // キーワードNGエラー時に表示されるエラー文言(初期設定)
82
+ $default_ng_key_error_msg = 'NGキーワードが含まれているため投稿できません。';
83
+
84
+ // 必須キーワードが含まれないエラー文言(初期設定)
85
+ $default_must_key_error_msg = '必須キーワードが含まれていないため投稿できません。';
86
+
87
+ /** トラックバックへの対応設定 */
88
+
89
+ // トラックバックへの対応 1: する
90
+ $default_tb_on_flg = '1';
91
+
92
+ // トラックバック記事に当サイトURLがなければ無視するか
93
+ $default_tb_url_flg = '1';
94
+
95
+ /** 投稿IPアドレスによる制御設定 */
96
+ /** ver 2.6.5から */
97
+ // スパムちゃんぷるーホスト
98
+ //$spam_champuru_host = 'dnsbl.spam-champuru.livedoor.com';
99
+ // すぱむちゃんぷるー代替リスト化
100
+ // リスト廃止 2.6.9
101
+ //$spam_champuru_hosts = array("bsb.spamlookup.net", "bsb.empty.us", "list.dsbl.org", "all.rbl.jp");
102
+
103
+ //$default_spam_champuru_hosts = array("bsb.spamlookup.net");
104
+
105
+ // スパムブラックリスト by テキスト
106
+ $default_spam_champuru_by_text = "";
107
+
108
+ // すぱむちゃんぷるー利用初期設定
109
+ $default_spam_champuru_flg = '2'; // "2":しない
110
+
111
+ /** /2.6.5 */
112
+
113
+ // WordPressのcommentsテーブルで「spam」判定されたことがあるIPアドレスからの投稿を無視するか
114
+ $default_ip_block_from_spam_chk_flg = '1'; // "1":する
115
+
116
+ // ブロックIPアドレスからの投稿の場合に表示されるエラー文言(初期設定)
117
+ $default_block_ip_address_error_msg = '';
118
+
119
+ /** ver.2.8から */
120
+ // ホワイトリスト以外無視するか
121
+ $default_only_whitelist_ip_flg = '2'; // "2":しない
122
+ /** /ver.2.8 */
123
+
124
+ /** スパムデータベース */
125
+
126
+ // スパムデータベース保存するか "0":保存しない
127
+ $default_spam_data_save = '0';
128
+
129
+ // 期間が過ぎたデータを削除するか? "1":する
130
+ $default_spam_data_delete_flg = '1';
131
+
132
+ // スパムデータ保持期間(日)
133
+ $default_spam_keep_day_count = 15; /** 30 -> 15 */
134
+
135
+ // 最低保存期間(日)
136
+ $lower_spam_keep_day_count =1;
137
+
138
+ // ○分以内に○回スパムとなったら○分間そのIPからのコメントははじくかの設定
139
+ $default_spam_limit_flg = 0; // 1:する Other:しない ※スパム情報保存がデフォルトではないのでこちらも基本はしない方向です。
140
+ // ※スパム情報保存していないと機能しません。
141
+ $default_spam_limit_minutes = 10; // 10分以内に・・・
142
+ $default_spam_limit_count = 2; // 2回までは許そうか。
143
+ $default_spam_limit_over_interval = 10; // だがそれを超えたら(デフォルト3回目以降)10分はOKコメントでもスパム扱いするんでよろしく!
144
+ $default_spam_limit_over_interval_error_msg = ''; // そしてその際のエラーメッセージは・・・
145
+
146
+
147
+
148
+ /** オプションキー */
149
+ // ダミーフィールドを生成しそこに入力がある場合はエラーとするかフラグ [tsa_dummy_param_field_flg] 1:する 2:しない
150
+ // 日本語が存在しない時エラーとするかフラグ [tsa_on_flg] 1:する 2:しない
151
+ // 日本語文字列含有数 (入力値以下ならエラー) [tsa_japanese_string_min_count] 数値型
152
+ // 元の記事に戻ってくる時間(秒) [tsa_back_second] 数値型
153
+ // コメント欄の下に表示される注意文言 [tsa_caution_message] 文字列型
154
+ // コメント欄の下に表示される注意文言の位置 [tsa_caution_message_point] 文字列型("1" or "2")
155
+ // 日本語文字列規定値未満エラー時に表示される文言(元の記事に戻ってくる時間の間のみ表示)
156
+ // [tsa_error_message] 文字列型
157
+ // その他NGキーワード(日本語でも英語(その他)でもNGとしたいキーワードを半角カンマ区切りで複数設定できます。挙動は同じです。NGキーワードだけでも使用できます。)
158
+ // [tsa_ng_keywords] 文字列型(半角カンマ区切り文字列)
159
+ // NGキーワードエラー時に表示される文言(元の記事に戻ってくる時間の間のみ表示)
160
+ // [tsa_ng_key_error_message] 文字列型
161
+ // 必須キーワード(日本語でも英語(その他)でも必須としたいキーワードを半角カンマ区切りで複数設定できます。指定文字列を含まない場合はエラーとなります。※複数の方が厳しくなります。必須キーワードだけでも使用できます。)
162
+ // [tsa_must_keywords] 文字列型(半角カンマ区切り文字列)
163
+ // 必須キーワードエラー時に表示される文言(元の記事に戻ってくる時間の間のみ表示)
164
+ // [tsa_must_key_error_message] 文字列型
165
+ // この設定をトラックバック記事にも採用するか [tsa_tb_on_flg] 1:する 2:しない
166
+ // トラックバック記事にも採用する場合、ついでにこちらのURLが含まれているか判断するか
167
+ // [tsa_tb_url_flg] 1:する 2:しない
168
+ // WordPressのcommentsテーブルで「spam」判定されたことがあるIPアドレスからの投稿を無視するか
169
+ // [tsa_ip_block_from_spam_chk_flg] 1:する その他:しない
170
+ // ブロックしたいIPアドレスを任意で入力(半角カンマ区切りで複数設定できます。)
171
+ // [tsa_block_ip_addresses] 文字列型
172
+ // ブロック対象IPアドレスからの投稿時に表示される文言(元の記事に戻ってくる時間の間のみ表示)
173
+ // [tsa_block_ip_address_error_message] 文字列型
174
+ // ホワイトリスト登録IPアドレスのみ許可フラグ
175
+ // [tsa_only_whitelist_ip_flg] 1:する その他:しない
176
+ // URL(単純に'http'文字列のチェックのみ)文字列数を制限するか [tsa_url_count_on_flg] 1:する その他:しない
177
+ // URL(単純に'http'文字列のチェックのみ)文字列の許容数 [tsa_ok_url_count] 数値型
178
+ // URL(単純に'http'文字列のチェックのみ)文字列許容数オーバー時に表示される文言(元の記事に戻ってくる時間の間のみ表示)
179
+ // [tsa_url_count_over_error_message] 文字列型
180
+
181
+ // スパムブラックリスト [tsa_spam_champuru_hosts] 配列型
182
+ // スパムブラックリスト by テキスト [tsa_spam_chmapuru_by_text] 文字列型(カンマ区切り)
183
+
184
+
185
+
186
+
187
+ /** プロセス */
188
+ $newThrowsSpamAway = new ThrowsSpamAway;
189
+ /**
190
+ // トラックバックチェックフィルター
191
+ add_filter( 'preprocess_comment', array( &$newThrowsSpamAway, 'trackback_spam_away' ), 1, 1 );
192
+ // ダミーフィールド作成
193
+ $dummy_param_field_flg = get_option( 'tsa_dummy_param_field_flg', $default_dummy_param_field_flg );
194
+ if ( '1' == $dummy_param_field_flg ) {
195
+ add_action( 'wp_head', array( &$newThrowsSpamAway, 'tsa_scripts_init' ), 9997 );
196
+ add_action( "comment_form", array(&$newThrowsSpamAway, "comment_form_dummy_param_field" ), 9998);
197
+ }
198
+ // 注意文言表示
199
+ // コメントフォーム表示
200
+ $comment_disp_point = 'comment_form';
201
+ $comment_form_action_point = get_option( 'tsa_caution_msg_point', $default_caution_msg_point );
202
+ // フォーム内かフォーム外か判断する
203
+ if ( '2' == $comment_form_action_point ) {
204
+ $comment_disp_point = 'comment_form_after';
205
+ }
206
+ add_action( $comment_disp_point, array( &$newThrowsSpamAway, 'comment_form' ), 9999 );
207
+ */
208
+ // コメントチェックフィルター
209
+ add_action( 'bbp_new_forum_pre_insert', array( &$newThrowsSpamAway, 'comment_post' ), 1 );
hostbyip.php CHANGED
@@ -2,8 +2,8 @@
2
  /**
3
  * <p>ThrowsSpamAway</p> hostbyipページ
4
  * WordPress's Plugin
5
- * @author Takeshi Satoh@GTI Inc. 2014
6
- * @version 2.6.8
7
  */
8
  require_once 'throws_spam_away.class.php';
9
  require_once dirname( __FILE__ ).'/../../../wp-load.php';
@@ -21,14 +21,12 @@ $is_spam_champuru = ( $newThrowsSpamAway->reject_spam_ip( $spam_ip ) ? FALSE :
21
  $spam_author = $last_spam_comment_result->spam_author;
22
  $spam_comment = esc_attr($last_spam_comment_result->spam_comment);
23
  ?><!DOCTYPE html>
24
- <!--[if IE 8]>
25
- <html xmlns="http://www.w3.org/1999/xhtml" class="ie8 wp-toolbar" lang="ja" prefix="og: http://ogp.me/ns#" >
26
- <![endif]-->
27
- <!--[if !(IE 8) ]><!-->
28
- <html xmlns="http://www.w3.org/1999/xhtml" class="wp-toolbar" lang="ja" >
29
- <!--<![endif]-->
30
  <head>
 
 
31
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 
32
  <title>Throws SPAM Away | Hostbyip[<?php echo htmlspecialchars($_GET['ip']); ?>]</title>
33
  <script type="text/javascript">
34
  window.onblur=function(){
2
  /**
3
  * <p>ThrowsSpamAway</p> hostbyipページ
4
  * WordPress's Plugin
5
+ * @author Takeshi Satoh@GTI Inc. 2016
6
+ * @version 2.8
7
  */
8
  require_once 'throws_spam_away.class.php';
9
  require_once dirname( __FILE__ ).'/../../../wp-load.php';
21
  $spam_author = $last_spam_comment_result->spam_author;
22
  $spam_comment = esc_attr($last_spam_comment_result->spam_comment);
23
  ?><!DOCTYPE html>
24
+ <html <?php language_attributes(); ?>>
 
 
 
 
 
25
  <head>
26
+ <meta charset="<?php bloginfo( 'charset' ); ?>">
27
+ <meta name="viewport" content="width=device-width">
28
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
29
+
30
  <title>Throws SPAM Away | Hostbyip[<?php echo htmlspecialchars($_GET['ip']); ?>]</title>
31
  <script type="text/javascript">
32
  window.onblur=function(){
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: tsato
3
  Donate link: http://gti.jp/throws-spam-away
4
  Tags: comments, spam
5
  Requires at least: 3.1
6
- Tested up to: 4.3.1
7
- Stable tag: 2.7.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -50,7 +50,11 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
50
 
51
   【ホワイトリスト】
52
    ホワイトリストに登録したIPアドレスからの投稿はすべてのフィルタを通しませんので優先的に通常コメントとしてノーチェックで投稿処理がなされます。
53
- ※ホワイトリストが一番強力にしてありますので、このIPアドレスがAkismetで捉えられていてもスパムちゃんぷるーでスパム扱いになったとしても優先で通過させます。
 
 
 
 
54
 
55
  IPアドレスの指定「ブロックリスト」「ホワイトリスト」共に「改行」区切りで複数入力できますが、「192.168.1.0/24」のようにIPアドレスの範囲指定も可能です。
56
  ※例:192.168.0.1,192.168.1.0/24,69.208.0.0/16 と指定した場合
@@ -82,6 +86,23 @@ IPアドレスの指定「ブロックリスト」「ホワイトリスト」共
82
  ※コメント投稿時のスパムコメント対応の煩わしさが原因で作ったものですのでスパム判定されたコメントを保持しておりません。
83
 
84
  -- これまでの変更点について
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  ・バージョン 2.7.1
86
   2015/11/16
87
  スパム判定の初期値設定を判定メソッド内部に移動。
@@ -284,6 +305,19 @@ e.g.
284
  == Screenshots ==
285
 
286
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
287
  = 2.7 =
288
   スパム判定メソッドの整理を実施。
289
   外部から利用できるようにしました。
3
  Donate link: http://gti.jp/throws-spam-away
4
  Tags: comments, spam
5
  Requires at least: 3.1
6
+ Tested up to: 4.7-RC1
7
+ Stable tag: 2.8.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
50
 
51
   【ホワイトリスト】
52
    ホワイトリストに登録したIPアドレスからの投稿はすべてのフィルタを通しませんので優先的に通常コメントとしてノーチェックで投稿処理がなされます。
53
+ ※ホワイトリストが一番強力にしてありますので、このIPアドレスがAkismetで捉えられていてもブロック対象だったとしても優先で通過させます。
54
+
55
+  【ホワイトリストのみ許可するフラグ】
56
+   ホワイトリストに登録したIPアドレスのみ許可するフラグをチェックするとホワイトリスト登録IP以外は無視されるようになります。
57
+   このフラグが付いている場合は本来ノーチェックだったホワイトリストへIPアドレスチェック以外が行われるようになります。
58
 
59
  IPアドレスの指定「ブロックリスト」「ホワイトリスト」共に「改行」区切りで複数入力できますが、「192.168.1.0/24」のようにIPアドレスの範囲指定も可能です。
60
  ※例:192.168.0.1,192.168.1.0/24,69.208.0.0/16 と指定した場合
86
  ※コメント投稿時のスパムコメント対応の煩わしさが原因で作ったものですのでスパム判定されたコメントを保持しておりません。
87
 
88
  -- これまでの変更点について
89
+ ・バージョン 2.8.2
90
+  2016/12/1
91
+  ロードバランサ経由のクライアントIP取得ができるように HTTP_X_FORWARDED_FOR を取得するようにしました。
92
+  JavaScriptの不具合修正
93
+
94
+ ・バージョン 2.8.1
95
+ 2016/5/14
96
+ ホワイトリストIPアドレスのチェックメソッドの不具合を修正しました。
97
+
98
+ ・バージョン 2.8
99
+   2016/5/2
100
+  ホワイトリスト登録IPアドレスだけを許可するフラグを追加
101
+  このフラグが「する」になっている場合は・・・
102
+   ホワイトリストに登録したIPアドレスのみ許可するフラグをチェックするとホワイトリスト登録IP以外は無視されるようになります。
103
+   このフラグが付いている場合は本来ノーチェックだったホワイトリストへIPアドレスチェック以外が行われるようになります。
104
+   このバージョンではホワイトリストをトラックバックには適用しておりません。
105
+
106
  ・バージョン 2.7.1
107
   2015/11/16
108
  スパム判定の初期値設定を判定メソッド内部に移動。
305
  == Screenshots ==
306
 
307
  == Changelog ==
308
+ = 2.8.2 =
309
+  ロードバランサ経由のクライアントIP取得ができるように HTTP_X_FORWARDED_FOR を取得するようにしました。
310
+  JavaScriptの不具合修正
311
+
312
+ = 2.8.1 =
313
+  ホワイトリスト判定に不具合がありロジックを修正しました。
314
+
315
+ = 2.8 =
316
+  ホワイトリスト登録IPアドレスだけを許可するフラグを追加
317
+  このフラグが「する」担っている場合は・・・
318
+   ホワイトリストに登録したIPアドレスのみ許可するフラグをチェックするとホワイトリスト登録IP以外は無視されるようになります。
319
+   このフラグが付いている場合は本来ノーチェックだったホワイトリストへIPアドレスチェック以外が行われるようになります。
320
+
321
  = 2.7 =
322
   スパム判定メソッドの整理を実施。
323
   外部から利用できるようにしました。
throws_spam_away.class.php CHANGED
@@ -3,8 +3,8 @@
3
  *
4
  * <p>ThrowsSpamAway</p> Class
5
  * WordPress's Plugin
6
- * @author Takeshi Satoh@GTI Inc. 2015
7
- * @version 2.7.1
8
  */
9
  class ThrowsSpamAway {
10
 
@@ -32,6 +32,8 @@ class ThrowsSpamAway {
32
 
33
  define( 'SPAM_TRACKBACK', 'spam_trackback' );
34
  define( 'NOT_JAPANESE', 'not_japanese');
 
 
35
  }
36
 
37
  // 接頭辞(wp_)を付けてテーブル名を設定
@@ -69,6 +71,7 @@ class ThrowsSpamAway {
69
  global $default_spam_data_delete_flg, $default_spam_keep_day_count, $lower_spam_keep_day_count;
70
  global $default_spam_limit_flg, $default_spam_limit_minutes, $default_spam_limit_count;
71
  global $default_spam_limit_over_interval, $default_spam_limit_over_interval_error_msg;
 
72
 
73
  // 初期設定値
74
  update_option( 'tsa_dummy_param_field_flg', $default_dummy_param_field_flg );
@@ -99,6 +102,7 @@ class ThrowsSpamAway {
99
  update_option( 'tsa_spam_limit_count', $default_spam_limit_count );
100
  update_option( 'tsa_spam_limit_over_interval', $default_spam_limit_over_interval );
101
  update_option( 'tsa_spam_limit_over_interval_error_message', $default_spam_limit_over_interval_error_msg );
 
102
 
103
  // スパムデータベース作成
104
  $this->tsa_create_tbl();
@@ -235,6 +239,7 @@ class ThrowsSpamAway {
235
  global $default_block_ip_address_error_msg;
236
  global $default_url_count_over_error_msg;
237
  global $default_spam_limit_over_interval_error_msg;
 
238
 
239
  // ログインしている場合は通過させます。
240
  if ( $user_ID ) {
@@ -246,36 +251,33 @@ class ThrowsSpamAway {
246
  $comment = esc_attr( $_POST['comment'] );
247
 
248
  // チェック対象IPアドレス
249
- $ip = $_SERVER['REMOTE_ADDR'];
 
 
 
 
 
250
 
251
  // ホワイトリスト優先通過
252
  // IP制御 任意のIPアドレスをあればブロックする
253
  $white_ip_addresses = get_option( 'tsa_white_ip_addresses', '' );
254
- if ( $white_ip_addresses != NULL && $white_ip_addresses != '' ) {
255
- // 改行区切りの場合はカンマ区切りに文字列置換後リスト化
256
- $white_ip_addresses = str_replace( "\n", ',', $white_ip_addresses );
257
- $ip_list = explode( ',', $white_ip_addresses );
258
- foreach ( $ip_list as $_ip ) {
259
- // 指定IPが範囲指定の場合 例:192.168.1.0/24
260
- if ( strpos( $_ip, '/' ) != FALSE ) {
261
- if ( $this->in_cidr( $ip, $_ip ) ) {
262
- // 通過対象
263
- return $id;
264
- }
265
- } elseif ( trim( $_ip ) == trim( $ip ) ) {
266
- // 通過対象
267
- return $id;
268
- }
269
  }
270
  }
271
- // IP系の検査
272
- if ( ! $newThrowsSpamAway->ip_check( $ip ) ) {
273
- // アウト!
274
- } else
275
- // コメント検査
276
- if ( $newThrowsSpamAway->validation( $comment, $author, $id ) ) {
277
- return $id;
278
- }
279
  $error_type = $newThrowsSpamAway->error_type;
280
  $error_msg = '';
281
  switch ( $error_type ) {
@@ -286,10 +288,10 @@ class ThrowsSpamAway {
286
  $error_msg = get_option( 'tsa_ng_key_error_message', $default_ng_key_error_msg );
287
  break;
288
  case BLOCK_IP :
289
- $error_msg = get_option( 'tsa_block_ip_address_error_message', $default_block_ip_address_error_msg );
290
- break;
291
  case SPAM_BLACKLIST :
292
  $error_msg = get_option( 'tsa_block_ip_address_error_message', $default_block_ip_address_error_msg );
 
293
  case URL_COUNT_OVER :
294
  $error_msg = get_option( 'tsa_url_count_over_error_message', $default_url_count_over_error_msg );
295
  break;
@@ -307,7 +309,7 @@ class ThrowsSpamAway {
307
  $spam_contents['author'] = mb_strcut( $author, 0, 255 );
308
  $spam_contents['comment'] = mb_strcut( $comment, 0, 255 );
309
 
310
- $this->save_post_meta( $id, $ip, $spam_contents );
311
  }
312
  // 元画面へ戻るタイム計算
313
  $back_time = ( (int) get_option( 'tsa_back_second', $default_back_second ) ) * 1000;
@@ -316,7 +318,9 @@ class ThrowsSpamAway {
316
  header( 'Location:'.$_SERVER['HTTP_REFERER'] );
317
  die;
318
  } else {
319
- wp_die( __( $error_msg.'<script type="text/javascript">window.setTimeout(location.href=\''.$_SERVER['HTTP_REFERER'].'\', '.$back_time.');</script>', 'throws-spam-away' ) );
 
 
320
  }
321
  }
322
 
@@ -465,6 +469,39 @@ class ThrowsSpamAway {
465
  return strlen( bin2hex( $comment ) ) / 2 == mb_strlen( $comment );
466
  }
467
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
468
  /**
469
  * IPアドレスのチェックメソッド
470
  * @param string $target_ip
@@ -552,7 +589,13 @@ class ThrowsSpamAway {
552
 
553
  $spam_def_ip = '127.0.0.2';
554
  $pattern = '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/';
555
- $check_IP = trim( preg_match( $pattern, $ip ) ? $ip : $_SERVER['REMOTE_ADDR'] );
 
 
 
 
 
 
556
  $spam = FALSE;
557
  if ( preg_match( $pattern, $check_IP ) ) {
558
 
@@ -644,11 +687,18 @@ class ThrowsSpamAway {
644
  $interval_minutes = ( $tsa_spam_limit_minutes >= $tsa_spam_limit_over_interval ? $tsa_spam_limit_minutes : $tsa_spam_limit_over_interval );
645
 
646
  // 上記が○回を超えているかチェック
647
- $ip = htmlspecialchars( $_SERVER['REMOTE_ADDR'] );
 
 
 
 
 
 
 
648
  $this_ip_spam_cnt = "
649
  SELECT ip_address, count(ppd) as spam_count, max(post_date)
650
  FROM (select ip_address, post_date as ppd, post_date from $this->table_name) as A
651
- WHERE A.ip_address = '".$ip."' AND
652
  ppd >= '".gmdate( 'Y-m-d H:i:s', current_time( 'timestamp' ) - 60 * $interval_minutes )."'
653
  GROUP BY ip_address LIMIT 1";
654
  $query = $wpdb->get_row( $this_ip_spam_cnt );
@@ -718,6 +768,8 @@ class ThrowsSpamAway {
718
  */
719
  function options_page() {
720
  global $wpdb; // WordPress DBアクセス
 
 
721
  global $default_on_flg;
722
  global $default_without_title_str;
723
  global $default_dummy_param_field_flg;
@@ -754,6 +806,8 @@ class ThrowsSpamAway {
754
 
755
  global $spam_champuru_hosts;
756
 
 
 
757
  // 設定完了の場合はメッセージ表示
758
  $_saved = FALSE;
759
 
@@ -792,6 +846,7 @@ class ThrowsSpamAway {
792
  update_option( 'tsa_memo', $_POST['tsa_memo'] );
793
  update_option( 'tsa_spam_champuru_by_text', $_POST['tsa_spam_champuru_by_text'] );
794
  //update_option( 'tsa_spam_champuru_hosts', ( isset( $_POST['tsa_spam_champuru_hosts'] ) ? $_POST['tsa_spam_champuru_hosts'] : NULL ) );
 
795
 
796
  // スパムデータベース作成
797
  $this->tsa_create_tbl();
@@ -1158,7 +1213,18 @@ function addIpAddresses(newAddressStr) {
1158
  <td>
1159
  ※ここに登録したIPアドレスはスパムフィルタを掛けず優先的に通します。<br />※日本語以外の言語でご利用になられるお客様のIPアドレスを登録するなどご利用ください。<br />改行区切りで複数設定できます。範囲指定も可能です。(半角数字とスラッシュ、ドットのみ)
1160
  <textarea name="tsa_white_ip_addresses"
1161
- id="tsa_white_ip_addresses" cols="80" rows="10"><?php echo get_option( 'tsa_white_ip_addresses', '' );?></textarea>
 
 
 
 
 
 
 
 
 
 
 
1162
  </td>
1163
  </tr>
1164
 
@@ -1242,12 +1308,14 @@ function addIpAddresses(newAddressStr) {
1242
  <?php /**
1243
  <input
1244
  type="hidden" name="page_options"
1245
- value="tsa_on_flg,tsa_japanese_string_min_count,tsa_back_second,tsa_caution_message,tsa_caution_msg_point,tsa_error_message,tsa_ng_keywords,tsa_ng_key_error_message,tsa_must_keywords,tsa_must_key_error_message,tsa_tb_on_flg,tsa_tb_url_flg,tsa_block_ip_addresses,tsa_ip_block_from_spam_chk_flg,tsa_block_ip_address_error_message,tsa_url_count_on_flg,tsa_ok_url_count,tsa_url_count_over_error_message,tsa_spam_data_save,tsa_spam_limit_flg,tsa_spam_limit_minutes,tsa_spam_limit_count,tsa_spam_limit_over_interval,tsa_spam_limit_over_interval_error_message,tsa_spam_champuru_flg,tsa_spam_keep_day_count,tsa_spam_data_delete_flg,tsa_white_ip_addresses,tsa_dummy_param_field_flg,tsa_memo,tsa_spam_champuru_by_text" />
1246
  */ ?>
1247
  <p class="submit" id="tsa_submit_button">
1248
  <input type="submit" class="button-primary"
1249
  value="<?php _e('Save Changes') ?>" />
1250
  </p>
 
 
1251
  </form>
1252
  </div>
1253
  <?php
@@ -1270,8 +1338,14 @@ function addIpAddresses(newAddressStr) {
1270
  $comment = $tb["comment_content"];
1271
  $post_id = $tb["comment_post_ID"];
1272
  // IP系の検査
1273
- $ip = $_SERVER['REMOTE_ADDR'];
1274
- if ( ! $newThrowsSpamAway->ip_check( $ip ) ) {
 
 
 
 
 
 
1275
  $tb_val['is_spam'] = TRUE;
1276
  } else
1277
  // 検査します!
@@ -1293,7 +1367,7 @@ function addIpAddresses(newAddressStr) {
1293
  $spam_contents['author'] = mb_strcut( strip_tags( $author ), 0, 255 );
1294
  $spam_contents['comment'] = mb_strcut( strip_tags( $comment ), 0, 255 );
1295
 
1296
- $this->save_post_meta( $post_id, $ip, $spam_contents );
1297
  }
1298
  die( 'Your Trackback Throws Away.' );
1299
  }
@@ -1591,6 +1665,9 @@ function addIpAddresses(newAddressStr) {
1591
  case DUMMY_FIELD:
1592
  $spam_error_type_str = 'ダミー項目エラー';
1593
  break;
 
 
 
1594
  }
1595
  ?>
1596
  <tr>
3
  *
4
  * <p>ThrowsSpamAway</p> Class
5
  * WordPress's Plugin
6
+ * @author Takeshi Satoh@GTI Inc. 2016
7
+ * @version 2.8.2
8
  */
9
  class ThrowsSpamAway {
10
 
32
 
33
  define( 'SPAM_TRACKBACK', 'spam_trackback' );
34
  define( 'NOT_JAPANESE', 'not_japanese');
35
+
36
+ define( 'NOT_IN_WHITELIST_IP', 'not_in_whitelist_ip');
37
  }
38
 
39
  // 接頭辞(wp_)を付けてテーブル名を設定
71
  global $default_spam_data_delete_flg, $default_spam_keep_day_count, $lower_spam_keep_day_count;
72
  global $default_spam_limit_flg, $default_spam_limit_minutes, $default_spam_limit_count;
73
  global $default_spam_limit_over_interval, $default_spam_limit_over_interval_error_msg;
74
+ global $default_only_whitelist_ip_flg;
75
 
76
  // 初期設定値
77
  update_option( 'tsa_dummy_param_field_flg', $default_dummy_param_field_flg );
102
  update_option( 'tsa_spam_limit_count', $default_spam_limit_count );
103
  update_option( 'tsa_spam_limit_over_interval', $default_spam_limit_over_interval );
104
  update_option( 'tsa_spam_limit_over_interval_error_message', $default_spam_limit_over_interval_error_msg );
105
+ update_option( 'tsa_only_whitelist_ip_flg', $default_only_whitelist_ip_flg );
106
 
107
  // スパムデータベース作成
108
  $this->tsa_create_tbl();
239
  global $default_block_ip_address_error_msg;
240
  global $default_url_count_over_error_msg;
241
  global $default_spam_limit_over_interval_error_msg;
242
+ global $default_only_whitelist_ip_flg;
243
 
244
  // ログインしている場合は通過させます。
245
  if ( $user_ID ) {
251
  $comment = esc_attr( $_POST['comment'] );
252
 
253
  // チェック対象IPアドレス
254
+ $remote_ip = $_SERVER['REMOTE_ADDR'];
255
+ if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
256
+ $remote_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
257
+ $ip_array = explode(",", $remote_ip);
258
+ $remote_ip = $ip_array[0];
259
+ }
260
 
261
  // ホワイトリスト優先通過
262
  // IP制御 任意のIPアドレスをあればブロックする
263
  $white_ip_addresses = get_option( 'tsa_white_ip_addresses', '' );
264
+ $only_whitelist_ip_flg = get_option( 'tsa_only_whitelist_ip_flg', $default_only_whitelist_ip_flg );
265
+ $white_ip = !$newThrowsSpamAway->white_ip_check( $remote_ip );
266
+ // IP制御 ホワイトリストIPのみ許可する場合(ホワイトリストに記入がある場合のみ有効)
267
+ if ( ( $white_ip_addresses != NULL && $white_ip_addresses != '' ) &&
268
+ $only_whitelist_ip_flg === '1' && $white_ip == FALSE) {
269
+ // ホワイトリスト以外通さない
270
+ $newThrowsSpamAway->error_type = NOT_IN_WHITELIST_IP;
271
+ } else {
272
+ // IP系の検査
273
+ if ( ! $newThrowsSpamAway->ip_check( $remote_ip ) && $white_ip == FALSE ) {
274
+ // アウト!
275
+ } else
276
+ // コメント検査
277
+ if ( $newThrowsSpamAway->validation( $comment, $author, $id ) ) {
278
+ return $id;
279
  }
280
  }
 
 
 
 
 
 
 
 
281
  $error_type = $newThrowsSpamAway->error_type;
282
  $error_msg = '';
283
  switch ( $error_type ) {
288
  $error_msg = get_option( 'tsa_ng_key_error_message', $default_ng_key_error_msg );
289
  break;
290
  case BLOCK_IP :
291
+ case NOT_IN_WHITELIST_IP :
 
292
  case SPAM_BLACKLIST :
293
  $error_msg = get_option( 'tsa_block_ip_address_error_message', $default_block_ip_address_error_msg );
294
+ break;
295
  case URL_COUNT_OVER :
296
  $error_msg = get_option( 'tsa_url_count_over_error_message', $default_url_count_over_error_msg );
297
  break;
309
  $spam_contents['author'] = mb_strcut( $author, 0, 255 );
310
  $spam_contents['comment'] = mb_strcut( $comment, 0, 255 );
311
 
312
+ $this->save_post_meta( $id, $remote_ip, $spam_contents );
313
  }
314
  // 元画面へ戻るタイム計算
315
  $back_time = ( (int) get_option( 'tsa_back_second', $default_back_second ) ) * 1000;
318
  header( 'Location:'.$_SERVER['HTTP_REFERER'] );
319
  die;
320
  } else {
321
+ wp_die( __( $error_msg.'<script type="text/javascript">
322
+ var closing = function() {location.href=\''.$_SERVER['HTTP_REFERER'].'\';}
323
+ window.setTimeout( closing, '.$back_time.');</script>', 'throws-spam-away' ) );
324
  }
325
  }
326
 
469
  return strlen( bin2hex( $comment ) ) / 2 == mb_strlen( $comment );
470
  }
471
 
472
+ /**
473
+ * IP制御ホワイトリストチェックメソッド
474
+ * @param string $target_ip
475
+ */
476
+ function white_ip_check( $target_ip ) {
477
+ global $default_only_whitelist_ip_flg;
478
+ $white_ip_addresses = get_option( 'tsa_white_ip_addresses', '' );
479
+ $only_whitelist_ip_flg = get_option( 'tsa_only_whitelist_ip_flg', $default_only_whitelist_ip_flg );
480
+
481
+ if ( $white_ip_addresses != NULL && $white_ip_addresses != '' ) {
482
+ // 改行区切りの場合はカンマ区切りに文字列置換後リスト化
483
+ $white_ip_addresses = str_replace( "\n", ',', $white_ip_addresses );
484
+ $ip_list = explode( ',', $white_ip_addresses );
485
+ foreach ( $ip_list as $_ip ) {
486
+ // 指定IPが範囲指定の場合 例:192.168.1.0/24
487
+ if ( strpos( $_ip, '/' ) != FALSE ) {
488
+ if ( $this->in_cidr( $target_ip, $_ip ) ) {
489
+ // 通過対象
490
+ if ( $only_whitelist_ip_flg === '1' ) {
491
+ return FALSE;
492
+ }
493
+ }
494
+ } elseif ( trim( $_ip ) == trim( $target_ip ) ) {
495
+ // 通過対象
496
+ if ( $only_whitelist_ip_flg === '1' ) {
497
+ return FALSE;
498
+ }
499
+ }
500
+ }
501
+ }
502
+ return TRUE;
503
+ }
504
+
505
  /**
506
  * IPアドレスのチェックメソッド
507
  * @param string $target_ip
589
 
590
  $spam_def_ip = '127.0.0.2';
591
  $pattern = '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/';
592
+ $remote_ip = $_SERVER['REMOTE_ADDR'];
593
+ if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
594
+ $remote_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
595
+ $ip_array = explode(",", $remote_ip);
596
+ $remote_ip = $ip_array[0];
597
+ }
598
+ $check_IP = trim( preg_match( $pattern, $ip ) ? $ip : $remote_ip );
599
  $spam = FALSE;
600
  if ( preg_match( $pattern, $check_IP ) ) {
601
 
687
  $interval_minutes = ( $tsa_spam_limit_minutes >= $tsa_spam_limit_over_interval ? $tsa_spam_limit_minutes : $tsa_spam_limit_over_interval );
688
 
689
  // 上記が○回を超えているかチェック
690
+ $remote_ip = $_SERVER['REMOTE_ADDR'];
691
+ if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
692
+ $remote_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
693
+ $ip_array = explode(",", $remote_ip);
694
+ $remote_ip = $ip_array[0];
695
+ }
696
+
697
+ $ip = htmlspecialchars( $remote_ip );
698
  $this_ip_spam_cnt = "
699
  SELECT ip_address, count(ppd) as spam_count, max(post_date)
700
  FROM (select ip_address, post_date as ppd, post_date from $this->table_name) as A
701
+ WHERE A.ip_address = '".$remote_ip."' AND
702
  ppd >= '".gmdate( 'Y-m-d H:i:s', current_time( 'timestamp' ) - 60 * $interval_minutes )."'
703
  GROUP BY ip_address LIMIT 1";
704
  $query = $wpdb->get_row( $this_ip_spam_cnt );
768
  */
769
  function options_page() {
770
  global $wpdb; // WordPress DBアクセス
771
+ global $tsa_version;
772
+
773
  global $default_on_flg;
774
  global $default_without_title_str;
775
  global $default_dummy_param_field_flg;
806
 
807
  global $spam_champuru_hosts;
808
 
809
+ global $default_only_whitelist_ip_flg;
810
+
811
  // 設定完了の場合はメッセージ表示
812
  $_saved = FALSE;
813
 
846
  update_option( 'tsa_memo', $_POST['tsa_memo'] );
847
  update_option( 'tsa_spam_champuru_by_text', $_POST['tsa_spam_champuru_by_text'] );
848
  //update_option( 'tsa_spam_champuru_hosts', ( isset( $_POST['tsa_spam_champuru_hosts'] ) ? $_POST['tsa_spam_champuru_hosts'] : NULL ) );
849
+ update_option( 'tsa_only_whitelist_ip_flg', $_POST['tsa_only_whitelist_ip_flg'] );
850
 
851
  // スパムデータベース作成
852
  $this->tsa_create_tbl();
1213
  <td>
1214
  ※ここに登録したIPアドレスはスパムフィルタを掛けず優先的に通します。<br />※日本語以外の言語でご利用になられるお客様のIPアドレスを登録するなどご利用ください。<br />改行区切りで複数設定できます。範囲指定も可能です。(半角数字とスラッシュ、ドットのみ)
1215
  <textarea name="tsa_white_ip_addresses"
1216
+ id="tsa_white_ip_addresses" cols="80" rows="10"><?php echo get_option( 'tsa_white_ip_addresses', '' );?></textarea><br />
1217
+ <?php
1218
+ $chk = '';
1219
+ if ( get_option( 'tsa_only_whitelist_ip_flg', $default_only_whitelist_ip_flg) == '1' ) {
1220
+ $chk = ' checked="checked"';
1221
+ }
1222
+ ?> <label><input type="checkbox"
1223
+ name="tsa_only_whitelist_ip_flg" value='1'
1224
+ <?php esc_attr_e( $chk ); ?> />&nbsp;ホワイトリストに登録したIPアドレス以外からの投稿を無視する(ホワイトリストへの登録がない場合は有効になりません)</label><br />
1225
+ (初期設定:<?php echo ( $default_only_whitelist_ip_flg != '1' ? "しない" : "する" ); ?>)<br />
1226
+ ※ホワイトリストで登録したIP以外の投稿は無視されますのでこの設定は慎重に行ってください。(すべての設定より優先します)<br />
1227
+ ※エラーメッセージは「ブロック対象のIPアドレスからの投稿時に表示される文言」が使われます。(エラー表示時のみ)
1228
  </td>
1229
  </tr>
1230
 
1308
  <?php /**
1309
  <input
1310
  type="hidden" name="page_options"
1311
+ value="tsa_on_flg,tsa_japanese_string_min_count,tsa_back_second,tsa_caution_message,tsa_caution_msg_point,tsa_error_message,tsa_ng_keywords,tsa_ng_key_error_message,tsa_must_keywords,tsa_must_key_error_message,tsa_tb_on_flg,tsa_tb_url_flg,tsa_block_ip_addresses,tsa_ip_block_from_spam_chk_flg,tsa_block_ip_address_error_message,tsa_url_count_on_flg,tsa_ok_url_count,tsa_url_count_over_error_message,tsa_spam_data_save,tsa_spam_limit_flg,tsa_spam_limit_minutes,tsa_spam_limit_count,tsa_spam_limit_over_interval,tsa_spam_limit_over_interval_error_message,tsa_spam_champuru_flg,tsa_spam_keep_day_count,tsa_spam_data_delete_flg,tsa_white_ip_addresses,tsa_dummy_param_field_flg,tsa_memo,tsa_spam_champuru_by_text,tsa_only_whitelist_ip_flg" />
1312
  */ ?>
1313
  <p class="submit" id="tsa_submit_button">
1314
  <input type="submit" class="button-primary"
1315
  value="<?php _e('Save Changes') ?>" />
1316
  </p>
1317
+ <p>Throws SPAM Away version <?php echo $tsa_version;?></p>
1318
+
1319
  </form>
1320
  </div>
1321
  <?php
1338
  $comment = $tb["comment_content"];
1339
  $post_id = $tb["comment_post_ID"];
1340
  // IP系の検査
1341
+ $remote_ip = $_SERVER['REMOTE_ADDR'];
1342
+ if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
1343
+ $remote_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
1344
+ $ip_array = explode(",", $remote_ip);
1345
+ $remote_ip = $ip_array[0];
1346
+ }
1347
+
1348
+ if ( ! $newThrowsSpamAway->ip_check( $remote_ip ) ) {
1349
  $tb_val['is_spam'] = TRUE;
1350
  } else
1351
  // 検査します!
1367
  $spam_contents['author'] = mb_strcut( strip_tags( $author ), 0, 255 );
1368
  $spam_contents['comment'] = mb_strcut( strip_tags( $comment ), 0, 255 );
1369
 
1370
+ $this->save_post_meta( $post_id, $remote_ip, $spam_contents );
1371
  }
1372
  die( 'Your Trackback Throws Away.' );
1373
  }
1665
  case DUMMY_FIELD:
1666
  $spam_error_type_str = 'ダミー項目エラー';
1667
  break;
1668
+ case NOT_IN_WHITELIST_IP:
1669
+ $spam_error_type_str = 'ホワイトリスト許可IP以外';
1670
+ break;
1671
  }
1672
  ?>
1673
  <tr>
throws_spam_away.php CHANGED
@@ -1,14 +1,14 @@
1
  <?php
2
  /*
3
  Plugin Name: Throws SPAM Away
4
- Plugin URI: http://gti.jp/throws-spam-away/
5
  Description: コメント内に日本語の記述が存在しない場合はあたかも受け付けたように振る舞いながらも捨ててしまうプラグイン
6
  Author: 株式会社ジーティーアイ さとう たけし
7
- Version: 2.7.1
8
- Author URI: http://gti.jp/
9
  License: GPL2
10
  */
11
- /* Copyright 2015 Takeshi Satoh (http://gti.jp/)
12
 
13
  This program is free software; you can redistribute it and/or modify
14
  it under the terms of the GNU General Public License, version 2, as
@@ -33,7 +33,7 @@ require_once 'throws_spam_away.class.php';
33
  $tsa_spam_tbl_name = 'tsa_spam';
34
 
35
  // Throws SPAM Awayバージョン
36
- $tsa_version = '2.7';
37
  // スパムデータベースバージョン
38
  $tsa_db_version = 2.6; // 2.6からデータベース変更 [error_type]追加
39
 
@@ -116,6 +116,11 @@ $default_ip_block_from_spam_chk_flg = '1'; // "1":する
116
  // ブロックIPアドレスからの投稿の場合に表示されるエラー文言(初期設定)
117
  $default_block_ip_address_error_msg = '';
118
 
 
 
 
 
 
119
  /** スパムデータベース */
120
 
121
  // スパムデータベース保存するか "0":保存しない
@@ -166,6 +171,8 @@ $default_spam_limit_over_interval_error_msg = ''; // そしてその際のエ
166
  // [tsa_block_ip_addresses] 文字列型
167
  // ブロック対象IPアドレスからの投稿時に表示される文言(元の記事に戻ってくる時間の間のみ表示)
168
  // [tsa_block_ip_address_error_message] 文字列型
 
 
169
  // URL(単純に'http'文字列のチェックのみ)文字列数を制限するか [tsa_url_count_on_flg] 1:する その他:しない
170
  // URL(単純に'http'文字列のチェックのみ)文字列の許容数 [tsa_ok_url_count] 数値型
171
  // URL(単純に'http'文字列のチェックのみ)文字列許容数オーバー時に表示される文言(元の記事に戻ってくる時間の間のみ表示)
@@ -198,3 +205,5 @@ if ( '2' == $comment_form_action_point ) {
198
  add_action( $comment_disp_point, array( &$newThrowsSpamAway, 'comment_form' ), 9999 );
199
  // コメントチェックフィルター
200
  add_action( 'pre_comment_on_post', array( &$newThrowsSpamAway, 'comment_post' ), 1 );
 
 
1
  <?php
2
  /*
3
  Plugin Name: Throws SPAM Away
4
+ Plugin URI: https://gti.co.jp/throws-spam-away/
5
  Description: コメント内に日本語の記述が存在しない場合はあたかも受け付けたように振る舞いながらも捨ててしまうプラグイン
6
  Author: 株式会社ジーティーアイ さとう たけし
7
+ Version: 2.8.1
8
+ Author URI: https://gti.co.jp/
9
  License: GPL2
10
  */
11
+ /* Copyright 2016 Takeshi Satoh (https://gti.co.jp/)
12
 
13
  This program is free software; you can redistribute it and/or modify
14
  it under the terms of the GNU General Public License, version 2, as
33
  $tsa_spam_tbl_name = 'tsa_spam';
34
 
35
  // Throws SPAM Awayバージョン
36
+ $tsa_version = '2.8.2';
37
  // スパムデータベースバージョン
38
  $tsa_db_version = 2.6; // 2.6からデータベース変更 [error_type]追加
39
 
116
  // ブロックIPアドレスからの投稿の場合に表示されるエラー文言(初期設定)
117
  $default_block_ip_address_error_msg = '';
118
 
119
+ /** ver.2.8から */
120
+ // ホワイトリスト以外無視するか
121
+ $default_only_whitelist_ip_flg = '2'; // "2":しない
122
+ /** /ver.2.8 */
123
+
124
  /** スパムデータベース */
125
 
126
  // スパムデータベース保存するか "0":保存しない
171
  // [tsa_block_ip_addresses] 文字列型
172
  // ブロック対象IPアドレスからの投稿時に表示される文言(元の記事に戻ってくる時間の間のみ表示)
173
  // [tsa_block_ip_address_error_message] 文字列型
174
+ // ホワイトリスト登録IPアドレスのみ許可フラグ
175
+ // [tsa_only_whitelist_ip_flg] 1:する その他:しない
176
  // URL(単純に'http'文字列のチェックのみ)文字列数を制限するか [tsa_url_count_on_flg] 1:する その他:しない
177
  // URL(単純に'http'文字列のチェックのみ)文字列の許容数 [tsa_ok_url_count] 数値型
178
  // URL(単純に'http'文字列のチェックのみ)文字列許容数オーバー時に表示される文言(元の記事に戻ってくる時間の間のみ表示)
205
  add_action( $comment_disp_point, array( &$newThrowsSpamAway, 'comment_form' ), 9999 );
206
  // コメントチェックフィルター
207
  add_action( 'pre_comment_on_post', array( &$newThrowsSpamAway, 'comment_post' ), 1 );
208
+ // // コメントチェックフィルター for bbPress
209
+ // add_action( 'bbp_new_forum_pre_insert', array( &$newThrowsSpamAway, 'comment_post' ), 1 );
uninstall.php CHANGED
@@ -53,5 +53,7 @@ delete_option('tsa_spam_champuru_by_text');
53
  // ver.2.6.8
54
  global $wpdb;
55
  $wpdb->query( "DROP TABLE IF EXISTS ".$wpdb->prefix . "tsa_spam" );
56
-
 
 
57
 
53
  // ver.2.6.8
54
  global $wpdb;
55
  $wpdb->query( "DROP TABLE IF EXISTS ".$wpdb->prefix . "tsa_spam" );
56
+
57
+ // ver.2.8
58
+ delete_option('tsa_only_whitelist_ip_flg');
59