+// Update module counter
+function FILTER_COUNT_MODULE () {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getModule()=' . getModule() . ' - ENTERED!');
+ // 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__);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getModule()=' . getModule() . ',SQL_AFFECTEDROWS()=' . SQL_AFFECTEDROWS() . ' - EXIT!');
+}
+
+// Handles fatal errors
+function FILTER_HANDLE_FATAL_ERRORS () {
+ // Do we have errors to handle and right output mode?
+ if ((!ifFatalErrorsDetected()) || (!isHtmlOutputMode())) {
+ // Abort executing here
+ return false;
+ } // END - if
+
+ // Set content type
+ setContentType('text/html');
+
+ // Load config here
+ loadIncludeOnce('inc/load_config.php');
+
+ // Default content 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 = '{--FATAL_REPORT_ERRORS--}';
+
+ // Maybe the admin wants to take a look?
+ if (isAdmin()) {
+ $CORR = '{--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 (((isConfigEntrySet('ENABLE_BACKLINK')) && (getConfig('ENABLE_BACKLINK') == 'Y')) || (isInstalling())) {
+ // Copyright with backlink, thanks! :-)
+ $GLOBALS['page_footer'] .= loadTemplate('copyright_backlink', true);
+ } else {
+ // No backlink in Copyright note
+ $GLOBALS['page_footer'] .= loadTemplate('copyright', true);
+ }
+ } // 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())) && (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()) return;
+
+ // Do we have cached eval() data?
+ if ((isset($GLOBALS['template_eval'])) && (count($GLOBALS['template_eval']) > 0)) {
+ // Now flush all
+ foreach ($GLOBALS['template_eval'] as $template => $eval) {
+ // Flush the cache (if not yet found)
+ flushTemplateCache($template, $eval);
+ } // END - if
+ } // END - if
+}
+
+// Filter for loading user data
+function FILTER_FETCH_USER_DATA ($userid = NULL) {
+ // Is the userid not set? Then use member id
+ if (!isValidUserId($userid)) {
+ $userid = getMemberId();
+ } // END - if
+
+ // Get user data
+ if (!fetchUserData($userid)) {
+ // Userid is not valid
+ debug_report_bug(__FUNCTION__, __LINE__, 'User id '.$userid . ' is invalid.');
+ } // END - if
+
+ // Set member id
+ setMemberId($userid);
+}
+
+// Filter for reseting users' last login failure, only available with latest ext-sql_patches
+function FILTER_RESET_USER_LOGIN_FAILURE () {
+ // Is the user data valid?
+ if (!isMember()) {
+ // Do only run for logged in members
+ debug_report_bug(__FUNCTION__, __LINE__, 'Please only run this filter for logged in users.');
+ } // END - if
+
+ // Remmeber login failures if available
+ if (isExtensionInstalledAndNewer('user', '0.3.7')) {
+ // Reset login failures
+ SQL_QUERY_ESC("UPDATE
+ `{?_MYSQL_PREFIX?}_user_data`
+SET
+ `login_failures`=0,
+ `last_failure`=NULL
+WHERE
+ `userid`=%s
+LIMIT 1",
+ array(getMemberId()), __FUNCTION__, __LINE__);
+
+ // Store it in session
+ 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 (getModule() == 'index') {
+ // Load meta data template
+ $GLOBALS['page_header'] .= loadTemplate('metadata', true);
+
+ // Add meta description to header
+ if ((isInstalled()) && (isAdminRegistered()) && (SQL_IS_LINK_UP())) {
+ // 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 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 'mid'?
+ if ($filterData['type'] == 'mid') {
+ // 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 () {
+ // Is the extension 'user' there?
+ if ((!isExtensionActive('user')) || (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
+ SQL_QUERY_ESC("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'] = SQL_INSERTID();
+
+ // Return data
+ return $filterData;
+}
+