| 1 |
<?php |
|---|
| 2 |
define( "BLOGDEFINITION", true ); |
|---|
| 3 |
require_once( "../wp-config.php" ); |
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
if( $_SERVER["HTTP_REFERER"] ) { |
|---|
| 7 |
if( strpos( $_SERVER["HTTP_REFERER"], $current_blog->domain ) == false ) { |
|---|
| 8 |
|
|---|
| 9 |
} |
|---|
| 10 |
} |
|---|
| 11 |
$file = $_GET[ 'file' ]; |
|---|
| 12 |
$file = ABSPATH . "wp-content/blogs.dir/" . $blog_id . '/files/' . $file; |
|---|
| 13 |
|
|---|
| 14 |
if( is_file( $file ) ) { |
|---|
| 15 |
$etag = md5( $file . filemtime( $file ) ); |
|---|
| 16 |
$lastModified = date( "D, j M Y H:i:s ", filemtime( $file ) ) . "GMT"; |
|---|
| 17 |
|
|---|
| 18 |
// get mime type |
|---|
| 19 |
$ext = substr( $_SERVER[ 'REQUEST_URI' ], strrpos( $_SERVER[ 'REQUEST_URI' ], '.' ) + 1 ); |
|---|
| 20 |
$ext_list = array( "jpg" => "image/jpeg", "mp3" => "audio/mpeg", "mov" => "video/quicktime" ); |
|---|
| 21 |
if( $ext_list[ $ext ] ) { |
|---|
| 22 |
$mimetype = $ext_list[ $ext ]; |
|---|
| 23 |
} else { |
|---|
| 24 |
$mimetype = "image/$ext"; |
|---|
| 25 |
} |
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
if( $_SERVER[ 'HTTP_IF_NONE_MATCH' ] == '"' . $etag . '"' || $lastModified == $_SERVER['HTTP_IF_MODIFIED_SINCE']) { |
|---|
| 29 |
|
|---|
| 30 |
header('HTTP/1.1 304 Not Modified'); |
|---|
| 31 |
header('Cache-Control: private'); |
|---|
| 32 |
header('Content-Type: $mimetype'); |
|---|
| 33 |
header('ETag: "'.$etag.'"'); |
|---|
| 34 |
} else { |
|---|
| 35 |
header("Content-type: $mimetype" ); |
|---|
| 36 |
header( "Last-Modified: " . $lastModified ); |
|---|
| 37 |
header( 'Accept-Ranges: bytes' ); |
|---|
| 38 |
header( "Content-Length: " . filesize( $file ) ); |
|---|
| 39 |
header( 'ETag: "' . $etag . '"' ); |
|---|
| 40 |
readfile( $file ); |
|---|
| 41 |
} |
|---|
| 42 |
} else { |
|---|
| 43 |
|
|---|
| 44 |
header("HTTP/1.1 404 Not Found"); |
|---|
| 45 |
print "<html><head><title>Error 404! File Not Found!</title></head>"; |
|---|
| 46 |
print "<body>"; |
|---|
| 47 |
print "<h1>File Not Found!</h1>"; |
|---|
| 48 |
print "</body></html>"; |
|---|
| 49 |
} |
|---|
| 50 |
?> |
|---|
| 51 |
|
|---|