From: Roland Häder Date: Thu, 10 Jan 2013 02:40:24 +0000 (+0000) Subject: Filters for configurable userid exclusion added: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4f7df133f736da124e6f7bd02008b9093f736451;p=mailer.git Filters for configurable userid exclusion added: - Rewrote some if() blocks to a filter to exclude configured userids, if set - Closed internal TODO (see above) - Added SQL columns/aliases/table names in back-ticks (missed some) - TODOs.txt updated --- diff --git a/.gitattributes b/.gitattributes index 5e8fa5d7e3..4ce171147d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -257,6 +257,7 @@ inc/filter/booking_filter.php svneol=native#text/plain inc/filter/cache_filter.php svneol=native#text/plain inc/filter/country_filter.php svneol=native#text/plain inc/filter/coupon_filter.php svneol=native#text/plain +inc/filter/doubler_filter.php svneol=native#text/plain inc/filter/earning_filter.php svneol=native#text/plain inc/filter/forced_filter.php svneol=native#text/plain inc/filter/mediadata_filter.php svneol=native#text/plain diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 71b11c870b..0d50e6453b 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -1,13 +1,13 @@ ### WARNING: THIS FILE IS AUTO-GENERATED BY ../../contrib/todo-builder.sh (uid=/user=quix0r) ### ### DO NOT EDIT THIS FILE. ### ./api.php:68:// @TODO Do stuff here -./autoreg.php:58:// @TODO Add processing of request here +./autoreg.php:62:// @TODO Add processing of request here ./beg.php:175: // @TODO Opps, what is missing here??? ./cron.php:62:// @TODO Do stuff here ./inc/classes/cachesystem.class.php:516: // @TODO Add support for more types which break in last else-block -./inc/config-functions.php:149: // @TODO Make this all better... :-/ -./inc/config-functions.php:325: // @TODO Call setConfigEntry() somehow -./inc/config-functions.php:353: // @TODO Call setConfigEntry() somehow +./inc/config-functions.php:150: // @TODO Make this all better... :-/ +./inc/config-functions.php:326: // @TODO Call setConfigEntry() somehow +./inc/config-functions.php:354: // @TODO Call setConfigEntry() somehow ./inc/daily/daily_beg.php:52:// @TODO This should be converted in a daily beg rallye ./inc/daily/daily_birthday.php:99: // @TODO 4 is hard-coded here, should we move it out in config? ./inc/email-functions.php:113: * @TODO Rewrite this to an extension 'smtp' @@ -42,7 +42,7 @@ ./inc/extensions/ext-network.php:97: // @TODO network_type_handler is an internal name and needs documentation ./inc/extensions/ext-newsletter.php:218: // @TODO Move these into configuration ./inc/extensions/ext-nickname.php:52: // @TODO NOT NULL DEFAULT '' is bad practice, use NULL -./inc/extensions/ext-yoomedia.php:121: // @TODO Can this be moved into a database table? +./inc/extensions/ext-yoomedia.php:120: // @TODO Can this be moved into a database table? ./inc/extensions/ext-yoomedia.php:54:// @TODO Only deprecated when 'ext-network' is ready! setExtensionDeprecated('Y'); ./inc/extensions-functions.php:2169: // @TODO Is this really neccessary? ./inc/extensions-functions.php:2220:// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable' @@ -77,6 +77,7 @@ ./inc/language/refback_de.php:51: // @TODO Rewrite these constants to one ./inc/libs/admins_functions.php:537: // @TODO This can be, somehow, rewritten ./inc/libs/bonus_functions.php:195: // @TODO Move this HTML to a template +./inc/libs/doubler_functions.php:130:// @TODO This could be rewritten to a filter ./inc/libs/doubler_functions.php:44:// @TODO Lame description ./inc/libs/doubler_functions.php:96: // @TODO Can't this be moved into EL? ./inc/libs/forced_functions.php:457:// @TODO Can't we use our new expression language instead of this ugly code? @@ -139,9 +140,9 @@ ./inc/modules/admin/what-list_mods.php:55: // @TODO This can be moved into mysql-function.php, see checkModulePermissions() function ./inc/modules/admin/what-list_rallye_prices.php:222: // @TODO Rewrite these two constants ./inc/modules/admin/what-list_refs.php:101: // @TODO Try to rewrite some to EL -./inc/modules/admin/what-list_unconfirmed.php:114: // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus -./inc/modules/admin/what-list_unconfirmed.php:84: // @TODO This constant might be unused? define('__LIST_UNCON_TITLE', '{--ADMIN_LIST_UNCONFIRMED_BONUS_LINKS--}'); -./inc/modules/admin/what-list_unconfirmed.php:87: // @TODO `id` has been used two times??? +./inc/modules/admin/what-list_unconfirmed.php:120: // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus +./inc/modules/admin/what-list_unconfirmed.php:90: // @TODO This constant might be unused? define('__LIST_UNCON_TITLE', '{--ADMIN_LIST_UNCONFIRMED_BONUS_LINKS--}'); +./inc/modules/admin/what-list_unconfirmed.php:93: // @TODO `id` has been used two times??? ./inc/modules/admin/what-list_user_cats.php:54: // @TODO No longer needed? define('__CATEGORIES_BASE' , ' not working here ./inc/template-functions.php:1095: // @TODO Deprecate this thing @@ -198,8 +198,8 @@ ./inc/template-functions.php:209: * @TODO On some pages this is buggy ./inc/template-functions.php:298: // @TODO Remove these sanity checks if all is fine ./inc/template-functions.php:747: // @TODO $userid is deprecated and should be removed from loadEmailTemplate() and replaced with $content[userid] in all templates -./inc/wrapper-functions.php:3197: // @TODO Find a way to not use direct module comparison -./inc/wrapper-functions.php:512:// @TODO Do some more sanity check here +./inc/wrapper-functions.php:3209: // @TODO Find a way to not use direct module comparison +./inc/wrapper-functions.php:524:// @TODO Do some more sanity check here ./inc/xml-functions.php:240: // @TODO Handle characters ./mailid.php:101: // @TODO Rewrite this to a filter ./mailid.php:144: // @TODO Rewrite this to a filter diff --git a/birthday_confirm.php b/birthday_confirm.php index 20e2f6eeab..607dd32c9e 100644 --- a/birthday_confirm.php +++ b/birthday_confirm.php @@ -62,16 +62,22 @@ $chk = bigintval(getRequestElement('check'), FALSE); // Check if link is not clicked so far $result = SQL_QUERY_ESC("SELECT - b.`points`, d.`userid`, d.`gender`, d.`surname`, d.`family`, d.`status`, d.`ref_payout` + `b`.`points`, + `d`.`userid`, + `d`.`gender`, + `d`.`surname`, + `d`.`family`, + `d`.`status`, + `d`.`ref_payout` FROM - `{?_MYSQL_PREFIX?}_user_birthday` AS b + `{?_MYSQL_PREFIX?}_user_birthday` AS `b` INNER JOIN - `{?_MYSQL_PREFIX?}_user_data` AS d + `{?_MYSQL_PREFIX?}_user_data` AS `d` ON - b.`userid`=d.`userid` + `b`.`userid`=`d`.`userid` WHERE - b.`userid`=%s AND - b.`chk_value`='%s' + `b`.`userid`=%s AND + `b`.`chk_value`='%s' LIMIT 1", array( $userid, diff --git a/inc/config-global.php b/inc/config-global.php index 6f0a13063b..ed79da2d75 100644 --- a/inc/config-global.php +++ b/inc/config-global.php @@ -53,7 +53,7 @@ if (function_exists('date_default_timezone_set')) { // CFG: ERROR-REPORTING error_reporting(E_ALL | E_DEPRECATED | E_STRICT); -// Is the function there? (removed in PHP 5.4.x) +// Is the function there? (removed in PHP 5.4.0) if (function_exists('import_request_variables')) { // CFG: REGISTER-GLOBALS @import_request_variables(''); diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index 85fb758195..d60af72c9d 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -1126,7 +1126,7 @@ function determineExtensionTaskId ($ext_name) { $data['task_id'] = NULL; // Search for extension task's id - $result = SQL_QUERY_ESC("SELECT `id` AS task_id FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `task_type`='EXTENSION' AND `subject`='[%s:]' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `id` AS `task_id` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `task_type`='EXTENSION' AND `subject`='[%s:]' LIMIT 1", array($ext_name), __FUNCTION__, __LINE__); // Entry found? @@ -1148,7 +1148,7 @@ function determineTaskIdBySubject ($subject) { $data['task_id'] = '0'; // Search for task id - $result = SQL_QUERY_ESC("SELECT `id` AS task_id FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `subject` LIKE '%s%%' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `id` AS `task_id` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `subject` LIKE '%s%%' LIMIT 1", array($subject), __FUNCTION__, __LINE__); // Entry found? diff --git a/inc/extensions/ext-beg.php b/inc/extensions/ext-beg.php index 12eb8f25ea..b9b1e522e0 100644 --- a/inc/extensions/ext-beg.php +++ b/inc/extensions/ext-beg.php @@ -41,10 +41,10 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('0.3.4'); +setThisExtensionVersion('0.3.5'); // Version history array (add more with , '0.0.1' and so on) -setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4')); +setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5')); switch (getExtensionMode()) { case 'register': // Do stuff when installation is running @@ -91,6 +91,7 @@ INDEX (`userid`)", // Unregister filter unregisterFilter(__FILE__, __LINE__, 'pre_user_registration', 'BEG_RALLYE_USER_REGISTRATION_ADD_SQL_COLUMNS', TRUE, isExtensionDryRun()); unregisterFilter(__FILE__, __LINE__, 'init', 'BEG_PURGE_IPS_NOTIFY_USER', TRUE, isExtensionDryRun()); + unregisterFilter(__FILE__, __LINE__, 'config_userid_exclusion_sql', 'EXCLUDE_BEG_USERID', TRUE, isExtensionDryRun()); break; case 'activate': // Do stuff when admin activates this extension @@ -366,6 +367,14 @@ INDEX (`userid`)", // Update notes setExtensionUpdateNotes("Verwendungszwecke für Referralgutgschriften registriert."); break; + + case '0.3.5': // SQL queries for v0.3.5 + // Register a filter + registerFilter(__FILE__, __LINE__, 'config_userid_exclusion_sql', 'EXCLUDE_BEG_USERID', FALSE, TRUE, isExtensionDryRun()); + + // Update notes + setExtensionUpdateNotes("Filter für das Ausschließen des konfigurierbaren Mitgliedaccounts hinzugefügt."); + break; } // END - switch break; diff --git a/inc/extensions/ext-bonus.php b/inc/extensions/ext-bonus.php index 04a8c9f431..49ec750262 100644 --- a/inc/extensions/ext-bonus.php +++ b/inc/extensions/ext-bonus.php @@ -41,10 +41,10 @@ if (!defined('__SECURITY')) { } // END - if // Version of this extension -setThisExtensionVersion('0.9.9'); +setThisExtensionVersion('1.0.0'); // Version history array (add more with , '0.0.1' and so on) -setExtensionVersionHistory(array('0.0.0', '0.1.6', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3', '0.6.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9', '0.7.0', '0.7.1', '0.7.2', '0.7.3', '0.7.4', '0.7.5', '0.7.6', '0.7.7', '0.7.8', '0.7.9', '0.8.0', '0.8.1', '0.8.2', '0.8.3', '0.8.4', '0.8.5', '0.8.6', '0.8.7', '0.8.8', '0.8.9', '0.9.0', '0.9.1', '0.9.2', '0.9.3', '0.9.4', '0.9.5', '0.9.6', '0.9.7', '0.9.8', '0.9.9')); +setExtensionVersionHistory(array('0.0.0', '0.1.6', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3', '0.6.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9', '0.7.0', '0.7.1', '0.7.2', '0.7.3', '0.7.4', '0.7.5', '0.7.6', '0.7.7', '0.7.8', '0.7.9', '0.8.0', '0.8.1', '0.8.2', '0.8.3', '0.8.4', '0.8.5', '0.8.6', '0.8.7', '0.8.8', '0.8.9', '0.9.0', '0.9.1', '0.9.2', '0.9.3', '0.9.4', '0.9.5', '0.9.6', '0.9.7', '0.9.8', '0.9.9', '1.0.0')); switch (getExtensionMode()) { case 'register': // Do stuff when installation is running @@ -97,6 +97,7 @@ INDEX (`cat_id`)", unregisterFilter(__FILE__, __LINE__, 'add_bonus_points_user_columns', 'ADD_BONUS_POINTS_USER_COLUMNS', TRUE, isExtensionDryRun()); unregisterFilter(__FILE__, __LINE__, 'pre_user_registration', 'BONUS_USER_REGISTRATION_ADD_SQL_COLUMNS', TRUE, isExtensionDryRun()); unregisterFilter(__FILE__, __LINE__, 'init', 'SEND_BONUS_NOTIFICATIONS', TRUE, isExtensionDryRun()); + unregisterFilter(__FILE__, __LINE__, 'config_userid_exclusion_sql', 'EXLCUDE_BONUS_USERID', TRUE, isExtensionDryRun()); break; case 'activate': // Do stuff when admin activates this extension @@ -653,6 +654,14 @@ ORDER BY // Update notes (these will be set as task text!) setExtensionUpdateNotes("Filter zum Hinzufügen von SQL-Spalten bei der Mitgliederanmeldung."); break; + + case '1.0.0': // SQL queries for v1.0.0 + // Register filter + registerFilter(__FILE__, __LINE__, 'config_userid_exclusion_sql', 'EXLCUDE_BONUS_USERID', FALSE, TRUE, isExtensionDryRun()); + + // Update notes (these will be set as task text!) + setExtensionUpdateNotes("Filter zum Ausschließen des konfigurierten Mitgliedaccounts."); + break; } // END - switch break; diff --git a/inc/extensions/ext-doubler.php b/inc/extensions/ext-doubler.php index aaef65a16b..79338de29f 100644 --- a/inc/extensions/ext-doubler.php +++ b/inc/extensions/ext-doubler.php @@ -41,10 +41,10 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('0.1.9'); +setThisExtensionVersion('0.2.0'); // Version history array (add more with , '0.0.1' and so on) -setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9')); +setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0')); switch (getExtensionMode()) { case 'register': // Do stuff when installation is running @@ -124,6 +124,9 @@ INDEX (`userid`)", // Unregister points data unregisterExtensionPointsData('doubler_direct'); unregisterExtensionPointsData('doubler_reset'); + + // Unregister filters + unregisterFilter(__FILE__, __LINE__, 'config_userid_exclusion_sql', 'EXLCUDE_DOUBLER_USERID', TRUE, isExtensionDryRun()); break; case 'activate': // Do stuff when admin activates this extension @@ -258,6 +261,14 @@ INDEX (`userid`)", // Update notes setExtensionUpdateNotes("Fehlender Konfigurationseintrag doubler_used hinzgefügt."); break; + + case '0.2.0': // SQL queries for v0.2.0 + // Register filter + registerFilter(__FILE__, __LINE__, 'config_userid_exclusion_sql', 'EXLCUDE_DOUBLER_USERID', FALSE, TRUE, isExtensionDryRun()); + + // Update notes (these will be set as task text!) + setExtensionUpdateNotes("Filter zum Ausschließen des konfigurierten Mitgliedaccounts."); + break; } // END - switch break; diff --git a/inc/extensions/ext-sql_patches.php b/inc/extensions/ext-sql_patches.php index 5f95f71384..b22c7a7be2 100644 --- a/inc/extensions/ext-sql_patches.php +++ b/inc/extensions/ext-sql_patches.php @@ -41,10 +41,10 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('0.9.6'); +setThisExtensionVersion('0.9.7'); // Version history array (add more with , '0.0.1' and so on) -setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3', '0.6.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9', '0.7.0', '0.7.1', '0.7.2', '0.7.3', '0.7.4', '0.7.5', '0.7.6', '0.7.7', '0.7.8', '0.7.9', '0.8.0', '0.8.1', '0.8.2', '0.8.3', '0.8.4', '0.8.5', '0.8.6', '0.8.7', '0.8.8', '0.8.9', '0.9.0', '0.9.1', '0.9.2', '0.9.3', '0.9.4', '0.9.5', '0.9.6')); +setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3', '0.6.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9', '0.7.0', '0.7.1', '0.7.2', '0.7.3', '0.7.4', '0.7.5', '0.7.6', '0.7.7', '0.7.8', '0.7.9', '0.8.0', '0.8.1', '0.8.2', '0.8.3', '0.8.4', '0.8.5', '0.8.6', '0.8.7', '0.8.8', '0.8.9', '0.9.0', '0.9.1', '0.9.2', '0.9.3', '0.9.4', '0.9.5', '0.9.6', '0.9.7')); // Keep this extension always active! setExtensionAlwaysActive('Y'); @@ -110,6 +110,7 @@ IN ( unregisterFilter(__FILE__, __LINE__, 'init', 'GENERATE_FILE_SECRET_HASH', TRUE, isExtensionDryRun()); unregisterFilter(__FILE__, __LINE__, 'extra_autopurge', 'SERVER_NAME_EXTRA_AUTOPURGE', TRUE, isExtensionDryRun()); unregisterFilter(__FILE__, __LINE__, 'determine_menu_mode', 'DETERMINE_MENU_MODE_GENERIC', TRUE, isExtensionDryRun()); + unregisterFilter(__FILE__, __LINE__, 'config_userid_exclusion_sql', 'EXCLUDE_DEFAULT_REFID', TRUE, isExtensionDryRun()); break; case 'activate': // Do stuff when admin activates this extension @@ -992,6 +993,14 @@ PRIMARY KEY (`server_name_id`) // Update notes (these will be set as task text!) setExtensionUpdateNotes("Filter hinzugefügt, der den Menümodus für weitere von dieser Erweiterung benutzten Module erkennen soll."); break; + + case '0.9.7': // SQL queries for v0.9.7 + // Register filter + registerFilter(__FILE__, __LINE__, 'config_userid_exclusion_sql', 'EXCLUDE_DEFAULT_REFID', FALSE, TRUE, isExtensionDryRun()); + + // Update notes (these will be set as task text!) + setExtensionUpdateNotes("Filter hinzugefügt, der die Standard-Referral-Id für SQL-Befehle ausschliesst."); + break; } // END - switch break; diff --git a/inc/filter/beg_filter.php b/inc/filter/beg_filter.php index 7c3cfc1c45..3909ce7e29 100644 --- a/inc/filter/beg_filter.php +++ b/inc/filter/beg_filter.php @@ -81,5 +81,17 @@ function FILTER_BEG_PURGE_IPS_NOTIFY_USER ($filterData) { return $filterData; } +// Filter to add exclusion SQL for configured userid +function FILTER_EXCLUDE_BEG_USERID ($filterData = array()) { + // Is it valid? + if (isValidId(getBegUserid())) { + // Exclude it + array_push($filterData, '{?beg_userid?}'); + } // END - if + + // Return it + return $filterData; +} + // [EOF] ?> diff --git a/inc/filter/bonus_filter.php b/inc/filter/bonus_filter.php index c86dda30de..c3ffe6d002 100644 --- a/inc/filter/bonus_filter.php +++ b/inc/filter/bonus_filter.php @@ -152,5 +152,17 @@ function FILTER_SEND_BONUS_NOTIFICATIONS ($filterData) { return $filterData; } +// Filter to add exclusion SQL for configured userid +function FILTER_EXLCUDE_BONUS_USERID ($filterData = array()) { + // Is it valid? + if (isValidId(getBonusUserid())) { + // Exclude it + array_push($filterData, '{?bonus_userid?}'); + } // END - if + + // Return it + return $filterData; +} + // [EOF] ?> diff --git a/inc/filter/doubler_filter.php b/inc/filter/doubler_filter.php new file mode 100644 index 0000000000..69ce8b30f1 --- /dev/null +++ b/inc/filter/doubler_filter.php @@ -0,0 +1,56 @@ + diff --git a/inc/filter/earning_filter.php b/inc/filter/earning_filter.php index 0b4bcace85..84d15f33f2 100644 --- a/inc/filter/earning_filter.php +++ b/inc/filter/earning_filter.php @@ -51,27 +51,27 @@ function FILTER_ADD_EARNING_GROUP_POPUP ($filterData) { // Now check if the user has subscription and amount left $result = SQL_QUERY_ESC("SELECT - d.`earning_id`, - d.`earning_provider`, - u.`earning_current_amount`, - u.`earning_daily_amount`, - u.`earning_active`, - u.`earning_added`, - u.`earning_canceled`, - u.`earning_points` + `d`.`earning_id`, + `d`.`earning_provider`, + `u`.`earning_current_amount`, + `u`.`earning_daily_amount`, + `u`.`earning_active`, + `u`.`earning_added`, + `u`.`earning_canceled`, + `u`.`earning_points` FROM - `{?_MYSQL_PREFIX?}_user_earning` AS u + `{?_MYSQL_PREFIX?}_user_earning` AS `u` INNER JOIN - `{?_MYSQL_PREFIX?}_earning_data` AS d + `{?_MYSQL_PREFIX?}_earning_data` AS `d` ON - u.`earning_id`=d.`earning_id` + `u`.`earning_id`=`d`.`earning_id` WHERE - u.`earning_userid`=%s AND - u.`earning_active`='Y' AND - u.`earning_current_amount` < u.`earning_daily_amount` AND - d.`earning_group`='POPUP' + `u`.`earning_userid`=%s AND + `u`.`earning_active`='Y' AND + `u`.`earning_current_amount` < `u`.`earning_daily_amount` AND + `d`.`earning_group`='POPUP' ORDER BY - d.`earning_sorting` ASC", + `d`.`earning_sorting` ASC", array( getMemberId() ), __FUNCTION__, __LINE__); diff --git a/inc/filter/rallye_filter.php b/inc/filter/rallye_filter.php index 2965cc5acc..2e9e84c33b 100644 --- a/inc/filter/rallye_filter.php +++ b/inc/filter/rallye_filter.php @@ -64,20 +64,20 @@ function FILTER_RALLYE_NOTIFY_USERS ($filterData) { // Check for new started but not notified rallyes $result = SQL_QUERY("SELECT SQL_SMALL_RESULT - d.`id`, - d.`title`, - d.`start_time`, - d.`end_time`, - d.`send_notify` + `d`.`id`, + `d`.`title`, + `d`.`start_time`, + `d`.`end_time`, + `d`.`send_notify` " . $sqlAddons['add'] . " FROM - `{?_MYSQL_PREFIX?}_rallye_data` AS d + `{?_MYSQL_PREFIX?}_rallye_data` AS `d` WHERE - d.`is_active`='Y' AND - d.`notified`='N' AND - d.`expired`='N' AND - d.`start_time` <= UNIX_TIMESTAMP() AND - d.`end_time` > UNIX_TIMESTAMP() + `d`.`is_active`='Y' AND + `d`.`notified`='N' AND + `d`.`expired`='N' AND + `d`.`start_time` <= UNIX_TIMESTAMP() AND + `d`.`end_time` > UNIX_TIMESTAMP() LIMIT 1", __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Start rallye @@ -89,19 +89,19 @@ LIMIT 1", __FILE__, __LINE__); // Check for expired rallyes $result = SQL_QUERY("SELECT SQL_SMALL_RESULT - d.`id`, - d.`title`, - d.`start_time`, - d.`end_time`, - d.`send_notify` + `d`.`id`, + `d`.`title`, + `d`.`start_time`, + `d`.`end_time`, + `d`.`send_notify` " . $sqlAddons['add'] . " FROM - `{?_MYSQL_PREFIX?}_rallye_data` AS d + `{?_MYSQL_PREFIX?}_rallye_data` AS `d` WHERE - d.`is_active`='Y' AND - d.`notified`='Y' AND - d.`expired`='N' AND - (d.`end_time` <= UNIX_TIMESTAMP()" . $sqlAddons['or'] . ") + `d`.`is_active`='Y' AND + `d`.`notified`='Y' AND + `d`.`expired`='N' AND + (`d`.`end_time` <= UNIX_TIMESTAMP()" . $sqlAddons['or'] . ") LIMIT 1", __FILE__, __LINE__); if ((SQL_NUMROWS($result) == 1) && (isExtensionActive('autopurge'))) { // End rallye here... @@ -124,7 +124,7 @@ function FILTER_ADD_RALLYE_SQL_COLUMNS ($filterData) { if (isExtensionInstalledAndNewer('rallye', '0.2.0')) { // Add more data on higher versions $filterData['add'] .= ',`min_users`, `min_prices`'; - $filterData['or'] .= ' OR (d.`min_users` <= ' . getTotalConfirmedUser() . ' AND d.`min_users` > 0)'; + $filterData['or'] .= ' OR (`d`.`min_users` <= ' . getTotalConfirmedUser() . ' AND `d`.`min_users` > 0)'; } // END - if // Return data diff --git a/inc/filters.php b/inc/filters.php index 78aef62f1f..37e297e2bc 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -1393,5 +1393,17 @@ function FILTER_DETERMINE_MENU_MODE_GENERIC ($filterData) { 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; +} + // [EOF] ?> diff --git a/inc/libs/doubler_functions.php b/inc/libs/doubler_functions.php index 9734b60377..6fb069733e 100644 --- a/inc/libs/doubler_functions.php +++ b/inc/libs/doubler_functions.php @@ -127,6 +127,7 @@ LIMIT %s", } // Get total points left in doubler pot +// @TODO This could be rewritten to a filter function getDoublerTotalPointsLeft() { // Initialize variables $points = '0'; @@ -137,16 +138,13 @@ function getDoublerTotalPointsLeft() { } // END - if if ((getConfig('doubler_jackpot') == 'Y') && (isExtensionActive('jackpot'))) { - // Load jackpot - $jackpot = getJackpotPoints(); - - if (!empty($jackpot)) $points += $jackpot; + // Get+add jackpot points + $points += getJackpotPoints(); } // END - if if (isValidId(getDoublerUserid())) { // Get user's points - $user = getTotalPoints(getDoublerUserid()); - $points += $user; + $points += getTotalPoints(getDoublerUserid()); } // END - if // Return value diff --git a/inc/libs/network_functions.php b/inc/libs/network_functions.php index 0926ad2748..cd737b14be 100644 --- a/inc/libs/network_functions.php +++ b/inc/libs/network_functions.php @@ -813,19 +813,19 @@ function generateAdminDistinctNetworkTypeList () { // Query all types of this network $result = SQL_QUERY('SELECT - t.`network_type_id`, - t.`network_type_handler`, - d.`network_title` + `t`.`network_type_id`, + `t`.`network_type_handler`, + `d`.`network_title` FROM - `{?_MYSQL_PREFIX?}_network_types` AS t + `{?_MYSQL_PREFIX?}_network_types` AS `t` LEFT JOIN - `{?_MYSQL_PREFIX?}_network_data` AS d + `{?_MYSQL_PREFIX?}_network_data` AS `d` ON - t.`network_id`=d.`network_id` + `t`.`network_id`=`d`.`network_id` ' . getNetworkActivatedColumn('WHERE', 'd') . ' ORDER BY - d.`network_short_name` ASC, - t.`network_type_handler` ASC', __FUNCTION__, __LINE__); + `d`.`network_short_name` ASC, + `t`.`network_type_handler` ASC', __FUNCTION__, __LINE__); // Are there entries? if (!SQL_HASZERONUMS($result)) { diff --git a/inc/libs/rallye_functions.php b/inc/libs/rallye_functions.php index ae70621749..1d697914c0 100644 --- a/inc/libs/rallye_functions.php +++ b/inc/libs/rallye_functions.php @@ -95,21 +95,21 @@ LIMIT 1", if (SQL_HASZERONUMS($result_ref)) { // Add userid and his ref count to table $result_ref = SQL_QUERY_ESC("SELECT - SUM(p.`points`) AS `points` + SUM(`p`.`points`) AS `points` FROM - `{?_MYSQL_PREFIX?}_user_points` AS p + `{?_MYSQL_PREFIX?}_user_points` AS `p` LEFT JOIN - `{?_MYSQL_PREFIX?}_user_data` AS d + `{?_MYSQL_PREFIX?}_user_data` AS `d` ON p.userid=d.userid WHERE - d.`status`='CONFIRMED' + `d`.`status`='CONFIRMED' " . runFilterChain('user_exclusion_sql', ' ') . " AND - d.`max_mails` > 0 AND - d.`mails_confirmed` >= {?ref_payout?} AND - p.`ref_depth`=1 AND - p.`points` > 0 AND - d.`userid`=%s", + `d`.`max_mails` > 0 AND + `d`.`mails_confirmed` >= {?ref_payout?} AND + `p`.`ref_depth`=1 AND + `p`.`points` > 0 AND + `d`.`userid`=%s", array(bigintval($content['userid'])), __FUNCTION__, __LINE__); // Get points @@ -236,24 +236,24 @@ function addReferralRallyeTopUsers ($mode, $rallye, $default=0) { // And load only limited users $result = SQL_QUERY_ESC("SELECT DISTINCT - u.`userid`, - u.`refs`, - u.`curr_points`, - rd.`min_users`, - rd.`min_prices` + `u`.`userid`, + `u`.`refs`, + `u`.`curr_points`, + `rd`.`min_users`, + `rd`.`min_prices` FROM - `{?_MYSQL_PREFIX?}_rallye_users` AS u + `{?_MYSQL_PREFIX?}_rallye_users` AS `u` INNER JOIN - `{?_MYSQL_PREFIX?}_refsystem` AS r + `{?_MYSQL_PREFIX?}_refsystem` AS `r` ON u.userid=r.userid INNER JOIN - `{?_MYSQL_PREFIX?}_rallye_data` AS rd + `{?_MYSQL_PREFIX?}_rallye_data` AS `rd` ON - u.`rallye_id`=rd.`id` + `u`.`rallye_id`=r`d`.`id` WHERE - u.`rallye_id`=%s AND - r.`counter` > 0 + `u`.`rallye_id`=%s AND + `r`.`counter` > 0 ORDER BY u.refs DESC", array(bigintval($rallye)), __FUNCTION__, __LINE__); @@ -273,20 +273,20 @@ ORDER BY // Points of ref's $result_ref = SQL_QUERY_ESC("SELECT - p.`points` + `p`.`points` FROM - `{?_MYSQL_PREFIX?}_user_points` AS p + `{?_MYSQL_PREFIX?}_user_points` AS `p` LEFT JOIN - `{?_MYSQL_PREFIX?}_user_data` AS d + `{?_MYSQL_PREFIX?}_user_data` AS `d` ON - p.`userid`=d.`userid` + `p`.`userid`=`d`.`userid` WHERE - d.`userid`=%s AND - d.`status`='CONFIRMED' + `d`.`userid`=%s AND + `d`.`status`='CONFIRMED' " . runFilterChain('user_exclusion_sql', ' ') . " AND - p.`ref_depth`=1 AND - d.`max_mails` > 0 AND - d.`mails_confirmed` >= {?ref_payout?} + `p`.`ref_depth`=1 AND + `d`.`max_mails` > 0 AND + `d`.`mails_confirmed` >= {?ref_payout?} LIMIT 1", array(bigintval($row['userid'])), __FUNCTION__, __LINE__); @@ -712,21 +712,21 @@ ORDER BY // Points of ref's $result_ref = SQL_QUERY_ESC("SELECT - SUM(p.`points`) AS `points` + SUM(`p`.`points`) AS `points` FROM - `{?_MYSQL_PREFIX?}_user_points` AS p + `{?_MYSQL_PREFIX?}_user_points` AS `p` LEFT JOIN - `{?_MYSQL_PREFIX?}_user_data` AS d + `{?_MYSQL_PREFIX?}_user_data` AS `d` ON - p.`userid`=d.`userid` + `p`.`userid`=`d`.`userid` WHERE - d.`status`='CONFIRMED' + `d`.`status`='CONFIRMED' " . runFilterChain('user_exclusion_sql', ' ' ) . " AND - d.`max_mails` > 0 AND - d.`mails_confirmed` >= {?ref_payout?} AND - p.`ref_depth`=1 AND - p.`points` > 0 AND - d.`userid`=%s + `d`.`max_mails` > 0 AND + `d`.`mails_confirmed` >= {?ref_payout?} AND + `p`.`ref_depth`=1 AND + `p`.`points` > 0 AND + `d`.`userid`=%s LIMIT 1", array(bigintval($content['userid'])), __FUNCTION__, __LINE__); @@ -968,14 +968,14 @@ function getReferralRallyeRefsCount ($currUserid, $oldReferralCount = '0') { $result_ref = SQL_QUERY_ESC("SELECT SUM(s.counter) AS `cnt` FROM - `{?_MYSQL_PREFIX?}_refsystem` AS s + `{?_MYSQL_PREFIX?}_refsystem` AS `s` LEFT JOIN - `{?_MYSQL_PREFIX?}_refdepths` AS d + `{?_MYSQL_PREFIX?}_refdepths` AS `d` ON - s.level=d.level + s.`level`=`d`.`level` WHERE - s.userid=%s AND - s.level=1", + s.`userid`=%s AND + s.`level`=1", array( bigintval($userid) ), __FUNCTION__, __LINE__); diff --git a/inc/libs/refback_functions.php b/inc/libs/refback_functions.php index dcc7740a32..a7db2cba3e 100644 --- a/inc/libs/refback_functions.php +++ b/inc/libs/refback_functions.php @@ -216,26 +216,26 @@ function getArrayFromRefbackUserRefs ($userid, $level) { // Get refs from database $result = SQL_QUERY_ESC("SELECT - r.`id`, - r.`refid`, - r.`refback_percents`, - r.`refback_points`, - d.`status`, - d.`joined`, - d.`mails_confirmed`, - d.`emails_received`, - d.`refid` AS `level_refid` + `r`.`id`, + `r`.`refid`, + `r`.`refback_percents`, + `r`.`refback_points`, + `d`.`status`, + `d`.`joined`, + `d`.`mails_confirmed`, + `d`.`emails_received`, + `d`.`refid` AS `level_refid` FROM - `{?_MYSQL_PREFIX?}_user_refs` AS r + `{?_MYSQL_PREFIX?}_user_refs` AS `r` LEFT JOIN - `{?_MYSQL_PREFIX?}_user_data` AS d + `{?_MYSQL_PREFIX?}_user_data` AS `d` ON - r.`refid`=d.`userid` + `r`.`refid`=`d`.`userid` WHERE - r.`userid`=%s AND - r.`level`=%s + `r`.`userid`=%s AND + `r`.`level`=%s ORDER BY - r.`refid` ASC", + `r`.`refid` ASC", array(bigintval($userid), bigintval($level)), __FUNCTION__, __LINE__); // Are there some entries? diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 801ab5a7ec..bc559acfac 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -959,13 +959,13 @@ FROM INNER JOIN `{?_MYSQL_PREFIX?}_surfbar_urls` AS `u` ON - u.`url_id`=l.`locks_url_id` + `u`.`url_id`=l.`locks_url_id` WHERE l.`locks_userid`=%s AND (UNIX_TIMESTAMP() - {%%pipe,getSurfbarSurfLock%%}) < UNIX_TIMESTAMP(l.`locks_last_surfed`) AND ( - ((UNIX_TIMESTAMP(l.`locks_last_surfed`) - u.`url_fixed_reload`) < 0 AND u.`url_fixed_reload` > 0) OR - u.`url_fixed_reload` = 0 + ((UNIX_TIMESTAMP(l.`locks_last_surfed`) - `u`.`url_fixed_reload`) < 0 AND `u`.`url_fixed_reload` > 0) OR + `u`.`url_fixed_reload` = 0 ) LIMIT 1", array(getMemberId()), __FUNCTION__, __LINE__ @@ -1302,41 +1302,41 @@ function determineSurfbarDepletedUserids ($limit=0) { // Get all userid except logged in one $result = SQL_QUERY_ESC("SELECT - u.`url_userid`, - UNIX_TIMESTAMP(d.`surfbar_low_notified`) AS `notified` + `u`.`url_userid`, + UNIX_TIMESTAMP(`d`.`surfbar_low_notified`) AS `notified` FROM `{?_MYSQL_PREFIX?}_surfbar_urls` AS `u` INNER JOIN `{?_MYSQL_PREFIX?}_user_data` AS `d` ON - u.`url_userid`=d.`userid` + `u`.`url_userid`=`d`.`userid` WHERE - u.`url_userid` NOT IN (%s) AND - u.`url_userid` IS NOT NULL AND - u.`url_status`='ACTIVE' + `u`.`url_userid` NOT IN (%s) AND + `u`.`url_userid` IS NOT NULL AND + `u`.`url_status`='ACTIVE' GROUP BY - u.`url_userid` + `u`.`url_userid` ORDER BY - u.`url_userid` ASC", + `u`.`url_userid` ASC", array(getMemberId()), __FUNCTION__, __LINE__); } else { // Get all userid $result = SQL_QUERY("SELECT - u.`url_userid`, - UNIX_TIMESTAMP(d.`surfbar_low_notified`) AS `notified` + `u`.`url_userid`, + UNIX_TIMESTAMP(`d`.`surfbar_low_notified`) AS `notified` FROM - `{?_MYSQL_PREFIX?}_surfbar_urls` AS u + `{?_MYSQL_PREFIX?}_surfbar_urls` AS `u` INNER JOIN - `{?_MYSQL_PREFIX?}_user_data` AS d + `{?_MYSQL_PREFIX?}_user_data` AS `d` ON - u.`url_userid`=d.`userid` + `u`.`url_userid`=`d`.`userid` WHERE - u.`url_userid` > 0 AND - u.`url_status`='ACTIVE' + `u`.`url_userid` > 0 AND + `u`.`url_status`='ACTIVE' GROUP BY - u.`url_userid` + `u`.`url_userid` ORDER BY - u.`url_userid` ASC", __FUNCTION__, __LINE__); + `u`.`url_userid` ASC", __FUNCTION__, __LINE__); } // Load all userid @@ -1606,24 +1606,24 @@ ORDER BY function getSurfbarMaximumRandom ($userids, $add) { // Count max availabe entries $result = SQL_QUERY("SELECT - sbu.`url_id` AS `cnt` + `sbu`.`url_id` AS `cnt` FROM `{?_MYSQL_PREFIX?}_surfbar_urls` AS `sbu` LEFT JOIN `{?_MYSQL_PREFIX?}_surfbar_salts` AS `sbs` ON - sbu.`url_id`=sbs.`salts_url_id` + `sbu`.`url_id`=`sbs`.`salts_url_id` LEFT JOIN `{?_MYSQL_PREFIX?}_surfbar_locks` AS `l` ON - sbu.`url_id`=l.`locks_url_id` + `sbu`.`url_id`=l.`locks_url_id` WHERE - sbu.`url_userid` NOT IN (" . implode(',', $userids) . ") AND - (sbu.`url_views_allowed`=0 OR (sbu.`url_views_allowed` > 0 AND sbu.`url_views_max` > 0)) AND - sbu.`url_status`='ACTIVE' + `sbu`.`url_userid` NOT IN (" . implode(',', $userids) . ") AND + (`sbu`.`url_views_allowed`=0 OR (`sbu`.`url_views_allowed` > 0 AND `sbu`.`url_views_max` > 0)) AND + `sbu`.`url_status`='ACTIVE' " . $add . " GROUP BY - sbu.`url_id` ASC", __FUNCTION__, __LINE__); + `sbu`.`url_id` ASC", __FUNCTION__, __LINE__); // Log last query //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'lastQuery='.getConfig('db_last_query').'|numRows='.SQL_NUMROWS($result).'|Affected='.SQL_AFFECTEDROWS()); @@ -1645,24 +1645,24 @@ function getSurfbarUserUrls () { // Begin the query $result = SQL_QUERY_ESC("SELECT - u.`url_id`, - u.`url_userid`, - u.`url_package_id`, - u.`url`, - u.`url_status`, - u.`url_views_total`, - u.`url_views_max`, - u.`url_views_allowed`, - UNIX_TIMESTAMP(u.`url_registered`) AS `url_registered`, - UNIX_TIMESTAMP(u.`url_last_locked`) AS `url_last_locked`, - u.`url_lock_reason` + `u`.`url_id`, + `u`.`url_userid`, + `u`.`url_package_id`, + `u`.`url`, + `u`.`url_status`, + `u`.`url_views_total`, + `u`.`url_views_max`, + `u`.`url_views_allowed`, + UNIX_TIMESTAMP(`u`.`url_registered`) AS `url_registered`, + UNIX_TIMESTAMP(`u`.`url_last_locked`) AS `url_last_locked`, + `u`.`url_lock_reason` FROM - `{?_MYSQL_PREFIX?}_surfbar_urls` AS u + `{?_MYSQL_PREFIX?}_surfbar_urls` AS `u` WHERE - u.`url_userid`=%s AND - u.`url_status` != 'DELETED' + `u`.`url_userid`=%s AND + `u`.`url_status` != 'DELETED' ORDER BY - u.`url_id` ASC", + `u`.`url_id` ASC", array(getMemberId()), __FUNCTION__, __LINE__); // Are there entries? @@ -1738,7 +1738,7 @@ function determineSurfbarNextId ($urlId = NULL) { $add = ''; if (count($USE) > 0) { // Ignore some! - $add = " AND sbu.`url_id` NOT IN ("; + $add = " AND `sbu`.`url_id` NOT IN ("; foreach ($USE as $url_id => $lid) { // Add URL id $add .= $url_id.','; @@ -1763,67 +1763,67 @@ function determineSurfbarNextId ($urlId = NULL) { // And query the database //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'randNum='.$randNum.',maxRand='.$maxRand.',surfLock='.getSurfbarSurfLock()); $result = SQL_QUERY_ESC("SELECT - sbu.`url_id`, - sbu.`url_userid`, - sbu.`url_package_id`, - sbu.`url`, - sbs.`salts_last_salt`, - sbu.`url_views_total`, - sbu.`url_views_max`, - sbu.`url_views_allowed`, + `sbu`.`url_id`, + `sbu`.`url_userid`, + `sbu`.`url_package_id`, + `sbu`.`url`, + `sbs`.`salts_last_salt`, + `sbu`.`url_views_total`, + `sbu`.`url_views_max`, + `sbu`.`url_views_allowed`, UNIX_TIMESTAMP(l.`locks_last_surfed`) AS `last_surfed`, - sbu.`url_fixed_reload` + `sbu`.`url_fixed_reload` FROM `{?_MYSQL_PREFIX?}_surfbar_urls` AS `sbu` LEFT JOIN `{?_MYSQL_PREFIX?}_surfbar_salts` AS `sbs` ON - sbu.`url_id`=sbs.`salts_url_id` + `sbu`.`url_id`=`sbs`.`salts_url_id` LEFT JOIN `{?_MYSQL_PREFIX?}_surfbar_locks` AS `l` ON - sbu.`url_id`=l.`locks_url_id` + `sbu`.`url_id`=l.`locks_url_id` WHERE - (sbu.`url_userid` NOT IN (" . implode(',', $userids['url_userid']) . ") OR sbu.`url_userid` IS NULL) AND - sbu.`url_status`='ACTIVE' AND - (sbu.`url_views_allowed`=0 OR (sbu.`url_views_allowed` > 0 AND sbu.`url_views_max` > 0)) + (`sbu`.`url_userid` NOT IN (" . implode(',', $userids['url_userid']) . ") OR `sbu`.`url_userid` IS NULL) AND + `sbu`.`url_status`='ACTIVE' AND + (`sbu`.`url_views_allowed`=0 OR (`sbu`.`url_views_allowed` > 0 AND `sbu`.`url_views_max` > 0)) " . $add . " GROUP BY - sbu.`url_id` + `sbu`.`url_id` ORDER BY l.`locks_last_surfed` ASC, - sbu.`url_id` ASC + `sbu`.`url_id` ASC LIMIT %s,1", array($randNum), __FUNCTION__, __LINE__ ); } else { // Get data from specified id number $result = SQL_QUERY_ESC("SELECT - sbu.`url_id`, - sbu.`url_userid`, - sbu.`url_package_id`, - sbu.`url`, - sbs.`salts_last_salt`, - sbu.`url_views_total`, - sbu.`url_views_max`, - sbu.`url_views_allowed`, + `sbu`.`url_id`, + `sbu`.`url_userid`, + `sbu`.`url_package_id`, + `sbu`.`url`, + `sbs`.`salts_last_salt`, + `sbu`.`url_views_total`, + `sbu`.`url_views_max`, + `sbu`.`url_views_allowed`, UNIX_TIMESTAMP(l.`locks_last_surfed`) AS `last_surfed`, - sbu.`url_fixed_reload` + `sbu`.`url_fixed_reload` FROM `{?_MYSQL_PREFIX?}_surfbar_urls` AS `sbu` LEFT JOIN `{?_MYSQL_PREFIX?}_surfbar_salts` AS `sbs` ON - sbu.`url_id`=sbs.`salts_url_id` + `sbu`.`url_id`=`sbs`.`salts_url_id` LEFT JOIN `{?_MYSQL_PREFIX?}_surfbar_locks` AS `l` ON - sbu.`url_id`=l.`locks_url_id` + `sbu`.`url_id`=l.`locks_url_id` WHERE - (sbu.`url_userid` != %s OR sbu.`url_userid` IS NULL) AND - sbu.`url_status`='ACTIVE' AND - sbu.`url_id`=%s AND - (sbu.`url_views_allowed` = 0 OR (sbu.`url_views_allowed` > 0 AND sbu.`url_views_max` > 0)) + (`sbu`.`url_userid` != %s OR `sbu`.`url_userid` IS NULL) AND + `sbu`.`url_status`='ACTIVE' AND + `sbu`.`url_id`=%s AND + (`sbu`.`url_views_allowed` = 0 OR (`sbu`.`url_views_allowed` > 0 AND `sbu`.`url_views_max` > 0)) LIMIT 1", array(getMemberId(), bigintval($urlId)), __FUNCTION__, __LINE__ ); diff --git a/inc/libs/task_functions.php b/inc/libs/task_functions.php index 1357218f1b..34462b98a3 100644 --- a/inc/libs/task_functions.php +++ b/inc/libs/task_functions.php @@ -254,30 +254,30 @@ function outputAdvancedOverview (&$result_main) { // Check for more extensions // @TODO These can be rewritten to filter - if (isValidId(getDefRefid())) $userExclusionSql .= ' AND d.`userid` != {?def_refid?}'; - if (isExtensionActive('beg')) $userExclusionSql .= ' AND d.`userid` != {?beg_userid?}'; - if (isExtensionActive('bonus')) $userExclusionSql .= ' AND d.`userid` != {?bonus_userid?}'; - if (isExtensionActive('doubler')) $userExclusionSql .= ' AND d.`userid` != {?doubler_userid?}'; + if (isValidId(getDefRefid())) $userExclusionSql .= ' AND `d`.`userid` != {?def_refid?}'; + if (isExtensionActive('beg')) $userExclusionSql .= ' AND `d`.`userid` != {?beg_userid?}'; + if (isExtensionActive('bonus')) $userExclusionSql .= ' AND `d`.`userid` != {?bonus_userid?}'; + if (isExtensionActive('doubler')) $userExclusionSql .= ' AND `d`.`userid` != {?doubler_userid?}'; if (isExtensionInstalledAndNewer('holiday', '0.1.3')) { // Recent ext-holiday found - $userExclusionSql .= " AND d.`holiday_active`='N'"; + $userExclusionSql .= " AND `d`.`holiday_active`='N'"; } // END - if // Check for all accounts addSql("SELECT - d.`userid`, - d.`email`, - d.`last_online` + `d`.`userid`, + `d`.`email`, + `d`.`last_online` FROM `{?_MYSQL_PREFIX?}_user_data` AS `d` WHERE - d.`status`='CONFIRMED' AND - (UNIX_TIMESTAMP() - d.`joined`) >= {?ap_inactive_since?} AND - (UNIX_TIMESTAMP() - d.`last_online`) >= {?ap_inactive_since?} AND - (UNIX_TIMESTAMP() - d.`ap_notified`) >= {?ap_inactive_since?} + `d`.`status`='CONFIRMED' AND + (UNIX_TIMESTAMP() - `d`.`joined`) >= {?ap_inactive_since?} AND + (UNIX_TIMESTAMP() - `d`.`last_online`) >= {?ap_inactive_since?} AND + (UNIX_TIMESTAMP() - `d`.`ap_notified`) >= {?ap_inactive_since?} " . $userExclusionSql . " ORDER BY - d.`userid` ASC"); + `d`.`userid` ASC"); $WHATs[] = 'list_autopurge'; $DESCRs[] = '{--ADMIN_TASK_INACTIVE_AUTOPURGE--}'; $TITLEs[] = '{--ADMIN_TASK_INACTIVE_AUTOPURGE_TITLE--}'; diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index 9a02c876fe..b305181ace 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -505,7 +505,7 @@ function getEpocheTimeFromUserStats ($statsType, $statsData, $userid = NULL) { // Try to find the entry $result = SQL_QUERY_ESC("SELECT - UNIX_TIMESTAMP(`inserted`) AS inserted + UNIX_TIMESTAMP(`inserted`) AS `inserted` FROM `{?_MYSQL_PREFIX?}_user_stats_data` WHERE diff --git a/inc/libs/yoomedia_functions.php b/inc/libs/yoomedia_functions.php index 5b82c5b5ce..5360c5104c 100644 --- a/inc/libs/yoomedia_functions.php +++ b/inc/libs/yoomedia_functions.php @@ -325,7 +325,7 @@ function YOOMEDIA_CHECK_RELOAD ($id, $reload, $type) { $reloaded = FALSE; // Query database - $result = SQL_QUERY_ESC("SELECT `id`, UNIX_TIMESTAMP(`inserted`) AS inserted FROM `{?_MYSQL_PREFIX?}_yoomedia_reload` WHERE `type`='%s' AND `y_id`=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `id`, UNIX_TIMESTAMP(`inserted`) AS `inserted` FROM `{?_MYSQL_PREFIX?}_yoomedia_reload` WHERE `type`='%s' AND `y_id`=%s LIMIT 1", array($type, bigintval($id)), __FUNCTION__, __LINE__); // Entry found? diff --git a/inc/mails/doubler_mails.php b/inc/mails/doubler_mails.php index e1620270bb..f9837feb99 100644 --- a/inc/mails/doubler_mails.php +++ b/inc/mails/doubler_mails.php @@ -72,46 +72,46 @@ if (empty($GLOBALS['local_doubler_userid'])) $GLOBALS['local_doubler_userid'] = $result_total = SQL_QUERY_ESC("SELECT d.id, d.userid, d.points, d.remote_ip, d.timemark FROM - `{?_MYSQL_PREFIX?}_doubler` AS d + `{?_MYSQL_PREFIX?}_doubler` AS `d` LEFT JOIN - `{?_MYSQL_PREFIX?}_user_data` AS u + `{?_MYSQL_PREFIX?}_user_data` AS `u` ON - d.`userid`=u.`userid` + `d`.`userid`=`u`.`userid` WHERE - u.`status`='CONFIRMED' + `u`.`status`='CONFIRMED' " . runFilterChain('user_exclusion_sql', ' ') . " AND - d.`points` <= %s AND - d.`points` >= ({?doubler_min?} * 2) AND - d.`completed`='N' AND - d.`is_ref`='N' + `d`.`points` <= %s AND + `d`.`points` >= ({?doubler_min?} * 2) AND + `d`.`completed`='N' AND + `d`.`is_ref`='N' ORDER BY - d.`timemark` ASC", + `d`.`timemark` ASC", array( $DOUBLER_POINTS ), __FILE__, __LINE__); // Check for accounts with limitation $result_main = SQL_QUERY_ESC("SELECT - d.`id`, - d.`userid`, - d.`points`, - d.`remote_ip`, - d.`timemark` + `d`.`id`, + `d`.`userid`, + `d`.`points`, + `d`.`remote_ip`, + `d`.`timemark` FROM - `{?_MYSQL_PREFIX?}_doubler` AS d + `{?_MYSQL_PREFIX?}_doubler` AS `d` LEFT JOIN - `{?_MYSQL_PREFIX?}_user_data` AS u + `{?_MYSQL_PREFIX?}_user_data` AS `u` ON - d.`userid`=u.`userid` + `d`.`userid`=`u`.`userid` WHERE - u.`status`='CONFIRMED' + `u`.`status`='CONFIRMED' " . runFilterChain('user_exclusion_sql', ' ') . " AND - d.`points` <= %s AND - d.`points` >= ({?doubler_min?} * 2) AND - d.`completed`='N' AND - d.`is_ref`='N' + `d`.`points` <= %s AND + `d`.`points` >= ({?doubler_min?} * 2) AND + `d`.`completed`='N' AND + `d`.`is_ref`='N' ORDER BY - d.`timemark` ASC + `d`.`timemark` ASC LIMIT {?doubler_max_sent?}", array( $DOUBLER_POINTS diff --git a/inc/modules/admin/what-admins_mails.php b/inc/modules/admin/what-admins_mails.php index 8795594390..32587a5840 100644 --- a/inc/modules/admin/what-admins_mails.php +++ b/inc/modules/admin/what-admins_mails.php @@ -108,21 +108,21 @@ if (isFormSent('edit')) { } else { // Load all assigned mails $result = SQL_QUERY("SELECT - m.`id`, - m.`admin_id`, - a.`login`, - m.`mail_template` + `m`.`id`, + `m`.`admin_id`, + `a`.`login`, + `m`.`mail_template` FROM `{?_MYSQL_PREFIX?}_admins_mails` AS `m` LEFT JOIN `{?_MYSQL_PREFIX?}_admins` AS `a` ON - m.`admin_id`=a.`id` + `m`.`admin_id`=`a`.`id` WHERE - (m.`admin_id`=a.`id` OR m.`admin_id` < 1) AND m.`mail_template` != '' + (`m`.`admin_id`=`a`.`id` OR `m`.`admin_id` < 1) AND `m`.`mail_template` != '' ORDER BY - m.`admin_id` ASC, - m.`mail_template` ASC", __FILE__, __LINE__); + `m`.`admin_id` ASC, + `m`.`mail_template` ASC", __FILE__, __LINE__); if (!SQL_HASZERONUMS($result)) { // Shall I change entries? @@ -158,18 +158,21 @@ ORDER BY // Query again... $result = SQL_QUERY("SELECT - m.id, m.admin_id, a.login, m.mail_template + `m`.`id`, + `m`.`admin_id`, + `a`.`login`, + `m`.`mail_template` FROM - `{?_MYSQL_PREFIX?}_admins_mails` AS m + `{?_MYSQL_PREFIX?}_admins_mails` AS `m` LEFT JOIN - `{?_MYSQL_PREFIX?}_admins` AS a + `{?_MYSQL_PREFIX?}_admins` AS `a` ON - m.admin_id=a.id + `m`.`admin_id`=`a`.`id` WHERE - (m.admin_id=a.id OR m.admin_id < 1) AND m.mail_template != '' + (`m`.`admin_id`=`a`.`id` OR `m`.`admin_id` < 1) AND `m`.`mail_template` != '' ORDER BY - m.admin_id ASC, - m.mail_template ASC", __FILE__, __LINE__); + `m`.`admin_id` ASC, + `m`.`mail_template` ASC", __FILE__, __LINE__); } // END - if // List found entries diff --git a/inc/modules/admin/what-config_network_types.php b/inc/modules/admin/what-config_network_types.php index 199a7f4ab8..df245ec0f3 100644 --- a/inc/modules/admin/what-config_network_types.php +++ b/inc/modules/admin/what-config_network_types.php @@ -64,11 +64,11 @@ if (isGetRequestElementSet('network_id')) { if (isGetRequestElementSet('network_type_id')) { // Load data for given network $result = SQL_QUERY_ESC('SELECT - t.`network_id`, - t.`network_type_id`, - t.`network_type_handler`, - t.`network_type_reload_time_unit`, - d.`network_active`, + `t`.`network_id`, + `t`.`network_type_id`, + `t`.`network_type_handler`, + `t`.`network_type_reload_time_unit`, + `d`.`network_active`, NULL AS `network_data_id`, NULL AS `network_max_reload_time`, NULL AS `network_min_waiting_time`, @@ -80,14 +80,14 @@ if (isGetRequestElementSet('network_id')) { NULL AS `network_media_size`, NULL AS `network_media_output` FROM - `{?_MYSQL_PREFIX?}_network_types` AS t + `{?_MYSQL_PREFIX?}_network_types` AS `t` INNER JOIN - `{?_MYSQL_PREFIX?}_network_data` AS d + `{?_MYSQL_PREFIX?}_network_data` AS `d` ON d.network_id=t.network_id WHERE - t.`network_id`=%s AND - t.`network_type_id`=%s + `t`.`network_id`=%s AND + `t`.`network_type_id`=%s LIMIT 1', array( bigintval(getRequestElement('network_id')), diff --git a/inc/modules/admin/what-del_email.php b/inc/modules/admin/what-del_email.php index 6afb0abc4f..06e2da757c 100644 --- a/inc/modules/admin/what-del_email.php +++ b/inc/modules/admin/what-del_email.php @@ -72,13 +72,13 @@ if (isGetRequestElementSet('mid')) { // Fetch right stats_id from pool $result_pool = SQL_QUERY_ESC("SELECT - s.id + s.`id` FROM - `{?_MYSQL_PREFIX?}_user_stats` AS s + `{?_MYSQL_PREFIX?}_user_stats` AS `s` LEFT JOIN - `{?_MYSQL_PREFIX?}_pool` AS p + `{?_MYSQL_PREFIX?}_pool` AS `p` ON - s.pool_id=p.id + s.`pool_id`=`p`.`id` WHERE s.`pool_id`=%s LIMIT 1", diff --git a/inc/modules/admin/what-list_autopurge.php b/inc/modules/admin/what-list_autopurge.php index 3213480bbf..eb76f798e2 100644 --- a/inc/modules/admin/what-list_autopurge.php +++ b/inc/modules/admin/what-list_autopurge.php @@ -50,28 +50,28 @@ if (isValidId(getDefRefid())) $userExclusionSql .= ' AND if (isExtensionActive('beg')) $userExclusionSql .= ' AND d.userid != {?beg_userid?}'; if (isExtensionActive('bonus')) $userExclusionSql .= ' AND d.userid != {?bonus_userid?}'; if (isExtensionActive('doubler')) $userExclusionSql .= ' AND d.userid != {?doubler_userid?}'; -if (isExtensionInstalledAndNewer('holiday', '0.1.3')) $userExclusionSql .= " AND d.`holiday_active`='N'"; +if (isExtensionInstalledAndNewer('holiday', '0.1.3')) $userExclusionSql .= " AND `d`.`holiday_active`='N'"; // Check for all accounts $result = SQL_QUERY("SELECT - d.`userid`, - d.`gender`, - d.`surname`, - d.`family`, - d.`email`, - d.`joined`, - d.`last_online`, - d.`ap_notified` + `d`.`userid`, + `d`.`gender`, + `d`.`surname`, + `d`.`family`, + `d`.`email`, + `d`.`joined`, + `d`.`last_online`, + `d`.`ap_notified` FROM - `{?_MYSQL_PREFIX?}_user_data` AS d + `{?_MYSQL_PREFIX?}_user_data` AS `d` WHERE - d.`status`='CONFIRMED' AND - (UNIX_TIMESTAMP() - d.`joined`) >= {?ap_inactive_since?} AND - (UNIX_TIMESTAMP() - d.`last_online`) >= {?ap_inactive_since?} AND - (UNIX_TIMESTAMP() - d.`ap_notified`) >= {?ap_inactive_since?} + `d`.`status`='CONFIRMED' AND + (UNIX_TIMESTAMP() - `d`.`joined`) >= {?ap_inactive_since?} AND + (UNIX_TIMESTAMP() - `d`.`last_online`) >= {?ap_inactive_since?} AND + (UNIX_TIMESTAMP() - `d`.`ap_notified`) >= {?ap_inactive_since?} " . $userExclusionSql . " ORDER BY - d.`userid` ASC", __FILE__, __LINE__); + `d`.`userid` ASC", __FILE__, __LINE__); if (!SQL_HASZERONUMS($result)) { // Ok, we have found some inactive accounts diff --git a/inc/modules/admin/what-list_coupon.php b/inc/modules/admin/what-list_coupon.php index af6b30d1ac..05a4134d8a 100644 --- a/inc/modules/admin/what-list_coupon.php +++ b/inc/modules/admin/what-list_coupon.php @@ -46,25 +46,25 @@ addYouAreHereLink('admin', __FILE__); if (isGetRequestElementSet('coupon_id')) { // List userids for given coupon $result = SQL_QUERY_ESC('SELECT - u.`coupon_id`, - u.`userid`, - UNIX_TIMESTAMP(u.`cashed_on`) AS `cashed_on`, - UNIX_TIMESTAMP(d.`coupon_created`) AS `coupon_created`, - UNIX_TIMESTAMP(d.`coupon_expired`) AS `coupon_expired`, - d.`points`, - d.`total_created`, - d.`total_cashed`, - d.`coupon_description` + `u`.`coupon_id`, + `u`.`userid`, + UNIX_TIMESTAMP(`u`.`cashed_on`) AS `cashed_on`, + UNIX_TIMESTAMP(`d`.`coupon_created`) AS `coupon_created`, + UNIX_TIMESTAMP(`d`.`coupon_expired`) AS `coupon_expired`, + `d`.`points`, + `d`.`total_created`, + `d`.`total_cashed`, + `d`.`coupon_description` FROM - `{?_MYSQL_PREFIX?}_user_coupons` AS u + `{?_MYSQL_PREFIX?}_user_coupons` AS `u` INNER JOIN - `{?_MYSQL_PREFIX?}_coupon_data` AS d + `{?_MYSQL_PREFIX?}_coupon_data` AS `d` ON - u.`coupon_id`=d.`id` + `u`.`coupon_id`=`d`.`id` WHERE - u.`coupon_id`=%s + `u`.`coupon_id`=%s ORDER BY - u.`cashed_on` DESC', + `u`.`cashed_on` DESC', array( bigintval(getRequestElement('coupon_id')) ), __FILE__, __LINE__); @@ -97,17 +97,17 @@ ORDER BY } else { // Check if the user has cashed coupons $result = SQL_QUERY('SELECT - d.`id` AS `coupon_id`, - UNIX_TIMESTAMP(d.`coupon_created`) AS `coupon_created`, - UNIX_TIMESTAMP(d.`coupon_expired`) AS `coupon_expired`, - d.`points`, - d.`total_created`, - d.`total_cashed`, - d.`coupon_description` + `d`.`id` AS `coupon_id`, + UNIX_TIMESTAMP(`d`.`coupon_created`) AS `coupon_created`, + UNIX_TIMESTAMP(`d`.`coupon_expired`) AS `coupon_expired`, + `d`.`points`, + `d`.`total_created`, + `d`.`total_cashed`, + `d`.`coupon_description` FROM - `{?_MYSQL_PREFIX?}_coupon_data` AS d + `{?_MYSQL_PREFIX?}_coupon_data` AS `d` ORDER BY - d.`id` ASC', __FILE__, __LINE__); + `d`.`id` ASC', __FILE__, __LINE__); // Are there entries? if (!SQL_HASZERONUMS($result)) { diff --git a/inc/modules/admin/what-list_holiday.php b/inc/modules/admin/what-list_holiday.php index da009cb1fe..b557952b0d 100644 --- a/inc/modules/admin/what-list_holiday.php +++ b/inc/modules/admin/what-list_holiday.php @@ -50,14 +50,14 @@ $result = SQL_QUERY("SELECT h.`holiday_start`, h.`holiday_end`, h.`comments`, - d.`status`, - d.`last_online` + `d`.`status`, + `d`.`last_online` FROM `{?_MYSQL_PREFIX?}_user_holidays` AS `h` LEFT JOIN `{?_MYSQL_PREFIX?}_user_data` AS `d` ON - h.`userid`=d.`userid` + h.`userid`=`d`.`userid` ORDER BY h.`userid` ASC", __FILE__, __LINE__); diff --git a/inc/modules/admin/what-list_network_request_params.php b/inc/modules/admin/what-list_network_request_params.php index 514b8a1e08..2fcadebed6 100644 --- a/inc/modules/admin/what-list_network_request_params.php +++ b/inc/modules/admin/what-list_network_request_params.php @@ -74,7 +74,7 @@ if (isGetRequestElementSet('network_id')) { $ADD = ''; if ((isPostRequestElementSet('network_type_id')) && (!is_array(postRequestElement('network_type_id')))) { // Only show from current type handler - $ADD = sprintf(" AND p.`network_type_id`=%s", bigintval(postRequestElement('network_type_id'))); + $ADD = sprintf(" AND `p`.`network_type_id`=%s", bigintval(postRequestElement('network_type_id'))); // Overwrite type id $networkData['network_type_id'] = bigintval(postRequestElement('network_type_id')); @@ -85,23 +85,23 @@ if (isGetRequestElementSet('network_id')) { // Load all advert types for given network $result = SQL_QUERY_ESC("SELECT - p.`network_request_param_id`, - t.`network_type_id`, - t.`network_type_handler`, - p.`network_request_param_key`, - p.`network_request_param_value`, - p.`network_request_param_default` + `p`.`network_request_param_id`, + `t`.`network_type_id`, + `t`.`network_type_handler`, + `p`.`network_request_param_key`, + `p`.`network_request_param_value`, + `p`.`network_request_param_default` FROM - `{?_MYSQL_PREFIX?}_network_request_params` AS p + `{?_MYSQL_PREFIX?}_network_request_params` AS `p` INNER JOIN - `{?_MYSQL_PREFIX?}_network_types` AS t + `{?_MYSQL_PREFIX?}_network_types` AS `t` ON - p.`network_type_id`=t.`network_type_id` + `p`.`network_type_id`=`t`.`network_type_id` WHERE - p.`network_id`=%s" . $ADD . " + `p`.`network_id`=%s" . $ADD . " ORDER BY - t.`network_type_handler` ASC, - p.`network_request_param_id` ASC", + `t`.`network_type_handler` ASC, + `p`.`network_request_param_id` ASC", array(bigintval(getRequestElement('network_id'))), __FILE__, __LINE__); // Are there entries? diff --git a/inc/modules/admin/what-list_rallye_prices.php b/inc/modules/admin/what-list_rallye_prices.php index 66487027e7..1f2f3368af 100644 --- a/inc/modules/admin/what-list_rallye_prices.php +++ b/inc/modules/admin/what-list_rallye_prices.php @@ -237,21 +237,21 @@ LIMIT 1", } else { // No rallye selected so display all available without prices $result = SQL_QUERY("SELECT - d.id AS `rallye_id`, - d.admin_id, - d.start_time, - d.end_time, - d.title, - a.login, - d.is_active + `d`.`id` AS `rallye_id`, + `d`.`admin_id`, + `d`.`start_time`, + `d`.`end_time`, + `d`.`title`, + `a`.`login`, + `d`.`is_active` FROM - `{?_MYSQL_PREFIX?}_rallye_data` AS d + `{?_MYSQL_PREFIX?}_rallye_data` AS `d` LEFT JOIN - `{?_MYSQL_PREFIX?}_admins` AS a + `{?_MYSQL_PREFIX?}_admins` AS `a` ON - d.admin_id=a.id + `d`.`admin_id`=`a`.`id` ORDER BY - d.start_time DESC", __FILE__, __LINE__); + `d`.`start_time` DESC", __FILE__, __LINE__); if (!SQL_HASZERONUMS($result)) { // List found rallyes $OUT = ''; diff --git a/inc/modules/admin/what-list_unconfirmed.php b/inc/modules/admin/what-list_unconfirmed.php index 02479af987..53de7682da 100644 --- a/inc/modules/admin/what-list_unconfirmed.php +++ b/inc/modules/admin/what-list_unconfirmed.php @@ -58,15 +58,21 @@ $sql = ''; if (isGetRequestElementSet('mid')) { // SQL query for mail data $sql = sprintf("SELECT - s.`id`, p.`sender`, p.`subject`, p.`text`, p.`url`, p.`timestamp`, s.`max_rec` + s.`id`, + `p`.`sender`, + `p`.`subject`, + `p`.`text`, + `p`.`url`, + `p`.`timestamp`, + s.`max_rec` FROM - `{?_MYSQL_PREFIX?}_pool` AS p + `{?_MYSQL_PREFIX?}_pool` AS `p` LEFT JOIN - `{?_MYSQL_PREFIX?}_user_stats` AS s + `{?_MYSQL_PREFIX?}_user_stats` AS `s` ON - p.id=s.pool_id + `p`.`id`=s.`pool_id` WHERE - p.`id`=%s + `p`.`id`=%s LIMIT 1", bigintval(getRequestElement('mid')) ); @@ -140,17 +146,17 @@ if (($listed === TRUE) && (!empty($sql))) { // accounts. So if you have delete one you did not see those links $result = SQL_QUERY_ESC("SELECT l.`userid`, - u.`status`, - u.`surname`, - u.`family`, - u.`gender`, - u.`email` + `u`.`status`, + `u`.`surname`, + `u`.`family`, + `u`.`gender`, + `u`.`email` FROM `{?_MYSQL_PREFIX?}_user_links` AS `l` LEFT JOIN `{?_MYSQL_PREFIX?}_user_data` AS `u` ON - l.`userid`=u.`userid` + l.`userid`=`u`.`userid` WHERE l.`%s`=%s ORDER BY diff --git a/inc/modules/admin/what-list_user_amounts.php b/inc/modules/admin/what-list_user_amounts.php index 76523825fc..cb6958a305 100644 --- a/inc/modules/admin/what-list_user_amounts.php +++ b/inc/modules/admin/what-list_user_amounts.php @@ -47,7 +47,7 @@ addYouAreHereLink('admin', __FILE__); $sql = ''; foreach (runFilterChain('locked_points_columns_array', array('points')) as $column) { // Add it with/-out locked - $sql .= 'p.`' . $column . '` + p.`locked_' . $column . '` +'; + $sql .= '`p`.`' . $column . '` + `p`.`locked_' . $column . '` +'; } // END - foreach // Remove last plus @@ -55,21 +55,21 @@ $sql = substr($sql, 0, -1); // Run the query to obtain all user's amounts (regardless of their status) $result = SQL_QUERY('SELECT - p.`userid`, + `p`.`userid`, SUM( ' . $sql . ' - - d.`used_points` + `d`.`used_points` ) AS `points` FROM `{?_MYSQL_PREFIX?}_user_points` AS `p` INNER JOIN `{?_MYSQL_PREFIX?}_user_data` AS `d` ON - d.`userid`=p.`userid` + `d`.`userid`=`p`.`userid` GROUP BY - p.`userid` + `p`.`userid` ORDER BY - p.`userid` ASC', __FILE__, __LINE__); + `p`.`userid` ASC', __FILE__, __LINE__); // Are there entries? (sorry, the XML functions cannot "produce" the above SQL statement) if (!SQL_HASZERONUMS($result)) { diff --git a/inc/modules/admin/what-unlock_sponsor.php b/inc/modules/admin/what-unlock_sponsor.php index fa35a95d92..b5cbe201a1 100644 --- a/inc/modules/admin/what-unlock_sponsor.php +++ b/inc/modules/admin/what-unlock_sponsor.php @@ -77,19 +77,23 @@ LIMIT 1", // Check for open payments and close them $result = SQL_QUERY_ESC("SELECT - so.admin_id, so.pay_count, - UNIX_TIMESTAMP(so.pay_ordered) AS `pay_ordered`, - so.pay_status, sp.pay_name, sp.pay_rate, sp.pay_currency + `so`.`admin_id`, + `so`.`pay_count`, + UNIX_TIMESTAMP(`so`.`pay_ordered`) AS `pay_ordered`, + `so`.`pay_status`, + `sp`.`pay_name`, + `sp`.`pay_rate`, + `sp`.`pay_currency` FROM - `{?_MYSQL_PREFIX?}_sponsor_orders` AS so + `{?_MYSQL_PREFIX?}_sponsor_orders` AS `so` LEFT JOIN - `{?_MYSQL_PREFIX?}_sponsor_paytypes` AS sp + `{?_MYSQL_PREFIX?}_sponsor_paytypes` AS `sp` ON - sp.id=so.payment_id + `sp`.`id`=`so`.`payment_id` WHERE - so.sponsor_id=%s + `so`.`sponsor_id`=%s ORDER BY - sp.pay_name ASC", + `sp`.`pay_name` ASC", array($content['id']), __FILE__, __LINE__); if (!SQL_HASZERONUMS($result)) { // Payment does exist diff --git a/inc/modules/guest/what-mediadata.php b/inc/modules/guest/what-mediadata.php index 8828b53ffd..a79c6ebddd 100644 --- a/inc/modules/guest/what-mediadata.php +++ b/inc/modules/guest/what-mediadata.php @@ -140,8 +140,8 @@ $content['jackpot'] = $jackpot; // Total referral link clicks, total logins $result = SQL_QUERY('SELECT - SUM(d.`ref_clicks`) AS `total_ref_clicks`, - SUM(d.`total_logins`) AS `total_logins` + SUM(`d`.`ref_clicks`) AS `total_ref_clicks`, + SUM(`d`.`total_logins`) AS `total_logins` FROM `{?_MYSQL_PREFIX?}_user_data` AS `d` ' . runFilterChain('user_exclusion_sql', ''), __FILE__, __LINE__); @@ -233,9 +233,9 @@ FROM LEFT JOIN `{?_MYSQL_PREFIX?}_user_data` AS `d` ON - h.`userid`=d.`userid` + h.`userid`=`d`.`userid` WHERE - d.`holiday_active`='Y' + `d`.`holiday_active`='Y' " . runFilterChain('user_exclusion_sql', ' '), __FILE__, __LINE__); list($holiday) = SQL_FETCHROW($result); @@ -251,14 +251,14 @@ WHERE if (isExtensionActive('transfer')) { // Statistics for points transfers $result = SQL_QUERY("SELECT - COUNT(t.`id`) AS `cnt`, - SUM(t.`points`) AS `points` + COUNT(`t`.`id`) AS `cnt`, + SUM(`t`.`points`) AS `points` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` AS `t` LEFT JOIN `{?_MYSQL_PREFIX?}_user_data` AS `d` ON - t.`userid`=d.`userid` + `t`.`userid`=`d`.`userid` " . runFilterChain('user_exclusion_sql', ''), __FILE__, __LINE__); list($count_in, $points_in) = SQL_FETCHROW($result); @@ -267,13 +267,13 @@ ON if (empty($points_in)) $points_in = '0'; $result = SQL_QUERY("SELECT - COUNT(t.`id`) AS `cnt`, SUM(t.`points`) AS `points` + COUNT(`t`.`id`) AS `cnt`, SUM(`t`.`points`) AS `points` FROM `{?_MYSQL_PREFIX?}_user_transfers_out` AS `t` LEFT JOIN `{?_MYSQL_PREFIX?}_user_data` AS `d` ON - t.userid=d.userid + `t`.`userid`=`d`.`userid` " . runFilterChain('user_exclusion_sql', ''), __FILE__, __LINE__); list($count_out, $points_out) = SQL_FETCHROW($result); diff --git a/inc/modules/guest/what-rallyes.php b/inc/modules/guest/what-rallyes.php index 0b5c79b6c7..43afabe64d 100644 --- a/inc/modules/guest/what-rallyes.php +++ b/inc/modules/guest/what-rallyes.php @@ -52,31 +52,31 @@ if ((!isExtensionActive('rallye')) && (!isAdmin())) { outputHtml('
'); // Check for possible running rallyes -$ADD = " AND d.`is_active`='Y'"; +$ADD = " AND `d`.`is_active`='Y'"; if (isAdmin()) $ADD = ''; $result = SQL_QUERY("SELECT - d.`id`, - d.`admin_id`, - a.`login`, - d.`title`, - d.`descr`, - d.`template`, - d.`start_time`, - d.`end_time`, - d.`min_users`, - d.`min_prices` + `d`.`id`, + `d`.`admin_id`, + `a`.`login`, + `d`.`title`, + `d`.`descr`, + `d`.`template`, + `d`.`start_time`, + `d`.`end_time`, + `d`.`min_users`, + `d`.`min_prices` FROM - `{?_MYSQL_PREFIX?}_rallye_data` AS d + `{?_MYSQL_PREFIX?}_rallye_data` AS `d` INNER JOIN - `{?_MYSQL_PREFIX?}_admins` AS a + `{?_MYSQL_PREFIX?}_admins` AS `a` ON - d.`admin_id`=a.`id` + `d`.`admin_id`=`a`.`id` WHERE - d.`notified`='Y' + `d`.`notified`='Y' " . $ADD . " ORDER BY - d.`end_time` ASC + `d`.`end_time` ASC LIMIT 1", __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { diff --git a/inc/modules/guest/what-sponsor_infos.php b/inc/modules/guest/what-sponsor_infos.php index dd757d9e3c..5adb08c67f 100644 --- a/inc/modules/guest/what-sponsor_infos.php +++ b/inc/modules/guest/what-sponsor_infos.php @@ -54,22 +54,24 @@ $result_pay = FALSE; // Load all sponsor actions $result_act = SQL_QUERY("SELECT - m.title AS `conv_title`, c.conv_rate, c.conv_name + `m`.`title` AS `conv_title`, + `c`.`conv_rate`, + `c`.`conv_name` FROM - `{?_MYSQL_PREFIX?}_sponsor_menu` AS m + `{?_MYSQL_PREFIX?}_sponsor_menu` AS `m` LEFT JOIN - `{?_MYSQL_PREFIX?}_sponsor_action_convert` AS c + `{?_MYSQL_PREFIX?}_sponsor_action_convert` AS `c` ON - m.what=c.ext_name + `m`.`what`=`c`.`ext_name` LEFT JOIN - `{?_MYSQL_PREFIX?}_sponsor_registry` AS r + `{?_MYSQL_PREFIX?}_sponsor_registry` AS `r` ON - m.what=r.ext_name + `m`.`what`=`r`.`ext_name` WHERE - m.`action`='actions' AND - r.is_active='Y' + `m`.`action`='actions' AND + `r`.`is_active`='Y' ORDER BY - m.sort ASC", __FILE__, __LINE__); + `m`.`sort` ASC", __FILE__, __LINE__); if (!SQL_HASZERONUMS($result_act)) { // Load all actions diff --git a/inc/modules/guest/what-top10.php b/inc/modules/guest/what-top10.php index e6e836228f..1c6231871f 100644 --- a/inc/modules/guest/what-top10.php +++ b/inc/modules/guest/what-top10.php @@ -102,24 +102,24 @@ SQL_FREERESULT($result); // TOP earners $result = SQL_QUERY("SELECT - d.`userid`, - SUM(p.`points` + p.`locked_points`) AS `points`, - d.`last_online` + `d`.`userid`, + SUM(`p`.`points` + `p`.`locked_points`) AS `points`, + `d`.`last_online` FROM `{?_MYSQL_PREFIX?}_user_data` AS `d` LEFT JOIN {?_MYSQL_PREFIX?}_user_points AS `p` ON - p.`userid`=d.`userid` + `p`.`userid`=`d`.`userid` WHERE - p.`points` > 0 AND - d.`status`='CONFIRMED' + `p`.`points` > 0 AND + `d`.`status`='CONFIRMED' " . runFilterChain('user_exclusion_sql', ' ') . " GROUP BY - p.`userid` + `p`.`userid` ORDER BY `points` DESC, - d.`last_online` DESC + `d`.`last_online` DESC LIMIT {?top10_max?}", __FILE__, __LINE__); $OUT = ''; $count = 1; @@ -156,24 +156,24 @@ SQL_FREERESULT($result); // TOP referral "hunter" $result = SQL_QUERY("SELECT - d.`userid`, - SUM(r.`counter`) AS `refs`, - d.`last_online` + `d`.`userid`, + SUM(`r`.`counter`) AS `refs`, + `d`.`last_online` FROM `{?_MYSQL_PREFIX?}_user_data` AS `d` LEFT JOIN {?_MYSQL_PREFIX?}_refsystem AS `r` ON - r.`userid`=d.`userid` + `r`.`userid`=`d`.`userid` WHERE - r.`counter` > 0 AND - d.`status`='CONFIRMED' + `r`.`counter` > 0 AND + `d`.`status`='CONFIRMED' " . runFilterChain('user_exclusion_sql', ' ') . " GROUP BY - r.`userid` + `r`.`userid` ORDER BY `refs` DESC, - d.`last_online` DESC + `d`.`last_online` DESC LIMIT {?top10_max?}", __FILE__, __LINE__); $OUT = ''; $count = 1; diff --git a/inc/modules/member/what-earning.php b/inc/modules/member/what-earning.php index d2943e5783..410f899a48 100644 --- a/inc/modules/member/what-earning.php +++ b/inc/modules/member/what-earning.php @@ -57,13 +57,13 @@ if (isFormSent()) { // Check for all earnings $result = SQL_QUERY('SELECT - d.`earning_id`, - d.`earning_group`, - d.`earning_provider` + `d`.`earning_id`, + `d`.`earning_group`, + `d`.`earning_provider` FROM - `{?_MYSQL_PREFIX?}_earning_data` AS d + `{?_MYSQL_PREFIX?}_earning_data` AS `d` ORDER BY - d.`earning_sorting` ASC', __FILE__, __LINE__); + `d`.`earning_sorting` ASC', __FILE__, __LINE__); // Are there entries? if (!SQL_HASZERONUMS($result)) { @@ -74,16 +74,16 @@ if (!SQL_HASZERONUMS($result)) { while ($content = SQL_FETCHARRAY($result)) { // Load user_earning data $result2 = SQL_QUERY_ESC('SELECT - u.`earning_active`, - UNIX_TIMESTAMP(u.`earning_added`) AS `earning_added`, - UNIX_TIMESTAMP(u.`earning_canceled`) AS `earning_canceled`, - u.`earning_daily_amount`, - u.`earning_points` + `u`.`earning_active`, + UNIX_TIMESTAMP(`u`.`earning_added`) AS `earning_added`, + UNIX_TIMESTAMP(`u`.`earning_canceled`) AS `earning_canceled`, + `u`.`earning_daily_amount`, + `u`.`earning_points` FROM - `{?_MYSQL_PREFIX?}_user_earning` AS u + `{?_MYSQL_PREFIX?}_user_earning` AS `u` WHERE - u.`earning_id`=%s AND - u.`earning_userid`=%s + `u`.`earning_id`=%s AND + `u`.`earning_userid`=%s LIMIT 1', array( bigintval($content['earning_id']), diff --git a/inc/modules/member/what-list_coupon.php b/inc/modules/member/what-list_coupon.php index 5e9b4b0859..d315464f2a 100644 --- a/inc/modules/member/what-list_coupon.php +++ b/inc/modules/member/what-list_coupon.php @@ -53,25 +53,25 @@ if ((!isExtensionActive('coupon')) && (!isAdmin())) { // Check if the user has cashed coupons $result = SQL_QUERY_ESC("SELECT - UNIX_TIMESTAMP(u.`cashed_on`) AS `cashed_on`, - UNIX_TIMESTAMP(d.`coupon_created`) AS `coupon_created`, - UNIX_TIMESTAMP(d.`coupon_expired`) AS `coupon_expired`, - d.`points`, - d.`total_created`, - d.`total_cashed`, - d.`coupon_description` + UNIX_TIMESTAMP(`u`.`cashed_on`) AS `cashed_on`, + UNIX_TIMESTAMP(`d`.`coupon_created`) AS `coupon_created`, + UNIX_TIMESTAMP(`d`.`coupon_expired`) AS `coupon_expired`, + `d`.`points`, + `d`.`total_created`, + `d`.`total_cashed`, + `d`.`coupon_description` FROM - `{?_MYSQL_PREFIX?}_user_coupons` AS u + `{?_MYSQL_PREFIX?}_user_coupons` AS `u` INNER JOIN - `{?_MYSQL_PREFIX?}_coupon_data` AS d + `{?_MYSQL_PREFIX?}_coupon_data` AS `d` ON - u.`coupon_id`=d.`id` + `u`.`coupon_id`=`d`.`id` WHERE - u.`userid`=%s AND - u.`coupon_code` IS NULL AND - u.`cashed_on` IS NOT NULL + `u`.`userid`=%s AND + `u`.`coupon_code` IS NULL AND + `u`.`cashed_on` IS NOT NULL ORDER BY - u.`cashed_on` DESC", array(getMemberId()), __FILE__, __LINE__); + `u`.`cashed_on` DESC", array(getMemberId()), __FILE__, __LINE__); // Are there entries? if (!SQL_HASZERONUMS($result)) { diff --git a/inc/modules/member/what-order.php b/inc/modules/member/what-order.php index d17dc594c2..60a07e03cf 100644 --- a/inc/modules/member/what-order.php +++ b/inc/modules/member/what-order.php @@ -172,9 +172,9 @@ LIMIT 1", $result = SQL_QUERY_ESC("SELECT `c`.`userid` FROM - `{?_MYSQL_PREFIX?}_user_cats` AS c + `{?_MYSQL_PREFIX?}_user_cats` AS `c` INNER JOIN - `{?_MYSQL_PREFIX?}_user_data` AS d + `{?_MYSQL_PREFIX?}_user_data` AS `d` ON `c`.`userid`=`d`.`userid` WHERE @@ -488,9 +488,9 @@ ORDER BY $result_holiday = SQL_QUERY_ESC("SELECT COUNT(`d`.`userid`) AS `cnt` FROM - `{?_MYSQL_PREFIX?}_user_data` AS d + `{?_MYSQL_PREFIX?}_user_data` AS `d` LEFT JOIN - `{?_MYSQL_PREFIX?}_user_holidays` AS h + `{?_MYSQL_PREFIX?}_user_holidays` AS `h` ON `d`.`userid`=`h`.`userid` WHERE diff --git a/inc/modules/member/what-payout.php b/inc/modules/member/what-payout.php index 7907f0e22a..731a00f42c 100644 --- a/inc/modules/member/what-payout.php +++ b/inc/modules/member/what-payout.php @@ -76,27 +76,27 @@ ORDER BY // Check for his payouts $result_payouts = SQL_QUERY_ESC("SELECT - p.`id`, - p.`payout_total`, - p.`target_account`, - p.`target_bank`, - t.`type`, - p.`payout_timestamp`, - p.`status`, - t.`allow_url` AS `allow`, - p.`target_url` AS `url`, - p.`link_text`, - p.`banner_url` AS `banner` + `p`.`id`, + `p`.`payout_total`, + `p`.`target_account`, + `p`.`target_bank`, + `t`.`type`, + `p`.`payout_timestamp`, + `p`.`status`, + `t`.`allow_url` AS `allow`, + `p`.`target_url` AS `url`, + `p`.`link_text`, + `p`.`banner_url` AS `banner` FROM `{?_MYSQL_PREFIX?}_user_payouts` AS `p` LEFT JOIN `{?_MYSQL_PREFIX?}_payout_types` AS `t` ON - p.`payout_id` = t.`id` + `p`.`payout_id`=`t`.`id` WHERE - p.`userid` = %s + `p`.`userid`=%s ORDER BY - p.`payout_timestamp` DESC", + `p`.`payout_timestamp` DESC", array(getMemberId()), __FILE__, __LINE__); if (!SQL_HASZERONUMS($result_payouts)) { // List all his requests @@ -137,7 +137,7 @@ ORDER BY } } else { // Chedk if he can get paid by selected type - $result = SQL_QUERY_ESC("SELECT `type`, `rate`, `min_points`, `allow_url` AS allow FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `type`, `rate`, `min_points`, `allow_url` AS `allow` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1", array(bigintval(getRequestElement('payout'))), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { diff --git a/inc/modules/member/what-points.php b/inc/modules/member/what-points.php index f6f5d59840..a1e39d5cdf 100644 --- a/inc/modules/member/what-points.php +++ b/inc/modules/member/what-points.php @@ -94,24 +94,24 @@ while ($data = SQL_FETCHARRAY($result_depths)) { $content = merge_array($content, $data); // Default for referral level > 0 - $depth = 'p.`ref_depth`=%s'; + $depth = '`p`.`ref_depth`=%s'; if (is_null($content['level'])) { - $depth = 'p.`ref_depth` IS NULL'; + $depth = '`p`.`ref_depth` IS NULL'; } // END - if // Load referral points $result_points = SQL_QUERY_ESC('SELECT ' . getAllPointColumns('p.', ',') . ' - r.`counter` + `r`.`counter` FROM - `{?_MYSQL_PREFIX?}_user_points` AS p + `{?_MYSQL_PREFIX?}_user_points` AS `p` LEFT JOIN - `{?_MYSQL_PREFIX?}_refsystem` AS r + `{?_MYSQL_PREFIX?}_refsystem` AS `r` ON - p.`userid`=r.`userid` AND - p.`ref_depth`=r.`level` + `p`.`userid`=`r`.`userid` AND + `p`.`ref_depth`=`r`.`level` WHERE - p.`userid`=%s AND + `p`.`userid`=%s AND ' . $depth . ' LIMIT 1', array( diff --git a/inc/modules/member/what-rallyes.php b/inc/modules/member/what-rallyes.php index 0265f94e6f..26292af156 100644 --- a/inc/modules/member/what-rallyes.php +++ b/inc/modules/member/what-rallyes.php @@ -51,31 +51,31 @@ if ((!isExtensionActive('rallye')) && (!isAdmin())) { } // END - if // Check for possible running rallyes -$ADD = " AND d.`is_active`='Y'"; +$ADD = " AND `d`.`is_active`='Y'"; if (isAdmin()) $ADD = ''; $result = SQL_QUERY("SELECT - d.`id`, - d.`admin_id`, - a.`login`, - d.`title`, - d.`descr`, - d.`template`, - d.`start_time`, - d.`end_time`, - d.`min_users`, - d.`min_prices` + `d`.`id`, + `d`.`admin_id`, + `a`.`login`, + `d`.`title`, + `d`.`descr`, + `d`.`template`, + `d`.`start_time`, + `d`.`end_time`, + `d`.`min_users`, + `d`.`min_prices` FROM - `{?_MYSQL_PREFIX?}_rallye_data` AS d + `{?_MYSQL_PREFIX?}_rallye_data` AS `d` INNER JOIN - `{?_MYSQL_PREFIX?}_admins` AS a + `{?_MYSQL_PREFIX?}_admins` AS `a` ON - d.`admin_id`=a.`id` + `d`.`admin_id`=`a`.`id` WHERE - d.`notified`='Y' + `d`.`notified`='Y' " . $ADD . " ORDER BY - d.`end_time` ASC + `d`.`end_time` ASC LIMIT 1", __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { diff --git a/inc/modules/member/what-refback.php b/inc/modules/member/what-refback.php index 203e4de170..482d1d14aa 100644 --- a/inc/modules/member/what-refback.php +++ b/inc/modules/member/what-refback.php @@ -97,14 +97,14 @@ if ((isFormSent('edit')) && (isPostRequestElementSet('id'))) { // Load all referral levels $result = SQL_QUERY('SELECT - r.`level`, - r.`percents` + `r`.`level`, + `r`.`percents` FROM - `{?_MYSQL_PREFIX?}_refdepths` AS r + `{?_MYSQL_PREFIX?}_refdepths` AS `r` WHERE - r.level > 0 + `r`.`level` > 0 ORDER BY - r.level ASC', __FILE__, __LINE__); + `r`.`level` ASC', __FILE__, __LINE__); // Are there some entries? (Shall be!) if (!SQL_HASZERONUMS($result)) { diff --git a/inc/modules/member/what-transfer.php b/inc/modules/member/what-transfer.php index b8bb61dc81..3d0fca10ab 100644 --- a/inc/modules/member/what-transfer.php +++ b/inc/modules/member/what-transfer.php @@ -281,14 +281,14 @@ switch ($mode) { $nothingMessage = ''; switch ($mode) { case 'list_in': - $sql = 'SELECT `trans_id`, `from_userid` AS party_userid,`points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` WHERE `userid`=%s ORDER BY `time_trans` DESC LIMIT {?transfer_max?}'; + $sql = 'SELECT `trans_id`, `from_userid` AS `party_userid`, `points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` WHERE `userid`=%s ORDER BY `time_trans` DESC LIMIT {?transfer_max?}'; $nothingMessage = '{--MEMBER_TRANSFER_NO_INCOMING_TRANSFERS--}'; $content['balance'] = '{--MEMBER_TRANSFER_TOTAL_INCOMING--}'; $content['title'] = '{--MEMBER_LIST_INCOMING_TRANSFER_TITLE--}'; break; case 'list_out': - $sql = 'SELECT `trans_id`, `to_userid` AS party_userid,`points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_out` WHERE `userid`=%s ORDER BY `time_trans` DESC LIMIT {?transfer_max?}'; + $sql = 'SELECT `trans_id`, `to_userid` AS `party_userid`, `points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_out` WHERE `userid`=%s ORDER BY `time_trans` DESC LIMIT {?transfer_max?}'; $nothingMessage = '{--MEMBER_TRANSFER_NO_OUTGOING_TRANSFERS--}'; $content['balance'] = '{--TRANSFER_TOTAL_OUTGOING--}'; $content['title'] = '{--MEMBER_LIST_OUTGOING_TRANSFER_TITLE--}'; diff --git a/inc/modules/member/what-unconfirmed.php b/inc/modules/member/what-unconfirmed.php index c648207612..f64ae4ce2f 100644 --- a/inc/modules/member/what-unconfirmed.php +++ b/inc/modules/member/what-unconfirmed.php @@ -105,13 +105,13 @@ LIMIT 1', $result_data = SQL_QUERY_ESC("SELECT s.`id`, s.`subject`, - p.`text`, + `p`.`text`, s.`timestamp_ordered` AS `timestamp`, s.`cat_id`, pay.`price` AS `points`, - p.`sender`, + `p`.`sender`, pay.`time`, - p.`data_type` + `p`.`data_type` FROM `{?_MYSQL_PREFIX?}_user_stats` AS `s` LEFT JOIN @@ -121,7 +121,7 @@ ON LEFT JOIN `{?_MYSQL_PREFIX?}_payments` AS `pay` ON - p.`payment_id`=pay.`id` + `p`.`payment_id`=pay.`id` WHERE s.`id`=%s LIMIT 1", @@ -189,13 +189,13 @@ if (!SQL_HASZERONUMS($result)) { s.`timestamp_ordered` AS `timestamp`, s.`cat_id`, s.`payment_id`, - p.`sender` + `p`.`sender` FROM `{?_MYSQL_PREFIX?}_user_stats` AS `s` LEFT JOIN `{?_MYSQL_PREFIX?}_pool` AS `p` ON - s.`pool_id`=p.`id` + s.`pool_id`=`p`.`id` WHERE s.`id`=%s LIMIT 1", diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index a242cd01c9..6824a16c43 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1471,15 +1471,15 @@ function deleteUserAccount ($userid, $reason) { // Search for the points and user data $result = SQL_QUERY_ESC("SELECT - (SUM(p.`points`) - d.`used_points`) AS `points` + (SUM(`p`.`points`) - `d`.`used_points`) AS `points` FROM `{?_MYSQL_PREFIX?}_user_points` AS `p` LEFT JOIN `{?_MYSQL_PREFIX?}_user_data` AS `d` ON - p.`userid`=d.`userid` + `p`.`userid`=`d`.`userid` WHERE - p.`userid`=%s + `p`.`userid`=%s LIMIT 1", array(bigintval($userid)), __FUNCTION__, __LINE__); @@ -1762,23 +1762,33 @@ function generateReceiverList ($categoryId, $receiver, $mode = '') { // Category given? if (isValidId($categoryId)) { // Select category - $extraColumns = "LEFT JOIN `{?_MYSQL_PREFIX?}_user_cats` AS c ON d.`userid`=c.`userid`"; - $addWhere = sprintf(" AND c.`cat_id`=%s", $categoryId); + $extraColumns = "LEFT JOIN `{?_MYSQL_PREFIX?}_user_cats` AS `c` ON `d`.`userid`=`c`.`userid`"; + $addWhere = sprintf(" AND `c`.`cat_id`=%s", $categoryId); } // END - if // Exclude users in holiday? if (isExtensionInstalledAndNewer('holiday', '0.1.3')) { // Add something for the holiday extension - $addWhere .= " AND d.`holiday_active`='N'"; + $addWhere .= " AND `d`.`holiday_active`='N'"; } // END - if // Include only HTML recipients? if ((isExtensionActive('html_mail')) && ($mode == 'html')) { - $addWhere .= " AND d.`html`='Y'"; + $addWhere .= " AND `d`.`html`='Y'"; } // END - if // Run query - $result = SQL_QUERY_ESC("SELECT d.`userid` FROM `{?_MYSQL_PREFIX?}_user_data` AS d ".$extraColumns." WHERE d.`status`='CONFIRMED' ".$addWhere." ORDER BY d.`{?order_select?}` {?order_mode?} LIMIT %s", + $result = SQL_QUERY_ESC("SELECT + `d`.`userid` +FROM + `{?_MYSQL_PREFIX?}_user_data` AS `d` + " . $extraColumns . " +WHERE + `d`.`status`='CONFIRMED' + " . $addWhere . " +ORDER BY + `d`.`{?order_select?}` {?order_mode?} +LIMIT %s", array( $receiver ), __FUNCTION__, __LINE__); diff --git a/inc/purge/purge- b/inc/purge/purge- index fadd911de3..2da55d1d09 100644 --- a/inc/purge/purge- +++ b/inc/purge/purge- @@ -41,7 +41,7 @@ if (!defined('__SECURITY')) { } // END - if // Abort if autopurge is not active or disabled by admin -if ((!isExtensionActive('autopurge')) || (getConfig('auto_purge_active') != 'Y')) { +if ((!isExtensionActive('autopurge')) || (!isAutoPurgingActive())) { // Abort here return FALSE; } // END - if diff --git a/inc/purge/purge-general.php b/inc/purge/purge-general.php index cb33c87992..07205e280f 100644 --- a/inc/purge/purge-general.php +++ b/inc/purge/purge-general.php @@ -53,17 +53,20 @@ if (getAutoPurge() > 0) { // Then check for outdated mail order. We don't delete them just the confirmation links will be deleted. $result = SQL_QUERY('SELECT - s.id, s.userid, s.pool_id, t.price + `s`.`id`, + `s`.`userid`, + `s`.`pool_id`, + `t`.`price` FROM - `{?_MYSQL_PREFIX?}_user_stats` AS s + `{?_MYSQL_PREFIX?}_user_stats` AS `s` LEFT JOIN - `{?_MYSQL_PREFIX?}_payments` AS t + `{?_MYSQL_PREFIX?}_payments` AS `t` ON - s.`payment_id`=t.`id` + `s`.`payment_id`=`t`.`id` WHERE - (UNIX_TIMESTAMP() - s.`timestamp_ordered`) >= {?auto_purge?} + (UNIX_TIMESTAMP() - `s`.`timestamp_ordered`) >= {?auto_purge?} ORDER BY - s.userid ASC', __FILE__, __LINE__); + `s`.`userid` ASC', __FILE__, __LINE__); if (!SQL_HASZERONUMS($result)) { // Start deleting procedure $userid = NULL; diff --git a/inc/purge/purge-inact.php b/inc/purge/purge-inact.php index e7472ef211..9c38a4b79e 100644 --- a/inc/purge/purge-inact.php +++ b/inc/purge/purge-inact.php @@ -51,20 +51,18 @@ if (isAutopurgeInactiveEnabled()) { // Init SQLs initSqls(); - // Init exclusion list - // @TODO Rewrite these if() blocks to a filter - $excludeUserids = ''; - if (isValidId(getDefRefid())) $excludeUserids .= ' AND `userid` != {?def_refid?}'; - - // Check for more extensions - if (isExtensionActive('beg')) $excludeUserids .= ' AND `userid` != {?beg_userid?}'; - if (isExtensionActive('bonus')) $excludeUserids .= ' AND `userid` != {?bonus_userid?}'; - if (isExtensionActive('doubler')) $excludeUserids .= ' AND `userid` != {?doubler_userid?}'; + // Init userid exclusion + $excludeSql = ''; + $excludedUserids = runFilterChain('config_userid_exclusion_sql', array()); + if (count($excludedUserids) > 0) { + // Exclude all + $excludeSql = ' AND `userid` NOT IN (' . implode(', ', $excludedUserids) . ')'; + } // END - if // Check for new holiday extension if (isExtensionInstalledAndNewer('holiday', '0.1.3')) { // Include only users with no active holiday - $excludeUserids .= " AND `holiday_active`='N'"; + $excludeSql .= " AND `holiday_active`='N'"; } // END - if // Check for all accounts @@ -79,8 +77,8 @@ WHERE " . runFilterChain('user_exclusion_sql', ' ') . " AND (UNIX_TIMESTAMP() - `joined`) >= {?ap_inactive_since?} AND (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?} AND - (UNIX_TIMESTAMP() - `ap_notified`) >= {?ap_inactive_since?} - " . $excludeUserids . " + (UNIX_TIMESTAMP() - `ap_notified`) >= {?ap_inactive_since?} AND + " . $excludeSql . " ORDER BY `userid` ASC", __FILE__, __LINE__); @@ -138,7 +136,7 @@ WHERE (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?} AND (UNIX_TIMESTAMP() - `ap_notified`) >= {?ap_inactive_time?} AND `ap_notified` > 0 -" . $excludeUserids . " + " . $excludeSql . " ORDER BY `userid` ASC", __FILE__, __LINE__); diff --git a/inc/purge/purge-user.php b/inc/purge/purge-user.php index 6b8a7d3242..c465793fd3 100644 --- a/inc/purge/purge-user.php +++ b/inc/purge/purge-user.php @@ -41,7 +41,7 @@ if (!defined('__SECURITY')) { } // END - if // Abort if autopurge is not active or disabled by admin -if ((!isExtensionActive('autopurge')) || (getConfig('auto_purge_active') != 'Y')) { +if ((!isExtensionActive('autopurge')) || (!isAutoPurgingActive())) { // Abort here return FALSE; } // END - if diff --git a/inc/referral-functions.php b/inc/referral-functions.php index 1b95e84ee9..267fd27963 100644 --- a/inc/referral-functions.php +++ b/inc/referral-functions.php @@ -390,29 +390,29 @@ function getUserReferralPoints ($userid, $level) { // Get refs from database $result = SQL_QUERY_ESC('SELECT - ur.`id`, - ur.`refid`, - ud.`status`, - ud.`last_online`, - ud.`mails_confirmed`, - ud.`emails_received`, - ud.`subid` + `ur`.`id`, + `ur`.`refid`, + `ud`.`status`, + `ud`.`last_online`, + `ud`.`mails_confirmed`, + `ud`.`emails_received`, + `ud`.`subid` FROM `{?_MYSQL_PREFIX?}_user_refs` AS `ur` LEFT JOIN `{?_MYSQL_PREFIX?}_user_points` AS `up` ON - ur.`refid`=up.`userid` AND - (ur.`level`=0 OR ur.`level` IS NULL) + `ur`.`refid`=`up`.`userid` AND + (`ur`.`level`=0 OR `ur`.`level` IS NULL) LEFT JOIN `{?_MYSQL_PREFIX?}_user_data` AS `ud` ON - ur.`refid`=ud.`userid` + `ur`.`refid`=`ud`.`userid` WHERE - ur.`userid`=%s AND - ur.`level`=%s + `ur`.`userid`=%s AND + `ur`.`level`=%s ORDER BY - ur.`refid` ASC', + `ur`.`refid` ASC', array( bigintval($userid), bigintval($level) diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index db7fa084b3..35af66dc44 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -3313,24 +3313,24 @@ function getUsersTotalLockedReferrals ($userid, $level = NULL) { // Is the not level NULL? if (!is_null($level)) { // Then add referral level - $add = ' AND r.`level`=' . bigintval($level); + $add = ' AND `r`.`level`=' . bigintval($level); } // END - if // Check for all referrals $result = SQL_QUERY_ESC("SELECT - COUNT(d.`userid`) AS `cnt` + COUNT(`d`.`userid`) AS `cnt` FROM - `{?_MYSQL_PREFIX?}_user_data` AS d + `{?_MYSQL_PREFIX?}_user_data` AS `d` INNER JOIN - `{?_MYSQL_PREFIX?}_user_refs` AS r + `{?_MYSQL_PREFIX?}_user_refs` AS `r` ON - d.`userid`=r.`refid` + `d`.`userid`=`r`.`refid` WHERE - d.`status` != 'CONFIRMED' AND - r.`userid`=%s + `d`.`status` != 'CONFIRMED' AND + `r`.`userid`=%s " . $add . " ORDER BY - d.`userid` ASC + `d`.`userid` ASC LIMIT 1", array( $userid diff --git a/show_bonus.php b/show_bonus.php index 6814e52df7..ff3545d61b 100644 --- a/show_bonus.php +++ b/show_bonus.php @@ -78,19 +78,19 @@ if ((isValidId(getRequestElement('userid'))) && (getRequestElement('d') > 0) && if (!empty($t)) { // Check for data $result = SQL_QUERY_ESC("SELECT - d.`userid`, - b.`level`, - b.`points` + `d`.`userid`, + `b`.`level`, + `b`.`points` FROM - `{?_MYSQL_PREFIX?}_user_data` AS d + `{?_MYSQL_PREFIX?}_user_data` AS `d` INNER JOIN - `{?_MYSQL_PREFIX?}_bonus_turbo` AS b + `{?_MYSQL_PREFIX?}_bonus_turbo` AS `b` ON - d.`userid`=b.`userid` + `d`.`userid`=`b`.`userid` WHERE - d.`status`='CONFIRMED' AND - d.`userid`=%s AND - b.`%s`=%s + `d`.`status`='CONFIRMED' AND + `d`.`userid`=%s AND + `b`.`%s`=%s LIMIT 1", array( bigintval(getRequestElement('userid')),