From 853b4b96406f1e75b57b8bd78eb7e38fc0729f2c Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 17 Jul 2004 23:52:11 +0000 Subject: [PATCH] The last checkin broke the wiki on installations where TMP is not set and the upload directory is not writable (ie, default install!) Now checks a system-dependent default temp dir first (/tmp or C:\Windows\Temp) and then falls back to upload dir. (TMP takes priority over either.) If the dir is not writable, print out an explanatory message for the poor sap trying to figure out why the wiki isn't working. Some of this crud shouldn't go in PHPTAL if possible, since it's rather mediawiki-specific. --- PHPTAL-NP-0.7.0/libs/PHPTAL.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/PHPTAL-NP-0.7.0/libs/PHPTAL.php b/PHPTAL-NP-0.7.0/libs/PHPTAL.php index 69a89a5e16..e3c0cd3fc9 100644 --- a/PHPTAL-NP-0.7.0/libs/PHPTAL.php +++ b/PHPTAL-NP-0.7.0/libs/PHPTAL.php @@ -67,11 +67,26 @@ define('PHPTAL_VERSION', '0.7.0'); define('PHPTAL_MARK', str_replace('.', '_', PHPTAL_VERSION) . '_'); if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") { - define('PHPTAL_DEFAULT_CACHE_DIR', getenv("TMP") . "\\"); + $default_temp = "C:\\Windows\\Temp"; } else { - global $wgUploadDirectory; - define('PHPTAL_DEFAULT_CACHE_DIR', $wgUploadDirectory.'/'); + $default_temp = "/tmp"; } +if( getenv( 'TMP' ) == "" ) { + if( is_writable( $default_temp ) ) { + define('PHPTAL_DEFAULT_CACHE_DIR', $default_temp.DIRECTORY_SEPARATOR); + } else { + global $wgUploadDirectory; + define('PHPTAL_DEFAULT_CACHE_DIR', $wgUploadDirectory.DIRECTORY_SEPARATOR); + } +} else { + define('PHPTAL_DEFAULT_CACHE_DIR', getenv("TMP") . DIRECTORY_SEPARATOR); +} + +if( !is_writable (PHPTAL_DEFAULT_CACHE_DIR) ) + die( htmlspecialchars( + 'Can\'t find a writable temp directory for the XHTML template. ' . + 'Check that the TMP environment variable points to a writable directory, ' . + 'or that the default temp dir (' . $default_temp . ') exists and is writable.' ) ); /** * This define is used to select the templates output format. -- 2.20.1