Captcha fejl i IE 6.0 men ikke i IE 7.0
Hej eksperter.Jeg har flg script det fungere fint ved mig på IE 7.0 på Windows Vista, men der er flere som ikke kan få det til at fungere på IE 6.0 Windows XP. De får meddelsen Koden er ikke skrevet rigtig. Klik tilbage og prøv igen.
jeg ved ikke hvorfor, er det nogen som kan se en fejl i scriptet. ?
Captcha.php
<?php
session_start();
class CaptchaSecurityImages {
var $font = 'monofont.ttf';
function generateCode($characters) {
$possible = '23456789bcdfghjkmnpqrstvwxyz';
$code = '';
$i = 0;
while ($i < $characters) {
$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
$i++;
}
return $code;
}
function CaptchaSecurityImages($width='120',$height='30',$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($image, 192, 192, 192);
$text_color = imagecolorallocate($image, 45, 45, 45);
$noise_color = imagecolorallocate($image, 122, 122, 122);
for( $i=0; $i<($width*$height)/3; $i++ ) {
imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
}
for( $i=0; $i<($width*$height)/150; $i++ ) {
imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
}
$textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function');
$x = ($width - $textbox[4])/2;
$y = ($height - $textbox[5])/2;
imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Error in imagettftext function');
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
$_SESSION['security_code'] = $code;
}
}
$width = isset($_GET['width']) ? $_GET['width'] : '120';
$height = isset($_GET['height']) ? $_GET['height'] : '40';
$characters = isset($_GET['characters']) && $_GET['characters'] > 1 ? $_GET['characters'] : '6';
$captcha = new CaptchaSecurityImages($width,$height,$characters);
?>
Form.php
<?php
session_start();
if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) {
if ($action){
require ("include.php");
$tak = tak();
$top = top();
$bottom = bottom();
$mail_til="info@gb-h.dk";
$mail_fra="info@gb-h.dk";
if ($action == "kontakt") {
if (!$navn OR !$adresse1 OR !$postby OR !$email OR !$besked) {
print ("der mangler informationer, klik tilbage og prøv igen.<br>");
echo '<a href="java script: history.go(-1)">Tilbage</a>';
}
else {
mail("$mail_til","test","
$top
<font size=4>Kontakt til test.</font><br><br>
<font size=\"3\"><b>Oplysninger:</b></font><br>
$navn<br>
$adresse1   $adresse2<br>
$postby<br>
$email<br><br>
<font size=\"3\"><b>Besked:</b></font><br>
$besked
$bottom
</font></html>","From: $mail_fra\nContent-type:text/html");
print ("$tak");
}
}
else
{
print ("der opstod en fejl, prøv venligst igen.");
}
}
else
{
print ("der opstod en fejl, prøv venligst igen.");
}
unset($_SESSION['security_code']);
}
else {
echo '<b>Koden er ikke skrevet rigtig. Klik tilbage og prøv igen.</b><br>';
echo '<a href="java script: history.go(-1)">Tilbage</a>';
}
?>
