Throws SPAM Away - Version 1.6.1

Version Description

NG

Download this release

Release Info

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

Code changes from version 1.3 to 1.6.1

Files changed (3) hide show
  1. readme.txt +72 -6
  2. throws_spam_away.php +254 -63
  3. uninstall.php +20 -0
readme.txt CHANGED
@@ -1,19 +1,46 @@
1
  === Plugin Name ===
2
- Contributors: tsato
3
- Donate link: http://iscw.jp/
4
  Tags: comments, spam
5
  Requires at least: 3.1
6
- Tested up to: 3.2.1
7
- Stable tag: 1.3
8
 
9
  コメント内に日本語文字列が一つも存在しない場合あたかも受け付けたように振る舞いながらも無視
10
 
11
  == Description ==
12
- コメント欄に日本語文字列が含まれていないと投稿出来ない・・・といってもエラーにするのではなく「無視」して何事もなかったようにもとの記事に戻る。
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  == Installation ==
15
 
16
- This section describes how to install the plugin and get it working.
 
 
 
 
 
 
17
 
18
  e.g.
19
 
@@ -30,6 +57,41 @@ e.g.
30
  == Screenshots ==
31
 
32
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  = 1.3 =
34
  コメント欄下の注意文言及びエラー文言を設定可能にしました。
35
 
@@ -47,6 +109,10 @@ e.g.
47
  新規作成
48
 
49
  == Upgrade Notice ==
 
 
 
 
50
  = 1.3 =
51
  コメント欄下の注意文言及びエラー文言を設定可能にしました。
52
 
1
  === Plugin Name ===
2
+ Contributors: taman777
3
+ Donate link: http://blog.gti.jp/
4
  Tags: comments, spam
5
  Requires at least: 3.1
6
+ Tested up to: 3.4
7
+ Stable tag: 1.6.1
8
 
9
  コメント内に日本語文字列が一つも存在しない場合あたかも受け付けたように振る舞いながらも無視
10
 
11
  == Description ==
12
+ 海外からのコメントスパムに対抗(?)する手段として開発したプラグインです。
13
+
14
+ コメント欄に日本語文字列が含まれていないと投稿出来ない・・・
15
+ といってもエラーにするのではなく「無視」して何事もなかったようにもとの記事に戻ります。
16
+
17
+ ダブルバイトをカウントするのではなく正規表現により日本語を検出しているため、ダブルバイトの他言語も侵入してきません。
18
+
19
+ また、NGキーワードを複数設定することが出来ます。(カンマ区切りにて設定)
20
+ 日本語の文章であっても設定された「NGキーワード」を含む投稿の場合は、同様に無視します。
21
+ もちろん他の言語のキーワードでもOKです。
22
+
23
+ 日本語が一切入っていないコメントでも「NGキーワード」だけ設定したい場合を想定し
24
+ 日本語が入っていないと許可しない設定を「オン・オフ」出来るようになっています。
25
+
26
+ バージョン1.5では「トラックバック」に対しても同様の規制を入れられるようになりました。
27
+ トラックバック記事の内容に日本語を含まないものを無視します。
28
+ 加えて、トラックバック記事内にこちらのサイトのURLが含まれない場合、日本語が含まれていても無視するかどうかの設定も出来るようにしました。
29
+
30
+ バージョン1.6にてNGキーワードとは逆にコレが入っていないとダメという「必須キーワード」の設定が出来るようにしました。
31
+ 日本語を入れれば良いため通ってしまいやすい「中国語」への配慮です。「が」や「の」や「は」など、日本語文章が成り立つ上で必ず使用するであろう「ひらがな」を入れることで効力が発揮されると思います。
32
+
33
+ 制作:佐藤 毅(さとう たけし) <a href="http://gti.jp/" target="_blank">博多 ホームページ制作</a> 株式会社ジーティーアイ代表
34
 
35
  == Installation ==
36
 
37
+ インストールする場合は、ダッシュボードの「プラグイン」メニューから
38
+ 「新規追加」をクリックして、「キーワード」に「Throws SPAM Away」と入力し「プラグインの検索」を行って
39
+ 結果に現れた「Throws SPAM Away」をインストールしてください。
40
+
41
+ または、ダウンロードした「throws-spam-away」フォルダを
42
+ FTPなどで /wp-content/plugins/ ディレクトリにアップロードし
43
+ 「プラグイン」メニューより「Throws SPAM Away」を「有効化」してご利用ください。
44
 
45
  e.g.
46
 
57
  == Screenshots ==
58
 
59
  == Changelog ==
60
+
61
+ = 1.6.1 =
62
+ 日本語文字が何文字以上入っていないとNGかのしきい値とちらっと現れるエラー文言画面から元の記事に戻ってくる時間の設定が
63
+ 「ミリ秒」だったのをわかりやすいように「秒」設定に変更します。
64
+
65
+ ~現在、この設定をしている方へ!!!~
66
+ 今までの設定値が有効の場合に1000秒以上待つことになりかねないため変数名を変更しました。
67
+ 再度設定を、「秒単位」にてお願い致します。
68
+
69
+ = 1.6 =
70
+ 必須キーワードの設定ができるようにしました。※複数指定可能
71
+ これにより漢字などが入り込んでなんとか通ってきた言語に対しても「ひらがな」等の指定によりより一層厳しくチェックできるようになります。
72
+
73
+ = 1.5 =
74
+ トラックバック・ピンバックに対しても同様のチェックを行う機能をつけました。
75
+ (オン・オフ設定出来ます。)
76
+ また、その際、トラックバック記事の中に自サイトのURLが含まれているかどうかをチェックすることも出来るようにしています。
77
+ (オン・オフ設定出来ます。)
78
+ ※トラックバックに対しては使用しないで従来通りご利用いただけます。
79
+ ※インストール時はトラックバック記事には適用しない設定になっておりますのでご利用時には「設定」メニューより「Throws SPAM Away」をクリックしていただき
80
+  「上記設定をトラックバック記事にも採用する」を「する」に
81
+  「トラックバック記事にも採用する場合、ついでにこちらのURLが含まれているか判断する」を適宜 変更してご使用ください。
82
+
83
+ = 1.4.2 =
84
+ バグ修正
85
+
86
+ = 1.4.1 =
87
+ バグ修正
88
+
89
+ = 1.4 =
90
+ 機能のオン・オフをつけました。
91
+ NGキーワードの設定が出来るようになりました。
92
+ 日本語でも他の言語でもNGキーワードが入っていれば同様に処理するようにしました。
93
+ NGキーワードに引っかかってしまった場合のエラー文言は別途設定できます。
94
+
95
  = 1.3 =
96
  コメント欄下の注意文言及びエラー文言を設定可能にしました。
97
 
109
  新規作成
110
 
111
  == Upgrade Notice ==
112
+ = 1.4 =
113
+ 機能のオン・オフ設定追加
114
+ NGキーワード(日本語及びその他言語)の設定による無視機能追加
115
+
116
  = 1.3 =
117
  コメント欄下の注意文言及びエラー文言を設定可能にしました。
118
 
throws_spam_away.php CHANGED
@@ -3,16 +3,61 @@
3
  Plugin Name: Throws SPAM Away
4
  Plugin URI: http://iscw.jp/wp/
5
  Description: コメント内に日本語の記述が一つも存在しない場合はあたかも受け付けたように振る舞いながらも捨ててしまうプラグイン
6
- Author: 株式会社アイ・エス・シー さとう たけし
7
- Version: 1.3
8
- Author URI: http://iscw.jp/
9
  */
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  class ThrowsSpamAway {
12
  // version
13
- var $version = '1.3';
14
-
15
- function ThrowsSpamAway() {
16
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
17
  }
18
 
@@ -23,13 +68,16 @@ class ThrowsSpamAway {
23
  echo '<div id="throwsSpamAway">';
24
  echo ($caution_msg != null? $caution_msg : $default_caution_msg);
25
  echo '</div>';
26
- return true;
27
  }
28
 
29
  function comment_post($id) {
30
  global $newThrowsSpamAway;
31
  global $user_ID;
32
  global $default_error_msg;
 
 
 
33
 
34
  if( $user_ID ) {
35
  return $id;
@@ -39,8 +87,16 @@ class ThrowsSpamAway {
39
  if ($newThrowsSpamAway->validation($comment)) {
40
  return $id;
41
  }
42
- $error_msg = get_option('tsa_error_message');
43
- wp_die( __(($error_msg != null? $error_msg : $default_error_msg).'<script type="text/javascript">window.setTimeout(location.href = "'.$_SERVER['HTTP_REFERER'].'", '.(get_option('tsa_back_content_second')!=null?get_option('tsa_back_content_second'):10).');</script>', 'throws-spam-away'));
 
 
 
 
 
 
 
 
44
  }
45
 
46
  /**
@@ -49,28 +105,65 @@ class ThrowsSpamAway {
49
  */
50
  function validation($comment) {
51
  global $newThrowsSpamAway;
 
52
  // まずはシングルバイトだけならエラー
53
- if (strlen(bin2hex($comment)) / 2 == mb_strlen($comment)) {
54
- return false;
55
  } else {
 
 
56
  // マルチバイト文字が含まれている場合は日本語が含まれていればOK
57
- $count_flg = 0;
58
- mb_regex_encoding('UTF-8');
59
- $com_split = $newThrowsSpamAway->mb_str_split($comment);
60
- foreach ($com_split as $it) {
61
- if (preg_match('/[一-龠]+/u', $it)){ $count_flg += 1; }
62
- if (preg_match('/[ァ-ヶー]+/u', $it)){ $count_flg += 1; }
63
- if (preg_match('/[ぁ-ん]+/u', $it)){ $count_flg += 1; }
64
- }
65
- return ((get_option('tsa_japanese_string_min_count')!= null?
 
66
  intval(get_option('tsa_japanese_string_min_count')):0) < $count_flg);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  }
68
  }
69
-
70
- function mb_str_split( $string ) {
71
- return preg_split('/(?<!^)(?!$)/u', $string );
72
- }
73
-
74
  /**
75
  * Callback admin_menu
76
  */
@@ -88,46 +181,144 @@ class ThrowsSpamAway {
88
  function options_page() {
89
  global $default_caution_msg;
90
  global $default_error_msg;
91
- ?>
 
 
92
  <div class="wrap">
93
  <h2>Throws SPAM Away. Setting</h2>
94
- <form method="post" action="options.php">
95
- <?php wp_nonce_field('update-options'); ?>
96
- <table class="form-table">
97
- <tr valign="top">
98
- <th scope="row">日本語文字列含有数<br />(この文字列に達していない場合無視対象となります。)</th>
99
- <td><input type="text" name="tsa_japanese_string_min_count" value="<?php echo get_option('tsa_japanese_string_min_count'); ?>" /></td>
100
- </tr>
101
- <tr valign="top">
102
- <th scope="row">元の記事に戻ってくる時間<br />(ミリ秒)</th>
103
- <td><input type="text" name="tsa_back_content_second" value="<?php echo get_option('tsa_back_content_second');?>" /></td>
104
- </tr>
105
- <tr valign="top">
106
- <th scope="row">コメント欄の下に表示される注意文言</th>
107
- <td><input type="text" name="tsa_caution_message" size="50" value="<?php echo get_option('tsa_caution_message');?>" /><br />(初期設定:<?php echo $default_caution_msg;?>)</td>
108
- </tr>
109
- <tr valign="top">
110
- <th scope="row">エラー時に表示される文言<br />(元の記事に戻ってくる時間の間のみ表示)</th>
111
- <td><input type="text" name="tsa_error_message" size="50" value="<?php echo get_option('tsa_error_message');?>" /><br />(初期設定:<?php echo $default_error_msg;?>)</td>
112
- </tr>
113
- </table>
114
- <input type="hidden" name="action" value="update" />
115
- <input type="hidden" name="page_options" value="tsa_japanese_string_min_count,tsa_back_content_second,tsa_caution_message,tsa_error_message" />
116
- <p class="submit">
117
- <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
118
- </p>
119
- </form>
120
- <div class="clear"></div>
121
- </div>
122
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
124
- }
125
- // コメント欄下に表示される注意文言(初期設定)
126
- $default_caution_msg = '日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)';
127
- // エラー時に表示されるエラー文言(初期設定)
128
- $default_error_msg = '日本語を規定文字数以上含まない記事は投稿できませんよ。';
129
 
130
- $newThrowsSpamAway = new ThrowsSpamAway;
131
- add_action('comment_form', array(&$newThrowsSpamAway, "comment_form"), 9999);
132
- add_action('pre_comment_on_post', array(&$newThrowsSpamAway, "comment_post"), 1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  ?>
3
  Plugin Name: Throws SPAM Away
4
  Plugin URI: http://iscw.jp/wp/
5
  Description: コメント内に日本語の記述が一つも存在しない場合はあたかも受け付けたように振る舞いながらも捨ててしまうプラグイン
6
+ Author: 株式会社ジーティーアイ さとう たけし
7
+ Version: 1.6.1
8
+ Author URI: http://gti.jp/
9
  */
10
 
11
+ /** 初期設定 */
12
+ // エラー種別
13
+ $error_type = "";
14
+ // コメント欄下に表示される注意文言(初期設定)
15
+ $default_caution_msg = '日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)';
16
+ // エラー時に表示されるエラー文言(初期設定)
17
+ $default_error_msg = '日本語を規定文字数以上含まない記事は投稿できませんよ。';
18
+ // キーワードNGエラー時に表示されるエラー文言(初期設定)
19
+ $default_ng_key_error_msg = 'NGキーワードが含まれているため投稿できません。';
20
+ // 必須キーワードが含まれないエラー文言(初期設定)
21
+ $default_must_key_error_msg = "必須キーワードが含まれていないため投稿できません。";
22
+ /** オプションキー */
23
+ // 日本語が存在しない時エラーとするかフラグ [tsa_on_flg] 1:する 2:しない
24
+ // 日本語文字列含有数 (入力値以下ならエラー) [tsa_japanese_string_min_count] 数値型
25
+ // 元の記事に戻ってくる時間(秒) [tsa_back_second] 数値型
26
+ // コメント欄の下に表示される注意文言 [tsa_caution_message] 文字列型
27
+ // 日本語文字列規定値未満エラー時に表示される文言(元の記事に戻ってくる時間の間のみ表示)
28
+ // [tsa_error_message] 文字列型
29
+ // その他NGキーワード(日本語でも英語(その他)でもNGとしたいキーワードを半角カンマ区切りで複数設定できます。挙動は同じです。NGキーワードだけでも使用できます。)
30
+ // [tsa_ng_keywords] 文字列型(半角カンマ区切り文字列)
31
+ // NGキーワードエラー時に表示される文言(元の記事に戻ってくる時間の間のみ表示)
32
+ // [tsa_ng_key_error_message] 文字列型
33
+ // 必須キーワード(日本語でも英語(その他)でも必須としたいキーワードを半角カンマ区切りで複数設定できます。指定文字列を含まない場合はエラーとなります。※複数の方が厳しくなります。必須キーワードだけでも使用できます。)
34
+ // [tsa_must_keywords] 文字列型(半角カンマ区切り文字列)
35
+ // 必須キーワードエラー時に表示される文言(元の記事に戻ってくる時間の間のみ表示)
36
+ // [tsa_must_key_error_message] 文字列型
37
+ // この設定をトラックバック記事にも採用するか [tsa_tb_on_flg] 1:する 2:しない
38
+ // トラックバック記事にも採用する場合、ついでにこちらのURLが含まれているか判断するか
39
+ // [tsa_tb_url_flg] 1:する 2:しない
40
+
41
+ /** プロセス */
42
+ $newThrowsSpamAway = new ThrowsSpamAway;
43
+ // トラックバックチェックフィルター
44
+ add_filter('preprocess_comment', array(&$newThrowsSpamAway, 'trackback_spam_away'), 1, 1);
45
+ // コメントフォーム表示
46
+ add_action('comment_form', array(&$newThrowsSpamAway, "comment_form"), 9999);
47
+ add_action('pre_comment_on_post', array(&$newThrowsSpamAway, "comment_post"), 1);
48
+
49
+ /**
50
+ *
51
+ * <p>ThrowsSpamAway</p>
52
+ * WordPress's Plugin
53
+ * @author TAMAN
54
+ *
55
+ */
56
  class ThrowsSpamAway {
57
  // version
58
+ var $version = '1.6.1';
59
+
60
+ public function __construct() {
61
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
62
  }
63
 
68
  echo '<div id="throwsSpamAway">';
69
  echo ($caution_msg != null? $caution_msg : $default_caution_msg);
70
  echo '</div>';
71
+ return TRUE;
72
  }
73
 
74
  function comment_post($id) {
75
  global $newThrowsSpamAway;
76
  global $user_ID;
77
  global $default_error_msg;
78
+ global $default_ng_key_error_msg;
79
+ global $default_must_key_error_msg;
80
+ global $error_type;
81
 
82
  if( $user_ID ) {
83
  return $id;
87
  if ($newThrowsSpamAway->validation($comment)) {
88
  return $id;
89
  }
90
+ $error_msg = (
91
+ $error_type != "must_word" ? (
92
+ $error_type != "ng_word" ? (
93
+ get_option('tsa_error_message') != null ?
94
+ get_option('tsa_error_message') : $default_error_msg) :
95
+ (get_option('tsa_ng_key_error_message') != null ?
96
+ get_option('tsa_ng_key_error_message') : $default_ng_key_error_msg)) :
97
+ (get_option('tsa_must_key_error_message') != null ?
98
+ get_option('tsa_must_key_error_message') : $default_must_key_error_msg));
99
+ wp_die( __(($error_msg != null? $error_msg : $default_error_msg)."<script type=\"text/javascript\">window.setTimeout(location.href='".$_SERVER['HTTP_REFERER']."', ".(get_option('tsa_back_second')!=null?(((int)get_option('tsa_back_second')) * 1000):0).");</script>", 'throws-spam-away'));
100
  }
101
 
102
  /**
105
  */
106
  function validation($comment) {
107
  global $newThrowsSpamAway;
108
+ global $error_type;
109
  // まずはシングルバイトだけならエラー
110
+ if (get_option('tsa_on_flg') != "2" && strlen(bin2hex($comment)) / 2 == mb_strlen($comment)) {
111
+ return FALSE;
112
  } else {
113
+ // OKフラグ
114
+ $flg = FALSE;
115
  // マルチバイト文字が含まれている場合は日本語が含まれていればOK
116
+ if (get_option('tsa_on_flg') != "2") {
117
+ $count_flg = 0;
118
+ mb_regex_encoding('UTF-8');
119
+ $com_split = $newThrowsSpamAway->mb_str_split($comment);
120
+ foreach ($com_split as $it) {
121
+ if (preg_match('/[一-龠]+/u', $it)){ $count_flg += 1; }
122
+ if (preg_match('/[ァ-ヶー]+/u', $it)){ $count_flg += 1; }
123
+ if (preg_match('/[ぁ-ん]+/u', $it)){ $count_flg += 1; }
124
+ }
125
+ $flg = ((get_option('tsa_japanese_string_min_count')!= null?
126
  intval(get_option('tsa_japanese_string_min_count')):0) < $count_flg);
127
+ if ($flg == FALSE) {
128
+ return FALSE;
129
+ }
130
+ }
131
+ // 日本語文字列チェック抜けたらキーワードチェックを行う
132
+ // キーワード文字列群
133
+ $ng_keywords = get_option('tsa_ng_keywords');
134
+ if ($ng_keywords != null && $ng_keywords != "") {
135
+ $keyword_list = mb_split(",", $ng_keywords);
136
+ foreach ($keyword_list as $key) {
137
+ if (preg_match('/'.trim($key)."/u", $comment)) {
138
+ $error_type = "ng_word";
139
+ return FALSE;
140
+ }
141
+ }
142
+ }
143
+ // キーワードチェック(ブラックリスト)を抜けたら必須キーワードチェックを行う
144
+ // キーワード文字列群 ※ブラックリストと重複するものはブラックリストのほうが優先です。
145
+ $must_keywords = get_option('tsa_must_keywords');
146
+ if ($must_keywords != null && $must_keywords != "") {
147
+ $keyword_list = mb_split(",", $must_keywords);
148
+ foreach ($keyword_list as $key) {
149
+ if (preg_match('/'.trim($key)."/u", $comment)) {
150
+ // OK
151
+ } else {
152
+ // 必須ワードがなかったためエラー
153
+ $error_type = "must_word";
154
+ return FALSE;
155
+ }
156
+ }
157
+ }
158
+
159
+ return TRUE;
160
  }
161
  }
162
+
163
+ function mb_str_split( $string ) {
164
+ return preg_split('/(?<!^)(?!$)/u', $string );
165
+ }
166
+
167
  /**
168
  * Callback admin_menu
169
  */
181
  function options_page() {
182
  global $default_caution_msg;
183
  global $default_error_msg;
184
+ global $default_ng_key_error_msg;
185
+ global $default_must_key_error_msg;
186
+ ?>
187
  <div class="wrap">
188
  <h2>Throws SPAM Away. Setting</h2>
189
+ <form method="post" action="options.php">
190
+ <?php wp_nonce_field('update-options'); ?>
191
+ <table class="form-table">
192
+ <tr valign="top">
193
+ <th scope="row">日本語が存在しない場合、無視対象とする<br />(日本語文字列が存在しない場合無視対象となります。)</th>
194
+ <td><?php
195
+ $chk_1 = "";
196
+ $chk_2 = "";
197
+ if (get_option('tsa_on_flg') == "2") {
198
+ $chk_2 = " checked=\"checked\"";
199
+ } else {
200
+ $chk_1 = " checked=\"checked\"";
201
+ }
202
+ ?>
203
+ <label><input type="radio" name="tsa_on_flg" value="1"<?php echo $chk_1;?>/>&nbsp;する</label>&nbsp;
204
+ <label><input type="radio" name="tsa_on_flg" value="2"<?php echo $chk_2;?>/>&nbsp;しない</label>
205
+ </td>
206
+ </tr>
207
+ <tr valign="top">
208
+ <th scope="row">日本語文字列含有数<br />(この文字列に達していない場合無視対象となります。)</th>
209
+ <td><input type="text" name="tsa_japanese_string_min_count"
210
+ value="<?php echo get_option('tsa_japanese_string_min_count'); ?>" />
211
+ </td>
212
+ </tr>
213
+ <tr valign="top">
214
+ <th scope="row">元の記事に戻ってくる時間<br />(秒)</th>
215
+ <td><input type="text" name="tsa_back_second"
216
+ value="<?php echo get_option('tsa_back_second');?>" /></td>
217
+ </tr>
218
+ <tr valign="top">
219
+ <th scope="row">コメント欄の下に表示される注意文言</th>
220
+ <td><input type="text" name="tsa_caution_message" size="100"
221
+ value="<?php echo get_option('tsa_caution_message');?>" /><br />(初期設定:<?php echo $default_caution_msg;?>)</td>
222
+ </tr>
223
+ <tr valign="top">
224
+ <th scope="row">日本語文字列規定値未満エラー時に表示される文言<br />(元の記事に戻ってくる時間の間のみ表示)</th>
225
+ <td><input type="text" name="tsa_error_message" size="100"
226
+ value="<?php echo get_option('tsa_error_message');?>" /><br />(初期設定:<?php echo $default_error_msg;?>)</td>
227
+ </tr>
228
+ <tr valign="top">
229
+ <th scope="row">その他NGキーワード<br />(日本語でも英語(その他)でもNGとしたいキーワードを半角カンマ区切りで複数設定できます。<br />挙動は同じです。NGキーワードだけでも使用できます。)</th>
230
+ <td><input type="text" name="tsa_ng_keywords" size="100"
231
+ value="<?php echo get_option('tsa_ng_keywords');?>" /></td>
232
+ </tr>
233
+ <tr valign="top">
234
+ <th scope="row">NGキーワードエラー時に表示される文言<br />(元の記事に戻ってくる時間の間のみ表示)</th>
235
+ <td><input type="text" name="tsa_ng_key_error_message" size="100"
236
+ value="<?php echo get_option('tsa_ng_key_error_message');?>" /><br />(初期設定:<?php echo $default_ng_key_error_msg;?>)</td>
237
+ </tr>
238
+ <tr valign="top">
239
+ <th scope="row">その上での必須キーワード<br />(日本語でも英語(その他)でも必須としたいキーワードを半角カンマ区切りで複数設定できます。<br />指定文字列を含まない場合はエラーとなります。※複数の方が厳しくなります。<br />必須キーワードだけでも使用できます。)</th>
240
+ <td><input type="text" name="tsa_must_keywords" size="100"
241
+ value="<?php echo get_option('tsa_must_keywords');?>" /></td>
242
+ </tr>
243
+ <tr valign="top">
244
+ <th scope="row">必須キーワードエラー時に表示される文言<br />(元の記事に戻ってくる時間の間のみ表示)</th>
245
+ <td><input type="text" name="tsa_must_key_error_message" size="100"
246
+ value="<?php echo get_option('tsa_must_key_error_message');?>" /><br />(初期設定:<?php echo $default_must_key_error_msg;?>)</td>
247
+ </tr>
248
+ <tr valign="top">
249
+ <th scope="row">上記設定をトラックバック記事にも採用する</th>
250
+ <td><?php
251
+ $chk_1 = "";
252
+ $chk_2 = "";
253
+ if (get_option('tsa_tb_on_flg', "2") == "2") {
254
+ $chk_2 = " checked=\"checked\"";
255
+ } else {
256
+ $chk_1 = " checked=\"checked\"";
257
+ }
258
+ ?>
259
+ <label><input type="radio" name="tsa_tb_on_flg" value="1"<?php echo $chk_1;?>/>&nbsp;する</label>&nbsp;
260
+ <label><input type="radio" name="tsa_tb_on_flg" value="2"<?php echo $chk_2;?>/>&nbsp;しない</label>
261
+ </td>
262
+ </tr>
263
+ <tr valign="top">
264
+ <th scope="row">トラックバック記事にも採用する場合、ついでにこちらのURLが含まれているか判断する<br />(初期設定:「しない」)</th>
265
+ <td><?php
266
+ $chk_1 = "";
267
+ $chk_2 = "";
268
+ if (get_option('tsa_tb_url_flg', "2") == "2") {
269
+ $chk_2 = " checked=\"checked\"";
270
+ } else {
271
+ $chk_1 = " checked=\"checked\"";
272
+ }
273
+ ?>
274
+ <label><input type="radio" name="tsa_tb_url_flg" value="1"<?php echo $chk_1;?>/>&nbsp;する</label>&nbsp;
275
+ <label><input type="radio" name="tsa_tb_url_flg" value="2"<?php echo $chk_2;?>/>&nbsp;しない</label>
276
+ </td>
277
+ </tr>
278
+ </table>
279
+ <input type="hidden" name="action" value="update" /> <input
280
+ type="hidden" name="page_options"
281
+ value="tsa_on_flg,tsa_japanese_string_min_count,tsa_back_second,tsa_caution_message,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" />
282
+ <p class="submit">
283
+ <input type="submit" class="button-primary"
284
+ value="<?php _e('Save Changes') ?>" />
285
+ </p>
286
+ </form>
287
+ <div class="clear"></div>
288
+ </div>
289
+ <?php
290
  }
 
 
 
 
 
291
 
292
+ function trackback_spam_away($tb) {
293
+ global $newThrowsSpamAway;
294
+
295
+ $tsa_tb_on_flg = get_option('tsa_tb_on_flg');
296
+ $tsa_tb_url_flg = get_option('tsa_tb_url_flg');
297
+ $siteurl = get_option('siteurl');
298
+ // トラックバック OR ピンバック時にフィルタ発動
299
+ if ($tsa_tb_on_flg == "2" || ($tb['comment_type'] != 'trackback' && $tb['comment_type'] != 'pingback')) return $tb;
300
+
301
+ // SPAMかどうかフラグ
302
+ $tb_val['is_spam'] = false;
303
+
304
+ // コメント判定
305
+ $comment = $tb['comment_content'];
306
+
307
+ // 検査します!
308
+ if (!$newThrowsSpamAway->validation($comment)) {
309
+ $tb_val['is_spam'] = true;
310
+ }
311
+ // URL検索する場合、URL包含検査 (このブログのURLを含んでない場合エラー
312
+ if ($tsa_tb_url_flg == "1" && stripos($comment, $siteurl) == false) {
313
+ $tb_val['is_spam'] = true; // スパム扱い
314
+ }
315
+ // トラックバックスパムがなければ返却・あったら捨てちゃう
316
+ if (!$tb_val['is_spam']) {
317
+ // トラックバック内に日本語存在(または禁止語句混入なし)
318
+ return $tb;
319
+ } else {
320
+ die('Your Trackback Throws Away.');
321
+ }
322
+ }
323
+ }
324
  ?>
uninstall.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Throws SPAM Awayプラグインアンインストール
4
+ */
5
+
6
+ if(!defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN')) { exit(); }
7
+
8
+ delete_option('tsa_back_content_second'); // ver.1.6以下の方用
9
+ delete_option('tsa_on_flg');
10
+ delete_option('tsa_japanese_string_min_count');
11
+ delete_option('tsa_back_second');
12
+ delete_option('tsa_caution_message');
13
+ delete_option('tsa_error_message');
14
+ delete_option('tsa_ng_keywords');
15
+ delete_option('tsa_ng_key_error_message');
16
+ delete_option('tsa_must_keywords');
17
+ delete_option('tsa_must_key_error_message');
18
+ delete_option('tsa_tb_on_flg');
19
+ delete_option('tsa_tb_url_flg');
20
+ ?>