+// Filter for auto-activation of a extension
+function FILTER_AUTO_ACTIVATE_EXTENSION ($data) {
+ // Is this extension always activated?
+ if (EXT_GET_ALWAYS_ACTIVE() == 'Y') {
+ // Then activate the extension
+ //* DEBUG: */ echo __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): ext_name={$data['ext_name']}<br />\n";
+ ACTIVATE_EXTENSION($data['ext_name']);
+ } // END - if
+
+ // Return the data
+ return $data;
+}
+
+// Filter for solving task given task
+function FILTER_SOLVE_TASK ($data) {
+ // Don't solve anything if no admin!
+ if (!IS_ADMIN()) return $data;
+
+ // Is this a direct task id or array element task_id is found?
+ if (is_int($data)) {
+ // Then solve it...
+ ADMIN_SOLVE_TASK($data);
+ } elseif ((is_array($data)) && (isset($data['task_id']))) {
+ // Solve it...
+ ADMIN_SOLVE_TASK($data['task_id']);
+ }
+
+ // Return the data
+ return $data;
+}
+
+// Filter to load include files
+function FILTER_LOAD_INCLUDES () {
+ // Default is $data as inclusion list
+ $data = GET_INC_POOL();
+
+ // Is it an array?
+ if ((!isset($data)) || (!is_array($data))) {
+ // Then abort here
+ debug_report_bug(sprintf("INC_POOL is no array! Type: %s", gettype($data)));
+ } elseif (isset($data['inc_pool'])) {
+ // Use this as new inclusion pool!
+ SET_INC_POOL($data['inc_pool']);
+ }
+
+ // Check for added include files
+ if (COUNT_INC_POOL() > 0) {
+ // Loads every include file
+ foreach (GET_INC_POOL() as $FQFN) {
+ loadIncludeOnce($FQFN);
+ } // END - foreach
+
+ // Reset array
+ INIT_INC_POOL();
+ } // END - if
+
+ // Continue with processing
+ return $data;
+}
+
+// Filter for running SQL commands
+function FILTER_RUN_SQLS ($data) {
+ // Debug message
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "- Entered!");
+
+ // Is the array there?
+ if ((IS_SQLS_VALID()) && ((!isset($data['dry_run'])) || ($data['dry_run'] == false))) {
+ // Run SQL commands
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "- Found ".COUNT_SQLS()." queries to run.");
+ foreach (GET_SQLS() as $sql) {
+ // Trim spaces away
+ $sql = trim($sql);
+
+ // Is there still a query left?
+ if (!empty($sql)) {
+ // Do we have an "ALTER TABLE" command?
+ if (substr(strtolower($sql), 0, 11) == "alter table") {
+ // Analyse the alteration command
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Alterting table: {$sql}");
+ SQL_ALTER_TABLE($sql, __FUNCTION__, __LINE__);
+ } else {
+ // Run regular SQL command
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Running regular query: {$sql}");
+ SQL_QUERY($sql, __FUNCTION__, __LINE__, false);
+ }
+ } // END - if
+ } // END - foreach
+ } // END - if
+
+ // Debug message
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "- Left!");
+}
+
+// Filter for updating/validating login data
+function FILTER_UPDATE_LOGIN_DATA () {
+ // Add missing array
+ if ((!isset($GLOBALS['last'])) || (!is_array($GLOBALS['last']))) $GLOBALS['last'] = array();
+
+ // Recheck if logged in
+ if (!IS_MEMBER()) return false;
+
+ // Secure user ID
+ setUserId(getSession('userid'));
+
+ // Load last module and last online time
+ $result = SQL_QUERY_ESC("SELECT `last_module`, `last_online` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
+ array(getUserId()), __FUNCTION__, __LINE__);
+
+ // Entry found?
+ if (SQL_NUMROWS($result) == 1) {
+ // Load last module and online time
+ $DATA = SQL_FETCHARRAY($result);
+
+ // Maybe first login time?
+ if (empty($DATA['last_module'])) $DATA['last_module'] = 'login';
+
+ // This will be displayed on welcome page! :-)
+ if (empty($GLOBALS['last']['module'])) {
+ $GLOBALS['last']['module'] = $DATA['last_module']; $GLOBALS['last']['online'] = $DATA['last_online'];
+ } // END - if
+
+ // 'what' not set?
+ if (!isWhatSet()) {
+ // Fix it to default
+ setWhat('welcome');
+ if (getConfig('index_home') != '') setWhatFromConfig('index_home');
+ } // END - if
+
+ // Update last module / online time
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `last_module`='%s', `last_online`=UNIX_TIMESTAMP(), `REMOTE_ADDR`='%s' WHERE `userid`=%s LIMIT 1",
+ array(
+ getWhat(),
+ detectRemoteAddr(),
+ getUserId()
+ ), __FUNCTION__, __LINE__);
+ } else {
+ // Destroy session, we cannot update!
+ destroyUserSession();
+ }
+
+ // Free the result
+ SQL_FREERESULT($result);
+}
+
+// Filter for checking admin ACL
+function FILTER_CHECK_ADMIN_ACL () {
+ // Extension not installed so it's always allowed to access everywhere!
+ $ret = true;
+
+ // Ok, Cookie-Update done
+ if ((GET_EXT_VERSION('admins') >= '0.3.0') && (EXT_IS_ACTIVE('admins'))) {
+ // Check if action GET variable was set
+ $action = getAction();
+ if (isWhatSet()) {
+ // Get action value by what-value
+ $action = getModeAction('admin', getWhat());
+ } // END - if
+
+ // Check for access control line of current menu entry
+ $ret = adminsCheckAdminAcl($action, getWhat());
+ } // END - if
+
+ // Return result
+ return $ret;
+}
+
+// Filter for initializing randomizer
+function FILTER_INIT_RANDOMIZER () {
+ // Simply init the randomizer with seed and _ADD value
+ mt_srand(generateSeed() + getConfig('_ADD'));
+}
+
+// Filter for removing updates
+function FILTER_REMOVE_UPDATES () {
+ // Init removal list
+ EXT_INIT_REMOVAL_LIST();
+
+ // Add the current extension to it
+ EXT_ADD_CURRENT_TO_REMOVAL_LIST();
+
+ // Simply remove it
+ UNSET_EXT_SQLS();
+
+ // Do we need to remove update depency?
+ if (EXT_COUNT_UPDATE_DEPENDS() > 0) {
+ // Then find all updates we shall no longer execute
+ foreach (EXT_GET_UPDATE_DEPENDS() as $id=>$ext_name) {
+ // Shall we remove this update?
+ if (in_array($ext_name, EXT_GET_REMOVAL_LIST())) {
+ // Then remove this extension!
+ EXT_REMOVE_UPDATE_DEPENDS($ext_name);
+ } // END - if
+ } // END - foreach
+ } // END - if
+}
+
+// Determines username for current user state
+function FILTER_DETERMINE_USERNAME () {
+ global $username;
+
+ // Check if logged in
+ if (IS_MEMBER()) {
+ // Is still logged in so we welcome him with his name
+ $result = SQL_QUERY_ESC("SELECT `surname`, `family` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
+ array(getUserId()), __FILE__, __LINE__);
+ if (SQL_NUMROWS($result) == 1) {
+ // Load surname and family's name and build the username
+ list($s, $f) = SQL_FETCHROW($result);
+ $username = $s . ' ' . $f;
+
+ // Additionally admin?
+ if (IS_ADMIN()) {
+ // Add it
+ $username .= ' ({--_ADMIN_SHORT--})';
+ } // END - if
+ } else {
+ // Hmmm, logged in and no valid userid?
+ $username = '<em>{--_UNKNOWN--}</em>';
+
+ // Destroy session
+ destroyUserSession();
+
+ // Kill userid
+ setUserId(0);
+ }
+
+ // Free memory
+ SQL_FREERESULT($result);
+ } elseif (IS_ADMIN()) {
+ // Admin is there
+ $username = getMessage('_ADMIN');