reportBug(__FUNCTION__, __LINE__, 'No database link is up. Cannot flush filters.');
} elseif ((isInstallationPhase()) && (!SQL_IS_LINK_UP())) {
// If the link is not up in installation phase, skip flushing filters
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot flush filters: No link is up.');
return;
}
- // Is the extension ext-sql_patches updated and not in installation phase?
- if ((!isInstallationPhase()) && ((!isExtensionInstalled('sql_patches')) || (isExtensionInstalledAndOlder('sql_patches', '0.5.9')))) {
+ // Is the extension ext-sql_patches updated?
+ if (((!isExtensionInstalled('sql_patches')) || (isExtensionInstalledAndOlder('sql_patches', '0.5.9'))) && (!isInstallationPhase())) {
// Log only in debug mode
if (isDebugModeEnabled()) {
logDebugMessage(__FUNCTION__, __LINE__, 'Cannot flush filters, ext-sql_patches might be missing. isExtensionInstalled()=' . intval(isExtensionInstalled('sql_patches')) . ',isExtensionInstalledAndOlder()=' . intval(isExtensionInstalledAndOlder('sql_patches', '0.5.9')));
// Walk through all filters
foreach ($filterArray as $filterFunction => $active) {
// Is this filter loaded?
- //* DEBUG: */ debugOutput('FOUND:'.$filterName.'/'.$filterFunction.'='.$active);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'FOUND:'.$filterName.'/'.$filterFunction.'='.$active);
if (((!isset($GLOBALS['cache_array']['filter']['loaded'][$filterName][$filterFunction])) && ($active != 'R')) || ($active == 'A')) {
- // Add this filter (all filters are active by default)
- //* DEBUG: */ debugOutput('ADD:'.$filterName.'/'.$filterFunction);
- $insertSQL .= sprintf("('%s','%s','Y'),", $filterName, $filterFunction);
- $inserted++;
+ // Is this filter already in database?
+ if (countSumTotalData($filterFunction, 'filters', 'filter_name', 'filter_function', TRUE, sprintf(" AND `filter_name`='%s'", SQL_ESCAPE($filterName))) == 0) {
+ // Add this filter (all filters are active by default)
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ADD:'.$filterName.'/'.$filterFunction);
+ $insertSQL .= sprintf("('%s','%s','Y'),", $filterName, $filterFunction);
+ $inserted++;
+ } elseif (isDebugModeEnabled()) {
+ // Log already registered filters
+ logDebugMessage(__FUNCTION__, __LINE__, 'Already registered: filterName=' . $filterName . ',filterFunction=' . $filterFunction . ',active=' . $active);
+ }
} elseif ($active == 'R') {
// Remove this filter
- //* DEBUG: */ debugOutput('REMOVE:'.$filterName.'/'.$filterFunction);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'REMOVE:'.$filterName.'/'.$filterFunction);
$removeSQL .= sprintf(" (`filter_name`='%s' AND `filter_function`='%s') OR", $filterName, $filterFunction);
$removed++;
}
} // END - foreach
} // END - foreach
+ // Debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'inserted=' . $inserted . ',removed=' . $removed . ' - AFTER COLLECTION');
+
// Something has been added?
if ($inserted > 0) {
// Finish SQL command and add it
return $content;
}
-// Filter for redirecting to logout if ext-sql_patches has been installed
-function FILTER_REDIRECT_TO_LOGOUT_SQL_PATCHES () {
- // Remove this filter
- unregisterFilter(__FUNCTION__, __LINE__, 'shutdown', __FUNCTION__);
-
- // Is the element set?
- if (isset($GLOBALS['ext_load_mode'])) {
- // Redirect here
- redirectToUrl('modules.php?module=admin&logout=1&' . $GLOBALS['ext_load_mode'] . '=sql_patches');
- } // END - if
-
- // This should not happen!
- logDebugMessage(__FUNCTION__, __LINE__, 'Cannot auto-logout because no extension load-mode has been set.');
-}
-
// Filter for auto-activation of a extension
function FILTER_AUTO_ACTIVATE_EXTENSION ($filterData) {
// Debug message
// Is there still a query left?
if (!empty($sql)) {
- // Is there an "ALTER TABLE" command?
- if (substr(strtolower($sql), 0, 11) == 'alter table') {
+ // Is there an "ALTER TABLE" command? Exclude installation phase here as it would cause this query to fail
+ if ((substr(strtolower($sql), 0, 11) == 'alter table') && (!isset($filterData['ext_installing']))) {
// Analyse the alteration command
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Alterting table: ' . $sql . ',enable_codes=' . intval($filterData['enable_codes']));
SQL_ALTER_TABLE($sql, __FUNCTION__, __LINE__, $filterData['enable_codes']);
// Debug message
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '- Left!');
- // Clear any SQL queries
- //initSqls();
-
// Return counter
return $count;
}
// Take a prime number which is long (if you know a longer one please try it out!)
setConfigEntry('_PRIME', 591623);
+ // Initialize array with all allowed chars
+ $GLOBALS['_abc'] = explode(',', 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,1,2,3,4,6,7,8,9,-,+,_,/,.');
+
// Only execute this filter if installed
if ((!isInstalled()) || (!isExtensionInstalledAndNewer('other', '0.2.5'))) {
// Set missing entry
// Simply init the randomizer with seed and _ADD value
mt_srand(generateSeed() + getConfig('_ADD'));
-
- // Initialize array with all allowed chars
- $GLOBALS['_abc'] = explode(',', 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,1,2,3,4,6,7,8,9,-,+,_,/,.');
}
// Filter for removing updates
} // END - foreach
} // END - if
- // Is there non-HTML mode?
- if (!isHtmlOutputMode()) {
+ // Is there non-HTML/AJAX mode?
+ if ((!isHtmlOutputMode()) && (!isAjaxOutputMode())) {
$filterData = decodeEntities($filterData);
} // END - if
// Filter for flushing the output
function FILTER_FLUSH_OUTPUT () {
+ // Is this filter called?
+ if (isset($GLOBALS[__FUNCTION__])) {
+ // Abort here
+ reportBug(__FUNCTION__, __LINE__, 'Double call of ' . __FUNCTION__ . ' causes problems with sent headers.');
+ } // END - if
+
+ // Mark this filter as called
+ $GLOBALS[__FUNCTION__] = TRUE;
+
// Simple, he?
- outputHtml('');
+ outputHtml();
}
// Prepares an SQL statement part for HTML mail and/or holiday dependency
// Filter for displaying copyright line
function FILTER_DISPLAY_COPYRIGHT () {
// Shall we display the copyright notice?
- if ((isFullPage()) && ((getConfig('WRITE_FOOTER') == 'Y') || (isInstalling())) && ($GLOBALS['__header_sent'] == 2) && (ifCopyrightFooterEnabled())) {
+ if ((isFullPage()) && ((getWriteFooter() == 'Y') || (isInstalling())) && ($GLOBALS['__header_sent'] == 2) && (ifCopyrightFooterEnabled())) {
// Backlink enabled?
if (((isConfigEntrySet('ENABLE_BACKLINK')) && (getConfig('ENABLE_BACKLINK') == 'Y')) || (isInstalling())) {
// Copyright with backlink, thanks! :-)
// Filter for displaying parsing time
function FILTER_DISPLAY_PARSING_TIME () {
// Shall we display the parsing time and number of queries?
- // 1234 5 54 4 5 5 4 4 5543 3 4432 2 332 2 21
- if ((((isExtensionInstalledAndNewer('sql_patches', '0.4.1')) && (getConfig('show_timings') == 'Y') && (isFullPage())) && (!isInstallationPhase())) && (isHtmlOutputMode()) && ($GLOBALS['__header_sent'] == 2)) {
+ // 1234 5 54 4 554 4 5543 3 4432 2 332 2 21
+ if ((((isExtensionInstalledAndNewer('sql_patches', '0.4.1')) && (isShowTimingsEnabled()) && (isFullPage())) && (!isInstallationPhase())) && (isHtmlOutputMode()) && ($GLOBALS['__header_sent'] == 2)) {
// Then display it here
displayParsingTime();
} // END - if
// Filter for flushing template cache
function FILTER_FLUSH_TEMPLATE_CACHE () {
// Do not flush when debugging the template cache
- if (isDebuggingTemplateCache()) {
+ if (isDebugTemplateCacheEnabled()) {
// Do not flush templates in debug-mode
return;
} // END - if
// Is there cached eval() data?
if ((isset($GLOBALS['template_eval'])) && (count($GLOBALS['template_eval']) > 0)) {
- // Now flush all
+ // Flush all
foreach ($GLOBALS['template_eval'] as $prefix => $templateArray) {
foreach ($templateArray as $template => $eval) {
// Flush the cache (if not yet found)
// Filter for loading user data
function FILTER_FETCH_USER_DATA ($userid = NULL) {
- // Is the userid not set? Then use member id
- if (!isValidUserId($userid)) {
+ // Is the userid not set?
+ if (!isValidId($userid)) {
+ // Then use member id
$userid = getMemberId();
} // END - if
// Get user data
if (!fetchUserData($userid)) {
// Userid is not valid
- reportBug(__FUNCTION__, __LINE__, 'User id '.$userid . ' is invalid.');
+ reportBug(__FUNCTION__, __LINE__, 'User id ' . $userid . ' is invalid.');
} // END - if
// Set member id
setMemberId($userid);
+
+ // Continue with next filter
+ return $userid;
}
// Filter for reseting users' last login failure, only available with latest ext-sql_patches
$GLOBALS['__page_header'] = loadTemplate('page_header', TRUE);
// Include meta data in 'guest' module
- if ((isModuleSet()) && (getModule() == 'index')) {
+ if (isModuleSet()) {
// Load meta data template
- $GLOBALS['__page_header'] .= loadTemplate('metadata', TRUE);
+ $GLOBALS['__page_header'] .= loadTemplate(getMenuModeFromModule() . '_metadata', TRUE);
// Add meta description to header
- if ((isInstalled()) && (isAdminRegistered()) && (SQL_IS_LINK_UP())) {
+ if ((isInstalled()) && (isAdminRegistered()) && (SQL_IS_LINK_UP()) && (getModule() == 'index')) {
// Add meta description not in admin and login module and when the script is installed
generateMetaDescriptionCode();
} // END - if
// Redirect
redirectToUrl($data['url'], FALSE);
- } else {
- // @TODO No banner found, output some default banner
- logDebugMessage(__FUNCTION__, __LINE__, 'Banner ' . bigintval(getRequestElement('banner')) . ' not dound.');
- }
+ } // END - if
+
+ // @TODO No banner found, output some default banner
+ logDebugMessage(__FUNCTION__, __LINE__, 'Banner ' . bigintval(getRequestElement('banner')) . ' not found.');
// Free memory
SQL_FREERESULT($result);
- } else {
- // Do nothing for now
- redirectToUrl('modules.php?module=index');
- }
+ } // END - if
+
+ // Do nothing for now
+ redirectToUrl('modules.php?module=index');
}
// Filter for redirecting on wrong server name (e.g. bad.your-server.tld will be redirected to your-server.tld)
return $filterData;
}
+// Filter for detecting menu mode
+function FILTER_DETERMINE_MENU_MODE_GENERIC ($filterData) {
+ // "Detect" it
+ switch (getModule()) {
+ case 'confirm': // Login script is 'member'
+ $filterData = 'member';
+ break;
+ } // END - switch
+
+ // Return filter data
+ return $filterData;
+}
+
// [EOF]
?>