This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 20th, 2011  |  syntax: PHP  |  size: 1.02 KB  |  views: 64  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. //Set time of starting
  3. $time1 = microtime(true);
  4. /**
  5.  * @return integer max time limit of execution that PMA can use
  6.  */
  7. function get_maxtime()
  8. {
  9. /**
  10.  * Seems hackish lol.
  11.  * Returns value of max_execution_time if safe mode is on
  12.  * else returns value set by set_time_limit
  13.  */
  14.         return (ini_get('safe_mode')) ? ini_get('max_execution_time') :(set_time_limit(5)) ? 5 : 0;
  15.  
  16. }
  17. echo "Started <br />";
  18. //Set and get the max time of execution
  19. $maxtime = get_maxtime();
  20. //Send out maxtime for user to see
  21. echo "$maxtime <br />";
  22.  
  23. for($i=1;$i<10000000;$i++)
  24. {
  25.         $mytime = $maxtime - (microtime(true)-$time1);
  26.        
  27.         //Stop working, prepare for clean redirect etc if only 1 second or less is left
  28.         if($mytime <= 1)
  29.         {
  30.                 // Do some necessary cleanup. stop outputting download
  31.                 // set some notice to show that we have more data to export.
  32.                 // redirect to the new export page with data starting with the row next in iteration.          
  33.                 die("1 second only. ".$i." iterations done");
  34.         }
  35. }
  36. //finished successfully
  37. echo "Ended Sucessfully at: ",$mytime," Seconds";
clone this paste RAW Paste Data