1<?php 2 3if (!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() 10 { 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']); 18 return "/tmp"; 19 } 20} 21 22if (!function_exists('file_put_contents')) { 23 function file_put_contents($filename, $data) 24 { 25 $handle = fopen($filename, "w"); 26 if (!$handle) 27 return FALSE; 28 $bytesWritten = fwrite($handle, $data); 29 if (!fclose($handle)) 30 return FALSE; 31 return $bytesWritten; 32 } 33} 34 35?> 36