diff options
| author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-11-25 11:28:06 +0000 |
|---|---|---|
| committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-11-25 11:28:06 +0000 |
| commit | 3588965a185e90bbb779b97ccf7cac2bb64b7320 (patch) | |
| tree | bce9b61fe8600e9301601600ee114b68bb2e6565 | |
| parent | c1ef28a0c9034737265c5b31b3dcea0e759ce500 (diff) | |
| download | wordpress-mu-3588965a185e90bbb779b97ccf7cac2bb64b7320.tar.gz wordpress-mu-3588965a185e90bbb779b97ccf7cac2bb64b7320.tar.xz wordpress-mu-3588965a185e90bbb779b97ccf7cac2bb64b7320.zip | |
We need this blogs script!
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@448 7be80a69-a1ef-0310-a953-fb0f7c49ff36
| -rw-r--r-- | wp-inst/wp-content/blogs.php | 51 | ||||
| -rw-r--r-- | wp-inst/wp-content/index.php | 3 |
2 files changed, 54 insertions, 0 deletions
diff --git a/wp-inst/wp-content/blogs.php b/wp-inst/wp-content/blogs.php new file mode 100644 index 0000000..8341e7d --- /dev/null +++ b/wp-inst/wp-content/blogs.php @@ -0,0 +1,51 @@ +<?php +define( "BLOGDEFINITION", true ); +require_once( "../wp-config.php" ); + +// Referrer protection +if( $_SERVER["HTTP_REFERER"] ) { + if( strpos( $_SERVER["HTTP_REFERER"], $current_blog->domain ) == false ) { + // do something against hot linking sites! + } +} +$file = $_GET[ 'file' ]; +$file = ABSPATH . "wp-content/blogs.dir/" . $blog_id . '/files/' . $file; + +if( is_file( $file ) ) { + $etag = md5( $file . filemtime( $file ) ); + $lastModified = date( "D, j M Y H:i:s ", filemtime( $file ) ) . "GMT"; + #$headers = apache_request_headers(); + // get mime type + $ext = substr( $_SERVER[ 'REQUEST_URI' ], strrpos( $_SERVER[ 'REQUEST_URI' ], '.' ) + 1 ); + $ext_list = array( "jpg" => "image/jpeg", "mp3" => "audio/mpeg", "mov" => "video/quicktime" ); + if( $ext_list[ $ext ] ) { + $mimetype = $ext_list[ $ext ]; + } else { + $mimetype = "image/$ext"; + } + + // from http://blog.rd2inc.com/archives/2005/03/24/making-dynamic-php-pages-cacheable/ + //if( $headers[ 'If-Range' ] == '"' . $etag . '"' || $lastModified == $headers['If-Modified-Since']) { + if( $_SERVER[ 'HTTP_IF_NONE_MATCH' ] == '"' . $etag . '"' || $lastModified == $_SERVER['HTTP_IF_MODIFIED_SINCE']) { + // They already have an up to date copy so tell them + header('HTTP/1.1 304 Not Modified'); + header('Cache-Control: private'); + header('Content-Type: $mimetype'); + header('ETag: "'.$etag.'"'); + } else { + header("Content-type: $mimetype" ); + header( "Last-Modified: " . $lastModified ); + header( 'Accept-Ranges: bytes' ); + header( "Content-Length: " . filesize( $file ) ); + header( 'ETag: "' . $etag . '"' ); + readfile( $file ); + } +} else { + // 404 + header("HTTP/1.1 404 Not Found"); + print "<html><head><title>Error 404! File Not Found!</title></head>"; + print "<body>"; + print "<h1>File Not Found!</h1>"; + print "</body></html>"; +} +?> diff --git a/wp-inst/wp-content/index.php b/wp-inst/wp-content/index.php new file mode 100644 index 0000000..3d5acf0 --- /dev/null +++ b/wp-inst/wp-content/index.php @@ -0,0 +1,3 @@ +<?php
+// Silence is golden.
+?>
\ No newline at end of file |
