Вход Регистрация
Файл: include/captcha.php
Строк: 46
<?php
include("config.php");

class 
CaptchaSecurityImages {

    var 
$font 'fonts/monofont.ttf';

    function 
generateCode($characters) {
        
$possible '23456789bcdfghjkmnpqrstvwxyz';
        
$code '';
        
$i 0;
        while (
$i $characters) { 
            
$code .= substr($possiblemt_rand(0strlen($possible)-1), 1);
            
$i++;
        }
        return 
$code;
    }

    function 
CaptchaSecurityImages($width='200',$height='40',$characters='6') {
        
$code $this->generateCode($characters);
        
$font_size $height 0.75;
        
$image = @imagecreate($width$height) or die('Cannot initialize new GD image stream');
        
$background_color imagecolorallocate($image255255255);
        
$text_color imagecolorallocate($image137136136);
        
$noise_color imagecolorallocate($image166165165);
        for( 
$i=0$i<3$i++ ) {
            
imagefilledellipse($imagemt_rand(0,$width), mt_rand(0,$height), 11$noise_color);
        }
        for( 
$i=0$i<5$i++ ) {
            
imageline($imagemt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
        }
        
$textbox imagettfbbox($font_size0$this->font$code) or die('Error in imagettfbbox function');
        
$x = ($width $textbox[4])/2;
        
$y = ($height $textbox[5])/2;
        
imagettftext($image$font_size0$x$y$text_color$this->font $code) or die('Error in imagettftext function');
        
header('Content-Type: image/jpeg');
        
imagejpeg($image);
        
imagedestroy($image);
        
$_SESSION['imagecode'] = $code;
    }

}

$width = isset($_GET['width']) ? $_GET['width'] : '200';
$height = isset($_GET['height']) ? $_GET['height'] : '40';
$characters = isset($_GET['characters']) && $_GET['characters'] > $_GET['characters'] : '6';

$captcha = new CaptchaSecurityImages($width,$height,$characters);

?>
Онлайн: 4
Реклама