Вход Регистрация
Файл: system/helpers/captcha.php
Строк: 30
<?php

function captcha()
{
    
$fontFile THEME 'fonts/captcha.otf';
    
$fontSize 24;
    
$height 50;
    
$width 160;

    do 
    {
        
$code substr(str_shuffle(str_repeat('1234567890'3)), 0mt_rand(35));
    } 
    while (
preg_match('/cp|cb|ck|c6|c9|rn|rm|mm|co|do|cl|db|qp|qb|dp|ww/'$code));

    
$image imagecreatetruecolor($width$height);

    
imagesavealpha($imagetrue);
    
imagefill($image00imagecolorallocatealpha($image000127));

    
$text str_split($code);
    
$len count($text);

    for (
$i 0$i $len$i++) 
    {
        
$angle mt_rand(-1010);
        
$x = ($width $fontSize) / $len $i + ($fontSize 2);
        
$x mt_rand($x$x 5);
        
$y $height - (($height $fontSize) / 2);
        
$color imagecolorallocatealpha($imagemt_rand(0100), mt_rand(0100), mt_rand(0100), mt_rand(2040));

         
imagettftext($image$fontSize$angle$x$y$color$fontFile$text[$i]);
    }

    
$_SESSION['captcha'] = $code;

    
ob_start();

    
imagepng($image);
    
imagedestroy($image);

    return 
'data:image/png;base64,' base64_encode(ob_get_clean());
}
Онлайн: 1
Реклама