mirror of
https://gh.wpcy.net/https://github.com/webguyio/dam-spam.git
synced 2026-05-26 03:13:58 +08:00
39 lines
No EOL
981 B
PHP
39 lines
No EOL
981 B
PHP
<?php
|
|
|
|
if ( !defined( 'ABSPATH' ) ) {
|
|
status_header( 404 );
|
|
exit;
|
|
}
|
|
|
|
class dam_spam_check_vpn extends dam_spam_module {
|
|
public function process( $ip, &$stats = array(), &$options = array(), &$post = array() ) {
|
|
$contact_email = defined( 'DAM_SPAM_MAIL' ) ? DAM_SPAM_MAIL : get_option( 'admin_email' );
|
|
$ban_threshold = 0.99;
|
|
$url = add_query_arg(
|
|
array(
|
|
'ip' => $ip,
|
|
'contact' => $contact_email,
|
|
'flags' => 'b',
|
|
),
|
|
'https://check.getipintel.net/check.php'
|
|
);
|
|
$response = $this->getafile( $url, 'GET' );
|
|
if ( empty( $response ) ) {
|
|
return false;
|
|
}
|
|
if ( strpos( $response, 'ERR:' ) !== false ) {
|
|
return false;
|
|
}
|
|
$score = floatval( trim( $response ) );
|
|
if ( $score < 0 ) {
|
|
return false;
|
|
}
|
|
if ( $score >= $ban_threshold ) {
|
|
// translators: %s is the GetIPIntel reputation score
|
|
return sprintf( esc_html__( 'VPN/Bad IP Detected (score: %s)', 'dam-spam' ), number_format( $score, 2 ) );
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
?>
|