所以我的自制验证码会直线显示文字,但我认为因此,机器人仍可以注册 - 他们会进入。
有人可以告诉我如何修改下面的代码来添加一个功能或某些东西,使每个字母显示高于或低于其他字母?请不要介意脏编码,因为我不是PHP专业人员。感谢大家的帮助。
$image = imagecreatetruecolor(70, 20);
for ($i=0; $i < rand(20,40); $i++) {
$x = rand(0, 70);
$y = rand(0, 20);
imageline($image, $x, $y, $x+rand(0,10), $y+rand(0,240), imagecolorallocate($image, rand(0,255),rand(0,190),rand(1,90)));
imageline($image, $x, $y, $x+rand(0,11), $y+rand(0,34), imagecolorallocate($image, 255,rand(50,240),rand(241,240)));
}
$s = rand(1, 240);
$x = rand(50, 240);
$f = rand(1, 4);
$d = rand(1, 1);
$c = rand(1, 4);
imagestring($image, $c, 3, $f, $_GET["T"], imagecolorallocate($image, $s,$x,$s));
imagestring($image, $c, 4, $f, $_GET["T"], imagecolorallocate($image, 255,rand(50,240),rand(241,240)));
imagecolortransparent($image, imagecolorallocate($image, 255, 0, 0));
imageinterlace($image);
header("Content-type: image/gif");
imagegif($image);
imagedestroy($image);
答案 0 :(得分:0)
Le code ...
$image = imagecreatetruecolor(70, 20);
for ($i=0; $i < rand(20,40); $i++) {
$x = rand(0, 70);
$y = rand(0, 20);
imageline($image, $x, $y, $x+rand(0,10), $y+rand(0,240), imagecolorallocate($image, rand(0,255),rand(0,190),rand(1,90)));
imageline($image, $x, $y, $x+rand(0,11), $y+rand(0,34), imagecolorallocate($image, 255,rand(50,240),rand(241,240)));
}
$s = rand(1, 240);
$x = rand(50, 240);
$f = rand(1, 4);
$d = rand(1, 1);
$pos_x = rand(5,10);
$strArr = str_split($_GET["T"]);
foreach ($strArr as $str){
$font_size = rand(1, 5); // range from 1-5
imagestring($image, $font_size, $pos_x, $f, $str, imagecolorallocate($image, $s,$x,$s));
imagestring($image, $font_size, $pos_x, $f, $str, imagecolorallocate($image, 255,rand(50,240),rand(241,240)));
$pos_x = $pos_x + rand(20,30); //adjust your letter spaceing, depend on max char per chaptcha
}
imagecolortransparent($image, imagecolorallocate($image, 255, 0, 0));
imageinterlace($image);
header("Content-type: image/gif");
imagegif($image);
imagedestroy($image);
没什么特别的,但是按照你的要求运作:) 添加兰特大小和兰特字母空间:)