From: Tim Starling Date: Sat, 16 Apr 2005 05:48:21 +0000 (+0000) Subject: Fixed some obvious bugs with the new code and implemented If-Modified-Since handling X-Git-Tag: 1.5.0alpha1~254 X-Git-Url: http://git.cyclocoop.org///%22%40url%40//%22?a=commitdiff_plain;h=f90c740f915a825acbecf64017b226a3761720d9;p=lhc%2Fweb%2Fwiklou.git Fixed some obvious bugs with the new code and implemented If-Modified-Since handling --- diff --git a/includes/Image.php b/includes/Image.php index 8dd6c27297..c1ec8c7837 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -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 ); } } diff --git a/includes/ImagePage.php b/includes/ImagePage.php index b117d42c17..586fc8a7b4 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -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. diff --git a/includes/StreamFile.php b/includes/StreamFile.php index 07f374d35e..1451f2e7ee 100644 --- a/includes/StreamFile.php +++ b/includes/StreamFile.php @@ -13,6 +13,16 @@ does not.

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.

} 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 ) { diff --git a/thumb.php b/thumb.php index 2b40c68a71..ff7f9153e9 100644 --- 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