From: <se...@us...> - 2008-08-14 14:08:34
|
Revision: 14250 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=14250&view=rev Author: sept_7 Date: 2008-08-14 14:08:43 +0000 (Thu, 14 Aug 2008) Log Message: ----------- [FIX] pb with file galleries on the filesystem Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2008-08-14 13:54:33 UTC (rev 14249) +++ trunk/tiki-download_file.php 2008-08-14 14:08:43 UTC (rev 14250) @@ -7,38 +7,38 @@ include_once('lib/filegals/filegallib.php'); if ( $prefs['feature_file_galleries'] != 'y' ) { - $smarty->assign('msg', tra('This feature is disabled')); - $smarty->display('error.tpl'); - die; + $smarty->assign('msg', tra('This feature is disabled')); + $smarty->display('error.tpl'); + die; } @set_time_limit(0); /* -Borrowed from http://php.net/manual/en/function.readfile.php#54295 -to come over the 2MB readfile() limitation -*/ + Borrowed from http://php.net/manual/en/function.readfile.php#54295 to come + over the 2MB readfile() limitation + */ function readfile_chunked($filename,$retbytes=true) { - $chunksize = 1*(1024*1024); // how many bytes per chunk - $buffer = ''; - $cnt =0; - $handle = fopen($filename, 'rb'); - if ($handle === false) { - return false; - } - while (!feof($handle)) { - $buffer = fread($handle, $chunksize); - echo $buffer; - @ob_flush(); - flush(); - if ($retbytes) { - $cnt += strlen($buffer); - } - } - $status = fclose($handle); - if ($retbytes && $status) { - return $cnt; // return num. bytes delivered like readfile() does. - } - return $status; + $chunksize = 1*(1024*1024); // how many bytes per chunk + $buffer = ''; + $cnt =0; + $handle = fopen($filename, 'rb'); + if ($handle === false) { + return false; + } + while (!feof($handle)) { + $buffer = fread($handle, $chunksize); + echo $buffer; + @ob_flush(); + flush(); + if ($retbytes) { + $cnt += strlen($buffer); + } + } + $status = fclose($handle); + if ($retbytes && $status) { + return $cnt; // return num. bytes delivered like readfile() does. + } + return $status; } if ( isset($_REQUEST['fileId']) ) { @@ -61,31 +61,31 @@ $smarty->assign('individual', 'n'); if ( $userlib->object_has_one_permission($_REQUEST['galleryId'], 'file gallery') ) { - $smarty->assign('individual', 'y'); - if ( $tiki_p_admin != 'y' ) { - // Now get all the permissions that are set for this type of permissions 'file gallery' - $perms = $userlib->get_permissions(0, -1, 'permName_desc', '', 'file galleries'); - foreach ( $perms['data'] as $perm ) { - $permName = $perm['permName']; - if ( $userlib->object_has_permission($user, $_REQUEST['galleryId'], 'file gallery', $permName) ) { - $$permName = 'y'; - $smarty->assign("$permName", 'y'); - } else { - $$permName = 'n'; - $smarty->assign("$permName", 'n'); - } - } - } + $smarty->assign('individual', 'y'); + if ( $tiki_p_admin != 'y' ) { + // Now get all the permissions that are set for this type of permissions 'file gallery' + $perms = $userlib->get_permissions(0, -1, 'permName_desc', '', 'file galleries'); + foreach ( $perms['data'] as $perm ) { + $permName = $perm['permName']; + if ( $userlib->object_has_permission($user, $_REQUEST['galleryId'], 'file gallery', $permName) ) { + $$permName = 'y'; + $smarty->assign("$permName", 'y'); + } else { + $$permName = 'n'; + $smarty->assign("$permName", 'n'); + } + } + } } if ( $tiki_p_admin_file_galleries == 'y' ) { - $tiki_p_download_files = 'y'; + $tiki_p_download_files = 'y'; } if ( $tiki_p_download_files != 'y' ) { - $smarty->assign('msg', tra('You can not download files')); - $smarty->display('error.tpl'); - die; + $smarty->assign('msg', tra('You can not download files')); + $smarty->display('error.tpl'); + die; } // Add hits ( if download or display only ) @@ -111,6 +111,7 @@ session_write_close(); error_reporting(E_ALL); +$content_changed = false; $content = &$info['data']; // Handle images display, files thumbnails and icons @@ -119,8 +120,13 @@ // Modify the original image if needed if ( ! isset($_GET['display']) || isset($_GET['x']) || isset($_GET['y']) || isset($_GET['scale']) || isset($_GET['max']) || isset($_GET['format']) ) { + $content_changed = true; + if ( $info['path'] ) { + $content=file_get_contents(($prefs['fgal_use_dir'].$info['path'])); + } + require_once('lib/images/images.php'); - if (!class_exists('Image')) die(); + if (!class_exists('Image')) die(); $format = substr($info['filename'], strrpos($info['filename'], '.') + 1); @@ -129,7 +135,7 @@ $_GET['icon'] = 'y'; $_GET['max'] = 32; } - + if ( isset($_GET['icon']) ) { unset($content); if ( isset($_GET['max']) ) { @@ -147,7 +153,7 @@ if ( ! isset($_GET['icon']) || ( isset($_GET['format']) && $_GET['format'] != $format ) ) { $image = new Image($content); - + $resize = false; // We resize if needed if ( isset($_GET['x']) || isset($_GET['y']) ) { @@ -168,7 +174,7 @@ elseif ( isset($_GET['thumbnail']) ) { $image->resizethumb(); } - + // We change the image format if needed if ( isset($_GET['format']) && Image::is_supported($_GET['format']) ) { $image->convert($_GET['format']); @@ -177,22 +183,11 @@ elseif ( isset($_GET['thumbnail']) ) { $image->convert('jpeg'); } - + $content =& $image->display(); $info['filetype'] = $image->get_mimetype(); } - } - - if ( function_exists('mb_strlen') ) { - header('Content-Length: '.mb_strlen($content, '8bit')); - } else { - header('Content-Length: '.strlen($content)); - } - header('Content-type: '.$info['filetype']); - echo "$content"; - - die(); } // Lock while downloading @@ -213,17 +208,23 @@ // File galleries should always be attachments (files) not inline (textual) header('Content-type: '.$info['filetype']); -header("Content-Disposition: attachment; filename=\"$file\""); +if (!$content_change and !isset($_GET['display'])) { + header("Content-Disposition: attachment; filename=\"$file\""); +} header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); -if ( $info['path'] ) { +if ( $info['path'] and !$content_changed ) { header('Content-Length: '.filesize($prefs['fgal_use_dir'].$info['path']) ); readfile_chunked($prefs['fgal_use_dir'].$info['path']); } else { - header('Content-Length: '.$info['filesize']); + if ( function_exists('mb_strlen') ) { + header('Content-Length: '.mb_strlen($content, '8bit')); + } else { + header('Content-Length: '.strlen($content)); + } echo "$content"; } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sy...@us...> - 2008-09-23 17:08:23
|
Revision: 14825 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=14825&view=rev Author: sylvieg Date: 2008-09-23 17:08:07 +0000 (Tue, 23 Sep 2008) Log Message: ----------- [MOD]fgal: move the lock part only for non image + use user_has_perm Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2008-09-23 15:26:07 UTC (rev 14824) +++ trunk/tiki-download_file.php 2008-09-23 17:08:07 UTC (rev 14825) @@ -45,7 +45,6 @@ $info = $tikilib->get_file($_REQUEST['fileId']); } elseif ( isset($_REQUEST['galleryId']) && isset($_REQUEST['name']) ) { $info = $tikilib->get_file_by_name($_REQUEST['galleryId'], $_REQUEST['name']); - $_REQUEST['fileId'] = $info['fileId']; } else { $smarty->assign('msg', tra('Incorrect param')); $smarty->display('error.tpl'); @@ -57,54 +56,38 @@ die; } -$_REQUEST['galleryId'] = $info['galleryId']; - -$smarty->assign('individual', 'n'); -if ( $userlib->object_has_one_permission($_REQUEST['galleryId'], 'file gallery') ) { - $smarty->assign('individual', 'y'); - if ( $tiki_p_admin != 'y' ) { - // Now get all the permissions that are set for this type of permissions 'file gallery' - $perms = $userlib->get_permissions(0, -1, 'permName_desc', '', 'file galleries'); - foreach ( $perms['data'] as $perm ) { - $permName = $perm['permName']; - if ( $userlib->object_has_permission($user, $_REQUEST['galleryId'], 'file gallery', $permName) ) { - $$permName = 'y'; - $smarty->assign("$permName", 'y'); - } else { - $$permName = 'n'; - $smarty->assign("$permName", 'n'); - } - } - } -} - -if ( $tiki_p_admin_file_galleries == 'y' ) { - $tiki_p_download_files = 'y'; -} - -if ( $tiki_p_download_files != 'y' ) { +if ( $tiki_p_admin_file_galleries != 'y' && !$user->user_has_perm_on_object($user, $info['galleryId'], 'file gallery', 'tiki_p_download_files')) { + $smarty->assign('errortype', 401); $smarty->assign('msg', tra('You can not download files')); $smarty->display('error.tpl'); die; } -// Add hits ( if download or display only ) +// Add hits ( if download or display only ) + lock if set if ( ! isset($_GET['thumbnail']) && ! isset($_GET['icon']) ) { require_once('lib/stats/statslib.php'); - if( ! $tikilib->add_file_hit($_REQUEST['fileId']) ) - { + if( ! $tikilib->add_file_hit($info['fileId']) ) { $smarty->assign('msg', tra('You cannot download this file right now. Your score is low or file limit was reached.')); $smarty->display('error.tpl'); die; } + $statslib->stats_hit($info['filename'], 'file', $info['fileId']); - $statslib->stats_hit($info['filename'], 'file', $_REQUEST['fileId']); - if ( $prefs['feature_actionlog'] == 'y' ) { require_once('lib/logs/logslib.php'); - $logslib->add_action('Downloaded', $_REQUEST['galleryId'], 'file gallery', 'fileId='.$_REQUEST["fileId"]); + $logslib->add_action('Downloaded', $info['galleryId'], 'file gallery', 'fileId='.$info['fileId']); } + + if ( ! empty($_REQUEST['lock']) ) { + if (!empty($info['lockedby']) && $info['lockedby'] != $user) { + $smarty->assign('msg', tra(sprintf('The file is locked by %s', $info['lockedby']))); + $smarty->assign('close_window', 'y'); + $smarty->display('error.tpl'); + die; + } + $filegallib->lock_file($info['fileId'], $user); + } } // close the session in case of large downloads to enable further browsing @@ -190,16 +173,6 @@ } } -// Lock while downloading -if ( ! empty($_REQUEST['lock']) ) { - if (!empty($info['lockedby']) && $info['lockedby'] != $user) { - $smarty->assign('msg', tra(sprintf('The file is locked by %s', $info['lockedby']))); - $smarty->assign('close_window', 'y'); - $smarty->display('error.tpl'); - die; - } - $filegallib->lock_file($_REQUEST['fileId'], $user); -} // IE6 can not download file with / in the name (the / can be there from a previous bug) $file = preg_replace('/.*([^\/]*)$/U', '$1', $info['filename']); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sy...@us...> - 2008-09-24 15:15:55
|
Revision: 14846 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=14846&view=rev Author: sylvieg Date: 2008-09-24 15:15:40 +0000 (Wed, 24 Sep 2008) Log Message: ----------- [MOD]fgal: button to download in a zip a set of files (not working for suggal now) Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2008-09-24 15:08:13 UTC (rev 14845) +++ trunk/tiki-download_file.php 2008-09-24 15:15:40 UTC (rev 14846) @@ -40,23 +40,28 @@ } return $status; } +$zip = false; +$error = ''; -if ( isset($_REQUEST['fileId']) ) { +if ( isset($_REQUEST['fileId']) && !is_array($_REQUEST['fileId'])) { $info = $tikilib->get_file($_REQUEST['fileId']); } elseif ( isset($_REQUEST['galleryId']) && isset($_REQUEST['name']) ) { $info = $tikilib->get_file_by_name($_REQUEST['galleryId'], $_REQUEST['name']); +} elseif ( isset($_REQUEST['fileId']) && is_array($_REQUEST['fileId'])) { + $info = $filegallib->zip($_REQUEST['fileId'], $error); + $zip = true; } else { $smarty->assign('msg', tra('Incorrect param')); $smarty->display('error.tpl'); die; } if ( ! is_array($info) ) { - $smarty->assign('msg', tra('Incorrect param')); + $smarty->assign('msg', tra('Incorrect param').' '.tra($error)); $smarty->display('error.tpl'); die; } -if ( $tiki_p_admin_file_galleries != 'y' && !$user->user_has_perm_on_object($user, $info['galleryId'], 'file gallery', 'tiki_p_download_files')) { +if ( !$zip && $tiki_p_admin_file_galleries != 'y' && !$userlib->user_has_perm_on_object($user, $info['galleryId'], 'file gallery', 'tiki_p_download_files')) { $smarty->assign('errortype', 401); $smarty->assign('msg', tra('You can not download files')); $smarty->display('error.tpl'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2008-11-10 10:06:20
|
Revision: 15590 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=15590&view=rev Author: nyloth Date: 2008-11-10 10:06:17 +0000 (Mon, 10 Nov 2008) Log Message: ----------- [ENH] filegals: download file will not get content twice when stored on filesystem + correctly handle cache in filesystem case Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2008-11-10 09:29:10 UTC (rev 15589) +++ trunk/tiki-download_file.php 2008-11-10 10:06:17 UTC (rev 15590) @@ -131,18 +131,15 @@ if ( $use_cache && $cachelib->isCached($cacheName, $cacheType) ) { $content = $cachelib->getCached($cacheName, $cacheType); + $content_changed = true; } else { - if ( $info['path'] && (!$content || sizeof($content) == 0)) { - $content = &get_readfile_chunked($prefs['fgal_use_dir'].$info['path']); - } - // Modify the original image if needed if ( ! isset($_GET['display']) || isset($_GET['x']) || isset($_GET['y']) || isset($_GET['scale']) || isset($_GET['max']) || isset($_GET['format']) ) { $content_changed = true; if ( $info['path'] ) { - $content=file_get_contents(($prefs['fgal_use_dir'].$info['path'])); + $content = file_get_contents(($prefs['fgal_use_dir'].$info['path'])); } require_once('lib/images/images.php'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2008-11-10 10:35:54
|
Revision: 15591 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=15591&view=rev Author: nyloth Date: 2008-11-10 10:35:49 +0000 (Mon, 10 Nov 2008) Log Message: ----------- [ENH] filegals: optimize image loading in case of filesystem storage Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2008-11-10 10:06:17 UTC (rev 15590) +++ trunk/tiki-download_file.php 2008-11-10 10:35:49 UTC (rev 15591) @@ -138,9 +138,9 @@ if ( ! isset($_GET['display']) || isset($_GET['x']) || isset($_GET['y']) || isset($_GET['scale']) || isset($_GET['max']) || isset($_GET['format']) ) { $content_changed = true; - if ( $info['path'] ) { - $content = file_get_contents(($prefs['fgal_use_dir'].$info['path'])); - } +// if ( $info['path'] ) { +// $content = file_get_contents(($prefs['fgal_use_dir'].$info['path'])); +// } require_once('lib/images/images.php'); if (!class_exists('Image')) die(); @@ -169,7 +169,11 @@ } if ( ! isset($_GET['icon']) || ( isset($_GET['format']) && $_GET['format'] != $format ) ) { - $image = new Image($content); + if ( isset($info['path']) ) { + $image = new Image($prefs['fgal_use_dir'].$info['path'], true); + } else { + $image = new Image($content); + } $resize = false; // We resize if needed This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-11-10 17:44:58
|
Revision: 15600 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=15600&view=rev Author: sept_7 Date: 2008-11-10 17:44:56 +0000 (Mon, 10 Nov 2008) Log Message: ----------- [FIX] filegals : case where cache is empty or return false or "" Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2008-11-10 17:44:01 UTC (rev 15599) +++ trunk/tiki-download_file.php 2008-11-10 17:44:56 UTC (rev 15600) @@ -129,10 +129,13 @@ $use_cache = true; } + $build_content = true; if ( $use_cache && $cachelib->isCached($cacheName, $cacheType) ) { $content = $cachelib->getCached($cacheName, $cacheType); + if ($content !== serialize(false) and $content != "") $build_content = false; $content_changed = true; - } else { + } + if ($build_content) { // Modify the original image if needed if ( ! isset($_GET['display']) || isset($_GET['x']) || isset($_GET['y']) || isset($_GET['scale']) || isset($_GET['max']) || isset($_GET['format']) ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2008-11-12 07:36:03
|
Revision: 15620 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=15620&view=rev Author: nyloth Date: 2008-11-12 07:35:56 +0000 (Wed, 12 Nov 2008) Log Message: ----------- [ENH] filegals: add support of client cache (with etag and last-modified headers) + reduce download file memory usage + use DB hash for cache key instead of regenerating one + remove useless function and comments + some minor perf improvements Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2008-11-12 07:32:30 UTC (rev 15619) +++ trunk/tiki-download_file.php 2008-11-12 07:35:56 UTC (rev 15620) @@ -11,8 +11,11 @@ $smarty->display('error.tpl'); die; } -@set_time_limit(0); +if ( ! ini_get('safe_mode') ) { + @set_time_limit(0); +} + /* Borrowed from http://php.net/manual/en/function.readfile.php#54295 to come over the 2MB readfile() limitation @@ -43,21 +46,6 @@ $zip = false; $error = ''; -function get_readfile_chunked($filename) { - $chunksize = 1*(1024*1024); // how many bytes per chunk - $buffer = ''; - $cnt =0; - $handle = fopen($filename, 'rb'); - if ($handle === false) { - return false; - } - while (!feof($handle)) { - $buffer = fread($handle, $chunksize); - } - fclose($handle); - return $buffer; -} - if ( isset($_REQUEST['fileId']) && !is_array($_REQUEST['fileId'])) { $info = $tikilib->get_file($_REQUEST['fileId']); } elseif ( isset($_REQUEST['galleryId']) && isset($_REQUEST['name']) ) { @@ -110,13 +98,63 @@ } } -// close the session in case of large downloads to enable further browsing -session_write_close(); +session_write_close(); // close the session in case of large downloads to enable further browsing error_reporting(E_ALL); +if ( ob_get_level() ) while (@ob_end_clean()); // Be sure output buffering is turned off $content_changed = false; $content = &$info['data']; +$md5 = ''; +if ( ! empty($info['path']) ) { + $filepath = $prefs['fgal_use_dir'].$info['path']; + if ( is_readable($filepath) ) { + $file_stats = stat($filepath); + $last_modified = $file_stats['mtime']; + $md5 = empty($info['hash']) ? + md5($file_stats['mtime'].'='.$file_stats['ino'].'='.$file_stats['size']) + : $info['hash']; + } else { + // File missing or not readable + die; + } +} elseif ( ! empty($content) ) { + $last_modified = $info['lastModif']; + $md5 = empty($info['hash']) ? md5($content) : $info['hash']; +} else { + // Empty content + die; +} + +// ETag: Entity Tag used for strong cache validation. +$etag = '"' . $md5 . '-' . crc32($md5) . '"'; +header('ETag: '.$etag); + +$use_client_cache = false; +if ( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $last_modified == strtotime(current($a = explode(';', $_SERVER['HTTP_IF_MODIFIED_SINCE']))) ) { + $use_client_cache = true; +} elseif ( isset($_SERVER['HTTP_IF_NONE_MATCH']) ) { + $tmp = array_map('trim', explode(',', $_SERVER['HTTP_IF_NONE_MATCH'])); + foreach ( $tmp as $v ) { + if ( $v == '*' || $v == $etag ) { + $use_client_cache = true; + break; + } + } + unset($tmp); +} + +header("Pragma: "); +header('Expires: '); +header('Cache-Control: '.( $user ? 'private' : 'public' ).',must-revalidate,post-check=0,pre-check=0'); + +if ( $use_client_cache ) { + header('Status: 304 Not Modified', true, 304); + exit; +} else { + if ( !empty($last_modified) ) header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_modified). ' GMT'); +} + // Handle images display, files thumbnails and icons if ( isset($_GET['preview']) || isset($_GET['thumbnail']) || isset($_GET['display']) || isset($_GET['icon']) ) { $use_cache = false; @@ -124,30 +162,28 @@ // Cache only thumbnails to avoid DOS attacks if ( ( isset($_GET['thumbnail']) || isset($_GET['preview']) ) && ! isset($_GET['display']) && ! isset($_GET['icon']) && ! isset($_GET['scale']) && ! isset($_GET['x']) && ! isset($_GET['y']) && ! isset($_GET['format']) && ! isset($_GET['max']) ) { global $cachelib; include_once('lib/cache/cachelib.php'); - $cacheName = md5($info['filesize']."\n".$info['created']."\n".$info['filename']); + $cacheName = $md5; $cacheType = ( isset($_GET['thumbnail']) ? 'thumbnail_' : 'preview_' ) . ((int)$_REQUEST['fileId']).'_'; $use_cache = true; } - $build_content = true; + $build_content = true; if ( $use_cache && $cachelib->isCached($cacheName, $cacheType) ) { + $content = null; // Explicitely free memory before getting cache $content = $cachelib->getCached($cacheName, $cacheType); if ($content !== serialize(false) and $content != "") $build_content = false; $content_changed = true; - } + } + if ($build_content) { // Modify the original image if needed if ( ! isset($_GET['display']) || isset($_GET['x']) || isset($_GET['y']) || isset($_GET['scale']) || isset($_GET['max']) || isset($_GET['format']) ) { - $content_changed = true; -// if ( $info['path'] ) { -// $content = file_get_contents(($prefs['fgal_use_dir'].$info['path'])); -// } - require_once('lib/images/images.php'); if (!class_exists('Image')) die(); + $content_changed = true; $format = substr($info['filename'], strrpos($info['filename'], '.') + 1); // Fallback to an icon if the format is not supported @@ -157,7 +193,9 @@ } if ( isset($_GET['icon']) ) { - unset($content); + unset($info['path']); + $content = null; // Explicitely free memory before generating icon + if ( isset($_GET['max']) ) { $icon_x = $_GET['max']; $icon_y = $_GET['max']; @@ -169,14 +207,17 @@ $content = Image::icon($format, $icon_x, $icon_y); $format = Image::get_icon_default_format(); $info['filetype'] = 'image/'.$format; + $info['lastModif'] = 0; } if ( ! isset($_GET['icon']) || ( isset($_GET['format']) && $_GET['format'] != $format ) ) { - if ( isset($info['path']) ) { + if ( isset($info['path']) ) { $image = new Image($prefs['fgal_use_dir'].$info['path'], true); } else { $image = new Image($content); + $content = null; // Explicitely free memory before getting cache } + if ( $image->is_empty() ) die; $resize = false; // We resize if needed @@ -229,25 +270,21 @@ } } +if ( empty($info['filetype']) ) $info['filetype'] = 'application/x-octetstream'; +header('Content-type: '.$info['filetype']); + // IE6 can not download file with / in the name (the / can be there from a previous bug) -$file = preg_replace('/.*([^\/]*)$/U', '$1', $info['filename']); +$file = basename($info['filename']); -// Added by Jenolan 31/8/2003 ///////////////////////////////////////////// -// File galleries should always be attachments (files) not inline (textual) - -header('Content-type: '.$info['filetype']); -if (!$content_change and !isset($_GET['display'])) { +// If the content has not changed, ask the browser to download it (instead of displaying it) +if ( ! $content_changed and !isset($_GET['display']) ) { header("Content-Disposition: attachment; filename=\"$file\""); } -header('Expires: 0'); -header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); -header('Pragma: public'); - if ( $info['path'] and !$content_changed ) { - header('Content-Length: '.filesize($prefs['fgal_use_dir'].$info['path']) ); - readfile_chunked($prefs['fgal_use_dir'].$info['path']); + header('Content-Length: '.filesize($filepath)); + readfile_chunked($filepath); } else { if ( function_exists('mb_strlen') ) { header('Content-Length: '.mb_strlen($content, '8bit')); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-11-12 15:39:28
|
Revision: 15624 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=15624&view=rev Author: sept_7 Date: 2008-11-12 15:39:26 +0000 (Wed, 12 Nov 2008) Log Message: ----------- [FIX] filegals : rework download_file optimization to work with AdoDB and PDO Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2008-11-12 15:23:55 UTC (rev 15623) +++ trunk/tiki-download_file.php 2008-11-12 15:39:26 UTC (rev 15624) @@ -9,11 +9,14 @@ session_start(); if ( $_SESSION['allowed'][$_GET['fileId']] ) { include('db/tiki-db.php'); + include('lib/tikidblib.php'); + $db = new TikiDB($dbTiki); $query = "select * from `tiki_files` where `fileId`=?"; - $result = $dbTiki->query($query, array((int)$_GET['fileId'])); + $result = $db->query($query, array((int)$_GET['fileId'])); + if (!$result) echo 'ARG1'; $info = $result ? $result->fetchRow() : array(); - $query = "select `value` from `tiki_preferences` where name = 'fgal_use_dir';"; - $result = $dbTiki->query($query); + $query = "select `value` from `tiki_preferences` where `name` = 'fgal_use_dir';"; + $result = $db->query($query); $tmp = $result->fetchRow(); $prefs['fgal_use_dir'] = $tmp['value']; $skip = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2008-11-12 21:19:26
|
Revision: 15629 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=15629&view=rev Author: nyloth Date: 2008-11-12 21:19:24 +0000 (Wed, 12 Nov 2008) Log Message: ----------- [FIX] filegals: when downloading file using session infos, do not get fgal_use_dir pref from db if it's already in session vars + fix handling images stored in DB Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2008-11-12 18:47:53 UTC (rev 15628) +++ trunk/tiki-download_file.php 2008-11-12 21:19:24 UTC (rev 15629) @@ -11,15 +11,27 @@ include('db/tiki-db.php'); include('lib/tikidblib.php'); $db = new TikiDB($dbTiki); + $query = "select * from `tiki_files` where `fileId`=?"; $result = $db->query($query, array((int)$_GET['fileId'])); - if (!$result) echo 'ARG1'; - $info = $result ? $result->fetchRow() : array(); - $query = "select `value` from `tiki_preferences` where `name` = 'fgal_use_dir';"; - $result = $db->query($query); - $tmp = $result->fetchRow(); - $prefs['fgal_use_dir'] = $tmp['value']; - $skip = true; + if ( $result ) { + $info = $result->fetchRow(); + + if ( isset($_SESSION['s_prefs']) ) { + $prefs = $_SESSION['s_prefs']; + } else { + $query = "select `value` from `tiki_preferences` where `name` = 'fgal_use_dir';"; + $result = $db->query($query); + if ( $result ) { + $tmp = $result->fetchRow(); + $prefs = array('fgal_use_dir' => $tmp['value']); + } + } + + $skip = true; + } else { + $info = array(); + } } else { session_write_close(); } @@ -237,7 +249,7 @@ } if ( ! isset($_GET['icon']) || ( isset($_GET['format']) && $_GET['format'] != $format ) ) { - if ( isset($info['path']) ) { + if ( ! empty($info['path']) ) { $image = new Image($prefs['fgal_use_dir'].$info['path'], true); } else { $image = new Image($content); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sy...@us...> - 2009-01-26 22:45:33
|
Revision: 16418 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=16418&view=rev Author: sylvieg Date: 2009-01-26 22:11:20 +0000 (Mon, 26 Jan 2009) Log Message: ----------- notice Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2009-01-26 21:46:53 UTC (rev 16417) +++ trunk/tiki-download_file.php 2009-01-26 22:11:20 UTC (rev 16418) @@ -7,7 +7,7 @@ if ( isset($_GET['fileId']) && isset($_GET['thumbnail']) && isset($_COOKIE['PHPSESSID']) && count($_GET) == 2 ) { session_start(); - if ( $_SESSION['allowed'][$_GET['fileId']] ) { + if ( isset($_SESSION['allowed'][$_GET['fileId']]) ) { include('db/tiki-db.php'); include('lib/tikidblib.php'); $db = new TikiDB($dbTiki); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2009-02-24 15:00:03
|
Revision: 16886 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=16886&view=rev Author: sept_7 Date: 2009-02-24 14:59:47 +0000 (Tue, 24 Feb 2009) Log Message: ----------- [FIX] file galeries : fix thumbnail display... Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2009-02-24 10:03:20 UTC (rev 16885) +++ trunk/tiki-download_file.php 2009-02-24 14:59:47 UTC (rev 16886) @@ -145,7 +145,7 @@ $md5 = ''; if ( ! empty($info['path']) ) { - if ($filegallib->isPodCastGallery($info['galleryId'])) { + if (!$skip and $filegallib->isPodCastGallery($info['galleryId'])) { $filepath = $prefs['fgal_podcast_dir'].$info['path']; } else { $filepath = $prefs['fgal_use_dir'].$info['path']; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2009-02-24 23:08:05
|
Revision: 16899 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=16899&view=rev Author: sewilco Date: 2009-02-24 22:43:39 +0000 (Tue, 24 Feb 2009) Log Message: ----------- [FIX] Use different ETag for modified image than original image. Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2009-02-24 19:22:00 UTC (rev 16898) +++ trunk/tiki-download_file.php 2009-02-24 22:43:39 UTC (rev 16899) @@ -169,7 +169,12 @@ } // ETag: Entity Tag used for strong cache validation. -$etag = '"' . $md5 . '-' . crc32($md5) . '"'; +if ( ! isset($_GET['display']) || isset($_GET['x']) || isset($_GET['y']) || isset($_GET['scale']) || isset($_GET['max']) || isset($_GET['format']) ) { + // if image will be modified, emit a different ETag for modifications. + $etag = '"' . $md5 . '-' . crc32($md5) . '-' . crc32( $_GET['x'] . 'x' . $_GET['y'] . 'y' . $_GET['scale'] . 's' . $_GET['max'] . 'm' . $_GET['format'] . 'f' ) . '"'; +} else { + $etag = '"' . $md5 . '-' . crc32($md5) . '"'; +} header('ETag: '.$etag); $use_client_cache = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_...@us...> - 2009-05-31 18:40:30
|
Revision: 19254 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=19254&view=rev Author: m_stef Date: 2009-05-31 18:40:20 +0000 (Sun, 31 May 2009) Log Message: ----------- [fix] system-wide pear installation blocked image thumbnail generation. tiki-download_file.php?fileId=1&thumbnail fails with this error if the OS has an own version of PEAR installed in the include path: Fatal error: Cannot redeclare _pear_call_destructors() (previously declared in /usr/share/php /PEAR.php:775) in /home/work/public/tiki/lib/pear/PEAR.php on line 806 Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2009-05-31 16:38:29 UTC (rev 19253) +++ trunk/tiki-download_file.php 2009-05-31 18:40:20 UTC (rev 19254) @@ -14,6 +14,7 @@ session_start(); if ( isset($_SESSION['allowed'][$_GET['fileId']]) ) { + require_once 'tiki-filter-base.php'; include('db/tiki-db.php'); include('lib/tikidblib.php'); $db = new TikiDB($dbTiki); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jon...@us...> - 2010-01-22 23:36:41
|
Revision: 24614 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=24614&view=rev Author: jonnybradley Date: 2010-01-22 23:36:31 +0000 (Fri, 22 Jan 2010) Log Message: ----------- [FIX] Don't replace the existing data with the cached version if empty Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2010-01-22 23:10:16 UTC (rev 24613) +++ trunk/tiki-download_file.php 2010-01-22 23:36:31 UTC (rev 24614) @@ -213,19 +213,22 @@ // Cache only thumbnails to avoid DOS attacks if ( ( isset($_GET['thumbnail']) || isset($_GET['preview']) ) && ! isset($_GET['display']) && ! isset($_GET['icon']) && ! isset($_GET['scale']) && ! isset($_GET['x']) && ! isset($_GET['y']) && ! isset($_GET['format']) && ! isset($_GET['max']) ) { - global $cachelib; include_once('lib/cache/cachelib.php'); + global $cachelib; include_once('lib/cache/cachelib.php'); $cacheName = $md5; - $cacheType = ( isset($_GET['thumbnail']) ? 'thumbnail_' : 'preview_' ) . ((int)$_REQUEST['fileId']).'_'; + $cacheType = ( isset($_GET['thumbnail']) ? 'thumbnail_' : 'preview_' ) . ((int)$_REQUEST['fileId']).'_'; $use_cache = true; } $build_content = true; - if ( $use_cache && $content = $cachelib->getCached($cacheName, $cacheType) ) { - if ($content !== serialize(false) and $content != "") { + $content_temp = $cachelib->getCached($cacheName, $cacheType); + if ( $use_cache && $content_temp ) { + if ($content_temp !== serialize(false) and $content_temp != "") { $build_content = false; + $content = $content_temp; } $content_changed = true; } + unset($content_temp); if ($build_content) { @@ -311,7 +314,7 @@ } } - if ( $use_cache ) { + if ( $use_cache && !empty($content) ) { // Remove all existing thumbnails for this file, to avoid taking too much disk space // (only one thumbnail size is handled at the same time) $cachelib->empty_type_cache($cacheType); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jon...@us...> - 2010-01-30 17:24:10
|
Revision: 24753 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=24753&view=rev Author: jonnybradley Date: 2010-01-30 17:24:04 +0000 (Sat, 30 Jan 2010) Log Message: ----------- [FIX] Only use params actually set in request in etag string. Also test for no $user properly. Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2010-01-30 17:21:52 UTC (rev 24752) +++ trunk/tiki-download_file.php 2010-01-30 17:24:04 UTC (rev 24753) @@ -176,7 +176,12 @@ // ETag: Entity Tag used for strong cache validation. if ( ! isset($_GET['display']) || isset($_GET['x']) || isset($_GET['y']) || isset($_GET['scale']) || isset($_GET['max']) || isset($_GET['format']) ) { // if image will be modified, emit a different ETag for modifications. - $etag = '"' . $md5 . '-' . crc32($md5) . '-' . crc32( $_GET['x'] . 'x' . $_GET['y'] . 'y' . $_GET['scale'] . 's' . $_GET['max'] . 'm' . $_GET['format'] . 'f' ) . '"'; + $str = isset($_GET['x']) ? $_GET['x'] . 'x' : ''; + $str .= isset($_GET['y']) ? $_GET['y'] . 'y' : ''; + $str .= isset($_GET['scale']) ? $_GET['scale'] . 's' : ''; + $str .= isset($_GET['max']) ? $_GET['max'] . 'm' : ''; + $str .= isset($_GET['format']) ? $_GET['format'] . 'f' : ''; + $etag = '"' . $md5 . '-' . crc32($md5) . '-' . crc32( $str ) . '"'; } else { $etag = '"' . $md5 . '-' . crc32($md5) . '"'; } @@ -198,7 +203,7 @@ header("Pragma: "); header('Expires: '); -header('Cache-Control: '.( $user ? 'private' : 'public' ).',must-revalidate,post-check=0,pre-check=0'); +header('Cache-Control: '.( !empty($user) ? 'private' : 'public' ).',must-revalidate,post-check=0,pre-check=0'); if ( $use_client_cache ) { header('Status: 304 Not Modified', true, 304); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lu...@us...> - 2010-02-02 22:59:42
|
Revision: 24805 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=24805&view=rev Author: luciash Date: 2010-02-02 22:59:36 +0000 (Tue, 02 Feb 2010) Log Message: ----------- [FIX] file galleries: php notices borked image file intended to display Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2010-02-02 22:44:43 UTC (rev 24804) +++ trunk/tiki-download_file.php 2010-02-02 22:59:36 UTC (rev 24805) @@ -95,8 +95,6 @@ } elseif ( isset($_REQUEST['fileId']) && is_array($_REQUEST['fileId'])) { $info = $filegallib->zip($_REQUEST['fileId'], $error); $zip = true; - } elseif ( !empty($_REQUEST['randomGalleryId'])) { - $info = $tikilib->get_file(0, $_REQUEST['randomGalleryId']); } else { $smarty->assign('msg', tra('Incorrect param')); $smarty->display('error.tpl'); @@ -219,6 +217,8 @@ $use_cache = false; // Cache only thumbnails to avoid DOS attacks + $cacheName = ''; + $cacheType = ''; if ( ( isset($_GET['thumbnail']) || isset($_GET['preview']) ) && ! isset($_GET['display']) && ! isset($_GET['icon']) && ! isset($_GET['scale']) && ! isset($_GET['x']) && ! isset($_GET['y']) && ! isset($_GET['format']) && ! isset($_GET['max']) ) { global $cachelib; include_once('lib/cache/cachelib.php'); $cacheName = $md5; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lu...@us...> - 2010-02-02 23:26:42
|
Revision: 24806 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=24806&view=rev Author: luciash Date: 2010-02-02 23:26:35 +0000 (Tue, 02 Feb 2010) Log Message: ----------- oops, accidental removal... sorry sylvie Modified Paths: -------------- trunk/tiki-download_file.php Property Changed: ---------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2010-02-02 22:59:36 UTC (rev 24805) +++ trunk/tiki-download_file.php 2010-02-02 23:26:35 UTC (rev 24806) @@ -1,5 +1,5 @@ <?php -// CVS: $Id: tiki-download_file.php,v 1.33.2.4 2008-03-13 20:12:44 nyloth Exp $ +// SVN $Id$ // Initialization $force_no_compression = true; $skip = false; @@ -95,6 +95,8 @@ } elseif ( isset($_REQUEST['fileId']) && is_array($_REQUEST['fileId'])) { $info = $filegallib->zip($_REQUEST['fileId'], $error); $zip = true; + } elseif ( !empty($_REQUEST['randomGalleryId'])) { + $info = $tikilib->get_file(0, $_REQUEST['randomGalleryId']); } else { $smarty->assign('msg', tra('Incorrect param')); $smarty->display('error.tpl'); Property changes on: trunk/tiki-download_file.php ___________________________________________________________________ Added: svn:keywords + Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sy...@us...> - 2010-10-18 13:55:39
|
Revision: 30090 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=30090&view=rev Author: sylvieg Date: 2010-10-18 13:55:33 +0000 (Mon, 18 Oct 2010) Log Message: ----------- [NEW]img: url param thumbnail=fileId to download a different thumbnail for an image Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2010-10-18 12:21:07 UTC (rev 30089) +++ trunk/tiki-download_file.php 2010-10-18 13:55:33 UTC (rev 30090) @@ -112,6 +112,15 @@ $smarty->display('error.tpl'); die; } + if ( isset($_GET['thumbnail']) && is_numeric($_GET['thumbnail'])) { //check also perms on thumb + $info_thumb = $tikilib->get_file($_GET['thumbnail']); + if ( !$zip && $tiki_p_admin_file_galleries != 'y' && !$userlib->user_has_perm_on_object($user, $info_thumb['galleryId'], 'file gallery', 'tiki_p_download_files') && !($info['backlinkPerms'] == 'y' && !$filegallib->hasOnlyPrivateBacklinks($info_thumb['fileId']))) { + $smarty->assign('errortype', 401); + $smarty->assign('msg', tra('Permission denied')); + $smarty->display('error.tpl'); + die; + } + } } // Add hits ( if download or display only ) + lock if set @@ -240,7 +249,7 @@ if ($build_content) { // Modify the original image if needed - if ( ! isset($_GET['display']) || isset($_GET['x']) || isset($_GET['y']) || isset($_GET['scale']) || isset($_GET['max']) || isset($_GET['format']) ) { + if ( ! isset($_GET['display']) || isset($_GET['x']) || isset($_GET['y']) || isset($_GET['scale']) || isset($_GET['max']) || isset($_GET['format']) || isset($_GET['thumbnail']) ) { require_once('lib/images/images.php'); if (!class_exists('Image')) die(); @@ -299,6 +308,18 @@ } // We resize to a thumbnail size if needed elseif ( isset($_GET['thumbnail']) ) { + if (is_numeric($_GET['thumbnail'])) { + if (empty($info_thumb)) { + $info_thumb = $tikilib->get_file($_GET['thumbnail']); + } + if ( ! empty($info_thumb['path']) ) { + $image = new Image($prefs['fgal_use_dir'].$info_thumb['path'], true); + } else { + $image = new Image($info_thumb['data']); + $content = null; // Explicitely free memory before getting cache + } + if ( $image->is_empty() ) die; + } $image->resizethumb(); } // We resize to a preview size if needed This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Nyloth <ny...@ti...> - 2011-01-30 22:47:35
|
Hi Sylvie ! I don't understand the purpose of this. In which case do you use it ? Why not simply calling tiki-download_file.php?fileId={$thumbId}&thumbnail ? Cheers, Nyloth 2010/10/18 <sy...@us...> > Revision: 30090 > http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=30090&view=rev > Author: sylvieg > Date: 2010-10-18 13:55:33 +0000 (Mon, 18 Oct 2010) > > Log Message: > ----------- > [NEW]img: url param thumbnail=fileId to download a different thumbnail for > an image > > Modified Paths: > -------------- > trunk/tiki-download_file.php > > Modified: trunk/tiki-download_file.php > =================================================================== > --- trunk/tiki-download_file.php 2010-10-18 12:21:07 UTC (rev 30089) > +++ trunk/tiki-download_file.php 2010-10-18 13:55:33 UTC (rev 30090) > @@ -112,6 +112,15 @@ > $smarty->display('error.tpl'); > die; > } > + if ( isset($_GET['thumbnail']) && is_numeric($_GET['thumbnail'])) { > //check also perms on thumb > + $info_thumb = $tikilib->get_file($_GET['thumbnail']); > + if ( !$zip && $tiki_p_admin_file_galleries != 'y' && > !$userlib->user_has_perm_on_object($user, $info_thumb['galleryId'], 'file > gallery', 'tiki_p_download_files') && !($info['backlinkPerms'] == 'y' && > !$filegallib->hasOnlyPrivateBacklinks($info_thumb['fileId']))) { > + $smarty->assign('errortype', 401); > + $smarty->assign('msg', tra('Permission denied')); > + $smarty->display('error.tpl'); > + die; > + } > + } > } > > // Add hits ( if download or display only ) + lock if set > @@ -240,7 +249,7 @@ > if ($build_content) { > > // Modify the original image if needed > - if ( ! isset($_GET['display']) || isset($_GET['x']) || > isset($_GET['y']) || isset($_GET['scale']) || isset($_GET['max']) || > isset($_GET['format']) ) { > + if ( ! isset($_GET['display']) || isset($_GET['x']) || > isset($_GET['y']) || isset($_GET['scale']) || isset($_GET['max']) || > isset($_GET['format']) || isset($_GET['thumbnail']) ) { > > require_once('lib/images/images.php'); > if (!class_exists('Image')) die(); > @@ -299,6 +308,18 @@ > } > // We resize to a thumbnail size if needed > elseif ( isset($_GET['thumbnail']) ) { > + if (is_numeric($_GET['thumbnail'])) > { > + if (empty($info_thumb)) { > + $info_thumb = > $tikilib->get_file($_GET['thumbnail']); > + } > + if ( ! > empty($info_thumb['path']) ) { > + $image = new > Image($prefs['fgal_use_dir'].$info_thumb['path'], true); > + } else { > + $image = new > Image($info_thumb['data']); > + $content = null; // > Explicitely free memory before getting cache > + } > + if ( $image->is_empty() ) > die; > + } > $image->resizethumb(); > } > // We resize to a preview size if needed > > > This was sent by the SourceForge.net collaborative development platform, > the world's largest Open Source development site. > > > ------------------------------------------------------------------------------ > Download new Adobe(R) Flash(R) Builder(TM) 4 > The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly > Flex(R) Builder(TM)) enable the development of rich applications that run > across multiple browsers and platforms. Download your free trials today! > http://p.sf.net/sfu/adobe-dev2dev > _______________________________________________ > Tikiwiki-cvs mailing list > Tik...@li... > https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs > |
From: Jonny B. <jo...@ti...> - 2011-01-31 12:22:51
|
On 30 Jan 2011, at 22:47, Nyloth wrote: > Hi Sylvie ! > > I don't understand the purpose of this. In which case do you use it ? > Why not simply calling tiki-download_file.php?fileId={$thumbId}&thumbnail ? > > Cheers, > Nyloth And there's already a sefurl so you can just use /thumbnail42 (since Tiki 3 i think?) Or are you somehow now having a different thumbId for a file (different from the fileId)? Also not understanding... jb > > > 2010/10/18 <sy...@us...> > Revision: 30090 > http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=30090&view=rev > Author: sylvieg > Date: 2010-10-18 13:55:33 +0000 (Mon, 18 Oct 2010) > > Log Message: > ----------- > [NEW]img: url param thumbnail=fileId to download a different thumbnail for an image > > Modified Paths: > -------------- > trunk/tiki-download_file.php > > Modified: trunk/tiki-download_file.php > =================================================================== > --- trunk/tiki-download_file.php 2010-10-18 12:21:07 UTC (rev 30089) > +++ trunk/tiki-download_file.php 2010-10-18 13:55:33 UTC (rev 30090) > @@ -112,6 +112,15 @@ > $smarty->display('error.tpl'); > die; > } > + if ( isset($_GET['thumbnail']) && is_numeric($_GET['thumbnail'])) { //check also perms on thumb > + $info_thumb = $tikilib->get_file($_GET['thumbnail']); > + if ( !$zip && $tiki_p_admin_file_galleries != 'y' && !$userlib->user_has_perm_on_object($user, $info_thumb['galleryId'], 'file gallery', 'tiki_p_download_files') && !($info['backlinkPerms'] == 'y' && !$filegallib->hasOnlyPrivateBacklinks($info_thumb['fileId']))) { > + $smarty->assign('errortype', 401); > + $smarty->assign('msg', tra('Permission denied')); > + $smarty->display('error.tpl'); > + die; > + } > + } > } > > // Add hits ( if download or display only ) + lock if set > @@ -240,7 +249,7 @@ > if ($build_content) { > > // Modify the original image if needed > - if ( ! isset($_GET['display']) || isset($_GET['x']) || isset($_GET['y']) || isset($_GET['scale']) || isset($_GET['max']) || isset($_GET['format']) ) { > + if ( ! isset($_GET['display']) || isset($_GET['x']) || isset($_GET['y']) || isset($_GET['scale']) || isset($_GET['max']) || isset($_GET['format']) || isset($_GET['thumbnail']) ) { > > require_once('lib/images/images.php'); > if (!class_exists('Image')) die(); > @@ -299,6 +308,18 @@ > } > // We resize to a thumbnail size if needed > elseif ( isset($_GET['thumbnail']) ) { > + if (is_numeric($_GET['thumbnail'])) { > + if (empty($info_thumb)) { > + $info_thumb = $tikilib->get_file($_GET['thumbnail']); > + } > + if ( ! empty($info_thumb['path']) ) { > + $image = new Image($prefs['fgal_use_dir'].$info_thumb['path'], true); > + } else { > + $image = new Image($info_thumb['data']); > + $content = null; // Explicitely free memory before getting cache > + } > + if ( $image->is_empty() ) die; > + } > $image->resizethumb(); > } > // We resize to a preview size if needed > > > This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. > > ------------------------------------------------------------------------------ > Download new Adobe(R) Flash(R) Builder(TM) 4 > The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly > Flex(R) Builder(TM)) enable the development of rich applications that run > across multiple browsers and platforms. Download your free trials today! > http://p.sf.net/sfu/adobe-dev2dev > _______________________________________________ > Tikiwiki-cvs mailing list > Tik...@li... > https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs > > ------------------------------------------------------------------------------ > Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! > Finally, a world-class log management solution at an even better price-free! > Download using promo code Free_Logger_4_Dev2Dev. Offer expires > February 28th, so secure your free ArcSight Logger TODAY! > http://p.sf.net/sfu/arcsight-sfd2d_______________________________________________ > Tikiwiki-cvs mailing list > Tik...@li... > https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs |
From: <ch...@us...> - 2010-12-16 16:36:01
|
Revision: 31453 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=31453&view=rev Author: chealer Date: 2010-12-16 16:35:55 +0000 (Thu, 16 Dec 2010) Log Message: ----------- Error if file cannot be accessed Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2010-12-16 16:32:06 UTC (rev 31452) +++ trunk/tiki-download_file.php 2010-12-16 16:35:55 UTC (rev 31453) @@ -176,6 +176,9 @@ : $info['hash']; } else { // File missing or not readable + header("HTTP/1.0 404 Not Found"); + header('Content-Type: text/plain'); + echo "Unable to access file: " . ($tiki_p_admin == 'y' ? $filepath : $info['path']); die; } } elseif ( ! empty($content) ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Marc L. <ma...@ma...> - 2010-12-17 01:00:14
|
This is useful if you move your site and you forget to move your files. (instead of a blank page) M ;-) On Thu, Dec 16, 2010 at 11:35 AM, <ch...@us...> wrote: > Revision: 31453 > http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=31453&view=rev > Author: chealer > Date: 2010-12-16 16:35:55 +0000 (Thu, 16 Dec 2010) > > Log Message: > ----------- > Error if file cannot be accessed > > Modified Paths: > -------------- > trunk/tiki-download_file.php > > Modified: trunk/tiki-download_file.php > =================================================================== > --- trunk/tiki-download_file.php 2010-12-16 16:32:06 UTC (rev 31452) > +++ trunk/tiki-download_file.php 2010-12-16 16:35:55 UTC (rev 31453) > @@ -176,6 +176,9 @@ > : $info['hash']; > } else { > // File missing or not readable > + header("HTTP/1.0 404 Not Found"); > + header('Content-Type: text/plain'); > + echo "Unable to access file: " . ($tiki_p_admin == 'y' ? $filepath : $info['path']); > die; > } > } elseif ( ! empty($content) ) { > > > This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. > > ------------------------------------------------------------------------------ > Lotusphere 2011 > Register now for Lotusphere 2011 and learn how > to connect the dots, take your collaborative environment > to the next level, and enter the era of Social Business. > http://p.sf.net/sfu/lotusphere-d2d > _______________________________________________ > Tikiwiki-cvs mailing list > Tik...@li... > https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs > -- Marc Laporte http://MarcLaporte.com http://Tiki.org/MarcLaporte http://AvanTech.net |
From: <ny...@us...> - 2011-01-30 21:43:17
|
Revision: 32270 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=32270&view=rev Author: nyloth Date: 2011-01-30 21:43:10 +0000 (Sun, 30 Jan 2011) Log Message: ----------- [FIX] file download: allow temporary access to the shared file if the token is valid Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2011-01-30 21:12:22 UTC (rev 32269) +++ trunk/tiki-download_file.php 2011-01-30 21:43:10 UTC (rev 32270) @@ -110,20 +110,25 @@ $smarty->display('error.tpl'); die; } - if ( !$zip && $tiki_p_admin_file_galleries != 'y' && !$userlib->user_has_perm_on_object($user, $info['galleryId'], 'file gallery', 'tiki_p_download_files') && !($info['backlinkPerms'] == 'y' && !$filegallib->hasOnlyPrivateBacklinks($info['fileId']))) { - $smarty->assign('errortype', 401); - $smarty->assign('msg', tra('Permission denied')); - $smarty->display('error.tpl'); - die; - } - if ( isset($_GET['thumbnail']) && is_numeric($_GET['thumbnail'])) { //check also perms on thumb - $info_thumb = $tikilib->get_file($_GET['thumbnail']); - if ( !$zip && $tiki_p_admin_file_galleries != 'y' && !$userlib->user_has_perm_on_object($user, $info_thumb['galleryId'], 'file gallery', 'tiki_p_download_files') && !($info['backlinkPerms'] == 'y' && !$filegallib->hasOnlyPrivateBacklinks($info_thumb['fileId']))) { + + if ( $prefs['auth_tokens'] == 'n' || !$is_token_access ) { + // Check permissions except if the user comes with a valid Token + + if ( !$zip && $tiki_p_admin_file_galleries != 'y' && !$userlib->user_has_perm_on_object($user, $info['galleryId'], 'file gallery', 'tiki_p_download_files') && !($info['backlinkPerms'] == 'y' && !$filegallib->hasOnlyPrivateBacklinks($info['fileId']))) { $smarty->assign('errortype', 401); $smarty->assign('msg', tra('Permission denied')); $smarty->display('error.tpl'); die; } + if ( isset($_GET['thumbnail']) && is_numeric($_GET['thumbnail'])) { //check also perms on thumb + $info_thumb = $tikilib->get_file($_GET['thumbnail']); + if ( !$zip && $tiki_p_admin_file_galleries != 'y' && !$userlib->user_has_perm_on_object($user, $info_thumb['galleryId'], 'file gallery', 'tiki_p_download_files') && !($info['backlinkPerms'] == 'y' && !$filegallib->hasOnlyPrivateBacklinks($info_thumb['fileId']))) { + $smarty->assign('errortype', 401); + $smarty->assign('msg', tra('Permission denied')); + $smarty->display('error.tpl'); + die; + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2011-01-30 21:47:48
|
Revision: 32271 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=32271&view=rev Author: nyloth Date: 2011-01-30 21:47:42 +0000 (Sun, 30 Jan 2011) Log Message: ----------- [FIX] download file: fix notice when fgal_use_dir is not set Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2011-01-30 21:43:10 UTC (rev 32270) +++ trunk/tiki-download_file.php 2011-01-30 21:47:42 UTC (rev 32271) @@ -33,9 +33,12 @@ $result = $db->query($query); if ( $result ) { $tmp = $result->fetchRow(); - $prefs = array('fgal_use_dir' => $tmp['value']); + $prefs['fgal_use_dir'] = $tmp['value']; } } + if ( !isset($prefs['fgal_use_dir']) ) { + $prefs['fgal_use_dir'] = ''; + } $skip = true; } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2011-01-30 22:42:57
|
Revision: 32275 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=32275&view=rev Author: nyloth Date: 2011-01-30 22:42:51 +0000 (Sun, 30 Jan 2011) Log Message: ----------- [FIX] filegals file download : Fix multiple problems, including : - fix thumbnail format and mime type - .txt files thumbnails ( by using a icon fallback method ) - thumbnails cache - mime type detection for files stored in DB Modified Paths: -------------- trunk/tiki-download_file.php Modified: trunk/tiki-download_file.php =================================================================== --- trunk/tiki-download_file.php 2011-01-30 22:10:52 UTC (rev 32274) +++ trunk/tiki-download_file.php 2011-01-30 22:42:51 UTC (rev 32275) @@ -7,6 +7,7 @@ $force_no_compression = true; $skip = false; +$thumbnail_format = 'jpeg'; if ( isset($_GET['fileId']) && isset($_GET['thumbnail']) && isset($_COOKIE[ session_name() ]) && count($_GET) == 2 ) { @@ -172,6 +173,7 @@ $content = &$info['data']; $md5 = ''; +$filepath = ''; if ( ! empty($info['path']) ) { if (!$skip and $filegallib->isPodCastGallery($info['galleryId'])) { $filepath = $prefs['fgal_podcast_dir'].$info['path']; @@ -250,6 +252,11 @@ $cacheName = $md5; $cacheType = ( isset($_GET['thumbnail']) ? 'thumbnail_' : 'preview_' ) . ((int)$_REQUEST['fileId']).'_'; $use_cache = true; + + if ( isset($_GET['thumbnail']) ) { + // For thumbnails, change the filetype to the appropriate one, which is often different from the original filetype... + $info['filetype'] = 'image/' . $thumbnail_format; + } } $build_content = true; @@ -279,84 +286,96 @@ $_GET['icon'] = 'y'; $_GET['max'] = 32; } - - if ( isset($_GET['icon']) ) { - unset($info['path']); - $content = null; // Explicitely free memory before generating icon - if ( isset($_GET['max']) ) { - $icon_x = $_GET['max']; - $icon_y = $_GET['max']; - } else { - $icon_x = isset($_GET['x']) ? $_GET['x'] : 0; - $icon_y = isset($_GET['y']) ? $_GET['y'] : 0; - } + do { + $tryIconFallback = false; + + if ( isset($_GET['icon']) ) { + unset($info['path']); + $content = null; // Explicitely free memory before generating icon - $content = Image::icon($format, $icon_x, $icon_y); - $format = Image::get_icon_default_format(); - $info['filetype'] = 'image/'.$format; - $info['lastModif'] = 0; - } - - if ( ! isset($_GET['icon']) || ( isset($_GET['format']) && $_GET['format'] != $format ) ) { - if ( ! empty($info['path']) ) { - $image = new Image($prefs['fgal_use_dir'].$info['path'], true); - } else { - $image = new Image($content); - $content = null; // Explicitely free memory before getting cache + if ( isset($_GET['max']) ) { + $icon_x = $_GET['max']; + $icon_y = $_GET['max']; + } else { + $icon_x = isset($_GET['x']) ? $_GET['x'] : 0; + $icon_y = isset($_GET['y']) ? $_GET['y'] : 0; + } + + $content = Image::icon($format, $icon_x, $icon_y); + $format = Image::get_icon_default_format(); + $info['filetype'] = 'image/'.$format; + $info['lastModif'] = 0; } - if ( $image->is_empty() ) die; - - $resize = false; - // We resize if needed - if ( isset($_GET['x']) || isset($_GET['y']) ) { - $image->resize($_GET['x']+0, $_GET['y']+0); - $resize = true; - } - // We scale if needed - elseif ( isset($_GET['scale']) ) { - $image->scale($_GET['scale']+0); - $resize = true; - } - // We reduce size if length or width is greater that $_GET['max'] if needed - elseif ( isset($_GET['max']) ) { - $image->resizemax($_GET['max']+0); - $resize = true; - } - // We resize to a thumbnail size if needed - elseif ( isset($_GET['thumbnail']) ) { - if (is_numeric($_GET['thumbnail'])) { - if (empty($info_thumb)) { - $info_thumb = $tikilib->get_file($_GET['thumbnail']); + + if ( ! isset($_GET['icon']) || ( isset($_GET['format']) && $_GET['format'] != $format ) ) { + if ( ! empty($info['path']) ) { + $image = new Image($prefs['fgal_use_dir'].$info['path'], true); + } else { + $image = new Image($content); + $content = null; // Explicitely free memory before getting cache + } + if ( $image->is_empty() ) die; + + $resize = false; + // We resize if needed + if ( isset($_GET['x']) || isset($_GET['y']) ) { + $image->resize($_GET['x']+0, $_GET['y']+0); + $resize = true; + } + // We scale if needed + elseif ( isset($_GET['scale']) ) { + $image->scale($_GET['scale']+0); + $resize = true; + } + // We reduce size if length or width is greater that $_GET['max'] if needed + elseif ( isset($_GET['max']) ) { + $image->resizemax($_GET['max']+0); + $resize = true; + } + // We resize to a thumbnail size if needed + elseif ( isset($_GET['thumbnail']) ) { + if (is_numeric($_GET['thumbnail'])) { + if (empty($info_thumb)) { + $info_thumb = $tikilib->get_file($_GET['thumbnail']); + } + if ( ! empty($info_thumb['path']) ) { + $image = new Image($prefs['fgal_use_dir'].$info_thumb['path'], true); + } else { + $image = new Image($info_thumb['data']); + $content = null; // Explicitely free memory before getting cache + } + if ( $image->is_empty() ) die; } - if ( ! empty($info_thumb['path']) ) { - $image = new Image($prefs['fgal_use_dir'].$info_thumb['path'], true); - } else { - $image = new Image($info_thumb['data']); - $content = null; // Explicitely free memory before getting cache - } - if ( $image->is_empty() ) die; + $image->resizethumb(); } - $image->resizethumb(); - } - // We resize to a preview size if needed - elseif ( isset($_GET['preview']) ) { - $image->resizemax('800'); - $resize = true; - } + // We resize to a preview size if needed + elseif ( isset($_GET['preview']) ) { + $image->resizemax('800'); + $resize = true; + } + + // We change the image format if needed + if ( isset($_GET['format']) && Image::is_supported($_GET['format']) ) { + $image->convert($_GET['format']); + } + // Or, if no format is explicitely specified and a thumbnail has to be created, we convert the image to the $thumbnail_format + elseif ( isset($_GET['thumbnail']) ) { + $image->convert($thumbnail_format); + } + + $content =& $image->display(); - // We change the image format if needed - if ( isset($_GET['format']) && Image::is_supported($_GET['format']) ) { - $image->convert($_GET['format']); + // If the new image creating has failed, fallback to an icon + if ( ! isset($_GET['icon']) && ( $content === null || $content === false ) ) { + $tryIconFallback = true; + $_GET['icon'] = 'y'; + $_GET['max'] = 32; + } else { + $info['filetype'] = $image->get_mimetype(); + } } - // By default, we change the image format to the usual most common format (jpeg) for thumbnails - elseif ( isset($_GET['thumbnail']) ) { - $image->convert('jpeg'); - } - - $content =& $image->display(); - $info['filetype'] = $image->get_mimetype(); - } + } while ( $tryIconFallback ); } if ( $use_cache && !empty($content) ) { @@ -372,7 +391,7 @@ if ( empty($info['filetype']) || $info['filetype'] == 'application/x-octetstream' || $info['filetype'] == 'application/octet-stream' ) { include_once('lib/mime/mimelib.php'); - $info['filetype'] = tiki_get_mime($info['filename'], 'application/octet-stream'); + $info['filetype'] = tiki_get_mime($info['filename'], 'application/octet-stream', $filepath); } header('Content-type: '.$info['filetype']); @@ -384,7 +403,7 @@ header("Content-Disposition: attachment; filename=\"$file\""); } -if ( $info['path'] and !$content_changed ) { +if ( !empty($filepath) and !$content_changed ) { header('Content-Length: '.filesize($filepath)); readfile_chunked($filepath); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |