From 13729dac930d0e56d607499f26aeb9f08795e65c Mon Sep 17 00:00:00 2001 From: "Fedor A. Fetisov" Date: Fri, 13 Sep 2013 22:56:01 +0400 Subject: [PATCH] Improve generation of CAPTCHA images --- src/messenger/webim/libs/captcha.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/messenger/webim/libs/captcha.php b/src/messenger/webim/libs/captcha.php index aa0f63e8..9fbffc12 100644 --- a/src/messenger/webim/libs/captcha.php +++ b/src/messenger/webim/libs/captcha.php @@ -22,8 +22,12 @@ function can_show_captcha() function gen_captcha() { - $md5_hash = md5(rand(0, 9999)); - return substr($md5_hash, 15, 5); + $symbols = 'abcdefghijkmnpqrstuvwxyz123456789'; + $string = ''; + for ($i = 0; $i < 5; $i++) { + $string .= substr($symbols, mt_rand(0, strlen($symbols)), 1); + } + return $string; } function draw_captcha($security_code)