[ Root ] [ Search ] [ Index ]

PHP Cross Reference of WordPress MU 2.9.2

Provided by Yoast

title

Body

[close]

/wp-content/ -> blogs.php (source)

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


Generated: Mon May 3 12:25:32 2010 Cross-referenced by PHPXref 0.7