From 250296e23774ddd1da7afc92f3eaa094bfafaea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?= Date: Wed, 18 Jun 2008 00:33:19 +0200 Subject: [PATCH] db_filter_ui: Restrict number of active filters --- include/db_filter_ui.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/db_filter_ui.php b/include/db_filter_ui.php index 61a6d93..a2644ce 100644 --- a/include/db_filter_ui.php +++ b/include/db_filter_ui.php @@ -15,6 +15,8 @@ define('FILTER_VALUES_ENUM', 2); define('FILTER_VALUES_BOOL', 3); define('FILTER_VALUES_OPTION', 4); +define('MAX_FILTERS', 50); + /* Info describing an available filter: what column it applies to, and what comparison options are available */ class FilterInfo @@ -436,10 +438,18 @@ class FilterInterface The given TableFilterSet defines available options */ public function readInput($aClean) { + $iCount = 0; // We set a maximum for how many filters a user can add, + // otherwise we may get a too long SQL query + foreach($this->getFilterInfo() as $oOption) { foreach($this->readInputForColumn($aClean, $oOption) as $oNewFilter) + { + $iCount ++; $this->AddFilterObject($oNewFilter); + if($iCount > MAX_FILTERS) + break; + } } }