/trunk/book/manage/yzm.php
PHP | 33 lines | 26 code | 3 blank | 4 comment | 3 complexity | df7ae6d71681368e5a5d23320a238d37 MD5 | raw file
- <?php
- session_start();//??session
- $randval;
- for($i = 0; $i<4; $i++){
- //??A-Z???ASCII???
- $randstr = mt_rand(ord('A'), ord('Z'));//ord($str)?????ASCII
- $randv = mt_rand(0, 10);//??0?10
- global $randval;
- //??0-9??????
- if($randv % 2 == 0){//?????,????
- $randval .= mt_rand(0, 9);
- }else{//????????,?chr??
- $randval .= chr($randstr);//chr()?????? ascii ?????????
- }
- }
- $_SESSION["randval"] = $randval;
- $intheight = 18;//????????
- $intwidth = 50;//????????,?????
- $img = imagecreatetruecolor($intwidth, $intheight);
- $fontcolor = imagecolorallocate($img, 255, 0, 0);
- $backcolor = imagecolorallocate($img, 255, 255, 255);
- imagefill($img, 0, 0, $backcolor);
- //??
- imageline($img, mt_rand(0,$intwidth/3), mt_rand(0,$intheight/3), mt_rand($intwidth/3,$intwidth), mt_rand($intheight/3,$intheight), $fontcolor);
- imageline($img, mt_rand($intwidth/3, $intwidth), mt_rand(0, $intheight/3), mt_rand(0, $intwidth/3), mt_rand(0, $intheight/3), $fontcolor);
- //??img???????
- imagestring($img, 8, mt_rand(0, $intwidth - strlen($randval) * 10), mt_rand(0, $intheight-12), $randval, $fontcolor);
- imagegif($img);
- imagedestroy($img);
- ?>
-
-
-