Guest User

Test_Script

a guest
Aug 28th, 2015
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.48 KB | None | 0 0
  1. <?php
  2.  
  3. set_time_limit(3600);
  4. error_reporting(E_ALL);
  5. ini_set('display_errors', TRUE);
  6. ini_set('display_startup_errors', TRUE);
  7.  
  8.  
  9. function generateRandomString($length = 10) {
  10.     $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  11.     $charactersLength = strlen($characters);
  12.     $randomString = '';
  13.     for ($i = 0; $i < $length; $i++) {
  14.         $randomString .= $characters[mt_rand(0, $charactersLength - 1)];
  15.     }
  16.     return $randomString;
  17. }
  18.  
  19. isset($_REQUEST["limit"]) ? $limit = $_REQUEST["limit"] : $limit = 10;
  20.  
  21.  
  22.  
  23. echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  24. <html>
  25. <head>
  26. <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">';
  27.  
  28. echo "<title>Test Script</title></head><body>";
  29.  
  30. //ob_start ();
  31. echo "<br><br>A random delay between 20 and 60 seconds will be generated, then a randomly generated string will be displayed<br>The default limit on iterations is ten<br>When the script terminates normally, the phrase \"test complete\" will be output at the bottom<br><br>";
  32.  flush();
  33.  
  34.  
  35. for ($i = 0; $i < $limit; $i++) {
  36.   $delay = mt_rand (20, 60);
  37.   echo "<br><br><br>iteration ".($i+1)." - script will now sleep for $delay seconds";
  38.     flush();
  39.   sleep ($delay);
  40.   echo "<br><br>Here is a random string:<br>";
  41.   $length = mt_rand (50, 100);
  42.   echo generateRandomString($length);
  43.     flush();
  44. }
  45.  
  46.  
  47. echo '<br><br>...test complete</body></html>';
  48. ob_end_flush();
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment