* @return string
*/
public static function getTempFolder() {
- $tmpDirName = TMP_FILE_PREFIX.'/';
-
// use tmp folder in document root by default
if (!empty($_SERVER['DOCUMENT_ROOT'])) {
- if (!@file_exists($_SERVER['DOCUMENT_ROOT'].'/tmp/'.$tmpDirName)) {
- @mkdir($_SERVER['DOCUMENT_ROOT'].'/tmp/'.$tmpDirName, 0777, true);
- self::makeWritable($_SERVER['DOCUMENT_ROOT'].'/tmp/'.$tmpDirName);
+ 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);
+ try {
+ self::makeWritable($_SERVER['DOCUMENT_ROOT'].'/tmp/');
+ }
+ catch (SystemException $e) {}
+ }
}
-
- if (@file_exists($_SERVER['DOCUMENT_ROOT'].'/tmp/'.$tmpDirName) && @is_writable($_SERVER['DOCUMENT_ROOT'].'/tmp/'.$tmpDirName)) {
- return $_SERVER['DOCUMENT_ROOT'].'/tmp/'.$tmpDirName;
+ if (@file_exists($_SERVER['DOCUMENT_ROOT'].'/tmp') && @is_writable($_SERVER['DOCUMENT_ROOT'].'/tmp')) {
+ return $_SERVER['DOCUMENT_ROOT'].'/tmp/';
}
}
-
- foreach (array('TMP', 'TEMP', 'TMPDIR') as $tmpDir) {
- if (isset($_ENV[$tmpDir]) && @is_writable($_ENV[$tmpDir])) {
- $dir = $_ENV[$tmpDir] . '/' . $tmpDirName;
- @mkdir($dir, 0777);
- self::makeWritable($dir);
-
- if (@file_exists($dir) && @is_writable($dir)) {
- return $dir;
- }
- }
+
+ if (isset($_ENV['TMP']) && @is_writable($_ENV['TMP'])) {
+ return $_ENV['TMP'] . '/';
}
-
- $dir = INSTALL_SCRIPT_DIR . 'tmp/' . $tmpDirName;
- @mkdir($dir, 0777);
- self::makeWritable($dir);
-
- if (!@file_exists($dir) || !@is_writable($dir)) {
- $tmpDir = explode('/', $dir);
- array_pop($tmpDir);
- $dir = implode('/', $tmpDir);
-
- 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 '.INSTALL_SCRIPT_DIR.'! This is a misconfiguration of your webserver software! Please create a folder called '.$dir.' using your favorite ftp program, make it writable and then retry this installation.');
+ 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 . '/';
+ }
+
+ $path = WCF_DIR.'tmp/';
+ if (@file_exists($path) && @is_writable($path)) {
+ return $path;
+ }
+ else {
+ 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 '.INSTALL_SCRIPT_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.');
}
+ }
+
+ /**
+ * Returns the temp folder for the installation.
+ *
+ * @return string
+ */
+ public static function getInstallTempFolder() {
+ $dir = self::getTempFolder() . TMP_FILE_PREFIX . '/';
+ @mkdir($dir);
+ self::makeWritable($dir);
return $dir;
}