<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 allowed to perform this action."));
	echo "parent.MyFilesEndAction(tb);</script>";
	exit();
}

$folderName = $str->fromHTML($_POST['dirName']);

if (!isCleanFilename($folderName)) {
	iframeAlert($lang->get('Ilegal folder name: ').$folderName);
	echo "parent.MyFilesEndAction(tb);</script>";
	exit();
}


/* check folder */
if (!is_dir(gluePath($permissions['path'], $sys['path']))) {
	iframeAlert($lang->get("The folder where you want to create the new folder does not exist any more."));
	echo "parent.MyFilesEndAction(tb);</script>";
	exit();
}

if (strlen($sys['path']) == 0) {
	$sys['path'] = "/";
}

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

$path = gluePath($permissions['path'], $sys['path'], $folderName);


if (file_exists($path)) {
	iframeAlert($lang->get("New folder: '%1' already exists", array(gluePath($sys['path'],$folderName))));
	echo "parent.MyFilesEndAction(tb);</script>";
	exit();
}

	$res = @mkdir($path, 0777);
	if ($res) {
	?>
	if (tb != undefined) {
	tb.destroyItems();
	}
	<?
		$log->act("0", "new folder creation", $path);
		$msg = $lang->get("Folder \"%1\" created.", array($folderName));
		$statusBarMessage[] = array($msg, 0);
		/* insert created folder in list */
		$data['name'] = $folderName;
		$data['lcname'] = strtolower($data['name']);
		$data['mdate'] = filemtime($path);
		$data['isdir'] = true;
		$data['size'] = 0;
		$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'] = "cd('".$str->safeJS(gluePath($sys['path'], $data['name']))."')";
		$data['extra'] = "&nbsp;";
		$list->drawIcon($data);
		?>
parent.AfianBubbleMessage('<?$lang->display("Folder created.");?>');
		
parent.MyFilesEndAction(tb);
if (tb != undefined) {
	tb.buildItems();
	if (tb.active) {
		tb.showItems();
		tb.focusItem('<?echo $str->safeJS($folderName);?>');
	}
}
parent.reloadTreeByPath('<?echo $str->safeJS($sys['path']);?>');
		<?
	} else {
		$iframeAlertMsg[] = $lang->get("Unable to create folder '%1'.", array($str->safeJS($folderName)));
		$log->act("1", "new folder creation", $path);
		?>
		parent.MyFilesEndAction(tb);
		<?
	}
?>

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