GIF89a;
Direktori : /home/serb/www/ |
Current File : /home/serb/www/captcha.php |
<? session_start(); $text = rand(10000,99999); $_SESSION["vercode"] = $text; $height = 50; $width = 100; $image_p = imagecreate($width, $height); $black = imagecolorallocate($image_p, 22, 86, 165); $white = imagecolorallocate($image_p, 255, 255, 255); $font_size = 14; imagestring($image_p, $font_size, 5, 5, $text, $white); imagejpeg($image_p, null, 80); ?> <?php /*?><? session_start(); $code=rand(1000,9999); $_SESSION["code"]=$code; $im = imagecreatetruecolor(50, 24); $bg = imagecolorallocate($im, 22, 86, 165); //background color blue $fg = imagecolorallocate($im, 255, 255, 255);//text color white imagefill($im, 0, 0, $bg); imagestring($im, 5, 5, 5, $code, $fg); header("Cache-Control: no-cache, must-revalidate"); header('Content-type: image/png'); imagepng($im); imagedestroy($im); ?><?php */?> <?php /*?><?php session_start(); $width = 120; $height = 40; $font_size = mt_rand(25,31); $fonts = array('BRADHITC.TTF','FREESCPT.TTF','ITCBLKAD.TTF','ITCEDSCR.TTF'); $image = imagecreate($width,$height); $background_color = imagecolorallocate($image,0,0,0); $font_color = imagecolorallocate($image,mt_rand(200,255),mt_rand(80,255),mt_rand(100,200)); $text = ''; for($x=0;$x<6;$x++){ $text.=generate_random_text(1,mt_rand(1,3)); } $font = 'fonts/'.$fonts[mt_rand(0,count($fonts)-1)]; $_SESSION['captcha_code'] = $text; imagettftext($image,$font_size,mt_rand(-10,10),mt_rand(2,10),mt_rand(28,32),$font_color,$font,$text); for($x=0;$x<mt_rand(4,6);$x++){ imageline($image,0,mt_rand(0,$height),$width,10+mt_rand(0,$height),$font_color); } header("Content-Type: image/png"); imagepng($image); imagedestroy($image); function generate_random_text($length,$method=1){ $str=''; for($x=0;$x<$length;$x++){ switch($method){ case 1:{ $str.=(chr(mt_rand(97,122)));//Lower Case Characters }break; case 2:{ $str.=(chr(mt_rand(65,90)));//Upper Case Characters }break; case 3:{ $str.=chr(mt_rand(48,57));//Numbers 0 - 9 }break; } } return $str; } ?> <?php */?>