- Session_Start ();
- $image = Imagecreatetruecolor (58,22);
- $color _background = imagecolorallocate ($image, 255,255,255);
- Imagefill ($image, 0,0, $color _background);
- $key = Array (
- ' 0′, ' 1′, ' 2′, ' 3′, ' 4′, ' 5′, ' 6′, ' 7′, ' 8′, ' 9′,
- ' A ', ' B ', ' C ', ' d ', ' e ', ' f ', ' g ', ' h ', ' I ', ' j ', ' K ', ' l ', ' m ', ' n ', ' o ', ' P ', ' Q ', ' R ', ' s ', ' t ', ' u ', ' V ', ' w ', ' x ', ' y ', ' z ',
- ' A ', ' B ', ' C ', ' D ', ' E ', ' F ', ' G ', ' H ', ' I ', ' J ', ' K ', ' L ', ' M ', ' N ', ' O ', ' P ', ' Q ', ' R ', ' S ', ' T ', ' U ', ' V ', ' W ', ' X ', ' Y ', ' Z ');
- $string = null;
- $char _x = 6;
- $char _y = 0;
- for ($i =0; $i <4; $i + +)
- {
- $char _y = Mt_rand (0,5);
- $char = $key [Mt_rand (0,61)];
- $string. = $char;
- $color _char = imagecolorallocate ($image, Mt_rand (0,230), Mt_rand (0,230), Mt_rand (0,230));
- Imagechar ($image, 5, $char _x, $char _y, $char, $color _char);
- $char _x = $char _x + mt_rand (8,15);
- }
- $line _x1 = 0;
- $line _y1 = 0;
- $line _x2 = 0;
- $line _y2 = 0;
- for ($i =0; $i
- {
- $line _x1 = Mt_rand (0,58);
- $line _y1 = Mt_rand (0,22);
- $line _x2 = Mt_rand (0,58);
- $line _y2 = Mt_rand (0,22);
- $line _x1 = $line _x1;
- $line _y1 = $line _y1;
- $line _x2 = $line _x1 + mt_rand (1,8);
- $line _y2 = $line _y1 + mt_rand (1,8);
- $color _line = imagecolorallocate ($image, Mt_rand (0,230), Mt_rand (0,230), Mt_rand (0,230));
- Imageline ($image, $line _x1, $line _y1, $line _x2, $line _y2, $color _line);
- }
- $_session[' seccode '] = $string;
- @header ("Expires: -1″);
- @header ("Cache-control:no-store, Private, post-check=0, Pre-check=0, Max-age=0″, FALSE);
- @header ("Pragma:no-cache");
- Header (' Content-type:image/jpeg ');
- Imagepng ($image);
- Imagedestroy ($image);
- ?>
Copy Code |