PageRenderTime 60ms CodeModel.GetById 36ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/book/manage/yzm.php

http://mycaptain.googlecode.com/
PHP | 33 lines | 26 code | 3 blank | 4 comment | 3 complexity | df7ae6d71681368e5a5d23320a238d37 MD5 | raw file
  1. <?php
  2. session_start();//??session
  3. $randval;
  4. for($i = 0; $i<4; $i++){
  5. //??A-Z???ASCII???
  6. $randstr = mt_rand(ord('A'), ord('Z'));//ord($str)?????ASCII
  7. $randv = mt_rand(0, 10);//??0?10
  8. global $randval;
  9. //??0-9??????
  10. if($randv % 2 == 0){//?????,????
  11. $randval .= mt_rand(0, 9);
  12. }else{//????????,?chr??
  13. $randval .= chr($randstr);//chr()?????? ascii ?????????
  14. }
  15. }
  16. $_SESSION["randval"] = $randval;
  17. $intheight = 18;//????????
  18. $intwidth = 50;//????????,?????
  19. $img = imagecreatetruecolor($intwidth, $intheight);
  20. $fontcolor = imagecolorallocate($img, 255, 0, 0);
  21. $backcolor = imagecolorallocate($img, 255, 255, 255);
  22. imagefill($img, 0, 0, $backcolor);
  23. //??
  24. imageline($img, mt_rand(0,$intwidth/3), mt_rand(0,$intheight/3), mt_rand($intwidth/3,$intwidth), mt_rand($intheight/3,$intheight), $fontcolor);
  25. imageline($img, mt_rand($intwidth/3, $intwidth), mt_rand(0, $intheight/3), mt_rand(0, $intwidth/3), mt_rand(0, $intheight/3), $fontcolor);
  26. //??img???????
  27. imagestring($img, 8, mt_rand(0, $intwidth - strlen($randval) * 10), mt_rand(0, $intheight-12), $randval, $fontcolor);
  28. imagegif($img);
  29. imagedestroy($img);
  30. ?>