Advertisement
Zeta_Avenger

Rotation script

Jul 20th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. <?php
  2.  
  3. $folder = '';
  4.  
  5. $exts = 'jpg jpeg png gif';
  6.  
  7. $files = array(); $i = -1;
  8.  
  9. if ('' == $folder) $folder = './';
  10.  
  11. $handle = opendir($folder);
  12.  
  13. $exts = explode(' ', $exts);
  14.  
  15. while (false !== ($file = readdir($handle))) {
  16.     foreach($exts as $ext) {
  17.         if (preg_match('/\.'.$ext.'$/i', $file, $test)) {
  18.             $files[] = $file;
  19.             ++$i;
  20.         }
  21.     }
  22. }
  23.  
  24. closedir($handle);
  25.  
  26. mt_srand((double)microtime()*1000000);
  27.  
  28. $rand = mt_rand(0, $i);
  29.  
  30. header("Cache-Control: no-cache, must-revalidate, no-store");
  31. header('Location: '.$folder.$files[$rand]);
  32.  
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement