data['comments']->captcha = $pass; $session->save(); // *** Create the image resource *** $image = ImageCreatetruecolor(100, 20); // *** We are making two colors, white and black *** $clr_white = ImageColorAllocate($image, 255, 255, 255); $clr_black = ImageColorAllocate($image, 0, 0, 0); $clr_green = ImageColorAllocate($image, 127, 255, 0); // *** Make the background black *** imagefill($image, 0, 0, $clr_white); // *** Set the image height and width *** imagefontheight(15); imagefontwidth(15); // *** Add the passcode in white to the image *** imagestring($image, 5, 30, 3, $pass, $clr_black); // *** Throw in some lines to trick those cheeky bots! *** $clr_rand = ImageColorAllocate($image, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255)); imageline($image, 5, 1, mt_rand(1, 70), mt_rand(5,100)+1, $clr_rand); $clr_rand = ImageColorAllocate($image, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255)); imageline($image, 60, 1, mt_rand(70, 120), mt_rand(5,100)+1, $clr_rand); $clr_rand = ImageColorAllocate($image, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255)); imageline($image, mt_rand(0,80), 1, mt_rand(1, 70), mt_rand(5,100)+1, $clr_rand); // *** Return the newly created image in jpeg format *** return imagejpeg($image); // *** Just in case... *** imagedestroy($image); } die(create_image()); ?>