<script language="JavaScript1.2" type="text/javascript">
tb = parent.AfianHandler['allTabs']['<?echo 
$_GET['fromtabid'];?>'];
<?
/* check user permission*/
if ($permissions['readonly']) {
	iframeAlert($lang->get($lang->get("You are not allowed to perform this action.")));
	echo "parent.MyFilesEndAction(tb);</script>";
	exit();
}

/* no item selected */
if ($_POST['itemlist'] == "") {
	iframeAlert($lang->get("Empty file list."));
	echo "parent.MyFilesEndAction(tb);</script>";
	exit();
}

$fromfolder	= $str->fromHTML($_GET['fromfolder']);

if (!isCleanPath($fromfolder)) {
	iframeAlert($lang->get("Ilegal path: ").$fromfolder);
	echo "parent.MyFilesEndAction(tb);</script>";
	exit();
}

/* checking input */
$split = explode("|", $str->fromHTML($_POST['itemlist']));
for ($i = 0 ; $i < sizeof($split) ; $i++) {
	if ($split[$i] != "") {
		$items[] = $split[$i];
	}
}

foreach ($items as $item) {
	if (!isCleanFilename($item)) {
	iframeAlert($lang->get("Ilegal filename: ").$item);
	echo "parent.MyFilesEndAction(tb);</script>";
	exit();
	}
}


/* do action */
$removedFolders = 0;
$removedObjects = 0;

foreach ($items as $filename) {
	$relativePath = gluePath($fromfolder, $filename);
	$fullPath = gluePath($permissions['path'], $relativePath);
	
	if (file_exists($fullPath)) {
		$isdir = is_dir($fullPath);
		if ($trash->add2trash($relativePath)) {
			$removedObjects++;
			?>
			/*remove deleted item from tab*/
			if (tb != undefined) {
			tb.removeItem('<?echo $str->safeJS($filename);?>');
			}
			<?
			if ($isdir) {
				$removedFolders++;
				?>
				/* close folder if opened in a tab */
				parent.closeTabByPath('<?echo $str->safeJS($relativePath);?>');
				<?
			}
		} else {
			$iframeAlertMsg[] = $lang->get("Failed to move '%1' to trash.", array($relativePath));
		}
	} else {
		$iframeAlertMsg[] = $lang->get("Delete failed: '%1' not available.", array($relativePath));
	}
}

if ($removedFolders > 0) {
?>
parent.reloadTreeByPath('<?echo $str->safeJS($fromfolder);?>');
<?
}
?>
<?
if ($removedObjects > 0) {
?>
parent.AfianBubbleMessage('<?$lang->display("Object(s) deleted.");?>');
<?}?>

parent.MyFilesEndAction(tb);
<?iframeAlert($iframeAlertMsg);?>
</script>