From ba59d6cfbe27195f59bbe2b7cab3d01bf9ceb566 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 31 Jul 2013 01:58:02 +0000 Subject: [PATCH] Introduced interruptFilterChain() and continueFilterChain(). Please DO ALWAYS use thse functions instead of directly setting the global array element --- inc/filter-functions.php | 18 +++++++++++++++--- inc/filter/blacklist_filter.php | 2 +- inc/filter/forced_filter.php | 4 ++-- inc/filter/order_filter.php | 12 ++++++------ inc/filter/register_filter.php | 12 ++++++++++++ inc/filter/surfbar_filter.php | 4 ++-- inc/filter/wernis_filter.php | 12 ++++++++++++ 7 files changed, 50 insertions(+), 14 deletions(-) diff --git a/inc/filter-functions.php b/inc/filter-functions.php index 4e19d0980a..dc97d8ec41 100644 --- a/inc/filter-functions.php +++ b/inc/filter-functions.php @@ -311,8 +311,8 @@ function runFilterChain ($filterName, $filterData = NULL) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'filterName=' . $filterName . ',count()=' . count($GLOBALS['cache_array']['filter']['chains'][$filterName])); $returnValue = $filterData; - // Remove any existing flag(s) - unset($GLOBALS['filter_chain_aborted']); + // Continue filter chain is default + continueFilterChain(); // Then run all filters foreach ($GLOBALS['cache_array']['filter']['chains'][$filterName] as $filterFunction => $active) { @@ -431,7 +431,19 @@ function loadExtensionFilters ($ext_name) { // Checks whether the filter chain has been aborted function isFilterChainAborted () { // Determine it - return ((isset($GLOBALS['filter_chain_aborted'])) && ($GLOBALS['filter_chain_aborted'] === TRUE)); + return ((isset($GLOBALS['filter_chain_interrupted'])) && ($GLOBALS['filter_chain_interrupted'] === TRUE)); +} + +// Interrupts the filter chain by enabling flag 'filter_chain_aborted' +function interruptFilterChain () { + // Set it + $GLOBALS['filter_chain_interrupted'] = TRUE; +} + +// Continues the filter chain by disabling flag 'filter_chain_aborted' +function continueFilterChain () { + // Set it + $GLOBALS['filter_chain_interrupted'] = FALSE; } // [EOF] diff --git a/inc/filter/blacklist_filter.php b/inc/filter/blacklist_filter.php index edba5885bf..26a846a66c 100644 --- a/inc/filter/blacklist_filter.php +++ b/inc/filter/blacklist_filter.php @@ -81,7 +81,7 @@ function FILTER_CHECK_URL_BLACKLISTED ($filterData) { if ((isUrlBlacklistEnabled()) && (isUrlBlacklisted($filterData['url']))) { // Create redirect-URL $filterData['redirect'] = 'modules.php?module=login&what=order&code=' . getCode('BLIST_URL') . '&blist=' . $GLOBALS['blacklist_data'][$filterData['url']]['timestamp']; - $GLOBALS['filter_chain_aborted'] = TRUE; + interruptFilterChain(); // Set data for next filter chain $filterData['init_done'] = FALSE; diff --git a/inc/filter/forced_filter.php b/inc/filter/forced_filter.php index b731596c3e..cca6b078e1 100644 --- a/inc/filter/forced_filter.php +++ b/inc/filter/forced_filter.php @@ -110,11 +110,11 @@ function FILTER_FORCED_CHANGE_CAMPAIGN_VALIDATE_DATA ($filterData) { if ((!is_string($filterData['new_status'])) || (empty($filterData['new_status']))) { // Abort here, not fine //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newStatus[' . gettype($filterData['new_status']) . ']=' . $filterData['new_status'] . ' - EXIT!'); - $GLOBALS['filter_chain_aborted'] = FALSE; + interruptFilterChain(); } elseif ($filterData['data']['forced_campaign_status'] != $filterData['prev_status']) { // Status is not like prevStatus //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $filterData['data']['forced_campaign_status'] . '!=' . $filterData['prev_status'] . ' - EXIT!'); - $GLOBALS['filter_chain_aborted'] = FALSE; + continueFilterChain(); } // END - if // Return filter data diff --git a/inc/filter/order_filter.php b/inc/filter/order_filter.php index a961dde09b..7b32e11122 100644 --- a/inc/filter/order_filter.php +++ b/inc/filter/order_filter.php @@ -136,7 +136,7 @@ function FILTER_MAIL_ORDER_GENERIC_CHECK_SUBJECT ($filterData) { if ((isInStringIgnoreCase('https://', $filterData['subject'])) || (isInStringIgnoreCase('http://', $filterData['subject'])) || (isInStringIgnoreCase('www', $filterData['subject']))) { // URL in subject found $filterData['redirect'] = 'modules.php?module=login&what=order&code=' . getCode('SUBJECT_URL'); - $GLOBALS['filter_chain_aborted'] = TRUE; + interruptFilterChain(); } // END - if } // END - if @@ -154,7 +154,7 @@ function FILTER_MAIL_ORDER_GENERIC_CHECK_TEXT ($filterData) { if ((isInStringIgnoreCase('https://', $filterData['text'])) || (isInStringIgnoreCase('http://', $filterData['text'])) || (isInStringIgnoreCase('www', $filterData['text']))) { // URL found $filterData['redirect'] = 'modules.php?module=login&what=order&code=' . getCode('URL_FOUND'); - $GLOBALS['filter_chain_aborted'] = TRUE; + interruptFilterChain(); } // END - if // Remove new-line and carriage-return characters @@ -164,7 +164,7 @@ function FILTER_MAIL_ORDER_GENERIC_CHECK_TEXT ($filterData) { if (strlen($TEST) > getMaxTextLength()) { // Text is too long! $filterData['redirect'] = 'modules.php?module=login&what=order&code=' . getCode('OVERLENGTH'); - $GLOBALS['filter_chain_aborted'] = TRUE; + interruptFilterChain(); } // END - if } // END - if @@ -181,7 +181,7 @@ function FILTER_MAIL_ORDER_GENERIC_CHECK_TYPE ($filterData) { if ((!isset($filterData['mail_type'])) || ($filterData['mail_type'] < 1)) { // Not correctly set $filterData['redirect'] = 'modules.php?module=login&what=order&code=' . getCode('NO_MAIL_TYPE'); - $GLOBALS['filter_chain_aborted'] = TRUE; + interruptFilterChain(); } // END - if // Return the data for next filter @@ -197,7 +197,7 @@ function FILTER_MAIL_ORDER_GENERIC_CHECK_URL ($filterData) { if (!isUrlValid($filterData['url'])) { // URL is invalid! $filterData['redirect'] = 'modules.php?module=login&what=order&code=' . getCode('INVALID_URL'); - $GLOBALS['filter_chain_aborted'] = TRUE; + interruptFilterChain(); } // END - if // Return the data for next filter @@ -213,7 +213,7 @@ function FILTER_MAIL_ORDER_GENERIC_CHECK_RECEIVER ($filterData) { if (($filterData['receiver'] < getOrderMin()) && (!isAdmin())) { // Less than allowed receivers entered! $filterData['redirect'] = 'modules.php?module=login&what=order&code=' . getCode('MORE_RECEIVERS3'); - $GLOBALS['filter_chain_aborted'] = TRUE; + interruptFilterChain(); } // END - if // Return the data for next filter diff --git a/inc/filter/register_filter.php b/inc/filter/register_filter.php index a96e34080b..b160adff37 100644 --- a/inc/filter/register_filter.php +++ b/inc/filter/register_filter.php @@ -126,6 +126,9 @@ function FILTER_GENERIC_USER_REGISTRATION ($filterData) { if ((isPostRequestElementSet('registration_provider')) && (postRequestElement('registration_provider') == 'register')) { // Run it $filterData['status'] = doGenericUserRegistration(); + + // Interrupt filter chain + interruptFilterChain(); } // END - if // Return it @@ -143,6 +146,9 @@ function FILTER_GENERIC_USER_REGISTRATION_CHECK () { if ((isFormSent()) && (isPostRequestElementSet('registration_provider')) && (postRequestElement('registration_provider') == 'register')) { // Check form $isFormSent = isRegistrationDataComplete(); + + // Interrupt filter chain + interruptFilterChain(); } // END - if // Return it @@ -158,6 +164,9 @@ function FILTER_GENERIC_USER_REGISTRATION_DONE () { if ((isPostRequestElementSet('registration_provider')) && (postRequestElement('registration_provider') == 'register')) { // Run it displayMessage('{--REGISTRATION_DONE--}'); + + // Interrupt filter chain + interruptFilterChain(); } // END - if // Return NULL @@ -186,6 +195,9 @@ function FILTER_GENERIC_USER_REGISTRATION_FORM () { if (((isGetRequestElementSet('registration_provider')) && (getRequestElement('registration_provider') == 'register')) || (getDefaultRegistrationProvider() == 'register')) { // Display generic form doDisplayGenericUserRegistrationForm(); + + // Interrupt filter chain + interruptFilterChain(); } // END - if // Return NULL diff --git a/inc/filter/surfbar_filter.php b/inc/filter/surfbar_filter.php index 517797ef8a..2bd3e5713e 100644 --- a/inc/filter/surfbar_filter.php +++ b/inc/filter/surfbar_filter.php @@ -73,11 +73,11 @@ function FILTER_SURFBAR_CHANGE_URL_VALIDATE_DATA ($filterData) { if ((!is_string($filterData['new_status'])) || (empty($filterData['new_status']))) { // Abort here, but fine! //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newStatus[' . gettype($filterData['new_status']) . ']=' . $filterData['new_status'] . ' - EXIT!'); - $GLOBALS['filter_chain_aborted'] = TRUE; + interruptFilterChain(); } elseif ($filterData['data'][$filterData['url_id']]['url_status'] != $filterData['prev_status']) { // Status is not like prevStatus //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $filterData['data'][$filterData['url_id']]['url_status'] . '!=' . $filterData['prev_status'] . ' - EXIT!'); - $GLOBALS['filter_chain_aborted'] = FALSE; + continueFilterChain(); } // END - if // Return filter data diff --git a/inc/filter/wernis_filter.php b/inc/filter/wernis_filter.php index e36364535b..53b5a43b8c 100644 --- a/inc/filter/wernis_filter.php +++ b/inc/filter/wernis_filter.php @@ -48,6 +48,9 @@ function FILTER_WERNIS_USER_REGISTRATION ($filterData) { if ((isPostRequestElementSet('registration_provider')) && (postRequestElement('registration_provider') == 'wernis')) { // Run it $filterData['status'] = doWernisUserRegistration(); + + // Interrupt filter chain + interruptFilterChain(); } // END - if // Return it @@ -63,6 +66,9 @@ function FILTER_WERNIS_USER_REGISTRATION_DONE () { // Is generic user registration selected? if ((isPostRequestElementSet('registration_provider')) && (postRequestElement('registration_provider') == 'wernis')) { // Run it + + // Interrupt filter chain + interruptFilterChain(); } // END - if // Return it @@ -78,6 +84,9 @@ function FILTER_WERNIS_USER_REGISTRATION_FAILED () { // Is generic user registration selected? if ((isPostRequestElementSet('registration_provider')) && (postRequestElement('registration_provider') == 'wernis')) { // Run it + + // Interrupt filter chain + interruptFilterChain(); } // END - if // Return it @@ -93,6 +102,9 @@ function FILTER_WERNIS_USER_REGISTRATION_FORM () { // Is generic user registration selected? if (((isGetRequestElementSet('registration_provider')) && (gettRequestElement('registration_provider') == 'wernis')) || (getDefaultRegistrationProvider() == 'wernis')) { // Run it + + // Interrupt filter chain + interruptFilterChain(); } // END - if // Return it -- 2.39.5