config->public_dir . 'font/PTF55F.ttf', $app->config->public_dir . 'font/PTF56F.ttf', $app->config->public_dir . 'font/PTF75F.ttf', $app->config->public_dir . 'font/PTF76F.ttf', $app->config->public_dir . 'font/PTZ55F.ttf', $app->config->public_dir . 'font/PTZ56F.ttf', ]; $fontsize_base = 36;// размер текста $image = imagecreatefrompng($app->config->public_dir . 'image/CAPTCHA_' . rand(0,4) .'.png'); $captcha = ''; for ($i = 0; $i < $length; $i++) { $fontsize = rand($fontsize_base - 2, $fontsize_base + 2) ; $captcha .= $letters[ rand(0, strlen($letters)-1) ]; $x = ($i + 1) * ($fontsize + 5 ); $x = rand($x, $x+6); $y = $height - ( ($height - $fontsize) / 2 ) + rand(-8,16); $curcolor = imagecolorallocate( $image, rand(50, 127), rand(0, 127), rand(0, 127) ); //шум imageellipse($image, rand($x - 32 ,$x + 32), $y, rand(16,32), rand(16,52), $curcolor); imageellipse($image, $x, rand($y - 16 ,$y + 16), rand(16,52), rand(16,32), $curcolor); $angle = rand(-25, 25); imagettftext($image, $fontsize, $angle, $x, $y, $curcolor, $fonts_arr[rand(0,5)], $captcha[$i]); } ob_start(); imagepng($image); $image_data = ob_get_contents(); ob_end_clean(); $_SESSION['CAPTCHA'] = $captcha; return $image_data; } }