X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffilters.php;h=db886a0d651df3c432abe16812a198e50baef5c9;hb=ca788fbec7763e4d61e918b6c8a7bc03f2e043e9;hp=5f9fa665c497d402768a257adfa84ae2a8fc1b83;hpb=3f51c40f4fede87228216f9285b745a339e3891d;p=mailer.git
diff --git a/inc/filters.php b/inc/filters.php
index 5f9fa665c4..db886a0d65 100644
--- a/inc/filters.php
+++ b/inc/filters.php
@@ -123,6 +123,7 @@ ORDER BY `filter_id` ASC", __FUNCTION__, __LINE__);
// Init filters
registerFilter('init', 'UPDATE_LOGIN_DATA');
registerFilter('init', 'INIT_RANDOMIZER');
+ registerFilter('init', 'DETERMINE_USERNAME');
// Login failures handler
registerFilter('post_youhere_line', 'CALL_HANDLER_LOGIN_FAILTURES');
@@ -306,7 +307,7 @@ function FILTER_FLUSH_FILTERS () {
// Add this filter (all filters are active by default)
$insertSQL .= sprintf("('%s','%s','Y'),", $filterName, $filterFunction);
$inserted++;
- } elseif ($active == "R") {
+ } elseif ($active == 'R') {
// Remove this filter
$removeSQL .= sprintf(" (`filter_name`='%s' AND `filter_function`='%s') OR", $filterName, $filterFunction);
$removed++;
@@ -326,7 +327,7 @@ function FILTER_FLUSH_FILTERS () {
// Something has been removed?
if ($removed > 0) {
// Finish SQL command
- $removeSQL = substr($removeSQL, 0, -2) . "LIMIT ".$removed;
+ $removeSQL = substr($removeSQL, 0, -2) . 'LIMIT '.$removed;
// And run it
ADD_SQL($removeSQL);
@@ -358,7 +359,7 @@ function FILTER_CALL_HANDLER_LOGIN_FAILTURES ($data) {
$content = $data;
// Handle failed logins here if not in guest
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):type={$data['type']},action={getAction()},what={getWhat()},lvl={$data['access_level']}
\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):type={$data['type']},action={getAction()},what={getWhat()},lvl={$data['access_level']}
");
if ((($data['type'] == 'what') || ($data['type'] == 'action') && ((!isWhatSet()) || (getWhat() == 'overview') || (getWhat() == getConfig('index_home')))) && ($data['access_level'] != 'guest') && ((GET_EXT_VERSION('sql_patches') >= '0.4.7') || (GET_EXT_VERSION('admins') >= '0.7.0'))) {
// Handle failure
$content['content'] .= HANDLE_LOGIN_FAILTURES($data['access_level']);
@@ -388,7 +389,7 @@ function FILTER_AUTO_ACTIVATE_EXTENSION ($data) {
// Is this extension always activated?
if (EXT_GET_ALWAYS_ACTIVE() == 'Y') {
// Then activate the extension
- //* DEBUG: */ echo __FUNCTION__."(".__LINE__."): ext_name={$data['ext_name']}
\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."): ext_name={$data['ext_name']}
");
ACTIVATE_EXTENSION($data['ext_name']);
} // END - if
@@ -446,12 +447,12 @@ function FILTER_LOAD_INCLUDES () {
// Filter for running SQL commands
function FILTER_RUN_SQLS ($data) {
// Debug message
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " - Entered!");
+ //* 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.");
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "- Found ".COUNT_SQLS()." queries to run.");
foreach (GET_SQLS() as $sql) {
// Trim spaces away
$sql = trim($sql);
@@ -473,7 +474,7 @@ function FILTER_RUN_SQLS ($data) {
} // END - if
// Debug message
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " - Left!");
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "- Left!");
}
// Filter for updating/validating login data
@@ -488,20 +489,20 @@ function FILTER_UPDATE_LOGIN_DATA () {
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",
+ $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
- list($mod, $onl) = SQL_FETCHROW($result);
+ $DATA = SQL_FETCHARRAY($result);
// Maybe first login time?
- if (empty($mod)) $mod = 'login';
+ if (empty($DATA['last_module'])) $DATA['last_module'] = 'login';
// This will be displayed on welcome page! :-)
if (empty($GLOBALS['last']['module'])) {
- $GLOBALS['last']['module'] = $mod; $GLOBALS['last']['online'] = $onl;
+ $GLOBALS['last']['module'] = $DATA['last_module']; $GLOBALS['last']['online'] = $DATA['last_online'];
} // END - if
// 'what' not set?
@@ -512,8 +513,12 @@ function FILTER_UPDATE_LOGIN_DATA () {
} // 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__);
+ 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();
@@ -575,5 +580,46 @@ function FILTER_REMOVE_UPDATES () {
} // 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 = '{--_UNKNOWN--}';
+
+ // Destroy session
+ destroyUserSession();
+
+ // Kill userid
+ setUserId(0);
+ }
+
+ // Free memory
+ SQL_FREERESULT($result);
+ } elseif (IS_ADMIN()) {
+ // Admin is there
+ $username = getMessage('_ADMIN');
+ } else {
+ // He's a guest, hello there... ;-)
+ $username = getMessage('_GUEST');
+ }
+}
+
//
?>