diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2007-10-18 17:44:02 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2007-10-18 17:44:02 +0000 |
commit | 6e530cb85128e5121606493dcad0962d7c5c1499 (patch) | |
tree | 3c3c06d8d9f1ca98e55491a2c9d3e87b0a2b3b25 /phpBB/includes/session.php | |
parent | 7b1a8511ce1ae8e240720afe253618fb0866cac2 (diff) | |
download | forums-6e530cb85128e5121606493dcad0962d7c5c1499.tar forums-6e530cb85128e5121606493dcad0962d7c5c1499.tar.gz forums-6e530cb85128e5121606493dcad0962d7c5c1499.tar.bz2 forums-6e530cb85128e5121606493dcad0962d7c5c1499.tar.xz forums-6e530cb85128e5121606493dcad0962d7c5c1499.zip |
make the ban check perform a bit better :/
git-svn-id: file:///svn/phpbb/trunk@8202 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/session.php')
-rw-r--r-- | phpBB/includes/session.php | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 6ddc97fff8..7ca2cbcdd0 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -905,48 +905,59 @@ class session } $banned = false; + $cache_ttl = 3600; + $where_sql = array(); $sql = 'SELECT ban_ip, ban_userid, ban_email, ban_exclude, ban_give_reason, ban_end FROM ' . BANLIST_TABLE . ' - WHERE (ban_end >= ' . time() . ' OR ban_end = 0)'; + WHERE '; // Determine which entries to check, only return those if ($user_email === false) { - $sql .= " AND ban_email = ''"; + $where_sql[] = "ban_email = ''"; } if ($user_ips === false) { - $sql .= " AND (ban_ip = '' OR ban_exclude = 1)"; + $where_sql[] = "(ban_ip = '' OR ban_exclude = 1)"; } if ($user_id === false) { - $sql .= ' AND (ban_userid = 0 OR ban_exclude = 1)'; + $where_sql[] = '(ban_userid = 0 OR ban_exclude = 1)'; } else { - $sql .= ' AND (ban_userid = ' . $user_id; + $cache_ttl = ($user_id == ANONYMOUS) ? 3600 : 0; + $_sql = '(ban_userid = ' . $user_id; if ($user_email !== false) { - $sql .= " OR ban_email <> ''"; + $_sql .= " OR ban_email <> ''"; } if ($user_ips !== false) { - $sql .= " OR ban_ip <> ''"; + $_sql .= " OR ban_ip <> ''"; } - $sql .= ')'; + $_sql .= ')'; + + $where_sql[] = $_sql; } - $result = $db->sql_query($sql); + $sql .= (sizeof($where_sql)) ? implode(' AND ', $where_sql) : ''; + $result = $db->sql_query($sql, $cache_ttl); $ban_triggered_by = 'user'; while ($row = $db->sql_fetchrow($result)) { + if ($row['ban_end'] && $row['ban_end'] < time()) + { + continue; + } + $ip_banned = false; if (!empty($row['ban_ip'])) { |