daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Mar 14th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     // Put this somewhere on the server and put these in an .htaccess file in the same folder
  3.     //
  4.     // Options +FollowSymLinks
  5.     // RewriteEngine on
  6.     // RewriteRule ^logo$ logo.php
  7.  
  8.     // Then point the image to <htaccess location>/logo. The folder logos is the default location for the logos files (accepts gif/jpg/png)
  9.  
  10.     error_reporting(E_ALL);
  11.     $LOGOSDIR = "logos/";
  12.  
  13.     if ($handle = opendir($LOGOSDIR)) {
  14.         $files = array();
  15.                 while (false !== ($file = readdir($handle))) {
  16.                         $files[] = $file;
  17.                                 }
  18.                     closedir($handle);
  19.     }
  20.     $files = preg_grep('/(png|gif|jpg|jpeg)$/', $files);
  21.     $fullPath = $LOGOSDIR . $files[array_rand($files)];
  22.         $path_parts = pathinfo($fullPath);
  23.     $ext = strtolower($path_parts["extension"]);
  24.    
  25.     switch ($ext) {
  26.       case "gif": $ctype="image/gif"; break;
  27.       case "png": $ctype="image/png"; break;
  28.       case "jpeg":
  29.       case "jpg": $ctype="image/jpg"; break;
  30.       default: $ctype="application/force-download";
  31.     }
  32.     header("Expires: " . date('r',strtotime("+1 days")));
  33.     header("Pragma: cache");
  34.     header("Cache-Control: max-age=86400");
  35.     header("Content-Type: " . $ctype);
  36.     header("Content-Length: " . filesize($fullPath));
  37.     header("Last-Modified: " . date('r',strtotime("today")));
  38.     readfile($fullPath);
  39. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top