| 12 | | require_once( dirname( dirname( __FILE__) ) . '/wp-load.php' ); // absolute includes are faster |
| 13 | | require_once( WP_CONTENT_DIR . '/blogs.php' ); |
| 14 | | exit(); |
| | 14 | require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' ); |
| | 15 | ms_default_constants( 'ms-files' ); |
| | 16 | |
| | 17 | error_reporting(0); |
| | 18 | |
| | 19 | // Allow wp-content/blogs.php to be used. |
| | 20 | if ( file_exists( WP_CONTENT_DIR . '/blogs.php' ) ) { |
| | 21 | require_once( WP_CONTENT_DIR . '/blogs.php' ); |
| | 22 | exit; |
| | 23 | } |
| | 24 | |
| | 25 | if ( $current_blog->archived == '1' || $current_blog->spam == '1' || $current_blog->deleted == '1' ) { |
| | 26 | status_header( 404 ); |
| | 27 | die( '404 — File not found.' ); |
| | 28 | } |
| | 29 | |
| | 30 | if ( !function_exists('wp_check_filetype') ) : |
| | 31 | function wp_check_filetype($filename, $mimes = null) { |
| | 32 | // Accepted MIME types are set here as PCRE unless provided. |
| | 33 | $mimes = is_array($mimes) ? $mimes : array ( |
| | 34 | 'jpg|jpeg|jpe' => 'image/jpeg', |
| | 35 | 'gif' => 'image/gif', |
| | 36 | 'png' => 'image/png', |
| | 37 | 'bmp' => 'image/bmp', |
| | 38 | 'tif|tiff' => 'image/tiff', |
| | 39 | 'ico' => 'image/x-icon', |
| | 40 | 'asf|asx|wax|wmv|wmx' => 'video/asf', |
| | 41 | 'avi' => 'video/avi', |
| | 42 | 'mov|qt' => 'video/quicktime', |
| | 43 | 'mpeg|mpg|mpe' => 'video/mpeg', |
| | 44 | 'txt|c|cc|h' => 'text/plain', |
| | 45 | 'rtx' => 'text/richtext', |
| | 46 | 'css' => 'text/css', |
| | 47 | 'htm|html' => 'text/html', |
| | 48 | 'mp3|mp4' => 'audio/mpeg', |
| | 49 | 'ra|ram' => 'audio/x-realaudio', |
| | 50 | 'wav' => 'audio/wav', |
| | 51 | 'ogg' => 'audio/ogg', |
| | 52 | 'mid|midi' => 'audio/midi', |
| | 53 | 'wma' => 'audio/wma', |
| | 54 | 'rtf' => 'application/rtf', |
| | 55 | 'js' => 'application/javascript', |
| | 56 | 'pdf' => 'application/pdf', |
| | 57 | 'doc' => 'application/msword', |
| | 58 | 'pot|pps|ppt' => 'application/vnd.ms-powerpoint', |
| | 59 | 'wri' => 'application/vnd.ms-write', |
| | 60 | 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel', |
| | 61 | 'mdb' => 'application/vnd.ms-access', |
| | 62 | 'mpp' => 'application/vnd.ms-project', |
| | 63 | 'swf' => 'application/x-shockwave-flash', |
| | 64 | 'class' => 'application/java', |
| | 65 | 'tar' => 'application/x-tar', |
| | 66 | 'zip' => 'application/zip', |
| | 67 | 'gz|gzip' => 'application/x-gzip', |
| | 68 | 'exe' => 'application/x-msdownload' |
| | 69 | ); |
| | 70 | |
| | 71 | $type = false; |
| | 72 | $ext = false; |
| | 73 | |
| | 74 | foreach ( (array) $mimes as $ext_preg => $mime_match ) { |
| | 75 | $ext_preg = '!\.(' . $ext_preg . ')$!i'; |
| | 76 | if ( preg_match($ext_preg, $filename, $ext_matches) ) { |
| | 77 | $type = $mime_match; |
| | 78 | $ext = $ext_matches[1]; |
| | 79 | break; |
| | 80 | } |
| | 81 | } |
| | 82 | |
| | 83 | return compact('ext', 'type'); |
| | 84 | } |
| | 85 | endif; |
| | 86 | |
| | 87 | $file = BLOGUPLOADDIR . str_replace( '..', '', $_GET[ 'file' ] ); |
| | 88 | if ( !is_file( $file ) ) { |
| | 89 | status_header( 404 ); |
| | 90 | die( '404 — File not found.' ); |
| | 91 | } |
| | 92 | |
| | 93 | $mime = wp_check_filetype( $_SERVER[ 'REQUEST_URI' ] ); |
| | 94 | if( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) ) |
| | 95 | $mime[ 'type' ] = mime_content_type( $file ); |
| | 96 | |
| | 97 | if( $mime[ 'type' ] ) |
| | 98 | $mimetype = $mime[ 'type' ]; |
| | 99 | else |
| | 100 | $mimetype = 'image/' . substr( $_SERVER[ 'REQUEST_URI' ], strrpos( $_SERVER[ 'REQUEST_URI' ], '.' ) + 1 ); |
| | 101 | |
| | 102 | header( 'Content-type: ' . $mimetype ); // always send this |
| | 103 | if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) ) |
| | 104 | header( 'Content-Length: ' . filesize( $file ) ); |
| | 105 | |
| | 106 | // Optional support for X-Sendfile and X-Accel-Redirect |
| | 107 | if ( WPMU_ACCEL_REDIRECT ) { |
| | 108 | header( 'X-Accel-Redirect: ' . str_replace( WP_CONTENT_DIR, '', $file ) ); |
| | 109 | exit; |
| | 110 | } elseif ( WPMU_SENDFILE ) { |
| | 111 | header( 'X-Sendfile: ' . $file ); |
| | 112 | exit; |
| | 113 | } |
| | 114 | |
| | 115 | $last_modified = gmdate( 'D, d M Y H:i:s', filemtime( $file ) ); |
| | 116 | $etag = '"' . md5( $last_modified ) . '"'; |
| | 117 | header( "Last-Modified: $last_modified GMT" ); |
| | 118 | header( 'ETag: ' . $etag ); |
| | 119 | header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 100000000 ) . ' GMT' ); |
| | 120 | |
| | 121 | // Support for Conditional GET |
| | 122 | $client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false; |
| | 123 | |
| | 124 | if( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) |
| | 125 | $_SERVER['HTTP_IF_MODIFIED_SINCE'] = false; |
| | 126 | |
| | 127 | $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); |
| | 128 | // If string is empty, return 0. If not, attempt to parse into a timestamp |
| | 129 | $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0; |
| | 130 | |
| | 131 | // Make a timestamp for our most recent modification... |
| | 132 | $modified_timestamp = strtotime($last_modified); |
| | 133 | |
| | 134 | if ( ( $client_last_modified && $client_etag ) |
| | 135 | ? ( ( $client_modified_timestamp >= $modified_timestamp) && ( $client_etag == $etag ) ) |
| | 136 | : ( ( $client_modified_timestamp >= $modified_timestamp) || ( $client_etag == $etag ) ) |
| | 137 | ) { |
| | 138 | status_header( 304 ); |
| | 139 | exit; |
| | 140 | } |
| | 141 | |
| | 142 | // If we made it this far, just serve the file |
| | 143 | readfile( $file ); |
| | 144 | |
| | 145 | ?> |
| | 146 | No newline at end of file |