*/
function ip_to_uint($ip)
{
- return ip2long($ip);
+ $part = explode('.', $ip);
+ if (count($part) != 4) {
+ return null;
+ }
+ $v = 0;
+ $fact = 0x1000000;
+ for ($i = 0 ; $i < 4 ; ++$i) {
+ $v += $fact * $part[$i];
+ $fact >>= 8;
+ }
+ return $v;
}
/** Convert uint to ip (to build a human understandable ip)
}
$ips[] = $_SERVER['REMOTE_ADDR'];
foreach ($ips as &$ip) {
- $ip = "ip = " . ip_to_uint($ip);
+ $ip = '(ip & mask) = (' . ip_to_uint($ip) . '& mask)';
}
- $res = XDB::query('SELECT state
+ $res = XDB::query('SELECT state, description
FROM ip_watch
WHERE ' . implode(' OR ', $ips) . '
ORDER BY state DESC');
if ($res->numRows()) {
- $_SESSION['check_ip'] = $res->fetchOneCell();
+ $state = $res->fetchOneAssoc();
+ $_SESSION['check_ip'] = $state['state'];
+ $_SESSION['check_ip_desc'] = $state['description'];
} else {
$_SESSION['check_ip'] = 'safe';
}
if (is_null($red)) {
$red = new Redirect(S::v('uid'));
}
- $_SESSION['no_redirect'] = !$red->other_active('');
- $_SESSION['mx_failures'] = $red->get_broken_mx();
+ if ($red->get_uid() == S::v('uid')) {
+ $_SESSION['no_redirect'] = !$red->other_active('');
+ $_SESSION['mx_failures'] = $red->get_broken_mx();
+ }
}
function send_warning_mail($title)