3 if (!function_exists('sys_get_temp_dir')) {
4 // Based on http://www.phpit.net/article/creating-zip-tar-archives-dynamically-php/2/
5 // If the builtin PHP sys_get_temp_dir doesn't exist, we replace it with one that will
6 // try to guess from the environment. Since sys_get_temp_dir() doesn't return a trailing
7 // slash on all system (see comment at http://us.php.net/sys_get_temp_dir), we don't
8 // append a trailing slash, and expect callers to append one when needed.
9 function sys_get_temp_dir()
11 // Try to get from environment variable
12 if (!empty($_ENV['TMP']))
13 return realpath($_ENV['TMP']);
14 if (!empty($_ENV['TMPDIR']))
15 return realpath($_ENV['TMPDIR']);
16 if (!empty($_ENV['TEMP']))
17 return realpath( $_ENV['TEMP']);
22 if (!function_exists('file_put_contents')) {
23 function file_put_contents($filename, $data)
25 $handle = fopen($filename, "w");
28 $bytesWritten = fwrite($handle, $data);