0

我使用脚本验证码表单(captcha.php)。适用于 IE 和 Firefox,但 Chrome 在验证期间崩溃。我试图修复,但我们没有。预先感谢您的支持。

脚本:

<?php

session_start();


function _generateRandom($length=6)

{

    $_rand_src = array(

        array(48,57) //digits

        , array(97,122) //lowercase chars



    );

    srand (floor(time() / (5*60)));

    $random_string = "";

    for($i=0;$i<$length;$i++)
    {

        $i1=rand(0,sizeof($_rand_src)-1);

        $random_string .= chr(rand($_rand_src[$i1][0],$_rand_src[$i1][1]));

    }

    return $random_string;

}

global $captchaimagepath;

$im = @imagecreatefromjpeg($captchaimagepath. "captcha.jpg"); 

$rand = _generateRandom(3);

$_SESSION['captcha'] = $rand;

ImageString($im, 15, 18, 8, " ".$rand[0]." ".$rand[1]." ".$rand[2]." ", ImageColorAllocate ($im, 0, 0, 0));

/*$rand = _generateRandom(3);

ImageString($im, 15, 18, 8, " ".$rand[0]." ".$rand[1]." ".$rand[2] ." ", ImageColorAllocate ($im, 255, 0, 0));

Header ('Content-type: image/jpeg');

*/

imagejpeg($im,NULL,100);

ImageDestroy($im);
4

0 回答 0