봇의 메일 링크 크롤링 방지

This commit is contained in:
thisgun
2018-11-26 15:11:19 +09:00
parent 8399dafd4b
commit 918663a7e2
3 changed files with 27 additions and 0 deletions

View File

@ -3434,6 +3434,27 @@ function get_real_client_ip(){
return preg_replace('/[^0-9.]/', '', $real_ip);
}
function check_mail_bot($ip=''){
//아이피를 체크하여 메일 크롤링을 방지합니다.
$check_ips = array('211.249.40.');
$bot_message = 'bot 으로 판단되어 중지합니다.';
if($ip){
foreach( $check_ips as $c_ip ){
if( preg_match('/^'.preg_quote($c_ip).'/', $ip) ) {
die($bot_message);
}
}
}
// user agent를 체크하여 메일 크롤링을 방지합니다.
$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
if ($user_agent === 'Carbon' || strpos($user_agent, 'BingPreview') !== false || strpos($user_agent, 'Slackbot') !== false) {
die($bot_message);
}
}
function get_call_func_cache($func, $args=array()){
static $cache = array();