Exemplo n.º 1
0
 function makeCaptcha()
 {
     $imagelength = $this->Length * 25 + 16;
     $imageheight = 75;
     $image = imagecreate($imagelength, $imageheight);
     //$bgcolor     = imagecolorallocate($image, 222, 222, 222);
     $bgcolor = imagecolorallocate($image, 255, 255, 255);
     $stringcolor = imagecolorallocate($image, 0, 0, 0);
     $filter = new filters();
     $funcnumber = rand(0, 1);
     switch ($funcnumber) {
         case 0:
             $randcellno = rand(2, 7);
             $filter->signs($image, $this->getRandFont(), $randcellno);
             break;
         case 1:
             $randruns = rand(10, 30);
             $filter->noise($image, $randruns);
             break;
         case 2:
         default:
             $randblurradius = rand(8, 20);
             $filter->blur($image, 15);
             break;
     }
     for ($i = 0; $i < strlen($this->CaptchaString); $i++) {
         imagettftext($image, 25, mt_rand(-15, 15), $i * 25 + 10, mt_rand(30, 70), $stringcolor, $this->getRandFont(), $this->CaptchaString[$i]);
     }
     //$filter->noise($image, 10);
     //$filter->blur($image, 6);
     $captchaImageFolder = "{$this->sourceFolder}/{$this->uploadFolder}/temp";
     // exec('find "'.$captchaImageFolder.'" -maxdepth 1 -type 5 -mmin +60 | xargs -0 /bin/rm -f');
     $captchaImageFile = scandir($captchaImageFolder, 1);
     if (count($captchaImageFile) <= 1) {
         $captchaImageFile[0] = '000000.png';
     }
     $captchaImageFile = substr($captchaImageFile[0], 0, strrpos($captchaImageFile[0], '.'));
     $captchaImageFile++;
     $captchaImageFile = str_pad($captchaImageFile, 6, '0', STR_PAD_LEFT) . '.png';
     $this->captchaImageUrl = "{$this->urlRequestRoot}/{$this->cmsFolder}/{$this->uploadFolder}/temp/{$captchaImageFile}";
     imagepng($image, $captchaImageFolder . '/' . $captchaImageFile);
     imagedestroy($image);
 }
Exemplo n.º 2
0
 function makeCaptcha()
 {
     $imagelength = $this->Length * 25 + 16;
     $imageheight = 75;
     $image = imagecreate($imagelength, $imageheight);
     //$bgcolor     = imagecolorallocate($image, 222, 222, 222);
     $bgcolor = imagecolorallocate($image, 255, 255, 255);
     $stringcolor = imagecolorallocate($image, 0, 0, 0);
     $filter = new filters();
     $filter->signs($image, $this->getRandFont());
     for ($i = 0; $i < strlen($this->CaptchaString); $i++) {
         imagettftext($image, 25, mt_rand(-15, 15), $i * 25 + 10, mt_rand(30, 70), $stringcolor, $this->getRandFont(), $this->CaptchaString[$i]);
     }
     $filter->noise($image, 10);
     $filter->blur($image, 1);
     imagepng($image);
     imagedestroy($image);
 }