Some fixes:
authorRoland Häder <roland@mxchange.org>
Mon, 29 Jul 2013 22:47:06 +0000 (22:47 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 29 Jul 2013 22:47:06 +0000 (22:47 +0000)
- added default value for optional parameter (better understanding)
- some double quotes converted to single
- fixes for Wernis API

inc/extensions/bonus/mode-update.php
inc/functions.php
inc/http-functions.php
inc/libs/wernis_functions.php
inc/modules/admin/what-config_wernis.php
inc/modules/admin/what-list_beg.php
inc/modules/admin/what-list_bonus.php
inc/modules/member/what-wernis.php
inc/template-functions.php

index 8c9997f2ff59dd88c3e752a26b4ff2b49c8c51bd..49a882a0817c42ad904f6411855ddbd6fc2df13a 100644 (file)
@@ -292,7 +292,7 @@ INDEX `userid` (`userid`)",
 
                        case '0.5.6': // SQL queries for v0.5.6
                                // Get current month
 
                        case '0.5.6': // SQL queries for v0.5.6
                                // Get current month
-                               $curr = padLeftZero(getMonth());
+                               $curr = padLeftZero(getMonth(), 2);
                                if ($curr == '00') $curr = '12';
 
                                // Generate timemark...
                                if ($curr == '00') $curr = '12';
 
                                // Generate timemark...
index c2c7101ca977981f92489ee40ecb729fcd6de7e5..1054326b7870dc11b961c847297fc0996220dba6 100644 (file)
@@ -939,7 +939,7 @@ function encodeHashForCookie ($passHash) {
 
                        $mod = substr($mod, 0, 2);
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'idx=' . $idx . ',part1=' . $part1 . '/part2=' . $part2 . '/mod=' . $mod . '(' . strlen($mod) . ')');
 
                        $mod = substr($mod, 0, 2);
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'idx=' . $idx . ',part1=' . $part1 . '/part2=' . $part2 . '/mod=' . $mod . '(' . strlen($mod) . ')');
-                       $mod = padLeftZero($mod);
+                       $mod = padLeftZero($mod, 2);
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'mod(' . ($idx * 2) . ')=' . $mod . '*');
                        $start += 2;
                        $newHash .= $mod;
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'mod(' . ($idx * 2) . ')=' . $mod . '*');
                        $start += 2;
                        $newHash .= $mod;
@@ -2724,7 +2724,7 @@ function hashSha256 ($str) {
        $hex = '';
        for ($i = 0; $i < strlen($hash); $i++) {
                // Encode char to decimal, pad it with zero, add it
        $hex = '';
        for ($i = 0; $i < strlen($hash); $i++) {
                // Encode char to decimal, pad it with zero, add it
-               $hex .= padLeftZero(dechex(ord(substr($hash, $i, 1))));
+               $hex .= padLeftZero(dechex(ord(substr($hash, $i, 1))), 2);
        } // END - if
 
        // Return it
        } // END - if
 
        // Return it
index 4fc66c95a5a94a4850f1af9106d3a284b9e34ace..1dea0788ec2734f9658e0a8a49b561c78070c289 100644 (file)
@@ -278,7 +278,7 @@ function sendHttpPostRequest ($baseUrl, $requestData = array(), $removeHeader =
        $body = http_build_query($requestData, '', '&');
 
        // Generate POST request header
        $body = http_build_query($requestData, '', '&');
 
        // Generate POST request header
-       $request  = 'POST ' . (isProxyUsed() === TRUE ? $baseUrl : '') . trim($baseUrl) . ' HTTP/1.0' . getConfig('HTTP_EOL');
+       $request  = 'POST ' . (isProxyUsed() === TRUE ? $getUrl : '') . trim($getUrl) . ' HTTP/1.0' . getConfig('HTTP_EOL');
        $request .= 'Host: ' . $host . getConfig('HTTP_EOL');
        $request .= 'Referer: ' . getUrl() . '/admin.php' . getConfig('HTTP_EOL');
        if (isConfigEntrySet('FULL_VERSION')) {
        $request .= 'Host: ' . $host . getConfig('HTTP_EOL');
        $request .= 'Referer: ' . getUrl() . '/admin.php' . getConfig('HTTP_EOL');
        if (isConfigEntrySet('FULL_VERSION')) {
index 0868db2f3d48c51182f8bda817e5a41cde43531a..b7c369d21b62051ff9bc65b9659ade678af95121 100644 (file)
@@ -190,7 +190,7 @@ function WERNIS_SEND_REQUEST ($scriptName, $requestData = array()) {
                                break;
 
                        default: // Unknown error (maybe new?)
                                break;
 
                        default: // Unknown error (maybe new?)
-                               logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown error %s from WDS66 API received.", $data[1]));
+                               logDebugMessage(__FUNCTION__, __LINE__, sprintf('Unknown error %s from WDS66 API received.', $data[1]));
                                $return = array(
                                        'status'  => 'request_failed',
                                        'message' => '{%message,WERNIS_API_REQUEST_FAILED=' . $data[1] . '%}'
                                $return = array(
                                        'status'  => 'request_failed',
                                        'message' => '{%message,WERNIS_API_REQUEST_FAILED=' . $data[1] . '%}'
@@ -211,11 +211,20 @@ function WERNIS_SEND_REQUEST ($scriptName, $requestData = array()) {
 
 // Tests the function by calling balance.php on the API
 function WERNIS_TEST_API () {
 
 // Tests the function by calling balance.php on the API
 function WERNIS_TEST_API () {
+       // Only as admin
+       assert(isAdmin());
+
        // Result is always failed
        $result = FALSE;
 
        // Result is always failed
        $result = FALSE;
 
+       // Prepare the request data
+       $requestData = array(
+               't_uid'       => getWernisRefid(),
+               't_md5'       => getWernisPassMd5()
+       );
+
        // Return the result from the lower functions
        // Return the result from the lower functions
-       $return = WERNIS_SEND_REQUEST('balance.php');
+       $return = WERNIS_SEND_REQUEST('balance.php', $requestData);
 
        // Did it went smoothly?
        if ($return['status'] == 'OK') {
 
        // Did it went smoothly?
        if ($return['status'] == 'OK') {
index 74770402dc4b7b16bc3ddcebafa981a62558597b..7acf89891c3005189802e1f4a4ec270992c34425 100644 (file)
@@ -44,6 +44,9 @@ if ((!defined('__SECURITY')) || (!isAdmin())) {
 addYouAreHereLink('admin', __FILE__);
 
 if (isFormSent('save_config')) {
 addYouAreHereLink('admin', __FILE__);
 
 if (isFormSent('save_config')) {
+       // Hash the password and remove clear-text
+       setPostRequestElement('wernis_pass_md5', hashSha256(postRequestElement('wernis_pass')));
+
        // First merge temporarily the new API data into the current config
        mergeConfig(postRequestArray());
 
        // First merge temporarily the new API data into the current config
        mergeConfig(postRequestArray());
 
@@ -54,8 +57,7 @@ if (isFormSent('save_config')) {
                        setPostRequestElement('wernis_' . $revert, postRequestElement('wernis_' . $revert));
                } // END - if
 
                        setPostRequestElement('wernis_' . $revert, postRequestElement('wernis_' . $revert));
                } // END - if
 
-               // Hash the password and remove clear-text
-               setPostRequestElement('wernis_pass_md5', hashSha256(postRequestElement('wernis_pass')));
+               // Remove clear password
                unsetPostRequestElement('wernis_pass');
 
                // Save settings
                unsetPostRequestElement('wernis_pass');
 
                // Save settings
index 7f2e2f06f903d4c87743c886bb57f50fb98341a7..14f786730acc480e6a60783cc5b92f87bd4d0928 100644 (file)
@@ -47,7 +47,7 @@ if (isBegRallyeEnabled()) {
        // Shall I withdraw now?
        if (isPostRequestElementSet('withdraw')) {
                // Okay, let's prepare...
        // Shall I withdraw now?
        if (isPostRequestElementSet('withdraw')) {
                // Okay, let's prepare...
-               $curr = padLeftZero(getMonth() - 1);
+               $curr = padLeftZero(getMonth() - 1, 2);
                updateConfiguration('last_monthly', $curr);
                displayMessage('{--ADMIN_BEG_WITHDRAW_PREPARED--}');
        } // END - if
                updateConfiguration('last_monthly', $curr);
                displayMessage('{--ADMIN_BEG_WITHDRAW_PREPARED--}');
        } // END - if
index 0d49bf5e94f441a8f43e16621a25bc868472fbb7..a9c155c40c1770aefb44d31a0970558133d4a292 100644 (file)
@@ -47,7 +47,7 @@ if (isBonusRallyeActive()) {
        // Shall I withdraw now?
        if (isPostRequestElementSet('withdraw')) {
                // Okay, let's prepare...
        // Shall I withdraw now?
        if (isPostRequestElementSet('withdraw')) {
                // Okay, let's prepare...
-               $curr = padLeftZero(getMonth() - 1);
+               $curr = padLeftZero(getMonth() - 1, 2);
                updateConfiguration('last_monthly', $curr);
                displayMessage('{--ADMIN_BONUS_WITHDRAW_PREPARED--}');
        } // END - if
                updateConfiguration('last_monthly', $curr);
                displayMessage('{--ADMIN_BONUS_WITHDRAW_PREPARED--}');
        } // END - if
index eec5f133092647c14faaa5d42d33ab7ec0ee4fbb..b5d5e31cfdd861dd8b5788196d7130e0ba4cb566 100644 (file)
@@ -179,7 +179,7 @@ if ((isFormSent()) && (isGetRequestElementSet('do'))) {
                                                addPointsThroughReferralSystem('wernis_withdraw', getMemberId(), bigintval(postRequestElement('amount')));
 
                                                // Update the user data as well..
                                                addPointsThroughReferralSystem('wernis_withdraw', getMemberId(), bigintval(postRequestElement('amount')));
 
                                                // Update the user data as well..
-                                               sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `wernis_userid`=%s WHERE `userid`=%s LIMIT 1",
+                                               sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `wernis_userid`=%s WHERE `userid`=%s LIMIT 1',
                                                        array(bigintval(postRequestElement('wernis_userid')), getMemberId()), __FILE__, __LINE__);
 
                                                // All done!
                                                        array(bigintval(postRequestElement('wernis_userid')), getMemberId()), __FILE__, __LINE__);
 
                                                // All done!
@@ -210,7 +210,7 @@ if ((isFormSent()) && (isGetRequestElementSet('do'))) {
                                                subtractPoints('wernis_payout', getMemberId(), postRequestElement('amount'));
 
                                                // Update WDS66 id
                                                subtractPoints('wernis_payout', getMemberId(), postRequestElement('amount'));
 
                                                // Update WDS66 id
-                                               sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `wernis_userid`=%s WHERE `userid`=%s LIMIT 1",
+                                               sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `wernis_userid`=%s WHERE `userid`=%s LIMIT 1',
                                                        array(bigintval(postRequestElement('wernis_userid')), getMemberId()), __FILE__, __LINE__);
 
                                                // All done!
                                                        array(bigintval(postRequestElement('wernis_userid')), getMemberId()), __FILE__, __LINE__);
 
                                                // All done!
@@ -227,7 +227,7 @@ if ((isFormSent()) && (isGetRequestElementSet('do'))) {
                                break;
 
                        default: // Invalid mode!
                                break;
 
                        default: // Invalid mode!
-                               logDebugMessage(__FILE__, __LINE__, sprintf("Invalid mode %s detected.", getRequestElement('do')));
+                               logDebugMessage(__FILE__, __LINE__, sprintf('Invalid mode %s detected.', getRequestElement('do')));
                                displayMessage('{%message,MEMBER_WERNIS_MODE_INVALID=' . getRequestElement('do') . '%}');
                                return;
                } // END - switch
                                displayMessage('{%message,MEMBER_WERNIS_MODE_INVALID=' . getRequestElement('do') . '%}');
                                return;
                } // END - switch
@@ -235,7 +235,7 @@ if ((isFormSent()) && (isGetRequestElementSet('do'))) {
 } // END - if
 
 // Prepare mode for template name
 } // END - if
 
 // Prepare mode for template name
-$mode = sprintf("member_wernis_mode_%s", getRequestElement('do'));
+$mode = sprintf('member_wernis_mode_%s', getRequestElement('do'));
 
 // Load the template
 loadTemplate($mode, FALSE, $content);
 
 // Load the template
 loadTemplate($mode, FALSE, $content);
index 73bf31ae009e71fa23b505936d955bfd040e798f..d3419dd80a2ef8225d38de21ac3ca35e3552bfe1 100644 (file)
@@ -859,7 +859,7 @@ function addSelectionBox ($type, $default, $prefix = '', $id = NULL, $class = 'f
 
                case 'ho': // Hours
                        for ($idx = 0; $idx <= 23; $idx++) {
 
                case 'ho': // Hours
                        for ($idx = 0; $idx <= 23; $idx++) {
-                               $padded = padLeftZero($idx);
+                               $padded = padLeftZero($idx, 2);
                                $OUT .= '<option value="' . $padded . '"';
                                if ($default == $padded) $OUT .= ' selected="selected"';
                                $OUT .= '>' . $padded . '</option>';
                                $OUT .= '<option value="' . $padded . '"';
                                if ($default == $padded) $OUT .= ' selected="selected"';
                                $OUT .= '>' . $padded . '</option>';
@@ -869,7 +869,7 @@ function addSelectionBox ($type, $default, $prefix = '', $id = NULL, $class = 'f
                case 'mi': // Minutes
                case 'se': // Seconds
                        for ($idx = 0; $idx <= 59; $idx+=5) {
                case 'mi': // Minutes
                case 'se': // Seconds
                        for ($idx = 0; $idx <= 59; $idx+=5) {
-                               $padded = padLeftZero($idx);
+                               $padded = padLeftZero($idx, 2);
                                $OUT .= '<option value="' . $padded . '"';
                                if ($default == $padded) $OUT .= ' selected="selected"';
                                $OUT .= '>' . $padded . '</option>';
                                $OUT .= '<option value="' . $padded . '"';
                                if ($default == $padded) $OUT .= ' selected="selected"';
                                $OUT .= '>' . $padded . '</option>';