Hi.
I'm using the ZenPhoto Captcha Hack from the ZenPhoto Wiki:
http://www.zenphoto.org:8080/confluence/display/PLUG/Home It works fine as it is but I would like to add one or two more letters in the captcha image. I suppose it's in the generate_code.php file. Does anybody know how?
- Meek
Comments
1 - I added the numbers to the alphabet and deleted the number string line 3
`$lettre='abcdefghijklmnpqrstuvwxyz123456789';`
2 - This is the first part to make your captcha larger. Add as many rand strings as you want. I have six so my captcha image will be six digits long. (Since I added to the number string on line 3 there are now 34 digits, hence the 0 to 33)
`$rand1=rand(0,33);
$rand2=rand(0,33);
$rand3=rand(0,33);
$rand4=rand(0,33);
$rand5=rand(0,33);
$rand6=rand(0,33);`
3 - Now to get the letter/number for each digit in the captcha. Again there are six as my captcha is six digits long.
`$lettre1=$lettre[$rand1];
$lettre2=$lettre[$rand2];
$lettre3=$lettre[$rand3];
$lettre4=$lettre[$rand4];
$lettre5=$lettre[$rand5];
$lettre6=$lettre[$rand6];
`
4 - Now you have to add all these variable to line 15 (or around there).
`$code=md5($lettre1.$lettre2.$lettre3.$lettre4.$lettre5.$lettre6);`
5 - next you have to change the number 65 to match the size of your captcha.
I use this formula:
Start with 5 and add 15 for every digit in your captcha.
a five digit captcha would be 80, six digits 90, seven digits 105 etc.
Whatever it is remember that number(We will use six digits in our example so our number is 95).
So this line
`//header ("Content-type: image/png");
$image = imagecreate(`65`,20);`
becomes
`//header ("Content-type: image/png");
$image = imagecreate(`95`,20);`
6 - Next this line has to change from
`$fond = imagecolorallocate($image, 255, 255, 255);
ImageFill ($image,`65`,20, $fond);`
to our number from 5
`$fond = imagecolorallocate($image, 255, 255, 255);
ImageFill ($image,`95`,20, $fond);`
7 - this line changes
`{
ImageLine($image, 0,$i, `65`,$i, $ligne);
$i = $i+7;
}`
to our number from 5
`{
ImageLine($image, 0,$i, `95`,$i, $ligne);
$i = $i+7;
}`
8 - and this changes
`$i = 10;
while($i<=`<strong>65`)
{
ImageLine($image,$i,0,$i,20, $ligne);
$i = $i+10;
}`
to our number from 5
`$i = 10;
while($i<=`<strong>95`)
{
ImageLine($image,$i,0,$i,20, $ligne);
$i = $i+10;
}`
9 - Now we add as many line here as we have digits
Make sure that the lines follow properly.
First number in sequence is always 10, second add fifteen for each digit you add (first line starts at 5)(no two the same), third number always zero and make sure your random variables are all there (no two the same).
`$lettre = imagecolorallocate($image,0,0,0);
imagestring($image,10,5,0,$lettre1,$lettre);
imagestring($image,10,20,0,$lettre2,$lettre);
imagestring($image,10,35,0,$lettre3,$lettre);
imagestring($image,10,50,0,$lettre4,$lettre);
imagestring($image,10,65,0,$lettre5,$lettre);
imagestring($image,10,80,0,$lettre6,$lettre);`
10 - Last change.We have to take the number 64 from this line and change to our number from 5 and minus one. So for six digits our number was 95 minus one equals 94.
So this
`$rectangle = imagecolorallocate($image,48,57,85);
ImageRectangle ($image,0,0,`64`,19,$rectangle);`
becomes this
`$rectangle = imagecolorallocate($image,48,57,85);
ImageRectangle ($image,0,0,`94`,19,$rectangle);`
Any questions just ask.
5 - next you have to change the number 65 to match the size of your captcha.
I use this formula:
Start with 5 and add 15 for every digit in your captcha.
`a five digit captcha would be 80, six digits 95, seven digits 110 etc.`
Whatever it is remember that number(We will use six digits in our example so our number is 95).