Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- define('CAPTCHA_NUMCHARS', 4);
- $pass_phrase = "";
- for($i = 0; $i < CAPTCHA_NUMCHARS; $i++) {
- $pass_phrase .= chr(rand(97, 122));
- }
- $_SESSION['cap_code'] = $pass_phrase;
- define('CAPTCHA_WIDTH', 70); define('CAPTCHA_HEIGHT', 20);
- $img = imagecreatetruecolor(CAPTCHA_WIDTH, CAPTCHA_HEIGHT);
- $gc = rand(1, 1);
- if($gc == '1')
- {
- //blue bg 30-144-255
- //white text 225-225-225
- $bg_color = imagecolorallocate($img, 105,105,105);
- $text_color = imagecolorallocate($img, 192,192,192);
- }
- if($gc == '2')
- {
- //green bg 124-252-0
- //black text 0-0-0
- //red lines 255-0-0
- //green dots 124-252-0
- $bg_color = imagecolorallocate($img, 124, 252, 0);
- $text_color = imagecolorallocate($img, 0, 0, 0);
- $graphic_line_color = imagecolorallocate($img, 225, 0, 0);
- $graphic_dot_color = imagecolorallocate($img, 124, 252, 0);
- }
- if($gc == '3')
- {
- //red bg 255-0-0
- //blue text 30-144-255
- //black lines 0-0-0
- //green dots 124-252-0
- $bg_color = imagecolorallocate($img, 225, 0, 0);
- $text_color = imagecolorallocate($img, 30, 144, 255);
- $graphic_line_color = imagecolorallocate($img, 0, 0, 0);
- $graphic_dot_color = imagecolorallocate($img, 124, 252, 0);
- }
- if($gc == '4')
- {
- //yellow bg 255-255-0
- //red text 255-0-0
- //blue lines 30-144-255
- //black dots 0-0-0
- $bg_color = imagecolorallocate($img, 225, 225, 0);
- $text_color = imagecolorallocate($img, 225, 0, 0);
- $graphic_line_color = imagecolorallocate($img, 30, 144, 255);
- $graphic_dot_color = imagecolorallocate($img, 0, 0, 0);
- }
- if($gc == '5')
- {
- //blue bg 30-144-255
- //yellow text 255-255-0
- //green lines 124-252-0
- //red dots 255-0-0
- $bg_color = imagecolorallocate($img, 30, 144, 255);
- $text_color = imagecolorallocate($img, 225, 225, 0);
- $graphic_line_color = imagecolorallocate($img, 124, 252, 0);
- $graphic_dot_color = imagecolorallocate($img, 225, 0, 0);
- }
- imagefilledrectangle($img, 0, 0, CAPTCHA_WIDTH, CAPTCHA_HEIGHT, $bg_color);
- for($i = 0; $i < 15; $i++) {
- imageline($img, 0, rand() % CAPTCHA_HEIGHT, CAPTCHA_WIDTH, rand() % CAPTCHA_HEIGHT, $graphic_line_color);
- }
- for($i = 0; $i < 150; $i++) {
- imagesetpixel($img, rand() % CAPTCHA_WIDTH, rand() % CAPTCHA_HEIGHT, $graphic_dot__color);
- }
- imagettftext($img, 13, 0, rand(12,22), CAPTCHA_HEIGHT - rand(5, 10), $text_color, 'ariblk.ttf', $pass_phrase);
- header('Content-type: image/png');
- imagepng($img);
- destroyimage($img);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment