garbage.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. // Disable Compression
  3. @ini_set('zlib.output_compression', 'Off');
  4. @ini_set('output_buffering', 'Off');
  5. @ini_set('output_handler', '');
  6. /**
  7. * @return int
  8. */
  9. function getChunkCount()
  10. {
  11. if (
  12. !array_key_exists('ckSize', $_GET)
  13. || !ctype_digit($_GET['ckSize'])
  14. || (int) $_GET['ckSize'] <= 0
  15. ) {
  16. return 4;
  17. }
  18. if ((int) $_GET['ckSize'] > 50) {
  19. return 50;
  20. }
  21. return (int) $_GET['ckSize'];
  22. }
  23. /**
  24. * @return void
  25. */
  26. function sendHeaders()
  27. {
  28. header('HTTP/1.1 200 OK');
  29. if (isset($_GET['cors'])) {
  30. header('Access-Control-Allow-Origin: *');
  31. header('Access-Control-Allow-Methods: GET, POST');
  32. }
  33. // Indicate a file download
  34. header('Content-Description: File Transfer');
  35. header('Content-Type: application/octet-stream');
  36. header('Content-Disposition: attachment; filename=random.dat');
  37. header('Content-Transfer-Encoding: binary');
  38. // Cache settings: never cache this request
  39. header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0, s-maxage=0');
  40. header('Cache-Control: post-check=0, pre-check=0', false);
  41. header('Pragma: no-cache');
  42. }
  43. // Determine how much data we should send
  44. $chunks = getChunkCount();
  45. // Generate data
  46. $data = openssl_random_pseudo_bytes(1048576);
  47. // Deliver chunks of 1048576 bytes
  48. sendHeaders();
  49. for ($i = 0; $i < $chunks; $i++) {
  50. echo $data;
  51. flush();
  52. }