From 7be96d4412e36b759590adfcdd470f21ab515589 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 7 Apr 2009 19:40:42 +0000 Subject: [PATCH] "added file_exists()" --- etemplate/thumbnail.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/etemplate/thumbnail.php b/etemplate/thumbnail.php index c2fc0cccfc..d331fa9bb0 100644 --- a/etemplate/thumbnail.php +++ b/etemplate/thumbnail.php @@ -9,6 +9,12 @@ * @version $Id$ */ +// strip slashes from _GET parameters, if someone still has magic_quotes_gpc on +if (get_magic_quotes_gpc() && $_GET) +{ + $_GET = etemplate::array_stripslashes($_GET); +} + if (isset($_GET['app'])) { $app = $_GET['app']; @@ -27,30 +33,26 @@ $GLOBALS['egw_info']['flags'] = array( ); include ('../header.inc.php'); -// strip slashes from _GET parameters, if someone still has magic_quotes_gpc on -if (get_magic_quotes_gpc() && $_GET) -{ - $_GET = etemplate::array_stripslashes($_GET); -} - if (isset($_GET['path'])) { - $g_srcfile = egw_vfs::PREFIX.$_GET['path']; + $g_srcfile = $_GET['path']; } else { - $g_srcfile = egw_link::vfs_path($_GET['app'],$_GET['id'],$_GET['file']); + $g_srcfile = egw_link::vfs_path($_GET['app'],$_GET['id'],$_GET['file'],true); } +$g_dstfile = $GLOBALS['egw_info']['server']['temp_dir'] . '/egw-thumbs'.$g_srcfile; +$g_srcfile = egw_vfs::PREFIX.$g_srcfile; + if (!file_exists($g_srcfile) || !egw_vfs::is_readable($g_srcfile)) { //error_log("file_exists('$g_srcfile')=".(int)file_exists($g_srcfile).", egw_vfs::is_readable('$g_srcfile')=".(int)egw_vfs::is_readable($g_srcfile)); header('404 Not found'); exit; } -$g_dstfile = $GLOBALS['egw_info']['server']['temp_dir'] . '/egw-thumbs'.parse_url($g_srcfile,PHP_URL_PATH); // Check for existing thumbnail -if(filemtime($g_dstfile) >= filemtime($g_srcfile)) { +if(file_exists($g_dstfile) && filemtime($g_dstfile) >= filemtime($g_srcfile)) { header('Content-Type: image/png'); readfile($g_dstfile); return;