source: spip-zone/_plugins_/captcha/create_image.php @ 117558

Last change on this file since 117558 was 13933, checked in by bernard.blazin@…, 13 years ago
File size: 936 bytes
Line 
1<?php
2
3
4session_start();
5
6
7create_image();
8exit();
9function create_image()
10{
11
12   
13    $md5_hash = md5(rand(0,999)); 
14   
15    $security_code = substr($md5_hash, 15, 5); 
16
17   
18    $_SESSION["security_code"] = $security_code;
19       
20   
21    $width = 100;
22    $height = 20; 
23
24    $image = ImageCreate($width, $height); 
25
26    $white = ImageColorAllocate($image, 255, 255, 255);
27    $black = ImageColorAllocate($image, 0, 0, 0);
28    $grey = ImageColorAllocate($image, 204, 204, 204);
29
30    ImageFill($image, 0, 0, $black); 
31
32    ImageString($image, 3, 30, 3, $security_code, $white); 
33
34   
35    ImageRectangle($image,0,0,$width-1,$height-1,$grey); 
36    //imageline($image, 0, $height/2, $width, $height/2, $grey);
37    //imageline($image, $width/2, 0, $width/2, $height, $grey);
38 
39 
40    header("Content-Type: image/jpeg"); 
41
42    ImageJpeg($image);
43   
44   
45    ImageDestroy($image);
46}
47
48
49
50?>
51
Note: See TracBrowser for help on using the repository browser.