Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
filetypes
:
edit.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?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(__FILE__) . "/defaultActionHead.php"); $fileName = getRequestVar("fileName"); $newName = getRequestVar("newName"); $content = getRequestVar("content"); $submitAction = getRequestVar("submitAction"); $submitOverwrite = getRequestVar("submitOverwrite"); if(!isset($newName)) $newName = $fileName; if(isset($newName)) if(!(strpos($newName, "..") === FALSE)) die($PXP_languages[$PXP_language]['accessDenied'] . " (804)"); if(!(strpos($fileName, "..") === FALSE)) die($PXP_languages[$PXP_language]['accessDenied'] . " (804)"); # checkFilePermission needs to know if folder or not $bDir = is_dir($currentDir . "/" . $fileName); if(isset($newName)){ $pInfoNew = checkFilePermissions($newName, !$bDir); if(!$pInfoNew["allowOpen"] or !$pInfoNew["allowEdit"]) die($PXP_languages[$PXP_language]["accessDenied"] . " (809)"); } $pInfo = checkFilePermissions($fileName, !$bDir); if(!$pInfo["allowOpen"] or !$pInfo["allowEdit"]) die($PXP_languages[$PXP_language]["accessDenied"] . " (809)"); # ensure that all filenames have got an allowed extension if(!$bDir){ if(strpos($fileName, $TP_extensions[$pInfo["extKey"]][0]) === FALSE) $fileName = $fileName . "." . $TP_extensions[$pInfo["extKey"]][0]; if(strpos($newName, ".") === FALSE) $newName = $newName . "." . $TP_extensions[$pInfo["extKey"]][0]; } if($submitAction != ""){ $n = $currentDir . "/" . $fileName; $nn = $currentDir . "/" . $newName; if($TP_isBinary[$pInfo["extKey"]]){ if($n != $nn){ if(file_exists($nn)){ if($submitOverwrite == ""){ $submitOverwrite = "overwrite"; }else{ if($submitOverwrite == "overwriteConfirm"){ pxp_unlink($nn); rename($n, $nn); $fileName = $newName; } } }else{ rename($n, $nn); $fileName = $newName; } } }else{ $bCreateFile = false; if($n != $nn){ if(file_exists($nn)){ if($submitOverwrite == ""){ $submitOverwrite = "overwrite"; }else{ if($submitOverwrite == "overwriteConfirm"){ $fileName = $newName; $bCreateFile = true; } } }else{ $fileName = $newName; $bCreateFile = true; } }else{ $bCreateFile = true; } if($bCreateFile){ $handle = fopen($currentDir . "/" . $fileName, "w"); fwrite($handle, $content); fclose($handle); } } } ?> <html> <head> <title><?php echo $PXP_languages[$PXP_language]['editProperties'] ?>: <?php echo $newName ?> (<?php echo $PXP_languages[$PXP_language]['filetype.' . $pInfo["extKey"]] ?>)</title> <style type="text/css"> <!-- body{ margin: 1px; padding: 0px; border:0px } --> </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"> <!-- var objectsToResize = new Array() function resize_editor(){ var newHeight var newWidth if(document.all){ newHeight = document.body.offsetHeight - 95 newWidth = document.body.offsetWidth - 100 }else{ newHeight = window.innerHeight - 90 newWidth = window.innerWidth - 100 } if(newHeight < 0) newHeight = 0 for(var o = 0; o < objectsToResize.length; o++){ var obj = objectsToResize[o] obj.style.width = newWidth + "px" if(obj.nodeName.toLowerCase() != "input") obj.style.height = newHeight + "px" } } 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.btnSave.disabled = !f.btnSave.disabled f.btnSaveAndExit.disabled = !f.btnSaveAndExit.disabled f.btnCancel.disabled = !f.btnCancel.disabled } function init(){ if(document.frm1.content) objectsToResize.push(document.frm1.content) objectsToResize.push(document.frm1.newName) document.body.style.overflow = 'hidden' <?php if($submitOverwrite == "overwrite"){ echo "if(confirm('" . $PXP_languages[$PXP_language]["allowOverwrite"] . "?')){\r\n"; echo " send('" . $submitAction . "', true)\r\n"; echo "}else{\r\n"; echo " document.frm1.newName.focus()\r\n"; echo " document.frm1.newName.select()\r\n"; echo "}\r\n"; }else{ switch($submitAction){ case "save": echo "opener.refreshDir()\r\n"; break; case "saveAndExit": echo "opener.refreshDir()\r\n"; echo "window.close()\r\n"; break; } } echo "window.onresize = resize_editor\r\n"; echo "resize_editor()\r\n"; echo "if(document.frm1.content)document.frm1.content.focus()\r\n"; ?> } //--> </script> </head> <body onLoad="init()"> <form name="frm1" action="./edit.php" method="post" onSubmit="return false"> <input type="hidden" name="currentDir" value="<?php echo $currentDir ?>"> <input type="hidden" name="fileName" value="<?php echo $fileName ?>"> <input type="hidden" name="shareId" value="<?php echo $shareId ?>"> <input type="hidden" name="submitAction" value="<?php echo $submitAction ?>"> <input type="hidden" name="submitOverwrite" value="<?php echo $submitOverwrite ?>"> <table border="1" rules="none" cellspacing="0" bordercolor="#EEEEEE" style="width:100%"> <tr><td class="caption"><?php echo $PXP_languages[$PXP_language]['editProperties'] ?></td></tr> <tr><td> <table style="width:100%"> <tr> <td> <?php echo $PXP_languages[$PXP_language]['name'] ?> </td> <td align="right"> <input type="text" name="newName" style="width:100px" value="<?php echo $newName ?>"> </td> </tr> <?php if(!$TP_isBinary[$pInfo["extKey"]]){ echo '<tr><td valign="top"> ' . $PXP_languages[$PXP_language]['content'] . ' </td><td align="right">'; echo ' <textarea style="width:100;height:100px" name="content" wrap="off" id="content">'; if(!isset($content)){ $arr = file($currentDir . "/" . $fileName); echo htmlspecialchars(implode("", $arr)); }else{ echo $content; } echo '</textarea> </td></tr>'; } ?> <tr> <td></td> <td align="right"> <input type="button" name="btnSave" onClick="send('save')" value="<?php echo $PXP_languages[$PXP_language]['save'] ?>"> <input type="button" name="btnSaveAndExit" onClick="send('saveAndExit')" value="<?php echo $PXP_languages[$PXP_language]['saveAndExit'] ?>"> <input type="button" name="btnCancel" onClick="window.close()" value="<?php echo $PXP_languages[$PXP_language]['cancel'] ?>"> </td> </tr> </table></td></tr></table></form></body></html>