+ return $filterData;
+}
+
+// Filter to initialize session
+function FILTER_INIT_SESSION ($filterData) {
+ // Determine and set referral id
+ determineReferralId();
+
+ // Return data
+ return $filterData;
+}
+
+// Filter for sending "build mail" to admin
+function FILTER_SEND_BUILD_MAIL ($filterData) {
+ // Was one line updated?
+ if (($filterData['affected'] > 0) || (isDebugBuildMailsEnabled())) {
+ // Then call the proper function
+ call_user_func_array('sendGenericBuildMails', $filterData);
+ } // END - if
+
+ // Return data
+ return $filterData;
+}
+
+// Handles click on referral banner
+function FILTER_HANDLE_REFERRER_BANNER_CLICK ($filterData) {
+ // Check required parameters
+ if ((isGetRequestElementSet('user')) && (isGetRequestElementSet('banner'))) {
+ // Update clicks counter...
+ sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `clicks`=`clicks`+1 WHERE `id`=%s LIMIT 1',
+ array(bigintval(getRequestElement('banner'))), __FUNCTION__, __LINE__);
+
+ // A line has been updated?
+ if ((!ifSqlHasZeroAffectedRows()) && (isGetRequestElementSet('user'))) {
+ // Redirect to the user's referral link
+ redirectToUrl('ref.php?refid=' . bigintval(getRequestElement('user')));
+ } // END - if
+ } // END - if
+
+ // Return filter data
+ return $filterData;
+}
+
+// Filter for handling viewing of a referral banner
+function FILTER_HANDLE_REFERRER_BANNER_VIEW ($filterData) {
+ // Are all required parameters set
+ if ((isGetRequestElementSet('user')) && (isGetRequestElementSet('banner'))) {
+ // For later things... ;-)
+ $result = sqlQueryEscaped('SELECT `url` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `id`=%s LIMIT 1',
+ array(bigintval(getRequestElement('banner'))), __FUNCTION__, __LINE__);
+
+ // Is there the banner?
+ if (sqlNumRows($result) == 1) {
+ // Load the URL
+ $data = sqlFetchArray($result);
+
+ // Update counter
+ sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `counter`=`counter`+1 WHERE `id`=%s LIMIT 1',
+ array(bigintval(getRequestElement('banner'))), __FUNCTION__, __LINE__);
+
+ // Set header and ...
+ setContentType('image/' . substr($data['url'], -3, 3));
+
+ // Redirect
+ redirectToUrl($data['url'], FALSE);
+ } // END - if
+
+ // @TODO No banner found, output some default banner
+ logDebugMessage(__FUNCTION__, __LINE__, 'Banner ' . bigintval(getRequestElement('banner')) . ' not found.');
+
+ // Free memory
+ sqlFreeResult($result);
+ } // 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)
+function FILTER_REDIRECT_WRONG_SERVER_NAME ($filterData) {
+ // Get URL
+ $url = getUrl();
+
+ // Is the configured URL same as SERVER_NAME?
+ if (extractHostnameFromUrl($url) != detectServerName()) {
+ // Log all attempts
+ logWrongServerNameRedirect();
+
+ // Then redirect to configured URL
+ redirectToRequestUri();
+ } // END - if
+
+ // Return filter data
+ return $filterData;
+}
+
+// Filter for adding hidden session id
+function FILTER_ADD_INPUT_HIDDEN_SESSION_ID ($filterData) {
+ // Is a spider detected?
+ if ((!isSpider()) && (!isValidSession()) && ($filterData['__form_method'] == 'get')) {
+ // No, then add the hidden field
+ $filterData['__replacer'] .= '<input type="hidden" name="' . session_name() . '" value="' . session_id() . '" />';
+ } // END - if
+
+ // Return filter data
+ return $filterData;
+}
+
+// Filter for purging old SERVER_NAME entries
+function FILTER_SERVER_NAME_EXTRA_AUTOPURGE ($filterData) {
+ // Is purging configured?
+ if ((isApServerNameEnabled()) && (getApServerNameSince() > 0)) {
+ // Then start purging
+ sqlQuery('DELETE LOW_PRIORITY FROM
+ `{?_MYSQL_PREFIX?}_server_name_log`
+WHERE
+ (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`server_name_added`)) >= {?ap_server_name_since?}',
+ __FILE__, __LINE__);
+
+ // Are some entries deleted?
+ if (sqlAffectedRows() > 0) {
+ // Okay, then send an email to the admin
+ sendAdminNotification('{--ADMIN_PURGE_USER_SERVER_NAME_LOG_SUBJECT--}', 'admin_purge_user_server_name_log', sqlAffectedRows());
+ } // END - if
+ } // END - if
+
+ // Return filter data
+ return $filterData;
+}
+
+// Filter for detecting menu mode
+function FILTER_DETERMINE_MENU_MODE_GENERIC ($filterData) {
+ // "Detect" it
+ switch (getModule()) {
+ case 'chk_login': // Is also faked
+ case 'confirm': // Login script is 'member'
+ case 'loader': // Is faked to 'member' to avoid indexing by search engines
+ case 'mailid': // Mail confirmation is 'member'
+ $filterData = 'member';
+ break;
+ } // END - switch
+
+ // Return filter data
+ return $filterData;
+}
+
+// Filter to exclude default referral id
+function FILTER_EXCLUDE_DEFAULT_REFID ($filterData = array()) {
+ // Is it valid?
+ if (isValidId(getDefRefid())) {
+ // Exclude it
+ array_push($filterData, '{?def_refid?}');
+ } // END - if
+
+ // Return it
+ return $filterData;