9 * delete an automagically created file by name and id
11 * @param string $auto_base
12 * @param string $auto_source
13 * @param string $auto_id
14 * @param integer $exp_time
18 // $auto_base, $auto_source = null, $auto_id = null, $exp_time = null
20 function smarty_core_rm_auto($params, &$smarty)
22 if (!@is_dir
($params['auto_base']))
25 if(!isset($params['auto_id']) && !isset($params['auto_source'])) {
27 'dirname' => $params['auto_base'],
29 'exp_time' => $params['exp_time']
31 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.rmdir.php');
32 $_res = smarty_core_rmdir($_params, $smarty);
34 $_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']);
36 if(isset($params['auto_source'])) {
37 if (isset($params['extensions'])) {
39 foreach ((array)$params['extensions'] as $_extension)
40 $_res |
= $smarty->_unlink($_tname.$_extension, $params['exp_time']);
42 $_res = $smarty->_unlink($_tname, $params['exp_time']);
44 } elseif ($smarty->use_sub_dirs
) {
48 'exp_time' => $params['exp_time']
50 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.rmdir.php');
51 $_res = smarty_core_rmdir($_params, $smarty);
53 // remove matching file names
54 $_handle = opendir($params['auto_base']);
56 while (false !== ($_filename = readdir($_handle))) {
57 if($_filename == '.' ||
$_filename == '..') {
59 } elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR
. $_filename, 0, strlen($_tname)) == $_tname) {
60 $_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR
. $_filename, $params['exp_time']);
69 /* vim: set expandtab: */