### WARNING: THIS FILE IS AUTO-GENERATED BY ./DOCS/todo-builder.sh (uid=/user=quix0r) ###
### DO NOT EDIT THIS FILE. ###
./autoreg.php:58:// @TODO Add processing of request here
-./beg.php:163: // @TODO Opps, what is missing here???
+./beg.php:171: // @TODO Opps, what is missing here???
./birthday_confirm.php:93: // @TODO Try to rewrite the following unset()
./inc/autopurge/purge-inact.php:55: // @TODO Rewrite these if() blocks to a filter
./inc/cache/config-local.php:124:// @TODO Rewrite the following three constants, somehow...
./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:430: // @TODO This can be, somehow, rewritten
-./inc/libs/beg_functions.php:52: // @TODO Try to rewrite the following unset()
+./inc/libs/beg_functions.php:55: // @TODO Try to rewrite the following unset()
./inc/libs/bonus_functions.php:199: // @TODO Move this HTML to a template
-./inc/libs/bonus_functions.php:283: // @TODO This query isn't right, it will only update if the user was for a longer time away!
+./inc/libs/bonus_functions.php:287: // @TODO This query isn't right, it will only update if the user was for a longer time away!
./inc/libs/cache_functions.php:78: // @TODO This should be rewritten not to load the cache file for just checking if it is there for save removal.
./inc/libs/doubler_functions.php:44:// @TODO Lame description
./inc/libs/doubler_functions.php:92: // @TODO Can't this be moved into EL?
./inc/libs/register_functions.php:362: // @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:1538: // @TODO This can be somehow rewritten
+./inc/libs/surfbar_functions.php:1026: // @TODO Try to rewrite the following unset()
+./inc/libs/surfbar_functions.php:1541: // @TODO This can be somehow rewritten
./inc/libs/surfbar_functions.php:710:// @TODO Can't we use our new expression language instead of this ugly code?
./inc/libs/surfbar_functions.php:951: // @TODO Invalid salt should be refused
./inc/libs/task_functions.php:239: // @TODO These can be rewritten to filter
./inc/libs/user_functions.php:144: // @TODO These two constants are no longer used, maybe we reactivate this code?
./inc/libs/user_functions.php:232:// @TODO Double-check configuration entry here
./inc/libs/user_functions.php:325: // @TODO Make this filter working: $ADDON = runFilterChain('post_login_update', $content);
-./inc/libs/user_functions.php:345: // @TODO Make this filter working: $url = runFilterChain('do_login', array('content' => $content, 'addon' => $ADDON));
-./inc/libs/user_functions.php:421: // @TODO We should try to rewrite this to fetchUserData() somehow
-./inc/libs/user_functions.php:609: // @TODO Try to rewrite the following unset()
+./inc/libs/user_functions.php:347: // @TODO Make this filter working: $url = runFilterChain('do_login', array('content' => $content, 'addon' => $ADDON));
+./inc/libs/user_functions.php:423: // @TODO We should try to rewrite this to fetchUserData() somehow
+./inc/libs/user_functions.php:611: // @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_cache-extension.php:13: * @TODO Rewrite this whole file to load_cache-extensions.php *
./inc/modules/member/what-unconfirmed.php:206: // @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:67: // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1172: // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1427: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
-./inc/mysql-manager.php:1535: // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1902: // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1946:// @TODO Fix inconsistency between last_module and getWhat()
+./inc/mysql-manager.php:1188: // @TODO Rewrite this to a filter
+./inc/mysql-manager.php:1443: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
+./inc/mysql-manager.php:1551: // @TODO Rewrite this to a filter
+./inc/mysql-manager.php:1922: // @TODO Rewrite this to a filter
+./inc/mysql-manager.php:1966:// @TODO Fix inconsistency between last_module and getWhat()
./inc/mysql-manager.php:368: // @TODO Try to rewrite this to one or more functions
./inc/mysql-manager.php:44:// @TODO Can we cache this?
./inc/reset/reset_beg.php:49:// @TODO This should be converted in a daily beg rallye
// Check if account was found
if ((isUserDataValid()) && (getUserData('status') == 'CONFIRMED')) {
- // Multiply configured values with 100000 and divide with 100000 so we can also handle small values
- // If we need more number behind the decimal dot then we just need to increase all these three
- // numbers matching to the numbers behind the decimal dot. Simple! ;-)
+ /*
+ * Multiply configured values with 100000 and divide with 100000 so we can also handle small values
+ * If we need more number behind the decimal dot then we just need to increase all these three
+ * numbers matching to the numbers behind the decimal dot. Simple! ;-)
+ */
$points = mt_rand((getConfig('beg_points') * 100000), (getConfig('beg_points_max') * 100000)) / 100000;
// Set nickname / userid for template
if (((SQL_HASZERONUMS($result)) || (isAdmin())) && ($points > 0) && (!isMember()) && (getConfig('beg_pay_mode') == 'NONE')) {
// Admin is testing?
if (!isAdmin()) {
- // Remember remote address, userid and timestamp for next click
- // but only when there is no admin begging.
- // Admins shall be able to test it!
+ /*
+ * Remember remote address, userid and timestamp for next click
+ * but only when there is no admin begging.
+ * Admins shall be able to test it!
+ */
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_beg_ips` (`userid`, `remote_ip`,`sid`, `timeout`) VALUES ('%s','%s','%s', UNIX_TIMESTAMP())",
- array(getUserData('userid'), detectRemoteAddr(), session_id()), __FILE__, __LINE__);
+ array(
+ getUserData('userid'),
+ detectRemoteAddr(),
+ session_id()
+ ), __FILE__, __LINE__);
// Was is successfull?
- $pay (SQL_AFFECTEDROWS() == 1);
+ $pay (!SQL_HASZEROAFFECTED());
} else {
// Is admin!
$pay = true;
SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `clicks`=`clicks`+1 WHERE `id`=%s LIMIT 1", array(bigintval(getRequestParameter('banner'))), __FILE__, __LINE__);
// A line has been updated?
- if ((SQL_AFFECTEDROWS() == 1) && (isGetRequestParameterSet('user'))) {
+ if ((!SQL_HASZEROAFFECTED()) && (isGetRequestParameterSet('user'))) {
// Redirect to the user's referal link
redirectToUrl('ref.php?refid=' . bigintval(getRequestParameter('user')));
} // END - if
$tableName = str_replace('`', '', $tableArray[2]);
// Shall we add/drop?
- if (((strpos($sql, 'ADD') !== false) || (strpos($sql, 'DROP') !== false)) && ($noIndex === true)) {
+ if (((strpos($sql, 'ADD') !== false) || (strpos($sql, 'DROP') !== false) || (strpos($sql, 'CHANGE') !== false)) && ($noIndex === true)) {
// Try two columns, one should fix
foreach (array(4,5) as $idx) {
// And column name as well
$result = SQL_QUERY_ESC("SHOW COLUMNS FROM `%s` LIKE '%s'",
array($tableName, $columnName), __FUNCTION__, __LINE__);
- // Do we have no entry on ADD or an entry on DROP?
- // 123 4 4 3 3 4 4 32 23 4 4 3 3 4 4 321
- if (((SQL_HASZERONUMS($result)) && (strpos($sql, 'ADD') !== false)) || ((SQL_NUMROWS($result) == 1) && (strpos($sql, 'DROP') !== false))) {
+ // Debug log
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'columnName=' . $columnName . ',idx=' . $idx . ',sql=' . $sql . ',hasZeroNums=' . intval(SQL_HASZERONUMS($result)));
+
+ // Do we have no entry on ADD or an entry on DROP/CHANGE?
+ // 123 4 43 3 4 4 32 23 4 4 3 3 4 4 32 23 4 43 3 4 4 3 3 321
+ if (((SQL_HASZERONUMS($result)) && (strpos($sql, 'ADD') !== false)) || ((!SQL_HASZERONUMS($result)) && (strpos($sql, 'DROP') !== false)) || ((!SQL_HASZERONUMS($result)) && (strpos($sql, 'CHANGE') !== false) && ($idx == 5))) {
// Do the query
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Executing: ' . $sql);
$result = SQL_QUERY($sql, $F, $L, false);
// Skip further attempt(s)
break;
- } elseif ((((SQL_NUMROWS($result) == 1) && (strpos($sql, 'ADD') !== false)) || ((SQL_HASZERONUMS($result)) && (strpos($sql, 'DROP') !== false))) && ($columnName != 'KEY')) {
+ // 1234 5 54 4 5 5 43 34 5 54 4 5 5 43 3 4 4 32 2 21
+ } elseif ((((!SQL_HASZERONUMS($result)) && (strpos($sql, 'ADD') !== false)) || ((!SQL_HASZERONUMS($result)) && (strpos($sql, 'DROP') !== false)) || (strpos($sql, 'CHANGE') !== false)) && ($columnName != 'KEY')) {
// Abort here because it is alreay there
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Skipped: ' . $sql);
break;
} elseif ($columnName != 'KEY') {
- // Something didn't fit
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Possible problem: ' . $sql);
+ // Something didn't fit, we better log it
+ logDebugMessage(__FUNCTION__, __LINE__, 'Possible problem: ' . $sql . ',hasZeroNums=' . intval(SQL_HASZERONUMS($result)) . '');
}
} // END - foreach
} elseif ((getConfig('_TABLE_TYPE') == 'InnoDB') && (strpos($sql, 'FULLTEXT') !== false)) {
// Skip this query silently
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Skipped FULLTEXT: sql=%s,file=%s,line=%s", $sql, $F, $L));
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Skipped FULLTEXT: sql=%s,columnName=%s,idx=%d,hasZeroNums=%d,file=%s,line=%s", $sql, $columnName, $idx, intval(SQL_HASZERONUMS($result)), $F, $L));
} elseif ($noIndex === false) {
// And column name as well
//* DEBUG: */ debugOutput(__LINE__.':tableArray=<pre>' . print_r($tableArray, true) . '</pre>');
return (SQL_NUMROWS($result) === 0);
}
+// Wrapper function to make code more readable
+function SQL_HASZEROAFFECTED () {
+ // Just pass it through
+ return (SQL_AFFECTEDROWS() === 0);
+}
+
// Private function to prepare the SQL query string
function SQL_PREPARE_SQL_STRING ($sqlString, $enableCodes = true) {
// Is it already cached?
runFilterChain('extension_' . $load_mode);
// Remove cache file(s) if extension is active
- if (((isExtensionActive('cache')) && ((SQL_AFFECTEDROWS() == 1)) || ($sqlRan === true) || ($load_mode == 'activate') || ($load_mode == 'deactivate'))) {
+ if (((isExtensionActive('cache')) && ((!SQL_HASZEROAFFECTED())) || ($sqlRan === true) || ($load_mode == 'activate') || ($load_mode == 'deactivate'))) {
// Run filters
runFilterChain('post_extension_run_sql', getCurrentExtensionName());
} // END - if
addExtensionSql($sql);
} elseif (isDebugModeEnabled()) {
// Double menus should be located and fixed!
- logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double guest menu action=%s,what=%s,title=%s,active=%s detected.", $action, $what, $title, $active));
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double guest menu action=%s,what=%s,title=%s,locked=%s,visible=%s detected.", $action, $what, $title, $locked, $visible));
}
}
} // END - if
// Version number
-setThisExtensionVersion('0.2.8');
+setThisExtensionVersion('0.2.9');
// Version history array (add more with , '0.1.0' and so on)
-setExtensionVersionHistory(array('0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8'));
+setExtensionVersionHistory(array('0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9'));
switch (getExtensionMode()) {
case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
`userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
`remote_ip` VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
`timeout` VARCHAR(10) NOT NULL DEFAULT '',
+`sid` VARCHAR(255) NOT NULL DEFAULT '',
KEY (`userid`),
PRIMARY KEY (`id`)
) TYPE={?_TABLE_TYPE?}");
case 'remove': // Do stuff when removing extension
// SQL commands to run
addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_beg_ips`');
- addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='config_beg' OR `what`='list_beg'");
+ addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_beg_referals`');
+ addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what` IN ('config_beg','list_beg','list_beg_referal_urls')");
addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `what`='beg'");
- addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='beg' OR `what`='beg2'");
+ addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what` IN ('beg','beg2')");
break;
case 'activate': // Do stuff when admin activates this extension
setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
break;
- case '0.2.6': // SQL queries for v0.2.6
+ case '0.2.6': // SQL queries for v0.2.6
addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_beg_ips` ADD `sid` VARCHAR(255) NOT NULL DEFAULT ''");
addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `beg_pay_mode` ENUM('IMG','JS','BOTH','NONE') DEFAULT 'NONE' NOT NULL ;");
// Update notes (these will be set as task text!)
setExtensionUpdateNotes("Umbenannt nach neuer Namenskonvention");
break;
+
+ case '0.2.9': // SQL queries for v0.2.9
+ addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_beg_referals`');
+ addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_beg_referals` (
+`id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
+`userid` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ,
+`remote_ip` VARCHAR( 15 ) NOT NULL DEFAULT '0.0.0.0',
+`timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
+`referal_url` TINYTEXT NOT NULL ,
+INDEX ( `userid` )
+) ENGINE = {?_TABLE_TYPE?} COMMENT = 'Recorded Referal URLs'");
+
+ // Add admin menu
+ addAdminMenuSql('user','list_beg_referal_urls','Bettel-Referals auflisten','Listet alle Bettellink-Aufrufe inklusive Referal-URL auf.','13');
+
+ // Update notes (these will be set as task text!)
+ setExtensionUpdateNotes("Loggen der Referal-URLs hinzugefügt.");
+ break;
} // END - switch
break;
// Remove old entries
$OLD = getConfig('beg_timeout');
if (getConfig('beg_userid_timeout') > $OLD) $OLD = getConfig('beg_userid_timeout');
- $result_ext = SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_beg_ips` WHERE `timeout` < (UNIX_TIMESTAMP() - ' . ($OLD + 60*60) . ')', __FILE__, __LINE__);
+ SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_beg_ips` WHERE `timeout` < (UNIX_TIMESTAMP() - ' . ($OLD + 60*60) . ')', __FILE__, __LINE__);
// Check for beg rallye is active and send mails out
if ((isBegRallyeEnabled()) && (isBegNewMemberNotifyEnabled())) {
// Update notes (these will be set as task text!)
setExtensionUpdateNotes('');
break;
- }
+ } // END - switch
case 'modify': // When the extension got modified
break;
default: // Unknown extension mode
logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
break;
-}
+} // END - switch
// [EOF]
?>
UNIQUE `user_refid` (`userid`,`level`,`refid`),
KEY (`level`),
KEY (`refid`)
-) ENGINE={?_TABLE_TYPE?} COMMENT='User Referals With Refback'");
+) ENGINE = {?_TABLE_TYPE?} COMMENT='User Referals With Refback'");
addMemberMenuSql('main','refback','Ref-Back einstellen','N','Y',4);
// Execute this special file on registration
`added` DATETIME NOT NULL,
PRIMARY KEY (`hostname`),
INDEX (`ip`)
-) ENGINE={?_TABLE_TYPE?}");
+) ENGINE = {?_TABLE_TYPE?}");
// Configuration
addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `dns_cache_timeout` BIGINT(20) NOT NULL DEFAULT ' . (60*60*24));
'BEG_CLICKS' => "Dies war insgesamt der <strong>%s.</strong> Klick auf sein Bettel-Link.",
'BEG_THANKS_FOR_CLICK' => "Danke für Ihre Spende.",
'BEG_CONTINUE_REGISTER' => "Und weiter geht es zur Anmeldung bei {?MAIN_TITLE?} ...",
- 'BEG_SORRY_ANOTHER_WAS_HERE_1' => "Oh schade! Es war vor kurzem schon einer hier! Das Mitglied ",
+ 'BEG_SORRY_ANOTHER_WAS_HERE_1' => "Oh, schade! Es war vor kurzem schon einer hier! Das Mitglied ",
'BEG_SORRY_ANOTHER_WAS_HERE_2' => " hat von Ihnen auch keine ",
'BEG_SORRY_ANOTHER_WAS_HERE_3' => " {?POINTS?} erhalten.",
'BEG_THANKS_FOR_CLICK_AGAIN' => "Danke dennoch für den erneuten Klick.",
'ADMIN_SELECT_BEG_MODE' => "Vergütungsmodus der erbettelten {?POINTS?}",
'BEG_MODE_DIRECT' => "Nur direktem Mitglied gutschreiben.",
'BEG_MODE_REF' => "Auch dem Werber des Mitgliedes gutschreiben.",
- 'BEG_SORRY_YOURE_LOGGED_IN_1' => "Oh schade! Sie haben vermutlich auf Ihren eigenen Bettel-Link mit der Mitglieder-Id ",
+ 'BEG_SORRY_YOURE_LOGGED_IN_1' => "Oh, schade! Sie haben vermutlich auf Ihren eigenen Bettel-Link mit der Mitglieder-Id ",
'BEG_SORRY_YOURE_LOGGED_IN_2' => " geklickt. Sie haben somit auch keine ",
'BEG_SORRY_YOURE_LOGGED_IN_3' => " {?POINTS?} erhalten.",
'BEG_SAME_UID_AS_OWN' => "Mitglieder-Id des Webmasters benutzt.",
'UNDO_SELECTIONS' => "Auswahl zurücknehmen",
'ADMIN_EDIT_MENUS' => "Menüs bearbeiten",
'ADMIN_DELETE_MENUS' => "Menüs löschen",
- 'ADMIN_EDIT_ADMIN_MENU' => "Admin-Menüeinträge ändern",
+ 'ADMIN_EDIT_ADMIN_MENU_TITLE' => "Admin-Menüeinträge ändern",
'ADMIN_EDIT_MENU' => "Es soll/sollen <span class=\"data\">%s</span> Menüeintrag/-einträge geändert werden:",
'ADMIN_ENTRY_MODIFY' => "Eintrag",
'SUBMIT_CHANGES' => "Änderungen durchführen",
// Add points to user or begging rallye account
function addPointsBeg ($userid, $points) {
+ // Default is not added
+ $added = false;
+
// Is begging rallye active?
if (isBegRallyeEnabled()) {
// Add points to rallye account
// Add points to account
// @TODO Try to rewrite the following unset()
unset($GLOBALS['ref_level']);
- addPointsThroughReferalSystem('beg', $userid, $points, false, 0, strtolower(getConfig('beg_mode')));
+ $added = addPointsThroughReferalSystem('beg', $userid, $points, false, 0, strtolower(getConfig('beg_mode')));
}
// Subtract begged points from member account if the admin has selected one
// Subtract from this account
subtractPoints('beg_payout', getConfig('beg_userid'), $points);
} // END - if
+
+ // Return result
+ return $added;
}
// Checks wether beg_rallye is enabled
$points
), __FUNCTION__, __LINE__);
- if ((isExtensionInstalledAndNewer('bonus', '0.3.5')) && (getConfig('bonus_mode') != 'ADD') && ($points > 0)) handleBonusPoints($points);
+ if ((isExtensionInstalledAndNewer('bonus', '0.3.5')) && (getBonusMode() != 'ADD') && ($points > 0)) handleBonusPoints($points);
}
//
if (!isBonusRallyeActive()) return;
// Switch to jackpot-mode when no UID is supplied but userid-mode is selected
- if ((getConfig('bonus_mode') == 'UID') && (getBonusUserId() == '0') && (isExtensionActive('jackpot'))) {
+ if ((getBonusMode() == 'UID') && (getBonusUserId() == '0') && (isExtensionActive('jackpot'))) {
// Update database & config
updateConfiguration('bonus_mode', 'JACKPOT');
} // END - if
$total = getTotalPoints(getBonusUserId());
// Subtract points from...
- switch (getConfig('bonus_mode')) {
+ switch (getBonusMode()) {
case 'JACKPOT': // ... jackpot
if ((isExtensionActive('jackpot')) && (subtractPointsFromJackpot($points) == -1) && (isValidUserId(getBonusUserId()))) {
if ($total >= $points) {
$dummy = subtractPointsFromJackpot($points);
}
break;
+
+ default: // This should not happen
+ debug_report_bug(__FUNCTION__, __LINE__, 'Invalid config entry ' . getBonusMode() . ' detected.');
+ break;
} // END - switch
}
// Remove entries
$result = SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_bonus_turbo` WHERE `timemark` < (UNIX_TIMESTAMP() - {?bonus_timeout?})', __FUNCTION__, __LINE__);
- if (SQL_AFFECTEDROWS() > 0) {
+ if (!SQL_HASZEROAFFECTED()) {
// Send out email to admin
sendAdminNotification('{--ADMIN_AUTOPURGE_TURBO_SUBJECT--}', 'admin_autopurge_turbo', SQL_AFFECTEDROWS());
} // END - if
);
// Updated entry?
- $bonus = (SQL_AFFECTEDROWS() == 1);
+ $bonus = (!SQL_HASZEROAFFECTED());
} // END - if
if (($bonus === true) && (getRequestParameter('mode') == 'bonus')) {
return $GLOBALS[__FUNCTION__];
}
+// Getter for bonus_mode
+function getBonusMode () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('bonus_mode');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
// [EOF]
?>
function FILTER_ADD_BOOKING_RECORD ($data) {
// Add a record
addBookingRecord($data['subject'], $data['userid'], $data['points'], $data['mode']);
+
+ // Return data
+ return $data;
}
// [EOF]
// Update an entry
function updateMediadataEntry ($keys_array, $mode, $value) {
+ // Default is nothing added/updated
+ $added = null;
+
+ // Do we have entries?
if (is_array($keys_array) && ($value > 0)) {
// Is an array so we can run it through
foreach ($keys_array as $key) {
// First check if it does exist
- $result_media = SQL_QUERY_ESC("SELECT media_key FROM `{?_MYSQL_PREFIX?}_mediadata`
-WHERE media_key = '%s' LIMIT 1", array($key), __FUNCTION__, __LINE__);
+ $result_media = SQL_QUERY_ESC("SELECT
+ `media_key`
+FROM
+ `{?_MYSQL_PREFIX?}_mediadata`
+WHERE
+ `media_key` = '%s'
+LIMIT 1", array($key), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result_media) == 0) {
// Not found so we create it (mode will be ignored here!)
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_mediadata` (`media_key`, `media_value`) VALUES ('%s', '%s')",
- array($key, $value), __FUNCTION__, __LINE__);
+ array($key, $value), __FUNCTION__, __LINE__);
} else {
// Update entry
switch ($mode) {
case 'add': $mode = '+'; break;
case 'sub': $mode = '-'; break;
- }
+ } // END - switch
if ($mode == 'init') {
// Initialize entry
SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_mediadata` SET `media_value`=%s WHERE `media_key`='%s' LIMIT 1",
- array($value, $key), __FUNCTION__, __LINE__);
+ array($value, $key), __FUNCTION__, __LINE__);
} else {
// Update entry
SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_mediadata` SET `media_value`=`media_value`".$mode."%s WHERE `media_key`='%s' LIMIT 1",
- array($value, $key), __FUNCTION__, __LINE__);
+ array($value, $key), __FUNCTION__, __LINE__);
}
}
- }
- }
+
+ // Check affected rows
+ if (is_null($added)) {
+ //* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):added='.intval($added));
+ $added = (!SQL_HASZEROAFFECTED());
+ //* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):added='.intval($added));
+ } else {
+ //* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):added='.intval($added));
+ $added = ($added && (!SQL_HASZEROAFFECTED()));
+ //* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):added='.intval($added));
+ }
+ } // END - foreach
+ } // END - if
+
+ // Zero entries are always added
+ if ($value == 0) {
+ // Is zero value, so we need to set $added here to avoid wrong false result
+ $added = true;
+ } // END - if
+
+ // Return result
+ return $added;
}
// Getter for entry
// Filter for updating media data
function FILTER_UPDATE_MEDIADATA_ENTRY ($data) {
// Execute the filter function
- updateMediadataEntry(array('total_points'), $data['mode'], $data['points']);
+ $data['added'] = ($data['added'] && updateMediadataEntry(array('total_points'), $data['mode'], $data['points']));
+
+ // Return data
+ return $data;
}
//
setPostRequestParameter('network_id', SQL_INSERTID());
// Output message
- if (SQL_AFFECTEDROWS() == 1) {
+ if (!SQL_HASZEROAFFECTED()) {
// Successfully added
loadTemplate('admin_network_added', false, postRequestArray());
} else {
)", __FUNCTION__, __LINE__);
// Output message
- if (SQL_AFFECTEDROWS() == 1) {
+ if (!SQL_HASZEROAFFECTED()) {
// Successfully added
loadTemplate('admin_network_type_added', false, postRequestArray());
} else {
)", __FUNCTION__, __LINE__);
// Output message
- if (SQL_AFFECTEDROWS() == 1) {
+ if (!SQL_HASZEROAFFECTED()) {
// Successfully added
loadTemplate('admin_network_request_param_added', false, postRequestArray());
} else {
)", __FUNCTION__, __LINE__);
// Output message
- if (SQL_AFFECTEDROWS() == 1) {
+ if (!SQL_HASZEROAFFECTED()) {
// Successfully added
loadTemplate('admin_network_api_translation_added', false, postRequestArray());
} else {
array($percents, $id, getMemberId()), __FUNCTION__, __LINE__);
// Entry updated?
- if (SQL_AFFECTEDROWS() < 1) {
+ if (SQL_HASZEROAFFECTED()) {
// Entry not updated!
$status['message'] = '{--MEMBER_REFBACK_ERROR_NOT_UPDATED--}';
return $status;
), __FUNCTION__, __LINE__);
// This update went fine?
- $login = (SQL_AFFECTEDROWS() == 1);
+ $login = (!SQL_HASZEROAFFECTED());
} // END - if
// Return status
} // END - switch
// Has an entry updated?
- if (SQL_AFFECTEDROWS() == 1) {
+ if (!SQL_HASZEROAFFECTED()) {
// Template and subject are set?
if (!empty($templ) && !empty($subj)) {
// Run SQL command and check for success
subtractPoints(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
} // END - if
- // Book it to the user
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.getMemberId().',reward='.SURFBAR_GET_REWARD().'', false);
- addPointsThroughReferalSystem(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), getMemberId(), SURFBAR_GET_DATA('reward'));
+ // @TODO Try to rewrite the following unset()
+ unset($GLOBALS['ref_level']);
+
+ // Book it to the user
+ addPointsThroughReferalSystem(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), getMemberId(), SURFBAR_GET_REWARD());
}
// Updates the statistics of current URL/userid
), __FUNCTION__, __LINE__);
// Was that update okay?
- if (SQL_AFFECTEDROWS() < 1) {
+ if (SQL_HASZEROAFFECTED()) {
// No, then insert entry
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_stats` (`stats_userid`, `stats_url_id`, `stats_count`) VALUES (%s,%s,1)",
array(
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'salt='.SURFBAR_GET_SALT().',id='.SURFBAR_GET_ID().',userid='.getMemberId().'', false);
// Was that okay?
- if (SQL_AFFECTEDROWS() < 1) {
+ 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__);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'affectedRows='.SQL_AFFECTEDROWS().'', false);
// Return if the update was okay
- return (SQL_AFFECTEDROWS() == 1);
+ return (!SQL_HASZEROAFFECTED());
}
// Check if the reload lock is active for given id
$GLOBALS['bonus_payed'] = true;
// Subtract login bonus from userid's account or jackpot
- if ((isExtensionInstalledAndNewer('bonus', '0.3.5')) && (getConfig('bonus_mode') != 'ADD')) handleBonusPoints('login_bonus');
+ if ((isExtensionInstalledAndNewer('bonus', '0.3.5')) && (getBonusMode() != 'ADD')) {
+ handleBonusPoints('login_bonus');
+ } // END - if
} // END - if
// @TODO Make this filter working: $url = runFilterChain('do_login', array('content' => $content, 'addon' => $ADDON));
// Update database records
SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `total_logins`=`total_logins`+1" . $add . " WHERE `userid`=%s LIMIT 1",
array($userid), __FUNCTION__, __LINE__);
- if (SQL_AFFECTEDROWS() == 1) {
+ if (!SQL_HASZEROAFFECTED()) {
// Is a success URL set?
if (empty($successUrl)) {
// Procedure to checking for login data
array($hash), __FILE__, __LINE__);
// Was it updated?
- if (SQL_AFFECTEDROWS() == 1) {
+ if (!SQL_HASZEROAFFECTED()) {
// Send email if updated
$message = loadEmailTemplate('confirm-member', $content, bigintval($userid));
}
// Everthing is fine?
- if (SQL_AFFECTEDROWS() < 1) {
+ if (SQL_HASZEROAFFECTED()) {
// Something bad happend!
setModuleStatus($module_chk, 'major');
return 'major';
// @TODO Kill all constants in this file
$content['sub'] = $SUB;
$content['chk'] = countPostSelection();
- $cnt = '0';
+ $cnt = '0'; $OUT = '';
foreach (postRequestParameter('sel') as $sel => $confirm) {
if ($confirm == 1) {
$cnt++;
bigintval(postRequestParameter('id')),
), __FILE__, __LINE__);
- if (SQL_AFFECTEDROWS() == 1) {
+ if (!SQL_HASZEROAFFECTED()) {
$content = '{--SETTINGS_SAVED--}';
} else {
$content = '<span class="notice">{--SETTINGS_NOT_SAVED--}</span>';
}
// Entry updated?
- if (SQL_AFFECTEDROWS() == 1) {
+ if (!SQL_HASZEROAFFECTED()) {
// Send an email to the user! In later version you can optionally switch this feature off
$message = loadEmailTemplate('lock-user', array('text' => postRequestParameter('reason')), bigintval(getRequestParameter('userid')));
}
// Entry updated?
- if (SQL_AFFECTEDROWS() == 1) {
+ if (!SQL_HASZEROAFFECTED()) {
// Send an email to the user! In later version you can optionally switch this feature off
$message = loadEmailTemplate('unlock-user', array('text' => postRequestParameter('reason')), bigintval(getRequestParameter('userid')));
} // END - switch
// Check if we have saved (updated)
- if (SQL_AFFECTEDROWS() == 1) {
+ if (!SQL_HASZEROAFFECTED()) {
// Updated!
$content = '{--SETTINGS_SAVED--}';
} else {
array(bigintval($content['refid'])), __FILE__, __LINE__);
// Whas that update fine?
- if (SQL_AFFECTEDROWS() == 1) {
+ if (!SQL_HASZEROAFFECTED()) {
// Load referal's data
$result = SQL_QUERY_ESC("SELECT
`id`, `gender`, `surname`, `family`, `email`,
), __FILE__, __LINE__);
// Check on success
- if (SQL_AFFECTEDROWS() == 1) {
+ if (!SQL_HASZEROAFFECTED()) {
// Prepare mail and send it to the sponsor
$message = loadEmailTemplate('sponsor_pending', $data);
sendEmail($data['email'], '{--SPONSOR_ACCOUNT_PENDING_SUBJECT--}', $message);
array(bigintval($data['id']), getRequestParameter('hash')), __FILE__, __LINE__);
// Check on success
- if (SQL_AFFECTEDROWS() == 1) {
+ if (!SQL_HASZEROAFFECTED()) {
// Sponsor account is unlocked again
loadTemplate('admin_settings_saved', false, '{--SPONSOR_ACCOUNT_IS_CONFIRMED_AGAIN--}');
} else {
}
// Did something change?
- if (SQL_AFFECTEDROWS() == 1) {
+ if (!SQL_HASZEROAFFECTED()) {
// Get all modes ...
$modes = explode(';', $mode);
array($type, bigintval(getRequestParameter('order')), getMemberId()), __FILE__, __LINE__);
// Finally is the entry valid?
- if (SQL_AFFECTEDROWS() == 1) {
+ if (!SQL_HASZEROAFFECTED()) {
// @TODO Unused: 2,4
// Load mail again... 0 1 2 3 4 5 6 7
$result = SQL_QUERY_ESC("SELECT `subject`, `text`, `receivers`, `payment_id`, `timestamp`, `url`, `cat_id`, `target_send` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s AND `sender`=%s LIMIT 1",
// Should we look for affected rows (only update) or found rows?
if ($updateEntry === true) {
// Check updated/affected rows
- $ret = (SQL_AFFECTEDROWS() == 1);
+ $ret = (!SQL_HASZEROAFFECTED());
} else {
// Check found rows
- $ret = (SQL_NUMROWS($result) == 1);
+ $ret = (!SQL_HASZERONUMS($result));
}
// Free memory
* for default value will cause no referal will get points ever!!!)
*/
function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify = false, $refid = '0', $add_mode = 'ref') {
+ // By default nothing has been added
+ $added = false;
+
//* DEBUG: */ debugOutput('----------------------- <font color="#00aa00">' . __FUNCTION__ . ' - ENTRY</font> ------------------------<ul><li>');
// Convert mode to lower-case
$add_mode = strtolower($add_mode);
//* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):data='.$data.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$add_mode.' - UPDATE! ('.SQL_AFFECTEDROWS().')');
// No entry updated?
- if (SQL_AFFECTEDROWS() < 1) {
+ if (SQL_HASZEROAFFECTED()) {
// First ref in this level! :-)
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_points` (`userid`,`ref_depth`,`%s`) VALUES (%s,%s,%s)",
array($data, bigintval($userid), bigintval($GLOBALS['ref_level']), $ref_points), __FUNCTION__, __LINE__);
//* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):data='.$data.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$add_mode.' - INSERTED! ('.SQL_AFFECTEDROWS().')');
} // END - if
+ // Check affected rows
+ $added = SQL_AFFECTEDROWS();
+ //* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):added='.intval($added));
+
// Prepare data for the filter
$filterData = array(
'subject' => $subject,
'locked' => $locked,
'mode' => 'add',
'sub_mode' => $add_mode,
+ 'added' => $added
);
// Filter it now
- runFilterChain('add_points', $filterData);
+ $filterData = runFilterChain('add_points', $filterData);
+
+ // Extract $added
+ $added = $filterData['added'];
+ //* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):added='.intval($added));
// Points updated, maybe I shall send him an email?
if (($sendNotify === true) && (isValidUserId(getUserData('refid'))) && ($locked === false)) {
if ((isValidUserId(getUserData('refid'))) && ($points > 0) && (getUserData('refid') != $userid) && ($add_mode == 'ref')) {
// Then let's credit him here...
//* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):userid='.$userid.',ref='.getUserData('refid').',points='.$points.' - ADVANCE!');
- addPointsThroughReferalSystem(sprintf("%s_ref:%s", $subject, $GLOBALS['ref_level']), getUserData('refid'), $points, $sendNotify, getUserData('refid'));
+ $added = ($added && addPointsThroughReferalSystem(sprintf("%s_ref:%s", $subject, $GLOBALS['ref_level']), getUserData('refid'), $points, $sendNotify, getUserData('refid')));
} // END - if
} // END - if
} // END - if
- //* DEBUG: */ debugOutput('</li></ul>----------------------- <font color="#aa0000">'.__FUNCTION__.' - EXIT</font> ------------------------<br />');
+ //* DEBUG: */ debugOutput('</li></ul>----------------------- <font color="#aa0000">'.__FUNCTION__.': added=' . intval($added) . ' - EXIT</font> ------------------------<br />');
+ return $added;
}
// Updates the referal counter
// When no entry was updated then we have to create it here
//* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):updated=' . SQL_AFFECTEDROWS());
- if (SQL_AFFECTEDROWS() < 1) {
+ if (SQL_HASZEROAFFECTED()) {
// First count!
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_refsystem` (`userid`, `level`, `counter`) VALUES (%s,%s,1)",
- array(bigintval($userid), $GLOBALS['cache_array']['ref_level'][$userid]), __FUNCTION__, __LINE__);
+ array(
+ bigintval($userid),
+ $GLOBALS['cache_array']['ref_level'][$userid]
+ ), __FUNCTION__, __LINE__);
//* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):userid='.$userid);
} // END - if
'subject' => $subject,
'userid' => $userid,
'points' => $points,
- 'mode' => 'sub'
+ 'mode' => 'sub',
+ 'added' => (!SQL_HASZEROAFFECTED())
);
// Insert booking record
- runFilterChain('sub_points', $filterData);
+ $filterData = runFilterChain('sub_points', $filterData);
+
+ // Return result
+ return $filterData['added'];
}
// "Getter" for total available receivers
if (isset($DATA['html_msg'])) $HTML = $DATA['html_msg'];
// Entry updated?
- if (SQL_AFFECTEDROWS() == 1) {
+ if (!SQL_HASZEROAFFECTED()) {
// "Explode" all receivers into an array
if (isInString(';', $DATA['receivers'])) {
// There's more than one receiver in the list...
<strong>{%pipe,fixEmptyContentToDashes=$content[lock_reason]%}</strong>
</td>
</tr>
- <!--
- <tr>
- <td align="center" class="top right">
- {--_UNUSED--}:<br />
- <strong>---</strong>
- </td>
- <td align="center" class="top right">
- {--_UNUSED--}:<br />
- <strong>---</strong>
- </td>
- <td align="center" class="top right">
- {--_UNUSED--}:<br />
- <strong>---</strong>
- </td>
- <td align="center" class="top">
- {--_UNUSED--}:<br />
- <strong>---</strong>
- </td>
- </tr>
- //-->
<tr>
<td align="center" class="table_footer top" colspan="4">
<div>