Fix for inserted codes while registering of extensions, many rewrites/cleanups:
authorRoland Häder <roland@mxchange.org>
Mon, 19 Jul 2010 15:38:33 +0000 (15:38 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 19 Jul 2010 15:38:33 +0000 (15:38 +0000)
- 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

43 files changed:
birthday_confirm.php
inc/autopurge/purge-general.php
inc/autopurge/purge-inact.php
inc/autopurge/purge-mails.php
inc/classes/resolver.class.php
inc/db/lib-mysql3.php
inc/extensions-functions.php
inc/extensions/ext-beg.php
inc/extensions/ext-order.php
inc/extensions/ext-rallye.php
inc/extensions/ext-transfer.php
inc/filter-functions.php
inc/filters.php
inc/gen_mediadata.php
inc/gen_refback.php
inc/libs/admins_functions.php
inc/libs/bonus_functions.php
inc/libs/network_functions.php
inc/libs/optimize_functions.php
inc/libs/register_functions.php
inc/libs/sponsor_functions.php
inc/libs/surfbar_functions.php
inc/libs/task_functions.php
inc/libs/theme_functions.php
inc/libs/transfer_functions.php
inc/modules/admin/what-admin_add.php
inc/modules/admin/what-config_admins.php
inc/modules/admin/what-edit_emails.php
inc/modules/admin/what-list_beg.php
inc/modules/admin/what-mem_add.php
inc/modules/admin/what-repair_amnu.php
inc/modules/admin/what-repair_gmnu.php
inc/modules/admin/what-repair_mmnu.php
inc/modules/guest/what-active.php
inc/modules/guest/what-mediadata.php
inc/modules/guest/what-stats.php
inc/monthly/monthly_beg.php
inc/monthly/monthly_bonus.php
inc/mysql-manager.php
inc/reset/reset_bonus.php
inc/reset/reset_daily.php
inc/reset/reset_profile.php
inc/template-functions.php

index 157a0358374aafd53e68b270b9271db46f01e4f5..91d5f911c3068a2539ec0360f4bed9375ccb7881 100644 (file)
@@ -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,
index c932ff47df0686a215b28a140b73e8e01c362744..8a7735c2f98b6a716052b6694d6b892c4713d027 100644 (file)
@@ -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';
index d3c9b49150e6029b551c22b2e6a877e23358b1f2..01a59c5f905075d639a4dcd32db23315b0f89278 100644 (file)
@@ -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...
index 712553b6557cb1e5ee86ab53e0ea167c0f3ecd7d..83584677776085fa5f208aafb22e5160666e9d7b 100644 (file)
@@ -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
index e6a63699e7ccd6e652effcecc3da2b60eb904e19..2677ca6f86cb5b9793d4da3690f8378ec65584d2 100644 (file)
@@ -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__);
        }
 }
index 67fcdd4e781f3c490dabe5653ba4ac067e94a6da..aada78066645053339dc73754f1b19191a7cbb5e 100644 (file)
@@ -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.'<br />'.$sqlString2.'<br />'.$GLOBALS['sql_strings'][$sqlString]);
        } // END - if
 
        // Return it
index c4e88abaf0e2c30d28e159c23a72515348249f42..e755418accd30e5ac705a8406b972a48675ba7a2 100644 (file)
@@ -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('{', '&#123;', str_replace('}', '&#125;', encodeEntities($sql)))
                                                );
 
                                                // Load row template
index fffd62d7279778fc5ef5986d79828e863aa81784..605a83ba1dcd72135701cb41878c3fee10d0f3c5 100644 (file)
@@ -54,18 +54,18 @@ switch (getExtensionMode()) {
                addAdminMenuSql('setup','config_beg','Bettel-Link','IP-Sperre, {OPEN_CONFIG}POINTS{CLOSE_CONFIG}-Verg&uuml;tung usw. k&ouml;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())) {
index 2dfbf609441ae94c2accaa4cccb9d4d6bfb4436d..37854c2fc62c6d15afe07c5f5e8f4f593e30ab8c 100644 (file)
@@ -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;
 
index f03bf03c016afa31585de9a45b04bd69b859513b..8b05ceb6095d60be860e42551fd3661aa44b0e87 100644 (file)
@@ -337,13 +337,13 @@ Zudem sollten Sie mindestens folgende Templates (in <strong>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...
index 8bdb7b3ac1e26cbe1a115811067e0123b76c143c..1b3aee19e93ab523e36bc66a5d2cfb1a5363c0ba 100644 (file)
@@ -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');
index d0e881ae8cd698d221e5faf3abc38f18174a3996..dac79b3107b5ce52f27a08b3de2c510a955667ed 100644 (file)
@@ -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)) {
index 181c1fe4f2d9567b5858e42c17fba6074896c50d..333b5eb34ee9712c4e23410c1031349503f83d02 100644 (file)
@@ -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
index 7f4246a5083b89c8d576e23d0e4007ad6cb218c3..8922660483b0431a3120658c7ed2384c646ee926 100644 (file)
@@ -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));
index 0ffa66449a0c5dc706b2870e2a129de1ff5bc2cc..e4fd569b19470a3e3e49266cf18608045d90c694 100644 (file)
@@ -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');
index e549b1fca3b1b345f20b62f8d9df2881bf62d2af..f87aff12df2aa19462b176d2f0639950167b3653 100644 (file)
@@ -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
index 17736e92928eaf3137403c87d37d14d1cb70a440..88f6d00262012987d1f95aa1104931ebedd1e717 100644 (file)
@@ -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
index 246e054dfc7823cfb59a8702d6445797e58ab5a0..535a9ec0656bca6afeb519f6d2f1b5e2e10f5d8a 100644 (file)
@@ -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__);
index 6fae587174774ea89b7646070ad0558c250d8060..011484fd2f34af09210828361b9f91d716bbc0f9 100644 (file)
@@ -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
index 8a3880c9405cd47ad2824b634de5d82f69e42eba..97c6216650a967671876b9d477c9931ee1013c01 100644 (file)
@@ -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
index 97034d5b9bc9a75fdd8fdc30277e4ed95db1b3cc..c6cd2e5b346215a95e884d2022ddcd71f62c4bac 100644 (file)
@@ -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__);
index 92655c666615c52b54cbed68b9b3d8f472186577..546f27d070e173ca008032eadfb5a18612041195 100644 (file)
@@ -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__);
 
index 1e5e0ec4be1c2d4e5df50f7d83da1b663bde266e..cee84ef22a812044143a6c2f437dc2c72293a2d2 100644 (file)
@@ -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'";
index 895ef86bf2798cc96181b411beb4c58c6582b122..1fcbd844159cced2e35038206ee509bb4a980539 100644 (file)
@@ -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)) {
index ee6946ae326a4743ced92e34eacd1ea78d6d7711..2f2d61c82749fa9edc18275c84092eb35ad81acf 100644 (file)
@@ -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;
index 980d6f85774ecaca40cf74a0f6470e875607ce2b..7e66899d8255772e00366d569d3a41ecaa06d892 100644 (file)
@@ -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();
index 5c73970d35253dc59983d5a79a07fd275b9d3527..f964eedb105b207db0780ce4bce4f7a765f36421 100644 (file)
@@ -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')),
index 0ecb55d49f33e57da838fea16c15ea682e461899..794fd2de8f0c67fa19d1e8dec61a59a4a2e1214a 100644 (file)
@@ -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)) {
index 5c68a0418d5a84fdfbe7ad090ee9c2c4bffaeeb0..225bac8125caab0cb65f2abf39b2f56b2c6853a8 100644 (file)
@@ -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,
index 682dcdbd20981bca3a5f4a718ccad88818e264b0..5c99507b6af6089ebeca23feec848f21e1b43ecc 100644 (file)
@@ -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();
index 00cb2d514e91277ca575e21d92928b00b3e6ef48..c9fc15ea22a56df3547ee3b0a1eba3e72df37695 100644 (file)
@@ -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
index a3b3ce3e34ec9ba426dbd1c5c166c1d146c7cb0a..a817e85a83455d0ba66a1d8c09e088c54e8f860d 100644 (file)
@@ -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();
 
index 9ce232fef3f03730cf667cf2b79bb3b7f860e27a..374e1cb8f8d7aa5a83221d4e5c324bd7e47b4d29 100644 (file)
@@ -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)) {
index 9b14876013dbb10cd0fd85cb62136e2385b2b572..559ecb44d2d6361ffc2e00d2bdf8b26e5e291422 100644 (file)
@@ -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__);
index 6fd3e085d1201f16b3c5b193eac09b69bf2d5ba0..733327beeba47653b71eaaceb1b70f322d2a8cdc 100644 (file)
@@ -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);
index 06cb3d8977ed9fc6eb68c5f3649e4b9ef0885b6a..6e6c88e2843d980d32a995f99b4ee29a2f933df6 100644 (file)
@@ -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)) {
index 386bcb9b1540ce4727a45b5b5c40720b8e953180..2ce572fc9d418b869ee0c2c742b70908c1702532 100644 (file)
@@ -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
index 516e43a0d2ec9e404ac572ec6306b91e5b9b8592..ed263737850bcc6cfdc8ed967e072c92a092f531 100644 (file)
@@ -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)) {
index 1dd3aa1ca361c916a3e33212b50524acba610c66..51e24c8eded41fdbbf2e3cf17bb56d1479ac8a14 100644 (file)
@@ -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?
index f57a665cf63555f21550fe3080572020fdc74ef2..52d886ba809035e020426fbf9eb6cb9dc13359d0 100644 (file)
@@ -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]
index 371b4c4ecf69effb92a9ad956e4a2d83621bbf4d..0d6c6b7fda124675a6efd436d1ed70b8cc7503be 100644 (file)
@@ -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
index 16001ed8566ee68602f37c140d76cd35bbf6c660..42d95ce89b233677645fcee2ca067600df960937 100644 (file)
@@ -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)) {
index 86cef50ed22b549c5ab7033fc861e58fa37a3dde..3ff65a4540d57640da39e5997ec75acb992546c7 100644 (file)
@@ -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('<pre>'.linenumberCode($code).'</pre>');
-               $eval = '$newContent = "' . str_replace('{DQUOTE}', '"', compileCode(escapeQuotes($code))) . '";';
+               $eval = '$newContent = "' . str_replace('{DQUOTE}', '"', compileCode(escapeQuotes($code), false, true, $enableCodes)) . '";';
                //* DEBUG: */ if (!$insertComments) print('<pre>'.linenumberCode($eval).'</pre>');
                eval($eval);
                //* DEBUG: */ die('<pre>'.encodeEntities($newContent).'</pre>');