Slamlander wrote:
OmnipotentEntity wrote:
Slamlander wrote:
until we get some better new user creation policies in place.
Take the captcha and use it for the wiki.Okay, I'll dl it and test it. My problem is that I only have PHP5 systems here and ErrantStory is on PHP4.
Here's the code that actually creates the image. Be sure to note the fonts, (search for ttf), you'll have to change them to paths that actually exist. And you'll also have to find out how to get the chars from wikisource and just remove the three lines it tells you to and then poke it into $code.
Code:
$im = ImageCreateTrueColor(500,140); // 150 on edges, 200 on middle
$chars = "ABCEFGHJKLMNPRTWXY3478";
/* Remove these three lines to use it in usercp_confirm.php: */
$code = '';
$n=0;$l = strlen($chars);
for($n=0; $n<6; ++$n) $code .= $chars[mt_rand(0,$l-1)];
$l = strlen($code);
for($n=0; $n<$l; ++$n)
if(mt_rand(0,2)==0)
$code[$n] = strtr($code[$n], 'KEMFAP', 'kemfap');
ImageFilledRectangle($im, 150,0, 350,140, 0x101010);
$l = strlen($chars);
for($n=0; $n<80; ++$n) add_random_char(20,60, 4,9, 0,150);
ImageCopy($im,$im, 350,0, 0,0, 150,140);
for($n=0; $n<30; ++$n) add_random_char(20,60, 26,30, 150,340);
for($n=0; $n<80; ++$n) add_random_char(20,75, 11,23, 110,380);
for($n=0; $n<50; ++$n) add_random_char(200,256, 4,9, 150,340);
function add_random_char($min_yuv, $max_yuv, $min_size, $max_size, $minx,$maxx)
{
global $im, $l, $chars;
for(;;)
{
$rgb = mt_rand(0,0xFFFFFF);
$r = $rgb>>16;
$g = ($rgb&0xFF00)>>8;
$b = ($rgb&0xFF);
$yuv_y = 0.299*$r + 0.587*$g + 0.114*$b;
if($yuv_y >= $min_yuv && $yuv_y <= $max_yuv) break;
}
$c = ImageColorAllocate($im, $r,$g,$b);
$ch = $chars[mt_rand(0,$l-1)];
$x = mt_rand($minx,$maxx);
$y = mt_rand(10,140);
ImageTTFText($im, mt_rand($min_size, $max_size),mt_rand(-40,40), $x,$y, $c, '/path/to/font1.ttf', $ch);
}
$x=0;
$l=strlen($code);
for($n=0; $n<$l; ++$n)
{
for(;;)
{
$rgb = mt_rand(0,0xFFFFFF);
$r = $rgb>>16;
$g = ($rgb&0xFF00)>>8;
$b = ($rgb&0xFF);
$yuv_y = 0.299*$r + 0.587*$g + 0.114*$b;
if($yuv_y > 180) break;
}
$c = ImageColorAllocate($im, $r,$g,$b);
$y = 140 - mt_rand(10,100);
if($n == 0) $y = max($y, 80);
$fnt = '/path/to/font2.ttf';
$slant = mt_rand(-30,30);
$bound =
ImageTTFText($im,
mt_rand(25,40),
$slant,
150+$x,
$y,
$c, $fnt, $code[$n]);
$wid = $bound[2] - $bound[0] + 2 + abs($slant)/5;
$x += $wid;
}
ImageTrueColorToPalette($im, false, 256); // to save in transmission length
header('Content-type: image/png');
header('Cache-Control: no-cache, no-store');
ob_start();
ImagePng($im);
$image = ob_get_contents();
ob_end_flush();