example09.png.php 681 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. $px = isset($_GET['px']) ? $_GET['px'] : 0;
  3. $px = preg_replace('/[^0-9]/isU', '', $px);
  4. $py = isset($_GET['py']) ? $_GET['py'] : 0;
  5. $py = preg_replace('/[^0-9]/isU', '', $py);
  6. if ($px<1) {
  7. $px = 5;
  8. }
  9. if ($py<1) {
  10. $py = 5;
  11. }
  12. if ($px>20) {
  13. $px = 20;
  14. }
  15. if ($py>20) {
  16. $py = 20;
  17. }
  18. $width = 100;
  19. $height = 100;
  20. $im = imagecreatetruecolor($width, $height);
  21. for ($y=0; $y<$height; $y+= $py) {
  22. for ($x=0; $x<$width; $x+= $px) {
  23. $c = imagecolorallocate($im, 200-$x, 100+$y, 100+$x-$y);
  24. imagefilledrectangle($im, $x, $y, $x+$px, $y+$py, $c);
  25. }
  26. }
  27. header("Content-type: image/png");
  28. imagepng($im);
  29. imagedestroy($im);