Code cleanups, ext-booking continued:
authorRoland Häder <roland@mxchange.org>
Thu, 30 Jun 2011 04:43:45 +0000 (04:43 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 30 Jun 2011 04:43:45 +0000 (04:43 +0000)
- Extension ext-booking: Renamed configuration and ENUM types should have
  all-uppercase values
- Some code cleanups
- TODOs.txt updated

DOCS/TODOs.txt
doubler.php
inc/extensions/ext-booking.php
inc/functions.php
inc/libs/user_functions.php
inc/libs/wernis_functions.php

index d4ee60e..4f50e24 100644 (file)
@@ -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                                        *
index 403009e..16aceb6 100644 (file)
@@ -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. ^^^
index 20c60dd..552ebca 100644 (file)
@@ -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,
index f081487..2a0e1d0 100644 (file)
@@ -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;
index 2fcebaf..7c23a24 100644 (file)
@@ -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 .= '&amp;ext=' . $ext;
+               if (!empty($ext)) {
+                       $url .= '&amp;ext=' . $ext;
+               } // END - if
        } // END - if
 
        // Return URL
index 46c1250..3419416 100644 (file)
@@ -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