19,22c19,31
< 
<   // Get solution (the code to show).
<   $code = db_result(db_query("SELECT solution FROM {captcha_sessions} WHERE csid = %d", (int)($captcha_sid)));
< 
---
>   if($_GET['r']) {
>     $allowed_chars = _image_captcha_utf8_split(variable_get('image_captcha_image_allowed_chars', IMAGE_CAPTCHA_ALLOWED_CHARACTERS));
>     $code_length = (int)variable_get('image_captcha_code_length', 5);
>     $code = '';
>     for ($i = 0; $i < $code_length; $i++) {
>       $code .= $allowed_chars[array_rand($allowed_chars)];
>     }
>     db_query('UPDATE {captcha_sessions} set solution = "%s" WHERE csid = %d', $code, (int)($captcha_sid));
>   } else {
>     // Get solution (the code to show).
>     $code = db_result(db_query("SELECT solution FROM {captcha_sessions} WHERE csid = %d", (int)($captcha_sid)));
>   }
>   
