Source for file captcha.php
Documentation is available at captcha.php
* Spam Protection - Code Image Generator - 2006 Dominik Paulus
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @author: Dominik Paulus, [email]mail@dpaulus.de[/email]
255, 244, 234, // Background
255, 128, 0, // Vertical Lines
255, 128, 0 // Border (Last value without ',')
$_SESSION['img'] =
"OK"; // debug
$font =
'./captchaFonts/FreeFarsi.ttf';
$string =
"abcdefghjkmnpqrstuvwxyz0123456789";
for($i =
0; $i <
5; $i++
)
$seccode .=
$string{mt_rand(0, $stringlen)};
$_SESSION['code'] =
$seccode;
$ennum =
array(0,1,2,3,4,5,6,7,8,9);
$fanum =
array('۰','۱','۲','۳','۴','۵','۶','۷','۸','۹');
$im =
imagecreate($box['width']+
5, $box['height']+
5);
$white =
imagecolorallocate($im, 255, 255, 255);
$grey =
imagecolorallocate($im, 128, 128, 128);
$black =
imagecolorallocate($im, rand(0,200), rand(0,200), rand(0,200));
// Add some shadow to the text
imagettftext($im, 20, 0, 2, 26, $grey, $font, $seccode);
imagettftext($im, 20, 0, 3, 25, $black, $font, $seccode);
Header("Content-Type: image/jpeg");
Header("Content-Type: image/png");
Header("Content-Type: image/gif");
die("Wrong \$type in captcha.php (should be jpeg, png or gif)\n");
$xOffset = -
abs($bbox[0] +
1);
$xOffset =
abs($bbox[0] +
2);
$width =
abs($bbox[2] -
$bbox[0]);
if ($bbox[0] < -
1) $width =
abs($bbox[2]) +
abs($bbox[0]) -
1;
$yOffset =
abs($bbox[5] +
1);
if ($bbox[5] >= -
1) $yOffset = -
$yOffset; // Fixed characters below the baseline.
$height =
abs($bbox[7]) -
abs($bbox[1]);
if ($bbox[3] >
0) $height =
abs($bbox[7] -
$bbox[1]) -
1;
'xOffset' =>
$xOffset, // Using xCoord + xOffset with imagettftext puts the left most pixel of the text at xCoord.
'yOffset' =>
$yOffset, // Using yCoord + yOffset with imagettftext puts the top most pixel of the text at yCoord.
'belowBasepoint' =>
max(0, $bbox[1])
Documentation generated on Mon, 05 May 2008 16:16:50 +0400 by phpDocumentor 1.4.0