|
<?php
/*
* File: chinesechar.php
* Role: Chinese character data storage
*/
$ChineseChar = Array ("Man", "Out", "Come", "friend", "Learn", "filial piety", "benevolence", "righteousness", "propriety," low "," Zhong "," Guo "," Zhong "," Yi "," white "," person "," Fire "," Earth "," gold "," Wood "," Thunder "," Wind "," Dragon " , "Tiger", "Day", "ground", "Sheng", "halo", "vegetable", "bird", "Tian", "three", "Hundred", "money", "Fu", "Love", "Love", "Beast", "Worm", "fish", "nine", "net", "new", "degree", "ay", "Alas", "ah", "Oh", "Miriam", "old", " Less "," Day "," month "," star ");
?>
<?php
/*
* File: check.php
* Role: Validation
*/
Session_Start ();
$errorMSG = ';
Verify that user input is consistent with the authentication code
if (!is_null ($_post[' check '))
{
if (strcasecmp ($_session[' code '],$_post[' Code ')) ==0)
$errorMSG = "<p style=" Font-size:12px;color: #009900 "> Validation Success!</p>";
Else
$errorMSG = "<p style=" Font-size:12px;color: #FF0000 "> Validation failure!</p>";
}
?>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body>
<?php
if ($errorMSG) {
Echo $errorMSG;
}
?>
<form action=<?php echo $_server[' php_self ']?> method=post>
Please enter the verification code: <input type= "text" name= "code" style= "width:
80px ">
<br>
<input type= "Submit" name= "Check" value= "Submission Verification Code" >
</form>
</body>
<?php
/*
* File: code.php
* Function: Verify code generation
* Special Note: By the grass without teeth Guide Copyright reproduced Annotated source! There will be pay to reap!
*/
Include_once ("chinesechar.php");
Session_Start ();
Set Content-type
Header ("Content-type:image/png");
Create a picture
$im = Imagecreatetruecolor (120, 30);
Create color
$fontcolor = Imagecolorallocate ($im, 255, 255, 255);
$BG = imagecolorallocate ($im, 0, 0, 0);
Set text
For ($i =0 $i <4; $i + +) $text. = $ChineseChar [(Array_rand ($ChineseChar))];
$_session[' Code ' = $text;
Set font
$font = ' Simkai.ttf ';
Add text
Imagettftext ($im, 0, one, $fontcolor, $font, Iconv ("GB2312", "UTF-8", $text));
Output picture
Imagepng ($im);
Imagedestroy ($im);
?>
|