Browse Source

fix ZF-4269

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@16121 44c647ce-9c0f-0410-b52a-842ac1e357ba
stas 16 years ago
parent
commit
b68e4281cb
1 changed files with 6 additions and 0 deletions
  1. 6 0
      library/Zend/Captcha/Image.php

+ 6 - 0
library/Zend/Captcha/Image.php

@@ -420,6 +420,12 @@ class Zend_Captcha_Image extends Zend_Captcha_Word
     public function generate()
     {
         $id = parent::generate();
+        $tries = 5;
+        // If there's already such file, try creating a new ID
+        while($tries-- && file_exists($this->getImgDir() . $id . $this->getSuffix())) {
+        	$id = $this->_generateRandomId();
+        	$this->_setId($id);
+        }
         $this->_generateImage($id, $this->getWord());
 
         if (mt_rand(1, $this->getGcFreq()) == 1) {