2013-04-27 2 views
1

Так что мой домашний CAPTCHA, отображает текст в прямой линии, но я думаю, что из-за этого, боты все еще может подписать -. Они получают визменить местоположение каждой буквы в доме сделали CAPTCHA,

Может кто-то показать мне, как пересмотреть мой код ниже, чтобы добавить функцию или что-то, что сделает каждую букву немного выше или ниже других букв? Пожалуйста, не обращайте внимания на грязное кодирование, поскольку я не профессионал 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

Le код ...

$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); 

ничего особенного, но функциональное ваши требования :) добавил ранды размера и ранд письмо пространства :)

+0

Иисуса был прекрасен - ле код - и я очень благодарен вам за это ... оттуда я могу поиграть с ним больше, но, о, о, я надеюсь, что это поможет блокировать чувака - он бьет меня годами ... Спасибо Lukas (Light) – DK1

+0

Lukas, would it быть очень похожим на ротацию e шрифт тоже, так что он тоже наклонный? – DK1

+0

для вращения вам нужно создать свой собственный шрифт, а затем реализовать его ... внимательно посмотрите на функцию imagestring [link] (http://php.net/manual/en/function.imagestring.php), затем на imageloadfont [link] (http://www.php.net/manual/en/function.imageloadfont.php) и воспроизвести llbit с ним –

Смежные вопросы