X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Ffilters.php;h=3ef321ce3234673aef4bbefeb043c8c86e51c0e2;hb=7c9cf221f2f7ef99d45fc233bf346c9f9168ef3e;hp=8ebe34f0c6a24180a9b0122cd1c194b42d9b47b7;hpb=1e6e1b8fbc79df082c8463f3e7eb72ae4761287c;p=mailer.git
diff --git a/inc/filters.php b/inc/filters.php
index 8ebe34f0c6..3ef321ce32 100644
--- a/inc/filters.php
+++ b/inc/filters.php
@@ -38,13 +38,13 @@ if (!defined('__SECURITY')) {
}
// Init "generic filter system"
-function INIT_FILTER_SYSTEM() {
+function INIT_FILTER_SYSTEM () {
global $filters, $loadedFilters, $counter;
// Is the filter already initialized?
if ((isset($filters)) && (is_array($filters))) {
// Then abort here
- ADD_FATAL(FILTER_FAILED_ALREADY_INIT);
+ addFatalMessage(FILTER_FAILED_ALREADY_INIT);
return false;
} // END - if
@@ -70,7 +70,7 @@ function INIT_FILTER_SYSTEM() {
// Load all active filers
$result = SQL_QUERY("SELECT `filter_name`, `filter_function`, `filter_active`".$ADD."
-FROM `"._MYSQL_PREFIX."_filters`
+FROM `{!_MYSQL_PREFIX!}_filters`
ORDER BY `filter_id` ASC", __FILE__, __LINE__);
// Are there entries?
@@ -105,7 +105,7 @@ ORDER BY `filter_id` ASC", __FILE__, __LINE__);
// Init filters
REGISTER_FILTER('init', 'UPDATE_LOGIN_DATA');
- // Login failtures handler
+ // Login failures handler
REGISTER_FILTER('post_youhere_line', 'CALL_HANDLER_LOGIN_FAILTURES');
// Filters for pre-extension-registration
@@ -143,7 +143,7 @@ function REGISTER_FILTER ($filterName, $filterFunction, $silentAbort = true, $fo
if ((isset($filters[$filterName][$filterFunction])) && (!$force)) {
// Then abort here
if (!$silentAbort) {
- ADD_FATAL(sprintf(FILTER_FAILED_ALREADY_ADDED, $filterFunction, $filterName));
+ addFatalMessage(sprintf(FILTER_FAILED_ALREADY_ADDED, $filterFunction, $filterName));
} // END - if
// Abort here
@@ -153,7 +153,7 @@ function REGISTER_FILTER ($filterName, $filterFunction, $silentAbort = true, $fo
// Is the function there?
if (!function_exists($filterFunction)) {
// Then abort here
- ADD_FATAL(sprintf(FILTER_FAILED_NOT_FOUND, $filterFunction, $filterName));
+ addFatalMessage(sprintf(FILTER_FAILED_NOT_FOUND, $filterFunction, $filterName));
return false;
} // END - if
@@ -177,7 +177,7 @@ function UNREGISTER_FILTER ($filterName, $filterFunction, $force = false, $dry_r
// Is that filter there?
if ((!isset($filters[$filterName][$filterFunction])) && (!$force)) {
// Not found, so abort here
- ADD_FATAL(sprintf(FILTER_FAILED_NOT_REMOVED, $filterFunction, $filterName));
+ addFatalMessage(sprintf(FILTER_FAILED_NOT_REMOVED, $filterFunction, $filterName));
return false;
} // END - if
@@ -198,7 +198,7 @@ function RUN_FILTER ($filterName, $data = null, $silentAbort = true) {
// Then abort here (quick'N'dirty hack)
if ((!$silentAbort) && (defined('FILTER_FAILED_NO_FILTER_FOUND'))) {
// Add fatal message
- ADD_FATAL(sprintf(FILTER_FAILED_NO_FILTER_FOUND, $filterName));
+ addFatalMessage(sprintf(FILTER_FAILED_NO_FILTER_FOUND, $filterName));
} // END - if
// Abort here
@@ -250,7 +250,7 @@ function FILTER_FLUSH_FILTERS () {
// Is a database link here and not in installation mode?
if ((!is_resource($link)) && (!isBooleanConstantAndTrue('mxchange_installing'))) {
// Abort here
- ADD_FATAL(sprintf(FILTER_FLUSH_FAILED_NO_DATABASE, $filterFunction, $filterName));
+ addFatalMessage(sprintf(FILTER_FLUSH_FAILED_NO_DATABASE, $filterFunction, $filterName));
return false;
} // END - if
@@ -264,8 +264,8 @@ function FILTER_FLUSH_FILTERS () {
$inserted = 0; $removed = 0;
// Prepare SQL queries
- $insertSQL = "INSERT INTO `"._MYSQL_PREFIX."_filters` (`filter_name`,`filter_function`,`filter_active`) VALUES";
- $removeSQL = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_filters` WHERE";
+ $insertSQL = "INSERT INTO `{!_MYSQL_PREFIX!}_filters` (`filter_name`,`filter_function`,`filter_active`) VALUES";
+ $removeSQL = "DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_filters` WHERE";
// Write all filters to database
foreach ($filters as $filterName => $filterArray) {
@@ -309,7 +309,7 @@ function FILTER_FLUSH_FILTERS () {
// Walk through all filters
foreach ($filterArray as $filterFunction => $cnt) {
// Construct and add the query
- $SQLs[] = sprintf("UPDATE `"._MYSQL_PREFIX."_filters` SET `filter_counter`=%s WHERE `filter_name`='%s' AND `filter_function`='%s' LIMIT 1",
+ $SQLs[] = sprintf("UPDATE `{!_MYSQL_PREFIX!}_filters` SET `filter_counter`=%s WHERE `filter_name`='%s' AND `filter_function`='%s' LIMIT 1",
bigintval($cnt),
$filterName,
$filterFunction
@@ -322,7 +322,7 @@ function FILTER_FLUSH_FILTERS () {
RUN_FILTER('run_sqls', array('dry_run' => false, 'sqls' => $SQLs));
}
-// Filter for calling the handler for login failtures
+// Filter for calling the handler for login failures
function FILTER_CALL_HANDLER_LOGIN_FAILTURES ($data) {
// Init content
$content = $data;
@@ -330,7 +330,7 @@ function FILTER_CALL_HANDLER_LOGIN_FAILTURES ($data) {
// Handle failed logins here if not in guest
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):type={$data['type']},action={$GLOBALS['action']},what={$GLOBALS['what']},lvl={$data['access_level']}
\n";
if ((($data['type'] == "what") || ($data['type'] == "action") && ((!isset($GLOBALS['what'])) || ($GLOBALS['what'] == "overview") || ($GLOBALS['what'] == getConfig('index_home')))) && ($data['access_level'] != "guest") && ((GET_EXT_VERSION("sql_patches") >= "0.4.7") || (GET_EXT_VERSION("admins") >= "0.7.0"))) {
- // Handle failture
+ // Handle failure
$content['content'] .= HANDLE_LOGIN_FAILTURES($data['access_level']);
} // END - if
@@ -450,40 +450,40 @@ function FILTER_UPDATE_LOGIN_DATA () {
// Secure user ID
$GLOBALS['userid'] = bigintval(get_session('userid'));
- // Extract last online time (life) and how long is auto-login valid (time)
- $newl = time() + bigintval(get_session('lifetime'));
-
// 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($GLOBALS['userid']), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT last_module, last_online FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
+ array($GLOBALS['userid']), __FILE__, __LINE__);
+
+ // Entry found?
if (SQL_NUMROWS($result) == 1) {
// Load last module and online time
list($mod, $onl) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
// Maybe first login time?
if (empty($mod)) $mod = "login";
- if (set_session("userid", $GLOBALS['userid'], $newl, COOKIE_PATH) && set_session("u_hash", get_session('u_hash'), $newl, COOKIE_PATH) && set_session("lifetime", bigintval(get_session('lifetime')), $newl, COOKIE_PATH)) {
- // This will be displayed on welcome page! :-)
- if (empty($LAST['module'])) {
- $LAST['module'] = $mod; $LAST['online'] = $onl;
- } // END - if
+ // This will be displayed on welcome page! :-)
+ if (empty($LAST['module'])) {
+ $LAST['module'] = $mod; $LAST['online'] = $onl;
+ } // END - if
- // "what" not set?
- if (empty($GLOBALS['what'])) {
- // Fix it to default
- $GLOBALS['what'] = "welcome";
- if (getConfig('index_home') != "") $GLOBALS['what'] = getConfig('index_home');
- } // END - if
+ // "what" not set?
+ if (empty($GLOBALS['what'])) {
+ // Fix it to default
+ $GLOBALS['what'] = "welcome";
+ if (getConfig('index_home') != "") $GLOBALS['what'] = getConfig('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($GLOBALS['what'], GET_REMOTE_ADDR(), $GLOBALS['userid']), __FILE__, __LINE__);
- }
+ // 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($GLOBALS['what'], GET_REMOTE_ADDR(), $GLOBALS['userid']), __FILE__, __LINE__);
} else {
// Destroy session, we cannot update!
destroy_user_session();
}
+
+ // Free the result
+ SQL_FREERESULT($result);
}
// Filter for checking admin ACL
@@ -492,7 +492,7 @@ function FILTER_CHECK_ADMIN_ACL () {
$ret = true;
// Ok, Cookie-Update done
- if ((EXT_IS_ACTIVE("admins")) && (GET_EXT_VERSION("admins") > "0.2")) {
+ if (GET_EXT_VERSION("admins") >= "0.3") {
// Check if action GET variable was set
$action = SQL_ESCAPE($GLOBALS['action']);
if (!empty($GLOBALS['what'])) {