plugins/SpecialUpdownload.php
changeset 1059 f5d2bca33bb8
parent 960 e74741b8360b
child 1081 745200a9cc2a
equal deleted inserted replaced
1058:c4b057708436 1059:f5d2bca33bb8
   194 function page_Special_DownloadFile()
   194 function page_Special_DownloadFile()
   195 {
   195 {
   196   global $db, $session, $paths, $template, $plugins; // Common objects
   196   global $db, $session, $paths, $template, $plugins; // Common objects
   197   global $lang;
   197   global $lang;
   198   global $do_gzip;
   198   global $do_gzip;
   199   $filename = rawurldecode($paths->getParam(0));
   199   $filename = $paths->getParam(0);
   200   $timeid = $paths->getParam(1);
   200   $timeid = $paths->getParam(1);
   201   if ( $timeid && preg_match('#^([0-9]+)$#', (string)$timeid) )
   201   if ( $timeid && ctype_digit((string)$timeid) )
   202   {
   202   {
   203     $tid = ' AND time_id='.$timeid;
   203     $tid = ' AND time_id='.$timeid;
   204   }
   204   }
   205   else
   205   else
   206   {
   206   {
   241   if ( isset($_GET['preview']) && substr($row['mimetype'], 0, 6) == 'image/' )
   241   if ( isset($_GET['preview']) && substr($row['mimetype'], 0, 6) == 'image/' )
   242   {
   242   {
   243     // Determine appropriate width and height
   243     // Determine appropriate width and height
   244     $width  = ( isset($_GET['width'])  ) ? intval($_GET['width'] ) : 320;
   244     $width  = ( isset($_GET['width'])  ) ? intval($_GET['width'] ) : 320;
   245     $height = ( isset($_GET['height']) ) ? intval($_GET['height']) : 320;
   245     $height = ( isset($_GET['height']) ) ? intval($_GET['height']) : 320;
   246     $cache_filename = ENANO_ROOT . "/cache/{$filename}-{$row['time_id']}-{$width}x{$height}{$row['file_extension']}";
   246     
       
   247     // 1.1.7: allow different format output
       
   248     $extension = $row['file_extension'];
       
   249     if ( isset($_GET['fmt']) && in_array($_GET['fmt'], array('png', 'jpg')) )
       
   250       $extension = ".{$_GET['fmt']}";
       
   251     
       
   252     $cache_filename = ENANO_ROOT . "/cache/{$filename}-{$row['time_id']}-{$width}x{$height}$extension";
   247     if ( file_exists($cache_filename) )
   253     if ( file_exists($cache_filename) )
   248     {
   254     {
   249       $fname = $cache_filename;
   255       $fname = $cache_filename;
   250     }
   256     }
   251     else
   257     else