X-Git-Url: https://git.p6c8.net/form-email.git/blobdiff_plain/d30a679aaebd16d4bef1f883f0ab63fbf1c2ecb2..290990d9b91349f0a5ac14efe25521b745d48a62:/form-email/captcha.php?ds=sidebyside diff --git a/form-email/captcha.php b/form-email/captcha.php index f796b46..8d00830 100644 --- a/form-email/captcha.php +++ b/form-email/captcha.php @@ -1,109 +1,101 @@ -# Letzte Aenderung: 11.1.2009 +# Letzte Aenderung: 7.11.2011 # -# Copyright (C) 2002-2011 Patrick Canterino +# Copyright (C) 2002-2012 Patrick Canterino # -# Diese Datei kann unter den Bedingungen der "Artistic License 1.0" +# Diese Datei kann unter den Bedingungen der "Artistic License 2.0" # weitergegeben und / oder veraendert werden. # Siehe: -# http://www.opensource.org/licenses/artistic-license-1.0.php +# http://www.opensource.org/licenses/artistic-license-2.0 # require('config.php'); require('functions.php'); require('class.Template.php'); -if($captcha_enable) -{ - session_start(); +if($captcha_enable) { + session_start(); - if($captcha_max && isset($_SESSION['captcha_failed']) && $_SESSION['captcha_failed'] >= $captcha_max) - { - show_fatal($err_captcha_max); - } - else - { - unset($_SESSION['captcha']); + if($captcha_max && isset($_SESSION['captcha_failed']) && $_SESSION['captcha_failed'] >= $captcha_max) { + show_fatal($err_captcha_max); + } + else { + unset($_SESSION['captcha']); - # Zufaellige Zeichenkette erzeugen + # Zufaellige Zeichenkette erzeugen - $captcha_string = ''; + $captcha_string = ''; - $x = 0; - srand(); + $x = 0; + srand(); - while($x<$captcha_length) - { - $rand = rand(0,strlen($captcha_possible)-1); - $captcha_string .= $captcha_possible[$rand]; + while($x<$captcha_length) { + $rand = rand(0,strlen($captcha_possible)-1); + $captcha_string .= $captcha_possible[$rand]; - $x++; - } + $x++; + } - $_SESSION['captcha'] = $captcha_string; + $_SESSION['captcha'] = $captcha_string; - # Ein Bild mit dem generierten Text erzeugen + # Ein Bild mit dem generierten Text erzeugen - if($captcha_image_bg && file_exists($captcha_image_bg)) - { - # Es wurde ein Hintergrundbild angegeben + if($captcha_image_bg && file_exists($captcha_image_bg)) { + # Es wurde ein Hintergrundbild angegeben - $captcha_img = imagecreatefrompng($captcha_image_bg); + $captcha_img = imagecreatefrompng($captcha_image_bg); - $image_size = getimagesize($captcha_image_bg); - $captcha_width = $image_size[0]; - $captcha_height = $image_size[1]; - } - else - { - # Es wurde kein Hintergrundbild angegeben + $image_size = getimagesize($captcha_image_bg); + $captcha_width = $image_size[0]; + $captcha_height = $image_size[1]; + } + else { + # Es wurde kein Hintergrundbild angegeben - $captcha_img = imagecreate($captcha_width,$captcha_height); - } + $captcha_img = imagecreate($captcha_width,$captcha_height); + } - $white = imagecolorallocate($captcha_img,$captcha_color_bg[0],$captcha_color_bg[1],$captcha_color_bg[2]); - $black = imagecolorallocate($captcha_img,$captcha_color_text[0],$captcha_color_text[1],$captcha_color_text[2]); + $white = imagecolorallocate($captcha_img,$captcha_color_bg[0],$captcha_color_bg[1],$captcha_color_bg[2]); + $black = imagecolorallocate($captcha_img,$captcha_color_text[0],$captcha_color_text[1],$captcha_color_text[2]); - $angle = rand($captcha_angle[0],$captcha_angle[1]); - $t_x = rand($captcha_x[0],$captcha_y[1]); - $t_y = rand($captcha_y[0],$captcha_y[1]); - - imagettftext($captcha_img,$captcha_font_size,$angle,$t_x,$t_y,$black,$captcha_font,$captcha_string); + $angle = rand($captcha_angle[0],$captcha_angle[1]); + $t_x = rand($captcha_x[0],$captcha_y[1]); + $t_y = rand($captcha_y[0],$captcha_y[1]); - # Zufaellige Linien einfuegen + imagettftext($captcha_img,$captcha_font_size,$angle,$t_x,$t_y,$black,$captcha_font,$captcha_string); - $y = 0; + # Zufaellige Linien einfuegen - while($y<$captcha_lines) - { - $begin_x = rand(0,$captcha_width); - $begin_y = rand(0,$captcha_height); - $end_x = rand(0,$captcha_width); - $end_y = rand(0,$captcha_height); + $y = 0; - imageline($captcha_img,$begin_x,$begin_y,$end_x,$end_y,$black); + while($y<$captcha_lines) { + $begin_x = rand(0,$captcha_width); + $begin_y = rand(0,$captcha_height); + $end_x = rand(0,$captcha_width); + $end_y = rand(0,$captcha_height); - $y++; - } + imageline($captcha_img,$begin_x,$begin_y,$end_x,$end_y,$black); - # Bild ausgeben + $y++; + } - header('Content-type: image/png'); - imagepng($captcha_img); + # Bild ausgeben - imagedestroy($captcha_img); - } + header('Content-type: image/png'); + imagepng($captcha_img); + + imagedestroy($captcha_img); + } } -else -{ - show_fatal($err_captcha_disabled); +else { + show_fatal($err_captcha_disabled); } #