makeParamString( $params ) . "-$fileName"; $thumbPath = wfImageThumbDir( $fileName ) . '/' . $thumbName; if ( is_file( $thumbPath ) && filemtime( $thumbPath ) >= filemtime( $imagePath ) ) { wfStreamFile( $thumbPath ); // Can't log profiling data with no Setup.php exit; } } // OK, no valid thumbnail, time to get out the heavy machinery wfProfileOut( 'thumb.php-start' ); require_once( './includes/Setup.php' ); wfProfileIn( 'thumb.php-render' ); $img = Image::newFromName( $fileName ); try { if ( $img ) { $thumb = $img->transform( $params, Image::RENDER_NOW ); } else { $thumb = false; } } catch( Exception $ex ) { // Tried to select a page on a non-paged file? $thumb = false; } if ( $thumb && $thumb->getPath() && file_exists( $thumb->getPath() ) ) { wfStreamFile( $thumb->getPath() ); } elseif ( $img ) { header( 'Cache-Control: no-cache' ); header( 'Content-Type: text/html; charset=utf-8' ); header( 'HTTP/1.1 500 Internal server error' ); if ( !$thumb ) { $msg = wfMsgHtml( 'thumbnail_error', 'Image::transform() returned false' ); } elseif ( $thumb->isError() ) { $msg = $thumb->getHtmlMsg(); } elseif ( !$thumb->getPath() ) { $msg = wfMsgHtml( 'thumbnail_error', 'No path supplied in thumbnail object' ); } else { $msg = wfMsgHtml( 'thumbnail_error', 'Output file missing' ); } echo <<Error generating thumbnail

Error generating thumbnail

$msg

EOT; } else { $badtitle = wfMsg( 'badtitle' ); $badtitletext = wfMsg( 'badtitletext' ); header( 'Cache-Control: no-cache' ); header( 'Content-Type: text/html; charset=utf-8' ); header( 'HTTP/1.1 500 Internal server error' ); echo " $badtitle

$badtitle

$badtitletext

"; } wfProfileOut( 'thumb.php-render' ); wfProfileOut( 'thumb.php' ); wfLogProfilingData(); //-------------------------------------------------------------------------- function thumbGetHandler( $fileName ) { // Determine type $magic = MimeMagic::singleton(); $extPos = strrpos( $fileName, '.' ); if ( $extPos === false ) { return false; } $mime = $magic->guessTypesForExtension( substr( $fileName, $extPos + 1 ) ); return MediaHandler::getHandler( $mime ); } ?>