seccode.php 861 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace app\index;
  3. class seccode extends Base
  4. {
  5. function index()
  6. {
  7. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  8. header("Cache-Control: no-cache, must-revalidate");
  9. header("Pragma: no-cache");
  10. header("Content-type: image/png");
  11. $authnum_session = NULL;
  12. for ($i = 0; $i < 4; $i++) {
  13. $authnum_session .= rand(0, 9);
  14. }
  15. $_SESSION['code'] = $authnum_session;
  16. $im = imagecreate(50, 24);
  17. ImageColorAllocate($im, 30, 144, 255);
  18. imagestring($im, 5, 8, 2, $authnum_session, ImageColorAllocate($im, 255, 255, 255));
  19. for ($i = 0; $i < 3; $i++) {
  20. imageline($im, rand(0, 30), rand(0, 21), rand(20, 40), rand(0, 21), ImageColorAllocate($im, 220, 220, 220));
  21. }
  22. for ($i = 0; $i < 90; $i++) {
  23. imagesetpixel($im, rand() % 70, rand() % 30, ImageColorAllocate($im, 200, 200, 200));
  24. }
  25. ImagePNG($im);
  26. ImageDestroy($im);
  27. }
  28. }