forked from GithubBackups/vichan
functions.php: remove checkDNSBL and DNS functions
This commit is contained in:
parent
4c29e84527
commit
08a5e0d3bf
@ -1767,61 +1767,6 @@ function buildJavascript() {
|
||||
file_write($config['file_script'], $script);
|
||||
}
|
||||
|
||||
function checkDNSBL() {
|
||||
global $config;
|
||||
|
||||
if (isIPv6())
|
||||
return; // No IPv6 support yet.
|
||||
|
||||
if (!isset($_SERVER['REMOTE_ADDR']))
|
||||
return; // Fix your web server configuration
|
||||
|
||||
if (preg_match("/^(::(ffff:)?)?(127\.|192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.|0\.|255\.)/", $_SERVER['REMOTE_ADDR']))
|
||||
return; // It's pointless to check for local IP addresses in dnsbls, isn't it?
|
||||
|
||||
if (in_array($_SERVER['REMOTE_ADDR'], $config['dnsbl_exceptions']))
|
||||
return;
|
||||
|
||||
$ipaddr = ReverseIPOctets($_SERVER['REMOTE_ADDR']);
|
||||
|
||||
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.
|
||||
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)
|
||||
error(sprintf($config['error']['dnsbl'], $blacklist_name));
|
||||
}
|
||||
} elseif (is_callable($blacklist[1])) {
|
||||
if ($blacklist[1]($ip))
|
||||
error(sprintf($config['error']['dnsbl'], $blacklist_name));
|
||||
} else {
|
||||
if ($ip == $blacklist[1] || $ip == '127.0.0.' . $blacklist[1])
|
||||
error(sprintf($config['error']['dnsbl'], $blacklist_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isIPv6() {
|
||||
return strstr($_SERVER['REMOTE_ADDR'], ':') !== false;
|
||||
}
|
||||
|
||||
function ReverseIPOctets($ip) {
|
||||
return implode('.', array_reverse(explode('.', $ip)));
|
||||
}
|
||||
|
||||
function wordfilters(&$body) {
|
||||
global $config;
|
||||
|
||||
@ -2512,60 +2457,6 @@ function undoImage(array $post) {
|
||||
}
|
||||
}
|
||||
|
||||
function rDNS($ip_addr) {
|
||||
global $config;
|
||||
|
||||
if ($config['cache']['enabled'] && ($host = cache::get('rdns_' . $ip_addr))) {
|
||||
return $host;
|
||||
}
|
||||
|
||||
if (!$config['dns_system']) {
|
||||
$host = gethostbyaddr($ip_addr);
|
||||
} else {
|
||||
$resp = shell_exec_error('host -W 3 ' . $ip_addr);
|
||||
if (preg_match('/domain name pointer ([^\s]+)$/', $resp, $m))
|
||||
$host = $m[1];
|
||||
else
|
||||
$host = $ip_addr;
|
||||
}
|
||||
|
||||
$isip = filter_var($host, FILTER_VALIDATE_IP);
|
||||
|
||||
if ($config['fcrdns'] && !$isip && DNS($host) != $ip_addr) {
|
||||
$host = $ip_addr;
|
||||
}
|
||||
|
||||
if ($config['cache']['enabled'])
|
||||
cache::set('rdns_' . $ip_addr, $host);
|
||||
|
||||
return $host;
|
||||
}
|
||||
|
||||
function DNS($host) {
|
||||
global $config;
|
||||
|
||||
if ($config['cache']['enabled'] && ($ip_addr = cache::get('dns_' . $host))) {
|
||||
return $ip_addr != '?' ? $ip_addr : false;
|
||||
}
|
||||
|
||||
if (!$config['dns_system']) {
|
||||
$ip_addr = gethostbyname($host);
|
||||
if ($ip_addr == $host)
|
||||
$ip_addr = false;
|
||||
} else {
|
||||
$resp = shell_exec_error('host -W 1 ' . $host);
|
||||
if (preg_match('/has address ([^\s]+)$/', $resp, $m))
|
||||
$ip_addr = $m[1];
|
||||
else
|
||||
$ip_addr = false;
|
||||
}
|
||||
|
||||
if ($config['cache']['enabled'])
|
||||
cache::set('dns_' . $host, $ip_addr !== false ? $ip_addr : '?');
|
||||
|
||||
return $ip_addr;
|
||||
}
|
||||
|
||||
function shell_exec_error($command, $suppress_stdout = false) {
|
||||
global $config, $debug;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user