コード例 #1
0
ファイル: give_process.php プロジェクト: Galaxy421/WOWMeter
function IsTorExitPoint()
{
    if (gethostbyname(ReverseIPOctets($_SERVER['REMOTE_ADDR']) . "." . $_SERVER['SERVER_PORT'] . "." . ReverseIPOctets($_SERVER['SERVER_ADDR']) . ".ip-port.exitlist.torproject.org") == "127.0.0.2") {
        return true;
    } else {
        return false;
    }
}
コード例 #2
0
ファイル: functions.php プロジェクト: Cipherwraith/infinity
function checkDNSBL($use_ip = false)
{
    global $config;
    if (!$use_ip && !isset($_SERVER['REMOTE_ADDR'])) {
        return;
    }
    // Fix your web server configuration
    $ip = $use_ip ? $use_ip : $_SERVER['REMOTE_ADDR'];
    if ($ip == '127.0.0.2') {
        return true;
    }
    if (isIPv6($ip)) {
        return;
    }
    // No IPv6 support yet.
    if (in_array($ip, $config['dnsbl_exceptions'])) {
        return;
    }
    $ipaddr = ReverseIPOctets($ip);
    foreach ($config['dnsbl'] as $blacklist) {
        if (!is_array($blacklist)) {
            $blacklist = array($blacklist);
        }
        if (($lookup = str_replace('%', $ipaddr, $blacklist[0])) == $blacklist[0]) {
            $lookup = $ipaddr . '.' . $blacklist[0];
        }
        if (!($ip = DNS($lookup))) {
            continue;
        }
        // not in list
        $blacklist_name = isset($blacklist[2]) ? $blacklist[2] : $blacklist[0];
        if (!isset($blacklist[1])) {
            // If you're listed at all, you're blocked.
            if ($use_ip) {
                return true;
            } else {
                error(sprintf($config['error']['dnsbl'], $blacklist_name));
            }
        } elseif (is_array($blacklist[1])) {
            foreach ($blacklist[1] as $octet) {
                if ($ip == $octet || $ip == '127.0.0.' . $octet) {
                    return true;
                }
            }
        } elseif (is_callable($blacklist[1])) {
            if ($blacklist[1]($ip)) {
                return true;
            }
        } else {
            if ($ip == $blacklist[1] || $ip == '127.0.0.' . $blacklist[1]) {
                return true;
            }
        }
    }
}
コード例 #3
0
ファイル: functions.php プロジェクト: nabm/Tinyboard
function checkDNSBL()
{
    global $config;
    if (isIPv6()) {
        return;
    }
    // No IPv6 support yet.
    if (!isset($_SERVER['REMOTE_ADDR'])) {
        return;
    }
    // Fix your web server configuration
    if (in_array($_SERVER['REMOTE_ADDR'], $config['dnsbl_exceptions'])) {
        return;
    }
    $ip = ReverseIPOctets($_SERVER['REMOTE_ADDR']);
    foreach ($config['dnsbl'] as &$blacklist) {
        $lookup = $ip . '.' . $blacklist;
        $host = gethostbyname($lookup);
        if ($host != $lookup) {
            // On NXDOMAIN (meaning it's not in the blacklist), gethostbyname() returns the host unchanged.
            if (preg_match('/^127\\.0\\.0\\./', $host) && $host != '127.0.0.10') {
                error(sprintf($config['error']['dnsbl'], $blacklist));
            }
        }
    }
}