From: quix0r Date: Thu, 30 Jun 2011 04:43:45 +0000 (+0000) Subject: Code cleanups, ext-booking continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=45a7bbc7a021845fee5f9c0fdb252f09d47e6bfb;p=mailer.git Code cleanups, ext-booking continued: - Extension ext-booking: Renamed configuration and ENUM types should have all-uppercase values - Some code cleanups - TODOs.txt updated --- diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index d4ee60e4ef..4f50e24e6b 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -91,9 +91,9 @@ ./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: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/user_functions.php:354: // @TODO Make this filter working: $url = runFilterChain('do_login', array('content' => $content, 'addon' => $ADDON)); +./inc/libs/user_functions.php:432: // @TODO We should try to rewrite this to fetchUserData() somehow +./inc/libs/user_functions.php:620: // @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 * diff --git a/doubler.php b/doubler.php index 403009eb18..16aceb6e3e 100644 --- a/doubler.php +++ b/doubler.php @@ -98,12 +98,13 @@ if (isFormSent()) { // So let's continue with probing his points amount if (($points - getConfig('doubler_left') - postRequestParameter('points') * getConfig('doubler_charge') / 100) >= 0) { // Enough points are left so let's continue with the doubling process - // Create doubling "account" width *DOUBLED* points - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_doubler` (`userid`, `refid`, `points`, `remote_ip`, `timemark`, `completed`, `is_ref`) VALUES ('%s','%s','%s','".detectRemoteAddr()."', UNIX_TIMESTAMP(), 'N','N')", + // Create doubling "account" with *DOUBLED* points + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_doubler` (`userid`, `refid`, `points`, `remote_ip`, `timemark`, `completed`, `is_ref`) VALUES (%s,%s,%s,'%s', UNIX_TIMESTAMP(), 'N','N')", array( getUserData('userid'), makeDatabaseUserId(determineReferalId()), - bigintval(postRequestParameter('points') * 2) + bigintval(postRequestParameter('points') * 2), + detectRemoteAddr() ), __FILE__, __LINE__); // Subtract entered points @@ -117,10 +118,11 @@ if (isFormSent()) { // Add second line for the referal but only when userid != refid if ((isValidUserId(determineReferalId())) && (determineReferalId() != getUserData('userid'))) { // Okay add a refid line and apply refid percents - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_doubler` (`userid`, `refid`, `points`, `remote_ip`, `timemark`, `completed`, `is_ref`) VALUES ('%s',0,'%s','".detectRemoteAddr()."',UNIX_TIMESTAMP(),'N','Y')", + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_doubler` (`userid`, `refid`, `points`, `remote_ip`, `timemark`, `completed`, `is_ref`) VALUES (%s,0,%s,'%s',UNIX_TIMESTAMP(),'N','Y')", array( makeDatabaseUserId(determineReferalId()), - bigintval(postRequestParameter('points') * 2 * getConfig('doubler_ref') / 100) + (postRequestParameter('points') * 2 * getConfig('doubler_ref') / 100), + detectRemoteAddr() ), __FILE__, __LINE__); // And that's why we don't want to you more than one referal level of doubler-points. ^^^ diff --git a/inc/extensions/ext-booking.php b/inc/extensions/ext-booking.php index 20c60dd08f..552ebca478 100644 --- a/inc/extensions/ext-booking.php +++ b/inc/extensions/ext-booking.php @@ -52,7 +52,7 @@ enableExtensionProductive(false); switch (getExtensionMode()) { case 'register': // Do stuff when installation is running // Configuration entries - addConfigAddSql('booking_per_page', 'TINYINT(3) UNSIGNED NOT NULL DEFAULT 10'); + addConfigAddSql('booking_page_count', 'TINYINT(3) UNSIGNED NOT NULL DEFAULT 10'); addConfigAddSql('booking_purge', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT ' . (getOneDay() * 3)); // Drop/create table for user bookings @@ -61,7 +61,7 @@ switch (getExtensionMode()) { `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, `subject` VARCHAR(255) NOT NULL DEFAULT 'missing', -`mode` ENUM('add','sub') NOT NULL DEFAULT 'add', +`mode` ENUM('ADD','SUB') NOT NULL DEFAULT 'add', `points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.0000, `comments` TINYTEXT NULL DEFAULT NULL, `recorded` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, diff --git a/inc/functions.php b/inc/functions.php index f081487413..2a0e1d0530 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -945,7 +945,7 @@ function scrambleString ($str) { // Init $scrambled = ''; - // Final check, in case of failture it will return unscrambled string + // Final check, in case of failure it will return unscrambled string if (strlen($str) > 40) { // The string is to long return $str; diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index 2fcebafc1d..7c23a24163 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -329,18 +329,25 @@ function doUserLogin ($userid, $passwd, $successUrl = '', $errorUrl = 'modules.p // No login bonus by default $GLOBALS['bonus_payed'] = false; - // Probe for last online timemark - $probe = time() - getUserData('last_online'); - if (getUserData('last_login') > 0) $probe = time() - getUserData('last_login'); - - if ((isExtensionInstalledAndNewer('bonus', '0.2.2')) && ($probe >= getConfig('login_timeout'))) { - // Add login bonus to user's account - $add = ', `login_bonus`=`login_bonus`+{?login_bonus?}'; - $GLOBALS['bonus_payed'] = true; - - // Subtract login bonus from userid's account or jackpot - if ((isExtensionInstalledAndNewer('bonus', '0.3.5')) && (getBonusMode() != 'ADD')) { - handleBonusPoints('login_bonus'); + // Is bonus up-to-date? + if (isExtensionInstalledAndNewer('bonus', '0.2.2')) { + // Probe for last online timemark + $probe = time() - getUserData('last_online'); + if (getUserData('last_login') > 0) { + // Use timestamp from last login + $probe = time() - getUserData('last_login'); + } // END - if + + // Is the timeout reached? + if ($probe >= getConfig('login_timeout')) { + // Add login bonus to user's account + $add = ', `login_bonus`=`login_bonus`+{?login_bonus?}'; + $GLOBALS['bonus_payed'] = true; + + // Subtract login bonus from userid's account or jackpot + if ((isExtensionInstalledAndNewer('bonus', '0.3.5')) && (getBonusMode() != 'ADD')) { + handleBonusPoints('login_bonus'); + } // END - if } // END - if } // END - if @@ -379,7 +386,7 @@ function doUserLogin ($userid, $passwd, $successUrl = '', $errorUrl = 'modules.p $errorCode = getCode('COOKIES_DISABLED'); } } elseif (isExtensionInstalledAndNewer('sql_patches', '0.6.1')) { - // Update failture counter + // Update failure counter SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `login_failures`=`login_failures`+1,`last_failure`=NOW() WHERE `userid`=%s LIMIT 1", array($userid), __FUNCTION__, __LINE__); @@ -406,7 +413,9 @@ function doUserLogin ($userid, $passwd, $successUrl = '', $errorUrl = 'modules.p $url = $errorUrl . $errorCode; // Extension set? Then add it as well. - if (!empty($ext)) $url .= '&ext=' . $ext; + if (!empty($ext)) { + $url .= '&ext=' . $ext; + } // END - if } // END - if // Return URL diff --git a/inc/libs/wernis_functions.php b/inc/libs/wernis_functions.php index 46c1250967..3419416228 100644 --- a/inc/libs/wernis_functions.php +++ b/inc/libs/wernis_functions.php @@ -222,7 +222,7 @@ function WERNIS_TEST_API () { // All fine! $result = true; } else { - // Status failture text + // Status failure text WERNIS_STATUS_MESSAGE($return['message'], $return['status']); } @@ -266,7 +266,7 @@ function WERNIS_EXECUTE_WITHDRAW ($wdsId, $userMd5, $amount) { // Log the transfer WERNIS_LOG_TRANSFER($wdsId, $amount, 'IN'); } else { - // Status failture text + // Status failure text WERNIS_STATUS_MESSAGE($return['message'], $return['status']); // Log the transfer @@ -303,7 +303,7 @@ function WERNIS_EXECUTE_PAYOUT ($wdsId, $amount) { // Log the transfer WERNIS_LOG_TRANSFER($wdsId, $amount, 'OUT'); } else { - // Status failture text + // Status failure text WERNIS_STATUS_MESSAGE($return['message'], $return['status']); // Log the transfer