<script language="JavaScript1.2" type="text/javascript">
tb = parent.AfianHandler['allTabs']['<?echo $_GET['totabid'];?>'];
<?
/* check user permission*/
if ($permissions['readonly']) {
	iframeAlert($lang->get("You are not alowed to copy shared files or folders."));
	echo "parent.MyFilesEndAction(tb);</script>";
	exit();
}


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

$list = new iconlist($_GET['totabid']);


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

if (!isCleanPath($tofolder)) {
	iframeAlert($lang->get("Ilegal path: ").$tofolder);
	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();
	}
}


$copyiedFolders = 0;
$copyiedItems = 0;

?>
if (tb != undefined) {
tb.destroyItems();
}
<?

foreach ($items as $filename) {

if ($permissions['unlimitedSpace'] || $quota->canAddToSpace()) {
	/* space available for this object */
	$shareInfo = $share->getInfo($uid."::".$fromfolder);
	$from_path = gluePath($shareInfo['path'],$filename);
	$shareName = $shareInfo['sharename'];
	$to_path =  gluePath($permissions['path'], $tofolder, $filename);
	//iframeJSdebug($sys);
		if ($fm->copy($from_path, $to_path)) {
		$copyiedItems++;
		$lastItem = $filename;
		$comments->copy($from_path, $to_path);
		$log->act("0", "copy", "Shared file, FROM \"".$from_path."\" TO \"".$to_path."\"");
		$quota->recalcUsedSpace();

		$data['name'] = $filename;
		$data['lcname'] = strtolower($filename);
		$data['mdate'] = filemtime($to_path);
		if (is_dir($to_path)) {
			$copyiedFolders++;
			$data['isdir'] = true;
			$data['size'] = $fm->getDirSize($to_path);
			$data['ext'] = "";
			$data['filetypedescription'] = $lang->get("Folder");
		
			$data['icon_img'] = "images/icons/filetypes/big/folder.gif";
			$data['thumb_img'] = "images/icons/filetypes/big/folder.gif";
			$data['list_img'] = "images/icons/filetypes/small/folder.gif";
			$data['filetype'] = "folder";
			$data['ondblclick'] = "loadPath(".$_GET['setindex'].", '".gluePath($sys['path'],$file)."')";
		} else {
			$data['isdir'] = false;
			$data['size'] = filesize($to_path);
			$extension = $fm->getExtension($filename);
			$data['ext'] = $extension;
			if (strtolower($data['ext']) == "zip") {
				$data['iszip'] = true;
			} else {
				$data['iszip'] = false;
			}
			$fileinfo = $fm->fileTypeInfo($extension);
			$data['filetypedescription'] = $fileinfo['description'];
			$data['icon_img'] = gluePath("images/icons/filetypes/big/",$fileinfo['icon']);
			$iconfolder = "images/icons/filetypes/big/";
			$data['thumb_img'] =  $img->icon($to_path, 1, 1, $tofolder);
			$data['bigthumb'] = ((strstr($data['thumb_img'], '?'))?true:false);
			$data['list_img'] = gluePath("images/icons/filetypes/small/",$fileinfo['icon']);
			$data['filetype'] = $img_prefix.$fileinfo['type'];
			$data['ondblclick'] = "get('".$str->safeJS($data['name'])."')";
			if ($fileinfo['type'] == "txt") {
				$data['txt'] = true;
			} else {
				$data['txt'] = false;
			}
		}
		$list->drawIcon($data);
			
			
			
		} else {
		if (!file_exists($from_path)) {
			$iframeAlertMsg[] = $lang->get("Copy failed: shared item '%1' not available.", array(gluePath($fromfolder, $filename)));
		} else if (file_exists($to_path)) {
			$iframeAlertMsg[] = $lang->get("Copy failed: '%1' already exists.", array(gluePath($tofolder, $filename)));
		}
			$log->act("1", "copy", "Shared folder, from \"".$from_path."\" to \"".$to_path."\" (".$fm->errorMsg.")");
		}
	} else {
		$iframeAlertMsg[] = $lang->get("Copy failed: not enought space available.");
	}
}
?>

<?
if ($copyiedItems > 0) {
?>
parent.AfianBubbleMessage('<?$lang->display("Object(s) copied.");?>');
<?}?>

<?if ($copyiedFolders > 0) {?>
parent.reloadTreeByPath('<?echo $str->safeJS($tofolder);?>');
<?}?>


parent.MyFilesEndAction(tb);
if (tb != undefined) {
	tb.buildItems();
	if (tb.active) {
		tb.showItems();
		tb.focusItem('<?echo $str->safeJS($lastItem);?>');
	}
}

<?iframeAlert($iframeAlertMsg);?>
</script>