### 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/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/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/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: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/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/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/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/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/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: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
./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
--- /dev/null
+#!/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
#!/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"`
#!/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" {} \;
#!/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
#!/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}" | \
// 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
//* 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;
- // 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;
} 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'))) {
} // 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
- /* 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
- /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql);
$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
//* 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!
- //* 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;
}
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));
}
}
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));
}
}
} // END - if
// Version number
-setThisExtensionVersion('0.0.1');
+setThisExtensionVersion('0.0.2');
// 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
// 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;
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
- addExtensionSql('');
+ addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `locked`='Y', `visible`='N' WHERE `what`='register' LIMIT 1");
break;
case 'update': // Update an extension
} // END - if
// Version number
-setThisExtensionVersion('0.4.1');
+setThisExtensionVersion('0.4.2');
// 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');
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('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');
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;
- 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;
- 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());
setExtensionUpdateNotes("Filter registriert, die das eigene {?POINTS?}-Guthaben des Mitgliedes zurü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');
setExtensionUpdateNotes("Das Mitgliederguthaben musste repariert werden, da fü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");
// 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
- //* 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
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!');
// Build key string
$keys = getSiteKey() . getEncryptSeperator() . getDateKey();
if (isConfigEntrySet('secret_key')) {
- $keys .= getEncryptSeperator().getSecretKey();
+ $keys .= getEncryptSeperator() . getSecretKey();
} // END - if
if (isConfigEntrySet('file_hash')) {
- $keys .= getEncryptSeperator().getFileHash();
+ $keys .= getEncryptSeperator() . getFileHash();
} // END - if
$keys .= getEncryptSeperator() . getDateFromPatchTime();
if (isConfigEntrySet('master_salt')) {
- $keys .= getEncryptSeperator().getMasterSalt();
+ $keys .= getEncryptSeperator() . getMasterSalt();
} // END - if
// Build string from misc data
// 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';
$pointsColumn = $filterData['column'];
// Return it
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',locked=' . intval($locked) . ',pointsColumn=' . $pointsColumn . ' - EXIT!');
return $pointsColumn;
}
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']);
} // 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?
// Check reload-locks
SURFBAR_CHECK_RELOAD_FULL();
-// Update stats
-SURFBAR_UPDATE_SALT_STATS();
-
// 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
'ADMIN_ENTER_POINTS_REGISTER' => "Willkommensgutschrift",
'ADMIN_ENTER_POINTS_REFERAL' => "Einmalige Referal-Gutschrift",
'CHOOSE_MORE_CATEGORIES' => "Bitte wä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äge editieren",
'ADMIN_EDIT_REFERAL_DEPTHS' => "Referal-Ebenen editieren / löschen / hinzufügen",
'REFERAL_IS_ACTIVE' => "Aktiv?",
'POINTS_USED' => "Verbrauchte {?POINTS?}",
'MEMBER_NO_POINTS' => "Sie haben keine {?POINTS?} mehr zum Versenden ü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 übrig",
'SELECT_MAIL_TYPE' => "Mailart auswählen",
'PLEASE_SELECT' => "Bitte auswählen",
'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.",
addMessages(array(
'MEMBER_PROFILE_LAST_CHANGE' => "Letzte Änderung",
'MEMBER_PROFILE_UPDATED' => "Ihre Profildaten wurden aktualisiert.",
+ 'MEMBER_EMAIL_IS_ALREADY_REGISTERED' => "Die Email-Adresse wird bereits von einem anderen Account verwendet.",
));
// [EOF]
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());
}
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
// 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
- $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',
// "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
- //* 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
- if ($userid == $refid) continue;
+ if ($userid == $refid) {
+ continue;
+ } // END - if
// 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) {
- //* 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",
- 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
- //* 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;
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'return=' . $return . ' - REDUCED!');
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'return=' . $return . ' - REDUCED!');
} // END - if
} // END - if
} // END foreach
$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) {
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ' - ENTERED!');
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ' - ENTERED!');
// 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])) {
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. :-(');
} // 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) {
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . $refid . ',level=' . $level);
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . $refid . ',level=' . $level);
// Init userids
$userIds = array();
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)) {
- //* 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
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;
}
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
- //* 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';
- $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
- //* 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)) {
$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]]))) {
$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
- $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?
- //* 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
- //* 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)",
- 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']++;
), __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)",
- 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
// 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']--;
- //* 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
- //* 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) {
- //* 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();
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) {
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ' - ENTERED!');
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ' - ENTERED!');
// Default data is nothing
$data = array();
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) {
- //* 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--}';
$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;
}
// 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
-('%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),
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
// 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');
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Fixed surf lock is '.getConfig('surfbar_static_lock') . '', false);
// 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
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'surf_lock=' . $GLOBALS['surfbar_cache']['surf_lock'] . ' - AFTER');
// Ask the database
$result = SQL_QUERY_ESC("SELECT
$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
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userLocks=' . SURFBAR_GET_USER_LOCKS() . ',total=' . $total . 'isFull=' . intval($isFull) . ' - EXIT!');
return $isFull;
}
SQL_FREERESULT($result);
// Debug message
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'cnt=' . $count);
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'cnt=' . $count);
// Return result
return $count;
// 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
- $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
- //* 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) {
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',check=' . $check . ',salt=' . $salt . ' - ENTERED!');
// Secure id number
$urlId = bigintval($urlId);
$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) {
- //* 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',
- 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
- //* 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
- //* 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());
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.SURFBAR_GET_USERID().',costs='.SURFBAR_GET_COSTS() . ' - EXIT!');
}
// Updates the statistics of current URL/userid
// 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());
+ // 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(
), __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')",
- array(SURFBAR_GET_ID(), getMemberId(), SURFBAR_GET_SALT()), __FUNCTION__, __LINE__);
+ array(
+ SURFBAR_GET_ID(),
+ getMemberId(),
+ SURFBAR_GET_SALT()
+ ), __FUNCTION__, __LINE__);
} // 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());
// 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
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);
}
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!
- //* 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'];
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;
// 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);
$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;
}
$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
// 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
- 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: */ 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
- 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: */ 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
- $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
- //* 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!
- $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
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);
// 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);
// 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';
} // 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,
}
// 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
- //* 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));
- //* 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();
// 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
- //* 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();
- //* 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();
- //* 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
SQL_FREERESULT($result);
// Return result
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'nextId='.$nextId.'', false);
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',nextId=' . $nextId . ' - EXIT!');
return $nextId;
}
// 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;
}
// 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 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]
?>
// Add links for selecting some users
function alpha ($sortby, $colspan, $return=false) {
if (!isGetRequestParameterSet('offset')) setGetRequestParameter('offset', 0);
- $add = '&page='.getRequestParameter('page').'&offset='.getRequestParameter('offset');
- if (isGetRequestParameterSet('mode')) $add .= '&mode='.getRequestParameter('mode');
+ $add = '&page=' . getRequestParameter('page').'&offset=' . getRequestParameter('offset');
+ if (isGetRequestParameterSet('mode')) $add .= '&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,');
`{?_MYSQL_PREFIX?}_user_data`
SET
`status`='CONFIRMED',
- `ref_payout`={?ref_payout?},
`user_hash`=NULL
WHERE
`user_hash`='%s' AND
} // 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
// 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
$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) {
// Then list it
$OUT .= loadTemplate(sprintf("admin_%s_%s_row",
$listType,
- $table
+ $table[0]
), true, $content
);
} // END - if
// Load master template
loadTemplate(sprintf("admin_%s_%s",
$listType,
- $table
+ $table[0]
), false, $OUT
);
}
registerOutputFailedMessage('ENTER_EMAIL');
setPostRequestParameter('email', '');
} elseif (postRequestParameter('email') == '?') {
- registerOutputFailedMessage('GUEST_EMAIL_ALREADY_DB');
+ registerOutputFailedMessage('GUEST_EMAIL_IS_ALREADY_REGISTERED');
setPostRequestParameter('email', '');
}
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!
* 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;
$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
- // 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
- //* 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);
// 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
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',points='.$points.',per='.$per.',depth='.$GLOBALS['ref_level']);
$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]))) {
- //* 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);
- //* 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...
- 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()) {
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();
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added='.intval($added));
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added='.intval($added));
// Prepare data for the filter
$filterData = array(
// 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)) {
} // 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...
- //* 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
- //* 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
- 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
- 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(
- bigintval($userid),
- $GLOBALS['cache_array']['ref_level'][$userid]
+ bigintval($userid),
+ bigintval($GLOBALS['cache_array']['ref_level'][$userid])
), __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
// 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
// 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
$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
// 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');
// 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'
} // 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];
}
// 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
} // END - if
// Return cache
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
return $GLOBALS[__FUNCTION__][$userid];
}
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" ?
// 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();
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%}";