/** * Removes given elements at request shutdown. * * If called with a filename will delete that file at request shutdown; if * called with a directory will remove that directory and all files in that * directory at request shutdown. * * If called with no arguments, return all elements to be deleted (this * should only be done by Horde_Util::_deleteAtShutdown()). * * The first time it is called, it initializes the array and registers * Horde_Util::_deleteAtShutdown() as a shutdown function - no need to do * so manually. * * The second parameter allows the unregistering of previously registered * elements. * * @param string $filename The filename to be deleted at the end of the * request. * @param boolean $register If true, then register the element for * deletion, otherwise, unregister it. * @param boolean $secure If deleting file, should we securely delete * the file? */ public static function deleteAtShutdown($filename, $register = true, $secure = false) { /* Initialization of variables and shutdown functions. */ if (!self::$_shutdownreg) { register_shutdown_function(array(__CLASS__, 'shutdown')); self::$_shutdownreg = true; } $ptr =& self::$_shutdowndata; if ($register) { if (@is_dir($filename)) { $ptr['dirs'][$filename] = true; } else { $ptr['files'][$filename] = true; } if ($secure) { $ptr['secure'][$filename] = true; } } else { unset($ptr['dirs'][$filename], $ptr['files'][$filename], $ptr['secure'][$filename]); } }