Advertisement
Guest User

Untitled

a guest
Dec 5th, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. <?php
  2.  
  3.     session_start();
  4.  
  5.     $action = isset($_GET['action']) ? $_GET['action'] : NULL;
  6.  
  7.     if ($action == 'file-end') {
  8.         session_write_close();
  9.         $str = "This is a fairly large file\n";
  10.         header('Content-Type: text/plain');
  11.         header('Content-Length: '.(strlen($str) * 1000000));
  12.         header('Content-Disposition: attachment; filename="largefile.txt"');
  13.         for ($i = 0; $i < 1000000; $i++) {
  14.             echo $str;
  15.         }
  16.     } else if ($action == 'file-noend') {
  17.         $str = "This is a fairly large file\n";
  18.         header('Content-Type: text/plain');
  19.         header('Content-Length: '.(strlen($str) * 1000000));
  20.         header('Content-Disposition: attachment; filename="largefile.txt"');
  21.         for ($i = 0; $i < 1000000; $i++) {
  22.             echo $str;
  23.         }
  24.     } else if ($action == 'click') {
  25.         echo "
  26. You clicked the link<br>
  27. <a href='?action=null'>back</a>";
  28.     } else {
  29.         echo "
  30. <a href='?action=file-end'>End the session and get the file</a><br>
  31. <a href='?action=file-noend'>Get the file without ending the session</a><br>
  32. <a href='?action=click'>Click the link</a>
  33. ";
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement