Since Wernis API 0.6-BETA SHA256 is the default now
authorRoland Häder <roland@mxchange.org>
Sat, 4 May 2013 01:14:19 +0000 (01:14 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 4 May 2013 01:14:19 +0000 (01:14 +0000)
inc/extensions/ext-wernis.php
inc/functions.php
inc/modules/admin/what-config_wernis.php
inc/modules/member/what-wernis.php

index 82065eb..19a01bc 100644 (file)
@@ -41,10 +41,10 @@ if (!defined('__SECURITY')) {
 } // END - if
 
 // Version of this extension
-setThisExtensionVersion('0.0.5');
+setThisExtensionVersion('0.0.6');
 
 // Version history array (add more with , '0.0.1' and so on)
-setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5'));
+setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6'));
 
 switch (getExtensionMode()) {
        case 'setup': // Do stuff when installation is running
@@ -152,6 +152,13 @@ INDEX (`userid`)",
                                // Update notes
                                setExtensionUpdateNotes("IN/OUT ersetzt mit WITHDRAW/PAYOUT.");
                                break;
+
+                       case '0.0.6': // SQL queries for v0.0.6
+                               addExtensionChangeTableColumnSql('config', 'wernis_pass_md5', 'wernis_pass_md5', " VARCHAR(255) NOT NULL DEFAULT ''");
+
+                               // Update notes
+                               setExtensionUpdateNotes("Es wird seit API-Version 0.6-BETA SHA256 (hexadezimal kodiert) verwendet.");
+                               break;
                } // END - switch
                break;
 
index 9060a90..ba5c096 100644 (file)
@@ -2694,6 +2694,22 @@ function convertCharsetToUtf8 ($str, $charset) {
        return $str;
 }
 
+// Hash string with SHA256 and encode it to hex
+function hashSha256 ($str) {
+       /// Hash string
+       $hash = mhash(MHASH_SHA256, $str);
+
+       // Encode it to hexadecimal
+       $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))));
+       } // END - if
+
+       // Return it
+       return $hex;
+}
+
 // ----------------------------------------------------------------------------
 //              "Translatation" functions for points_data table
 // ----------------------------------------------------------------------------
index 5651735..7477040 100644 (file)
@@ -55,7 +55,7 @@ if (isFormSent('save_config')) {
                } // END - if
 
                // Hash the password and remove clear-text
-               setPostRequestElement('wernis_pass_md5', md5(postRequestElement('wernis_pass')));
+               setPostRequestElement('wernis_pass_md5', hashSha256(postRequestElement('wernis_pass')));
                unsetPostRequestElement('wernis_pass');
 
                // Save settings
index 401e858..eec5f13 100644 (file)
@@ -172,7 +172,7 @@ if ((isFormSent()) && (isGetRequestElementSet('do'))) {
                                        displayMessage('{--MEMBER_WERNIS_WITHDRAW_AMOUNT_SMALLER_MIN--}');
                                } else {
                                        // All is fine here so do the withdraw
-                                       $success = WERNIS_EXECUTE_WITHDRAW(postRequestElement('wernis_userid'), md5(postRequestElement('wds66_password')), postRequestElement('amount'));
+                                       $success = WERNIS_EXECUTE_WITHDRAW(postRequestElement('wernis_userid'), hashSha256(postRequestElement('wds66_password')), postRequestElement('amount'));
                                        if ($success === TRUE) {
                                                // Add it to this amount
                                                initReferralSystem();