File "edit.php"
Full Path: /home/analogde/www/filetypes/pxsf/edit.php
File size: 12.32 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!
***************************************************************/
$acronym = basename(dirname(__FILE__));
require(dirname(__FILE__) . "/../defaultActionHead.php");
$fileName = getRequestVar("fileName");
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)");
# write permission files for each share
if(isset($HTTP_POST_VARS["shares"])){
$rowActions = explode("<|>", $HTTP_POST_VARS["rowActions"]);
$shares = explode("<|>", $HTTP_POST_VARS["shares"]);
$basedir = explode("<|>", $HTTP_POST_VARS["basedir"]);
$share_users = explode("<|>", $HTTP_POST_VARS["share_users"]);
$share_roles = explode("<|>", $HTTP_POST_VARS["share_roles"]);
$rights_dir = explode("<|>", $HTTP_POST_VARS["rights_dir"]);
$startpage = explode("<|>", $HTTP_POST_VARS["startpage"]);
$tree_reload = explode("<|>", $HTTP_POST_VARS["tree_reload"]);
$enc_key = explode("<|>", $HTTP_POST_VARS["enc_key"]);
$create_htaccess = explode("<|>", $HTTP_POST_VARS["create_htaccess"]);
$pxsf = $currentDir . "/shares.pxsf";
if(is_dir($pxsf)){
$d = dir($pxsf);
while($file = $d->read())
if($file != "." AND $file != "..")
if(is_dir($pxsf . "/" . $file))
rmdirRecursive($pxsf . "/" . $file);
$strDefaultRightFile = implode("", file(dirname(__FILE__) . "/../pxs/default.php"));
foreach($shares as $index => $share){
if($rowActions[$index] == "d")
continue;
mkdir($currentDir . "/shares.pxsf/" . $share, 0755);
copy($currentDir . "/shares.pxsf/default_index.php", $currentDir . "/shares.pxsf/" . $share . "/index.php");
$strNewFile = $strDefaultRightFile;
$strNewFile = str_replace("{@pxsId}", $shares[$index], $strNewFile);
if($share == "system")
$basedir[$index] = '" . dirname(dirname(dirname(__FILE__))) . "';
$share_users[$index] = ($share_users[$index] != "null" and $share_users[$index] != "") ? '"' . str_replace('|', '", "', $share_users[$index]) . '"' : "";
$share_roles[$index] = ($share_roles[$index] != "null" and $share_roles[$index] != "") ? '"' . str_replace('|', '", "', $share_roles[$index]) . '"' : "";
$strNewFile = str_replace("{@pxsBasedir}", $basedir[$index], $strNewFile);
$strNewFile = str_replace("{@pxsShareUsers}", $share_users[$index], $strNewFile);
$strNewFile = str_replace("{@pxsShareRoles}", $share_roles[$index], $strNewFile);
$strNewFile = str_replace("{@pxsRightsDir}", $rights_dir[$index], $strNewFile);
$strNewFile = str_replace("{@pxsStartpage}", $startpage[$index], $strNewFile);
$strNewFile = str_replace("{@pxsTreeReload}", $tree_reload[$index] == "true" ? "true" : "false", $strNewFile);
$strNewFile = str_replace("{@pxsKey}", $enc_key[$index], $strNewFile);
$strNewFile = str_replace("{@pxsCreateHtaccess}", $create_htaccess[$index], $strNewFile);
$handle = fopen($currentDir . "/shares.pxsf/" . $share . "/config." . $share . ".pxs.php", "w");
fwrite($handle, $strNewFile);
fclose($handle);
}
}
require(dirname(__FILE__) . "/writeShareHtaccessFiles.php");
die();
}
$caption = $PXP_languages[$PXP_language]['filetype.' . $acronym] . " - " . str_replace($PXP_basedir, "", $currentDir) . "/" . $fileName;
$shares = Array();
$basedir = Array();
$share_users = Array();
$share_roles = Array();
$rights_dir = Array();
$startpage = Array();
$tree_reload = Array();
$enc_key = Array();
$create_htaccess = Array();
$pxsf = $currentDir . "/shares.pxsf";
$d = dir($pxsf);
while($file = $d->read())
if($file != "." and $file != "..")
if(is_dir($pxsf . "/" . $file))
array_push($shares, $file);
# import existing shares
$PXP_onlyReadValues = true;
foreach($shares as $share){
require($currentDir . "/shares.pxsf/" . $share . "/config." . $share . ".pxs.php");
$basedir[$share] = $PXP_basedir;
$share_users[$share] = $PXP_share_users;
$share_roles[$share] = $PXP_share_roles;
$rights_dir[$share] = $PXP_rights_dir;
$startpage[$share] = $PXP_startpage;
$tree_reload[$share] = $PXP_tree_reload ? "true" : "false";
$enc_key[$share] = $PXP_key;
$create_htaccess[$share] = $PXP_create_htaccess;
}
# build strings from arrays
function replaceNull($arr){
foreach($arr as $index => $typeKey)
$arr[$index] = is_null($typeKey) ? "null" : "'" . $arr[$index] . "'";
return sizeof($arr) > 0 ? implode(",", $arr) . ",null" : "null";
}
foreach($share_users as $index => $user){
$share_users[$index] = implode("|", $share_users[$index]);
$share_roles[$index] = implode("|", $share_roles[$index]);
}
$strShares = sizeof($shares) > 0 ? "'" . implode("','", $shares) . "',null" : "null";
$strBasedir = sizeof($shares) > 0 ? "'" . implode("','", $basedir) . "',null" : "null";
$strShare_users = replaceNull($share_users);
$strShare_roles = replaceNull($share_roles);
$strRights_dir = sizeof($shares) > 0 ? "'" . implode("','", $rights_dir) . "',null" : "null";
$strStartpage = sizeof($shares) > 0 ? "'" . implode("','", $startpage) . "',null" : "null";
$strTree_reload = sizeof($shares) > 0 ? implode(",", $tree_reload) . ",null" : "null";
$strEnc_key = sizeof($shares) > 0 ? "'" . implode("','", $enc_key) . "',null" : "null";
$strCreate_htaccess = sizeof($shares) > 0 ? implode(",", $create_htaccess) . ",null" : "null";
?>
<html>
<head><title><?php echo $caption ?></title>
<script src="<?php echo $GC_webGridClient_URL ?>/webGrid.js" type="text/javascript" language="JavaScript"></script>
<script language="JavaScript" type="text/javascript">
//<![CDATA[
httpParameter=new Array()
httpParameter['http_user']=''
wGB32541416dc342461548 = new gridBox("wGB32541416dc342461548")
var b=wGB32541416dc342461548
b.wgURL="<?php echo $GC_webGridClient_URL ?>"
//]]>
</script>
<script src="<?php echo $GC_webGridClient_URL ?>/cache/columnTemplates.js" type="text/javascript" language="JavaScript"></script>
<script src="<?php echo $GC_webGridClient_URL ?>/cache/validations.js" type="text/javascript" language="JavaScript"></script>
<script src="<?php echo $GC_webGridClient_URL ?>/getJSDefinition.php?id=wGB32541416dc342461548" type="text/javascript" language="JavaScript"></script>
<style type="text/css">
/*<![CDATA[*/
body{margin:0px}
/*]]>*/
</style>
<script language="JavaScript" type="text/javascript">
//<![CDATA[
function getRequestString(arr){
var newArr = new Array()
for(var y in arr)
newArr[newArr.length] = arr[y] == null ? "null" : arr[y]
return newArr.join("<|>")
}
function save(){
var f = document.frm1
var arrRA = new Array()
for(var y in pxsfmodell.rows)
arrRA[arrRA.length] = pxsfmodell.gRS(pxsfmodell.rows[y])
f.rowActions.value = arrRA.join("<|>")
f.shares.value = pxsfmodell.aCols['id'].vs.join("<|>");
f.basedir.value = pxsfmodell.aCols['basedir'].vs.join("<|>");
f.share_users.value = getRequestString(pxsfmodell.aCols['share_users'].vs);
f.share_roles.value = getRequestString(pxsfmodell.aCols['share_roles'].vs);
f.rights_dir.value = pxsfmodell.aCols['rights_dir'].vs.join("<|>");
f.startpage.value = pxsfmodell.aCols['startpage'].vs.join("<|>");
f.tree_reload.value = pxsfmodell.aCols['tree_reload'].vs.join("<|>");
f.enc_key.value = pxsfmodell.aCols['enc_key'].vs.join("<|>");
f.create_htaccess.value = pxsfmodell.aCols['create_htaccess'].vs.join("<|>");
f.submit()
}
function init(){
var g = pxsfmodell;
g.rC = <?php echo sizeof($shares) ?>
g.aCols['id'].vs = Array(<?php echo $strShares ?>)
g.aCols['basedir'].vs = Array(<?php echo $strBasedir ?>)
g.aCols['share_users'].vs = Array(<?php echo $strShare_users ?>)
g.aCols['share_users'].options = Array('<?php echo implode("','", $PXP_users) ?>')
g.aCols['share_roles'].vs = Array(<?php echo $strShare_roles ?>)
g.aCols['share_roles'].options = Array('<?php echo implode("','", $PXP_roles) ?>')
g.aCols['rights_dir'].vs = Array(<?php echo $strRights_dir ?>)
g.aCols['startpage'].vs = Array(<?php echo $strStartpage ?>)
g.aCols['tree_reload'].vs = Array(<?php echo $strTree_reload ?>)
g.aCols['enc_key'].vs = Array(<?php echo $strEnc_key ?>)
g.aCols['create_htaccess'].vs = Array(<?php echo $strCreate_htaccess ?>)
g.aCols['create_htaccess'].options = Array("<?php echo $PXP_languages[$PXP_language]['notRestricted'] ?>", "<?php echo $PXP_languages[$PXP_language]['shareUsersAndRoles'] ?>", "<?php echo $PXP_languages[$PXP_language]['phpXplorerOnly'] ?>")
g.aCols['create_htaccess'].values = Array(0, 1, 2)
g.title = "<?php echo $PXP_languages[$PXP_language]['shares'] ?>"
g.aCols['id'].title = "<?php echo $PXP_languages[$PXP_language]['id'] ?>"
g.aCols['basedir'].title = "<?php echo $PXP_languages[$PXP_language]['basedir'] ?>"
g.aCols['share_users'].title = "<?php echo $PXP_languages[$PXP_language]['user'] ?>"
g.aCols['share_roles'].title = "<?php echo $PXP_languages[$PXP_language]['roles'] ?>"
g.aCols['rights_dir'].title = "<?php echo $PXP_languages[$PXP_language]['rightsDir'] ?>"
g.aCols['startpage'].title = "<?php echo $PXP_languages[$PXP_language]['startpage'] ?>"
g.aCols['tree_reload'].title = "<?php echo $PXP_languages[$PXP_language]['treeReload'] ?>"
g.aCols['enc_key'].title = "<?php echo $PXP_languages[$PXP_language]['encKey'] ?>"
g.aCols['create_htaccess'].title = "<?php echo $PXP_languages[$PXP_language]['webserverAccess'] ?>"
b.render(window.frames['wGB32541416dc342461548Content'])
b.resize()
window.setInterval('wGB32541416dc342461548.resize()', 444)
}
//]]>
</script>
</head>
<body onLoad="init()">
<form name="frm1" action="./edit.php" method="post" target="frmSave">
<input type="hidden" name="rowActions" value="">
<input type="hidden" name="shares" value="">
<input type="hidden" name="basedir" value="">
<input type="hidden" name="share_users" value="">
<input type="hidden" name="share_roles" value="">
<input type="hidden" name="rights_dir" value="">
<input type="hidden" name="startpage" value="">
<input type="hidden" name="tree_reload" value="">
<input type="hidden" name="enc_key" value="">
<input type="hidden" name="create_htaccess" value="">
<input type="hidden" name="currentDir" value="<?php echo $currentDir ?>">
<input type="hidden" name="shareId" value="<?php echo $shareId ?>">
<input type="hidden" name="fileName" value="<?php echo $fileName ?>">
<input type="hidden" name="actionType" value="">
<input type="hidden" name="keyGenList" value="">
<table style="background-color:#DDDDDD" cellspacing="0" cellpadding="1" width="100%">
<tr>
<td>
<iframe scrolling="auto" id="wGB32541416dc342461548Content" name="wGB32541416dc342461548Content" width="100%" height="480px" frameborder="0"></iframe>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="height:1px" colspan="4"></td>
</tr>
<tr>
<td height="28">
<input type="button" value="<?php echo $PXP_languages[$PXP_language]['add'] ?>" onClick="wGB32541416dc342461548.addRow()">
</td>
<td height="28">
<input type="button" value="<?php echo $PXP_languages[$PXP_language]['insert'] ?>" onClick="wGB32541416dc342461548.insRow()">
</td>
<td height="28">
<input type="button" value="<?php echo $PXP_languages[$PXP_language]['delete'] ?>" onClick="wGB32541416dc342461548.delRow()">
</td>
<td height="28">
<input type="button" value="<?php echo $PXP_languages[$PXP_language]['save'] ?>" onClick="save()">
</td>
<td height="28">
<input type="button" value="<?php echo $PXP_languages[$PXP_language]['cancel'] ?>" onClick="window.close()">
</td>
</tr>
</table>
</td>
</tr>
</table>
<iframe name="frmSave" style="display:none"></iframe>
</form>
</body>
</html>