further simplify context link code; use non-greedy matching instead of modifying...
[lhc/web/wiklou.git] / thumb.php
index 32dec6d..d4e561e 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -4,19 +4,12 @@
  * PHP script to stream out an image thumbnail.
  * If the file exists, we make do with abridged MediaWiki initialisation.
  */
-
-define( 'MEDIAWIKI', true );
-unset( $IP );
-if ( isset( $_REQUEST['GLOBALS'] ) ) {
-       echo '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>';
-       die( -1 );
-}
-
-$wgNoOutputBuffer = true;
-
-require_once( './includes/Defines.php' );
-require_once( './LocalSettings.php' );
+define( 'MW_NO_SETUP', 1 );
+require_once( './includes/WebStart.php' );
+wfProfileIn( 'thumb.php' );
+wfProfileIn( 'thumb.php-start' );
 require_once( 'GlobalFunctions.php' );
+require_once( 'ImageFunctions.php' );
 
 $wgTrivialMimeDetection = true; //don't use fancy mime detection, just check the file extension for jpg/gif/png.
 
@@ -51,12 +44,14 @@ $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( 'Setup.php' );
-wfProfileIn( 'thumb.php' );
+wfProfileIn( 'thumb.php-render' );
 
 $img = Image::newFromName( $fileName );
 if ( $img ) {
@@ -78,7 +73,8 @@ if ( $thumb && $thumb->path ) {
 </body></html>";
 }
 
+wfProfileOut( 'thumb.php-render' );
 wfProfileOut( 'thumb.php' );
-
+wfLogProfilingData();
 
 ?>