Bry8Star

Untitled

Sep 16th, 2011
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.04 KB | None | 0 0
  1. <?php
  2. // (C) 2011 Bry8Star.
  3. // Bry8Star <at> yahoo <dot> com.
  4. //
  5. // Shuffle Photo :
  6. // Randomly output any image from a folder to the caller of this php
  7. // It should be called in this way :
  8. //     ./shuffle_photo.php?pic=any.jpg
  9. // example : <img src="shuffle_photo.php?pic=any.jpg" alt="" />
  10. //
  11.  
  12. $ref = strtolower($_SERVER['HTTP_REFERER']);
  13. $agnt = strtolower($_SERVER['HTTP_USER_AGENT']);
  14. $rurl = @parse_url($ref);
  15.  
  16. $v = '0';
  17. $rc = '1';
  18.  
  19. $mydom = array(
  20. 'exm1.com',
  21. 'www.exm1.com');
  22.  
  23. $err = 'http://www.exm1.com/400.shtml';
  24.        
  25. if(strpos($ref, 'google') != ''){ $v = '1';}
  26. if(strpos($agnt, 'google') != ''){ $v = '2';}
  27. if(strpos($ref, 'altavista') != ''){ $v = '1';}
  28. if(strpos($agnt, 'altavista') != ''){ $v = '2';}
  29. if(strpos($ref, 'yahoo') != ''){ $v = '1';}
  30. if(strpos($agnt, 'yahoo') != ''){ $v = '2';}
  31. if(strpos($agnt, 'slurp') != ''){ $v = '2';}
  32. if(strpos($ref, 'lycos') != ''){ $v = '1';}
  33. if(strpos($agnt, 'lycos') != ''){ $v = '2';}
  34. if(strpos($ref, 'ask') != ''){ $v = '1';}
  35. if(strpos($agnt, 'teoma') != ''){ $v = '2';}
  36.  
  37. if($rc == '1') {
  38.     if(isset($_REQUEST['pic'])) {
  39.         while(list($k,$c)=each($mydom)) {
  40.             if(strstr($ref,$c)) {
  41.                 $v = '3';
  42.             }
  43.             else {
  44.                 if(strstr($ref.$rurl[path],$c)) {
  45.                     $v = '3';
  46.                 }
  47.             }
  48.         }
  49.     }
  50.     if($v == '0') {
  51.         header('Location: '. $err .'');
  52.         exit;
  53.     }
  54. }
  55.  
  56. $picL2 = array(         # image/pic LIST
  57. 'pic01.jpg',        #1
  58. 'pic02.jpg',        #2
  59. 'pic03.jpg');       #3
  60. // Add numbers inside below array , keep 1 less than the above LIST,
  61. // as it already starts with 0.
  62. $numL2 = array(0,1,2);  
  63. $temp2 = count($numL2);
  64. $secssame2=8;
  65. $seedval2=(int)(time()/$secssame2);
  66. srand($seedval2);
  67. for ($i2=0; $i2<$temp2; ++$i2){
  68.     $rand2=rand(0,$temp2);      //$rand2=rand(0,$temp2-1);
  69.     $temp2 =$numL2[$i2];
  70.     $numL2[$i2]=$numL2[$rand2];
  71.     $numL2[$rand2]=$temp2;
  72. }
  73. $temp2 = $numL2[5];
  74. $file2 = $picL2[$temp2];
  75. header('Content-Disposition: filename=any.jpg');
  76. header('Content-Length: ' . filesize( $file2 ) );
  77. header('Content-type: image/jpeg');
  78. readfile($file2);
  79. ?>
Advertisement
Add Comment
Please, Sign In to add comment