Re-add fallbacks to getTempFolder() but show big error in ACP
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 24 Mar 2015 14:23:37 +0000 (15:23 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 24 Mar 2015 15:13:33 +0000 (16:13 +0100)
see 9e1466d5234033e6af344d2a146d6b03ccfdac0f

wcfsetup/install/files/acp/templates/index.tpl
wcfsetup/install/files/lib/util/FileUtil.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index b9c775cf8eee80d5d53df140d0b3d58dd928a80e..b0011a99816ba568c8f5c89cad5e397a45e22197 100644 (file)
        <p style="background-color: rgb(255, 153, 153); border: 2px solid rgb(255, 0, 0); padding: 1em;">{lang}wcf.acp.index.inRescueMode{/lang}</p>
 {/if}
 
+{if TMP_DIR !== WCF_DIR|concat:'tmp/'}
+       <p class="error">{lang}wcf.acp.index.tmpBroken{/lang}</p>
+{/if}
+
 {if $usersAwaitingApproval}
        <p class="info">{lang}wcf.acp.user.usersAwaitingApprovalInfo{/lang}</p>
 {/if}
index 26e65e1ca769fcdb30eb48b42dc33e07c814c009..4705e6a322eabf0648c38e787f9da047d91a5771 100644 (file)
@@ -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;
        }
        
        /** 
index 3bd871d322ee5b658940732c0680089fad075ab2..773d2539355e5192a20f1142ad2c2d67068d5f7c 100644 (file)
                <item name="wcf.acp.index.credits.contributor.more"><![CDATA[Weitere]]></item>
                <item name="wcf.acp.index.innoDBWarning"><![CDATA[Die MySQL-Einstellung „innodb_flush_log_at_trx_commit“ steht auf dem Wert „1“ und verursacht dadurch eine starke Verlangsamung bestimmter Datenbankabfragen. Es wird empfohlen diesen Wert auf „2“ zu setzen.]]></item>
                <item name="wcf.acp.index.inRescueMode"><![CDATA[Sie rufen diese Installation über eine abweichende Domain auf, etwa auf Grund eines Umzuges. Bitte korrigieren Sie die Einstellungen unter <a href="{link controller='ApplicationManagement'}{/link}">Anwendungen verwalten</a>.]]></item>
+               <item name="wcf.acp.index.tmpBroken"><![CDATA[Für den ordnungsgemäßen Betrieb muss das Verzeichnis „{WCF_DIR|concat:'tmp/'}“ existieren und beschreibbar sein. Bitte überprüfen Sie auch die Zugriffsrechte auf den Ordner „{'WCF_DIR'|constant}“.]]></item>
                <item name="wcf.acp.index.news"><![CDATA[Nachrichten]]></item>
                <item name="wcf.acp.index.setup.notice"><![CDATA[Die Installation wird in wenigen Augenblicken automatisch gestartet, bitte laden Sie diese Seite nicht neu.]]></item>
                <item name="wcf.acp.index.setup.title"><![CDATA[Bitte warten]]></item>
index 61674f3fd7a83185873d63bb87d11409d4ddfcd4..5007ba89c51a8fc78a3db4789f060679f347abd1 100644 (file)
@@ -449,8 +449,9 @@ Examples for medium ID detection:
                <item name="wcf.acp.index.credits.productManager"><![CDATA[Product Manager]]></item>
                <item name="wcf.acp.index.credits.trademarks"><![CDATA[“WoltLab&reg;” and “Burning Board&reg;” are registered Community Trade Marks at The Office of Harmonization for the Internal Market (OHIM) in Alicante, Spain.]]></item>
                <item name="wcf.acp.index.credits.contributor.more"><![CDATA[More]]></item>
-               <item name="wcf.acp.index.inRescueMode"><![CDATA[You are accessing this installation from an unknown domain, possibly caused by moving to a new host. Please update the settings on <a href="{link controller='ApplicationManagement'}{/link}">Manage Applications</a>.]]></item>
                <item name="wcf.acp.index.innoDBWarning"><![CDATA[The MySQL configuration option “innodb_flush_log_at_trx_commit” is set to “1”, slowing down certain database queries. It is highly recommended to set it’s value to “2”.]]></item>
+               <item name="wcf.acp.index.inRescueMode"><![CDATA[You are accessing this installation from an unknown domain, possibly caused by moving to a new host. Please update the settings on <a href="{link controller='ApplicationManagement'}{/link}">Manage Applications</a>.]]></item>
+               <item name="wcf.acp.index.tmpBroken"><![CDATA[For proper operation the folder “{WCF_DIR|concat:'tmp/'}” must exist and it must be writable. Please also check the permissions of the “{'WCF_DIR'|constant}” folder.]]></item>
                <item name="wcf.acp.index.news"><![CDATA[News]]></item>
                <item name="wcf.acp.index.setup.notice"><![CDATA[The installation will be continued within a few moments, please do not reload this page.]]></item>
                <item name="wcf.acp.index.setup.title"><![CDATA[Please Wait]]></item>