varchar instead of char for interwiki table
[lhc/web/wiklou.git] / thumb.php
index 4ec40dc..42bc549 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -5,16 +5,17 @@
  * If the file exists, we make do with abridged MediaWiki initialisation.
  */
 define( 'MW_NO_SETUP', 1 );
+define( 'MW_NO_OUTPUT_COMPRESSION', 1 );
 require_once( './includes/WebStart.php' );
 wfProfileIn( 'thumb.php' );
 wfProfileIn( 'thumb.php-start' );
-require_once( 'GlobalFunctions.php' );
-require_once( 'ImageFunctions.php' );
+require_once( './includes/GlobalFunctions.php' );
+require_once( './includes/ImageFunctions.php' );
 
 $wgTrivialMimeDetection = true; //don't use fancy mime detection, just check the file extension for jpg/gif/png.
 
-require_once( 'Image.php' );
-require_once( 'StreamFile.php' );
+require_once( './includes/Image.php' );
+require_once( './includes/StreamFile.php' );
 
 // Get input parameters
 $fileName = isset( $_REQUEST['f'] ) ? $_REQUEST['f'] : '';
@@ -50,16 +51,21 @@ if ( is_file( $thumbPath ) && filemtime( $thumbPath ) >= filemtime( $imagePath )
 
 // OK, no valid thumbnail, time to get out the heavy machinery
 wfProfileOut( 'thumb.php-start' );
-require_once( 'Setup.php' );
+require_once( './includes/Setup.php' );
 wfProfileIn( 'thumb.php-render' );
 
 $img = Image::newFromName( $fileName );
-if ( $img ) {
-       if ( ! is_null( $page ) ) {
-               $img->selectPage( $page );
+try {
+       if ( $img ) {
+               if ( ! is_null( $page ) ) {
+                       $img->selectPage( $page );
+               }
+               $thumb = $img->renderThumb( $width, false );
+       } else {
+               $thumb = false;
        }
-       $thumb = $img->renderThumb( $width, false );
-} else {
+} catch( Exception $ex ) {
+       // Tried to select a page on a non-paged file?
        $thumb = false;
 }
 
@@ -68,12 +74,15 @@ if ( $thumb && $thumb->path ) {
 } else {
        $badtitle = wfMsg( 'badtitle' );
        $badtitletext = wfMsg( 'badtitletext' );
+       header( 'Cache-Control: no-cache' );
+       header( 'Content-Type: text/html; charset=utf-8' );
        echo "<html><head>
        <title>$badtitle</title>
        <body>
 <h1>$badtitle</h1>
 <p>$badtitletext</p>
-</body></html>";
+</body></html>
+";
 }
 
 wfProfileOut( 'thumb.php-render' );