Go to the documentation of this file.
24 define(
'MW_NO_OUTPUT_COMPRESSION', 1 );
25 require __DIR__ .
'/includes/WebStart.php';
30 if ( defined(
'THUMB_HANDLER' ) ) {
52 $params = get_magic_quotes_gpc()
53 ? array_map(
'stripslashes', $_GET )
67 # Set action base paths so that WebRequest::getPathInfo()
68 # recognizes the "X" as the 'title' in ../thumb_handler.php/X urls.
69 # Note: If Custom per-extension repo paths are set, this may break.
79 wfThumbError( 404,
'Could not determine the name of the requested thumbnail.' );
85 wfThumbError( 400,
'The specified thumbnail parameters are not recognized.' );
132 $fileName = strtr( $fileName,
'\\/',
'__' );
140 # @todo fix
this convention to actually be reasonable.
141 $repo->getZonePath(
'public' ) .
'/' . $repo->getTempHashPath( $fileName ) . $fileName
143 } elseif ( $isOld ) {
145 $bits = explode(
'!', $fileName, 2 );
146 if ( count( $bits ) != 2 ) {
167 $varyHeader =
array();
169 if ( !$img->getTitle() || !$img->getTitle()->userCan(
'read' ) ) {
170 wfThumbError( 403,
'Access denied. You do not have permission to access ' .
171 'the source file.' );
174 $headers[] =
'Cache-Control: private';
175 $varyHeader[] =
'Cookie';
179 if ( isset(
$params[
'thumbName'] ) ) {
183 wfThumbError( 400,
'The specified thumbnail parameters are not recognized.' );
188 if ( !$img->exists() ) {
189 $redirectedLocation =
false;
195 if ( $possRedirFile && !is_null( $possRedirFile->getRedirected() ) ) {
196 $redirTarget = $possRedirFile->getName();
198 if ( $targetFile->exists() ) {
199 $newThumbName = $targetFile->thumbName(
$params );
201 $newThumbUrl = $targetFile->getArchiveThumbUrl(
202 $bits[0] .
'!' . $targetFile->getName(), $newThumbName );
204 $newThumbUrl = $targetFile->getThumbUrl( $newThumbName );
211 if ( $redirectedLocation ) {
215 $response->header(
'Location: ' . $redirectedLocation );
217 gmdate(
'D, d M Y H:i:s', time() + 12 * 3600 ) .
' GMT' );
218 if ( $wgVaryOnXFP ) {
219 $varyHeader[] =
'X-Forwarded-Proto';
221 if ( count( $varyHeader ) ) {
222 $response->header(
'Vary: ' . implode(
', ', $varyHeader ) );
228 wfThumbError( 404,
"The source file '$fileName' does not exist." );
230 } elseif ( $img->getPath() ===
false ) {
231 wfThumbError( 500,
"The source file '$fileName' is not locally accessible." );
237 if ( !empty( $_SERVER[
'HTTP_IF_MODIFIED_SINCE'] ) ) {
239 $imsString = preg_replace(
'/;.*$/',
'', $_SERVER[
"HTTP_IF_MODIFIED_SINCE"] );
242 $imsUnix = strtotime( $imsString );
245 header(
'HTTP/1.1 304 Not Modified' );
255 $thumbName = $img->thumbName(
$params );
256 if ( !strlen( $thumbName ) ) {
257 wfThumbError( 400,
'The specified thumbnail parameters are not valid.' );
270 if ( isset(
$params[
'rel404'] ) ) {
271 if ( rawurldecode(
$params[
'rel404'] ) === $img->getThumbRel( $thumbName ) ) {
273 } elseif ( rawurldecode(
$params[
'rel404'] ) === $img->getThumbRel( $thumbName2 ) ) {
280 gmdate(
'D, d M Y H:i:s', time() + 7 * 86400 ) .
' GMT' );
281 if ( $wgVaryOnXFP ) {
282 $varyHeader[] =
'X-Forwarded-Proto';
284 if ( count( $varyHeader ) ) {
285 $response->header(
'Vary: ' . implode(
', ', $varyHeader ) );
289 wfThumbError( 404,
"The given path of the specified thumbnail is incorrect;
290 expected '" . $img->getThumbRel( $thumbName ) .
"' but got '" .
291 rawurldecode(
$params[
'rel404'] ) .
"'." );
296 $dispositionType = isset(
$params[
'download'] ) ?
'attachment' :
'inline';
299 $headers[] =
"Content-Disposition: {$img->getThumbDisposition( $thumbName, $dispositionType )}";
301 if ( count( $varyHeader ) ) {
302 $headers[] =
'Vary: ' . implode(
', ', $varyHeader );
306 $thumbPath = $img->getThumbPath( $thumbName );
307 if ( $img->getRepo()->fileExists( $thumbPath ) ) {
308 $img->getRepo()->streamFile( $thumbPath, $headers );
313 if (
$user->pingLimiter(
'renderfile' ) ) {
324 }
catch ( Exception $ex ) {
333 $errorMsg = $msg->rawParams(
'File::transform() returned false' )->escaped();
334 } elseif ( $thumb->isError() ) {
335 $errorMsg = $thumb->getHtmlMsg();
336 } elseif ( !$thumb->hasFile() ) {
337 $errorMsg = $msg->rawParams(
'No path supplied in thumbnail object' )->escaped();
338 } elseif ( $thumb->fileIsSource() ) {
340 rawParams(
'Image was not scaled, is the requested width bigger than the source?' )->escaped();
343 if ( $errorMsg !==
false ) {
348 $thumb->streamFile( $headers );
372 if ( !
$wgMemc->incr( $key, 1 ) ) {
373 if ( !
$wgMemc->add( $key, 1, 3600 ) ) {
385 global $wgAttemptFailureEpoch;
387 return wfMemcKey(
'attempt-failures', $wgAttemptFailureEpoch,
388 $img->
getRepo()->getName(), md5( $img->
getName() ), md5( $thumbName ) );
413 $hashDirReg = $subdirReg =
'';
414 for ( $i = 0; $i < $repo->getHashLevels(); $i++ ) {
415 $subdirReg .=
'[0-9a-f]';
416 $hashDirReg .=
"$subdirReg/";
420 if ( preg_match(
"!^((archive/)?$hashDirReg([^/]*)/([^/]*))$!", $thumbRel, $m ) ) {
421 list( , $rel, $archOrTemp, $filename, $thumbname ) = $m;
423 } elseif ( preg_match(
"!^(temp/)($hashDirReg([^/]*)/([^/]*))$!", $thumbRel, $m ) ) {
424 list( , $archOrTemp, $rel, $filename, $thumbname ) = $m;
430 if ( $archOrTemp ===
'archive/' ) {
432 } elseif ( $archOrTemp ===
'temp/' ) {
436 $params[
'thumbName'] = $thumbname;
449 if ( !isset(
$params[
'thumbName'] ) ) {
450 throw new MWException(
"No thumbnail name passed to wfExtractThumbParams" );
453 $thumbname =
$params[
'thumbName'];
470 $handler =
$file->getHandler();
473 $fileNamePos = strrpos( $thumbname,
$params[
'f'] );
474 if ( $fileNamePos ===
false ) {
476 $fileNamePos = strrpos( $thumbname,
'thumbnail' );
479 if ( $handler && $fileNamePos !==
false ) {
480 $paramString = substr( $thumbname, 0, $fileNamePos - 1 );
481 $extraParams = $handler->parseParamString( $paramString );
482 if ( $extraParams !==
false ) {
488 if ( preg_match(
'!^(page(\d*)-)*(\d*)px-[^/]*$!', $thumbname,
$matches ) ) {
509 header(
'Cache-Control: no-cache' );
510 header(
'Content-Type: text/html; charset=utf-8' );
511 if ( $status == 404 ) {
512 header(
'HTTP/1.1 404 Not found' );
513 } elseif ( $status == 403 ) {
514 header(
'HTTP/1.1 403 Forbidden' );
515 header(
'Vary: Cookie' );
517 header(
'HTTP/1.1 500 Internal server error' );
519 if ( $wgShowHostnames ) {
520 header(
'X-MW-Thumbnail-Renderer: ' .
wfHostname() );
521 $url = htmlspecialchars( isset( $_SERVER[
'REQUEST_URI'] ) ? $_SERVER[
'REQUEST_URI'] :
'' );
523 $debug =
"<!-- $url -->\n<!-- $hostname -->\n";
528 <html><head><
title>Error generating thumbnail</
title></head>
530 <h1>Error generating thumbnail</h1>
wfThumbHandleRequest()
Handle a thumbnail request via query parameters.
static singleton()
Get a RepoGroup instance.
wfThumbHandle404()
Handle a thumbnail request via thumbnail file URL.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest to get request data $wgMemc
wfThumbAttemptKey(File $img, $thumbName)
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
A file object referring to either a standalone local file, or a file in a local repository with no da...
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
wfExtractThumbRequestInfo( $thumbRel)
Convert pathinfo type parameter, into normal request parameters.
wfHostname()
Fetch server name for use in error reporting etc.
wfExtractThumbParams( $file, $params)
Convert a thumbnail name (122px-foo.png) to parameters, using file handler.
to move a page</td >< td > &*You are moving the page across *A non empty talk page already exists under the new or *You uncheck the box below In those you will have to move or merge the page manually if desired</td >< td > be sure to &You are responsible for making sure that links continue to point where they are supposed to go Note that the page will &a page at the new title
Implements some public methods and some protected utility functions which are required by multiple ch...
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero based
Class for handling function-scope profiling.
wfMemcKey()
Get a cache key.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
wfRestoreWarnings()
Restore error level to previous value.
static getPathInfo( $want='all')
Extract relevant query arguments from the http request uri's path to be merged with the normal php pr...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
wfThumbError( $status, $msg)
Output a thumbnail generation error message.
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
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
wfThumbIncrAttemptFailures(File $img, $thumbName)
</td >< td > &</td >< td > t want your writing to be edited mercilessly and redistributed at will
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
presenting them properly to the user as errors is done by the caller $title
if(!defined( 'MEDIAWIKI')) if(!isset( $wgVersion)) $matches
static getGroupPermissions( $groups)
Get the permissions associated with a given list of groups.
getName()
Return the name of this file.
static getMain()
Static methods.
static getMessage( $code)
Get the message associated with HTTP response code $code.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
if(PHP_SAPI !='cli') $file
const RENDER_NOW
Force rendering in the current process.
& wfGetLBFactory()
Get the load balancer factory object.
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going on
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of and so on Built in content types are
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
</span ></p > ! end ! test Comments and Indent Pre ! wikitext<!-- comment 1 --> asdf<!-- comment 1 --> asdf<!-- comment 2 --><!-- comment 1 --> asdf<!-- comment 2 --> xyz<!-- comment 1 --> asdf<!-- comment 2 --> xyz ! html< pre > asdf</pre >< pre > asdf</pre >< pre > asdf</pre >< p > xyz</p >< pre > asdf xyz</pre > ! end ! test Comment test ! wikitext asdf<!-- comment 1 --> jkl ! html< p > asdf jkl</p > ! end ! test Comment test ! wikitext asdf<!-- comment 1 --> jkl ! html< p > asdf</p >< p > jkl</p > ! end ! test Comment test ! wikitext asdf<!-- comment 1 --><!-- comment 2 --> jkl ! html< p > asdf jkl</p > ! end ! test Comment test ! wikitext asdf<!-- comment 1 --> jkl ! html< p > asdfjkl</p > ! end ! test Comment spacing ! wikitext a<!-- foo --> b<!-- bar --> c ! html< p > a</p >< pre > b</pre >< p > c</p > ! end ! test Comment whitespace ! wikitext<!-- returns a single newline, not nothing, since the newline after > is not stripped ! html ! end ! test Comment semantics and delimiters ! wikitext<!-- --><!----><!-----><!------> ! html ! end ! test Comment semantics and redux ! wikitext<!-- In SGML every "foo" here would actually show up in the text -- foo -- bar-- foo -- funky huh? ... --> ! html ! end ! test Comment semantics and that wouldn t be valid XML however
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at name
getRepo()
Returns the repository.
wfLocalFile( $title)
Get an object referring to a locally registered file.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfStreamThumb(array $params)
Stream a thumbnail specified by parameters.
wfThumbIsAttemptThrottled(File $img, $thumbName, $limit)