52 foreach ( $headers as $name =>
$header ) {
54 if (
in_array( $nameLower, [
'range',
'if-modified-since' ],
true ) ) {
57 $rawHeaders[] =
"$name: $header";
71 $this->obResetFunc =
$params[
'obResetFunc'] ?? [
__CLASS__,
'resetOutputBuffers' ];
72 $this->streamMimeFunc =
$params[
'streamMimeFunc'] ?? [
__CLASS__,
'contentTypeFromPath' ];
87 $headers = [], $sendErrors =
true, $optHeaders = [], $flags = 0
90 if ( ( ( $flags & self::STREAM_HEADLESS ) == 0 || $headers ) &&
headers_sent() ) {
91 echo
"Headers already sent, terminating.\n";
104 $info =
stat( $this->path );
115 $mtimeCT =
new ConvertibleTimestamp( $info[
'mtime'] );
116 $headerFunc(
'Last-Modified: ' . $mtimeCT->getTimestamp( TS_RFC2822 ) );
118 if ( ( $flags & self::STREAM_ALLOW_OB ) == 0 ) {
134 if (
isset( $optHeaders[
'if-modified-since'] ) ) {
135 $modsince =
preg_replace(
'/;.*$/',
'', $optHeaders[
'if-modified-since'] );
136 if ( $mtimeCT->getTimestamp( TS_UNIX ) <= strtotime( $modsince ) ) {
137 ini_set(
'zlib.output_compression', 0 );
144 foreach ( $headers as
$header ) {
148 if (
isset( $optHeaders[
'range'] ) ) {
153 $headerFunc(
"Content-Range: bytes {$range[0]}-{$range[1]}/{$info['size']}" );
154 }
elseif ( $range ===
'invalid' ) {
158 $headerFunc(
'Content-Type: text/html; charset=utf-8' );
159 $headerFunc(
'Content-Range: bytes */' . $info[
'size'] );
172 $handle =
fopen( $this->path,
'rb' );
175 fseek( $handle, $range[0] );
176 $remaining = $range[2];
177 while ( $remaining > 0 && $ok ) {
178 $bytes = min( $remaining, 8 * 1024 );
188 return readfile( $this->path ) !==
false;
202 if ( ( $flags & self::STREAM_HEADLESS ) == 0 ) {
204 header(
'Cache-Control: no-cache' );
205 header(
'Content-Type: text/html; charset=utf-8' );
209 echo
"<!DOCTYPE html><html><body>
210 <h1>File not found</h1>
211 <p>Although this PHP script ($encScript) exists, the file requested for output
212 ($encFile) does not.</p>
227 if (
preg_match(
'#^bytes=(\d*)-(\d*)$#', $range, $m ) ) {
228 list( , $start, $end ) = $m;
229 if ( $start ===
'' && $end ===
'' ) {
230 $absRange = [ 0, $size - 1 ];
231 }
elseif ( $start ===
'' ) {
232 $absRange = [ $size - $end, $size - 1 ];
233 }
elseif ( $end ===
'' ) {
234 $absRange = [ $start, $size - 1 ];
236 $absRange = [ $start, $end ];
238 if ( $absRange[0] >= 0 && $absRange[1] >= $absRange[0] ) {
239 if ( $absRange[0] < $size ) {
240 $absRange[1] = min( $absRange[1], $size - 1 );
241 $absRange[2] = $absRange[1] - $absRange[0] + 1;
243 }
elseif ( $absRange[0] == 0 && $size == 0 ) {
244 return 'unrecognized';
249 return 'unrecognized';
283 return 'unknown/unknown';
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Functions related to the output of file content.
static preprocessHeaders( $headers)
Takes HTTP headers in a name => value format and converts them to the weird format expected by stream...
static send404Message( $fname, $flags=0)
Send out a standard 404 message for a file.
static resetOutputBuffers()
static contentTypeFromPath( $filename)
Determine the file type of a file based on the path.
static parseRange( $range, $size)
Convert a Range header value to an absolute (start, end) range tuple.
__construct( $path, array $params=[])
stream( $headers=[], $sendErrors=true, $optHeaders=[], $flags=0)
Stream a file to the browser, adding all the headings and fun stuff.
static header( $code)
Output an HTTP status code header.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
processing should stop and the error should be shown to the user * false
while(( $__line=Maintenance::readconsole()) !==false) print
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
if(!is_readable( $file)) $ext