1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

Merge branch 'develop-olympus' into develop

* develop-olympus:
  [ticket/10042] GD CAPTCHA: Call phpbb_mt_rand() where required.
  [ticket/10042] GD CAPTCHA: Round offset to the next pixel.
  [ticket/10042] Add mt_rand() wrapper which allows swapping $min and $max.
This commit is contained in:
Nils Adermann
2011-06-05 03:22:40 +02:00
3 changed files with 63 additions and 1 deletions

View File

@@ -77,7 +77,7 @@ class captcha
{
$denom = ($code_len - $i);
$denom = max(1.3, $denom);
$offset[$i] = mt_rand(0, (1.5 * $width_avail) / $denom);
$offset[$i] = phpbb_mt_rand(0, (int) round((1.5 * $width_avail) / $denom));
$width_avail -= $offset[$i];
}

View File

@@ -190,6 +190,22 @@ function unique_id($extra = 'c')
return substr($val, 4, 16);
}
/**
* Wrapper for mt_rand() which allows swapping $min and $max parameters.
*
* PHP does not allow us to swap the order of the arguments for mt_rand() anymore.
* (since PHP 5.3.4, see http://bugs.php.net/46587)
*
* @param int $min Lowest value to be returned
* @param int $max Highest value to be returned
*
* @return int Random integer between $min and $max (or $max and $min)
*/
function phpbb_mt_rand($min, $max)
{
return ($min > $max) ? mt_rand($max, $min) : mt_rand($min, $max);
}
/**
* Return formatted string for filesizes
*