Fixed some obvious bugs with the new code and implemented If-Modified-Since handling
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 16 Apr 2005 05:48:21 +0000 (05:48 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 16 Apr 2005 05:48:21 +0000 (05:48 +0000)
includes/Image.php
includes/ImagePage.php
includes/StreamFile.php
thumb.php

index 8dd6c27..c1ec8c7 100644 (file)
@@ -607,7 +607,7 @@ class Image
                        $scriptUrl = $thumbScript . '?f=' . urlencode( $this->name ) . '&w=' . urlencode( $width );
                        if ( $useScript ) {
                                // Use thumb.php to render the image
-                               return new ThumbnailImage( , $width, $height );
+                               return new ThumbnailImage( $scriptUrl, $width, $height );
                        }
                }
 
index b117d42..586fc8a 100644 (file)
@@ -85,17 +85,7 @@ class ImagePage extends Article {
                                if ( $width != $this->img->getWidth() || $height != $this->img->getHeight() ) {
                                        if( $wgUseImageResize ) {
                                                $thumbnail = $this->img->getThumbnail( $width );
-
-                                               if (    ( ! $this->img->mustRender() )
-                                                    && ( $thumbnail->getSize() > $this->img->getSize() ) ) {
-                                                       # the thumbnail is bigger thatn the original image.
-                                                       # show the original image instead of the thumb.
-                                                       $url = $full_url;
-                                                       $width = $this->img->getWidth();
-                                                       $height = $this->img->getHeight();
-                                               } else {
-                                                       $url = $thumbnail->getUrl();
-                                               }
+                                               $url = $thumbnail->getUrl();
                                        } else {
                                                # No resize ability? Show the full image, but scale
                                                # it down in the browser so it fits on the page.
index 07f374d..1451f2e 100644 (file)
@@ -13,6 +13,16 @@ does not.</p>
                return;
        }
 
+       header( "Cache-Control: s-maxage=$wgSquidMaxage, must-revalidate, max-age=0" );
+       header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s', $stat['mtime'] ) . ' GMT' );
+
+       if ( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
+               $sinceTime = strtotime( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
+               if ( $stat['mtime'] <= $sinceTime ) {
+                       header( "HTTP/1.0 304 Not Modified" );
+                       return;
+               }
+       }
        
        $type = wfGetType( $fname );
        if ( $type ) {
@@ -20,10 +30,7 @@ does not.</p>
        } else {
                header('Content-type: application/x-wiki');
        }
-       header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s', $stat['mtime'] ) );
-       header( "Cache-Control: s-maxage=$wgSquidMaxage, must-revalidate, max-age=0" );
        readfile( $fname );
-       exit;
 }
 
 function wfGetType( $filename ) {
index 2b40c68..ff7f915 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -25,7 +25,7 @@ if ( get_magic_quotes_gpc() ) {
 // Some basic input validation
 
 $width = intval( $width );
-$fileName = str_replace( '/', '_', $fileName );
+$fileName = strtr( $fileName, '\\/', '__' );
 
 // Work out paths, carefully avoiding constructing an Image object because that won't work yet