X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffilters.php;h=f100892efe2a292be3a60ac8980fc1b5030ec2b0;hb=cd06fbc228eff8b408816c70fd37ed9f8b59a305;hp=1d7a5004760d661695a464d82faa6a6a84cd918f;hpb=64c8349613addc3da2242c5cd6b99d64e3fb5f8e;p=mailer.git diff --git a/inc/filters.php b/inc/filters.php index 1d7a500476..f100892efe 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -95,20 +95,14 @@ function FILTER_FLUSH_FILTERS () { // Something has been added? if ($inserted > 0) { - // Finish SQL command - $insertSQL = substr($insertSQL, 0, -1); - - // And run it - addSql($insertSQL); + // Finish SQL command and add it + addSql(substr($insertSQL, 0, -1)); } // END - if // Something has been removed? if ($removed > 0) { - // Finish SQL command - $removeSQL = substr($removeSQL, 0, -2) . 'LIMIT '.$removed; - - // And run it - addSql($removeSQL); + // Finish SQL command and add it + addSql(substr($removeSQL, 0, -2) . 'LIMIT ' . $removed); } // END - if // Shall we update usage counters (ONLY FOR DEBUGGING!) @@ -331,28 +325,6 @@ function FILTER_UPDATE_LOGIN_DATA () { SQL_FREERESULT($result); } -// Filter for checking admin ACL -function FILTER_CHECK_ADMIN_ACL () { - // Extension not installed so it's always allowed to access everywhere! - $ret = true; - - // Ok, Cookie-Update done - if ((isExtensionInstalledAndNewer('admins', '0.3.0')) && (isExtensionActive('admins'))) { - // Check if action GET variable was set - $action = getAction(); - if (isWhatSet()) { - // Get action value by what-value - $action = getModeAction('admin', getWhat()); - } // END - if - - // Check for access control line of current menu entry - $ret = adminsCheckAdminAcl($action, getWhat()); - } // END - if - - // Return result - return $ret; -} - // Filter for initializing randomizer function FILTER_INIT_RANDOMIZER () { // Simply init the randomizer with seed and _ADD value @@ -442,9 +414,15 @@ function FILTER_COMPILE_CONFIG ($code) { if (isConfigEntrySet($matches[1][$key])) { // Set it for caching $GLOBALS['compile_config'][$matches[1][$key]] = getConfig($matches[1][$key]); - } else { + } elseif (isConfigEntrySet('default_' . strtoupper($matches[1][$key]))) { + // Use default value + $GLOBALS['compile_config'][$matches[1][$key]] = getConfig('DEFAULT_' . strtoupper($matches[1][$key])); + } elseif (isMessageIdValid('DEFAULT_' . strtoupper($matches[1][$key]))) { // No config, try the language system $GLOBALS['compile_config'][$matches[1][$key]] = getMessage('DEFAULT_' . strtoupper($matches[1][$key])); + } else { + // Unhandled! + $GLOBALS['compile_config'][$matches[1][$key]] = '!' . $matches[1][$key] . '!'; } } // END - if @@ -501,7 +479,7 @@ function FILTER_UPDATE_EXTENSION_DATA ($ext_name) { // Load more reset scripts function FILTER_RUN_RESET_INCLUDES () { // Is the reset set or old sql_patches? - if ((!isResetModeEnabled()) || (!isExtensionInstalledAndOlder('sql_patches', '0.4.5'))) { + if (((!isResetModeEnabled()) || (!isExtensionInstalledAndOlder('sql_patches', '0.4.5'))) && (getOutputMode() == 0)) { // Then abort here logDebugMessage(__FUNCTION__, __LINE__, 'Cannot run reset! Please report this bug. Thanks'); } // END - if @@ -580,6 +558,16 @@ function FILTER_HTML_INCLUDE_USERS ($mode) { // Filter for determining what/action/module function FILTER_DETERMINE_WHAT_ACTION () { + // In installation phase we don't have what/action + if (isInstallationPhase()) { + // Set both to empty + setAction(''); + setWhat(''); + + // Abort here + return; + } // END - if + // Get all values if ((getOutputMode() != 1) && (getOutputMode() != -1)) { // Fix module @@ -615,7 +603,7 @@ function FILTER_DETERMINE_WHAT_ACTION () { // Sends out pooled mails function FILTER_TRIGGER_SENDING_POOL () { // Are we in normal output mode? - if (getOutputMode() != '0') { + if (getOutputMode() != 0) { // Only in normal output mode to prevent race-conditons! } // END - if @@ -671,5 +659,159 @@ function FILTER_LOAD_RUNTIME_INCLUDES () { //* DEBUG: */ die(); } +// Filter for checking admin ACL +function FILTER_CHECK_ADMIN_ACL () { + // Extension not installed so it's always allowed to access everywhere! + $ret = true; + + // Ok, Cookie-Update done + if ((isExtensionInstalledAndNewer('admins', '0.3.0')) && (isExtensionActive('admins'))) { + // Check if action GET variable was set + $action = getAction(); + if (isWhatSet()) { + // Get action value by what-value + $action = getModeAction('admin', getWhat()); + } // END - if + + // Check for access control line of current menu entry + $ret = adminsCheckAdminAcl($action, getWhat()); + } // END - if + + // Set it here + $GLOBALS['acl_allow'] = $ret; +} + +// Init random number/cache buster +function FILTER_INIT_RANDOM_NUMBER () { + // Is the extension sql_patches installed and at least 0.3.6? + if ((isExtensionActive('sql_patches')) && (getExtensionVersion('sql_patches') >= '0.3.6')) { + // Generate random number + setConfigEntry('RAND_NUMBER', generateRandomCode(10, mt_rand(10000, 32766), getUserId(), '')); + } else { + // Generate weak (!!!) code + setConfigEntry('RAND_NUMBER', mt_rand(1000000, 9999999)); + } + + // Copy it to CACHE_BUSTER + setConfigEntry('CACHE_BUSTER', getConfig('RAND_NUMBER')); +} + +// Update module counter +function FILTER_COUNT_MODULE () { + // Do count all other modules but not accesses on CSS file css.php! + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `clicks`=`clicks`+1 WHERE `module`='%s' LIMIT 1", + array(getModule()), __FUNCTION__, __LINE__); +} + +// Handles fatal errors +function FILTER_HANDLE_FATAL_ERRORS () { + // Do we have errors to handle and right output mode? + if ((getTotalFatalErrors() == 0) || (getOutputMode() != 0)) { + // Abort executing here + return false; + } // END - if + + // Set content type + setContentType('text/html'); + + // Load config here + loadIncludeOnce('inc/load_config.php'); + + // Set unset variable + if (empty($check)) $check = ''; + + // Default is none + $content = ''; + + // Installation phase or regular mode? + if ((isInstallationPhase())) { + // While we are installing ouput other header than while it is installed... :-) + $OUT = ''; + foreach (getFatalArray() as $key => $value) { + // Prepare content for the template + $content = array( + 'key' => ($key + 1), + 'value' => $value + ); + + // Load row template + $OUT .= loadTemplate('install_fatal_row', true, $content); + } + + // Load main template + $content = loadTemplate('install_fatal_table', true, $OUT); + } elseif (isInstalled()) { + // Display all runtime fatal errors + $OUT = ''; + foreach (getFatalArray() as $key => $value) { + // Prepare content for the template + $content = array( + 'key' => ($key + 1), + 'value' => $value + ); + + // Load row template + $OUT .= loadTemplate('runtime_fatal_row', true, $content); + } + + // Load main template + $content = loadTemplate('runtime_fatal_table', true, $OUT); + } + + // Message to regular users (non-admin) + $CORR = getMessage('FATAL_REPORT_ERRORS'); + + // PHP warnings fixed + if ($check == 'done') { + if (isAdmin()) $CORR = getMessage('FATAL_CORRECT_ERRORS'); + } // END - if + + // Remember all in array + $content = array( + 'rows' => $content, + 'corr' => $CORR + ); + + // Load footer + loadIncludeOnce('inc/header.php'); + + // Load main template + loadTemplate('fatal_errors', false, $content); + + // Delete all to prevent double-display + initFatalMessages(); + + // Load footer + loadIncludeOnce('inc/footer.php'); + + // Abort here + shutdown(); +} + +// Filter for displaying copyright line +function FILTER_DISPLAY_COPYRIGHT () { + // Shall we display the copyright notice? + if ((!isGetRequestElementSet('frame')) && (basename($_SERVER['PHP_SELF']) != 'mailid_top.php') && ((getConfig('WRITE_FOOTER') == 'Y') || (isInstalling())) && ($GLOBALS['header_sent'] == 2)) { + // Backlink enabled? + if ((getConfig('ENABLE_BACKLINK') == 'Y') || (isInstalling())) { + // Copyright with backlink, thanks! :-) + loadTemplate('copyright_backlink'); + } else { + // No backlink in Copyright note + loadTemplate('copyright'); + } + } // END - if +} + +// 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 5 543 3 4432 2 33 2 2 21 + if ((((isExtensionInstalledAndNewer('sql_patches', '0.4.1')) && (getConfig('show_timings') == 'Y') && (!isGetRequestElementSet('frame'))) || (isInstallationPhase())) && (getOutputMode() == 0) && ($GLOBALS['header_sent'] == 2)) { + // Then display it here + displayParsingTime(); + } // END - if +} + // [EOF] ?>