X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffilters.php;h=c8b52da2c81ef4dabc3415d27884e8f91c2e18bd;hp=1bbede3a98313c2113f8d7b2b5dbc942d429b8cf;hb=9b8fe454a575a1f000b00bc7ca37eaad6d59d21a;hpb=5d89789720c77e954b2eba28c00ec710dd28900d diff --git a/inc/filters.php b/inc/filters.php index 1bbede3a98..c8b52da2c8 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -16,7 +16,7 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009, 2010 by Mailer Developer Team * + * Copyright (c) 2009 - 2011 by Mailer Developer Team * * For more information visit: http://www.mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -164,10 +164,10 @@ function FILTER_REDIRECT_TO_LOGOUT_SQL_PATCHES () { // Filter for auto-activation of a extension function FILTER_AUTO_ACTIVATE_EXTENSION ($data) { // Debug message - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $data['ext_name'] . ',isExtensionAlwaysActive()=' . intval(isExtensionAlwaysActive())); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $data['ext_name'] . ',isThisExtensionAlwaysActive()=' . intval(isThisExtensionAlwaysActive())); // Is this extension always activated? - if (isExtensionAlwaysActive()) { + if (isThisExtensionAlwaysActive()) { // Then activate the extension doActivateExtension($data['ext_name']); } // END - if @@ -258,7 +258,9 @@ function FILTER_RUN_SQLS ($data) { $sql = trim($sql); // Is 'enable_codes' not set? Then set it to true - if (!isset($data['enable_codes'])) $data['enable_codes'] = true; + if (!isset($data['enable_codes'])) { + $data['enable_codes'] = true; + } // END - if // Is there still a query left? if (!empty($sql)) { @@ -284,10 +286,14 @@ function FILTER_RUN_SQLS ($data) { // Filter for updating/validating login data function FILTER_UPDATE_LOGIN_DATA () { // Add missing array - if ((!isset($GLOBALS['last_online'])) || (!is_array($GLOBALS['last_online']))) $GLOBALS['last_online'] = array(); + if ((!isset($GLOBALS['last_online'])) || (!is_array($GLOBALS['last_online']))) { + $GLOBALS['last_online'] = array(); + } // END - if // Recheck if logged in - if (!isMember()) return false; + if (!isMember()) { + return false; + } // END - if // Secure user id setMemberId(getSession('userid')); @@ -298,7 +304,9 @@ function FILTER_UPDATE_LOGIN_DATA () { $content = getUserDataArray(); // Maybe first login time? - if (empty($content['last_module'])) $content['last_module'] = 'login'; + if (empty($content['last_module'])) { + $content['last_module'] = 'login'; + } // END - if // This will be displayed on welcome page! :-) if (empty($GLOBALS['last_online']['module'])) { @@ -310,7 +318,9 @@ function FILTER_UPDATE_LOGIN_DATA () { if (!isWhatSet()) { // Fix it to default setWhat('welcome'); - if (getIndexHome() != '') setWhatFromConfig('index_home'); + if (getIndexHome() != '') { + setWhatFromConfig('index_home'); + } // END - if } // END - if // Update last module / online time @@ -324,7 +334,9 @@ function FILTER_UPDATE_LOGIN_DATA () { // Filter for initializing randomizer function FILTER_INIT_RANDOMIZER () { // Only execute this filter if installed - if ((!isInstalled()) || (!isExtensionInstalledAndNewer('other', '0.2.5'))) return; + if ((!isInstalled()) || (!isExtensionInstalledAndNewer('other', '0.2.5'))) { + return; + } // END - if // Take a prime number which is long (if you know a longer one please try it out!) setConfigEntry('_PRIME', 591623); @@ -508,7 +520,7 @@ function FILTER_COMPILE_EXPRESSION_CODE ($code) { $data = array( 'matches' => $matches, 'key' => $key, - 'mode' => $outputMode, + 'mode' => getScriptOutputMode(), 'code' => $code, 'callback' => $callback, 'extra_func' => $extraFunction, @@ -527,7 +539,9 @@ function FILTER_COMPILE_EXPRESSION_CODE ($code) { } // END - if // Do we have non-HTML mode? - if ((!isHtmlOutputMode()) || ($outputMode != '0')) $code = decodeEntities($code); + if (!isHtmlOutputMode()) { + $code = decodeEntities($code); + } // END - if // Return compiled code //* DEBUG: */ debugOutput(__FUNCTION__.'['.__LINE__.']:
'.($code).'
'); @@ -548,6 +562,26 @@ function FILTER_UPDATE_EXTENSION_DATA ($ext_name) { unset($GLOBALS['update_ver'][$ext_name]); } +// Load more hourly reset scripts +function FILTER_RUN_HOURLY_INCLUDES () { + // Is the reset set or old sql_patches? + if (((!isHourlyResetEnabled()) || (!isExtensionInstalledAndNewer('sql_patches', '0.7.5'))) && (isHtmlOutputMode())) { + // Then abort here + debug_report_bug(__FUNCTION__, __LINE__, 'Cannot run reset! enabled='.intval(isHourlyResetEnabled()).',ext_newer[sql_patches:0.7.5]='.intval(isExtensionInstalledAndNewer('sql_patches', '0.7.5')).' Please report this bug. Thanks'); + } // END - if + + // Get more hourly reset scripts + setIncludePool('hourly', getArrayFromDirectory('inc/hourly/', 'hourly_')); + + // Update database + if ((!isConfigEntrySet('DEBUG_RESET')) || (!isDebugResetEnabled())) { + updateConfiguration('last_hour', getHour()); + } // END - if + + // Run the filter + runFilterChain('load_includes', 'hourly'); +} + // Load more reset scripts function FILTER_RUN_RESET_INCLUDES () { // Is the reset set or old sql_patches? @@ -557,10 +591,12 @@ function FILTER_RUN_RESET_INCLUDES () { } // END - if // Get more daily reset scripts - setIncludePool('reset', getArrayFromDirectory('inc/reset/', 'reset_')); + setIncludePool('reset', getArrayFromDirectory('inc/daily/', 'daily_')); // Update database - if ((!isConfigEntrySet('DEBUG_RESET')) || (getConfig('DEBUG_RESET') != 'Y')) updateConfiguration('last_update', 'UNIX_TIMESTAMP()'); + if ((!isConfigEntrySet('DEBUG_RESET')) || (!isDebugResetEnabled())) { + updateConfiguration('last_update', 'UNIX_TIMESTAMP()'); + } // END - if // Is the config entry set? if (isExtensionInstalledAndNewer('sql_patches', '0.4.2')) { @@ -585,7 +621,9 @@ function FILTER_RUN_RESET_INCLUDES () { mergeIncludePool('reset', getArrayFromDirectory('inc/monthly/', 'monthly_')); // Update config - if (!isMonthlyResetDebugEnabled()) updateConfiguration('last_month', $currMonth); + if (!isMonthlyResetDebugEnabled()) { + updateConfiguration('last_month', $currMonth); + } // END - if } // END - if } // END - if @@ -714,7 +752,7 @@ function FILTER_CHECK_REPOSITORY_REVISION () { // Only execute this filter if installed and all config entries are there if ((!isInstalled()) || (!isConfigEntrySet('patch_level'))) return; - // Check for patch level differences between databases and current hard-coded + // Check for patch level differences between database and current hard-coded if ((getCurrentRepositoryRevision() > getConfig('patch_level')) || (getConfig('patch_level') == 'CURRENT_REPOSITORY_REVISION') || (getConfig('patch_ctime') == 'UNIX_TIMES')) { // Update database and CONFIG array updateConfiguration(array('patch_level', 'patch_ctime'), array(getCurrentRepositoryRevision(), 'UNIX_TIMESTAMP()')); @@ -726,21 +764,37 @@ function FILTER_CHECK_REPOSITORY_REVISION () { // Filter for running daily reset function FILTER_RUN_DAILY_RESET () { // Only execute this filter if installed - if ((isInstallationPhase()) || (!isInstalled()) || (!isAdminRegistered()) || (!isExtensionInstalled('sql_patches'))) return; + if ((isInstallationPhase()) || (!isInstalled()) || (!isAdminRegistered()) || (!isExtensionInstalled('sql_patches'))) { + return; + } // END - if // Shall we run the reset scripts? If a day has changed, maybe also a week/month has changed... Simple! :D - if (((getDay(getConfig('last_update')) != getDay()) || ((isConfigEntrySet('DEBUG_RESET')) && (getConfig('DEBUG_RESET') == 'Y'))) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestParameterSet('register')) && (!isCssOutputMode())) { + if (((getDay(getConfig('last_update')) != getDay()) || (isDebugResetEnabled())) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestParameterSet('register')) && (!isCssOutputMode())) { // Tell every module we are in reset-mode! doReset(); } // END - if } +// Filter for running hourly reset +function FILTER_RUN_HOURLY_RESET () { + // Only execute this filter if installed + if ((isInstallationPhase()) || (!isInstalled()) || (!isAdminRegistered()) || (!isExtensionInstalledAndNewer('sql_patches', '0.7.5'))) { + return; + } // END - if + + // Shall we run the reset scripts? If a day has changed, maybe also a week/month has changed... Simple! :D + if (((getConfig('last_hour') != getHour()) || (isDebugResetEnabled())) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestParameterSet('register')) && (!isCssOutputMode())) { + // Tell every module we are in reset-mode! + doHourly(); + } // END - if +} + // Filter for loading more runtime includes (not for installation) function FILTER_LOAD_RUNTIME_INCLUDES () { // Load more includes - foreach (array('inc/databases.php','inc/session.php','inc/versions.php') as $inc) { + foreach (array('databases', 'session', 'versions') as $inc) { // Load the include - loadIncludeOnce($inc); + loadIncludeOnce('inc/' . $inc . '.php'); } // END - foreach } @@ -759,7 +813,7 @@ function FILTER_CHECK_ADMIN_ACL () { } // END - if // Check for access control line of current menu entry - $ret = adminsCheckAdminAcl($action, getWhat()); + $ret = isAdminsAllowedByAcl($action, getWhat()); } // END - if // Set it here @@ -959,11 +1013,11 @@ LIMIT 1", function FILTER_DO_LOGIN_ADMIN ($data) { // Now set all session variables and store the result for later processing $GLOBALS['admin_login_success'] = (( - setSession('admin_md5', encodeHashForCookie($data['pass_hash'])) + setAdminMd5(encodeHashForCookie($data['pass_hash'])) ) && ( - setSession('admin_id', $data['id']) + setAdminId($data['id']) ) && ( - setSession('admin_last', time()) + setAdminLast(time()) )); // Return the data for further processing @@ -1019,7 +1073,7 @@ function FILTER_SET_CURRENT_DATE () { // Set current date setConfigEntry('CURRENT_DATE', generateDateTime(time(), '3')); - // Timestamp for yesterday, today ... all at 00:00 am + // Epoche time for yesterday, today ... all at 00:00 am setConfigEntry('START_YDAY', makeTime(0, 0, 0, time() - getOneDay())); setConfigEntry('START_TDAY', makeTime(0, 0, 0, time())); }