Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Put this somewhere on the server and put these in an .htaccess file in the same folder
- //
- // Options +FollowSymLinks
- // RewriteEngine on
- // RewriteRule ^logo$ logo.php
- // Then point the image to <htaccess location>/logo. The folder logos is the default location for the logos files (accepts gif/jpg/png)
- error_reporting(E_ALL);
- $LOGOSDIR = "logos/";
- if ($handle = opendir($LOGOSDIR)) {
- $files = array();
- while (false !== ($file = readdir($handle))) {
- $files[] = $file;
- }
- closedir($handle);
- }
- $files = preg_grep('/(png|gif|jpg|jpeg)$/', $files);
- $fullPath = $LOGOSDIR . $files[array_rand($files)];
- $path_parts = pathinfo($fullPath);
- $ext = strtolower($path_parts["extension"]);
- switch ($ext) {
- case "gif": $ctype="image/gif"; break;
- case "png": $ctype="image/png"; break;
- case "jpeg":
- case "jpg": $ctype="image/jpg"; break;
- default: $ctype="application/force-download";
- }
- header("Expires: " . date('r',strtotime("+1 days")));
- header("Pragma: cache");
- header("Cache-Control: max-age=86400");
- header("Content-Type: " . $ctype);
- header("Content-Length: " . filesize($fullPath));
- header("Last-Modified: " . date('r',strtotime("today")));
- readfile($fullPath);
- ?>
Add Comment
Please, Sign In to add comment