mirror of
https://github.com/mosbth/cimage.git
synced 2025-07-30 21:20:11 +02:00
always send last-modified header
This commit is contained in:
10
CImage.php
10
CImage.php
@@ -275,9 +275,12 @@ EOD;
|
||||
$info = list($width, $height, $type, $attr) = getimagesize($file);
|
||||
!empty($info) or $this->RaiseError("The file doesn't seem to be an image.");
|
||||
$mime = $info['mime'];
|
||||
$time = filemtime($file);
|
||||
$lastModified = filemtime($file);
|
||||
$gmdate = gmdate("D, d M Y H:i:s", $lastModified);
|
||||
|
||||
if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $time){
|
||||
if(!$this->verbose) { header('Last-Modified: ' . $gmdate . " GMT"); }
|
||||
|
||||
if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified){
|
||||
if($this->verbose) {
|
||||
$this->Log("304 not modified");
|
||||
$this->VerboseOutput();
|
||||
@@ -285,8 +288,6 @@ EOD;
|
||||
}
|
||||
header("HTTP/1.0 304 Not Modified");
|
||||
} else {
|
||||
$gmdate = gmdate("D, d M Y H:i:s", $time);
|
||||
|
||||
if($this->verbose) {
|
||||
$this->Log("Last modified: " . $gmdate . " GMT");
|
||||
$this->VerboseOutput();
|
||||
@@ -294,7 +295,6 @@ EOD;
|
||||
}
|
||||
|
||||
header('Content-type: ' . $mime);
|
||||
header('Last-Modified: ' . $gmdate . " GMT");
|
||||
readfile($file);
|
||||
}
|
||||
exit;
|
||||
|
@@ -83,6 +83,12 @@ Combine the parameters to get the desired behavior and resulting image. For exam
|
||||
Revision history
|
||||
-------------------------------------
|
||||
|
||||
v0.4.x (latest)
|
||||
|
||||
* Changed => to == on Modified-Since.
|
||||
* Always send Last-Modified-Header.
|
||||
|
||||
|
||||
v0.4 (2013-10-08)
|
||||
|
||||
* Improved support for pre-defined sizes.
|
||||
@@ -101,7 +107,8 @@ v0.4 (2013-10-08)
|
||||
* Added usage of all parameters to README.md
|
||||
* Added documentation here http://dbwebb.se/opensource/cimage
|
||||
* Adding `.gitignore`
|
||||
* Readding `cache` directory
|
||||
* Re-adding `cache` directory
|
||||
|
||||
|
||||
v0.3 (2012-10-02)
|
||||
|
||||
|
9
img.php
9
img.php
@@ -24,9 +24,9 @@ set_exception_handler('myExceptionHandler');
|
||||
|
||||
|
||||
// Use preprocessing of images
|
||||
#define('PNG_FILTER', '/usr/local/bin/optipng -q');
|
||||
#define('PNG_DEFLATE', '/usr/local/bin/pngout -q');
|
||||
#define('JPEG_OPTIMIZE', '/usr/local/bin/jpegtran -copy none -optimize');
|
||||
define('PNG_FILTER', '/usr/local/bin/optipng -q');
|
||||
define('PNG_DEFLATE', '/usr/local/bin/pngout -q');
|
||||
define('JPEG_OPTIMIZE', '/usr/local/bin/jpegtran -copy none -optimize');
|
||||
|
||||
|
||||
// Append ending slash
|
||||
@@ -151,13 +151,14 @@ else {
|
||||
|
||||
|
||||
|
||||
// Display image if vebose mode
|
||||
// Display image if verbose mode
|
||||
if($verbose) {
|
||||
$query = array();
|
||||
parse_str($_SERVER['QUERY_STRING'], $query);
|
||||
unset($query['verbose']);
|
||||
unset($query['v']);
|
||||
unset($query['nocache']);
|
||||
unset($query['nc']);
|
||||
$url1 = '?' . http_build_query($query);
|
||||
echo <<<EOD
|
||||
<a href=$url1><code>$url1</code></a><br>
|
||||
|
BIN
img/kodim15.png
Normal file
BIN
img/kodim15.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 589 KiB |
Reference in New Issue
Block a user