From b1324098d8627a34ccc42bd7bc4c8bb05429c760 Mon Sep 17 00:00:00 2001 From: Git Date: Wed, 6 Feb 2013 08:00:17 +0000 Subject: [PATCH] Empty commit --- classes/class_tools.php | 33 ++++++++++-------- gazelle.sql | 4 +-- sections/login/index.php | 5 +-- sections/tools/data/upscale_pool.php | 2 +- sections/tools/data/user_flow.php | 2 +- sections/tools/managers/eb.php | 32 ++++++++--------- sections/tools/managers/permissions_list.php | 13 ++++--- sections/tools/managers/tag_aliases.php | 36 ++++++++++---------- sections/tools/misc/quick_ban.php | 22 ++++++------ static/functions/collage.js | 8 ++--- 10 files changed, 79 insertions(+), 78 deletions(-) diff --git a/classes/class_tools.php b/classes/class_tools.php index 1f33e489..96dacc01 100644 --- a/classes/class_tools.php +++ b/classes/class_tools.php @@ -6,22 +6,25 @@ class Tools { * @param string $IP */ public static function site_ban_ip($IP) { - global $DB, $Cache; - $IPNum = Tools::ip_to_unsigned($IP); - $IPBans = $Cache->get_value('ip_bans'); - if (!is_array($IPBans)) { - $DB->query("SELECT ID, FromIP, ToIP FROM ip_bans"); - $IPBans = $DB->to_array(0, MYSQLI_NUM); - $Cache->cache_value('ip_bans', $IPBans, 0); - } - foreach ($IPBans as $Index => $IPBan) { - list ($ID, $FromIP, $ToIP) = $IPBan; - if ($IPNum >= $FromIP && $IPNum <= $ToIP) { - return true; - } - } + global $DB, $Cache, $Debug; + $A = substr($IP, 0, strcspn($IP, '.')); + $IPNum = Tools::ip_to_unsigned($IP); + $IPBans = $Cache->get_value('ip_bans_'.$A); + if (!is_array($IPBans)) { + $SQL = sprintf("SELECT ID, FromIP, ToIP FROM ip_bans WHERE FromIP BETWEEN %d << 24 AND (%d << 24) - 1", $A, $A+1); + $DB->query($SQL); + $IPBans = $DB->to_array(0, MYSQLI_NUM); + $Cache->cache_value('ip_bans_'.$A, $IPBans, 0); + } + $Debug->log_var($IPBans, 'IP bans for class '.$A); + foreach ($IPBans as $Index => $IPBan) { + list ($ID, $FromIP, $ToIP) = $IPBan; + if ($IPNum >= $FromIP && $IPNum <= $ToIP) { + return true; + } + } - return false; + return false; } /** diff --git a/gazelle.sql b/gazelle.sql index 857c77e4..ec22f359 100644 --- a/gazelle.sql +++ b/gazelle.sql @@ -420,7 +420,6 @@ CREATE TABLE `ip_bans` ( `Reason` varchar(255) DEFAULT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `FromIP_2` (`FromIP`,`ToIP`), - KEY `FromIP` (`FromIP`,`ToIP`), KEY `ToIP` (`ToIP`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; @@ -1575,7 +1574,8 @@ CREATE TABLE `wiki_revisions` ( `Title` varchar(100) DEFAULT NULL, `Body` mediumtext, `Date` datetime DEFAULT NULL, - `Author` int(10) DEFAULT NULL + `Author` int(10) DEFAULT NULL, + KEY `ID_Revision` (`ID`,`Revision`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `wiki_torrents` ( diff --git a/sections/login/index.php b/sections/login/index.php index b635e41d..17883893 100644 --- a/sections/login/index.php +++ b/sections/login/index.php @@ -172,7 +172,7 @@ // Function to log a user's login attempt function log_attempt($UserID) { - global $DB, $AttemptID, $Attempts, $Bans, $BannedUntil, $Time; + global $DB, $Cache, $AttemptID, $Attempts, $Bans, $BannedUntil, $Time; if($AttemptID) { // User has attempted to log in recently $Attempts++; if ($Attempts>5) { // Only 6 allowed login attempts, ban user's IP @@ -200,7 +200,8 @@ function log_attempt($UserID) { $DB->query("INSERT INTO ip_bans (FromIP, ToIP, Reason) VALUES ('$IP','$IP', 'Automated ban per >60 failed login attempts')"); - $Cache->delete_value('ip_bans'); + $A = substr($_SERVER['REMOTE_ADDR'], 0, strcspn($_SERVER['REMOTE_ADDR'], '.')); + $Cache->delete_value('ip_bans_'.$A); } } } else { diff --git a/sections/tools/data/upscale_pool.php b/sections/tools/data/upscale_pool.php index 49141024..3e301462 100644 --- a/sections/tools/data/upscale_pool.php +++ b/sections/tools/data/upscale_pool.php @@ -47,7 +47,7 @@ Down Ratio Required Ratio - Defecit + Deficit Gamble Registered Remaining diff --git a/sections/tools/data/user_flow.php b/sections/tools/data/user_flow.php index d4837407..50052f42 100644 --- a/sections/tools/data/user_flow.php +++ b/sections/tools/data/user_flow.php @@ -104,7 +104,7 @@
- + User Flow vs. Time