mirror of
https://github.com/WhatCD/Gazelle.git
synced 2025-01-31 02:21:36 +00:00
Faster geoip in most cases
This commit is contained in:
parent
3b0f7f967a
commit
bb9600894d
@ -424,12 +424,14 @@ function geoip($IP) {
|
||||
return $IPs[$IP];
|
||||
}
|
||||
$Long = ip2unsigned($IP);
|
||||
if($Long == 2130706433 || !$Long) {
|
||||
if(!$Long || $Long == 2130706433) { // No need to check cc for 127.0.0.1
|
||||
return false;
|
||||
}
|
||||
global $DB;
|
||||
$DB->query("SELECT Code FROM geoip_country WHERE $Long BETWEEN StartIP AND EndIP LIMIT 1");
|
||||
list($Country) = $DB->next_record();
|
||||
$DB->query("SELECT EndIP,Code FROM geoip_country WHERE $Long >= StartIP ORDER BY StartIP DESC LIMIT 1");
|
||||
if((!list($EndIP,$Country) = $DB->next_record()) || $EndIP < $Long) {
|
||||
$Country = '?';
|
||||
}
|
||||
$IPs[$IP] = $Country;
|
||||
return $Country;
|
||||
}
|
||||
|
@ -339,7 +339,8 @@ CREATE TABLE `ip_bans` (
|
||||
`Reason` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`ID`),
|
||||
UNIQUE KEY `FromIP_2` (`FromIP`,`ToIP`),
|
||||
KEY `FromIP` (`FromIP`,`ToIP`)
|
||||
KEY `FromIP` (`FromIP`,`ToIP`),
|
||||
KEY `ToIP` (`ToIP`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE `log` (
|
||||
|
Loading…
Reference in New Issue
Block a user