|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
/**
|
|
Chris PeBenito |
696b41 |
* Smarty plugin
|
|
Chris PeBenito |
696b41 |
* @package Smarty
|
|
Chris PeBenito |
696b41 |
* @subpackage plugins
|
|
Chris PeBenito |
696b41 |
*/
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
/**
|
|
Chris PeBenito |
696b41 |
* delete an automagically created file by name and id
|
|
Chris PeBenito |
696b41 |
*
|
|
Chris PeBenito |
696b41 |
* @param string $auto_base
|
|
Chris PeBenito |
696b41 |
* @param string $auto_source
|
|
Chris PeBenito |
696b41 |
* @param string $auto_id
|
|
Chris PeBenito |
696b41 |
* @param integer $exp_time
|
|
Chris PeBenito |
696b41 |
* @return boolean
|
|
Chris PeBenito |
696b41 |
*/
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
// $auto_base, $auto_source = null, $auto_id = null, $exp_time = null
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
function smarty_core_rm_auto($params, &$smarty)
|
|
Chris PeBenito |
696b41 |
{
|
|
Chris PeBenito |
696b41 |
if (!@is_dir($params['auto_base']))
|
|
Chris PeBenito |
696b41 |
return false;
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
if(!isset($params['auto_id']) && !isset($params['auto_source'])) {
|
|
Chris PeBenito |
696b41 |
$_params = array(
|
|
Chris PeBenito |
696b41 |
'dirname' => $params['auto_base'],
|
|
Chris PeBenito |
696b41 |
'level' => 0,
|
|
Chris PeBenito |
696b41 |
'exp_time' => $params['exp_time']
|
|
Chris PeBenito |
696b41 |
);
|
|
Chris PeBenito |
696b41 |
require_once(SMARTY_CORE_DIR . 'core.rmdir.php');
|
|
Chris PeBenito |
696b41 |
$_res = smarty_core_rmdir($_params, $smarty);
|
|
Chris PeBenito |
696b41 |
} else {
|
|
Chris PeBenito |
696b41 |
$_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']);
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
if(isset($params['auto_source'])) {
|
|
Chris PeBenito |
696b41 |
if (isset($params['extensions'])) {
|
|
Chris PeBenito |
696b41 |
$_res = false;
|
|
Chris PeBenito |
696b41 |
foreach ((array)$params['extensions'] as $_extension)
|
|
Chris PeBenito |
696b41 |
$_res |= $smarty->_unlink($_tname.$_extension, $params['exp_time']);
|
|
Chris PeBenito |
696b41 |
} else {
|
|
Chris PeBenito |
696b41 |
$_res = $smarty->_unlink($_tname, $params['exp_time']);
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
} elseif ($smarty->use_sub_dirs) {
|
|
Chris PeBenito |
696b41 |
$_params = array(
|
|
Chris PeBenito |
696b41 |
'dirname' => $_tname,
|
|
Chris PeBenito |
696b41 |
'level' => 1,
|
|
Chris PeBenito |
696b41 |
'exp_time' => $params['exp_time']
|
|
Chris PeBenito |
696b41 |
);
|
|
Chris PeBenito |
696b41 |
require_once(SMARTY_CORE_DIR . 'core.rmdir.php');
|
|
Chris PeBenito |
696b41 |
$_res = smarty_core_rmdir($_params, $smarty);
|
|
Chris PeBenito |
696b41 |
} else {
|
|
Chris PeBenito |
696b41 |
// remove matching file names
|
|
Chris PeBenito |
696b41 |
$_handle = opendir($params['auto_base']);
|
|
Chris PeBenito |
696b41 |
$_res = true;
|
|
Chris PeBenito |
696b41 |
while (false !== ($_filename = readdir($_handle))) {
|
|
Chris PeBenito |
696b41 |
if($_filename == '.' || $_filename == '..') {
|
|
Chris PeBenito |
696b41 |
continue;
|
|
Chris PeBenito |
696b41 |
} elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) {
|
|
Chris PeBenito |
696b41 |
$_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']);
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
return $_res;
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
/* vim: set expandtab: */
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
?>
|