connect($dbconfig["server"], $dbconfig["appender_name"], $dbconfig["appender_pwd"], $dbconfig["database"]);
$rs = $db->execute('SELECT code FROM wb_secure WHERE cid='.$cid);
$code = $rs->fields['code'];
$rs->close();
$im = ImageCreate($width,$height);
$c_white = ImageColorAllocate($im, 0xff, 0xff, 0xff);
$c_black = ImageColorAllocate($im, 0x00, 0x00, 0x00);
ImageFilledRectangle($im, 0, 0, $width, $height, $c_black);
ImageFilledRectangle($im, 1, 1, $width-2, $height-2, $c_white);
srand((double)microtime()*1000000);
ImageFilledRectangle($im, 0, 0, $width, $height, $c_black);
ImageFilledRectangle($im, 1, 1, $width-2, $height-2, $c_white);
// srand((double)microtime()*1000000);
mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff);
$x = 3;
$x_plus = mt_rand(0, 5);
$font_size = mt_rand(24, 32);
$y = mt_rand(32, 40);
$angle = mt_rand(-10, 10);
$x += $x_plus;
ImageTTFText($im, $font_size, $angle, $x, $y, $c_black, $config['font_file_bold'], $code[0]);
ImageTTFText($im, $font_size-4, $angle, $x, $y-2, $c_white, $config['font_file'], $code[0]);
$x_plus = mt_rand(15, 20);
$font_size = mt_rand(24, 32);
$y = mt_rand(32, 40);
$angle = mt_rand(-10, 10);
$x += $x_plus;
ImageTTFText($im, $font_size, $angle, $x, $y, $c_black, $config['font_file_bold'], $code[1]);
ImageTTFText($im, $font_size-4, $angle, $x, $y-2, $c_white, $config['font_file'], $code[1]);
$x_plus = mt_rand(15, 20);
$font_size = mt_rand(24, 32);
$angle = mt_rand(-10, 10);
$y = mt_rand(32, 40);
$x += $x_plus;
ImageTTFText($im, $font_size, $angle, $x, $y, $c_black, $config['font_file_bold'], $code[2]);
ImageTTFText($im, $font_size-4, $angle, $x, $y-2, $c_white, $config['font_file'], $code[2]);
$x_plus = mt_rand(15, 20);
$font_size = mt_rand(24, 32);
$angle = mt_rand(-10, 10);
$y = mt_rand(32, 40);
$x += $x_plus;
ImageTTFText($im, $font_size, $angle, $x, $y, $c_black, $config['font_file_bold'], $code[3]);
ImageTTFText($im, $font_size-4, $angle, $x, $y-2, $c_white, $config['font_file'], $code[3]);
for($i=0; $i < 2; $i++) {
$y1 = mt_rand(1, $height-2);
$y2 = mt_rand(1, $height-2);
ImageLine($im, 1, $y1, $width-2, $y2, $c_white);
}
for($i=0; $i < 2; $i++) {
$x1 = mt_rand(1, $width-2);
$x2 = mt_rand(1, $width-2);
ImageLine($im, $x1, 1, $x2, $height-2, $c_white);
}
for($i=0; $i < 100; $i++) {
$x = mt_rand(1, $width-2);
$y = mt_rand(1, $height-2);
$c = mt_rand(0, 1);
ImageSetPixel($im, $x, $y, $c ? $c_black : $c_white);
}
ImageWbmp($im);
ImageDestroy($im);
if ($debug) {
$tmpmtime=explode(" ",microtime());
$finish=(double)$tmpmtime[1]+(double)$tmpmtime[0];
$scmtime=$finish-$start;
echo "$scmtime sec.
\n";
}
}
?>