Index: trunk/phase3/PHPTAL-NP-0.7.0/libs/PHPTAL.php |
— | — | @@ -67,12 +67,27 @@ |
68 | 68 | define('PHPTAL_MARK', str_replace('.', '_', PHPTAL_VERSION) . '_'); |
69 | 69 | |
70 | 70 | if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") { |
71 | | - define('PHPTAL_DEFAULT_CACHE_DIR', getenv("TMP") . "\\"); |
| 71 | + $default_temp = "C:\\Windows\\Temp"; |
72 | 72 | } else { |
73 | | - global $wgUploadDirectory; |
74 | | - define('PHPTAL_DEFAULT_CACHE_DIR', $wgUploadDirectory.'/'); |
| 73 | + $default_temp = "/tmp"; |
75 | 74 | } |
| 75 | +if( getenv( 'TMP' ) == "" ) { |
| 76 | + if( is_writable( $default_temp ) ) { |
| 77 | + define('PHPTAL_DEFAULT_CACHE_DIR', $default_temp.DIRECTORY_SEPARATOR); |
| 78 | + } else { |
| 79 | + global $wgUploadDirectory; |
| 80 | + define('PHPTAL_DEFAULT_CACHE_DIR', $wgUploadDirectory.DIRECTORY_SEPARATOR); |
| 81 | + } |
| 82 | +} else { |
| 83 | + define('PHPTAL_DEFAULT_CACHE_DIR', getenv("TMP") . DIRECTORY_SEPARATOR); |
| 84 | +} |
76 | 85 | |
| 86 | +if( !is_writable (PHPTAL_DEFAULT_CACHE_DIR) ) |
| 87 | + die( htmlspecialchars( |
| 88 | + 'Can\'t find a writable temp directory for the XHTML template. ' . |
| 89 | + 'Check that the TMP environment variable points to a writable directory, ' . |
| 90 | + 'or that the default temp dir (' . $default_temp . ') exists and is writable.' ) ); |
| 91 | + |
77 | 92 | /** |
78 | 93 | * This define is used to select the templates output format. |
79 | 94 | * |