]> git.mxchange.org Git - mailer.git/commitdiff
Fixes for referal system, shell scripts overworked:
authorRoland Häder <roland@mxchange.org>
Tue, 12 Jul 2011 00:32:40 +0000 (00:32 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 12 Jul 2011 00:32:40 +0000 (00:32 +0000)
- Various fixes to the referal/points system (still some work needs to be done)
- Shell scripts enhanced with check for "root" directory (modules.php)
- Shell debug-lines.sh added which will show which debug lines are commented in
- Other minor rewrites/fixes
- TODOs.txt updated

34 files changed:
DOCS/TODOs.txt
DOCS/debug.lines.sh [new file with mode: 0755]
DOCS/lint.sh
DOCS/prop-set.sh
DOCS/remove-deprecated.sh
DOCS/validator.sh
birthday_confirm.php
inc/db/lib-mysql3.php
inc/extensions-functions.php
inc/extensions/ext-refback.php
inc/extensions/ext-register.php
inc/extensions/ext-user.php
inc/filter/surfbar_filter.php
inc/filter/user_filter.php
inc/functions.php
inc/gen_refback.php
inc/header.php
inc/js/js-surfbar_frame_top.php
inc/language/de.php
inc/language/mydata_de.php
inc/libs/beg_functions.php
inc/libs/rallye_functions.php
inc/libs/refback_functions.php
inc/libs/register_functions.php
inc/libs/surfbar_functions.php
inc/libs/user_functions.php
inc/modules/admin/admin-inc.php
inc/modules/guest/what-register.php
inc/mysql-manager.php
inc/template-functions.php
inc/wrapper-functions.php
mailid_top.php
surfbar.php
templates/de/html/js/js_surfbar_frame_top.tpl

index 4e633e84695a3f0d82fa9e6a5db82a049ec037a9..561837e4b30e483e752b35142f455a770823d732 100644 (file)
@@ -2,7 +2,6 @@
 ### DO NOT EDIT THIS FILE. ###
 ./autoreg.php:58:// @TODO Add processing of request here
 ./beg.php:168:                 // @TODO Opps, what is missing here???
 ### DO NOT EDIT THIS FILE. ###
 ./autoreg.php:58:// @TODO Add processing of request here
 ./beg.php:168:                 // @TODO Opps, what is missing here???
-./birthday_confirm.php:93:             // @TODO Try to rewrite the following unset()
 ./inc/cache/config-local.php:124:// @TODO Rewrite the following three constants, somehow...
 ./inc/classes/cachesystem.class.php:504:       // @TODO Add support for more types which break in last else-block
 ./inc/config-functions.php:136:        // @TODO Make this all better... :-/
 ./inc/cache/config-local.php:124:// @TODO Rewrite the following three constants, somehow...
 ./inc/classes/cachesystem.class.php:504:       // @TODO Add support for more types which break in last else-block
 ./inc/config-functions.php:136:        // @TODO Make this all better... :-/
@@ -55,9 +54,9 @@
 ./inc/functions.php:2200:      // @TODO Rename column data_type to e.g. mail_status
 ./inc/gen_sql_patches.php:95:// @TODO Rewrite this to a filter
 ./inc/install-functions.php:57:        // @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0);
 ./inc/functions.php:2200:      // @TODO Rename column data_type to e.g. mail_status
 ./inc/gen_sql_patches.php:95:// @TODO Rewrite this to a filter
 ./inc/install-functions.php:57:        // @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0);
-./inc/language/de.php:1068:    // @TODO Rewrite these two constants
-./inc/language/de.php:1084:    // @TODO Rewrite these three constants
-./inc/language/de.php:760:// @TODO Are these constants longer used?
+./inc/language/de.php:1066:    // @TODO Rewrite these two constants
+./inc/language/de.php:1082:    // @TODO Rewrite these three constants
+./inc/language/de.php:758:// @TODO Are these constants longer used?
 ./inc/language-functions.php:255:      // @TODO These are all valid languages, again hard-coded
 ./inc/language-functions.php:44:// @TODO Rewrite all language constants to this function.
 ./inc/language/newsletter_de.php:13: * @TODO This language file is completely out-dated, please do no       *
 ./inc/language-functions.php:255:      // @TODO These are all valid languages, again hard-coded
 ./inc/language-functions.php:44:// @TODO Rewrite all language constants to this function.
 ./inc/language/newsletter_de.php:13: * @TODO This language file is completely out-dated, please do no       *
@@ -65,7 +64,6 @@
 ./inc/language/refback_de.php:44:// @TODO Rewrite these constants to one
 ./inc/language/sponsor_de.php:117:// @TODO Rewrite these four constants to one and use sprintf()
 ./inc/libs/admins_functions.php:451:           // @TODO This can be, somehow, rewritten
 ./inc/language/refback_de.php:44:// @TODO Rewrite these constants to one
 ./inc/language/sponsor_de.php:117:// @TODO Rewrite these four constants to one and use sprintf()
 ./inc/libs/admins_functions.php:451:           // @TODO This can be, somehow, rewritten
-./inc/libs/beg_functions.php:55:               // @TODO Try to rewrite the following unset()
 ./inc/libs/bonus_functions.php:194:            // @TODO Move this HTML to a template
 ./inc/libs/doubler_functions.php:44:// @TODO Lame description
 ./inc/libs/doubler_functions.php:91:                   // @TODO Can't this be moved into EL?
 ./inc/libs/bonus_functions.php:194:            // @TODO Move this HTML to a template
 ./inc/libs/doubler_functions.php:44:// @TODO Lame description
 ./inc/libs/doubler_functions.php:91:                   // @TODO Can't this be moved into EL?
 ./inc/libs/rallye_functions.php:768:   $EXPIRE = 3; // @TODO The hard-coded value...
 ./inc/libs/rallye_functions.php:854:// @TODO Please document this function
 ./inc/libs/rallye_functions.php:910:           // Load count @TODO Can't we rewrite this to our API?
 ./inc/libs/rallye_functions.php:768:   $EXPIRE = 3; // @TODO The hard-coded value...
 ./inc/libs/rallye_functions.php:854:// @TODO Please document this function
 ./inc/libs/rallye_functions.php:910:           // Load count @TODO Can't we rewrite this to our API?
-./inc/libs/refback_functions.php:59:           // @TODO Try to rewrite the following unset()
 ./inc/libs/register_functions.php:290: // @TODO Rewrite these all to a single filter
 ./inc/libs/register_functions.php:290: // @TODO Rewrite these all to a single filter
-./inc/libs/register_functions.php:360: // @TODO Rewrite this to a filter
-./inc/libs/register_functions.php:367: // @TODO Wether the registration bonus should only be added to user directly or through referal system should be configurable
+./inc/libs/register_functions.php:363: // @TODO Wether the registration bonus should only be added to user directly or through referal system should be configurable
 ./inc/libs/sponsor_functions.php:159:                                  // @TODO Rewrite this to API function
 ./inc/libs/sponsor_functions.php:430:                  // @TODO Rewrite this to API function
 ./inc/libs/sponsor_functions.php:159:                                  // @TODO Rewrite this to API function
 ./inc/libs/sponsor_functions.php:430:                  // @TODO Rewrite this to API function
-./inc/libs/surfbar_functions.php:1018: // @TODO Invalid salt should be refused
-./inc/libs/surfbar_functions.php:1099: // @TODO Try to rewrite the following unset()
-./inc/libs/surfbar_functions.php:1614:         // @TODO This can be somehow rewritten
+./inc/libs/surfbar_functions.php:1621:         // @TODO This can be somehow rewritten
 ./inc/libs/surfbar_functions.php:729:// @TODO Can't we use our new expression language instead of this ugly code?
 ./inc/libs/task_functions.php:247:             // @TODO These can be rewritten to filter
 ./inc/libs/task_functions.php:51:// @TODO Move all extension-dependent queries into filters
 ./inc/libs/surfbar_functions.php:729:// @TODO Can't we use our new expression language instead of this ugly code?
 ./inc/libs/task_functions.php:247:             // @TODO These can be rewritten to filter
 ./inc/libs/task_functions.php:51:// @TODO Move all extension-dependent queries into filters
 ./inc/libs/user_functions.php:234:// @TODO Double-check configuration entry here
 ./inc/libs/user_functions.php:329:                     // @TODO Make this filter working: $ADDON = runFilterChain('post_login_update', $content);
 ./inc/libs/user_functions.php:358:                     // @TODO Make this filter working: $url = runFilterChain('do_login', array('content' => $content, 'addon' => $ADDON));
 ./inc/libs/user_functions.php:234:// @TODO Double-check configuration entry here
 ./inc/libs/user_functions.php:329:                     // @TODO Make this filter working: $ADDON = runFilterChain('post_login_update', $content);
 ./inc/libs/user_functions.php:358:                     // @TODO Make this filter working: $url = runFilterChain('do_login', array('content' => $content, 'addon' => $ADDON));
-./inc/libs/user_functions.php:625:                                     // @TODO Try to rewrite the following unset()
 ./inc/libs/yoomedia_functions.php:114: $response = YOOMEDIA_QUERY_API('out_textmail.php', true); // @TODO Ask Yoo!Media for test script
 ./inc/load_config.php:75:      // @TODO Rewrite them to avoid this else block
 ./inc/loader/load-extension.php:13: * @TODO Rewrite this whole file                                        *
 ./inc/mails/doubler_mails.php:53:// @TODO Can this be rewritten to a filter?
 ./inc/module-functions.php:267:                        // @TODO Nothing helped???
 ./inc/module-functions.php:308:                        // @TODO Rewrite this to a filter
 ./inc/libs/yoomedia_functions.php:114: $response = YOOMEDIA_QUERY_API('out_textmail.php', true); // @TODO Ask Yoo!Media for test script
 ./inc/load_config.php:75:      // @TODO Rewrite them to avoid this else block
 ./inc/loader/load-extension.php:13: * @TODO Rewrite this whole file                                        *
 ./inc/mails/doubler_mails.php:53:// @TODO Can this be rewritten to a filter?
 ./inc/module-functions.php:267:                        // @TODO Nothing helped???
 ./inc/module-functions.php:308:                        // @TODO Rewrite this to a filter
-./inc/modules/admin/admin-inc.php:1227:                                // @TODO If we can rewrite the EL sub-system to support more than one parameter, this call_user_func_array() can be avoided
+./inc/modules/admin/admin-inc.php:1236:                                // @TODO If we can rewrite the EL sub-system to support more than one parameter, this call_user_func_array() can be avoided
 ./inc/modules/admin/admin-inc.php:171:         // @TODO This and the next getCurrentAdminId() call might be moved into the templates?
 ./inc/modules/admin/admin-inc.php:242:         // @TODO This can be rewritten into a filter
 ./inc/modules/admin/admin-inc.php:274:         // @TODO Rewrite this to $content = SQL_FETCHARRAY()
 ./inc/modules/admin/admin-inc.php:171:         // @TODO This and the next getCurrentAdminId() call might be moved into the templates?
 ./inc/modules/admin/admin-inc.php:242:         // @TODO This can be rewritten into a filter
 ./inc/modules/admin/admin-inc.php:274:         // @TODO Rewrite this to $content = SQL_FETCHARRAY()
 ./inc/modules/member/what-unconfirmed.php:209:                         // @TODO This 'userid' cannot be saved because of encapsulated EL code
 ./inc/modules/order.php:74:            // @TODO Unused: 2,4
 ./inc/monthly/monthly_bonus.php:64:    // @TODO Rewrite this to a filter
 ./inc/modules/member/what-unconfirmed.php:209:                         // @TODO This 'userid' cannot be saved because of encapsulated EL code
 ./inc/modules/order.php:74:            // @TODO Unused: 2,4
 ./inc/monthly/monthly_bonus.php:64:    // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1241:  // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1503:                  // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
-./inc/mysql-manager.php:1591:          // @TODO Rewrite these lines to a filter
-./inc/mysql-manager.php:1615:  // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1979:                  // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:2023:// @TODO Fix inconsistency between last_module and getWhat()
+./inc/mysql-manager.php:1258:  // @TODO Rewrite this to a filter
+./inc/mysql-manager.php:1520:                  // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
+./inc/mysql-manager.php:1608:          // @TODO Rewrite these lines to a filter
+./inc/mysql-manager.php:1632:  // @TODO Rewrite this to a filter
+./inc/mysql-manager.php:1998:                  // @TODO Rewrite this to a filter
+./inc/mysql-manager.php:2042:// @TODO Fix inconsistency between last_module and getWhat()
 ./inc/mysql-manager.php:371:   // @TODO Try to rewrite this to one or more functions
 ./inc/mysql-manager.php:44:// @TODO Can we cache this?
 ./inc/purge/purge-inact.php:55:        // @TODO Rewrite these if() blocks to a filter
 ./inc/revision-functions.php:169:// @TODO This function does also set and get in 'cache_array'
 ./inc/mysql-manager.php:371:   // @TODO Try to rewrite this to one or more functions
 ./inc/mysql-manager.php:44:// @TODO Can we cache this?
 ./inc/purge/purge-inact.php:55:        // @TODO Rewrite these if() blocks to a filter
 ./inc/revision-functions.php:169:// @TODO This function does also set and get in 'cache_array'
-./inc/template-functions.php:1066:                     // @TODO Deprecate this thing
-./inc/template-functions.php:1077:                     // @TODO Deprecate this thing
-./inc/template-functions.php:1170:     // @TODO This can be easily moved out after the merge from EL branch to this is complete
-./inc/template-functions.php:1203:             // @TODO Add a little more infos here
-./inc/template-functions.php:1517:// @TODO Lame description for this function
-./inc/template-functions.php:1539:                     // @TODO Move this in a filter
+./inc/template-functions.php:1069:                     // @TODO Deprecate this thing
+./inc/template-functions.php:1080:                     // @TODO Deprecate this thing
+./inc/template-functions.php:1173:     // @TODO This can be easily moved out after the merge from EL branch to this is complete
+./inc/template-functions.php:1206:             // @TODO Add a little more infos here
+./inc/template-functions.php:1520:// @TODO Lame description for this function
+./inc/template-functions.php:1542:                     // @TODO Move this in a filter
 ./inc/template-functions.php:189:       * @TODO On some pages this is buggy
 ./inc/template-functions.php:189:       * @TODO On some pages this is buggy
-./inc/template-functions.php:266:              // @TODO Remove this sanity-check if all is fine
-./inc/template-functions.php:594:// @TODO $simple/$constants are deprecated
-./inc/template-functions.php:620:      // @TODO Do only use $content and deprecate $GLOBALS and $DATA in templates
+./inc/template-functions.php:269:              // @TODO Remove this sanity-check if all is fine
+./inc/template-functions.php:597:// @TODO $simple/$constants are deprecated
+./inc/template-functions.php:623:      // @TODO Do only use $content and deprecate $GLOBALS and $DATA in templates
 ./inc/wrapper-functions.php:130:// @TODO Implement $compress
 ./inc/wrapper-functions.php:137:// @TODO Implement $decompress
 ./inc/wrapper-functions.php:514:// @TODO Do some more sanity check here
 ./inc/wrapper-functions.php:130:// @TODO Implement $compress
 ./inc/wrapper-functions.php:137:// @TODO Implement $decompress
 ./inc/wrapper-functions.php:514:// @TODO Do some more sanity check here
 ./mailid_top.php:183:                                                  // @TODO Rewrite this to a filter
 ./mailid_top.php:190:                                                                  // @TODO Rewrite this to a filter
 ./mailid_top.php:225:                                                                  // @TODO Rewrite these blocks to filter
 ./mailid_top.php:183:                                                  // @TODO Rewrite this to a filter
 ./mailid_top.php:190:                                                                  // @TODO Rewrite this to a filter
 ./mailid_top.php:225:                                                                  // @TODO Rewrite these blocks to filter
-./mailid_top.php:261:                                                                          // @TODO Try to rewrite the following unset()
 ./network-check.php:54:// @TODO Add processing of request here
 ./show_bonus.php:105:                  // @TODO No more needed? $content['points'] = translateComma($content['points']);
 ./view.php:68:         // @TODO No banner found, output some default banner
 ./network-check.php:54:// @TODO Add processing of request here
 ./show_bonus.php:105:                  // @TODO No more needed? $content['points'] = translateComma($content['points']);
 ./view.php:68:         // @TODO No banner found, output some default banner
diff --git a/DOCS/debug.lines.sh b/DOCS/debug.lines.sh
new file mode 100755 (executable)
index 0000000..7b31b12
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# Shell script to determine where in the code are commented-in debug lines
+#
+if ! test -e "modules.php"; then
+  echo "$0: Please execute this script from root directory."
+  exit 1
+fi
+
+svn diff |grep -v "svn diff" | grep "DEBUG" | grep "+" | grep -v "//\* DEBUG" > DOCS/debug-lines.log
index 00c4a2c545218402502edfebac78a36eb112910b..1e333eee6adac48f6618ceb1b796b4011216b251 100755 (executable)
@@ -1,5 +1,10 @@
 #!/bin/sh
 
 #!/bin/sh
 
+if ! test -e "modules.php"; then
+  echo "$0: Please execute this script from root directory."
+  exit 1
+fi
+
 echo "$0: Analysing PHP scripts for syntax errors (lint) ..."
 LINT=`find -type f -name "*.php" -exec php -l -f {} 2>&1 \; | grep -v "No syntax errors detected in"`
 
 echo "$0: Analysing PHP scripts for syntax errors (lint) ..."
 LINT=`find -type f -name "*.php" -exec php -l -f {} 2>&1 \; | grep -v "No syntax errors detected in"`
 
index 1df2b4ca7dd928d1a9fbb4d9d157f78cb07eada2..caf1bcd5424f662dd76074b08400d39b37784661 100755 (executable)
@@ -1,5 +1,10 @@
 #!/bin/sh
 
 #!/bin/sh
 
+if ! test -e "modules.php"; then
+  echo "$0: Please execute this script from root directory."
+  exit 1
+fi
+
 find -type f -name "*.php" -exec svn propset svn:keywords "Author Id Revision HeadURL Date Tag" {} \;
 find -type f -name "*-" -exec svn propset svn:keywords "Author Id Revision HeadURL Date Tag" {} \;
 find -type f -name "*_" -exec svn propset svn:keywords "Author Id Revision HeadURL Date Tag" {} \;
 find -type f -name "*.php" -exec svn propset svn:keywords "Author Id Revision HeadURL Date Tag" {} \;
 find -type f -name "*-" -exec svn propset svn:keywords "Author Id Revision HeadURL Date Tag" {} \;
 find -type f -name "*_" -exec svn propset svn:keywords "Author Id Revision HeadURL Date Tag" {} \;
index b813380d7f500db89ba1e6abfffda270f6e4efcd..87bed750d944fee16987e144d4e9d3dcfc3bc11d 100755 (executable)
@@ -1,5 +1,10 @@
 #!/bin/sh
 
 #!/bin/sh
 
+if ! test -e "modules.php"; then
+  echo "$0: Please execute this script from root directory."
+  exit 1
+fi
+
 LIST=`find -name "*.tpl" -exec grep -H "@DEPRECATED" {} \;`
 if test "${LIST}" != ""; then
        echo "${LIST}" | cut -d ":" -f 1 | xargs svn --force del
 LIST=`find -name "*.tpl" -exec grep -H "@DEPRECATED" {} \;`
 if test "${LIST}" != ""; then
        echo "${LIST}" | cut -d ":" -f 1 | xargs svn --force del
index 20aedf2a56f481a6cfea804373d0a952af12fcf4..9dea827d03f77191a032ade21b241a2e008f65ea 100755 (executable)
@@ -1,5 +1,10 @@
 #!/bin/sh
 
 #!/bin/sh
 
+if ! test -e "modules.php"; then
+  echo "$0: Please execute this script from root directory."
+  exit 1
+fi
+
 echo "$0: Validating all templates..."
 DUMMY=`find templates/de/html/ -type f -name *.tpl -exec php DOCS/tpl-validator.php {} \; 2>&1`
 echo "${DUMMY}" | \
 echo "$0: Validating all templates..."
 DUMMY=`find templates/de/html/ -type f -name *.tpl -exec php DOCS/tpl-validator.php {} \; 2>&1`
 echo "${DUMMY}" | \
index 8619fc7056b819e703e7769695f5394a526469b5..24f71259c4b978e0badad49c0326e73286c5a25c 100644 (file)
@@ -90,8 +90,7 @@ if (SQL_NUMROWS($result) == 1) {
        // Is the account confirmed?
        if ($data['status'] == 'CONFIRMED') {
                // Add points to account
        // Is the account confirmed?
        if ($data['status'] == 'CONFIRMED') {
                // Add points to account
-               // @TODO Try to rewrite the following unset()
-               unset($GLOBALS['ref_level']);
+               initReferalSystem();
                addPointsThroughReferalSystem('birthday_confirm', $userid, $data['points'], false, 0, strtolower(getConfig('birthday_mode')));
 
                // Remove entry from table
                addPointsThroughReferalSystem('birthday_confirm', $userid, $data['points'], false, 0, strtolower(getConfig('birthday_mode')));
 
                // Remove entry from table
index 975cefd78d94adab1f443c120fe78ebb36f29172..68cdd067ad5fd0c6f8a8f11e871b22585b76dcc7 100644 (file)
@@ -397,16 +397,16 @@ function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = true) {
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'columnName=' . $columnName . ',idx=' . $idx . ',sql=' . $sql . ',hasZeroNums=' . intval(isSqlTableColumnFound($tableName, $columnName)));
 
                        // Do we have no entry on ADD or an entry on DROP/CHANGE?
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'columnName=' . $columnName . ',idx=' . $idx . ',sql=' . $sql . ',hasZeroNums=' . intval(isSqlTableColumnFound($tableName, $columnName)));
 
                        // Do we have no entry on ADD or an entry on DROP/CHANGE?
-                       // 123                      4                       43    3      4           4          32    23                     4                       43    3      4            4          32    23                     4                       43    3      4              4          3    3         3    3                      4                          4321
-                       if (((!isSqlTableColumnFound($tableName, $columnName)) && (strpos($sql, 'ADD') !== false)) || ((isSqlTableColumnFound($tableName, $columnName)) && (strpos($sql, 'DROP') !== false)) || ((isSqlTableColumnFound($tableName, $columnName)) && (strpos($sql, 'CHANGE') !== false) && ($idx == 4) && (!isSqlTableColumnFound($tableName, $tableArray[5])))) {
+                       // 123                      4                       43    3      4           4          32    23                     4                       43    34      5            5          4    45      6              6          5    5         5    56                      7                          76    6                             654321
+                       if (((!isSqlTableColumnFound($tableName, $columnName)) && (strpos($sql, 'ADD') !== false)) || ((isSqlTableColumnFound($tableName, $columnName)) && ((strpos($sql, 'DROP') !== false) || ((strpos($sql, 'CHANGE') !== false) && ($idx == 4) && ((!isSqlTableColumnFound($tableName, $tableArray[5])) || ($columnName == $tableArray[5])))))) {
                                // Do the query
                                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Executing: ' . $sql);
                                $result = SQL_QUERY($sql, $F, $L, false);
 
                                // Skip further attempt(s)
                                break;
                                // Do the query
                                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Executing: ' . $sql);
                                $result = SQL_QUERY($sql, $F, $L, false);
 
                                // Skip further attempt(s)
                                break;
-                       //       1234                     5                       54    4      5           5          43    34                     5                       54    4      5            5          43    3      4              4          32    2                    21
-                       } elseif ((((isSqlTableColumnFound($tableName, $columnName)) && (strpos($sql, 'ADD') !== false)) || ((isSqlTableColumnFound($tableName, $columnName)) && (strpos($sql, 'DROP') !== false)) || (strpos($sql, 'CHANGE') !== false)) && ($columnName != 'KEY')) {
+                       //       1234                     5                       54    4      5           5          43    34                      5                       54    45      6            6          54    4      5              5          432    2                    21
+                       } elseif ((((isSqlTableColumnFound($tableName, $columnName)) && (strpos($sql, 'ADD') !== false)) || ((!isSqlTableColumnFound($tableName, $columnName)) && ((strpos($sql, 'DROP') !== false)) || (strpos($sql, 'CHANGE') !== false))) && ($columnName != 'KEY')) {
                                // Abort here because it is alreay there
                                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Skipped: sql=' . $sql . ',columnName=' . $columnName . ',idx=' . $idx);
                                break;
                                // Abort here because it is alreay there
                                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Skipped: sql=' . $sql . ',columnName=' . $columnName . ',idx=' . $idx);
                                break;
@@ -425,7 +425,7 @@ function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = true) {
        } elseif ($noIndex === false) {
                // And column name as well without backticks
                $keyName = str_replace('`', '', $tableArray[5]);
        } elseif ($noIndex === false) {
                // And column name as well without backticks
                $keyName = str_replace('`', '', $tableArray[5]);
-               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyName=' . $keyName . ',tableArray=<pre>' . print_r($tableArray, true) . '</pre>');
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyName=' . $keyName . ',tableArray=<pre>' . print_r($tableArray, true) . '</pre>');
 
                // Is this "UNIQUE" or so? FULLTEXT has been handled the elseif() block above
                if (in_array(strtoupper($tableArray[4]), array('INDEX', 'UNIQUE', 'KEY', 'FULLTEXT'))) {
 
                // Is this "UNIQUE" or so? FULLTEXT has been handled the elseif() block above
                if (in_array(strtoupper($tableArray[4]), array('INDEX', 'UNIQUE', 'KEY', 'FULLTEXT'))) {
@@ -447,18 +447,18 @@ function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = true) {
                } // END - if
 
                // Shall we run it?
                } // END - if
 
                // Shall we run it?
-               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ', tableArray[3]=' . $tableArray[3] . ',keyName=' . $keyName);
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ', tableArray[3]=' . $tableArray[3] . ',keyName=' . $keyName);
                if ((!isSqlTableIndexAdded($tableName, $tableArray[3], $keyName)) && ($tableArray[3] == 'ADD')) {
                        // Send it to the SQL_QUERY() function to add it
                if ((!isSqlTableIndexAdded($tableName, $tableArray[3], $keyName)) && ($tableArray[3] == 'ADD')) {
                        // Send it to the SQL_QUERY() function to add it
-                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql);
+                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql);
                        $result = SQL_QUERY($sql, $F, $L, $enableCodes);
                } elseif ((isSqlTableIndexAdded($tableName, $tableArray[3], $keyName)) && ($tableArray[3] == 'DROP')) {
                        // Send it to the SQL_QUERY() function to drop it
                        $result = SQL_QUERY($sql, $F, $L, $enableCodes);
                } elseif ((isSqlTableIndexAdded($tableName, $tableArray[3], $keyName)) && ($tableArray[3] == 'DROP')) {
                        // Send it to the SQL_QUERY() function to drop it
-                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql);
+                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql);
                        $result = SQL_QUERY($sql, $F, $L, $enableCodes);
                } else {
                        // Not executed
                        $result = SQL_QUERY($sql, $F, $L, $enableCodes);
                } else {
                        // Not executed
-                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Not executed: ' . $sql);
+                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Not executed: ' . $sql);
                }
        } else {
                // Other ALTER TABLE query
                }
        } else {
                // Other ALTER TABLE query
@@ -620,12 +620,12 @@ function isSqlTableIndexAdded ($tableName, $mode, $keyName) {
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'columnName='.$keyName.',content=<pre>' . print_r($content, true) . '</pre>');
                        if (($content['Key_name'] == $keyName) && ($mode == 'ADD')) {
                                // Skip this query!
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'columnName='.$keyName.',content=<pre>' . print_r($content, true) . '</pre>');
                        if (($content['Key_name'] == $keyName) && ($mode == 'ADD')) {
                                // Skip this query!
-                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("ADD: Skiped: %s", $sql));
+                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ADD: Skiped: tableName=' . $tableName . ',mode=' . $mode . ',keyName=' . $keyName);
                                $GLOBALS[__FUNCTION__][$tableName][$mode] = true;
                                break;
                        } elseif (($content['Key_name'] == $keyName) && ($mode == 'DROP')) {
                                // Don't skip this!
                                $GLOBALS[__FUNCTION__][$tableName][$mode] = true;
                                break;
                        } elseif (($content['Key_name'] == $keyName) && ($mode == 'DROP')) {
                                // Don't skip this!
-                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("DROP: Not skiped: %s", $sql));
+                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'DROP: Not skiped: tableName=' . $tableName . ',mode=' . $mode . ',keyName=' . $keyName);
                                $GLOBALS[__FUNCTION__][$tableName][$mode] = false;
                                break;
                        }
                                $GLOBALS[__FUNCTION__][$tableName][$mode] = false;
                                break;
                        }
index d1c46faf4268dd058cbff96565b9b3b3cff96954..be86049739fb3fd18c45a26a2f10c68891dbb260 100644 (file)
@@ -1843,7 +1843,7 @@ function addGuestMenuSql ($action, $what, $title, $sort) {
                addExtensionSql($sql);
        } elseif (isDebugModeEnabled()) {
                // Double menus should be located and fixed!
                addExtensionSql($sql);
        } elseif (isDebugModeEnabled()) {
                // Double menus should be located and fixed!
-               logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double guest menu action=%s,what=%s,title=%s,locked=%s,visible=%s detected.", $action, $what, $title, $locked, $visible));
+               logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double guest menu action=%s,what=%s,title=%s detected.", $action, $what, $title));
        }
 }
 
        }
 }
 
@@ -1873,7 +1873,7 @@ function addMemberMenuSql ($action, $what, $title, $sort) {
                addExtensionSql($sql);
        } elseif (isDebugModeEnabled()) {
                // Double menus should be located and fixed!
                addExtensionSql($sql);
        } elseif (isDebugModeEnabled()) {
                // Double menus should be located and fixed!
-               logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double member menu action=%s,what=%s,title=%s,visivle=%s,locked=%s detected.", $action, $what, $title, $visible, $locked));
+               logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double member menu action=%s,what=%s,title=%s detected.", $action, $what, $title));
        }
 }
 
        }
 }
 
index db45a2050442cf7f91e817860a73c0d606865cc8..1720650b014a28862073250c701ada23d5b69955 100644 (file)
@@ -41,10 +41,10 @@ if (!defined('__SECURITY')) {
 } // END - if
 
 // Version number
 } // END - if
 
 // Version number
-setThisExtensionVersion('0.0.1');
+setThisExtensionVersion('0.0.2');
 
 // Version history array (add more with , '0.0.1' and so on)
 
 // Version history array (add more with , '0.0.1' and so on)
-setExtensionVersionHistory(array('0.0.0','0.0.1'));
+setExtensionVersionHistory(array('0.0.0','0.0.1', '0.0.2'));
 
 switch (getExtensionMode()) {
        case 'register': // Do stuff when installation is running
 
 switch (getExtensionMode()) {
        case 'register': // Do stuff when installation is running
@@ -98,6 +98,16 @@ INDEX (`refid`)",
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Refback-System ist nun ein-/ausschaltbar und minimale/maximale Refback-Prozente sind festlegbar.");
                                break;
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Refback-System ist nun ein-/ausschaltbar und minimale/maximale Refback-Prozente sind festlegbar.");
                                break;
+
+                       case '0.0.2': // SQL queries for v0.0.2
+                               addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_refs` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
+                               addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_refs` CHANGE `level` `level` SMALLINT(6) UNSIGNED NULL DEFAULT NULL');
+                               addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_refs` CHANGE `refid` `refid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
+                               addExtensionSql('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid` IS NULL OR `refid` IS NULL OR `level` IS NULL');
+
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Updates von ext-user hier her verschoben.");
+                               break;
                } // END - switch
                break;
 
                } // END - switch
                break;
 
index 019915876bead85780ac77108b382619b250ce81..26b080afc728cbcd36058b9d8a49ada825445316 100644 (file)
@@ -64,12 +64,12 @@ switch (getExtensionMode()) {
 
        case 'activate': // Do stuff when admin activates this extension
                // SQL commands to run
 
        case 'activate': // Do stuff when admin activates this extension
                // SQL commands to run
-               addExtensionSql('');
+               addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `locked`='N', `visible`='Y' WHERE `what`='register' LIMIT 1");
                break;
 
        case 'deactivate': // Do stuff when admin deactivates this extension
                // SQL commands to run
                break;
 
        case 'deactivate': // Do stuff when admin deactivates this extension
                // SQL commands to run
-               addExtensionSql('');
+               addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `locked`='Y', `visible`='N' WHERE `what`='register' LIMIT 1");
                break;
 
        case 'update': // Update an extension
                break;
 
        case 'update': // Update an extension
index 9f30d00bac3c77277b3db66d99ad3e5d476d6b41..195d0dd1aa1516c185c7689276b0b7a3786736f2 100644 (file)
@@ -41,10 +41,10 @@ if (!defined('__SECURITY')) {
 } // END - if
 
 // Version number
 } // END - if
 
 // Version number
-setThisExtensionVersion('0.4.1');
+setThisExtensionVersion('0.4.2');
 
 // Version history array (add more with , '0.0.1' and so on)
 
 // Version history array (add more with , '0.0.1' and so on)
-setExtensionVersionHistory(array('0.0.0', '0.1.0', '0.1.1', '0.1.2', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1'));
+setExtensionVersionHistory(array('0.0.0', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2'));
 
 // Keep this extension always active!
 setExtensionAlwaysActive('Y');
 
 // Keep this extension always active!
 setExtensionAlwaysActive('Y');
@@ -387,9 +387,6 @@ INDEX (`userid`)",
                                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
                                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
                                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` CHANGE `ref_depth` `ref_depth` TINYINT(3) UNSIGNED NULL DEFAULT NULL');
                                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
                                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
                                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` CHANGE `ref_depth` `ref_depth` TINYINT(3) UNSIGNED NULL DEFAULT NULL');
-                               addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_refs` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
-                               addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_refs` CHANGE `level` `level` SMALLINT(6) UNSIGNED NULL DEFAULT NULL');
-                               addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_refs` CHANGE `refid` `refid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
                                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
                                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `cat_id` `cat_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
                                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `payment_id` `payment_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
                                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
                                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `cat_id` `cat_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
                                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `payment_id` `payment_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
@@ -403,7 +400,6 @@ INDEX (`userid`)",
                                addExtensionSql('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid` IS NULL');
                                addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `ref_depth`=NULL WHERE `ref_depth`=0');
                                addExtensionSql('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid` IS NULL');
                                addExtensionSql('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid` IS NULL');
                                addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `ref_depth`=NULL WHERE `ref_depth`=0');
                                addExtensionSql('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid` IS NULL');
-                               addExtensionSql('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid` IS NULL OR `refid` IS NULL OR `level` IS NULL');
                                addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `cat_id`=NULL WHERE `cat_id`=0');
                                addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `payment_id`=NULL WHERE `payment_id`=0');
                                addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `pool_id`=NULL WHERE `pool_id`=0');
                                addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `cat_id`=NULL WHERE `cat_id`=0');
                                addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `payment_id`=NULL WHERE `payment_id`=0');
                                addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `pool_id`=NULL WHERE `pool_id`=0');
@@ -413,19 +409,19 @@ INDEX (`userid`)",
                                setExtensionUpdateNotes("NULL ist wichtiger als 0 und UNSIGNED auch.");
                                break;
 
                                setExtensionUpdateNotes("NULL ist wichtiger als 0 und UNSIGNED auch.");
                                break;
 
-                       case '0.3.7': // SQL queries for v0.3.7
+                       case '0.3.8': // SQL queries for v0.3.8
                                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `last_failure` `last_failure` TIMESTAMP NULL DEFAULT NULL');
 
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Ausgangswert ist nicht mehr 0000-00-00 00:00:00, sondern einfach NULL.");
                                break;
 
                                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `last_failure` `last_failure` TIMESTAMP NULL DEFAULT NULL');
 
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Ausgangswert ist nicht mehr 0000-00-00 00:00:00, sondern einfach NULL.");
                                break;
 
-                       case '0.3.8': // SQL queries for v0.3.8
+                       case '0.3.9': // SQL queries for v0.3.9
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Update verschoben nach ext-order (da es Werbeguthaben ist und nichts mit dem Mitglied selbst zu tun hat).");
                                break;
 
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Update verschoben nach ext-order (da es Werbeguthaben ist und nichts mit dem Mitglied selbst zu tun hat).");
                                break;
 
-                       case '0.3.9': // SQL queries for v0.3.9
+                       case '0.4.0': // SQL queries for v0.4.0
                                // Register new filters for gathering points
                                registerFilter('get_total_points', 'USER_POINTS', false, true, isExtensionDryRun());
                                registerFilter('get_own_points', 'USER_POINTS', false, true, isExtensionDryRun());
                                // Register new filters for gathering points
                                registerFilter('get_total_points', 'USER_POINTS', false, true, isExtensionDryRun());
                                registerFilter('get_own_points', 'USER_POINTS', false, true, isExtensionDryRun());
@@ -434,7 +430,7 @@ INDEX (`userid`)",
                                setExtensionUpdateNotes("Filter registriert, die das eigene {?POINTS?}-Guthaben des Mitgliedes zur&uuml;ckliefern.");
                                break;
 
                                setExtensionUpdateNotes("Filter registriert, die das eigene {?POINTS?}-Guthaben des Mitgliedes zur&uuml;ckliefern.");
                                break;
 
-                       case '0.4.0': // SQL queries for v0.4.0
+                       case '0.4.1': // SQL queries for v0.4.1
                                // Add special fix include to fix filters
                                addIncludeToPool('extension', 'inc/fix_user_points.php');
 
                                // Add special fix include to fix filters
                                addIncludeToPool('extension', 'inc/fix_user_points.php');
 
@@ -442,7 +438,7 @@ INDEX (`userid`)",
                                setExtensionUpdateNotes("Das Mitgliederguthaben musste repariert werden, da f&uuml;r Referal-Ebene 0, noch NULL geschrieben wurde.");
                                break;
 
                                setExtensionUpdateNotes("Das Mitgliederguthaben musste repariert werden, da f&uuml;r Referal-Ebene 0, noch NULL geschrieben wurde.");
                                break;
 
-                       case '0.4.1': // SQL queries for v0.4.1
+                       case '0.4.2': // SQL queries for v0.4.2
                                // Add special fix include to fix filters
                                addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='chk_regs' LIMIT 1");
 
                                // Add special fix include to fix filters
                                addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='chk_regs' LIMIT 1");
 
index e0470d3f0a004ccc122fb866ed2602fc32148e23..25b1df08d48d1499edbcddb33b0627615668028a 100644 (file)
@@ -74,9 +74,9 @@ function FILTER_SURFBAR_CHANGE_URL_VALIDATE_DATA ($filterData) {
                // Abort here, but fine!
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newStatus[' . gettype($filterData['new_status']) . ']=' . $filterData['new_status'] . ' - EXIT!');
                $filterData['abort'] = true;
                // Abort here, but fine!
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newStatus[' . gettype($filterData['new_status']) . ']=' . $filterData['new_status'] . ' - EXIT!');
                $filterData['abort'] = true;
-       } elseif ($filterData[$urlId]['url_status'] != $filterData['prev_status']) {
+       } elseif ($filterData['data'][$filterData['url_id']]['url_status'] != $filterData['prev_status']) {
                // Status is not like prevStatus
                // Status is not like prevStatus
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $filterData[$urlId]['url_status'] . '!=' . $filterData['prev_status'] . ' - EXIT!');
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $filterData['data'][$filterData['url_id']]['url_status'] . '!=' . $filterData['prev_status'] . ' - EXIT!');
                $filterData['abort'] = false;
        } // END - if
 
                $filterData['abort'] = false;
        } // END - if
 
index 71920260f0a84127b9a88d549b464cf953d75ab6..fbc0e5e2fe34faeb7f33983729ba55199aa23dc8 100644 (file)
@@ -44,7 +44,7 @@ if (!defined('__SECURITY')) {
 function FILTER_USER_POINTS ($filterData) {
        // Get the points and add them to the existing
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
 function FILTER_USER_POINTS ($filterData) {
        // Get the points and add them to the existing
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
-       $filterData['points'] += countSumTotalData($content['userid'], 'user_points', 'points');
+       $filterData['points'] += countSumTotalData($filterData['userid'], 'user_points', 'points');
 
        // Return the data for next filter
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
 
        // Return the data for next filter
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
index bb9301f583dab251416ae0c5890016fec60251c2..c85d6fde9ab3ecafe1d007323eb746dac57a7dd4 100644 (file)
@@ -640,14 +640,14 @@ function generateRandomCode ($length, $code, $userid, $extraData = '') {
        // Build key string
        $keys = getSiteKey() . getEncryptSeperator() . getDateKey();
        if (isConfigEntrySet('secret_key')) {
        // Build key string
        $keys = getSiteKey() . getEncryptSeperator() . getDateKey();
        if (isConfigEntrySet('secret_key')) {
-               $keys .= getEncryptSeperator().getSecretKey();
+               $keys .= getEncryptSeperator() . getSecretKey();
        } // END - if
        if (isConfigEntrySet('file_hash')) {
        } // END - if
        if (isConfigEntrySet('file_hash')) {
-               $keys .= getEncryptSeperator().getFileHash();
+               $keys .= getEncryptSeperator() . getFileHash();
        } // END - if
        $keys .= getEncryptSeperator() . getDateFromPatchTime();
        if (isConfigEntrySet('master_salt')) {
        } // END - if
        $keys .= getEncryptSeperator() . getDateFromPatchTime();
        if (isConfigEntrySet('master_salt')) {
-               $keys .= getEncryptSeperator().getMasterSalt();
+               $keys .= getEncryptSeperator() . getMasterSalt();
        } // END - if
 
        // Build string from misc data
        } // END - if
 
        // Build string from misc data
@@ -2337,6 +2337,7 @@ function getArrayKeysFromSubStrArray ($heystack, $needles, $offset = 0) {
 
 // Determines database column name from given subject and locked
 function determinePointsColumnFromSubjectLocked ($subject, $locked) {
 
 // Determines database column name from given subject and locked
 function determinePointsColumnFromSubjectLocked ($subject, $locked) {
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',locked=' . intval($locked) . ' - ENTERED!');
        // Default is 'normal' points
        $pointsColumn = 'points';
 
        // Default is 'normal' points
        $pointsColumn = 'points';
 
@@ -2359,6 +2360,7 @@ function determinePointsColumnFromSubjectLocked ($subject, $locked) {
        $pointsColumn = $filterData['column'];
 
        // Return it
        $pointsColumn = $filterData['column'];
 
        // Return it
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',locked=' . intval($locked) . ',pointsColumn=' . $pointsColumn . ' - EXIT!');
        return $pointsColumn;
 }
 
        return $pointsColumn;
 }
 
index 59e457098d7325a4986cced399f01d6c91e5ff20..cd20c0f730b69cf921fb33be4b9390c0f215d8cb 100644 (file)
@@ -79,9 +79,6 @@ ORDER BY
 if (!SQL_HASZERONUMS($result_direct)) {
        // When 'walk' through all users
        while ($content = SQL_FETCHARRAY($result_direct)) {
 if (!SQL_HASZERONUMS($result_direct)) {
        // When 'walk' through all users
        while ($content = SQL_FETCHARRAY($result_direct)) {
-               // Init level
-               $GLOBALS['refback_level'] = 1;
-
                // Update refback table
                //* DEBUG: */ debugOutput('userid=' . $content['userid']);
                updateRefbackTable($content['userid']);
                // Update refback table
                //* DEBUG: */ debugOutput('userid=' . $content['userid']);
                updateRefbackTable($content['userid']);
index 48b35d40df7b0cfa3533598647563da490839392..0f592edb2bfaecb6d22ce9959f16637364e03fc4 100644 (file)
@@ -57,7 +57,9 @@ if (($GLOBALS['header_sent'] != 1) && ($GLOBALS['header_sent'] != 2)) {
        } // END - if
 
        // Closing HEAD tag
        } // END - if
 
        // Closing HEAD tag
-       if ($GLOBALS['header_sent'] == '0') $GLOBALS['header_sent'] = 1;
+       if ($GLOBALS['header_sent'] == '0') {
+               $GLOBALS['header_sent'] = 1;
+       } // END - if
 } // END - if
 
 // Add BODY tag or not?
 } // END - if
 
 // Add BODY tag or not?
index 9c9240b1450dde58a079d5b8b00a12031065c8d7..25bc676197bb8baf65679f385f9bae19165bbf9c 100644 (file)
@@ -51,12 +51,11 @@ SURFBAR_DETERMINE_NEXT_ID(getRequestParameter('url_id'));
 // Check reload-locks
 SURFBAR_CHECK_RELOAD_FULL();
 
 // Check reload-locks
 SURFBAR_CHECK_RELOAD_FULL();
 
-// Update stats
-SURFBAR_UPDATE_SALT_STATS();
-
 // Prepare content
 $content = array(
 // Prepare content
 $content = array(
-       'url_id' => bigintval(getRequestParameter('url_id'))
+       'url_id' => bigintval(getRequestParameter('url_id')),
+       'check'  => SURFBAR_GENERATE_VALIDATION_CODE(getRequestParameter('url_id'), SURFBAR_GET_LAST_SALT()),
+       'salt'   => SURFBAR_GET_LAST_SALT(),
 );
 
 // Load template
 );
 
 // Load template
index 8f0dc5d699a1194e5c51fc93dab6113ae60b28f6..81b0e2e829fe801dfd9ee262ba1657f4402e1cf0 100644 (file)
@@ -208,8 +208,6 @@ addMessages(array(
        'ADMIN_ENTER_POINTS_REGISTER' => "Willkommensgutschrift",
        'ADMIN_ENTER_POINTS_REFERAL' => "Einmalige Referal-Gutschrift",
        'CHOOSE_MORE_CATEGORIES' => "Bitte w&auml;hlen Sie mehr Kategorien aus! Minimum ist: <span class=\"data\">{?least_cats?}</span>",
        'ADMIN_ENTER_POINTS_REGISTER' => "Willkommensgutschrift",
        'ADMIN_ENTER_POINTS_REFERAL' => "Einmalige Referal-Gutschrift",
        'CHOOSE_MORE_CATEGORIES' => "Bitte w&auml;hlen Sie mehr Kategorien aus! Minimum ist: <span class=\"data\">{?least_cats?}</span>",
-       'GUEST_EMAIL_IS_ALREADY_REGISTERED' => "Sie haben sich bereits mit dieser Email-Adresse angemeldet, oder jemand anderes verwendet Ihre. Doppelte Anmeldungen sind bei uns nicht erlaubt.",
-       'MEMBER_EMAIL_IS_ALREADY_REGISTERED' => "Die Email-Adresse wird bereits von einem anderen Account verwendet.",
        'ADMIN_CONFIG_REJECT_DOUBLE_EMAIL' => "Doppelt angemeldete Email-Adressen ablehnen?",
        'ADMIN_EDIT_POINTS' => "Willkommensgutschrift und andere Festbetr&auml;ge editieren",
        'ADMIN_EDIT_REFERAL_DEPTHS' => "Referal-Ebenen editieren / l&ouml;schen / hinzuf&uuml;gen",
        'ADMIN_CONFIG_REJECT_DOUBLE_EMAIL' => "Doppelt angemeldete Email-Adressen ablehnen?",
        'ADMIN_EDIT_POINTS' => "Willkommensgutschrift und andere Festbetr&auml;ge editieren",
        'ADMIN_EDIT_REFERAL_DEPTHS' => "Referal-Ebenen editieren / l&ouml;schen / hinzuf&uuml;gen",
@@ -343,7 +341,7 @@ addMessages(array(
        'REFERAL_IS_ACTIVE' => "Aktiv?",
        'POINTS_USED' => "Verbrauchte {?POINTS?}",
        'MEMBER_NO_POINTS' => "Sie haben keine {?POINTS?} mehr zum Versenden &uuml;brig.",
        'REFERAL_IS_ACTIVE' => "Aktiv?",
        'POINTS_USED' => "Verbrauchte {?POINTS?}",
        'MEMBER_NO_POINTS' => "Sie haben keine {?POINTS?} mehr zum Versenden &uuml;brig.",
-       'MEMBER_NO_PAYMENTS' => "Der Admin diesen {?mt_word?} hat noch keine Mailarten definiert.",
+       'MEMBER_NO_PAYMENTS' => "Der Admin dieses {?mt_word3?} hat noch keine Mailarten definiert.",
        'MEMBER_POINTS_LEFT' => "{?POINTS?}-Guthaben zum Mailversand &uuml;brig",
        'SELECT_MAIL_TYPE' => "Mailart ausw&auml;hlen",
        'PLEASE_SELECT' => "Bitte ausw&auml;hlen",
        'MEMBER_POINTS_LEFT' => "{?POINTS?}-Guthaben zum Mailversand &uuml;brig",
        'SELECT_MAIL_TYPE' => "Mailart ausw&auml;hlen",
        'PLEASE_SELECT' => "Bitte ausw&auml;hlen",
@@ -644,7 +642,7 @@ addMessages(array(
        'ADMIN_EXTENSION_REGISTRATION_FAILED_ID_404' => "Registrierung fehlgeschlagen: Erweiterung-Id nicht auffindbar.",
        'ADMIN_EXTENSION_REGISTRATION_FAILED_404' => "Registrierung fehlgeschlagen: Erweiterung <span class=\"data\">%s</span> nicht auffindbar.",
        'ADMIN_EXTENSION_REGISTRATION_FAILED_ASSIGED' => "Registrierung fehlgeschlagen: Sie sind nicht zugewiesen oder die Aufgabe ist veraltet.",
        'ADMIN_EXTENSION_REGISTRATION_FAILED_ID_404' => "Registrierung fehlgeschlagen: Erweiterung-Id nicht auffindbar.",
        'ADMIN_EXTENSION_REGISTRATION_FAILED_404' => "Registrierung fehlgeschlagen: Erweiterung <span class=\"data\">%s</span> nicht auffindbar.",
        'ADMIN_EXTENSION_REGISTRATION_FAILED_ASSIGED' => "Registrierung fehlgeschlagen: Sie sind nicht zugewiesen oder die Aufgabe ist veraltet.",
-       'ADMIN_EXTENSION_REGISTRATION_FAILED_ALREADY' => "Registrierung fehlgeschlagen: Erweiterun bereits installiert.",
+       'ADMIN_EXTENSION_REGISTRATION_FAILED_ALREADY' => "Registrierung fehlgeschlagen: Erweiterung bereits installiert.",
        'ADMIN_EXTENSION_REGISTRATION_FAILED_DEPRECATED' => "Registrierung fehlgeschlagen: Erweiterung ist veraltet.",
        'ADMIN_NO_EXTENSION_REGISTERED' => "Derzeit haben Sie keine Erweiterung in Ihrem {?mt_word?} registriert.",
        'ADMIN_EXTENSION_REGISTERED' => "Erweiterung <span class=\"data\">%s</span> wurde in Ihrem {?mt_word?} registriert.",
        'ADMIN_EXTENSION_REGISTRATION_FAILED_DEPRECATED' => "Registrierung fehlgeschlagen: Erweiterung ist veraltet.",
        'ADMIN_NO_EXTENSION_REGISTERED' => "Derzeit haben Sie keine Erweiterung in Ihrem {?mt_word?} registriert.",
        'ADMIN_EXTENSION_REGISTERED' => "Erweiterung <span class=\"data\">%s</span> wurde in Ihrem {?mt_word?} registriert.",
index e5d1dbd913934ea35f25af756f14e6121d2c45e9..fbc9695bf99c55af33636e5159df5d3f1f8a35ef 100644 (file)
@@ -44,6 +44,7 @@ if (!defined('__SECURITY')) {
 addMessages(array(
        'MEMBER_PROFILE_LAST_CHANGE' => "Letzte &Auml;nderung",
        'MEMBER_PROFILE_UPDATED' => "Ihre Profildaten wurden aktualisiert.",
 addMessages(array(
        'MEMBER_PROFILE_LAST_CHANGE' => "Letzte &Auml;nderung",
        'MEMBER_PROFILE_UPDATED' => "Ihre Profildaten wurden aktualisiert.",
+       'MEMBER_EMAIL_IS_ALREADY_REGISTERED' => "Die Email-Adresse wird bereits von einem anderen Account verwendet.",
 ));
 
 // [EOF]
 ));
 
 // [EOF]
index 953a5ff901cf6f070ff1f68c1bc135f850dbd8a9..8035ccf27d1ed1f8bad22d111137e4f13bc5eb88 100644 (file)
@@ -52,8 +52,7 @@ function addPointsBeg ($userid, $points) {
                        array($points, $userid), __FUNCTION__, __LINE__);
        } else {
                // Add points to account
                        array($points, $userid), __FUNCTION__, __LINE__);
        } else {
                // Add points to account
-               // @TODO Try to rewrite the following unset()
-               unset($GLOBALS['ref_level']);
+               initReferalSystem();
                $added = addPointsThroughReferalSystem('beg', $userid, $points, false, 0, getBegMode());
        }
 
                $added = addPointsThroughReferalSystem('beg', $userid, $points, false, 0, getBegMode());
        }
 
index b3fb7f1fa6d37a6dc6ab579a5efa9c32060b31dc..4f86bd6cfd40e9554e0824af65907736b45e02cb 100644 (file)
@@ -117,11 +117,11 @@ ON
        p.userid=d.userid
 WHERE
        d.`status`='CONFIRMED' AND
        p.userid=d.userid
 WHERE
        d.`status`='CONFIRMED' AND
-       d.max_mails > 0 AND
-       d.mails_confirmed >= {?ref_payout?} AND
-       p.ref_depth=1 AND
-       p.points > 0 AND
-       d.userid=%s",
+       d.`max_mails` > 0 AND
+       d.`mails_confirmed` >= {?ref_payout?} AND
+       p.`ref_depth`=1 AND
+       p.`points` > 0 AND
+       d.`userid`=%s",
                                array(bigintval($content['userid'])), __FUNCTION__, __LINE__);
 
                        // Get points
                                array(bigintval($content['userid'])), __FUNCTION__, __LINE__);
 
                        // Get points
index 92a13150aef08dfb99f2d86f48252abfc9296989..c66cdcf6801591b83cd898ed5aa363f45617eae7 100644 (file)
@@ -42,12 +42,12 @@ if (!defined('__SECURITY')) {
 
 // Payback refback for refid and reduce it for current user
 function addRefbackPoints ($userid, $ref, $points, $ref_points) {
 
 // Payback refback for refid and reduce it for current user
 function addRefbackPoints ($userid, $ref, $points, $ref_points) {
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',points=' . $points . ',ref_points=' . $ref_points . ' - ENTERED!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',points=' . $points . ',ref_points=' . $ref_points . ' - ENTERED!');
        // Back ref depths
        $GLOBALS['refback_depth'][$userid][$ref] = $GLOBALS['ref_level'];
 
        // Init points
        // Back ref depths
        $GLOBALS['refback_depth'][$userid][$ref] = $GLOBALS['ref_level'];
 
        // Init points
-       $return = $points;
+       $return = $ref_points;
 
        // Get all ref levels
        $result_refs = SQL_QUERY('SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `level` > 0 ORDER BY `level` ASC',
 
        // Get all ref levels
        $result_refs = SQL_QUERY('SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `level` > 0 ORDER BY `level` ASC',
@@ -56,39 +56,49 @@ function addRefbackPoints ($userid, $ref, $points, $ref_points) {
        // "Walk" through all level
        while ($content = SQL_FETCHARRAY($result_refs)) {
                // Reset ref depths
        // "Walk" through all level
        while ($content = SQL_FETCHARRAY($result_refs)) {
                // Reset ref depths
-               // @TODO Try to rewrite the following unset()
-               unset($GLOBALS['ref_level']);
+               initReferalSystem();
 
                // "Walk" through all refids
 
                // "Walk" through all refids
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',level=' . $content['level'] . ',points=' . $points);
+               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',level=' . $content['level'] . ',percents=' . $content['percents'] . ',points=' . $points . ' - LOOP START!');
                foreach (getArrayFromRefbackLevel($userid, $content['level']) as $refid) {
                        // Skip level zero or if both are the same
                foreach (getArrayFromRefbackLevel($userid, $content['level']) as $refid) {
                        // Skip level zero or if both are the same
-                       if ($userid == $refid) continue;
+                       if ($userid == $refid) {
+                               continue;
+                       } // END - if
 
                        // Get refback percents
                        $percents = getRefbackPercents($userid, $refid);
 
                        // Get refback percents
                        $percents = getRefbackPercents($userid, $refid);
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',refid=' . $refid . ',points=' . $points . ',percents=' . $percents);
+                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',refid=' . $refid . ',points=' . $points . ',percents=' . $percents);
 
                        // Some percents given?
                        if ($percents > 0) {
 
                        // Some percents given?
                        if ($percents > 0) {
-                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'points=' . $points . ',[percents]=' . $content['percents'] . ',percents=' . $percents . ',level=' . $content['level']);
+                               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'points=' . $points . ',[percents]=' . $content['percents'] . ',percents=' . $percents . ',level=' . $content['level']);
                                // Calculate points for refback
                                $refback = $points * ($content['percents'] / 100) * ($percents / 100);
 
                                // Update refback table ('refid' and 'userid' must be exchanged!)
                                SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_refs` SET `points`=`points`+%s WHERE `userid`=%s AND `refid`=%s LIMIT 1",
                                // Calculate points for refback
                                $refback = $points * ($content['percents'] / 100) * ($percents / 100);
 
                                // Update refback table ('refid' and 'userid' must be exchanged!)
                                SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_refs` SET `points`=`points`+%s WHERE `userid`=%s AND `refid`=%s LIMIT 1",
-                                       array($refback, $refid, $userid), __FUNCTION__, __LINE__);
-                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refback=' . $refback . ',userid=' . $userid . ',refid=' . $refid . ' - UPDATE! (' . SQL_AFFECTEDROWS() . ')');
+                                       array(
+                                               $refback,
+                                               $refid,
+                                               $userid
+                                       ), __FUNCTION__, __LINE__);
+
+                               // Something must have been updated
+                               if (SQL_HASZEROAFFECTED()) {
+                                       // Please report this bug
+                                       debug_report_bug(__FUNCTION__, __LINE__, 'Nothing has been updated in user_refs,userid=' . $userid . ',refid=' . $refid . ',refback=' . $refback);
+                               } // END - if
 
                                // Add points again, but only directly
 
                                // Add points again, but only directly
-                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refback=' . $refback);
+                               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refback=' . $refback . ',userid=' . $userid . ',ref=' . $ref . ',refid=' . $refid . ' - UPDATE! (' . SQL_AFFECTEDROWS() . ')');
                                addPointsDirectly(sprintf("refback:%s", $refid), $userid, $refback);
 
                                // Reduce points if refid is found
                                if ($refid == $ref) {
                                        // Reduce points here!
                                        $return = $points * ($content['percents'] / 100) - $refback;
                                addPointsDirectly(sprintf("refback:%s", $refid), $userid, $refback);
 
                                // Reduce points if refid is found
                                if ($refid == $ref) {
                                        // Reduce points here!
                                        $return = $points * ($content['percents'] / 100) - $refback;
-                                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'return=' . $return . ' - REDUCED!');
+                                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'return=' . $return . ' - REDUCED!');
                                } // END - if
                        } // END - if
                } // END foreach
                                } // END - if
                        } // END - if
                } // END foreach
@@ -101,15 +111,17 @@ function addRefbackPoints ($userid, $ref, $points, $ref_points) {
        $GLOBALS['ref_level'] = $GLOBALS['refback_depth'][$userid][$ref];
 
        // Return them
        $GLOBALS['ref_level'] = $GLOBALS['refback_depth'][$userid][$ref];
 
        // Return them
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',points=' . $points . ',ref_points=' . $ref_points . ',return=' . $return . ' - ENTERED!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',points=' . $points . ',ref_points=' . $ref_points . ',return=' . $return . ' - EXIT!');
        return $return;
 }
 
 // "Getter" for refback percents
 function getRefbackPercents ($userid, $ref) {
        return $return;
 }
 
 // "Getter" for refback percents
 function getRefbackPercents ($userid, $ref) {
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ' - ENTERED!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ' - ENTERED!');
        // Skip identical ids
        // Skip identical ids
-       if ($userid == $ref) return 0;
+       if ($userid == $ref) {
+               return 0;
+       } // END - if
 
        // Is it cached?
        if (!isset($GLOBALS['refback_percents'][$userid][$ref])) {
 
        // Is it cached?
        if (!isset($GLOBALS['refback_percents'][$userid][$ref])) {
@@ -124,7 +136,7 @@ function getRefbackPercents ($userid, $ref) {
                if (SQL_NUMROWS($result) == 1) {
                        // Fetch percents
                        list($GLOBALS['refback_percents'][$userid][$ref]) = SQL_FETCHROW($result);
                if (SQL_NUMROWS($result) == 1) {
                        // Fetch percents
                        list($GLOBALS['refback_percents'][$userid][$ref]) = SQL_FETCHROW($result);
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',percents=' . $GLOBALS['refback_percents'][$userid][$ref]);
+                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',percents=' . $GLOBALS['refback_percents'][$userid][$ref]);
                } else {
                        // Debug log
                        logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ' - No entry found. :-(');
                } else {
                        // Debug log
                        logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ' - No entry found. :-(');
@@ -135,13 +147,13 @@ function getRefbackPercents ($userid, $ref) {
        } // END - if
 
        // Return percents
        } // END - if
 
        // Return percents
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',refback_percents=' . $GLOBALS['refback_percents'][$userid][$ref] . ' - EXIT!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',refback_percents=' . $GLOBALS['refback_percents'][$userid][$ref] . ' - EXIT!');
        return $GLOBALS['refback_percents'][$userid][$ref];
 }
 
 // "Getter" for userid array which will return only one entry
 function getArrayFromRefbackLevel ($refid, $level) {
        return $GLOBALS['refback_percents'][$userid][$ref];
 }
 
 // "Getter" for userid array which will return only one entry
 function getArrayFromRefbackLevel ($refid, $level) {
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . $refid . ',level=' . $level);
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . $refid . ',level=' . $level);
        // Init userids
        $userIds = array();
 
        // Init userids
        $userIds = array();
 
@@ -157,11 +169,11 @@ ORDER BY
                array($refid, $level), __FUNCTION__, __LINE__);
 
        // Entries found?
                array($refid, $level), __FUNCTION__, __LINE__);
 
        // Entries found?
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'numRows=' . SQL_NUMROWS($result));
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'numRows=' . SQL_NUMROWS($result));
        if (!SQL_HASZERONUMS($result)) {
                // Add all
                while ($content = SQL_FETCHARRAY($result)) {
        if (!SQL_HASZERONUMS($result)) {
                // Add all
                while ($content = SQL_FETCHARRAY($result)) {
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . $refid . ',level=' . $level . ',userid=' . $content['userid']);
+                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . $refid . ',level=' . $level . ',userid=' . $content['userid']);
                        $userIds[] = $content['userid'];
                } // END - while
        } // END - if
                        $userIds[] = $content['userid'];
                } // END - while
        } // END - if
@@ -170,7 +182,7 @@ ORDER BY
        SQL_FREERESULT($result);
 
        // Return array
        SQL_FREERESULT($result);
 
        // Return array
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . $refid . ',userIds()=' . count($userIds) . ' - EXIT!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . $refid . ',userIds()=' . count($userIds) . ' - EXIT!');
        return $userIds;
 }
 
        return $userIds;
 }
 
@@ -178,20 +190,21 @@ ORDER BY
 function updateRefbackTable ($userid) {
        // Make it sure referal level zero (member him-/herself) is at least selected
        if (empty($GLOBALS['refback_level'])) {
 function updateRefbackTable ($userid) {
        // Make it sure referal level zero (member him-/herself) is at least selected
        if (empty($GLOBALS['refback_level'])) {
-               $GLOBALS['refback_level'] = 1;
+               $GLOBALS['refback_level'] = NULL;
        } // END - if
        } // END - if
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $GLOBALS['refback_level'] . ' - ENTERED!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $GLOBALS['refback_level'] . ' - ENTERED!');
 
 
-       // Init refid
+       // Init refid and variables
        $GLOBALS['refback_refid'][$GLOBALS['refback_level']] = '0';
        $GLOBALS['refback_refid'][$GLOBALS['refback_level']] = '0';
-       $old = '0'; $minus = '0';
+       $old = '0';
+       $minus = '0';
 
        // Check for his referal
        $result_refid = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `refid`=%s ORDER BY `userid` ASC",
                array(bigintval($userid)), __FUNCTION__, __LINE__);
 
        // When no entry was updated then we have to create it here
 
        // Check for his referal
        $result_refid = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `refid`=%s ORDER BY `userid` ASC",
                array(bigintval($userid)), __FUNCTION__, __LINE__);
 
        // When no entry was updated then we have to create it here
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SQL_NUMROWS()=' . SQL_NUMROWS($result_refid));
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SQL_NUMROWS()=' . SQL_NUMROWS($result_refid));
        if (!SQL_HASZERONUMS($result_refid)) {
                // Load all refids
                while (list($GLOBALS['refback_refid'][$GLOBALS['refback_level']]) = SQL_FETCHROW($result_refid)) {
        if (!SQL_HASZERONUMS($result_refid)) {
                // Load all refids
                while (list($GLOBALS['refback_refid'][$GLOBALS['refback_level']]) = SQL_FETCHROW($result_refid)) {
@@ -199,7 +212,7 @@ function updateRefbackTable ($userid) {
                        $GLOBALS['refback_userid'][$GLOBALS['refback_refid'][$GLOBALS['refback_level']]] = $userid;
 
                        // Refid set?
                        $GLOBALS['refback_userid'][$GLOBALS['refback_refid'][$GLOBALS['refback_level']]] = $userid;
 
                        // Refid set?
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']]);
+                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']]);
                        if (($GLOBALS['refback_refid'][$GLOBALS['refback_level']] > 0) && ($GLOBALS['refback_refid'][$GLOBALS['refback_level']] != $userid) && (isset($GLOBALS['refback_refid'][$GLOBALS['refback_level']]))) {
                                // New userid?
                                if ((isset($GLOBALS['refback_refid'][$GLOBALS['refback_level']-1])) && (isset($GLOBALS['refback_userid'][$GLOBALS['refback_refid'][$GLOBALS['refback_level']-1]]))) {
                        if (($GLOBALS['refback_refid'][$GLOBALS['refback_level']] > 0) && ($GLOBALS['refback_refid'][$GLOBALS['refback_level']] != $userid) && (isset($GLOBALS['refback_refid'][$GLOBALS['refback_level']]))) {
                                // New userid?
                                if ((isset($GLOBALS['refback_refid'][$GLOBALS['refback_level']-1])) && (isset($GLOBALS['refback_userid'][$GLOBALS['refback_refid'][$GLOBALS['refback_level']-1]]))) {
@@ -207,24 +220,38 @@ function updateRefbackTable ($userid) {
                                        $old = $userid;
                                        $userid = $GLOBALS['refback_userid'][$GLOBALS['refback_refid'][$GLOBALS['refback_level']-1]];
                                        $minus = 1;
                                        $old = $userid;
                                        $userid = $GLOBALS['refback_userid'][$GLOBALS['refback_refid'][$GLOBALS['refback_level']-1]];
                                        $minus = 1;
-                                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',old=' . $old . ',level=' . $GLOBALS['refback_level'] . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ' - NEW UID!');
+                                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',old=' . $old . ',level=' . $GLOBALS['refback_level'] . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ' - NEW UID!');
                                } // END - if
 
                                // Check existence
                                } // END - if
 
                                // Check existence
-                               $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid`=%s AND `level`=%s AND `refid`=%s LIMIT 1",
-                                       array(
-                                               bigintval($userid),
-                                               bigintval($GLOBALS['refback_level']),
-                                               bigintval($GLOBALS['refback_refid'][$GLOBALS['refback_level']])
-                                       ), __FUNCTION__, __LINE__);
+                               if (is_null($GLOBALS['refback_level'])) {
+                                       // Level is NULL
+                                       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid`=%s AND `level` IS NULL AND `refid`=%s LIMIT 1",
+                                               array(
+                                                       bigintval($userid),
+                                                       bigintval($GLOBALS['refback_refid'][$GLOBALS['refback_level']])
+                                               ), __FUNCTION__, __LINE__);
+                               } else {
+                                       // Level is > 0
+                                       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid`=%s AND `level`=%s AND `refid`=%s LIMIT 1",
+                                               array(
+                                                       bigintval($userid),
+                                                       bigintval($GLOBALS['refback_level']),
+                                                       bigintval($GLOBALS['refback_refid'][$GLOBALS['refback_level']])
+                                               ), __FUNCTION__, __LINE__);
+                               }
 
                                // Do we have no entry?
 
                                // Do we have no entry?
-                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $GLOBALS['refback_level'] . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ',minus=' . $minus . ',numRows=' . SQL_NUMROWS($result) . ' - FOUND!');
+                               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $GLOBALS['refback_level'] . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ',minus=' . $minus . ',numRows=' . SQL_NUMROWS($result) . ' - FOUND!');
                                if (SQL_HASZERONUMS($result)) {
                                        // Insert this level
                                if (SQL_HASZERONUMS($result)) {
                                        // Insert this level
-                                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $GLOBALS['refback_level'] . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ' - ADD!');
+                                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $GLOBALS['refback_level'] . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ' - ADD!');
                                        SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_refs` (`userid`,`level`,`refid`) VALUES (%s,%s,%s)",
                                        SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_refs` (`userid`,`level`,`refid`) VALUES (%s,%s,%s)",
-                                               array(bigintval($userid), $GLOBALS['refback_level'], bigintval($GLOBALS['refback_refid'][$GLOBALS['refback_level']])), __FUNCTION__, __LINE__);
+                                               array(
+                                                       bigintval($userid),
+                                                       $GLOBALS['refback_level'],
+                                                       bigintval($GLOBALS['refback_refid'][$GLOBALS['refback_level']])
+                                               ), __FUNCTION__, __LINE__);
 
                                        // Move to next referal level and count his counter one up!
                                        $GLOBALS['refback_level']++;
 
                                        // Move to next referal level and count his counter one up!
                                        $GLOBALS['refback_level']++;
@@ -245,12 +272,16 @@ function updateRefbackTable ($userid) {
                                                ), __FUNCTION__, __LINE__);
 
                                        // Do we have no entry?
                                                ), __FUNCTION__, __LINE__);
 
                                        // Do we have no entry?
-                                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . ($GLOBALS['refback_level'] - $minus) . ',minus=' . $minus . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ',numRows=' . SQL_NUMROWS($result) . ' - BACK!');
+                                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . ($GLOBALS['refback_level'] - $minus) . ',minus=' . $minus . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ',numRows=' . SQL_NUMROWS($result) . ' - BACK!');
                                        if (SQL_HASZERONUMS($result)) {
                                                // Insert this level
                                                SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_refs` (`userid`,`level`,`refid`) VALUES (%s,%s,%s)",
                                        if (SQL_HASZERONUMS($result)) {
                                                // Insert this level
                                                SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_refs` (`userid`,`level`,`refid`) VALUES (%s,%s,%s)",
-                                                       array(bigintval($userid), ($GLOBALS['refback_level']-$minus), bigintval($GLOBALS['refback_refid'][$GLOBALS['refback_level']])), __FUNCTION__, __LINE__);
-                                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . ($GLOBALS['refback_level'] - $minus) . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ' - RETURNED!');
+                                                       array(
+                                                               bigintval($userid),
+                                                               ($GLOBALS['refback_level'] - $minus),
+                                                               bigintval($GLOBALS['refback_refid'][$GLOBALS['refback_level']])
+                                                       ), __FUNCTION__, __LINE__);
+                                               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . ($GLOBALS['refback_level'] - $minus) . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ' - RETURNED!');
                                        } // END - if
                                } // END - if
                        } // END - if
                                        } // END - if
                                } // END - if
                        } // END - if
@@ -263,25 +294,25 @@ function updateRefbackTable ($userid) {
        // When he has a referal...
        if ((($GLOBALS['refback_refid'][$GLOBALS['refback_level']] == $userid) || ($GLOBALS['refback_refid'][$GLOBALS['refback_level']] == '0')) && (isExtensionInstalledAndNewer('cache', '0.1.2')) && (!isset($GLOBALS['refback_cached']))) {
                // Remove cache here
        // When he has a referal...
        if ((($GLOBALS['refback_refid'][$GLOBALS['refback_level']] == $userid) || ($GLOBALS['refback_refid'][$GLOBALS['refback_level']] == '0')) && (isExtensionInstalledAndNewer('cache', '0.1.2')) && (!isset($GLOBALS['refback_cached']))) {
                // Remove cache here
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ' - CACHE!');
+               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ' - CACHE!');
                if ($GLOBALS['cache_instance']->loadCacheFile('refback')) $GLOBALS['cache_instance']->removeCacheFile();
                $GLOBALS['refback_cached'] = 1;
        } // END - if
 
        // "Walk" back here
        $GLOBALS['refback_level']--;
                if ($GLOBALS['cache_instance']->loadCacheFile('refback')) $GLOBALS['cache_instance']->removeCacheFile();
                $GLOBALS['refback_cached'] = 1;
        } // END - if
 
        // "Walk" back here
        $GLOBALS['refback_level']--;
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refback_level=' . $GLOBALS['refback_level'] .' - LEVEL!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refback_level=' . $GLOBALS['refback_level'] .' - LEVEL!');
 
        // Fix empty refid
        if (!isset($GLOBALS['refback_refid'][$GLOBALS['refback_level']-1])) {
                $GLOBALS['refback_refid'][$GLOBALS['refback_level']-1] = '0';
        } // END - if
 
        // Fix empty refid
        if (!isset($GLOBALS['refback_refid'][$GLOBALS['refback_level']-1])) {
                $GLOBALS['refback_refid'][$GLOBALS['refback_level']-1] = '0';
        } // END - if
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refback_level=' . {$GLOBALS['refback_level'] . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']-1] . ' - EXIT!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refback_level=' . $GLOBALS['refback_level'] . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']-1] . ' - EXIT!');
 }
 
 // "Getter" for array for user refs in given level
 function getArrayFromRefbackUserRefs ($userid, $level) {
 }
 
 // "Getter" for array for user refs in given level
 function getArrayFromRefbackUserRefs ($userid, $level) {
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ' - ENTERED!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ' - ENTERED!');
        // Default is no refs and no nickname
        $refs = array();
 
        // Default is no refs and no nickname
        $refs = array();
 
@@ -320,13 +351,13 @@ ORDER BY
        SQL_FREERESULT($result);
 
        // Return result
        SQL_FREERESULT($result);
 
        // Return result
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refs()=' . count($refs) . ' - EXIT!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refs()=' . count($refs) . ' - EXIT!');
        return $refs;
 }
 
 // "Getter" for refback entry
 function getArrayFromUserRefbackData ($id) {
        return $refs;
 }
 
 // "Getter" for refback entry
 function getArrayFromUserRefbackData ($id) {
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ' - ENTERED!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ' - ENTERED!');
        // Default data is nothing
        $data = array();
 
        // Default data is nothing
        $data = array();
 
@@ -347,13 +378,13 @@ function getArrayFromUserRefbackData ($id) {
        SQL_FREERESULT($result);
 
        // Return entry
        SQL_FREERESULT($result);
 
        // Return entry
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',data()=' . count($data) . ' - EXIT!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',data()=' . count($data) . ' - EXIT!');
        return $data;
 }
 
 // Update refback percents (but with some sanity-checks!
 function updateMemberRefbackPercents ($id, $percents) {
        return $data;
 }
 
 // Update refback percents (but with some sanity-checks!
 function updateMemberRefbackPercents ($id, $percents) {
-       //* logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',percents=' . $percents . ' - ENTERED!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',percents=' . $percents . ' - ENTERED!');
        // Default status is failed
        $status['message'] = '{--MEMBER_REFBACK_ERROR_GENERAL--}';
 
        // Default status is failed
        $status['message'] = '{--MEMBER_REFBACK_ERROR_GENERAL--}';
 
@@ -412,7 +443,7 @@ function updateMemberRefbackPercents ($id, $percents) {
        $status['ok'] = true;
 
        // Return status array
        $status['ok'] = true;
 
        // Return status array
-       //* logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',percents=' . $percents . ' - EXIT!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',percents=' . $percents . ' - EXIT!');
        return $status;
 }
 
        return $status;
 }
 
index 5bf3cdbb9195c9dc7b69a9c2459df3757ba37dec..0b2f58f63ada678355e1bc0fee6f818d5d5c4d3f 100644 (file)
@@ -320,9 +320,9 @@ function doRegistration () {
        // Create user's account...
        SQL_QUERY_ESC("INSERT INTO
        `{?_MYSQL_PREFIX?}_user_data`
        // Create user's account...
        SQL_QUERY_ESC("INSERT INTO
        `{?_MYSQL_PREFIX?}_user_data`
-(`gender`, `surname`, `family`, `street_nr`,%s, `zip`, `city`, `email`, `birth_day`, `birth_month`, `birth_year`, `password`, `max_mails`, `receive_mails`, `refid`, `status`, `user_hash`, `REMOTE_ADDR`, `joined`, `last_update`".$GLOBALS['register_sql_columns'].")
+(`gender`, `surname`, `family`, `street_nr`,%s, `zip`, `city`, `email`, `birth_day`, `birth_month`, `birth_year`, `password`, `max_mails`, `receive_mails`, `refid`, `status`, `user_hash`, `REMOTE_ADDR`, `joined`, `last_update`,`ref_payout`".$GLOBALS['register_sql_columns'].")
        VALUES
        VALUES
-('%s','%s','%s','%s','%s',%s,'%s','%s',%s, %s,%s,'%s',%s, %s,'%s','UNCONFIRMED','%s','%s', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()".$GLOBALS['register_sql_data'].")",
+('%s','%s','%s','%s','%s',%s,'%s','%s',%s, %s,%s,'%s',%s, %s,'%s','UNCONFIRMED','%s','%s', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), {?ref_payout?}".$GLOBALS['register_sql_data'].")",
        array(
                $countryRow,
                substr(postRequestParameter('gender'), 0, 1),
        array(
                $countryRow,
                substr(postRequestParameter('gender'), 0, 1),
@@ -356,12 +356,8 @@ function doRegistration () {
                return;
        } // END - if
 
                return;
        } // END - if
 
-       // Is the refback extension there?
-       // @TODO Rewrite this to a filter
-       if (isExtensionActive('refback')) {
-               // Update refback table
-               updateRefbackTable($userid);
-       } // END - if
+       // Update referal table
+       updateReferalCounter($userid);
 
        // Write his welcome-points
        // @TODO Wether the registration bonus should only be added to user directly or through referal system should be configurable
 
        // Write his welcome-points
        // @TODO Wether the registration bonus should only be added to user directly or through referal system should be configurable
index fdf54732838642be27311ce0ef2b8763589bec24..2e5c248c663302a89c905eac9606262123b8b3f3 100644 (file)
@@ -873,18 +873,20 @@ function SURFBAR_DETERMINE_TEMPLATE_NAME() {
 // Check if the "reload lock" of the current user is full, call this function
 // before you call SURFBAR_CHECK_RELOAD_LOCK().
 function SURFBAR_CHECK_RELOAD_FULL () {
 // Check if the "reload lock" of the current user is full, call this function
 // before you call SURFBAR_CHECK_RELOAD_LOCK().
 function SURFBAR_CHECK_RELOAD_FULL () {
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Fixed surf lock is ' . getConfig('surfbar_static_lock') . ' - ENTERED!');
        // Default is full!
        $isFull = true;
 
        // Cache static reload lock
        $GLOBALS['surfbar_cache']['surf_lock'] = getConfig('surfbar_static_lock');
        // Default is full!
        $isFull = true;
 
        // Cache static reload lock
        $GLOBALS['surfbar_cache']['surf_lock'] = getConfig('surfbar_static_lock');
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Fixed surf lock is '.getConfig('surfbar_static_lock') . '', false);
 
        // Do we have dynamic model?
 
        // Do we have dynamic model?
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'surf_lock=' . $GLOBALS['surfbar_cache']['surf_lock'] . ' - BEFORE');
        if (getSurfbarPaymentModel() == 'DYNAMIC') {
                // "Calculate" dynamic lock
                $GLOBALS['surfbar_cache']['surf_lock'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
        } // END - if
        if (getSurfbarPaymentModel() == 'DYNAMIC') {
                // "Calculate" dynamic lock
                $GLOBALS['surfbar_cache']['surf_lock'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
        } // END - if
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'surf_lock=' . $GLOBALS['surfbar_cache']['surf_lock'] . ' - AFTER');
 
        // Ask the database
        $result = SQL_QUERY_ESC("SELECT
 
        // Ask the database
        $result = SQL_QUERY_ESC("SELECT
@@ -922,10 +924,10 @@ LIMIT 1",
        $total = SURFBAR_GET_TOTAL_URLS();
 
        // Do we have some URLs in lock? Admins can always surf on own URLs!
        $total = SURFBAR_GET_TOTAL_URLS();
 
        // Do we have some URLs in lock? Admins can always surf on own URLs!
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userLocks=' . SURFBAR_GET_USER_LOCKS() . ',total=' . $total);
        $isFull = ((SURFBAR_GET_USER_LOCKS() == $total) && ($total > 0));
 
        // Return result
        $isFull = ((SURFBAR_GET_USER_LOCKS() == $total) && ($total > 0));
 
        // Return result
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userLocks=' . SURFBAR_GET_USER_LOCKS() . ',total=' . $total . 'isFull=' . intval($isFull) . ' - EXIT!');
        return $isFull;
 }
 
        return $isFull;
 }
 
@@ -965,7 +967,7 @@ LIMIT 1",
        SQL_FREERESULT($result);
 
        // Debug message
        SQL_FREERESULT($result);
 
        // Debug message
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'cnt=' . $count);
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'cnt=' . $count);
 
        // Return result
        return $count;
 
        // Return result
        return $count;
@@ -1015,53 +1017,32 @@ function SURFBAR_GET_TOTAL_USER_URLS ($userid = '0', $status = '', $exclude = ''
 
 // Generate a validation code for the given id number
 function SURFBAR_GENERATE_VALIDATION_CODE ($urlId, $salt = '') {
 
 // Generate a validation code for the given id number
 function SURFBAR_GENERATE_VALIDATION_CODE ($urlId, $salt = '') {
-       // @TODO Invalid salt should be refused
-       $length = '0';
-       $GLOBALS['surfbar_cache']['salt'] = 'INVALID';
-
-       // Is extension ext-other there?
-       if (isExtensionActive('other')) {
-               // Get code length from config
-               $length = getCodeLength();
-       } // END - if
-
-       // Fix length to 10
-       if ($length == '0') {
-               $length = 10;
-       } // END - if
-
-       // Generate a code until the length matches
-       $valCode = '';
-       while (strlen($valCode) != $length) {
-               // Is the salt set?
-               if (empty($salt)) {
-                       // Generate random hashed string
-                       $GLOBALS['surfbar_cache']['salt'] = sha1(generatePassword(mt_rand(200, 255)));
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newSalt='.SURFBAR_GET_SALT().'', false);
-               } else {
-                       // Use this as salt!
-                       $GLOBALS['surfbar_cache']['salt'] = $salt;
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'oldSalt='.SURFBAR_GET_SALT().'', false);
-               }
-
-               // ... and now the validation code
-               $valCode = generateRandomCode($length, sha1(SURFBAR_GET_SALT() . getEncryptSeperator() . $urlId), getMemberId());
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'valCode='.valCode.'', false);
-       } // END - while
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',salt=' . $salt . ' - ENTERED!');
+       // Init hash with invalid value
+       if (empty($salt)) {
+                // Generate random hashed string
+               $GLOBALS['surfbar_cache']['salt'] = sha1(generatePassword(mt_rand(200, 255)));
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newSalt='.SURFBAR_GET_SALT().'', false);
+       } else {
+               // Use this as salt!
+               $GLOBALS['surfbar_cache']['salt'] = $salt;
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'oldSalt='.SURFBAR_GET_SALT().'', false);
+       }
 
        // Hash it with md5() and salt it with the random string
 
        // Hash it with md5() and salt it with the random string
-       $hashedCode = generateHash(md5($valCode), SURFBAR_GET_SALT());
+       $hashedCode = generateHash(md5($urlId . getEncryptSeperator() . getMemberId()), SURFBAR_GET_SALT());
 
        // Finally encrypt it PGP-like and return it
        $valHashedCode = encodeHashForCookie($hashedCode);
 
        // Return hashed value
 
        // Finally encrypt it PGP-like and return it
        $valHashedCode = encodeHashForCookie($hashedCode);
 
        // Return hashed value
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'finalValCode='.$valHashedCode.'', false);
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',salt=' . $salt . ',urlId=' . $urlId . ',salt=' . $salt . ',valHashedCode=' . $valHashedCode . ' - EXIT!');
        return $valHashedCode;
 }
 
 // Check validation code
 function SURFBAR_CHECK_VALIDATION_CODE ($urlId, $check, $salt) {
        return $valHashedCode;
 }
 
 // Check validation code
 function SURFBAR_CHECK_VALIDATION_CODE ($urlId, $check, $salt) {
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',check=' . $check . ',salt=' . $salt . ' - ENTERED!');
        // Secure id number
        $urlId = bigintval($urlId);
 
        // Secure id number
        $urlId = bigintval($urlId);
 
@@ -1069,38 +1050,51 @@ function SURFBAR_CHECK_VALIDATION_CODE ($urlId, $check, $salt) {
        $code = SURFBAR_GENERATE_VALIDATION_CODE($urlId, $salt);
 
        // Return result of checking hashes and salts
        $code = SURFBAR_GENERATE_VALIDATION_CODE($urlId, $salt);
 
        // Return result of checking hashes and salts
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '---'.$code.'|'.$check.'---', false);
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '+++'.$salt.'|'.SURFBAR_GET_DATA('salts_last_salt').'+++', false);
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',(code==check)=' . intval($code == $check) . ',(salt==salts_last_salt)=' . intval($salt == SURFBAR_GET_DATA('salts_last_salt')) . ' - EXIT!');
        return (($code == $check) && ($salt == SURFBAR_GET_DATA('salts_last_salt')));
 }
 
 // Lockdown the userid/id combination (reload lock)
 function SURFBAR_LOCKDOWN_ID ($urlId) {
        return (($code == $check) && ($salt == SURFBAR_GET_DATA('salts_last_salt')));
 }
 
 // Lockdown the userid/id combination (reload lock)
 function SURFBAR_LOCKDOWN_ID ($urlId) {
-       //* DEBUG: */ debugOutput('LOCK!');
-       ///* DEBUG: */ return;
-       // Just add it to the database
-       SQL_QUERY_ESC('INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_locks` (`locks_userid`, `locks_url_id`) VALUES (%s, %s)',
-               array(getMemberId(), bigintval($urlId)), __FUNCTION__, __LINE__);
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',getMemberId()=' . getMemberId() . ' - ENTERED!');
+       // Search for an entry
+       $countLock = countSumTotalData(getMemberId(), 'surfbar_locks', 'locks_id', 'locks_userid', true, ' AND `locks_url_id`=' . bigintval($urlId));
+
+       // Do we have no record?
+       if ($countLock == 0) {
+               // Just add it to the database
+               SQL_QUERY_ESC('INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_locks` (`locks_userid`, `locks_url_id`) VALUES (%s, %s)',
+                       array(
+                               getMemberId(),
+                               bigintval($urlId)
+                       ), __FUNCTION__, __LINE__);
+       } // END - if
 
        // Remove the salt from database
        SQL_QUERY_ESC('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_surfbar_salts` WHERE `salts_url_id`=%s AND `salts_userid`=%s LIMIT 1',
 
        // Remove the salt from database
        SQL_QUERY_ESC('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_surfbar_salts` WHERE `salts_url_id`=%s AND `salts_userid`=%s LIMIT 1',
-               array(bigintval($urlId), getMemberId()), __FUNCTION__, __LINE__);
+               array(
+                       bigintval($urlId),
+                       getMemberId()
+               ), __FUNCTION__, __LINE__);
+
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',getMemberId()=' . getMemberId() . ',SQL_AFFECTEDROWS()=' . SQL_AFFECTEDROWS() . ' - EXIT!');
 }
 
 // Pay points to the user and remove it from the sender if userid is given else it is a "sponsored surf"
 function SURFBAR_PAY_POINTS () {
        // Remove it from the URL owner
 }
 
 // Pay points to the user and remove it from the sender if userid is given else it is a "sponsored surf"
 function SURFBAR_PAY_POINTS () {
        // Remove it from the URL owner
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.SURFBAR_GET_USERID().',costs='.SURFBAR_GET_COSTS().'', false);
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.SURFBAR_GET_USERID().',costs='.SURFBAR_GET_COSTS() . ' - ENTERED!');
        if (isValidUserId(SURFBAR_GET_USERID())) {
                subtractPoints(sprintf("surfbar_%s", getSurfbarPaymentModel()), SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
        } // END - if
 
        if (isValidUserId(SURFBAR_GET_USERID())) {
                subtractPoints(sprintf("surfbar_%s", getSurfbarPaymentModel()), SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
        } // END - if
 
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.getMemberId().',reward='.SURFBAR_GET_REWARD().'', false);
-       // @TODO Try to rewrite the following unset()
-       unset($GLOBALS['ref_level']);
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.getMemberId().',reward='.SURFBAR_GET_REWARD());
+       // Init referal system here
+       initReferalSystem();
 
        // Book it to the user
        addPointsThroughReferalSystem(sprintf("surfbar_%s", getSurfbarPaymentModel()), getMemberId(), SURFBAR_GET_REWARD());
 
        // Book it to the user
        addPointsThroughReferalSystem(sprintf("surfbar_%s", getSurfbarPaymentModel()), getMemberId(), SURFBAR_GET_REWARD());
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.SURFBAR_GET_USERID().',costs='.SURFBAR_GET_COSTS() . ' - EXIT!');
 }
 
 // Updates the statistics of current URL/userid
 }
 
 // Updates the statistics of current URL/userid
@@ -1150,12 +1144,18 @@ function SURFBAR_UPDATE_INSERT_STATS_RECORD () {
 
 // Update the salt for validation and statistics
 function SURFBAR_UPDATE_SALT_STATS () {
 
 // Update the salt for validation and statistics
 function SURFBAR_UPDATE_SALT_STATS () {
-       // Update statistics record
-       SURFBAR_UPDATE_INSERT_STATS_RECORD();
-
        // Update salt
        SURFBAR_GENERATE_VALIDATION_CODE(SURFBAR_GET_ID());
 
        // Update salt
        SURFBAR_GENERATE_VALIDATION_CODE(SURFBAR_GET_ID());
 
+       // Make sure only valid salts can pass
+       if (SURFBAR_GET_SALT() == 'INVALID') {
+               // Invalid provided
+               debug_report_bug(__FUNCTION__, __LINE__, 'Invalid salt provided, id=' . SURFBAR_GET_ID() . ',getMemberId()=' . getMemberId());
+       } // END - if
+
+       // Update statistics record
+       SURFBAR_UPDATE_INSERT_STATS_RECORD();
+
        // Simply store the salt from cache away in database...
        SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_salts` SET `salts_last_salt`='%s' WHERE `salts_url_id`=%s AND `salts_userid`=%s LIMIT 1",
                array(
        // Simply store the salt from cache away in database...
        SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_salts` SET `salts_last_salt`='%s' WHERE `salts_url_id`=%s AND `salts_userid`=%s LIMIT 1",
                array(
@@ -1165,17 +1165,21 @@ function SURFBAR_UPDATE_SALT_STATS () {
                ), __FUNCTION__, __LINE__);
 
        // Debug message
                ), __FUNCTION__, __LINE__);
 
        // Debug message
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'salt='.SURFBAR_GET_SALT().',id='.SURFBAR_GET_ID().',userid='.getMemberId().'', false);
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'salt=' . SURFBAR_GET_SALT() . ',id=' . SURFBAR_GET_ID() . ',userid=' . getMemberId() . ',SQL_AFFECTEDROWS()=' . SQL_AFFECTEDROWS() . ' - UPDATE!');
 
        // Was that okay?
        if (SQL_HASZEROAFFECTED()) {
                // Insert missing entry!
                SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_salts` (`salts_url_id`, `salts_userid`, `salts_last_salt`) VALUES (%s, %s, '%s')",
 
        // Was that okay?
        if (SQL_HASZEROAFFECTED()) {
                // Insert missing entry!
                SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_salts` (`salts_url_id`, `salts_userid`, `salts_last_salt`) VALUES (%s, %s, '%s')",
-                       array(SURFBAR_GET_ID(), getMemberId(), SURFBAR_GET_SALT()), __FUNCTION__, __LINE__);
+                       array(
+                               SURFBAR_GET_ID(),
+                               getMemberId(),
+                               SURFBAR_GET_SALT()
+                       ), __FUNCTION__, __LINE__);
        } // END - if
 
        // Debug message
        } // END - if
 
        // Debug message
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'affectedRows='.SQL_AFFECTEDROWS().'', false);
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'affectedRows=' . SQL_AFFECTEDROWS() . ' - EXIT!');
 
        // Return if the update was okay
        return (!SQL_HASZEROAFFECTED());
 
        // Return if the update was okay
        return (!SQL_HASZEROAFFECTED());
@@ -1183,7 +1187,7 @@ function SURFBAR_UPDATE_SALT_STATS () {
 
 // Check if the reload lock is active for given id
 function SURFBAR_CHECK_RELOAD_LOCK ($urlId) {
 
 // Check if the reload lock is active for given id
 function SURFBAR_CHECK_RELOAD_LOCK ($urlId) {
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $urlId . '', false);
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $urlId . ' -  ENTERED!');
        // Ask the database
        $result = SQL_QUERY_ESC("SELECT COUNT(`locks_id`) AS cnt
 FROM
        // Ask the database
        $result = SQL_QUERY_ESC("SELECT COUNT(`locks_id`) AS cnt
 FROM
@@ -1205,7 +1209,7 @@ LIMIT 1",
        SQL_FREERESULT($result);
 
        // Return check
        SQL_FREERESULT($result);
 
        // Return check
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'cnt=' . $count . ',' . SURFBAR_GET_SURF_LOCK() . '', false);
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',count=' . $count . ',SURFBAR_GET_SURF_LOCK()=' . SURFBAR_GET_SURF_LOCK() . ' - EXIT!');
        return ($count == 1);
 }
 
        return ($count == 1);
 }
 
@@ -1265,12 +1269,12 @@ ORDER BY
        while ($content = SQL_FETCHARRAY($result)) {
                // Get total points
                $points = getTotalPoints($content['url_userid']);
        while ($content = SQL_FETCHARRAY($result)) {
                // Get total points
                $points = getTotalPoints($content['url_userid']);
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $content['url_userid'] . ',points=' . $points);
+               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $content['url_userid'] . ',points=' . $points);
 
                // Shall we add this to ignore?
                if ($points <= $limit) {
                        // Ignore this one!
 
                // Shall we add this to ignore?
                if ($points <= $limit) {
                        // Ignore this one!
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $content['url_userid'] . ' has depleted points amount!');
+                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $content['url_userid'] . ' has depleted points amount!');
                        $userids['url_userid'][$content['url_userid']] = $content['url_userid'];
                        $userids['points'][$content['url_userid']]     = $points;
                        $userids['notified'][$content['url_userid']]   = $content['notified'];
                        $userids['url_userid'][$content['url_userid']] = $content['url_userid'];
                        $userids['points'][$content['url_userid']]     = $points;
                        $userids['notified'][$content['url_userid']]   = $content['notified'];
@@ -1281,7 +1285,7 @@ ORDER BY
        SQL_FREERESULT($result);
 
        // Debug message
        SQL_FREERESULT($result);
 
        // Debug message
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'UIDs::count=' . count($userids) . ' (with own userid=' . getMemberId() . ')');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'UIDs::count=' . count($userids) . ' (with own userid=' . getMemberId() . ')');
 
        // Return result
        return $userids;
 
        // Return result
        return $userids;
@@ -1335,7 +1339,7 @@ function SURFBAR_DETERMINE_WAIT_TIME () {
 
 // Changes the status of an URL from given to other
 function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array()) {
 
 // Changes the status of an URL from given to other
 function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array()) {
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',prevStatus=' . $prevStatus . ',newStatus=' . $newStatus . ' - ENTERED!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',prevStatus=' . $prevStatus . ',newStatus=' . $newStatus . ' - ENTERED!');
        // Make new status always lower-case
        $newStatus = strtolower($newStatus);
 
        // Make new status always lower-case
        $newStatus = strtolower($newStatus);
 
@@ -1387,7 +1391,7 @@ function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array())
        $data = $filterData['data'];
 
        // All done!
        $data = $filterData['data'];
 
        // All done!
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',prevStatus=' . $prevStatus . ',newStatus=' . $newStatus . ' - EXIT!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',prevStatus=' . $prevStatus . ',newStatus=' . $newStatus . ' - EXIT!');
        return true;
 }
 
        return true;
 }
 
@@ -1475,7 +1479,10 @@ function SURFBAR_GET_LOCK_IDS () {
        $ignored = array();
 
        // Get all id from locks within the timestamp
        $ignored = array();
 
        // Get all id from locks within the timestamp
-       $result = SQL_QUERY_ESC("SELECT `locks_id`, `locks_url_id`, UNIX_TIMESTAMP(`locks_last_surfed`) AS last_surfed
+       $result = SQL_QUERY_ESC("SELECT
+       `locks_id`,
+       `locks_url_id`,
+       UNIX_TIMESTAMP(`locks_last_surfed`) AS `last_surfed`
 FROM
        `{?_MYSQL_PREFIX?}_surfbar_locks`
 WHERE
 FROM
        `{?_MYSQL_PREFIX?}_surfbar_locks`
 WHERE
@@ -1487,30 +1494,30 @@ ORDER BY
        // Load all entries
        while ($content = SQL_FETCHARRAY($result)) {
                // Debug message
        // Load all entries
        while ($content = SQL_FETCHARRAY($result)) {
                // Debug message
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'next - lid='.$content['id'].',url='.$content['url_id'].',rest='.(time() - $content['last_surfed']).'/'.SURFBAR_GET_SURF_LOCK().'', false);
+               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'next - lid='.$content['locks_id'].',url='.$content['locks_url_id'].',rest='.(time() - $content['last_surfed']).'/'.SURFBAR_GET_SURF_LOCK());
 
                // Skip entries that are too old
 
                // Skip entries that are too old
-               if (($content['last_surfed'] > (time() - SURFBAR_GET_SURF_LOCK())) && (!in_array($content['url_id'], $ignored))) {
+               if (($content['last_surfed'] > (time() - SURFBAR_GET_SURF_LOCK())) && (!in_array($content['locks_url_id'], $ignored))) {
                        // Debug message
                        // Debug message
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'okay - lid='.$content['id'].',url='.$content['url_id'].',last='.$content['last_surfed'].'', false);
+                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'okay - lid='.$content['locks_id'].',url='.$content['locks_url_id'].',last='.$content['last_surfed']);
 
                        // Add only if missing or bigger
 
                        // Add only if missing or bigger
-                       if ((!isset($IDs[$content['url_id']])) || ($IDs[$content['url_id']] > $content['last_surfed'])) {
+                       if ((!isset($IDs[$content['locks_url_id']])) || ($IDs[$content['locks_url_id']] > $content['last_surfed'])) {
                                // Debug message
                                // Debug message
-                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ADD - lid='.$content['id'].',url='.$content['url_id'].',last='.$content['last_surfed'].'', false);
+                               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ADD - lid='.$content['locks_id'].',url='.$content['locks_url_id'].',last='.$content['last_surfed']);
 
                                // Add this id
 
                                // Add this id
-                               $IDs[$content['url_id']] = $content['last_surfed'];
-                               $USE[$content['url_id']] = $content['id'];
+                               $IDs[$content['locks_url_id']] = $content['last_surfed'];
+                               $USE[$content['locks_url_id']] = $content['locks_id'];
                        } // END - if
                } else {
                        // Debug message
                        } // END - if
                } else {
                        // Debug message
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ignore - lid='.$content['id'].',url='.$content['url_id'].',last='.$content['last_surfed'].'', false);
+                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ignore - lid='.$content['locks_id'].',url='.$content['locks_url_id'].',last='.$content['last_surfed']);
 
                        // Ignore these old entries!
 
                        // Ignore these old entries!
-                       $ignored[] = $content['url_id'];
-                       unset($IDs[$content['url_id']]);
-                       unset($USE[$content['url_id']]);
+                       $ignored[] = $content['locks_url_id'];
+                       unset($IDs[$content['locks_url_id']]);
+                       unset($USE[$content['locks_url_id']]);
                }
        } // END - while
 
                }
        } // END - while
 
@@ -1545,7 +1552,7 @@ GROUP BY
        sbu.url_id ASC", __FUNCTION__, __LINE__);
 
        // Log last query
        sbu.url_id ASC", __FUNCTION__, __LINE__);
 
        // Log last query
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'lastQuery='.getConfig('db_last_query').'|numRows='.SQL_NUMROWS($result).'|Affected='.SQL_AFFECTEDROWS().'', false);
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'lastQuery='.getConfig('db_last_query').'|numRows='.SQL_NUMROWS($result).'|Affected='.SQL_AFFECTEDROWS());
 
        // Fetch max rand
        $maxRand = SQL_NUMROWS($result);
 
        // Fetch max rand
        $maxRand = SQL_NUMROWS($result);
@@ -1627,6 +1634,7 @@ function SURFBAR_GET_ARRAY_FROM_STATUS ($status) {
 // Reload to configured stop page
 function SURFBAR_RELOAD_TO_STOP_PAGE ($page = 'stop') {
        // Internal or external?
 // Reload to configured stop page
 function SURFBAR_RELOAD_TO_STOP_PAGE ($page = 'stop') {
        // Internal or external?
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'page=' . $page . ' - ENTERED!');
        if ((getConfig('surfbar_pause_mode') == 'INTERNAL') || (getConfig('surfbar_pause_url') == '')) {
                // Reload to internal page
                redirectToUrl('surfbar.php?frame=' . $page);
        if ((getConfig('surfbar_pause_mode') == 'INTERNAL') || (getConfig('surfbar_pause_url') == '')) {
                // Reload to internal page
                redirectToUrl('surfbar.php?frame=' . $page);
@@ -1639,6 +1647,7 @@ function SURFBAR_RELOAD_TO_STOP_PAGE ($page = 'stop') {
 // Determine next id for surfbar or get data for given id, always call this before you call other
 // getters below this function!
 function SURFBAR_DETERMINE_NEXT_ID ($urlId = '0') {
 // Determine next id for surfbar or get data for given id, always call this before you call other
 // getters below this function!
 function SURFBAR_DETERMINE_NEXT_ID ($urlId = '0') {
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ' - ENTERED!');
        // Default is no id and no random number
        $nextId = '0';
        $randNum = '0';
        // Default is no id and no random number
        $nextId = '0';
        $randNum = '0';
@@ -1675,7 +1684,7 @@ function SURFBAR_DETERMINE_NEXT_ID ($urlId = '0') {
                } // END - if
 
                // And query the database
                } // END - if
 
                // And query the database
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'randNum='.$randNum.',maxRand='.$maxRand.',surfLock='.SURFBAR_GET_SURF_LOCK().'', false);
+               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'randNum='.$randNum.',maxRand='.$maxRand.',surfLock='.SURFBAR_GET_SURF_LOCK());
                $result = SQL_QUERY_ESC("SELECT
        sbu.url_id,
        sbu.url_userid,
                $result = SQL_QUERY_ESC("SELECT
        sbu.url_id,
        sbu.url_userid,
@@ -1742,12 +1751,12 @@ LIMIT 1",
        }
 
        // Is there an id number?
        }
 
        // Is there an id number?
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'lastQuery='.getConfig('db_last_query').'|numRows='.SQL_NUMROWS($result).'|Affected='.SQL_AFFECTEDROWS().'', false);
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'lastQuery='.getConfig('db_last_query').'|numRows='.SQL_NUMROWS($result).'|Affected='.SQL_AFFECTEDROWS());
        if (SQL_NUMROWS($result) == 1) {
                // Load/cache data
        if (SQL_NUMROWS($result) == 1) {
                // Load/cache data
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count('.count($GLOBALS['surfbar_cache']).') - BEFORE', false);
+               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count('.count($GLOBALS['surfbar_cache']).') - BEFORE', false);
                $GLOBALS['surfbar_cache'] = merge_array($GLOBALS['surfbar_cache'], SQL_FETCHARRAY($result));
                $GLOBALS['surfbar_cache'] = merge_array($GLOBALS['surfbar_cache'], SQL_FETCHARRAY($result));
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count('.count($GLOBALS['surfbar_cache']).') - AFTER', false);
+               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count('.count($GLOBALS['surfbar_cache']).') - AFTER', false);
 
                // Determine waiting time
                $GLOBALS['surfbar_cache']['time'] = SURFBAR_DETERMINE_WAIT_TIME();
 
                // Determine waiting time
                $GLOBALS['surfbar_cache']['time'] = SURFBAR_DETERMINE_WAIT_TIME();
@@ -1755,28 +1764,28 @@ LIMIT 1",
                // Is the last salt there?
                if (is_null($GLOBALS['surfbar_cache']['salts_last_salt'])) {
                        // Then repair it wit the static!
                // Is the last salt there?
                if (is_null($GLOBALS['surfbar_cache']['salts_last_salt'])) {
                        // Then repair it wit the static!
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'last_salt - FIXED!', false);
+                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'last_salt - FIXED!', false);
                        $GLOBALS['surfbar_cache']['salts_last_salt'] = '';
                } // END - if
 
                // Fix missing last_surfed
                if ((!isset($GLOBALS['surfbar_cache']['last_surfed'])) || (is_null($GLOBALS['surfbar_cache']['last_surfed']))) {
                        // Fix it here
                        $GLOBALS['surfbar_cache']['salts_last_salt'] = '';
                } // END - if
 
                // Fix missing last_surfed
                if ((!isset($GLOBALS['surfbar_cache']['last_surfed'])) || (is_null($GLOBALS['surfbar_cache']['last_surfed']))) {
                        // Fix it here
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'last_surfed - FIXED!', false);
+                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'last_surfed - FIXED!', false);
                        $GLOBALS['surfbar_cache']['last_surfed'] = '0';
                } // END - if
 
                // Get base/fixed reward and costs
                $GLOBALS['surfbar_cache']['reward'] = SURFBAR_DETERMINE_REWARD();
                $GLOBALS['surfbar_cache']['costs']  = SURFBAR_DETERMINE_COSTS();
                        $GLOBALS['surfbar_cache']['last_surfed'] = '0';
                } // END - if
 
                // Get base/fixed reward and costs
                $GLOBALS['surfbar_cache']['reward'] = SURFBAR_DETERMINE_REWARD();
                $GLOBALS['surfbar_cache']['costs']  = SURFBAR_DETERMINE_COSTS();
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'BASE/STATIC - reward='.SURFBAR_GET_REWARD().'|costs='.SURFBAR_GET_COSTS().'', false);
+               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'BASE/STATIC - reward='.SURFBAR_GET_REWARD().'|costs='.SURFBAR_GET_COSTS());
 
                // Only in dynamic model add the dynamic bonus!
                if (getSurfbarPaymentModel() == 'DYNAMIC') {
                        // Calculate dynamic reward/costs and add it
                        $GLOBALS['surfbar_cache']['reward'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
                        $GLOBALS['surfbar_cache']['costs']  += SURFBAR_CALCULATE_DYNAMIC_ADD();
 
                // Only in dynamic model add the dynamic bonus!
                if (getSurfbarPaymentModel() == 'DYNAMIC') {
                        // Calculate dynamic reward/costs and add it
                        $GLOBALS['surfbar_cache']['reward'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
                        $GLOBALS['surfbar_cache']['costs']  += SURFBAR_CALCULATE_DYNAMIC_ADD();
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'DYNAMIC+ - reward='.SURFBAR_GET_REWARD().'|costs='.SURFBAR_GET_COSTS().'', false);
+                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'DYNAMIC+ - reward='.SURFBAR_GET_REWARD().'|costs='.SURFBAR_GET_COSTS());
                } // END - if
 
                // Now get the id
                } // END - if
 
                // Now get the id
@@ -1787,7 +1796,7 @@ LIMIT 1",
        SQL_FREERESULT($result);
 
        // Return result
        SQL_FREERESULT($result);
 
        // Return result
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'nextId='.$nextId.'', false);
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',nextId=' . $nextId . ' - EXIT!');
        return $nextId;
 }
 
        return $nextId;
 }
 
@@ -1868,7 +1877,7 @@ function SURFBAR_INIT () {
 
 // Private getter for data elements
 function SURFBAR_GET_DATA ($element) {
 
 // Private getter for data elements
 function SURFBAR_GET_DATA ($element) {
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ' - CALLED!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ' - ENTERED!');
 
        // Default is null
        $data = null;
 
        // Default is null
        $data = null;
@@ -1885,7 +1894,7 @@ function SURFBAR_GET_DATA ($element) {
        }
 
        // Return result
        }
 
        // Return result
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element[' . $element . ']=[' . gettype($data) . ']' . $data . ' - EXIT!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element[' . $element . ']=[' . gettype($data) . ']' . $data . ' - EXIT!');
        return $data;
 }
 
        return $data;
 }
 
@@ -1967,5 +1976,11 @@ function SURFBAR_GET_NEW_STATUS () {
        return SURFBAR_GET_DATA('new_status');
 }
 
        return SURFBAR_GET_DATA('new_status');
 }
 
+// Getter for last salt
+function SURFBAR_GET_LAST_SALT () {
+       // Get data element and return its contents
+       return SURFBAR_GET_DATA('salts_last_salt');
+}
+
 // [EOF]
 ?>
 // [EOF]
 ?>
index 18b0cd64c4c4682440ed318348a88aedaa7fbed9..09dc679ba2d9201bb24deaa50931e1839af08001 100644 (file)
@@ -43,8 +43,8 @@ if (!defined('__SECURITY')) {
 // Add links for selecting some users
 function alpha ($sortby, $colspan, $return=false) {
        if (!isGetRequestParameterSet('offset')) setGetRequestParameter('offset', 0);
 // Add links for selecting some users
 function alpha ($sortby, $colspan, $return=false) {
        if (!isGetRequestParameterSet('offset')) setGetRequestParameter('offset', 0);
-       $add = '&amp;page='.getRequestParameter('page').'&amp;offset='.getRequestParameter('offset');
-       if (isGetRequestParameterSet('mode')) $add .= '&amp;mode='.getRequestParameter('mode');
+       $add = '&amp;page=' . getRequestParameter('page').'&amp;offset=' . getRequestParameter('offset');
+       if (isGetRequestParameterSet('mode')) $add .= '&amp;mode=' . getRequestParameter('mode');
 
        /* Creates the list of letters and makes them a link. */
        $alphabet = explode(',', 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,');
 
        /* Creates the list of letters and makes them a link. */
        $alphabet = explode(',', 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,');
@@ -588,7 +588,6 @@ function doConfirmUserAccount ($hash) {
        `{?_MYSQL_PREFIX?}_user_data`
 SET
        `status`='CONFIRMED',
        `{?_MYSQL_PREFIX?}_user_data`
 SET
        `status`='CONFIRMED',
-       `ref_payout`={?ref_payout?},
        `user_hash`=NULL
 WHERE
        `user_hash`='%s' AND
        `user_hash`=NULL
 WHERE
        `user_hash`='%s' AND
@@ -622,8 +621,7 @@ LIMIT 1",
                                        } // END - if
 
                                        // Add one-time referal bonus over referal system or directly
                                        } // END - if
 
                                        // Add one-time referal bonus over referal system or directly
-                                       // @TODO Try to rewrite the following unset()
-                                       unset($GLOBALS['ref_level']);
+                                       initReferalSystem();
                                        addPointsThroughReferalSystem('referal_bonus', $refid, getPointsRef(), true, bigintval($userid), getConfig('reg_points_mode'));
                                } // END - if
                        } // END - if
                                        addPointsThroughReferalSystem('referal_bonus', $refid, getPointsRef(), true, bigintval($userid), getConfig('reg_points_mode'));
                                } // END - if
                        } // END - if
index d762abd90d9b40b1784ce5b55ec335d2628b67b7..f8017ebbef57b183ebe1e64e96abb1e0e2f7df73 100644 (file)
@@ -787,6 +787,15 @@ function sendAdminBuildMails ($mode, $table, $content, $id, $subjectPart = '', $
 
 // Build a special template list
 function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $userid = 'userid') {
 
 // Build a special template list
 function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $userid = 'userid') {
+       // $table and $idColumn must bove be arrays!
+       if (!is_array($table)) {
+               // $table is no array
+               debug_report_bug(__FUNCTION__, __LINE__, 'table[]=' . gettype($table) . '!=array');
+       } elseif (!is_array($idColumn)) {
+               // $idColumn is no array
+               debug_report_bug(__FUNCTION__, __LINE__, 'idColumn[]=' . gettype($idColumn) . '!=array');
+       }
+
        $OUT = '';
 
        // "Walk" through all entries
        $OUT = '';
 
        // "Walk" through all entries
@@ -795,7 +804,7 @@ function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions,
                $id = bigintval($id);
 
                // Get result from a given column array and table name
                $id = bigintval($id);
 
                // Get result from a given column array and table name
-               $result = SQL_RESULT_FROM_ARRAY($table, $columns, $idColumn, $id, __FUNCTION__, __LINE__);
+               $result = SQL_RESULT_FROM_ARRAY($table[0], $columns, $idColumn[0], $id, __FUNCTION__, __LINE__);
 
                // Is there one entry?
                if (SQL_NUMROWS($result) == 1) {
 
                // Is there one entry?
                if (SQL_NUMROWS($result) == 1) {
@@ -833,7 +842,7 @@ function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions,
                        // Then list it
                        $OUT .= loadTemplate(sprintf("admin_%s_%s_row",
                                $listType,
                        // Then list it
                        $OUT .= loadTemplate(sprintf("admin_%s_%s_row",
                                $listType,
-                               $table
+                               $table[0]
                                ), true, $content
                        );
                } // END - if
                                ), true, $content
                        );
                } // END - if
@@ -845,7 +854,7 @@ function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions,
        // Load master template
        loadTemplate(sprintf("admin_%s_%s",
                $listType,
        // Load master template
        loadTemplate(sprintf("admin_%s_%s",
                $listType,
-               $table
+               $table[0]
                ), false, $OUT
        );
 }
                ), false, $OUT
        );
 }
index 5016b33538277b60463ec1050c2c8fcaaffae595..5ea1ecd0ab06fee1c085484e588808b685035af7 100644 (file)
@@ -70,7 +70,7 @@ if ((isFormSent()) && (isRegistrationDataComplete())) {
                        registerOutputFailedMessage('ENTER_EMAIL');
                        setPostRequestParameter('email', '');
                } elseif (postRequestParameter('email') == '?') {
                        registerOutputFailedMessage('ENTER_EMAIL');
                        setPostRequestParameter('email', '');
                } elseif (postRequestParameter('email') == '?') {
-                       registerOutputFailedMessage('GUEST_EMAIL_ALREADY_DB');
+                       registerOutputFailedMessage('GUEST_EMAIL_IS_ALREADY_REGISTERED');
                        setPostRequestParameter('email', '');
                }
 
                        setPostRequestParameter('email', '');
                }
 
index afed52db34fe7b0d169cc70be00ff33f03a5f30a..177da67eb57a0f78f35cc46720a4d8c639d89caf 100644 (file)
@@ -1024,6 +1024,13 @@ function getReferalLevelPercents ($level) {
        return $data['percents'];
 }
 
        return $data['percents'];
 }
 
+// Initializes the referal system
+function initReferalSystem () {
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ' Referal system initialized!');
+       $GLOBALS['ref_level']  = NULL;
+       $GLOBALS['ref_system'] = true;
+}
+
 /**
  *
  * Dynamic referal and points system, can also send mails!
 /**
  *
  * Dynamic referal and points system, can also send mails!
@@ -1038,7 +1045,7 @@ function getReferalLevelPercents ($level) {
  *               for default value will cause no referal will get points ever!!!)
  */
 function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify = false, $refid = '0', $addMode = 'REFERAL') {
  *               for default value will cause no referal will get points ever!!!)
  */
 function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify = false, $refid = '0', $addMode = 'REFERAL') {
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',userid=' . $userid . ',points=' . $points . ',sendNotify=' . intval($sendNotify) . ',refid=' . $refid . ',addMode=' . $addMode . ' - ENTERED!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',userid=' . $userid . ',points=' . $points . ',sendNotify=' . intval($sendNotify) . ',refid=' . $refid . ',addMode=' . $addMode . ' - ENTERED!');
        // By default nothing has been added
        $added = false;
 
        // By default nothing has been added
        $added = false;
 
@@ -1046,24 +1053,13 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
        $addMode = strtoupper($addMode);
 
        // When $userid = '0' add points to jackpot
        $addMode = strtoupper($addMode);
 
        // When $userid = '0' add points to jackpot
-       if (($userid == '0') && (isExtensionActive('jackpot'))) {
-               // Add points to jackpot
+       if (($userid == '0') && ($addMode == 'DIRECT') && (isExtensionActive('jackpot'))) {
+               // Add points to jackpot only in DIRECT mode
                return addPointsToJackpot($points);
        } // END - if
 
                return addPointsToJackpot($points);
        } // END - if
 
-       // Count up referal depth
-       if (!isset($GLOBALS['ref_level'])) {
-               // Initialialize referal system
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ' Referal system initialized!');
-               $GLOBALS['ref_level'] = NULL;
-       } else {
-               // Increase referal level
-               $GLOBALS['ref_level']++;
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ' Referal level increased. DEPTH='.$GLOBALS['ref_level']);
-       }
-
        // Check user account
        // Check user account
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',points='.$points);
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',points='.$points);
        if (fetchUserData($userid)) {
                // Determine wether the user has some mails to click before he/she gets the points
                $locked = ifUserPointsLocked($userid);
        if (fetchUserData($userid)) {
                // Determine wether the user has some mails to click before he/she gets the points
                $locked = ifUserPointsLocked($userid);
@@ -1076,31 +1072,43 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
 
                // Get percents
                $per = getReferalLevelPercents($GLOBALS['ref_level']);
 
                // Get percents
                $per = getReferalLevelPercents($GLOBALS['ref_level']);
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',points='.$points.',depth='.$GLOBALS['ref_level'].',per='.$per.',mode='.$addMode);
+               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',points='.$points.',depth='.$GLOBALS['ref_level'].',per='.$per.',mode='.$addMode);
 
                // Some percents found?
                if ($per > 0) {
                        // Calculate new points
 
                // Some percents found?
                if ($per > 0) {
                        // Calculate new points
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',points='.$points.',per='.$per.',depth='.$GLOBALS['ref_level']);
                        $ref_points = $points * $per / 100;
                        $ref_points = $points * $per / 100;
+                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',points='.$points.',per='.$per.',depth='.$GLOBALS['ref_level'].',ref_points='.$ref_points);
 
                        // Pay refback here if level > 0 and in ref-mode
                        if ((isExtensionActive('refback')) && ($GLOBALS['ref_level'] > 0) && ($per < 100) && ($addMode == 'REFERAL') && (isset($GLOBALS['cache_array']['add_userid'][$userid]))) {
 
                        // Pay refback here if level > 0 and in ref-mode
                        if ((isExtensionActive('refback')) && ($GLOBALS['ref_level'] > 0) && ($per < 100) && ($addMode == 'REFERAL') && (isset($GLOBALS['cache_array']['add_userid'][$userid]))) {
-                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',data='.$GLOBALS['cache_array']['add_userid'][$userid].',ref_points='.$ref_points.',depth='.$GLOBALS['ref_level'].' - BEFORE!');
+                               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',data='.$GLOBALS['cache_array']['add_userid'][$userid].',ref_points='.$ref_points.',depth='.$GLOBALS['ref_level'].' - BEFORE!');
                                $ref_points = addRefbackPoints($GLOBALS['cache_array']['add_userid'][$userid], $userid, $points, $ref_points);
                                $ref_points = addRefbackPoints($GLOBALS['cache_array']['add_userid'][$userid], $userid, $points, $ref_points);
-                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',data='.$GLOBALS['cache_array']['add_userid'][$userid].',ref_points='.$ref_points.',depth='.$GLOBALS['ref_level'].' - AFTER!');
+                               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',data='.$GLOBALS['cache_array']['add_userid'][$userid].',ref_points='.$ref_points.',depth='.$GLOBALS['ref_level'].' - AFTER!');
                        } // END - if
 
                        // Update points...
                        } // END - if
 
                        // Update points...
-                       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `%s`=`%s`+%s WHERE `userid`=%s AND `ref_depth`=%s LIMIT 1",
-                               array(
-                                       $pointsColumn,
-                                       $pointsColumn,
-                                       $ref_points,
-                                       bigintval($userid),
-                                       makeZeroToNull($GLOBALS['ref_level'])
-                               ), __FUNCTION__, __LINE__);
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'pointsColumn='.$pointsColumn.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$addMode.' - UPDATE! ('.SQL_AFFECTEDROWS().')');
+                       if (is_null($GLOBALS['ref_level'])) {
+                               // Level NULL (self)
+                               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `%s`=`%s`+%s WHERE `userid`=%s AND `ref_depth` IS NULL LIMIT 1",
+                                       array(
+                                               $pointsColumn,
+                                               $pointsColumn,
+                                               $ref_points,
+                                               bigintval($userid)
+                                       ), __FUNCTION__, __LINE__);
+                       } else {
+                               // Level 1+
+                               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `%s`=`%s`+%s WHERE `userid`=%s AND `ref_depth`=%s LIMIT 1",
+                                       array(
+                                               $pointsColumn,
+                                               $pointsColumn,
+                                               $ref_points,
+                                               bigintval($userid),
+                                               bigintval($GLOBALS['ref_level'])
+                                       ), __FUNCTION__, __LINE__);
+                       }
+                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'pointsColumn='.$pointsColumn.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$addMode.' - UPDATE! ('.SQL_AFFECTEDROWS().')');
 
                        // No entry updated?
                        if (SQL_HASZEROAFFECTED()) {
 
                        // No entry updated?
                        if (SQL_HASZEROAFFECTED()) {
@@ -1112,12 +1120,12 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
                                                makeZeroToNull($GLOBALS['ref_level']),
                                                $ref_points
                                        ), __FUNCTION__, __LINE__);
                                                makeZeroToNull($GLOBALS['ref_level']),
                                                $ref_points
                                        ), __FUNCTION__, __LINE__);
-                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'data='.$pointsColumn.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$addMode.' - INSERTED! ('.SQL_AFFECTEDROWS().')');
+                               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'data='.$pointsColumn.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$addMode.' - INSERTED! ('.SQL_AFFECTEDROWS().')');
                        } // END - if
 
                        // Check affected rows
                        $added = SQL_AFFECTEDROWS();
                        } // END - if
 
                        // Check affected rows
                        $added = SQL_AFFECTEDROWS();
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added='.intval($added));
+                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added='.intval($added));
 
                        // Prepare data for the filter
                        $filterData = array(
 
                        // Prepare data for the filter
                        $filterData = array(
@@ -1139,7 +1147,7 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
 
                        // Extract $added
                        $added = $filterData['added'];
 
                        // Extract $added
                        $added = $filterData['added'];
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added='.intval($added));
+                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added='.intval($added));
 
                        // Points updated, maybe I shall send him an email?
                        if (($sendNotify === true) && (isValidUserId(getUserData('refid'))) && ($locked === false)) {
 
                        // Points updated, maybe I shall send him an email?
                        if (($sendNotify === true) && (isValidUserId(getUserData('refid'))) && ($locked === false)) {
@@ -1173,42 +1181,51 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
                                } // END - if
                        }
 
                                } // END - if
                        }
 
+                       // Increase referal level
+                       $GLOBALS['ref_level']++;
+                       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ' Referal level increased, ref_level=' . $GLOBALS['ref_level']);
+
                        // Maybe there's another ref?
                        if ((isValidUserId(getUserData('refid'))) && ($points > 0) && (getUserData('refid') != $userid) && ($addMode == 'REFERAL')) {
                                // Then let's credit him here...
                        // Maybe there's another ref?
                        if ((isValidUserId(getUserData('refid'))) && ($points > 0) && (getUserData('refid') != $userid) && ($addMode == 'REFERAL')) {
                                // Then let's credit him here...
-                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',ref='.getUserData('refid').',points='.$points.' - ADVANCE!');
+                               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . getUserData('refid') . ',points=' . $points . ',ref_points=' . $ref_points . ' - ADVANCE!');
                                $added = ($added && addPointsThroughReferalSystem(sprintf("%s_ref:%s", $subject, $GLOBALS['ref_level']), getUserData('refid'), $points, $sendNotify, getUserData('refid')));
                        } // END - if
                } // END - if
        } // END - if
 
                                $added = ($added && addPointsThroughReferalSystem(sprintf("%s_ref:%s", $subject, $GLOBALS['ref_level']), getUserData('refid'), $points, $sendNotify, getUserData('refid')));
                        } // END - if
                } // END - if
        } // END - if
 
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',userid=' . $userid . ',points=' . $points . ',sendNotify=' . intval($sendNotify) . ',refid=' . $refid . ',addMode=' . $addMode . ' - EXIT!');
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',userid=' . $userid . ',points=' . $points . ',sendNotify=' . intval($sendNotify) . ',refid=' . $refid . ',addMode=' . $addMode . ' - EXIT!');
        return $added;
 }
 
 // Updates the referal counter
 function updateReferalCounter ($userid) {
        // Make it sure referal level zero (member him-/herself) is at least selected
        return $added;
 }
 
 // Updates the referal counter
 function updateReferalCounter ($userid) {
        // Make it sure referal level zero (member him-/herself) is at least selected
-       if (empty($GLOBALS['cache_array']['ref_level'][$userid])) $GLOBALS['cache_array']['ref_level'][$userid] = 1;
+       if (empty($GLOBALS['cache_array']['ref_level'][$userid])) {
+               $GLOBALS['cache_array']['ref_level'][$userid] = NULL;
+       } // END - if
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',level='.$GLOBALS['cache_array']['ref_level'][$userid]);
 
        // Update counter
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',level='.$GLOBALS['cache_array']['ref_level'][$userid]);
 
        // Update counter
-       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refsystem` SET `counter`=`counter`+1 WHERE `userid`=%s AND `level`=%s LIMIT 1",
-               array(
-                       bigintval($userid),
-                       bigintval($GLOBALS['cache_array']['ref_level'][$userid])
-               ), __FUNCTION__, __LINE__);
-
-       // When no entry was updated then we have to create it here
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'updated=' . SQL_AFFECTEDROWS());
-       if (SQL_HASZEROAFFECTED()) {
-               // First count!
-               SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_refsystem` (`userid`, `level`, `counter`) VALUES (%s,%s,1)",
+       if (!is_null($GLOBALS['cache_array']['ref_level'][$userid])) {
+               // Level is > 0
+               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refsystem` SET `counter`=`counter`+1 WHERE `userid`=%s AND `level`=%s LIMIT 1",
                        array(
                        array(
-                               bigintval($userid),
-                               $GLOBALS['cache_array']['ref_level'][$userid]
+                                       bigintval($userid),
+                               bigintval($GLOBALS['cache_array']['ref_level'][$userid])
                        ), __FUNCTION__, __LINE__);
                        ), __FUNCTION__, __LINE__);
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid);
+
+               // When no entry was updated then we have to create it here
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'updated=' . SQL_AFFECTEDROWS());
+               if (SQL_HASZEROAFFECTED()) {
+                       // First count!
+                       SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_refsystem` (`userid`, `level`, `counter`) VALUES (%s,%s,1)",
+                               array(
+                                       bigintval($userid),
+                                       makeZeroToNull($GLOBALS['cache_array']['ref_level'][$userid])
+                               ), __FUNCTION__, __LINE__);
+                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',SQL_AFFECTEDROWS()=' . SQL_AFFECTEDROWS());
+               } // END - if
        } // END - if
 
        // Init referal id
        } // END - if
 
        // Init referal id
@@ -1871,7 +1888,9 @@ function generateReceiverList ($categoryId, $receiver, $mode = '') {
                // Load all entries
                while ($content = SQL_FETCHARRAY($result)) {
                        // Add receiver when not empty
                // Load all entries
                while ($content = SQL_FETCHARRAY($result)) {
                        // Add receiver when not empty
-                       if (!empty($content['userid'])) $receiverList .= $content['userid'] . ';';
+                       if (!empty($content['userid'])) {
+                               $receiverList .= $content['userid'] . ';';
+                       } // END - if
                } // END - while
 
                // Free memory
                } // END - while
 
                // Free memory
index db267b113768e33b7e34ef9cd580f6a2b3e7226c..10e1240b1d6c25c9c4a29ada1be7d95a2a7e5fd7 100644 (file)
@@ -217,6 +217,9 @@ function doFinalCompilation ($code, $insertComments = true, $enableCodes = true)
        // Init counter
        $count = 0;
 
        // Init counter
        $count = 0;
 
+       // Compile the raw code
+       $code = compileRawCode($code);
+
        // Compile all out
        while (((strpos($code, '{--') !== false) || (strpos($code, '{DQUOTE}') !== false) || (strpos($code, '{?') !== false) || (strpos($code, '{%') !== false)) && ($count < 7)) {
                // Init common variables
        // Compile all out
        while (((strpos($code, '{--') !== false) || (strpos($code, '{DQUOTE}') !== false) || (strpos($code, '{?') !== false) || (strpos($code, '{%') !== false)) && ($count < 7)) {
                // Init common variables
@@ -1693,8 +1696,8 @@ function generateMetaDescriptionCode () {
                $GLOBALS['page_header'] .= '<meta name="description" content="' . $DESCR . '" />';
        } // END - if
 
                $GLOBALS['page_header'] .= '<meta name="description" content="' . $DESCR . '" />';
        } // END - if
 
-       // Remove depth
-       unset($GLOBALS['ref_level']);
+       // Initialize referal system
+       initReferalSystem();
 }
 
 // Generates an FQFN for template cache from the given template name
 }
 
 // Generates an FQFN for template cache from the given template name
index a89c49a676972c42d106c7e4548a8e29a71e84f3..16b10bcb27e074add2f15b8a3968cf2ff49694f4 100644 (file)
@@ -744,7 +744,7 @@ function isBlockModeEnabled () {
 // Wrapper function for addPointsThroughReferalSystem()
 function addPointsDirectly ($subject, $userid, $points) {
        // Reset level here
 // Wrapper function for addPointsThroughReferalSystem()
 function addPointsDirectly ($subject, $userid, $points) {
        // Reset level here
-       unset($GLOBALS['ref_level']);
+       initReferalSystem();
 
        // Call more complicated method (due to more parameters)
        return addPointsThroughReferalSystem($subject, $userid, $points, false, 0, 'DIRECT');
 
        // Call more complicated method (due to more parameters)
        return addPointsThroughReferalSystem($subject, $userid, $points, false, 0, 'DIRECT');
@@ -1052,6 +1052,7 @@ function isDebuggingTemplateCache () {
 
 // Wrapper for fetchUserData() and getUserData() calls
 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
 
 // Wrapper for fetchUserData() and getUserData() calls
 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!');
        // Is it cached?
        if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
                // Default is 'guest'
        // Is it cached?
        if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
                // Default is 'guest'
@@ -1068,6 +1069,7 @@ function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
        } // END - if
 
        // Return it
        } // END - if
 
        // Return it
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!');
        return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
 }
 
        return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
 }
 
@@ -2469,6 +2471,7 @@ function generateWrappedUserEmailLink ($email) {
 
 // Wrapper to check if user points are locked
 function ifUserPointsLocked ($userid) {
 
 // Wrapper to check if user points are locked
 function ifUserPointsLocked ($userid) {
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
        // Do we have cache?
        if (!isset($GLOBALS[__FUNCTION__][$userid])) {
                // Determine it
        // Do we have cache?
        if (!isset($GLOBALS[__FUNCTION__][$userid])) {
                // Determine it
@@ -2476,6 +2479,7 @@ function ifUserPointsLocked ($userid) {
        } // END - if
 
        // Return cache
        } // END - if
 
        // Return cache
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
        return $GLOBALS[__FUNCTION__][$userid];
 }
 
        return $GLOBALS[__FUNCTION__][$userid];
 }
 
index 2f04e4caeb8f6b28a1aeff0cfd810be59f03ec73..68aff4de92948c583697f3f60ea894872cdd6b20 100644 (file)
@@ -258,8 +258,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
                                                                                        array($userId), __FILE__, __LINE__);
 
                                                                                // Add points
                                                                                        array($userId), __FILE__, __LINE__);
 
                                                                                // Add points
-                                                                               // @TODO Try to rewrite the following unset()
-                                                                               unset($GLOBALS['ref_level']);
+                                                                               initReferalSystem();
                                                                                addPointsThroughReferalSystem('mailid_okay', $userId, $payment);
 
                                                                                // Shall I add bonus points for "turbo clickers" ?
                                                                                addPointsThroughReferalSystem('mailid_okay', $userId, $payment);
 
                                                                                // Shall I add bonus points for "turbo clickers" ?
index ae3fd6fd8c6bb60f5513bbd6ba705f7363846a48..8ad2c2af012473fd73719298e06bc00aa866b8fb 100644 (file)
@@ -163,6 +163,9 @@ if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isGetRequestParameterSet('frame')) && (in
                        // Then load waiting page
                        SURFBAR_RELOAD_TO_STOP_PAGE();
                } // END - if
                        // Then load waiting page
                        SURFBAR_RELOAD_TO_STOP_PAGE();
                } // END - if
+
+               // Load header to avoid a bug
+               loadIncludeOnce('inc/header.php');
        } else {
                // Reload to stop frame!
                SURFBAR_RELOAD_TO_STOP_PAGE();
        } else {
                // Reload to stop frame!
                SURFBAR_RELOAD_TO_STOP_PAGE();
index b5cabc45641f3846fee4974ed1dedb822d546445..1126345eb555696e95f26846169f708fc9d6e022 100644 (file)
@@ -27,7 +27,7 @@ function init () {
 function confirm () {
        if (parent.surfbar_url != null) {
                // Is in right frameset
 function confirm () {
        if (parent.surfbar_url != null) {
                // Is in right frameset
-               parent.surfbar_url.location.href = "{%url=surfbar.php?id=$content[url_id]&check={%pipe,SURFBAR_GENERATE_VALIDATION_CODE=$content[url_id]%}&salt={%pipe,SURFBAR_GET_SALT%}%}";
+               parent.surfbar_url.location.href = "{%url=surfbar.php?id=$content[url_id]&check=$content[check]&salt=$content[salt]%}";
        } else {
                // Called frame=top directly
                window.location.href = "{%url=surfbar.php%}";
        } else {
                // Called frame=top directly
                window.location.href = "{%url=surfbar.php%}";