added opendir() error handling
This commit is contained in:
@ -51,14 +51,17 @@ function smarty_core_rm_auto($params, &$smarty)
|
|||||||
$_res = smarty_core_rmdir($_params, $smarty);
|
$_res = smarty_core_rmdir($_params, $smarty);
|
||||||
} else {
|
} else {
|
||||||
// remove matching file names
|
// remove matching file names
|
||||||
$_handle = opendir($params['auto_base']);
|
$_res = false;
|
||||||
$_res = true;
|
if ($_handle = opendir($params['auto_base']))
|
||||||
while (false !== ($_filename = readdir($_handle))) {
|
{
|
||||||
if($_filename == '.' || $_filename == '..') {
|
$_res = true;
|
||||||
continue;
|
while (false !== ($_filename = readdir($_handle))) {
|
||||||
} elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) {
|
if($_filename == '.' || $_filename == '..') {
|
||||||
$_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']);
|
continue;
|
||||||
}
|
} elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) {
|
||||||
|
$_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,19 +164,21 @@ if (substr($folder,-1) != '/')
|
|||||||
}
|
}
|
||||||
|
|
||||||
$fileList = array();
|
$fileList = array();
|
||||||
$handle = opendir($folder);
|
if ($handle = opendir($folder))
|
||||||
while (false !== ($file = readdir($handle)))
|
|
||||||
{
|
{
|
||||||
if (is_file($file))
|
while (false !== ($file = readdir($handle)))
|
||||||
{
|
{
|
||||||
$file_info = pathinfo($file);
|
if (is_file($file))
|
||||||
if (isset($extList[strtolower($file_info['extension'])]))
|
|
||||||
{
|
{
|
||||||
$fileList[] = $file;
|
$file_info = pathinfo($file);
|
||||||
|
if (isset($extList[strtolower($file_info['extension'])]))
|
||||||
|
{
|
||||||
|
$fileList[] = $file;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
closedir($handle);
|
||||||
}
|
}
|
||||||
closedir($handle);
|
|
||||||
|
|
||||||
if (count($fileList) > 0)
|
if (count($fileList) > 0)
|
||||||
{
|
{
|
||||||
|
@ -1093,7 +1093,7 @@ function unlinkrecursiv($path)
|
|||||||
$notunlinked = 0;
|
$notunlinked = 0;
|
||||||
|
|
||||||
$hDir = opendir($path);
|
$hDir = opendir($path);
|
||||||
if ($hDir === FALSE)
|
if ($hDir === false)
|
||||||
++$notunlinked;
|
++$notunlinked;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user