summaryrefslogtreecommitdiff
path: root/extlib/get_temp_dir.php
blob: 4ec96e5221668f2a4d8d31303cd16336db624809 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
if ( !function_exists('sys_get_temp_dir')) {
	function sys_get_temp_dir() {
		if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); }
		if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); }
		if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); }
		$tempfile=tempnam(uniqid(rand(),TRUE),'');
		if (file_exists($tempfile)) {
			unlink($tempfile);
		}
		return realpath(dirname($tempfile));
	}
}
?>