Hi,
Learning PHP code; playing with various methods of generating captcha
codes:
In the code below, how would I change the size of the text displayed in
the captcha code?
Is it even possible with this method?
TIA,
Twayne
--------------------------
<?php
session_start() ;
$width = 120;
$height = 40;
$length = 5;
$baseList = '23456789abcdfg hjkmnpqrstvwxyz ABCDEFGHIJKLMNP QRSTUVWXYZ';
$code = "";
$counter = 0;
$image = @imagecreate($w idth, $height) or die('Cannot initialize GD!');
for( $i=0; $i<10; $i++ ) {
imageline($imag e,
mt_rand(0,$widt h), mt_rand(0,$heig ht),
mt_rand(0,$widt h), mt_rand(0,$heig ht),
imagecoloralloc ate($image, mt_rand(150,255 ),
mt_rand(150,255 ),
mt_rand(150,255 )));
}
for( $i=0, $x=0; $i<$length; $i++ ) {
$actChar = substr($baseLis t, rand(0, strlen($baseLis t)-1), 1);
$x += 10 + mt_rand(0,10);
imagechar($imag e, mt_rand(3,5), $x, mt_rand(5,20), $actChar,
imagecoloralloc ate($image, mt_rand(0,155), mt_rand(0,155),
mt_rand(0,155)) );
$code .= strtolower($act Char);
}
header('Content-Type: image/jpeg');
imagejpeg($imag e);
imagedestroy($i mage);
$_SESSION['securityCode'] = $code;
?>
\
---------------------------------
Learning PHP code; playing with various methods of generating captcha
codes:
In the code below, how would I change the size of the text displayed in
the captcha code?
Is it even possible with this method?
TIA,
Twayne
--------------------------
<?php
session_start() ;
$width = 120;
$height = 40;
$length = 5;
$baseList = '23456789abcdfg hjkmnpqrstvwxyz ABCDEFGHIJKLMNP QRSTUVWXYZ';
$code = "";
$counter = 0;
$image = @imagecreate($w idth, $height) or die('Cannot initialize GD!');
for( $i=0; $i<10; $i++ ) {
imageline($imag e,
mt_rand(0,$widt h), mt_rand(0,$heig ht),
mt_rand(0,$widt h), mt_rand(0,$heig ht),
imagecoloralloc ate($image, mt_rand(150,255 ),
mt_rand(150,255 ),
mt_rand(150,255 )));
}
for( $i=0, $x=0; $i<$length; $i++ ) {
$actChar = substr($baseLis t, rand(0, strlen($baseLis t)-1), 1);
$x += 10 + mt_rand(0,10);
imagechar($imag e, mt_rand(3,5), $x, mt_rand(5,20), $actChar,
imagecoloralloc ate($image, mt_rand(0,155), mt_rand(0,155),
mt_rand(0,155)) );
$code .= strtolower($act Char);
}
header('Content-Type: image/jpeg');
imagejpeg($imag e);
imagedestroy($i mage);
$_SESSION['securityCode'] = $code;
?>
\
---------------------------------
Comment