Fixing multiple & path issies in delete function

Establish a fullPath to begin with and use that
Only show relative path in message re not being able to delete
This commit is contained in:
Matt Pass
2013-01-13 16:10:19 +00:00
parent 2ee777739f
commit 497efaabf0

View File

@@ -138,15 +138,20 @@ if ($_GET['action']=="perms") {
if ($_GET['action']=="delete") {
$filesArray = explode(";",$file); // May contain more than one file here
for ($i=0;$i<=count($filesArray)-1;$i++) {
if (!$demoMode && is_writable($iceRoot.$filesArray[$i])) {
is_dir($iceRoot.$filesArray[$i])
? rrmdir($iceRoot.$filesArray[$i])
: unlink($iceRoot.$filesArray[$i]);
$fullPath = str_replace($docRoot,"",$filesArray[$i]);
$fullPath = str_replace($iceRoot,"",$fullPath);
$fullPath = $docRoot.$iceRoot.$fullPath;
if (!$demoMode && is_writable($fullPath)) {
is_dir($fullPath)
? rrmdir($fullPath)
: unlink($fullPath);
$fileName = basename($fullPath);
$fileLoc = dirname(str_replace($docRoot,"",$fullPath));
// Reload file manager
echo '<script>top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'delete\',\''.$fileLoc.'\',\''.$fileName.'\');';
echo 'action="delete";</script>';
} else {
echo "<script>top.ICEcoder.message('Sorry can\\'t delete\\n".$filesArray[$i]."');</script>";
echo "<script>top.ICEcoder.message('Sorry can\\'t delete\\n".str_replace($docRoot,"",$fullPath)."');</script>";
}
echo '<script>action="nothing";</script>';
}