Changeset 10448 for temp/trunk


Ignore:
Timestamp:
2006/12/08 11:36:38 (20 years ago)
Author:
uehara
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • temp/trunk/html/test/uehara/captcha/ajax_captcha/create_image.php

    r10447 r10448  
    11<? 
    2 /* 
    3     This is PHP file that generates CAPTCHA image for the How to Create CAPTCHA Protection using PHP and AJAX Tutorial 
    4  
    5     You may use this code in your own projects as long as this  
    6     copyright is left in place.  All code is provided AS-IS. 
    7     This code is distributed in the hope that it will be useful, 
    8     but WITHOUT ANY WARRANTY; without even the implied warranty of 
    9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
    10      
    11     For the rest of the code visit http://www.WebCheatSheet.com 
    12      
    13     Copyright 2006 WebCheatSheet.com     
    14  
    15 */ 
    16  
    17 //Start the session so we can store what the security code actually is 
     2// ¥»¥Ã¥·¥ç¥ó¥¹¥¿¡¼¥È 
    183session_start(); 
    19  
    20 //Send a generated image to the browser  
    21 create_image();  
     4// ²èÁü¥¤¥á¡¼¥¸À¸À®  
     5create_image(); 
    226exit();  
    237 
    248function create_image()  
    259{  
    26     //Let's generate a totally random string using md5  
     10    // ¥é¥ó¥À¥à¤Êʸ»úÎó¤òÀ¸À® 
    2711    $md5_hash = md5(rand(0,999));  
    28     //We don't need a 32 character long string so we trim it down to 5  
     12    // Ê¸»úÎó¤ò£µ·å¤Ë¤¹¤ë  
    2913    $security_code = substr($md5_hash, 15, 5);  
    30  
    31     //Set the session to store the security code 
     14    // ¥»¥Ã¥·¥ç¥ó¤ËÀ¸À®¤µ¤ì¤¿¥³¡¼¥É¤òÊݸ 
    3215    $_SESSION["security_code"] = $security_code; 
    3316 
    34     //Set the image width and height  
    35     $width = 100;  
    36     $height = 20;   
     17    //¡¡¥¤¥á¡¼¥¸¥µ¥¤¥ºÄêµÁ 
     18    $width = 120;  
     19    $height = 30;   
    3720 
    38     //Create the image resource  
    3921    $image = ImageCreate($width, $height);   
    4022 
    41     //We are making three colors, white, black and gray  
     23    // ¿§¤ÎÄêµÁ  
    4224    $white = ImageColorAllocate($image, 255, 255, 255);  
    4325    $black = ImageColorAllocate($image, 0, 0, 0);  
    4426    $grey = ImageColorAllocate($image, 204, 204, 204);  
    4527 
    46     //Make the background black  
    47     ImageFill($image, 0, 0, $black);  
     28    // ÇØ·Ê¿§ 
     29    ImageFill($image, 0, 0, $white);  
    4830 
    49     //Add randomly generated string in white to the image 
    50     ImageString($image, 3, 30, 3, $security_code, $white);  
    51  
     31    // À¸À®¤·¤¿¥³¡¼¥É¤òɽ¼¨ 
     32    ImageString($image, 3, 30, 3, $security_code, $black);  
     33/* 
    5234    //Throw in some lines to make it a little bit harder for any bots to break  
    5335    ImageRectangle($image,0,0,$width-1,$height-1,$grey);  
    5436    imageline($image, 0, $height/2, $width, $height/2, $grey);  
    5537    imageline($image, $width/2, 0, $width/2, $height, $grey);  
    56   
     38*/  
    5739    //Tell the browser what kind of file is come in  
    5840    header("Content-Type: image/jpeg");  
    59  
    60     //Output the newly created image in jpeg format  
     41    // jpag¤Ç½ÐÎÏ  
    6142    ImageJpeg($image);  
    62      
    63     //Free up resources 
    6443    ImageDestroy($image);  
    6544}  
Note: See TracChangeset for help on using the changeset viewer.