From 24dfd21baed6a9a112992bdabf7da96576012bc4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 2 Jun 2011 05:00:15 +0000 Subject: [PATCH] Moved all FILTER_FOO() filter functions to an own include directory: - For example inc/filter/foo_filter.php holds filter functions for extension 'foo' --- .gitattributes | 17 ++++ inc/extensions-functions.php | 3 + inc/extensions/ext-rallye.php | 2 +- inc/filter-functions.php | 25 +++++ inc/filter/.htaccess | 1 + inc/filter/_filter.php | 44 +++++++++ inc/filter/active_filter.php | 61 ++++++++++++ inc/filter/admins_filter.php | 117 ++++++++++++++++++++++ inc/filter/bonus_filter.php | 83 ++++++++++++++++ inc/filter/booking_filter.php | 53 ++++++++++ inc/filter/cache_filter.php | 97 ++++++++++++++++++ inc/filter/mediadata_filter.php | 53 ++++++++++ inc/filter/online_filter.php | 132 +++++++++++++++++++++++++ inc/filter/other_filter.php | 53 ++++++++++ inc/filter/politician_stop_filter.php | 53 ++++++++++ inc/filter/rallye_filter.php | 50 ++++++++++ inc/filter/register_filter.php | 69 +++++++++++++ inc/filter/removeip_filter.php | 59 +++++++++++ inc/filter/theme_filter.php | 77 +++++++++++++++ inc/filter/timezone_filter.php | 53 ++++++++++ inc/filter/uberwach_filter.php | 53 ++++++++++ inc/libs/active_functions.php | 17 ---- inc/libs/admins_functions.php | 77 --------------- inc/libs/bonus_functions.php | 43 -------- inc/libs/booking_functions.php | 9 -- inc/libs/cache_functions.php | 53 ---------- inc/libs/mediadata_functions.php | 17 +--- inc/libs/online_functions.php | 85 ---------------- inc/libs/other_functions.php | 9 -- inc/libs/politician_stop_functions.php | 9 -- inc/libs/rallye_functions.php | 8 +- inc/libs/register_functions.php | 25 ----- inc/libs/removeip_functions.php | 15 --- inc/libs/theme_functions.php | 37 ------- inc/libs/timezone_functions.php | 9 -- inc/libs/uberwach_functions.php | 9 -- 36 files changed, 1160 insertions(+), 417 deletions(-) create mode 100644 inc/filter/.htaccess create mode 100644 inc/filter/_filter.php create mode 100644 inc/filter/active_filter.php create mode 100644 inc/filter/admins_filter.php create mode 100644 inc/filter/bonus_filter.php create mode 100644 inc/filter/booking_filter.php create mode 100644 inc/filter/cache_filter.php create mode 100644 inc/filter/mediadata_filter.php create mode 100644 inc/filter/online_filter.php create mode 100644 inc/filter/other_filter.php create mode 100644 inc/filter/politician_stop_filter.php create mode 100644 inc/filter/rallye_filter.php create mode 100644 inc/filter/register_filter.php create mode 100644 inc/filter/removeip_filter.php create mode 100644 inc/filter/theme_filter.php create mode 100644 inc/filter/timezone_filter.php create mode 100644 inc/filter/uberwach_filter.php diff --git a/.gitattributes b/.gitattributes index 6f6db16a90..26353d9e07 100644 --- a/.gitattributes +++ b/.gitattributes @@ -200,6 +200,23 @@ inc/extensions/ext-wernis.php svneol=native#text/plain inc/extensions/ext-yacy.php svneol=native#text/plain inc/extensions/ext-yoomedia.php svneol=native#text/plain inc/filter-functions.php svneol=native#text/plain +inc/filter/.htaccess svneol=native#text/plain +inc/filter/_filter.php svneol=native#text/plain +inc/filter/active_filter.php svneol=native#text/plain +inc/filter/admins_filter.php svneol=native#text/plain +inc/filter/bonus_filter.php svneol=native#text/plain +inc/filter/booking_filter.php svneol=native#text/plain +inc/filter/cache_filter.php svneol=native#text/plain +inc/filter/mediadata_filter.php svneol=native#text/plain +inc/filter/online_filter.php svneol=native#text/plain +inc/filter/other_filter.php svneol=native#text/plain +inc/filter/politician_stop_filter.php svneol=native#text/plain +inc/filter/rallye_filter.php svneol=native#text/plain +inc/filter/register_filter.php svneol=native#text/plain +inc/filter/removeip_filter.php svneol=native#text/plain +inc/filter/theme_filter.php svneol=native#text/plain +inc/filter/timezone_filter.php svneol=native#text/plain +inc/filter/uberwach_filter.php svneol=native#text/plain inc/filters.php svneol=native#text/plain inc/fix_filters.php svneol=native#text/plain inc/fix_menu.php svneol=native#text/plain diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index 56f624b44b..780ee2f8bc 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -142,6 +142,9 @@ function loadExtension ($ext_name, $ext_mode, $ext_ver = '0.0', $dry_run = false )); } + // Load extension's filter library if present + loadExtensionFilters($ext_name); + // Extensions are not deprecated by default setExtensionDeprecated('N'); diff --git a/inc/extensions/ext-rallye.php b/inc/extensions/ext-rallye.php index b594f4e054..90583365c6 100644 --- a/inc/extensions/ext-rallye.php +++ b/inc/extensions/ext-rallye.php @@ -326,7 +326,7 @@ Zudem sollten Sie mindestens folgende Templates (in templates/".getLangu case 'init': // Do stuff when extension is initialized // Do stuff only when not in CSS mode - // @TODO Move this code into rallye_functions.php + // @TODO Move this code into a hook if (!isCssOutputMode()) { // Get total member count $total = getTotalConfirmedUser(); diff --git a/inc/filter-functions.php b/inc/filter-functions.php index 613760b858..066ca22365 100644 --- a/inc/filter-functions.php +++ b/inc/filter-functions.php @@ -343,5 +343,30 @@ function prepareFilterArray () { $GLOBALS['cache_array']['filter'] = $filterArray; } +// Loads filter for given extension if present. This function will silently +// ignore absent filter files. +function loadExtensionFilters ($ext_name) { + // Do we have cache entry? + if (!isset($GLOBALS[__FUNCTION__][$ext_name])) { + // Default is not found + $GLOBALS[__FUNCTION__][$ext_name] = false; + + // Construct include file name + $incFileName = sprintf("inc/filter/%s_filter.php", $ext_name); + + // Is the include file readable? + if (isIncludeReadable($incFileName)) { + // Load the include file + loadIncludeOnce($incFileName); + + // Mark the file as loaded + $GLOBALS[__FUNCTION__][$ext_name] = true; + } elseif (isDebugModeEnabled()) { + // Log missing file + logDebugMessage(__FUNCTION__, __LINE__, 'Include file ' . $incFileName . ' for extension ' . $ext_name . ' is missing.'); + } + } // END - if +} + // [EOF] ?> diff --git a/inc/filter/.htaccess b/inc/filter/.htaccess new file mode 100644 index 0000000000..3a42882788 --- /dev/null +++ b/inc/filter/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/filter/_filter.php b/inc/filter/_filter.php new file mode 100644 index 0000000000..ff369843ae --- /dev/null +++ b/inc/filter/_filter.php @@ -0,0 +1,44 @@ + diff --git a/inc/filter/active_filter.php b/inc/filter/active_filter.php new file mode 100644 index 0000000000..2132e64b7a --- /dev/null +++ b/inc/filter/active_filter.php @@ -0,0 +1,61 @@ + '{?menu_blur_spacer?}{--GUEST_ACTIVE_LINK--}', + 'what' => 'active', + 'visible' => 'Y', + 'locked' => 'N' + ); + + // Add link to "we were active today" page + $GLOBALS['rows'] .= loadTemplate('guest_menu_bottom', true, $content); + } // END - if +} + +// [EOF] +?> diff --git a/inc/filter/admins_filter.php b/inc/filter/admins_filter.php new file mode 100644 index 0000000000..81beec2b19 --- /dev/null +++ b/inc/filter/admins_filter.php @@ -0,0 +1,117 @@ + diff --git a/inc/filter/bonus_filter.php b/inc/filter/bonus_filter.php new file mode 100644 index 0000000000..b72d994b6c --- /dev/null +++ b/inc/filter/bonus_filter.php @@ -0,0 +1,83 @@ +{--MEMBER_BONUS_LOGIN_BONUS_ADDED--}'; + } elseif (isExtensionActive('bonus')) { + // No login bonus added! + $GLOBALS['message'] .= '
{--MEMBER_BONUS_LOGIN_BONUS_NOT_ADDED--}
'; + } +} + +// [EOF] +?> diff --git a/inc/filter/booking_filter.php b/inc/filter/booking_filter.php new file mode 100644 index 0000000000..4fb2b207ab --- /dev/null +++ b/inc/filter/booking_filter.php @@ -0,0 +1,53 @@ + diff --git a/inc/filter/cache_filter.php b/inc/filter/cache_filter.php new file mode 100644 index 0000000000..ec708e1ce0 --- /dev/null +++ b/inc/filter/cache_filter.php @@ -0,0 +1,97 @@ +loadCacheFile($cache)) $GLOBALS['cache_instance']->removeCacheFile(); + } // END - foreach + + // Return it + return $data; +} + +// Destroy the cache on changing admin +function FILTER_CACHE_DESTROY_ON_ADMIN_CHANGE ($data) { + // Skip this step if the cache instance is not there + if (!isCacheInstanceValid()) return false; + + // Remove cache + if ($GLOBALS['cache_instance']->loadCacheFile('admin')) $GLOBALS['cache_instance']->removeCacheFile(); + + // Return the data + return $data; +} + +// Destroy all cache files +function FILTER_CACHE_DESTROY_ALL () { + // Skip this step if the cache instance is not there + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + if (!isCacheInstanceValid()) return false; + + // Remove cache files + foreach (array('admin','admin_acls','config','extension','modules','refdepths','refsystem','themes','filter','imprint') as $cache) { + // Is the cache file readable? + // @TODO This should be rewritten not to load the cache file for just checking if it is there for save removal. + if ($GLOBALS['cache_instance']->loadCacheFile($cache)) { + // Remove the cache file + $GLOBALS['cache_instance']->removeCacheFile(); + } // END - if + } // END - foreach + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); +} + +// Filter for purging 'filter' cache +function FILTER_CACHE_DESTROY_FILTER () { + // Skip this step if the cache instance is not there + if ((!isCacheInstanceValid()) || (getConfig('update_filter_usage') != 'Y')) return false; + + // Remove cache files + if ($GLOBALS['cache_instance']->loadCacheFile('filter')) $GLOBALS['cache_instance']->removeCacheFile(); +} + +// [EOF] +?> diff --git a/inc/filter/mediadata_filter.php b/inc/filter/mediadata_filter.php new file mode 100644 index 0000000000..102ee3f7f1 --- /dev/null +++ b/inc/filter/mediadata_filter.php @@ -0,0 +1,53 @@ + diff --git a/inc/filter/online_filter.php b/inc/filter/online_filter.php new file mode 100644 index 0000000000..50fb19a473 --- /dev/null +++ b/inc/filter/online_filter.php @@ -0,0 +1,132 @@ + diff --git a/inc/filter/other_filter.php b/inc/filter/other_filter.php new file mode 100644 index 0000000000..17fa7113c9 --- /dev/null +++ b/inc/filter/other_filter.php @@ -0,0 +1,53 @@ + diff --git a/inc/filter/politician_stop_filter.php b/inc/filter/politician_stop_filter.php new file mode 100644 index 0000000000..8a66346a2d --- /dev/null +++ b/inc/filter/politician_stop_filter.php @@ -0,0 +1,53 @@ + diff --git a/inc/filter/rallye_filter.php b/inc/filter/rallye_filter.php new file mode 100644 index 0000000000..cda5e6bc2e --- /dev/null +++ b/inc/filter/rallye_filter.php @@ -0,0 +1,50 @@ + diff --git a/inc/filter/register_filter.php b/inc/filter/register_filter.php new file mode 100644 index 0000000000..e73d8a45a9 --- /dev/null +++ b/inc/filter/register_filter.php @@ -0,0 +1,69 @@ +(*)'; + } // END - if + + // Add it + $content['must_fillout_' . strtolower($row['field_name']) . ''] = $value; + } // END - while + + // Free memory + SQL_FREERESULT($result); + + // Return it + return $content; +} + +// [EOF] +?> diff --git a/inc/filter/removeip_filter.php b/inc/filter/removeip_filter.php new file mode 100644 index 0000000000..39afe01257 --- /dev/null +++ b/inc/filter/removeip_filter.php @@ -0,0 +1,59 @@ +\n"; + } // END - if + + // Return it + return $content; +} + +// [EOF] +?> diff --git a/inc/filter/theme_filter.php b/inc/filter/theme_filter.php new file mode 100644 index 0000000000..5cb385c994 --- /dev/null +++ b/inc/filter/theme_filter.php @@ -0,0 +1,77 @@ + diff --git a/inc/filter/timezone_filter.php b/inc/filter/timezone_filter.php new file mode 100644 index 0000000000..7ff31c151b --- /dev/null +++ b/inc/filter/timezone_filter.php @@ -0,0 +1,53 @@ + diff --git a/inc/filter/uberwach_filter.php b/inc/filter/uberwach_filter.php new file mode 100644 index 0000000000..ec30e1a778 --- /dev/null +++ b/inc/filter/uberwach_filter.php @@ -0,0 +1,53 @@ + diff --git a/inc/libs/active_functions.php b/inc/libs/active_functions.php index 30e4c74da6..a868326a39 100644 --- a/inc/libs/active_functions.php +++ b/inc/libs/active_functions.php @@ -40,22 +40,5 @@ if (!defined('__SECURITY')) { die(); } // END - if -// Filter for adding link to "active list" -function FILTER_ADD_LINK_ACTIVE_LIST () { - // Is ext-active/online there? - if ((isExtensionActive('active')) && (isExtensionActive('online'))) { - // Init fake-content because there is no `what`='active' in database - $content = array( - 'menu' => '{?menu_blur_spacer?}{--GUEST_ACTIVE_LINK--}', - 'what' => 'active', - 'visible' => 'Y', - 'locked' => 'N' - ); - - // Add link to "we were active today" page - $GLOBALS['rows'] .= loadTemplate('guest_menu_bottom', true, $content); - } // END - if -} - // [EOF] ?> diff --git a/inc/libs/admins_functions.php b/inc/libs/admins_functions.php index c46ee546f3..18d2d5c715 100644 --- a/inc/libs/admins_functions.php +++ b/inc/libs/admins_functions.php @@ -624,83 +624,6 @@ function getAdminLastFailure ($adminId) { return $data['last_failure']; } -//----------------------------------------------------------------------------- -// Filter Functions -//----------------------------------------------------------------------------- - -// Filter for adding extra data to the query -function FILTER_ADD_EXTRA_SQL_DATA ($add = '') { - // Is the admins extension updated? (should be!) - if (isExtensionInstalledAndNewer('admins', '0.3.0')) $add .= ', `default_acl` AS def_acl'; - if (isExtensionInstalledAndNewer('admins', '0.6.7')) $add .= ', `la_mode`'; - if (isExtensionInstalledAndNewer('admins', '0.7.2')) $add .= ', `login_failures`, UNIX_TIMESTAMP(`last_failure`) AS last_failure'; - if (isExtensionInstalledAndNewer('admins', '0.7.3')) $add .= ', `expert_settings`, `expert_warning`'; - - // Return it - return $add; -} - -// Reset the login failures -function FILTER_RESET_ADMINS_LOGIN_FAILURES ($data) { - // Store it in session - setSession('mailer_admin_failures' , getAdminLoginFailures($data['id'])); - setSession('mailer_admin_last_failure', getAdminLastFailure($data['id'])); - - // Prepare update data - $postData['login'][getCurrentAdminId()] = $data['login']; - $postData['login_failures'][getCurrentAdminId()] = '0'; - $postData['last_failure'][getCurrentAdminId()] = null; - - // Change it in the admin - adminsChangeAdminAccount($postData); - - // Always make sure the cache is destroyed - rebuildCache('admin'); - - // Return the data for further processing - return $data; -} - -// Count the login failure -function FILTER_COUNT_ADMINS_LOGIN_FAILURE ($data) { - // Prepare update data - $postData['login'][getCurrentAdminId()] = $data['login']; - $postData['login_failures'][getCurrentAdminId()] = '`login_failures`+1'; - $postData['last_failure'][getCurrentAdminId()] = 'NOW()'; - - // Change it in the admin - adminsChangeAdminAccount($postData); - - // Always make sure the cache is destroyed - rebuildCache('admin'); - - // Return the data for further processing - return $data; -} - -// Rehashes the given plain admin password and stores it the database -function FILTER_REHASH_ADMINS_PASSWORD ($data) { - // Generate new hash - $newHash = generateHash($data['plain_pass']); - - // Prepare update data - $postData['login'][getCurrentAdminId()] = $data['login']; - $postData['password'][getCurrentAdminId()] = $newHash; - - // Change it in the admin - adminsChangeAdminAccount($postData); - - // Update cookie/session and data array - setAdminMd5(encodeHashForCookie($newHash)); - $data['pass_hash'] = $newHash; - - // Always make sure the cache is destroyed - rebuildCache('admin'); - - // Return the data for further processing - return $data; -} - // --------------------------------------------------------------------------- // Wrapper functions // --------------------------------------------------------------------------- diff --git a/inc/libs/bonus_functions.php b/inc/libs/bonus_functions.php index 68269946d8..0ef95848f6 100644 --- a/inc/libs/bonus_functions.php +++ b/inc/libs/bonus_functions.php @@ -274,49 +274,6 @@ function purgeExpiredTurboBonus() { } // END - if } -//----------------------------------------------------------------------------- -// Filter Functions -//----------------------------------------------------------------------------- - -// Filter for adding login bonus to the user's account -function FILTER_ADD_LOGIN_BONUS () { - // 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 - - // Bonus is not given by default ;-) - $bonus = false; - if ((isExtensionInstalledAndNewer('sql_patches', '0.2.8')) && (isBonusRallyeActive()) && (getConfig('bonus_login_yn') == 'Y')) { - // Update last login if far enougth away - // @TODO This query isn't right, it will only update if the user was for a longer time away! - SQL_QUERY_ESC('UPDATE - `{?_MYSQL_PREFIX?}_user_data` -SET - `last_login`=UNIX_TIMESTAMP() -WHERE - `userid`=%s AND - `last_login` < (UNIX_TIMESTAMP() - {?login_timeout?}) -LIMIT 1', - array( - getMemberId() - ), __FUNCTION__, __LINE__ - ); - - // Updated entry? - $bonus = (!SQL_HASZEROAFFECTED()); - } // END - if - - if (($bonus === true) && (getRequestParameter('mode') == 'bonus')) { - // Output message with added points - $GLOBALS['message'] .= '
{--MEMBER_BONUS_LOGIN_BONUS_ADDED--}
'; - } elseif (isExtensionActive('bonus')) { - // No login bonus added! - $GLOBALS['message'] .= '
{--MEMBER_BONUS_LOGIN_BONUS_NOT_ADDED--}
'; - } -} - //----------------------------------------------------------------------------- // Wrapper Functions //----------------------------------------------------------------------------- diff --git a/inc/libs/booking_functions.php b/inc/libs/booking_functions.php index 957c46cf41..ad4601c0e4 100644 --- a/inc/libs/booking_functions.php +++ b/inc/libs/booking_functions.php @@ -53,14 +53,5 @@ function addBookingRecord ($subject, $userid, $points, $mode) { array($userid, $subject, $mode, $points), __FUNCTION__, __LINE__); } -// Filter for adding booking record -function FILTER_ADD_BOOKING_RECORD ($data) { - // Add a record - addBookingRecord($data['subject'], $data['userid'], $data['points'], $data['mode']); - - // Return data - return $data; -} - // [EOF] ?> diff --git a/inc/libs/cache_functions.php b/inc/libs/cache_functions.php index 40505c6e94..8896ffdf41 100644 --- a/inc/libs/cache_functions.php +++ b/inc/libs/cache_functions.php @@ -40,58 +40,5 @@ if (!defined('__SECURITY')) { die(); } // END - if -// Destroy the cache on extension changes -function FILTER_CACHE_DESTROY_ON_EXT_CHANGE ($data) { - // Return the data anyway if there is no cache extension - if (!isCacheInstanceValid()) return $data; - - // Remove cache - foreach (array('config','extension','filter','modules') as $cache) { - if ($GLOBALS['cache_instance']->loadCacheFile($cache)) $GLOBALS['cache_instance']->removeCacheFile(); - } // END - foreach - - // Return it - return $data; -} - -// Destroy the cache on changing admin -function FILTER_CACHE_DESTROY_ON_ADMIN_CHANGE ($data) { - // Skip this step if the cache instance is not there - if (!isCacheInstanceValid()) return false; - - // Remove cache - if ($GLOBALS['cache_instance']->loadCacheFile('admin')) $GLOBALS['cache_instance']->removeCacheFile(); - - // Return the data - return $data; -} - -// Destroy all cache files -function FILTER_CACHE_DESTROY_ALL () { - // Skip this step if the cache instance is not there - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); - if (!isCacheInstanceValid()) return false; - - // Remove cache files - foreach (array('admin','admin_acls','config','extension','modules','refdepths','refsystem','themes','filter','imprint') as $cache) { - // Is the cache file readable? - // @TODO This should be rewritten not to load the cache file for just checking if it is there for save removal. - if ($GLOBALS['cache_instance']->loadCacheFile($cache)) { - // Remove the cache file - $GLOBALS['cache_instance']->removeCacheFile(); - } // END - if - } // END - foreach - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); -} - -// Filter for purging 'filter' cache -function FILTER_CACHE_DESTROY_FILTER () { - // Skip this step if the cache instance is not there - if ((!isCacheInstanceValid()) || (getConfig('update_filter_usage') != 'Y')) return false; - - // Remove cache files - if ($GLOBALS['cache_instance']->loadCacheFile('filter')) $GLOBALS['cache_instance']->removeCacheFile(); -} - // [EOF] ?> diff --git a/inc/libs/mediadata_functions.php b/inc/libs/mediadata_functions.php index 03d9d534a5..151aa2783e 100644 --- a/inc/libs/mediadata_functions.php +++ b/inc/libs/mediadata_functions.php @@ -38,7 +38,7 @@ // Some security stuff... if (!defined('__SECURITY')) { die(); -} +} // END - if // Update an entry function updateMediadataEntry ($keys_array, $mode, $value) { @@ -108,8 +108,10 @@ function getMediadataEntry ($key) { $value = ''; // Check for entry - $result = SQL_QUERY_ESC("SELECT media_value FROM `{?_MYSQL_PREFIX?}_mediadata` WHERE media_key='%s' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `media_value` FROM `{?_MYSQL_PREFIX?}_mediadata` WHERE `media_key`='%s' LIMIT 1", array($key), __FUNCTION__, __LINE__); + + // Do we have one? if (SQL_NUMROWS($result) == 1) { // Load data list($value) = SQL_FETCHROW($result); @@ -119,14 +121,5 @@ function getMediadataEntry ($key) { return $value; } -// Filter for updating media data -function FILTER_UPDATE_MEDIADATA_ENTRY ($data) { - // Execute the filter function - $data['added'] = ($data['added'] && updateMediadataEntry(array('total_points'), $data['mode'], $data['points'])); - - // Return data - return $data; -} - -// +// [EOF] ?> diff --git a/inc/libs/online_functions.php b/inc/libs/online_functions.php index 31743dfdd7..c22a7fa2da 100644 --- a/inc/libs/online_functions.php +++ b/inc/libs/online_functions.php @@ -40,90 +40,5 @@ if (!defined('__SECURITY')) { die(); } // END - if -// Filter for updates/extends on the online list -function FILTER_UPDATE_ONLINE_LIST () { - // Do not update online list when extension is deactivated - if (!isExtensionActive('online', true)) return; - - // Empty session? - if (session_id() == '') { - // This is invalid here! - debug_report_bug(__FUNCTION__, __LINE__, 'Invalid session.'); - } // END - if - - // Initialize variables - $userid = '0'; - $isMember = 'N'; - $isAdmin = 'N'; - $action = getActionFromModuleWhat(getModule(), getWhat()); - - // Valid userid? - if (isMember()) { - // Is valid user - $userid = getMemberId(); - $isMember = 'Y'; - } // END - if - - if (isAdmin()) { - // Is administrator - $isAdmin = 'Y'; - } // END - if - - // Now search for the user - $result = SQL_QUERY_ESC("SELECT `timestamp` FROM `{?_MYSQL_PREFIX?}_online` WHERE `sid`='%s' LIMIT 1", - array(session_id()), __FUNCTION__, __LINE__); - - // Entry found? - if (SQL_NUMROWS($result) == 1) { - // Then update it - SQL_QUERY_ESC("UPDATE - `{?_MYSQL_PREFIX?}_online` -SET - `module`='%s', - `action`='%s', - `what`='%s', - `userid`=%s, - `refid`=%s, - `is_member`='%s', - `is_admin`='%s', - `timestamp`=UNIX_TIMESTAMP(), - `ip`='%s' -WHERE - `sid`='%s' -LIMIT 1", - array( - getModule(), - $action, - getWhat(), - makeDatabaseUserId($userid), - makeDatabaseUserId(determineReferalId()), - $isMember, - $isAdmin, - detectRemoteAddr(), - session_id() - ), __FUNCTION__, __LINE__); - } else { - // No entry does exists so we simply add it! - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_online` (`module`, `action`, `what`, `userid`, `refid`, `is_member`, `is_admin`, `timestamp`, `sid`, `ip`) VALUES ('%s','%s','%s', %s, %s, '%s','%s', UNIX_TIMESTAMP(), '%s','%s')", - array( - getModule(), - $action, - getWhat(), - makeDatabaseUserId($userid), - makeDatabaseUserId(determineReferalId()), - $isMember, - $isAdmin, - session_id(), - detectRemoteAddr() - ), __FUNCTION__, __LINE__); - } - - // Free result - SQL_FREERESULT($result); - - // Purge old entries - SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_online` WHERE `timestamp` <= (UNIX_TIMESTAMP() - {?online_timeout?})', __FUNCTION__, __LINE__); -} - // [EOF] ?> diff --git a/inc/libs/other_functions.php b/inc/libs/other_functions.php index 46a5aa6199..fa7d3a0558 100644 --- a/inc/libs/other_functions.php +++ b/inc/libs/other_functions.php @@ -60,14 +60,5 @@ function displayDebugSqls () { $GLOBALS['page_footer'] .= loadTemplate('admin_other_sqls', true, $OUT); } -// Filter for debugging SQLs -function FILTER_DISPLAY_DEBUG_SQL () { - // Shall we display SQL queries? - if ((isAdmin()) && (isDisplayDebugSqlEnabled()) && (!isGetRequestParameterSet('frame')) && ($GLOBALS['header_sent'] == 2)) { - // Then display it here - displayDebugSqls(); - } // END - if -} - // [EOF] ?> diff --git a/inc/libs/politician_stop_functions.php b/inc/libs/politician_stop_functions.php index 6d21762f95..e22fd33f50 100644 --- a/inc/libs/politician_stop_functions.php +++ b/inc/libs/politician_stop_functions.php @@ -46,14 +46,5 @@ function loadPoliticianStopSnippet () { loadTemplate('politician_stop_snippet'); } -// Filter for displaying politician_stop snippet -function FILTER_DISPLAY_POLITICIAN_STOP_SNIPPET () { - // Shall we include the politician_stop snippet? - if ((!isGetRequestParameterSet('frame')) && (isExtensionActive('politician_stop')) && (getModule() != 'admin') && ($GLOBALS['header_sent'] == 2)) { - // Then display it here - loadPoliticianStopSnippet(); - } // END - if -} - // [EOF] ?> diff --git a/inc/libs/rallye_functions.php b/inc/libs/rallye_functions.php index e2b69c0b67..b2fb6807a3 100644 --- a/inc/libs/rallye_functions.php +++ b/inc/libs/rallye_functions.php @@ -462,7 +462,7 @@ function markReferalRallyesAsExpired ($result) { // Check status // active = 1: account is still confirmed // active = 0: account is deleted or locked - $active = countSumTotalData($DATA['userid'][$idx], 'user_data', 'userid', 'userid', true, " AND `status`='CONFIRMED'"); + $active = countSumTotalData($userid, 'user_data', 'userid', 'userid', true, " AND `status`='CONFIRMED'"); $prices['active'][$key] = $active; @@ -952,11 +952,5 @@ function determineReferalRallyeMinimumPrices ($min_prices) { return $return; } -// Filter for extra-autpurge -function FILTER_RALLYE_EXTRA_AUTOPURGE () { - // Check expired rallyes (hard-coded 3 days limit for displaying expired rallyes!) - purgeExpiredReferalRallyes(); -} - // [EOF] ?> diff --git a/inc/libs/register_functions.php b/inc/libs/register_functions.php index 9153021f77..85af2723d9 100644 --- a/inc/libs/register_functions.php +++ b/inc/libs/register_functions.php @@ -130,31 +130,6 @@ function registerOutputFailedMessage ($messageId, $extra='') { } } -// Run a filter for must-fillout fields -function FILTER_REGISTER_MUST_FILLOUT ($content) { - // Get all fields for output - $result = SQL_QUERY('SELECT `field_name`, `field_required` FROM `{?_MYSQL_PREFIX?}_must_register` ORDER BY `id` ASC', - __FUNCTION__, __LINE__); - - // Walk through all entries - while ($row = SQL_FETCHARRAY($result)) { - // Must the user fill out this element? - $value = ''; - if ($row['field_required'] == 'Y') { - $value = '(*)'; - } // END - if - - // Add it - $content['must_fillout_' . strtolower($row['field_name']) . ''] = $value; - } // END - while - - // Free memory - SQL_FREERESULT($result); - - // Return it - return $content; -} - // Checks wether the registration data is complete function isRegistrationDataComplete () { // Init elements diff --git a/inc/libs/removeip_functions.php b/inc/libs/removeip_functions.php index afb9e0265b..7c9b07acce 100644 --- a/inc/libs/removeip_functions.php +++ b/inc/libs/removeip_functions.php @@ -141,20 +141,5 @@ function addAnonymityLevel () { return loadTemplate('removeip_level', true, $message); } -// Filter for adding anonymity notice to the output stream -function FILTER_ADD_ANONYMITY_NOTICE ($data) { - // Init content - $content = $data; - - // Extension removeip activated? - if ((isExtensionActive('removeip')) && (getConfig('removeip_'.strtolower($data['access_level']).'_show') == 'Y')) { - // Add anoymity/privacy infos - $content['content'] .= addAnonymityLevel() . "
\n"; - } // END - if - - // Return it - return $content; -} - // [EOF] ?> diff --git a/inc/libs/theme_functions.php b/inc/libs/theme_functions.php index 177ac8f66b..6ee3384fd7 100644 --- a/inc/libs/theme_functions.php +++ b/inc/libs/theme_functions.php @@ -303,42 +303,5 @@ function getThemeId ($name) { return $id; } -//----------------------------------------------------------------------------- -// Only filter functions -//----------------------------------------------------------------------------- - -// Filter for generic handling of theme change -function FILTER_HANDLE_THEME_CHANGE () { - // Check if new theme is selcted - if ((isPostRequestParameterSet('new_theme')) && (postRequestParameter('new_theme') != getCurrentTheme())) { - // Set new theme for guests - $newTheme = postRequestParameter('new_theme'); - - // Change to new theme - setTheme($newTheme); - - // Remove current from array - removeIncludeFromPool('theme', sprintf("theme/%s/theme.php", getCurrentTheme())); - - // Add new theme - addIncludeToPool('theme', sprintf("theme/%s/theme.php", $newTheme)); - - // Redirect to same URL - redirectToRequestUri(); - } // END - if -} - -// Filter for settings theme from user profile, must be executed only if FILTER_FETCH_USER_DATA() ran before -function FILTER_SET_USERS_THEME () { - // 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 - - // Change to new theme - setTheme(getUserData('curr_theme')); -} - // [EOF] ?> diff --git a/inc/libs/timezone_functions.php b/inc/libs/timezone_functions.php index 5250e1a207..fa77f98fbe 100644 --- a/inc/libs/timezone_functions.php +++ b/inc/libs/timezone_functions.php @@ -40,14 +40,5 @@ if (!defined('__SECURITY')) { die(); } // END - if -// Filter for setting the timezone -function FILTER_INIT_TIMEZONE () { - // Just set it if the required function is there - if (function_exists('date_default_timezone_set')) { - // CFG: TIME-ZONE - date_default_timezone_set(getConfig('timezone')); - } // END - if -} - // [EOF] ?> diff --git a/inc/libs/uberwach_functions.php b/inc/libs/uberwach_functions.php index b7d19a289f..4b35731c90 100644 --- a/inc/libs/uberwach_functions.php +++ b/inc/libs/uberwach_functions.php @@ -46,14 +46,5 @@ function loadUberwachSnippet () { $GLOBALS['page_footer'] .= loadTemplate('uberwach_snippet', true); } -// Filter for displaying uberwach snippet -function FILTER_DISPLAY_UBERWACH_SNIPPET () { - // Shall we include the uberwach snippet? - if ((!isGetRequestParameterSet('frame')) && (isExtensionActive('uberwach')) && (getModule() != 'admin') && ($GLOBALS['header_sent'] == 2)) { - // Then display it here - loadUberwachSnippet(); - } // END - if -} - // [EOF] ?> -- 2.39.5