File "create.php"

Full Path: /home/analogde/www/filetypes/folder/create.php
File size: 4.15 KB
MIME-type: text/x-php
Charset: utf-8

<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2003-2004 Tobias Bender (tobias@phpXplorer.org)
*  All rights reserved
*
*  This script is part of the phpXplorer project. The phpXplorer project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*  A copy is found in the textfile GPL.txt distributed with these scripts.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

require(dirname(dirname(__FILE__)) . "/defaultActionHead.php");

$fileName = getRequestVar("fileName");
$submitAction = getRequestVar("submitAction");

if(!(strpos($fileName, "..") === FALSE))
	die($PXP_languages[$PXP_language]['accessDenied'] . " (804)");


$pInfo = checkFilePermissions($fileName, false);
if(!$pInfo["allowOpen"] or !$pInfo["allowEdit"])
	die($PXP_languages[$PXP_language]["accessDenied"] . " (809)");

if($submitAction != "")
	$result = @mkdir($currentDir . "/" . $fileName, 0777);

?>
<html>
<head>
<title>
<?php echo $PXP_languages[$PXP_language]['createFolder'] ?>
</title>
<style type="text/css">
<!--

-->
</style>
<link rel="stylesheet" type="text/css" href="<?php echo $PXP_url ?>/styles/<?php echo $PXP_style ?>/main.css"/>
<script language="JavaScript" type="text/javascript">
<!--

function validate(){
	var f = document.frm1
	if(!f.fileName.value != ""){
		alert("<?php echo $PXP_languages[$PXP_language]['pleaseInsertValue'] ?>")
		f.fileName.focus()
		return false
	}
	
	return true
}

function send(a, overwrite){

	if(!validate())
		return false
		
	switchButton()

	var f = document.frm1
	f.submitAction.value = a
	
	if(overwrite)
		f.submitOverwrite.value = "overwriteConfirm"

	f.submit()
}

function switchButton(){
	var f = document.frm1
	
	f.btnCreate.disabled = !f.btnCreate.disabled
	f.btnCreateAndExit.disabled = !f.btnCreateAndExit.disabled
	f.btnCancel.disabled = !f.btnCancel.disabled
}

function init(){
	<?php
		if($submitAction != "" and $result == FALSE){
			echo 'alert("' . $PXP_languages[$PXP_language]['canNotCreateFolder'] . '");';
		}else{
	  	switch($submitAction){
	  		case "create":
					echo "opener.parent.frames['phpXplorerTree'].addNode('/" . str_replace("/", "|", str_replace($PXP_basedir, "", $currentDir)) ."', ['$fileName', ['',,'closed_folder']], false)\r\n";
					echo "opener.refreshDir()\r\n";
	  		break;
	  		case "createAndExit":
					echo "opener.parent.frames['phpXplorerTree'].addNode('/" . str_replace("/", "|", str_replace($PXP_basedir, "", $currentDir)) ."', ['$fileName', ['',,'closed_folder']], false)\r\n";
	  			echo "opener.refreshDir()\r\n";
					echo "window.close()\r\n";
	  		break;
	  	}
		}
		echo "document.frm1.fileName.focus()"
	?>//javascript
}
//-->
</script>
</head>
<body onLoad="init()">
<form name="frm1" action="./create.php" method="post">
<input type="hidden" name="currentDir" value="<?php echo $currentDir ?>">
<input type="hidden" name="shareId" value="<?php echo $shareId ?>">
<input type="hidden" name="submitAction" value="<?php echo $submitAction ?>">

<?php echo $PXP_languages[$PXP_language]['createFolder'] ?>
<br><br>
<table>
<tr>
  <td><?php echo $PXP_languages[$PXP_language]['name'] ?>&nbsp;</td><td><input type="text" name="fileName" size="30"></td>
</tr>
</table>
<br>
<input type="button" name="btnCreate" onClick="send('create')" value="<?php echo $PXP_languages[$PXP_language]['create'] ?>">
<input type="button" name="btnCreateAndExit" onClick="send('createAndExit')" value="<?php echo $PXP_languages[$PXP_language]['createAndExit'] ?>">
<input type="button" name="btnCancel" onClick="window.close()" value="<?php echo $PXP_languages[$PXP_language]['cancel'] ?>">

</form>
</body>
</html>