Файл: captcha.php
Строк: 16
<?php
session_start();
    $string = '';
    
    for ($i = 0; $i < 5; $i++) {
        // this numbers refer to numbers of the ascii table (lower case)
        $string .= chr(rand(97, 122));
    }
    
    $_SESSION['rand_code'] = $string;
    
    $_SESSION['captcha_time'] = time() + 600;    
  
    $dir = 'fonts/';
    
    $image = imagecreatetruecolor(100, 60);
    $black = imagecolorallocate($image, 0, 0, 0);
    $color = imagecolorallocate($image, 200, 100, 90); // red
    $white = imagecolorallocate($image, 255, 255, 255);
    
    imagefilledrectangle($image,0,0,399,99,$white);
    imagettftext ($image, 20, 0, 10, 40, $color, $dir."arial.ttf", $_SESSION['rand_code']);
    
    header("Content-type: image/png");
    imagepng($image);
?>