Home >Backend Development >PHP Tutorial >屏蔽机器人从你的网站搜取email地址的php代码_php技巧

屏蔽机器人从你的网站搜取email地址的php代码_php技巧

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-17 09:08:02813browse

垃圾邮件很烦人,下面贴一种能够自动屏蔽机器人从你的网站搜集email地址的方法。

复制代码 代码如下:

function security_remove_emails($content) {
$pattern = '/([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})/i';
$fix = preg_replace_callback($pattern,
"security_remove_emails_logic", $content);

return $fix;
}
function security_remove_emails_logic($result) {
return antispambot($result[1]);
}
add_filter( 'the_content', 'flex_remove_emails', 20 );
add_filter( 'widget_text', 'flex_remove_emails', 20 );

把这个放到functions.php文件中,如果机器人来搜集email地址,就会自动屏蔽了。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn