From: Roland Häder Date: Mon, 19 Jul 2010 15:38:33 +0000 (+0000) Subject: Fix for inserted codes while registering of extensions, many rewrites/cleanups: X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=ff9e8f739bd4b6e184b2a6bf427334196e501da8 Fix for inserted codes while registering of extensions, many rewrites/cleanups: - Fix for extension registration, codes like {OPEN_CONFIG} and such are no longer compiled in while the extension gots registered. This come handy for e.g. our POINTS replacement. - More usage of countSumTotalData() which should reduce the number of SQL queries in the whole script - Replaced a lot double-quotes with single-quotes - Other minor cleanups --- diff --git a/birthday_confirm.php b/birthday_confirm.php index 157a035837..91d5f911c3 100644 --- a/birthday_confirm.php +++ b/birthday_confirm.php @@ -64,16 +64,16 @@ $chk = bigintval(getRequestParameter('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 INNER JOIN `{?_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/autopurge/purge-general.php b/inc/autopurge/purge-general.php index c932ff47df..8a7735c2f9 100644 --- a/inc/autopurge/purge-general.php +++ b/inc/autopurge/purge-general.php @@ -54,7 +54,7 @@ if (getAutoPurge() > 0) { $admin_points = '0'; // Then check for outdated mail order. We don't delete them just the confirmation links will be deleted. - $result = SQL_QUERY("SELECT + $result = SQL_QUERY('SELECT s.id, s.userid, s.pool_id, t.price FROM `{?_MYSQL_PREFIX?}_user_stats` AS s @@ -65,7 +65,7 @@ ON WHERE s.timestamp_ordered <= (UNIX_TIMESTAMP() - {?auto_purge?}) ORDER BY - s.userid ASC", __FILE__, __LINE__); + s.userid ASC', __FILE__, __LINE__); if (!SQL_HASZERONUMS($result)) { // Start deleting procedure $userid = '0'; $points = '0'; diff --git a/inc/autopurge/purge-inact.php b/inc/autopurge/purge-inact.php index d3c9b49150..01a59c5f90 100644 --- a/inc/autopurge/purge-inact.php +++ b/inc/autopurge/purge-inact.php @@ -124,7 +124,7 @@ ORDER BY // Now let's have a look for inactive accounts we want to delete we newly use the same exclude list // here for e.g. excluding holiday users - $result_inactive = SQL_QUERY("SELECT + $result_inactive = SQL_QUERY('SELECT d.userid, d.email, d.last_online FROM `{?_MYSQL_PREFIX?}_user_data` AS d @@ -133,9 +133,9 @@ WHERE `joined` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND `last_online` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND `ap_notified` < (UNIX_TIMESTAMP() - {?ap_inactive_time?}) -".$EXCLUDE_LIST." +' . $EXCLUDE_LIST . ' ORDER BY - `userid` ASC", __FILE__, __LINE__); + `userid` ASC', __FILE__, __LINE__); if (!SQL_HASZERONUMS($result_inactive)) { // Prepare variable... diff --git a/inc/autopurge/purge-mails.php b/inc/autopurge/purge-mails.php index 712553b655..8358467777 100644 --- a/inc/autopurge/purge-mails.php +++ b/inc/autopurge/purge-mails.php @@ -54,7 +54,8 @@ $result_mails = SQL_QUERY("SELECT FROM `{?_MYSQL_PREFIX?}_pool` WHERE - `data_type`='DELETED' AND `timestamp` <= (UNIX_TIMESTAMP() - {?ap_dm_timeout?}) + `data_type`='DELETED' AND + `timestamp` <= (UNIX_TIMESTAMP() - {?ap_dm_timeout?}) ORDER BY `sender` ASC", __FILE__, __LINE__); @@ -80,7 +81,8 @@ if (!SQL_HASZERONUMS($result_mails)) { FROM `{?_MYSQL_PREFIX?}_pool` WHERE - `data_type`='DELETED' AND timestamp <= (UNIX_TIMESTAMP() - {?ap_dm_timeout?}) + `data_type`='DELETED' AND + `timestamp` <= (UNIX_TIMESTAMP() - {?ap_dm_timeout?}) ORDER BY `sender` ASC", __FILE__, __LINE__); } // END - if @@ -115,7 +117,7 @@ if (!SQL_HASZERONUMS($result_mails)) { // Reset query (to prevent possible errors) ... $result_mails = SQL_QUERY("SELECT - `userid` AS userid + `userid` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE diff --git a/inc/classes/resolver.class.php b/inc/classes/resolver.class.php index e6a63699e7..2677ca6f86 100644 --- a/inc/classes/resolver.class.php +++ b/inc/classes/resolver.class.php @@ -127,7 +127,7 @@ class HostnameResolver { // Purge old entries function purgeEntries() { // SQL for cleaning up - SQL_QUERY("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_dns_cache` WHERE UNIX_TIMESTAMP(`added`) < (UNIX_TIMESTAMP() - {?dns_cache_timeout?})", + SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_dns_cache` WHERE UNIX_TIMESTAMP(`added`) < (UNIX_TIMESTAMP() - {?dns_cache_timeout?})', __METHOD__, __LINE__); } } diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index 67fcdd4e78..aada780666 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -43,7 +43,7 @@ if (!defined('__SECURITY')) { } // END - if // SQL queries -function SQL_QUERY ($sqlString, $F, $L) { +function SQL_QUERY ($sqlString, $F, $L, $enableCodes = true) { // Trim SQL string $sqlString = trim($sqlString); @@ -73,7 +73,7 @@ function SQL_QUERY ($sqlString, $F, $L) { $sqlString = str_replace("\t", ' ', str_replace("\n", ' ', str_replace("\r", ' ', $sqlString))); // Compile config entries out - $GLOBALS['last_sql'] = SQL_PREPARE_SQL_STRING($sqlString); + $GLOBALS['last_sql'] = SQL_PREPARE_SQL_STRING($sqlString, $enableCodes); // Starting time $querytimeBefore = microtime(true); @@ -353,7 +353,7 @@ function SQL_RESULT_FROM_ARRAY ($table, $columns, $idRow, $id, $F, $L) { } // ALTER TABLE wrapper function -function SQL_ALTER_TABLE ($sql, $F, $L) { +function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = true) { // Abort if link is down if (!SQL_IS_LINK_UP()) return false; @@ -469,7 +469,7 @@ function SQL_ALTER_TABLE ($sql, $F, $L) { if ($skip === false) { // Send it to the SQL_QUERY() function //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql); - $result = SQL_QUERY($sql, $F, $L, false); + $result = SQL_QUERY($sql, $F, $L, $enableCodes); } else { // Not executed //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Not executed: ' . $sql); @@ -477,7 +477,7 @@ function SQL_ALTER_TABLE ($sql, $F, $L) { } else { // Other ALTER TABLE query //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql); - $result = SQL_QUERY($sql, $F, $L, false); + $result = SQL_QUERY($sql, $F, $L, $enableCodes); } // Return result @@ -542,14 +542,15 @@ function SQL_HASZERONUMS ($result) { } // Private function to prepare the SQL query string -function SQL_PREPARE_SQL_STRING ($sqlString) { +function SQL_PREPARE_SQL_STRING ($sqlString, $enableCodes = true) { // Is it already cached? if (!isset($GLOBALS['sql_strings'][$sqlString])) { // Compile config+expression code $sqlString2 = FILTER_COMPILE_EXPRESSION_CODE(FILTER_COMPILE_CONFIG($sqlString)); // Do final compilation - $GLOBALS['sql_strings'][$sqlString] = doFinalCompilation($sqlString2, false); + $GLOBALS['sql_strings'][$sqlString] = doFinalCompilation($sqlString2, false, $enableCodes); + //die($sqlString.'
'.$sqlString2.'
'.$GLOBALS['sql_strings'][$sqlString]); } // END - if // Return it diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index c4e88abaf0..e755418acc 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -338,7 +338,7 @@ function registerExtension ($ext_name, $taskId, $dry_run = false, $logout = true setSqlsArray(getExtensionSqls()); // Run installation pre-installation filters - runFilterChain('pre_extension_installed', array('dry_run' => isExtensionDryRun())); + runFilterChain('pre_extension_installed', array('dry_run' => isExtensionDryRun(), 'enable_codes' => false)); // Register extension //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'insert=' . getCurrentExtensionName() . '/' . getCurrentExtensionVersion() . ' - INSERT!'); @@ -720,7 +720,7 @@ function updateExtension ($ext_name, $ext_ver, $dry_run = false) { setSqlsArray(getExtensionSqls()); // Run SQLs - runFilterChain('run_sqls', array('dry_run' => isExtensionDryRun())); + runFilterChain('run_sqls', array('dry_run' => isExtensionDryRun(), 'enable_codes' => false)); if (isExtensionDryRun() === false) { // Run filters on success extension update @@ -758,7 +758,7 @@ function addExtensionVerboseSqlTable ($title = '', $dashed = '', $switch = false // Prepare output for template $content = array( 'i' => ($idx + 1), - 'sql' => $sql + 'sql' => str_replace('{', '{', str_replace('}', '}', encodeEntities($sql))) ); // Load row template diff --git a/inc/extensions/ext-beg.php b/inc/extensions/ext-beg.php index fffd62d727..605a83ba1d 100644 --- a/inc/extensions/ext-beg.php +++ b/inc/extensions/ext-beg.php @@ -54,18 +54,18 @@ switch (getExtensionMode()) { addAdminMenuSql('setup','config_beg','Bettel-Link','IP-Sperre, {OPEN_CONFIG}POINTS{CLOSE_CONFIG}-Vergütung usw. können Sie hier einstellen.', 10); addGuestMenuSql('main','beg','{OPEN_CONFIG}POINTS{CLOSE_CONFIG} erbetteln!','N','Y',4); addMemberMenuSql('main','beg','Ihr Bettel-Link','N','Y',6); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD beg_timeout BIGINT(20) UNSIGNED NOT NULL DEFAULT '600'"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD beg_userid_timeout BIGINT(20) UNSIGNED NOT NULL DEFAULT 1800"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD beg_points FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00100"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD beg_clicks BIGINT(20) UNSIGNED NOT NULL DEFAULT 0"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `beg_timeout` BIGINT(20) UNSIGNED NOT NULL DEFAULT '600'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `beg_userid_timeout` BIGINT(20) UNSIGNED NOT NULL DEFAULT 1800"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `beg_points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00100"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `beg_clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0"); addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_beg_ips`'); addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_beg_ips` ( -id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, -userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, -remote_ip VARCHAR(15) NOT NULL DEFAULT '0.0.0.0', -timeout VARCHAR(10) NOT NULL DEFAULT '', -KEY (userid), -PRIMARY KEY (id) +`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, +`userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, +`remote_ip` VARCHAR(15) NOT NULL DEFAULT '0.0.0.0', +`timeout` VARCHAR(10) NOT NULL DEFAULT '', +KEY (`userid`), +PRIMARY KEY (`id`) ) TYPE={?_TABLE_TYPE?}"); break; @@ -289,7 +289,7 @@ PRIMARY KEY (id) // Remove old entries $OLD = getConfig('beg_timeout'); if (getConfig('beg_userid_timeout') > $OLD) $OLD = getConfig('beg_userid_timeout'); - $result_ext = SQL_QUERY("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_beg_ips` WHERE `timeout` < (UNIX_TIMESTAMP() - ".($OLD + 60*60).")", __FILE__, __LINE__); + $result_ext = SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_beg_ips` WHERE `timeout` < (UNIX_TIMESTAMP() - ' . ($OLD + 60*60) . ')', __FILE__, __LINE__); // Check for beg rallye is active and send mails out if ((isBegRallyeEnabled()) && (isBegNewMemberNotifyEnabled())) { diff --git a/inc/extensions/ext-order.php b/inc/extensions/ext-order.php index 2dfbf60944..37854c2fc6 100644 --- a/inc/extensions/ext-order.php +++ b/inc/extensions/ext-order.php @@ -344,7 +344,7 @@ INDEX (`pool_id`) // @TODO This should be moved out to inc/reset/ if ((isResetModeEnabled()) && (isInstalled()) && (isAdminRegistered()) && (isExtensionInstalledAndNewer('order', '0.1.1'))) { // Reset mail order values - $result_ext = SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `mail_orders`=0 WHERE `mail_orders` > 0", __FILE__, __LINE__); + $result_ext = SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `mail_orders`=0 WHERE `mail_orders` > 0', __FILE__, __LINE__); } // END - if break; diff --git a/inc/extensions/ext-rallye.php b/inc/extensions/ext-rallye.php index f03bf03c01..8b05ceb609 100644 --- a/inc/extensions/ext-rallye.php +++ b/inc/extensions/ext-rallye.php @@ -337,13 +337,13 @@ Zudem sollten Sie mindestens folgende Templates (in templates/".getLangu $ADD1 = ''; $ADD2 = ''; $OR = ''; if (isExtensionInstalledAndNewer('rallye', '0.2.0')) { $ADD1 = ", `min_users`, `min_prices`"; - $ADD2 = ", d.min_users, d.min_prices"; - $OR = " OR (d.min_users <= ".$total." AND d.min_users > 0)"; + $ADD2 = ", d.`min_users`, d.`min_prices`"; + $OR = " OR (d.`min_users` <= " . $total . " AND d.`min_users` > 0)"; } // END - if // Check for new started but not notified rallyes $result = SQL_QUERY("SELECT SQL_SMALL_RESULT - `id`, `title`, `start_time`, `end_time`, `send_notify`".$ADD1." + `id`, `title`, `start_time`, `end_time`, `send_notify`" . $ADD1 . " FROM `{?_MYSQL_PREFIX?}_rallye_data` WHERE @@ -363,14 +363,14 @@ 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".$ADD2." + d.`id`, d.`title`, d.`start_time`, d.`end_time`, d.`send_notify`" . $ADD2 . " FROM `{?_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()".$OR.") + d.`is_active`='Y' AND + d.`notified`='Y' AND + d.`expired`='N' AND + (d.`end_time` <= UNIX_TIMESTAMP()".$OR.") LIMIT 1", __FILE__, __LINE__); if ((SQL_NUMROWS($result) == 1) && (isExtensionActive('autopurge'))) { // End rallye here... diff --git a/inc/extensions/ext-transfer.php b/inc/extensions/ext-transfer.php index 8bdb7b3ac1..1b3aee19e9 100644 --- a/inc/extensions/ext-transfer.php +++ b/inc/extensions/ext-transfer.php @@ -56,30 +56,30 @@ switch (getExtensionMode()) { // Transfer from a member addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_user_transfers_in` ( -id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, -userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, -from_userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, -points BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, -reason VARCHAR(255) NOT NULL DEFAULT '', -time_trans VARCHAR(14) NOT NULL DEFAULT 0, -trans_id VARCHAR(12) NOT NULL DEFAULT '', -KEY (userid), -KEY (from_userid), -PRIMARY KEY (id) +`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, +`userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, +`from_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, +`points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, +`reason` VARCHAR(255) NOT NULL DEFAULT '', +`time_trans` VARCHAR(14) NOT NULL DEFAULT 0, +`trans_id` VARCHAR(12) NOT NULL DEFAULT '', +KEY (`userid`), +KEY (`from_userid`), +PRIMARY KEY (`id`) ) Type={?_TABLE_TYPE?}"); // Transfers to a member addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_user_transfers_out` ( -id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, -userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, -to_userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, -points BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, -reason VARCHAR(255) NOT NULL DEFAULT '', -time_trans VARCHAR(14) NOT NULL DEFAULT 0, -trans_id VARCHAR(12) NOT NULL DEFAULT '', -KEY (userid), -KEY (to_userid), -PRIMARY KEY (id) +`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, +`userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, +`to_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, +`points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, +`reason` VARCHAR(255) NOT NULL DEFAULT '', +`time_trans` VARCHAR(14) NOT NULL DEFAULT 0, +`trans_id` VARCHAR(12) NOT NULL DEFAULT '', +KEY (`userid`), +KEY (`to_userid`), +PRIMARY KEY (`id`) ) Type={?_TABLE_TYPE?}"); // Admin menu @@ -231,9 +231,9 @@ PRIMARY KEY (id) break; case '0.2.3': // SQL queries for v0.2.3 - addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (la_id, la_action, la_what) VALUES ('member', '', 'list_transfer')"); - addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (la_id, la_action, la_what) VALUES ('member', '', 'del_transfer')"); - addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (la_id, la_action, la_what) VALUES ('config', '', 'config_transfer')"); + addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (`la_id`, `la_action`, `la_what`) VALUES ('member', '', 'list_transfer')"); + addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (`la_id`, `la_action`, `la_what`) VALUES ('member', '', 'del_transfer')"); + addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (`la_id`, `la_action`, `la_what`) VALUES ('config', '', 'config_transfer')"); // Depends on sql_patches (or you have to execute these both SQL statements by phpMyAdmin addExtensionUpdateDependency('sql_patches'); diff --git a/inc/filter-functions.php b/inc/filter-functions.php index d0e881ae8c..dac79b3107 100644 --- a/inc/filter-functions.php +++ b/inc/filter-functions.php @@ -63,12 +63,12 @@ function initFilterSystem () { if (isExtensionINstalledAndNewer('sql_patches', '0.6.0')) $add = ", `filter_counter`"; // Load all filters - $result = SQL_QUERY("SELECT - `filter_name`,`filter_function`,`filter_active`".$add." + $result = SQL_QUERY('SELECT + `filter_name`,`filter_function`,`filter_active`' . $add . ' FROM `{?_MYSQL_PREFIX?}_filters` ORDER BY - `filter_id` ASC", __FUNCTION__, __LINE__); + `filter_id` ASC', __FUNCTION__, __LINE__); // Are there entries? if (!SQL_HASZERONUMS($result)) { diff --git a/inc/filters.php b/inc/filters.php index 181c1fe4f2..333b5eb34e 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -254,17 +254,20 @@ function FILTER_RUN_SQLS ($data) { // Trim spaces away $sql = trim($sql); + // Is 'enable_codes' not set? Then set it to true + if (!isset($data['enable_codes'])) $data['enable_codes'] = true; + // Is there still a query left? if (!empty($sql)) { // Do we have an "ALTER TABLE" command? if (substr(strtolower($sql), 0, 11) == 'alter table') { // Analyse the alteration command //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "Alterting table: {$sql}"); - SQL_ALTER_TABLE($sql, __FUNCTION__, __LINE__); + SQL_ALTER_TABLE($sql, __FUNCTION__, __LINE__, $data['enable_codes']); } else { // Run regular SQL command //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "Running regular query: {$sql}"); - SQL_QUERY($sql, __FUNCTION__, __LINE__, false); + SQL_QUERY($sql, __FUNCTION__, __LINE__, $data['enable_codes']); } } // END - if } // END - foreach diff --git a/inc/gen_mediadata.php b/inc/gen_mediadata.php index 7f4246a508..8922660483 100644 --- a/inc/gen_mediadata.php +++ b/inc/gen_mediadata.php @@ -86,14 +86,10 @@ updateMediadataEntry(array('total_clicks', 'bonus_clicks') , 'init', $bclicks); updateMediadataEntry(array('total_orders', 'bonus_orders') , 'init', $bcount); // Aquire total used points -$result = SQL_QUERY('SELECT SUM(`used_points`) AS used_points FROM `{?_MYSQL_PREFIX?}_user_data`', __FILE__, __LINE__); -list($used) = SQL_FETCHROW($result); -SQL_FREERESULT($result); +$used = countSumTotalData('', 'user_data', 'used_points', ''); // ... and total points -$result = SQL_QUERY('SELECT SUM(`points`) AS points FROM `{?_MYSQL_PREFIX?}_user_points`', __FILE__, __LINE__); -list($points) = SQL_FETCHROW($result); -SQL_FREERESULT($result); +$points = countSumTotalData('', 'user_points', 'points', ''); // Update database updateMediadataEntry(array('total_points'), 'init', ($points - $used)); diff --git a/inc/gen_refback.php b/inc/gen_refback.php index 0ffa66449a..e4fd569b19 100644 --- a/inc/gen_refback.php +++ b/inc/gen_refback.php @@ -46,16 +46,16 @@ if (!defined('__SECURITY')) { loadIncludeOnce('inc/libs/refback_functions.php'); // Sanity-check: Do we have ref level 0? -$result = SQL_QUERY("SELECT `id` FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `level`=0", __FILE__, __LINE__); +$result = SQL_QUERY('SELECT `id` FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `level`=0', __FILE__, __LINE__); if (!SQL_HASZERONUMS($result)) { // Remove index temporaly - SQL_ALTER_TABLE("ALTER TABLE `{?_MYSQL_PREFIX?}_refsystem` DROP INDEX `userid_level`", __FILE__, __LINE__); + SQL_ALTER_TABLE('ALTER TABLE `{?_MYSQL_PREFIX?}_refsystem` DROP INDEX `userid_level`', __FILE__, __LINE__); // Upgrade refsystem, ref-level 0 is silly here - SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_refsystem` SET `level`=`level`+1", __FILE__, __LINE__); + SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_refsystem` SET `level`=`level`+1', __FILE__, __LINE__); // Add it again - SQL_ALTER_TABLE("ALTER TABLE `{?_MYSQL_PREFIX?}_refsystem` ADD UNIQUE `userid_level` ( `userid`,`level` )", __FILE__, __LINE__); + SQL_ALTER_TABLE('ALTER TABLE `{?_MYSQL_PREFIX?}_refsystem` ADD UNIQUE `userid_level` ( `userid`,`level` )', __FILE__, __LINE__); // Rebuild cache rebuildCache('refsystem', 'refsystem'); diff --git a/inc/libs/admins_functions.php b/inc/libs/admins_functions.php index e549b1fca3..f87aff12df 100644 --- a/inc/libs/admins_functions.php +++ b/inc/libs/admins_functions.php @@ -393,7 +393,7 @@ function adminsRemoveAdminAccount ($postData) { // List all admin accounts function adminsListAdminAccounts() { // Select all admin accounts - $result = SQL_QUERY("SELECT `id`, `login`, `email`, `default_acl` AS mode, `la_mode` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `login` ASC", __FUNCTION__, __LINE__); + $result = SQL_QUERY('SELECT `id`, `login`, `email`, `default_acl` AS mode, `la_mode` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `login` ASC', __FUNCTION__, __LINE__); $OUT = ''; while ($content = SQL_FETCHARRAY($result)) { // Compile some variables @@ -460,7 +460,7 @@ function sendAdminsEmails ($subj, $template, $content, $userid) { } } elseif (($adminId == '0') || (empty($adminId))) { // Select all email adresses - $result = SQL_QUERY("SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC", + $result = SQL_QUERY('SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC', __FUNCTION__, __LINE__); } else { // If Admin-Id is not "to-all" select diff --git a/inc/libs/bonus_functions.php b/inc/libs/bonus_functions.php index 17736e9292..88f6d00262 100644 --- a/inc/libs/bonus_functions.php +++ b/inc/libs/bonus_functions.php @@ -261,7 +261,7 @@ function handleBonusPoints ($mode) { // Purges expired fast-click bonus entries function purgeExpiredTurboBonus() { // Remove entries - $result = SQL_QUERY("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_bonus_turbo` WHERE `timemark` < (UNIX_TIMESTAMP() - {?bonus_timeout?})", __FUNCTION__, __LINE__); + $result = SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_bonus_turbo` WHERE `timemark` < (UNIX_TIMESTAMP() - {?bonus_timeout?})', __FUNCTION__, __LINE__); if (SQL_AFFECTEDROWS() > 0) { // Send out email to admin diff --git a/inc/libs/network_functions.php b/inc/libs/network_functions.php index 246e054dfc..535a9ec065 100644 --- a/inc/libs/network_functions.php +++ b/inc/libs/network_functions.php @@ -358,12 +358,12 @@ function generateAdminNetworkList () { $content = ''; // Query for all networks - $result = SQL_QUERY("SELECT + $result = SQL_QUERY('SELECT `network_id`, `network_short_name`, `network_title` FROM `{?_MYSQL_PREFIX?}_network_data` ORDER BY - `network_short_name` ASC", __FUNCTION__, __LINE__); + `network_short_name` ASC', __FUNCTION__, __LINE__); // Do we have entries? if (!SQL_HASZERONUMS($result)) { @@ -441,7 +441,7 @@ function generateAdminDistinctNetworkTypeList () { $content = ''; // Query all types of this network - $result = SQL_QUERY("SELECT + $result = SQL_QUERY('SELECT t.`network_type_id`, t.`network_type_handle`, d.`network_title` FROM `{?_MYSQL_PREFIX?}_network_types` AS t @@ -451,7 +451,7 @@ ON t.`network_id`=d.`network_id` ORDER BY d.`network_short_name` ASC, - t.`network_type_handle` ASC", __FUNCTION__, __LINE__); + t.`network_type_handle` ASC', __FUNCTION__, __LINE__); // Do we have entries? if (!SQL_HASZERONUMS($result)) { @@ -594,10 +594,10 @@ function doAdminNetworkProcessAddnetworkForm () { unsetPostRequestParameter('ok'); // Add the whole request to database - SQL_QUERY("INSERT INTO + SQL_QUERY('INSERT INTO `{?_MYSQL_PREFIX?}_network_data` ( - `" . implode('`,`', array_keys(postRequestArray())) . "` + `' . implode('`,`', array_keys(postRequestArray())) . "` ) VALUES ( '" . implode("','", array_values(postRequestArray())) . "' )", __FUNCTION__, __LINE__); @@ -1103,10 +1103,10 @@ function doAdminNetworkProcessAddnetworkparamForm () { } // END - if // Add the whole request to database - SQL_QUERY("INSERT INTO + SQL_QUERY('INSERT INTO `{?_MYSQL_PREFIX?}_network_request_params` ( - `" . implode('`,`', array_keys(postRequestArray())) . "` + `' . implode('`,`', array_keys(postRequestArray())) . "` ) VALUES ( '" . implode("','", array_values(postRequestArray())) . "' )", __FUNCTION__, __LINE__); diff --git a/inc/libs/optimize_functions.php b/inc/libs/optimize_functions.php index 6fae587174..011484fd2f 100644 --- a/inc/libs/optimize_functions.php +++ b/inc/libs/optimize_functions.php @@ -48,7 +48,7 @@ function repairOptimizeDatabase () { $tot_data = '0'; $tabs = '0'; $opts = '0'; $tot_idx = '0'; $total_gain = '0'; $tot_all = '0'; - $result = SQL_QUERY("SHOW TABLE STATUS FROM `{?__DB_NAME?}`", __FUNCTION__, __LINE__); + $result = SQL_QUERY('SHOW TABLE STATUS FROM `{?__DB_NAME?}`', __FUNCTION__, __LINE__); $tabs = SQL_NUMROWS($result); $ret['total_size'] = '0'; $ret['total_tabs'] = $tabs; @@ -91,7 +91,7 @@ function repairOptimizeDatabase () { array($total_gain), __FUNCTION__, __LINE__); // Get total runs and total optimization count - $result = SQL_QUERY("SELECT COUNT(`id`) AS `total_rows`, SUM(`gain`) AS `total_optimized` FROM `{?_MYSQL_PREFIX?}_optimize_gain`", __FUNCTION__, __LINE__); + $result = SQL_QUERY('SELECT COUNT(`id`) AS `total_rows`, SUM(`gain`) AS `total_optimized` FROM `{?_MYSQL_PREFIX?}_optimize_gain`', __FUNCTION__, __LINE__); $ret = merge_array($ret, SQL_FETCHARRAY($result)); // Free memory diff --git a/inc/libs/register_functions.php b/inc/libs/register_functions.php index 8a3880c940..97c6216650 100644 --- a/inc/libs/register_functions.php +++ b/inc/libs/register_functions.php @@ -84,7 +84,7 @@ function registerGenerateCategoryTable ($mode, $return=false) { if (isAdmin()) $AND = ''; // Look for categories - $result = SQL_QUERY("SELECT `id`, `cat`, `visible` FROM `{?_MYSQL_PREFIX?}_cats` ".$AND." ORDER BY `sort` ASC", + $result = SQL_QUERY('SELECT `id`, `cat`, `visible` FROM `{?_MYSQL_PREFIX?}_cats` ' . $AND . ' ORDER BY `sort` ASC', __FUNCTION__, __LINE__); if (!SQL_HASZERONUMS($result)) { @@ -135,7 +135,7 @@ function registerOutputFailedMessage ($messageId, $extra='') { // Run a filter for must-fillout fields function FILTER_REGISTER_MUST_FILLOUT ($content) { // Get all fields for output - $result = SQL_QUERY("SELECT `field_name`, `field_required` FROM `{?_MYSQL_PREFIX?}_must_register` ORDER BY `id` ASC", + $result = SQL_QUERY('SELECT `field_name`, `field_required` FROM `{?_MYSQL_PREFIX?}_must_register` ORDER BY `id` ASC', __FUNCTION__, __LINE__); // Walk through all entries diff --git a/inc/libs/sponsor_functions.php b/inc/libs/sponsor_functions.php index 97034d5b9b..c6cd2e5b34 100644 --- a/inc/libs/sponsor_functions.php +++ b/inc/libs/sponsor_functions.php @@ -272,7 +272,7 @@ LIMIT 1", // function addSponsorMenu ($current) { $OUT = ''; - $WHERE = " AND active='Y'"; + $WHERE = " AND `active`='Y'"; if (isAdmin()) $WHERE = ''; // Load main menu entries @@ -282,7 +282,7 @@ FROM `{?_MYSQL_PREFIX?}_sponsor_menu` WHERE (`what`='' OR `what` IS NULL) - ".$WHERE." + " . $WHERE . " ORDER BY `sort` ASC", __FUNCTION__, __LINE__); if (!SQL_HASZERONUMS($result_main)) { @@ -297,7 +297,7 @@ WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL - ".$WHERE." + " . $WHERE . " ORDER BY `sort` ASC", array($content['main_action']), __FUNCTION__, __LINE__); diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 92655c6666..546f27d070 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -1214,14 +1214,14 @@ ORDER BY // Determine how many users are Online in surfbar function SURFBAR_DETERMINE_TOTAL_ONLINE () { // Count all users in surfbar modue and return the value - $result = SQL_QUERY("SELECT + $result = SQL_QUERY('SELECT `stats_id` FROM `{?_MYSQL_PREFIX?}_surfbar_stats` WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`stats_last_surfed`)) <= {?online_timeout?} GROUP BY - `stats_userid` ASC", __FUNCTION__, __LINE__); + `stats_userid` ASC', __FUNCTION__, __LINE__); // Fetch count $cnt = SQL_NUMROWS($result); @@ -1463,10 +1463,10 @@ LEFT JOIN ON sbu.url_id=l.locks_url_id WHERE - sbu.url_userid NOT IN (".implode(',', $userids).") AND + 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." + " . $add . " GROUP BY sbu.url_id ASC", __FUNCTION__, __LINE__); diff --git a/inc/libs/task_functions.php b/inc/libs/task_functions.php index 1e5e0ec4be..cee84ef22a 100644 --- a/inc/libs/task_functions.php +++ b/inc/libs/task_functions.php @@ -239,10 +239,10 @@ function outputAdvancedOverview (&$result_main) { // Check for more extensions // @TODO These can be rewritten to filter - if (getConfig('def_refid') > 0) $EXCLUDE_LIST .= ' AND d.userid != {?def_refid?}'; - if (isExtensionActive('beg')) $EXCLUDE_LIST .= ' AND d.userid != {?beg_userid?}'; - if (isExtensionActive('bonus')) $EXCLUDE_LIST .= ' AND d.userid != {?bonus_userid?}'; - if (isExtensionActive('doubler')) $EXCLUDE_LIST .= ' AND d.userid != {?doubler_userid?}'; + if (getConfig('def_refid') > 0) $EXCLUDE_LIST .= ' AND d.`userid` != {?def_refid?}'; + if (isExtensionActive('beg')) $EXCLUDE_LIST .= ' AND d.`userid` != {?beg_userid?}'; + if (isExtensionActive('bonus')) $EXCLUDE_LIST .= ' AND d.`userid` != {?bonus_userid?}'; + if (isExtensionActive('doubler')) $EXCLUDE_LIST .= ' AND d.`userid` != {?doubler_userid?}'; if (isExtensionInstalledAndNewer('holiday', '0.1.3')) { // Recent ext-holiday found $EXCLUDE_LIST .= " AND d.`holiday_active`='N'"; diff --git a/inc/libs/theme_functions.php b/inc/libs/theme_functions.php index 895ef86bf2..1fcbd84415 100644 --- a/inc/libs/theme_functions.php +++ b/inc/libs/theme_functions.php @@ -66,13 +66,13 @@ function generateThemeSelectionBox () { if (isAdmin()) $add = ''; // Select all themes we want - $result = SQL_QUERY("SELECT + $result = SQL_QUERY('SELECT `theme_path`, `theme_name` FROM `{?_MYSQL_PREFIX?}_themes` -".$add." +' . $add . ' ORDER BY - `theme_name` ASC", __FUNCTION__, __LINE__); + `theme_name` ASC', __FUNCTION__, __LINE__); // Load all themes while ($content = SQL_FETCHARRAY($result)) { diff --git a/inc/libs/transfer_functions.php b/inc/libs/transfer_functions.php index ee6946ae32..2f2d61c827 100644 --- a/inc/libs/transfer_functions.php +++ b/inc/libs/transfer_functions.php @@ -45,7 +45,7 @@ if (!defined('__SECURITY')) { // Purge expired transfer entries function autoPurgeTransfers ($max, $age) { // First get total in-going lines - $result = SQL_QUERY("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` ORDER BY `id` ASC", __FUNCTION__, __LINE__); + $result = SQL_QUERY('SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` ORDER BY `id` ASC', __FUNCTION__, __LINE__); if (SQL_NUMROWS($result) > $max) { // Update overdue transfers $remove = SQL_NUMROWS($result) - $max; @@ -56,7 +56,7 @@ function autoPurgeTransfers ($max, $age) { } // END - if // Second get total out-going lines - $result = SQL_QUERY("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_transfers_out` ORDER BY `id` ASC", __FUNCTION__, __LINE__); + $result = SQL_QUERY('SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_transfers_out` ORDER BY `id` ASC', __FUNCTION__, __LINE__); if (SQL_NUMROWS($result) > $max) { // Update overdue transfers $remove = SQL_NUMROWS($result) - $max; diff --git a/inc/modules/admin/what-admin_add.php b/inc/modules/admin/what-admin_add.php index 980d6f8577..7e66899d82 100644 --- a/inc/modules/admin/what-admin_add.php +++ b/inc/modules/admin/what-admin_add.php @@ -55,7 +55,7 @@ if (!isFormSent()) { $menus = array(); $titles = array(); $below = array(); // Get all available main menus - $result = SQL_QUERY("SELECT action, title, sort FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE (`what`='' OR `what` IS NULL) ORDER BY `sort`", __FILE__, __LINE__); + $result = SQL_QUERY("SELECT `action`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE (`what`='' OR `what` IS NULL) ORDER BY `sort` ASC", __FILE__, __LINE__); if (!SQL_HASZERONUMS($result)) { // Read menu structure // @TODO Cant this be rewritten? @@ -93,8 +93,8 @@ if (!isFormSent()) { // Load sub menus :) foreach ($menus as $key_main => $value_main) { - $result = SQL_QUERY_ESC("SELECT `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort`", - array($value_main), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC", + array($value_main), __FILE__, __LINE__); if (!SQL_HASZERONUMS($result)) { // Init arrays $menus[$value_main] = array(); diff --git a/inc/modules/admin/what-config_admins.php b/inc/modules/admin/what-config_admins.php index 5c73970d35..f964eedb10 100644 --- a/inc/modules/admin/what-config_admins.php +++ b/inc/modules/admin/what-config_admins.php @@ -154,11 +154,11 @@ if ((isFormSent('edit')) && (ifPostContainsSelections())) { $BOTH = ((isPostRequestParameterSet('action_menu')) && (isPostRequestParameterSet('what_menu'))); if (((isPostRequestParameterSet('action_menu')) || (isPostRequestParameterSet('what_menu'))) && ($BOTH === false)) { // Main or sub menu selected - $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE admin_id=%s AND action_menu='%s' AND what_menu='%s' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `admin_id`=%s AND `action_menu`='%s' AND `what_menu`='%s' LIMIT 1", array(bigintval(postRequestParameter('admin_id')), postRequestParameter('action_menu'), postRequestParameter('what_menu')), __FILE__, __LINE__); if (SQL_HASZERONUMS($result)) { // Finally add the new ACL - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_acls` (admin_id, action_menu, what_menu, access_mode) + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_acls` (`admin_id`, `action_menu`, `what_menu`, `access_mode`) VALUES ('%s','%s','%s','%s')", array( bigintval(postRequestParameter('admin_id')), diff --git a/inc/modules/admin/what-edit_emails.php b/inc/modules/admin/what-edit_emails.php index 0ecb55d49f..794fd2de8f 100644 --- a/inc/modules/admin/what-edit_emails.php +++ b/inc/modules/admin/what-edit_emails.php @@ -50,12 +50,12 @@ if ((isFormSent()) && (!isPostRequestParameterSet('id'))) { } // END - if // Query the pool -$result = SQL_QUERY("SELECT +$result = SQL_QUERY('SELECT `id`, `sender`, `subject`, `payment_id`, `cat_id` FROM `{?_MYSQL_PREFIX?}_pool` ORDER BY - `timestamp` ASC", __FILE__, __LINE__); + `timestamp` ASC', __FILE__, __LINE__); // Entries found? if (!SQL_HASZERONUMS($result)) { diff --git a/inc/modules/admin/what-list_beg.php b/inc/modules/admin/what-list_beg.php index 5c68a0418d..225bac8125 100644 --- a/inc/modules/admin/what-list_beg.php +++ b/inc/modules/admin/what-list_beg.php @@ -67,7 +67,9 @@ if (isBegRallyeEnabled()) { FROM `{?_MYSQL_PREFIX?}_user_data` WHERE - `status`='CONFIRMED' AND beg_points > 0".$lastOnline." + `status`='CONFIRMED' AND + `beg_points` > 0 + " . $lastOnline . " ORDER BY `beg_points` DESC, `last_online` DESC, diff --git a/inc/modules/admin/what-mem_add.php b/inc/modules/admin/what-mem_add.php index 682dcdbd20..5c99507b6a 100644 --- a/inc/modules/admin/what-mem_add.php +++ b/inc/modules/admin/what-mem_add.php @@ -99,8 +99,8 @@ if (!isFormSent()) { // Load sub menus :) foreach ($menus as $key_main => $value_main) { - $result = SQL_QUERY_ESC("SELECT what, title, sort FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='%s' AND `what` != '' ORDER BY `sort`", - array($value_main), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='%s' AND `what` != '' ORDER BY `sort` ASC", + array($value_main), __FILE__, __LINE__); if (!SQL_HASZERONUMS($result)) { // Initialize arrays $menus[$value_main] = array(); diff --git a/inc/modules/admin/what-repair_amnu.php b/inc/modules/admin/what-repair_amnu.php index 00cb2d514e..c9fc15ea22 100644 --- a/inc/modules/admin/what-repair_amnu.php +++ b/inc/modules/admin/what-repair_amnu.php @@ -48,7 +48,7 @@ addMenuDescription('admin', __FILE__); $ACTIONS = array(); // First fix all main menus (what = '')... -$result_fix = SQL_QUERY("SELECT id, action FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE (`what`='' OR `what` IS NULL) AND action != 'logout' ORDER BY `sort` ASC", __FILE__, __LINE__); +$result_fix = SQL_QUERY("SELECT `id`, `action` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE (`what`='' OR `what` IS NULL) AND `action` != 'logout' ORDER BY `sort` ASC", __FILE__, __LINE__); $cnt = '0'; $REP = '0'; while ($content = SQL_FETCHARRAY($result_fix)) { // Store act value for later usage in sorting sub menus diff --git a/inc/modules/admin/what-repair_gmnu.php b/inc/modules/admin/what-repair_gmnu.php index a3b3ce3e34..a817e85a83 100644 --- a/inc/modules/admin/what-repair_gmnu.php +++ b/inc/modules/admin/what-repair_gmnu.php @@ -47,7 +47,7 @@ addMenuDescription('admin', __FILE__); $ACTIONS = array(); // First fix all main menus (what = '')... -$result_fix = SQL_QUERY("SELECT id, action FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE (`what`='' OR `what` IS NULL) AND action != 'logout' ORDER BY `sort` ASC", __FILE__, __LINE__); +$result_fix = SQL_QUERY("SELECT `id`, `action` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE (`what`='' OR `what` IS NULL) AND `action` != 'logout' ORDER BY `sort` ASC", __FILE__, __LINE__); $cnt = '0'; $REP = '0'; while ($content = SQL_FETCHARRAY($result_fix)) { // Store act value for later usage in sorting sub menus @@ -69,12 +69,12 @@ $result_sort = SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET sort='999' W // Now sort every each menu foreach ($ACTIONS as $action) { - $result_fix = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort`", + $result_fix = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC", array($action), __FILE__, __LINE__); $cnt = 1; while ($content = SQL_FETCHARRAY($result_fix)) { // Fix weight - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET sort=%s WHERE `id`=%s LIMIT 1", + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `sort`=%s WHERE `id`=%s LIMIT 1", array($cnt, $content['id']), __FILE__, __LINE__); $REP += SQL_AFFECTEDROWS(); diff --git a/inc/modules/admin/what-repair_mmnu.php b/inc/modules/admin/what-repair_mmnu.php index 9ce232fef3..374e1cb8f8 100644 --- a/inc/modules/admin/what-repair_mmnu.php +++ b/inc/modules/admin/what-repair_mmnu.php @@ -48,14 +48,14 @@ addMenuDescription('admin', __FILE__); $ACTIONS = array(); // First fix all main menus (what = '')... -$result_fix = SQL_QUERY("SELECT id, action FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE (`what`='' OR `what` IS NULL) AND action != 'logout' ORDER BY `sort` ASC", __FILE__, __LINE__); +$result_fix = SQL_QUERY("SELECT `id`, `action` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE (`what`='' OR `what` IS NULL) AND `action` != 'logout' ORDER BY `sort` ASC", __FILE__, __LINE__); $cnt = '0'; $REP = '0'; while ($content = SQL_FETCHARRAY($result_fix)) { // Store action value for later usage in sorting sub menus $ACTIONS[] = $content['action']; // Fix weight - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET sort=%s WHERE `id`=%s LIMIT 1", + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `sort`=%s WHERE `id`=%s LIMIT 1", array($cnt, $content['id']), __FILE__, __LINE__); $REP += SQL_AFFECTEDROWS(); @@ -68,7 +68,7 @@ SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET sort='999' WHERE `action`= // Now sort every each menu foreach ($ACTIONS as $action) { - $result_fix = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort`", + $result_fix = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC", array($action), __FILE__, __LINE__); $cnt = 1; while ($content = SQL_FETCHARRAY($result_fix)) { diff --git a/inc/modules/guest/what-active.php b/inc/modules/guest/what-active.php index 9b14876013..559ecb44d2 100644 --- a/inc/modules/guest/what-active.php +++ b/inc/modules/guest/what-active.php @@ -62,7 +62,8 @@ $result = SQL_QUERY("SELECT FROM `{?_MYSQL_PREFIX?}_user_data` WHERE - `last_online` >= {?START_TDAY?} AND `status`='CONFIRMED' + `last_online` >= {?START_TDAY?} AND + `status`='CONFIRMED' ORDER BY `last_online` DESC LIMIT {?active_limit?}", __FILE__, __LINE__); diff --git a/inc/modules/guest/what-mediadata.php b/inc/modules/guest/what-mediadata.php index 6fd3e085d1..733327beeb 100644 --- a/inc/modules/guest/what-mediadata.php +++ b/inc/modules/guest/what-mediadata.php @@ -136,10 +136,10 @@ if (empty($jackpot)) $jackpot = '0'; $content['jackpot'] = translateComma($jackpot); // Total referal link clicks, total logins -$result = SQL_QUERY("SELECT +$result = SQL_QUERY('SELECT SUM(d.ref_clicks), SUM(d.total_logins) FROM - `{?_MYSQL_PREFIX?}_user_data` AS d", __FILE__, __LINE__); + `{?_MYSQL_PREFIX?}_user_data` AS d', __FILE__, __LINE__); list($ref, $logins) = SQL_FETCHROW($result); SQL_FREERESULT($result); @@ -258,10 +258,14 @@ ON if (empty($count_in)) $count_in = '0'; if (empty($points_in)) $points_in = '0'; - $result = SQL_QUERY("SELECT COUNT(t.id), SUM(t.points) -FROM `{?_MYSQL_PREFIX?}_user_transfers_out` AS t -LEFT JOIN `{?_MYSQL_PREFIX?}_user_data` AS d -ON t.userid=d.userid", + $result = SQL_QUERY("SELECT + COUNT(t.id), SUM(t.points) +FROM + `{?_MYSQL_PREFIX?}_user_transfers_out` AS t +LEFT JOIN + `{?_MYSQL_PREFIX?}_user_data` AS d +ON + t.userid=d.userid", __FILE__, __LINE__); list($count_out, $points_out) = SQL_FETCHROW($result); SQL_FREERESULT($result); diff --git a/inc/modules/guest/what-stats.php b/inc/modules/guest/what-stats.php index 06cb3d8977..6e6c88e284 100644 --- a/inc/modules/guest/what-stats.php +++ b/inc/modules/guest/what-stats.php @@ -190,8 +190,8 @@ switch (getConfig('guest_stats')) { if (isAdmin()) $AND = ''; // Query for guest and member menus - $guest_t10 = SQL_QUERY("SELECT `counter`, `title` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `counter` > 0".$AND." ORDER BY `counter` DESC LIMIT 0,10", __FILE__, __LINE__); - $mem_t10 = SQL_QUERY("SELECT `counter`, `title` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `counter` > 0".$AND." ORDER BY `counter` DESC LIMIT 0,10", __FILE__, __LINE__); + $guest_t10 = SQL_QUERY('SELECT `counter`, `title` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `counter` > 0' . $AND . ' ORDER BY `counter` DESC LIMIT 0,10', __FILE__, __LINE__); + $mem_t10 = SQL_QUERY('SELECT `counter`, `title` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `counter` > 0' . $AND . ' ORDER BY `counter` DESC LIMIT 0,10', __FILE__, __LINE__); $OUT = ''; if (!SQL_HASZERONUMS($guest_t10)) { diff --git a/inc/monthly/monthly_beg.php b/inc/monthly/monthly_beg.php index 386bcb9b15..2ce572fc9d 100644 --- a/inc/monthly/monthly_beg.php +++ b/inc/monthly/monthly_beg.php @@ -96,7 +96,7 @@ LIMIT {?beg_ranks?}", __FILE__, __LINE__); } // END - while // Reset accounts - $result = SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `beg_points`=0.00000 WHERE `beg_points` > 0", __FILE__, __LINE__); + $result = SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `beg_points`=0.00000 WHERE `beg_points` > 0', __FILE__, __LINE__); } // END - if // Free memory diff --git a/inc/monthly/monthly_bonus.php b/inc/monthly/monthly_bonus.php index 516e43a0d2..ed26373785 100644 --- a/inc/monthly/monthly_bonus.php +++ b/inc/monthly/monthly_bonus.php @@ -79,15 +79,15 @@ if (($curr != getConfig('last_month')) && (getConfig('bonus_ranks') > 0) && (get } // END - if // Run SQL string to check for accounts - $result_main = SQL_QUERY("SELECT + $result_main = SQL_QUERY('SELECT `userid`, `email`, `gender`, `surname`, `family`, (0" . $add . ") AS points FROM `{?_MYSQL_PREFIX?}_user_data` -" . $whereStatement1 . " +' . $whereStatement1 . ' ORDER BY `points` DESC, `userid` ASC -LIMIT {?bonus_ranks?}", __FILE__, __LINE__); +LIMIT {?bonus_ranks?}', __FILE__, __LINE__); // Some entries were found? if (!SQL_HASZERONUMS($result_main)) { diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 1dd3aa1ca3..51e24c8ede 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -585,13 +585,13 @@ function addMaxReceiveList ($mode, $default = '', $return = false) { switch ($mode) { case 'guest': // Guests (in the registration form) are not allowed to select 0 mails per day. - $result = SQL_QUERY("SELECT `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `value` > 0 ORDER BY `value` ASC", + $result = SQL_QUERY('SELECT `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `value` > 0 ORDER BY `value` ASC', __FUNCTION__, __LINE__); break; case 'member': // Members are allowed to set to zero mails per day (we will change this soon!) - $result = SQL_QUERY("SELECT `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` ORDER BY `value` ASC", + $result = SQL_QUERY('SELECT `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` ORDER BY `value` ASC', __FUNCTION__, __LINE__); break; @@ -1171,7 +1171,7 @@ function updateReferalCounter ($userid) { // because we need it when there is no ext-admins installed function sendAdminEmails ($subj, $message) { // Load all admin email addresses - $result = SQL_QUERY("SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC", __FUNCTION__, __LINE__); + $result = SQL_QUERY('SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC', __FUNCTION__, __LINE__); while ($content = SQL_FETCHARRAY($result)) { // Send the email out sendEmail($content['email'], $subj, $message); @@ -1467,15 +1467,15 @@ function deleteUserAccount ($userid, $reason) { $data['points'] = '0'; $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__); @@ -1602,7 +1602,7 @@ function generateCategoryOptionsList ($mode) { ); // Get categories - $result = SQL_QUERY("SELECT `id`, `cat` FROM `{?_MYSQL_PREFIX?}_cats`".$whereStatement." ORDER BY `sort` ASC", + $result = SQL_QUERY('SELECT `id`, `cat` FROM `{?_MYSQL_PREFIX?}_cats`' . $whereStatement . ' ORDER BY `sort` ASC', __FUNCTION__, __LINE__); // Do we have entries? @@ -1735,8 +1735,8 @@ function generateReceiverList ($cat, $receiver, $mode = '') { // Category given? if ($cat > 0) { // Select category - $CAT_TABS = "LEFT JOIN `{?_MYSQL_PREFIX?}_user_cats` AS c ON d.userid=c.userid"; - $CAT_WHERE = sprintf(" AND c.cat_id=%s", $cat); + $CAT_TABS = "LEFT JOIN `{?_MYSQL_PREFIX?}_user_cats` AS c ON d.`userid`=c.`userid`"; + $CAT_WHERE = sprintf(" AND c.`cat_id`=%s", $cat); } // END - if // Exclude users in holiday? diff --git a/inc/reset/reset_bonus.php b/inc/reset/reset_bonus.php index f57a665cf6..52d886ba80 100644 --- a/inc/reset/reset_bonus.php +++ b/inc/reset/reset_bonus.php @@ -52,14 +52,14 @@ if (!defined('__SECURITY')) { purgeExpiredTurboBonus(); // Reset accounts -SQL_QUERY("UPDATE +SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `turbo_bonus`=0, `login_bonus`=0, `bonus_order`=0, `bonus_stats`=0, - `bonus_ref`=0", + `bonus_ref`=0', __FILE__, __LINE__); // [EOF] diff --git a/inc/reset/reset_daily.php b/inc/reset/reset_daily.php index 371b4c4ecf..0d6c6b7fda 100644 --- a/inc/reset/reset_daily.php +++ b/inc/reset/reset_daily.php @@ -51,21 +51,21 @@ if (!defined('__SECURITY')) { // Update user profiles if (isExtensionInstalledAndNewer('order', '0.1.1')) { // Latest version - SQL_QUERY("UPDATE + SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `receive_mails`=`max_mails`, `mail_orders`=0 WHERE - `receive_mails` != `max_mails`", __FILE__, __LINE__); + `receive_mails` != `max_mails`', __FILE__, __LINE__); } else { // Obsolete version - SQL_QUERY("UPDATE + SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `receive_mails`=`max_mails` WHERE - `receive_mails` != `max_mails`", __FILE__, __LINE__); + `receive_mails` != `max_mails`', __FILE__, __LINE__); } // Transfer points from locked_points to points diff --git a/inc/reset/reset_profile.php b/inc/reset/reset_profile.php index 16001ed856..42d95ce89b 100644 --- a/inc/reset/reset_profile.php +++ b/inc/reset/reset_profile.php @@ -51,17 +51,17 @@ if (!defined('__SECURITY')) { if ((getConfig('send_prof_update') == 'Y') && (getConfig('profile_update') > 0) && (getConfig('resend_profile_update'))) { // Load personal data - $result = SQL_QUERY("SELECT `userid`, `email`, `last_update`, `joined` + $result = SQL_QUERY('SELECT `userid`, `email`, `last_update`, `joined` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE (`last_update` < (UNIX_TIMESTAMP() - {?profile_update?}) AND - `last_update` != 0 AND + `last_update` > 0 AND `last_profile_sent` < (UNIX_TIMESTAMP() - {?resend_profile_update?})) OR - (`last_update` = '0' AND `last_profile_sent` = '0' AND `joined` < (UNIX_TIMESTAMP() - {?profile_update?})) + (`last_update` = 0 AND `last_profile_sent` = 0 AND `joined` < (UNIX_TIMESTAMP() - {?profile_update?})) ORDER BY - `userid` ASC", __FILE__, __LINE__); + `userid` ASC', __FILE__, __LINE__); // Do we have some notifications to sent? if (!SQL_HASZERONUMS($result)) { diff --git a/inc/template-functions.php b/inc/template-functions.php index 86cef50ed2..3ff65a4540 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -226,7 +226,7 @@ function compileFinalOutput () { } // Main compilation loop -function doFinalCompilation ($code, $insertComments = true) { +function doFinalCompilation ($code, $insertComments = true, $enableCodes = true) { // Insert comments? (Only valid with HTML templates, of course) enableTemplateHtml($insertComments); @@ -241,7 +241,7 @@ function doFinalCompilation ($code, $insertComments = true) { // Compile it //* DEBUG: */ debugOutput('
'.linenumberCode($code).'
'); - $eval = '$newContent = "' . str_replace('{DQUOTE}', '"', compileCode(escapeQuotes($code))) . '";'; + $eval = '$newContent = "' . str_replace('{DQUOTE}', '"', compileCode(escapeQuotes($code), false, true, $enableCodes)) . '";'; //* DEBUG: */ if (!$insertComments) print('
'.linenumberCode($eval).'
'); eval($eval); //* DEBUG: */ die('
'.encodeEntities($newContent).'
');