From: Tim Düsterhus Date: Tue, 24 Mar 2015 14:23:37 +0000 (+0100) Subject: Re-add fallbacks to getTempFolder() but show big error in ACP X-Git-Tag: 2.1.2~6^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=40c9a81c4dd79b079b0f945f0eefaedabc317e8a;p=GitHub%2FWoltLab%2FWCF.git Re-add fallbacks to getTempFolder() but show big error in ACP see 9e1466d5234033e6af344d2a146d6b03ccfdac0f --- diff --git a/wcfsetup/install/files/acp/templates/index.tpl b/wcfsetup/install/files/acp/templates/index.tpl index b9c775cf8e..b0011a9981 100644 --- a/wcfsetup/install/files/acp/templates/index.tpl +++ b/wcfsetup/install/files/acp/templates/index.tpl @@ -16,6 +16,10 @@

{lang}wcf.acp.index.inRescueMode{/lang}

{/if} +{if TMP_DIR !== WCF_DIR|concat:'tmp/'} +

{lang}wcf.acp.index.tmpBroken{/lang}

+{/if} + {if $usersAwaitingApproval}

{lang}wcf.acp.user.usersAwaitingApprovalInfo{/lang}

{/if} diff --git a/wcfsetup/install/files/lib/util/FileUtil.class.php b/wcfsetup/install/files/lib/util/FileUtil.class.php index 26e65e1ca7..4705e6a322 100644 --- a/wcfsetup/install/files/lib/util/FileUtil.class.php +++ b/wcfsetup/install/files/lib/util/FileUtil.class.php @@ -39,34 +39,74 @@ final class FileUtil { * @return string */ public static function getTempFolder() { - // This method does not contain any shut up operator by intent. - // Any operation that fails here is fatal. - $path = WCF_DIR.'tmp/'; - - if (is_file($path)) { - // wat - unlink($path); - } - - if (!file_exists($path)) { - mkdir($path, 0777); - } - - if (!is_dir($path)) { - throw new SystemException("Temporary folder '".$path."' does not exist and could not be created. Please check the permissions of the '".WCF_DIR."' folder using your favorite ftp program."); - } - - if (!is_writable($path)) { - self::makeWritable($path); - } - - if (!is_writable($path)) { - throw new SystemException("Temporary folder '".$path."' is not writable. Please check the permissions using your favorite ftp program."); + try { + // This method does not contain any shut up operator by intent. + // Any operation that fails here is fatal. + $path = WCF_DIR.'tmp/'; + + if (is_file($path)) { + // wat + unlink($path); + } + + if (!file_exists($path)) { + mkdir($path, 0777); + } + + if (!is_dir($path)) { + throw new SystemException("Temporary folder '".$path."' does not exist and could not be created. Please check the permissions of the '".WCF_DIR."' folder using your favorite ftp program."); + } + + if (!is_writable($path)) { + self::makeWritable($path); + } + + if (!is_writable($path)) { + throw new SystemException("Temporary folder '".$path."' is not writable. Please check the permissions using your favorite ftp program."); + } + + file_put_contents($path.'/.htaccess', 'deny from all'); + + return $path; + } + catch (SystemException $e) { + // use tmp folder in document root by default + if (!empty($_SERVER['DOCUMENT_ROOT'])) { + if (strpos($_SERVER['DOCUMENT_ROOT'], 'strato') !== false) { + // strato bugfix + // create tmp folder in document root automatically + if (!@file_exists($_SERVER['DOCUMENT_ROOT'].'/tmp')) { + @mkdir($_SERVER['DOCUMENT_ROOT'].'/tmp/', 0777); + self::makeWritable($_SERVER['DOCUMENT_ROOT'].'/tmp/'); + } + } + if (@file_exists($_SERVER['DOCUMENT_ROOT'].'/tmp') && @is_writable($_SERVER['DOCUMENT_ROOT'].'/tmp')) { + return $_SERVER['DOCUMENT_ROOT'].'/tmp/'; + } + } + + if (isset($_ENV['TMP']) && @is_writable($_ENV['TMP'])) { + return $_ENV['TMP'] . '/'; + } + if (isset($_ENV['TEMP']) && @is_writable($_ENV['TEMP'])) { + return $_ENV['TEMP'] . '/'; + } + if (isset($_ENV['TMPDIR']) && @is_writable($_ENV['TMPDIR'])) { + return $_ENV['TMPDIR'] . '/'; + } + + if (($path = ini_get('upload_tmp_dir')) && @is_writable($path)) { + return $path . '/'; + } + if (@file_exists('/tmp/') && @is_writable('/tmp/')) { + return '/tmp/'; + } + if (function_exists('session_save_path') && ($path = session_save_path()) && @is_writable($path)) { + return $path . '/'; + } + + throw new SystemException('There is no access to the system temporary folder due to an unknown reason and no user specific temporary folder exists in '.WCF_DIR.'! This is a misconfiguration of your webserver software! Please create a folder called '.$path.' using your favorite ftp program, make it writable and then retry this installation.'); } - - file_put_contents($path.'/.htaccess', 'deny from all'); - - return $path; } /** diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 3bd871d322..773d253935 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -452,6 +452,7 @@ Anwendungen verwalten.]]> + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 61674f3fd7..5007ba89c5 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -449,8 +449,9 @@ Examples for medium ID detection: - Manage Applications.]]> + Manage Applications.]]> +