X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffilters.php;h=db886a0d651df3c432abe16812a198e50baef5c9;hb=60c6d7a179157acd6e5f6df2ed8968980aebe193;hp=433f4958099751fac2a590f2c0131458aee57208;hpb=e1d636846bafc8ae71855595a2a2843463025e26;p=mailer.git diff --git a/inc/filters.php b/inc/filters.php index 433f495809..db886a0d65 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -47,8 +47,7 @@ function initFilterSystem () { // Is the filter already initialized? if ((isset($GLOBALS['filters']['chains'])) && (is_array($GLOBALS['filters']['chains']))) { // Then abort here - addFatalMessage(__FUNCTION__, __LINE__, getMessage('FILTER_FAILED_ALREADY_INIT')); - return false; + debug_report_bug(getMessage('FILTER_FAILED_ALREADY_INIT')); } // END - if // Init the filter system (just some ideas) @@ -63,7 +62,26 @@ function initFilterSystem () { $GLOBALS['filters']['counter'] = array(); // Load all saved filers if sql_patches is updated - if (GET_EXT_VERSION('sql_patches') >= '0.5.9') { + if (isset($GLOBALS['cache_array']['filter']['filter_name'])) { + // Found in cache so rewrite the array + $filterArray = array(); + foreach ($GLOBALS['cache_array']['filter']['filter_name'] as $idx => $filterName) { + // Get filter function + $filterFunction = $GLOBALS['cache_array']['filter']['filter_function'][$idx]; + + // Add the element with mapped index + $filterArray['counter'][$filterName][$filterFunction] = $GLOBALS['cache_array']['filter']['filter_counter'][$idx]; + $filterArray['loaded'][$filterName][$filterFunction] = true; + $filterArray['chains'][$filterName][$filterFunction] = $GLOBALS['cache_array']['filter']['filter_active'][$idx]; + } // END - foreach + + // Set the array + //die('
'.print_r($filterArray, true).''); + $GLOBALS['filters'] = $filterArray; + + // Remove the cache + unset($GLOBALS['cache_array']['filter']); + } elseif (GET_EXT_VERSION('sql_patches') >= '0.5.9') { // Init add $add = ''; if (GET_EXT_VERSION('sql_patches') >= '0.6.0') $add = ", `filter_counter`"; @@ -100,11 +118,12 @@ ORDER BY `filter_id` ASC", __FUNCTION__, __LINE__); // Free result SQL_FREERESULT($result); - } // END - if + } // Init filters registerFilter('init', 'UPDATE_LOGIN_DATA'); registerFilter('init', 'INIT_RANDOMIZER'); + registerFilter('init', 'DETERMINE_USERNAME'); // Login failures handler registerFilter('post_youhere_line', 'CALL_HANDLER_LOGIN_FAILTURES'); @@ -142,7 +161,7 @@ function registerFilter ($filterName, $filterFunction, $silentAbort = true, $for // Is that filter already there? if ((isset($GLOBALS['filters']['chains'][$filterName][$filterFunction])) && (!$force)) { // Then abort here - if (!$silentAbort) { + if ($silentAbort === false) { addFatalMessage(__FUNCTION__, __LINE__, getMessage('FILTER_FAILED_ALREADY_ADDED'), array($filterFunction, $filterName)); } // END - if @@ -187,11 +206,14 @@ function unregisterFilter ($filterName, $filterFunction, $force = false, $dry_ru } // "Runs" the given filters, data is optional and can be any type of data -function runFilterChain ($filterName, $data = null, $silentAbort = true) { +function runFilterChain ($filterName, $data = null) { // Is that filter chain there? if (!isset($GLOBALS['filters']['chains'][$filterName])) { // We should find all these non-existing filter chains - debug_report_bug('Filter chain '.$filterName.' not found!'); + DEBUG_LOG(__FUNCTION__, __LINE__, 'Filter chain ' . $filterName . ' not found!'); + + // Abort here + return false; } // END - if // Default return value @@ -285,7 +307,7 @@ function FILTER_FLUSH_FILTERS () { // Add this filter (all filters are active by default) $insertSQL .= sprintf("('%s','%s','Y'),", $filterName, $filterFunction); $inserted++; - } elseif ($active == "R") { + } elseif ($active == 'R') { // Remove this filter $removeSQL .= sprintf(" (`filter_name`='%s' AND `filter_function`='%s') OR", $filterName, $filterFunction); $removed++; @@ -305,7 +327,7 @@ function FILTER_FLUSH_FILTERS () { // Something has been removed? if ($removed > 0) { // Finish SQL command - $removeSQL = substr($removeSQL, 0, -2) . "LIMIT ".$removed; + $removeSQL = substr($removeSQL, 0, -2) . 'LIMIT '.$removed; // And run it ADD_SQL($removeSQL); @@ -319,9 +341,9 @@ function FILTER_FLUSH_FILTERS () { foreach ($filterArray as $filterFunction => $cnt) { // Construct and add the query ADD_SQL(sprintf("UPDATE `{!_MYSQL_PREFIX!}_filters` SET `filter_counter`=%s WHERE `filter_name`='%s' AND `filter_function`='%s' LIMIT 1", - bigintval($cnt), - $filterName, - $filterFunction + bigintval($cnt), + $filterName, + $filterFunction )); } // END - foreach } // END - foreach @@ -337,7 +359,7 @@ function FILTER_CALL_HANDLER_LOGIN_FAILTURES ($data) { $content = $data; // Handle failed logins here if not in guest - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):type={$data['type']},action={getAction()},what={getWhat()},lvl={$data['access_level']}