From b61d5d537fef06f2d95da0df14d1cc00ad13d242 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 30 Oct 2012 13:36:21 +0000 Subject: [PATCH] download etemplate.inc.php distribution file, if webserver has no write rights to setup directory --- etemplate/inc/class.soetemplate.inc.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/etemplate/inc/class.soetemplate.inc.php b/etemplate/inc/class.soetemplate.inc.php index 3d4deb7bbc..7f44319d59 100644 --- a/etemplate/inc/class.soetemplate.inc.php +++ b/etemplate/inc/class.soetemplate.inc.php @@ -875,19 +875,23 @@ class soetemplate $dir = EGW_SERVER_ROOT . "/$app/setup"; if (!is_writeable($dir)) { - return lang("Error: webserver is not allowed to write into '%1' !!!",$dir); + // if dir is not writable, download file + html::content_header('etemplates.inc.php','application/octet-stream'); + $file = 'php://stdout'; } - $file = "$dir/etemplates.inc.php"; - if (file_exists($file)) + else { - $old_file = "$dir/etemplates.old.inc.php"; - if (file_exists($old_file)) + $file = "$dir/etemplates.inc.php"; + if (file_exists($file)) { - unlink($old_file); + $old_file = "$dir/etemplates.old.inc.php"; + if (file_exists($old_file)) + { + unlink($old_file); + } + rename($file,$old_file); } - rename($file,$old_file); } - if (!($f = fopen($file,'w'))) { return 0; @@ -930,6 +934,8 @@ class soetemplate } fclose($f); + if ($file == 'php://stdout') common::egw_exit(); + return lang("%1 eTemplates for Application '%2' dumped to '%3'",$n,$app,$file); }