Changeset 12778 for extensions
- Timestamp:
- Dec 21, 2011, 10:01:26 PM (12 years ago)
- Location:
- extensions/derivatives
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/derivatives/i.php
r12775 r12778 1 1 <?php 2 // +-----------------------------------------------------------------------+ 3 // | Piwigo - a PHP based photo gallery | 4 // +-----------------------------------------------------------------------+ 5 // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org | 6 // +-----------------------------------------------------------------------+ 7 // | This program is free software; you can redistribute it and/or modify | 8 // | it under the terms of the GNU General Public License as published by | 9 // | the Free Software Foundation | 10 // | | 11 // | This program is distributed in the hope that it will be useful, but | 12 // | WITHOUT ANY WARRANTY; without even the implied warranty of | 13 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 // | General Public License for more details. | 15 // | | 16 // | You should have received a copy of the GNU General Public License | 17 // | along with this program; if not, write to the Free Software | 18 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | 19 // | USA. | 20 // +-----------------------------------------------------------------------+ 21 2 22 defined('PHPWG_ROOT_PATH') || die('hacking'); 3 23 … … 58 78 header('Content-Location: '.$url); 59 79 header('Location: '.$url); 60 exit(); 80 exit; 81 } 82 if ($code>=400) 83 { 84 $protocol = $_SERVER["SERVER_PROTOCOL"]; 85 if ( ('HTTP/1.1' != $protocol) && ('HTTP/1.0' != $protocol) ) 86 $protocol = 'HTTP/1.0'; 87 88 header( "$protocol $code $msg", true, $code ); 61 89 } 62 90 //todo improve … … 178 206 } 179 207 208 $src_mtime = @filemtime($page['src_path']); 209 if ($src_mtime === false) 210 { 211 ierror('Source not found', 404); 212 } 213 214 $need_generate = false; 215 $derivative_mtime = @filemtime($page['derivative_path']); 216 if ($derivative_mtime === false or 217 $derivative_mtime < $src_mtime or 218 $derivative_mtime < $params->last_mod_time) 219 { 220 $need_generate = true; 221 } 222 223 if (!$need_generate) 224 { 225 if ( isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) 226 and strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $derivative_mtime) 227 {// send the last mod time of the file back 228 header('Last-Modified: '.gmdate('D, d M Y H:i:s', $derivative_mtime).' GMT', true, 304); 229 header('Expires: '.gmdate('D, d M Y H:i:s', time()+10*24*3600).' GMT', true, 304); 230 exit; 231 } 232 // todo send pass-through 233 } 234 235 180 236 include_once(PHPWG_ROOT_PATH . 'admin/include/image.class.php'); 181 237 $image = new pwg_image($page['src_path']); … … 217 273 218 274 $fstat = fstat($fp); 219 $gmt_mtime = gmdate('D, d M Y H:i:s', $fstat['mtime']).' GMT';220 header(' Last-Modified: '.$gmt_mtime);275 header('Last-Modified: '.gmdate('D, d M Y H:i:s', $fstat['mtime']).' GMT'); 276 header('Expires: '.gmdate('D, d M Y H:i:s', time()+10*24*3600).' GMT'); 221 277 header('Content-length: '.$fstat['size']); 222 278 header('Connection: close'); -
extensions/derivatives/include/derivative.inc.php
r12775 r12778 1 1 <?php 2 // +-----------------------------------------------------------------------+ 3 // | Piwigo - a PHP based photo gallery | 4 // +-----------------------------------------------------------------------+ 5 // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org | 6 // +-----------------------------------------------------------------------+ 7 // | This program is free software; you can redistribute it and/or modify | 8 // | it under the terms of the GNU General Public License as published by | 9 // | the Free Software Foundation | 10 // | | 11 // | This program is distributed in the hope that it will be useful, but | 12 // | WITHOUT ANY WARRANTY; without even the implied warranty of | 13 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 // | General Public License for more details. | 15 // | | 16 // | You should have received a copy of the GNU General Public License | 17 // | along with this program; if not, write to the Free Software | 18 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | 19 // | USA. | 20 // +-----------------------------------------------------------------------+ 2 21 3 22 final class SrcImage … … 150 169 { 151 170 $mtime = @filemtime(PHPWG_ROOT_PATH.$rel_path); 152 if ($mtime===false )171 if ($mtime===false or $mtime < $params->last_mod_time) 153 172 { 154 173 $url_style = 2; -
extensions/derivatives/include/derivative_params.inc.php
r12775 r12778 1 1 <?php 2 // +-----------------------------------------------------------------------+ 3 // | Piwigo - a PHP based photo gallery | 4 // +-----------------------------------------------------------------------+ 5 // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org | 6 // +-----------------------------------------------------------------------+ 7 // | This program is free software; you can redistribute it and/or modify | 8 // | it under the terms of the GNU General Public License as published by | 9 // | the Free Software Foundation | 10 // | | 11 // | This program is distributed in the hope that it will be useful, but | 12 // | WITHOUT ANY WARRANTY; without even the implied warranty of | 13 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 // | General Public License for more details. | 15 // | | 16 // | You should have received a copy of the GNU General Public License | 17 // | along with this program; if not, write to the Free Software | 18 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | 19 // | USA. | 20 // +-----------------------------------------------------------------------+ 2 21 3 22 function size_to_url($s) … … 258 277 { 259 278 public $type = IMG_CUSTOM; 279 public $last_mod_time = 0; // used for non-custom images to regenerate the cached files 260 280 public $sizing; 261 281
Note: See TracChangeset
for help on using the changeset viewer.