From: Roland Häder Date: Sat, 13 Sep 2008 19:31:00 +0000 (+0000) Subject: Fix for surfbar if code length is zero X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2ed1fa148954934a37ce31342c90cb2d90b80ecd;p=mailer.git Fix for surfbar if code length is zero --- diff --git a/inc/databases.php b/inc/databases.php index fd7d2aa703..74de24b765 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -114,7 +114,7 @@ define('USAGE_BASE', "usage"); define('SERVER_URL', "http://www.mxchange.org"); // This current patch level -define('CURR_SVN_REVISION', "323"); +define('CURR_SVN_REVISION', "324"); // Take a prime number which is long (if you know a longer one please try it out!) define('_PRIME', 591623); diff --git a/inc/functions.php b/inc/functions.php index d9a2388fcb..59e8c8c4a9 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1182,6 +1182,7 @@ function GEN_RANDOM_CODE($length, $code, $uid, $DATA="") { // At least 10 numbers shall be secure enought! $len = $_CONFIG['code_length']; + if ($len == 0) $len = $length; if ($len == 0) $len = 10; // Cut off requested counts of number diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 8b491c650a..3ca9d415d7 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -450,9 +450,18 @@ LIMIT %s", function SURFBAR_GENERATE_VALIDATION_CODE ($id, $salt="") { global $_CONFIG, $SURFBAR_CACHE; + // @TODO Invalid salt should be refused + $SURFBAR_CACHE['salt'] = "INVALID"; + + // Get code length from config + $length = $_CONFIG['code_length']; + + // Fix length to 10 + if ($length == 0) $length = 10; + // Generate a code until the length matches $valCode = ""; - while (strlen($valCode) != $_CONFIG['code_length']) { + while (strlen($valCode) != $length) { // Is the salt set? if (empty($salt)) { // Generate random hashed string @@ -465,7 +474,7 @@ function SURFBAR_GENERATE_VALIDATION_CODE ($id, $salt="") { } // ... and now the validation code - $valCode = GEN_RANDOM_CODE($_CONFIG['code_length'], sha1(SURFBAR_GET_SALT().":".$id), $GLOBALS['userid']); + $valCode = GEN_RANDOM_CODE($length, sha1(SURFBAR_GET_SALT().":".$id), $GLOBALS['userid']); //DEBUG_LOG(__FUNCTION__.":valCode={$valCode}"); } // END - while