+ setSession('mailer_member_failures' , getUserData('login_failures'));
+ setSession('mailer_member_last_failure', getUserData('last_failure'));
+ } // END - if
+}
+
+// Try to login the admin by setting some session/cookie variables
+function FILTER_DO_LOGIN_ADMIN ($filterData) {
+ // Now set all session variables and store the result for later processing
+ $GLOBALS['admin_login_success'] = ((
+ setAdminMd5(encodeHashForCookie($filterData['pass_hash']))
+ ) && (
+ setAdminId($filterData['id'])
+ ) && (
+ setAdminLast(time())
+ ));
+
+ // Return the data for further processing
+ return $filterData;
+}
+
+// Filter for loading page header, this should be ran first!
+function FILTER_LOAD_PAGE_HEADER () {
+ // Output page header code
+ $GLOBALS['__page_header'] = loadTemplate('page_header', TRUE);
+
+ // Include meta data in 'guest' module
+ if (isModuleSet()) {
+ // Load meta data template
+ $GLOBALS['__page_header'] .= loadTemplate(getMenuModeFromModule() . '_metadata', TRUE);
+
+ // Add meta description to header
+ if ((isInstalled()) && (isAdminRegistered()) && (isSqlLinkUp()) && (getModule() == 'index')) {
+ // Add meta description not in admin and login module and when the script is installed
+ generateMetaDescriptionCode();
+ } // END - if
+ } // END - if
+}
+
+// Filter for adding style sheet, closing page header
+function FILTER_FINISH_PAGE_HEADER () {
+ // Include stylesheet
+ loadIncludeOnce('inc/stylesheet.php');
+
+ // Closing HEAD tag
+ $GLOBALS['__page_header'] .= '</head>';
+}
+
+// Cleans up the DNS cache if ext-sql_patches is at least 0.7.0
+function FILTER_CLEANUP_DNS_CACHE () {
+ // Is the latest version installed?
+ if (isExtensionInstalledAndNewer('sql_patches', '0.7.0')) {
+ // Load class file
+ loadIncludeOnce('inc/classes/resolver.class.php');
+
+ // Instance the resolver
+ $resolver = new HostnameResolver();
+
+ // Purge entries
+ $resolver->purgeEntries();
+
+ // Cute, isn't it? ;-)
+ } // END - if
+}
+
+// Filter for setting CURRENT_DATE, this is required after initialization of extensions
+function FILTER_SET_CURRENT_DATE () {
+ // Set current date
+ setConfigEntry('CURRENT_DATE', generateDateTime(time(), '3'));
+
+ // 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()));
+}
+
+// Filter for marking extension as installed
+function FILTER_EXTENSION_MARK_INSTALLED ($filterData) {
+ // Mark it as installed
+ $GLOBALS['ext_is_installed'][$filterData['ext_name']] = TRUE;
+}
+
+// Filter for generating mails links for 'pool' mails
+function FILTER_GENERATE_POOL_MAIL_LINKS ($filterData) {
+ // Is type 'normal'?
+ if ($filterData['type'] == 'normal') {
+ // Load template
+ $filterData['__output'] .= loadTemplate('admin_links_' . strtolower($filterData['mail_status']) . '_pool_mail', TRUE, $filterData);
+ } // END - if
+
+ // Return data
+ return $filterData;
+}
+
+// Filter to activate exchange
+function FILTER_ACTIVATE_EXCHANGE () {
+ // Are the extension ext-user/other there?
+ if ((!isExtensionActive('user')) || (!isExtensionInstalled('other')) || (isAjaxOutputMode()) || (getActivateXchange() == '0')) {
+ // Silently abort here
+ return FALSE;
+ } // END - if
+
+ // Check total amount of users
+ if (getTotalConfirmedUser() >= getActivateXchange()) {
+ // Activate System
+ addSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='N',`hidden`='N',`mem_only`='Y' WHERE `module`='order' LIMIT 1");
+ addSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y',`locked`='N' WHERE `what`='order' OR `what`='unconfirmed' LIMIT 2");
+
+ // Run SQLs
+ runFilterChain('run_sqls');
+
+ // Update configuration
+ updateConfiguration('activate_xchange' ,0);
+
+ // Rebuild cache
+ rebuildCache('modules', 'modules');
+ } // END - if
+}
+
+// Filter to handle configuration
+function FILTER_HANDLE_HOME_IN_INDEX_SETTING ($filterData) {
+ // Is ext-sql_patches up-to-date?
+ if ((isExtensionInstalledAndNewer('sql_patches', '0.8.3')) && (isDisplayHomeInIndexEnabled())) {
+ // Is 'search' as same as 'index_home'?
+ if ($filterData['search'] == getIndexHome()) {
+ // Then set 'content' to link to index.php
+ $filterData['content'] = $filterData['prefix'] . '<strong><a class="you_are_here" href="{%url=index.php' . $filterData['link_add'] . '%}">' . getTitleFromMenu($filterData['access_level'], $filterData['search'], $filterData['type'], $filterData['add']) . '</a></strong>';
+ } // END - if
+ } // END - if
+
+ // Return data
+ return $filterData;
+}
+
+// Filter to add history entry
+function FILTER_ADD_HISTORY_ENTRY ($filterData) {
+ // Add the entry
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_history` (`history_subject`, `history_userid`, `history_value`) VALUES ('%s',%s,'%s')",
+ $filterData,
+ __FUNCTION__, __LINE__);
+
+ // Remember insert id for other filters
+ $filterData['history_id'] = getSqlInsertId();
+
+ // Return data
+ return $filterData;
+}
+
+// Filter for initializing ext-sql_patches
+function FILTER_GENERATE_FILE_SECRET_HASH ($filterData) {
+ // Is ext-sql_patches installed and transfer POINTS word?
+ if ((!isExtensionInstalled('sql_patches')) || (!isExtensionInstalledAndNewer('sql_patches', '0.9.0'))) {
+ // Extension ext-sql_patches is missing, so better abort here
+ return;
+ } // END - if
+
+ // Okay, recent enough, so transfer the word for POINTS
+ setConfigEntry('POINTS', getPointsWord());
+
+ // Init key
+ setConfigEntry('secret_key', '');
+
+ // File hash was generated so we can also file the secret file... hopefully.
+ $hashFile = sprintf('%s%s.%s.cache', getPath(), getCachePath(), getFileHash());
+
+ // Read key from secret file
+ if ((getFileHash() == '') || (getMasterSalt() == '') || (getPassScramble() == '') || (!isFileReadable($hashFile))) {
+ // Maybe need setup of secret key!
+ loadIncludeOnce('inc/gen_sql_patches.php');
+
+ // Generate file name again
+ $hashFile = sprintf('%s%s.%s.cache', getPath(), getCachePath(), getFileHash());
+ } // END - if
+
+ // Test again
+ if ((getFileHash() != '') && (getMasterSalt() != '') && (getPassScramble() != '')) {
+ // Is the secret key file readable?
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'hashFile=' . $hashFile);
+ if (isFileReadable($hashFile)) {
+ // Read file
+ setConfigEntry('secret_key', readFromFile($hashFile));
+ } else {
+ // Remove it from database
+ updateConfiguration('file_hash', '', '', '0', TRUE);
+
+ // Cannot read secret file!
+ reportBug(__FILE__, __LINE__, 'Cannot read secret file! Please try to reload.');
+ }