/**
     * @param mixed $ip_address
     * @param int|null $unixday
     */
    public static function logBlockedIP($ip_address, $unixday = null)
    {
        /** @var wpdb $wpdb */
        global $wpdb;
        if (wfUtils::isValidIP($ip_address)) {
            $ip_bin = wfUtils::inet_pton($ip_address);
        } else {
            $ip_bin = $ip_address;
            $ip_address = wfUtils::inet_ntop($ip_bin);
        }
        $blocked_table = "{$wpdb->base_prefix}wfBlockedIPLog";
        $unixday_insert = 'FLOOR(UNIX_TIMESTAMP() / 86400)';
        if (is_int($unixday)) {
            $unixday_insert = absint($unixday);
        }
        $country = wfUtils::IP2Country($ip_address);
        $wpdb->query($wpdb->prepare(<<<SQL
INSERT INTO {$blocked_table} (IP, countryCode, blockCount, unixday)
VALUES (%s, %s, 1, {$unixday_insert})
ON DUPLICATE KEY UPDATE blockCount = blockCount + 1
SQL
, $ip_bin, $country));
    }
Exemple #2
0
 public static function pushCommentSpamIP($m)
 {
     if (wfUtils::isValidIP($m[1]) && strpos($m[1], '127.0.0') !== 0) {
         self::$commentSpamItems[] = trim($m[1]);
     }
 }