1e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block<?php 2e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block 3e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Blockif (!function_exists('sys_get_temp_dir')) { 4e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block // Based on http://www.phpit.net/article/creating-zip-tar-archives-dynamically-php/2/ 5e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block // If the builtin PHP sys_get_temp_dir doesn't exist, we replace it with one that will 6e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block // try to guess from the environment. Since sys_get_temp_dir() doesn't return a trailing 7e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block // slash on all system (see comment at http://us.php.net/sys_get_temp_dir), we don't 8e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block // append a trailing slash, and expect callers to append one when needed. 9e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block function sys_get_temp_dir() 10e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block { 11e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block // Try to get from environment variable 12e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block if (!empty($_ENV['TMP'])) 13e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block return realpath($_ENV['TMP']); 14e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block if (!empty($_ENV['TMPDIR'])) 15e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block return realpath($_ENV['TMPDIR']); 16e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block if (!empty($_ENV['TEMP'])) 17e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block return realpath( $_ENV['TEMP']); 18e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block return "/tmp"; 19e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block } 20e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block} 21e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block 22e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Blockif (!function_exists('file_put_contents')) { 23e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block function file_put_contents($filename, $data) 24e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block { 25e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block $handle = fopen($filename, "w"); 26e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block if (!$handle) 27e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block return FALSE; 28e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block $bytesWritten = fwrite($handle, $data); 29e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block if (!fclose($handle)) 30e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block return FALSE; 31e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block return $bytesWritten; 32e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block } 33e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block} 34e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block 35e45c1cdad9627f8b5f50f55c4a9642c1703a616aSteve Block?> 36