aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2011-06-05 03:22:09 +0200
committerNils Adermann <naderman@naderman.de>2011-06-05 03:22:09 +0200
commit893d0ae96f4fba26a10b909d39abe952601bca41 (patch)
treedc9a81f1ee6f492c7c70cbf5aa02c75a5761e0fa /phpBB/includes
parentffc137986fa9ba91ebc4bc203c7081409d46c44c (diff)
parent18daf6345f64e59f651c43a3150d9e139ac2a4cc (diff)
downloadforums-893d0ae96f4fba26a10b909d39abe952601bca41.tar
forums-893d0ae96f4fba26a10b909d39abe952601bca41.tar.gz
forums-893d0ae96f4fba26a10b909d39abe952601bca41.tar.bz2
forums-893d0ae96f4fba26a10b909d39abe952601bca41.tar.xz
forums-893d0ae96f4fba26a10b909d39abe952601bca41.zip
Merge branch 'ticket/bantu/10042' into develop-olympus
* ticket/bantu/10042: [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.
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/captcha/captcha_gd.php2
-rw-r--r--phpBB/includes/functions.php16
2 files changed, 17 insertions, 1 deletions
diff --git a/phpBB/includes/captcha/captcha_gd.php b/phpBB/includes/captcha/captcha_gd.php
index 5f24618aab..ecdad43978 100644
--- a/phpBB/includes/captcha/captcha_gd.php
+++ b/phpBB/includes/captcha/captcha_gd.php
@@ -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];
}
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 2d9d2c225f..c48eb6d102 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -250,6 +250,22 @@ function unique_id($extra = 'c')
}
/**
+* 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
*
* @param int $value filesize in bytes