From 43f8fab36af6c030d8835e1118cab430f8585e67 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 3 Dec 2008 15:11:28 +0000 Subject: [PATCH] Fixes for login bonus, some minor rewrites --- inc/databases.php | 2 +- inc/libs/bonus_functions.php | 18 +++++----- inc/modules/chk_login.php | 2 +- inc/modules/guest/what-login.php | 5 +-- inc/modules/login.php | 6 ---- inc/mysql-manager.php | 58 ++++++++++++++------------------ 6 files changed, 41 insertions(+), 50 deletions(-) diff --git a/inc/databases.php b/inc/databases.php index 3774c5042e..2bb9c5c36f 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -114,7 +114,7 @@ define('USAGE_BASE', "usage"); define('SERVER_URL', "http://www.mxchange.org"); // Current SVN revision -define('CURR_SVN_REVISION', "588"); +define('CURR_SVN_REVISION', "590"); // Take a prime number which is long (if you know a longer one please try it out!) define('_PRIME', 591623); diff --git a/inc/libs/bonus_functions.php b/inc/libs/bonus_functions.php index 3d3a648ebc..bbb2a32388 100644 --- a/inc/libs/bonus_functions.php +++ b/inc/libs/bonus_functions.php @@ -181,23 +181,25 @@ function BONUS_MAKE_RANK_ROWS($data, $type, $uid) return $OUT; } // -function BONUS_POINTS_HANDLER($MODE) -{ +function BONUS_POINTS_HANDLER($MODE) { global $_CONFIG; // Shall we add bonus points? if ($_CONFIG['bonus_active'] == "N") return; // Switch to jackpot-mode when no UID is supplied but userid-mode is selected - if (($_CONFIG['bonus_mode'] == "UID") && ($_CONFIG['bonus_uid'] == "0")) $_CONFIG['bonus_mode'] = "JACKPOT"; + if (($_CONFIG['bonus_mode'] == "UID") && ($_CONFIG['bonus_uid'] == "0")) { + // Update database + UPDATE_CONFIG(array('bonus_mode'), array("JACKPOT")); - if ($MODE == "login_bonus") - { + // Update configuration + $_CONFIG['bonus_mode'] = "JACKPOT"; + } // END - if + + if ($MODE == "login_bonus") { // Login bonus detected $points = $_CONFIG['login_bonus']; - } - else - { + } else { // Direct points supplied $points = $MODE; } diff --git a/inc/modules/chk_login.php b/inc/modules/chk_login.php index a96bc1d651..5d78f50a14 100644 --- a/inc/modules/chk_login.php +++ b/inc/modules/chk_login.php @@ -79,7 +79,7 @@ LIMIT 1", // Bonus is not given by default ;-) $bonus = false; - if ((GET_EXT_VERSION("sql_patches") >= "0.2.8") && (GET_EXT_VERSION("bonus") >= "0.2.1") && ($_CONFIG['bonus_login_yn'] == "N") && ($_CONFIG['bonus_login_yn'] == "Y")) { + if ((GET_EXT_VERSION("sql_patches") >= "0.2.8") && (GET_EXT_VERSION("bonus") >= "0.2.1") && ($_CONFIG['bonus_login_yn'] == "Y")) { // Update last login if far enougth away $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET last_login=UNIX_TIMESTAMP() diff --git a/inc/modules/guest/what-login.php b/inc/modules/guest/what-login.php index 0e74a953e3..fc66b24708 100644 --- a/inc/modules/guest/what-login.php +++ b/inc/modules/guest/what-login.php @@ -133,7 +133,8 @@ if (IS_MEMBER()) { // Probe for last online timemark $probe = time() - $online; if (!empty($login)) $probe = time() - $login; - if ((GET_EXT_VERSION("bonus") >= "0.2.2") && ($probe >= $_CONFIG['login_timeout'])) { + //if ((GET_EXT_VERSION("bonus") >= "0.2.2") && ($probe >= $_CONFIG['login_timeout'])) { + if (true) { // Add login bonus to user's account $ADD = sprintf(", login_bonus=login_bonus+%s", (float)$_CONFIG['login_bonus'] @@ -192,7 +193,7 @@ if (IS_MEMBER()) { // Cookies not setable! $URL = URL."/modules.php?module=index&what=login&login=".CODE_NO_COOKIES; } - } else { + } elseif (GET_EXT_VERSION("sql_patches") >= "0.4.7") { // Update failture counter SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET login_failtures=login_failtures+1,last_failture=NOW() WHERE userid=%s LIMIT 1", array($uid), __FILE__, __LINE__); diff --git a/inc/modules/login.php b/inc/modules/login.php index 971a7c0309..fcf4e9db9c 100644 --- a/inc/modules/login.php +++ b/inc/modules/login.php @@ -62,12 +62,6 @@ if ($status != "CONFIRMED") { LOAD_URL($URL); } // END - if -// Recheck if he got logged out because bad cookies -if (!IS_MEMBER()) { - $URL = URL."/modules.php?module=index"; - LOAD_URL($URL); -} // END - if - // Load adverstising template define('__MEMBER_ADVERT', LOAD_TEMPLATE("member_banner", true)); diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index b90a230cf3..cedb715f33 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1671,28 +1671,28 @@ WHERE p.userid=%s", array(bigintval($uid)), __FILE__, __LINE__); $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array(bigintval($uid)), __FILE__, __LINE__); } // -function META_DESCRIPTION($mod, $wht) -{ +function META_DESCRIPTION ($mod, $wht) { global $_CONFIG, $DEPTH; - if (($mod != "admin") && ($mod != "login")) - { - // Exclude admin and member's area + + // Exclude admin and member's area + if (($mod != "admin") && ($mod != "login")) { + // Construct dynamic description $DESCR = MAIN_TITLE." ".trim($_CONFIG['title_middle'])." ".ADD_DESCR("guest", "what-".$wht, true); - unset($DEPTH); - OUTPUT_HTML(""); - } + + // Output it directly + OUTPUT_HTML(""); + } // END - if + + // Remove depth + unset($DEPTH); } // -function ADD_JACKPOT($points) -{ +function ADD_JACKPOT($points) { $result = SQL_QUERY("SELECT points FROM "._MYSQL_PREFIX."_jackpot WHERE ok='ok' LIMIT 1", __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 0) - { + if (SQL_NUMROWS($result) == 0) { // Create line $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_jackpot (ok, points) VALUES ('ok','%s')", array($points), __FILE__, __LINE__); - } - else - { + } else { // Free memory SQL_FREERESULT($result); @@ -1702,33 +1702,28 @@ function ADD_JACKPOT($points) } } // -function SUB_JACKPOT($points) -{ +function SUB_JACKPOT($points) { // First failed $ret = "-1"; // Get current points $result = SQL_QUERY("SELECT points FROM "._MYSQL_PREFIX."_jackpot WHERE ok='ok' LIMIT 1", __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 0) - { + if (SQL_NUMROWS($result) == 0) { // Create line - $result = SQL_QUERY("INSERT INTO "._MYSQL_PREFIX."_jackpot (ok, points) VALUES ('ok', 0.00000)", __FILE__, __LINE__); - } - else - { - // Free memory - SQL_FREERESULT($result); - + SQL_QUERY("INSERT INTO "._MYSQL_PREFIX."_jackpot (ok, points) VALUES ('ok', 0.00000)", __FILE__, __LINE__); + } else { // Read points list($jackpot) = SQL_FETCHROW($result); - if ($jackpot >= $points) - { + if ($jackpot >= $points) { // Update points when there are enougth points in jackpot - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_jackpot SET points=points-%s WHERE ok='ok' LIMIT 1", + SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_jackpot SET points=points-%s WHERE ok='ok' LIMIT 1", array($points), __FILE__, __LINE__); $ret = $jackpot - $points; - } + } // END - if } + + // Free memory + SQL_FREERESULT($result); } // function IS_DEMO() { @@ -1796,8 +1791,7 @@ function GET_WHAT($modCheck) { return $wht; } // -function MODULE_HAS_MENU($mod, $forceDb = false) -{ +function MODULE_HAS_MENU($mod, $forceDb = false) { global $cacheArray, $_CONFIG; // All is false by default -- 2.30.2