Created
February 27, 2014 06:59
-
-
Save CzBiX/9245629 to your computer and use it in GitHub Desktop.
Filter spam comment in Typecho,
file path: /var/Widget/Feedback.php, line 82
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!$this->user->hasLogin()) { | |
/** 过滤纯英文评论 */ | |
$pattern = '/[\x{4E00}-\x{9FA5}]/u'; | |
if (!preg_match($pattern, $comment['text'], $match)) { | |
throw new Typecho_Widget_Exception(_t('You should type some Chinese word (like "你好") in your comment to pass the spam-check, thanks for your patience!<br />您的评论中必须包含汉字!<p><a style="color:#FFF; border: 1px solid;text-decoration:none;padding:0px 2px" href="javascript:void(history.back())">点此返回</a></p>')); | |
} | |
/** 过滤包含日文的评论 */ | |
$pattern = '/[\x{3040}-\x{31FF}]/u'; | |
if (preg_match($pattern, $comment['text'], $match)) { | |
throw new Typecho_Widget_Exception(_t('You can not contains Japenese word in your comment to pass the spam-check, thanks for your patience!<br />您的评论中不能包含日文!<p><a style="color:#FFF; border: 1px solid;text-decoration:none;padding:0px 2px" href="javascript:void(history.back())">点此返回</a></p>')); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment