File "edit.php"
Full Path: /home/analogde/www/filetypes/pxrf/edit.php
File size: 17.83 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 submitted values to rights files
if(isset($HTTP_POST_VARS["members"])){
$rowActionsValues = explode("<|>", $HTTP_POST_VARS["rowActions"]);
$membersValues = explode("<|>", $HTTP_POST_VARS["members"]);
$openByNameInheritValues = explode("<|>", $HTTP_POST_VARS["openByNameInherit"]);
$openByNameValues = explode("<|>", $HTTP_POST_VARS["openByName"]);
$openByTypekeyInheritValues = explode("<|>", $HTTP_POST_VARS["openByTypekeyInherit"]);
$openByTypekeyValues = explode("<|>", $HTTP_POST_VARS["openByTypekey"]);
$openByPathInvertValues = explode("<|>", $HTTP_POST_VARS["openByPathInvert"]);
$openByPathValues = explode("<|>", $HTTP_POST_VARS["openByPath"]);
$editByNameInheritValues = explode("<|>", $HTTP_POST_VARS["editByNameInherit"]);
$editByNameValues = explode("<|>", $HTTP_POST_VARS["editByName"]);
$editByTypekeyInheritValues = explode("<|>", $HTTP_POST_VARS["editByTypekeyInherit"]);
$editByTypekeyValues = explode("<|>", $HTTP_POST_VARS["editByTypekey"]);
$editByPathInvertValues = explode("<|>", $HTTP_POST_VARS["editByPathInvert"]);
$editByPathValues = explode("<|>", $HTTP_POST_VARS["editByPath"]);
# replace WebGrid seperation slash (|) through commas
foreach($membersValues as $index => $member){
$openByNameValues[$index] = $openByNameValues[$index] != "null" ? '"' . str_replace('|', '","', $openByNameValues[$index]) . '"' : "";
$openByTypekeyValues[$index] = $openByTypekeyValues[$index] != "null" ? '"' . str_replace('|', '","', $openByTypekeyValues[$index]) . '"' : "";
$openByPathValues[$index] = $openByPathValues[$index] != "null" ? '"' . str_replace('|', '","', $openByPathValues[$index]) . '"' : "";
$editByNameValues[$index] = $editByNameValues[$index] != "null" ? '"' . str_replace('|', '","', $editByNameValues[$index]) . '"' : "";
$editByTypekeyValues[$index] = $editByTypekeyValues[$index] != "null" ? '"' . str_replace('|', '","', $editByTypekeyValues[$index]) . '"' : "";
$editByPathValues[$index] = $editByPathValues[$index] != "null" ? '"' . str_replace('|', '","', $editByPathValues[$index]) . '"' : "";
}
$pxrf = $currentDir . "/" . $PXP_rights_dir;
if(is_dir($pxrf)){
$d = dir($pxrf);
while($file = $d->read())
if($file != "." AND $file != "..")
if(!is_dir($pxrf . "/" . $file))
if(strpos($file, "pxr") !== false)
pxp_unlink($pxrf . "/" . $file);
$lines = file(dirname(__FILE__) . "/../pxr/default.php");
$strDefaultRightFile = implode("", $lines);
foreach($membersValues as $index => $member){
if($rowActionsValues[$index] == "d")
continue;
$strNewFile = $strDefaultRightFile;
$strNewFile = str_replace("{@pxrRole}", $member, $strNewFile);
$strNewFile = str_replace("{@pxrOpen_byName_inherit}", $openByNameInheritValues[$index], $strNewFile);
$strNewFile = str_replace("{@pxrOpen_byName}", $openByNameValues[$index], $strNewFile);
$strNewFile = str_replace("{@pxrOpen_byTypekey_inherit}", $openByTypekeyInheritValues[$index], $strNewFile);
$strNewFile = str_replace("{@pxrOpen_byTypekey}", $openByTypekeyValues[$index], $strNewFile);
$strNewFile = str_replace("{@pxrOpen_byPath_invert}", $openByPathInvertValues[$index], $strNewFile);
$strNewFile = str_replace("{@pxrOpen_byPath}", $openByPathValues[$index], $strNewFile);
$strNewFile = str_replace("{@pxrEdit_byName_inherit}", $editByNameInheritValues[$index], $strNewFile);
$strNewFile = str_replace("{@pxrEdit_byName}", $editByNameValues[$index], $strNewFile);
$strNewFile = str_replace("{@pxrEdit_byTypekey_inherit}", $editByTypekeyInheritValues[$index], $strNewFile);
$strNewFile = str_replace("{@pxrEdit_byTypekey}", $editByTypekeyValues[$index], $strNewFile);
$strNewFile = str_replace("{@pxrEdit_byPath_invert}", $editByPathInvertValues[$index], $strNewFile);
$strNewFile = str_replace("{@pxrEdit_byPath}", $editByPathValues[$index], $strNewFile);
$handle = fopen($pxrf . "/$member.pxr.php", "w");
fwrite($handle, $strNewFile);
fclose($handle);
}
}
die();
}
$caption = $PXP_languages[$PXP_language]['filetype.' . $acronym] . " - " . str_replace($PXP_basedir, "", $currentDir) . "/" . $fileName;
$arrTypekeyOptions = Array();
$arrTypekeyValues = Array();
foreach($TP_group as $key => $value){
array_push($arrTypekeyOptions, $PXP_languages[$PXP_language]["filetype.$key"]);
array_push($arrTypekeyValues, $key);
}
$arrFolder = Array();
$arrFile = Array();
$d = dir($currentDir);
while($file = $d->read())
if($file != "." AND $file != "..")
if(is_dir($currentDir . "/" . $file)){
array_push($arrFolder, $file);
}else{
array_push($arrFile, $file);
}
asort($arrFolder);
asort($arrFile);
$arrFiles = array_merge($arrFolder, $arrFile);
$memberOptions = array_merge(Array("%"), $PXP_roles, $PXP_users);
$members = Array();
$openByNameInherit = Array();
$openByName = Array();
$openByTypekeyInherit = Array();
$openByTypekey = Array();
$openByPathInvert = Array();
$openByPath = Array();
$editByNameInherit = Array();
$editByName = Array();
$editByTypekeyInherit = Array();
$editByTypekey = Array();
$editByPathInvert = Array();
$editByPath = Array();
$PXP_rightsOpen_byName_inherit = Array();
$PXP_rightsOpen_byName = Array();
$PXP_rightsOpen_byTypekey_inherit = Array();
$PXP_rightsOpen_byTypekey = Array();
$PXP_rightsOpen_byPath_invert = Array();
$PXP_rightsOpen_byPath = Array();
$PXP_rightsEdit_byName_inherit = Array();
$PXP_rightsEdit_byName = Array();
$PXP_rightsEdit_byTypekey_inherit = Array();
$PXP_rightsEdit_byTypekey = Array();
$PXP_rightsEdit_byPath_invert = Array();
$PXP_rightsEdit_byPath = Array();
$pxrf = $currentDir . "/" . $PXP_rights_dir;
if(is_dir($pxrf)){
$d = dir($pxrf);
while($file = $d->read())
if($file != "." AND $file != "..")
if(!is_dir($pxrf . "/" . $file))
if(strpos($file, ".pxr.php") !== false){
require($pxrf . "/" . $file);
$filename = basename($file);
$filename = str_replace(".pxr.php", "", $filename);
array_push($members, $filename);
}
}
foreach($members as $member){
array_push($openByNameInherit, $PXP_rightsOpen_byName_inherit[$member] ? "true" : "false");
array_push($openByName, sizeof($PXP_rightsOpen_byName[$member]) == 0 ? null : implode("|", $PXP_rightsOpen_byName[$member]));
array_push($openByTypekeyInherit, $PXP_rightsOpen_byTypekey_inherit[$member] ? "true" : "false");
array_push($openByTypekey, sizeof($PXP_rightsOpen_byTypekey[$member]) == 0 ? null : implode("|", $PXP_rightsOpen_byTypekey[$member]));
array_push($openByPathInvert, $PXP_rightsOpen_byPath_invert[$member] ? "true" : "false");
array_push($openByPath, sizeof($PXP_rightsOpen_byPath[$member]) == 0 ? null : implode("|", $PXP_rightsOpen_byPath[$member]));
array_push($editByNameInherit, $PXP_rightsEdit_byName_inherit[$member] ? "true" : "false");
array_push($editByName, sizeof($PXP_rightsEdit_byName[$member]) == 0 ? null : implode("|", $PXP_rightsEdit_byName[$member]));
array_push($editByTypekeyInherit, $PXP_rightsEdit_byTypekey_inherit[$member] ? "true" : "false");
array_push($editByTypekey, sizeof($PXP_rightsEdit_byTypekey[$member]) == 0 ? null : implode("|", $PXP_rightsEdit_byTypekey[$member]));
array_push($editByPathInvert, $PXP_rightsEdit_byPath_invert[$member] ? "true" : "false");
array_push($editByPath, sizeof($PXP_rightsEdit_byPath[$member]) == 0 ? null : implode("|", $PXP_rightsEdit_byPath[$member]));
}
function replaceNull($arr){
foreach($arr as $index => $typeKey)
$arr[$index] = is_null($typeKey) ? "null" : "'" . $arr[$index] . "'";
return sizeof($arr) > 0 ? implode(",", $arr) . ",null" : "null";
}
$strMembers = sizeof($members) > 0 ? "'" . implode("','", $members) . "',null" : "null";
$strOpenByNameInherit = sizeof($openByNameInherit) > 0 ? implode(",", $openByNameInherit) . ",null" : "null";
$strOpenByName = replaceNull($openByName);
$strOpenByTypekeyInherit = sizeof($openByTypekeyInherit) > 0 ? implode(",", $openByTypekeyInherit) . ",null" : "null";
$strOpenByTypekey = replaceNull($openByTypekey);
$strOpenByPathInvert = sizeof($openByPathInvert) > 0 ? implode(",", $openByPathInvert) . ",null" : "null";
$strOpenByPath = replaceNull($openByPath);
$strEditByNameInherit = sizeof($editByNameInherit) > 0 ? implode(",", $editByNameInherit) . ",null" : "null";
$strEditByName = replaceNull($editByName);
$strEditByTypekeyInherit = sizeof($editByTypekeyInherit) > 0 ? implode(",", $editByTypekeyInherit) . ",null" : "null";
$strEditByTypekey = replaceNull($editByTypekey);
$strEditByPathInvert = sizeof($editByPathInvert) > 0 ? implode(",", $editByPathInvert) . ",null" : "null";
$strEditByPath = replaceNull($editByPath);
?>
<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']=''
wGB3252941500c0c533256=new gridBox("wGB3252941500c0c533256")
var b=wGB3252941500c0c533256
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=wGB3252941500c0c533256" 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 pxrfmodell.rows)
arrRA[arrRA.length] = pxrfmodell.gRS(pxrfmodell.rows[y])
f.rowActions.value = arrRA.join("<|>")
f.members.value = pxrfmodell.aCols['members'].vs.join("<|>")
f.openByNameInherit.value = pxrfmodell.aCols['open_by_name_inherit'].vs.join("<|>")
f.openByName.value = getRequestString(pxrfmodell.aCols['open_by_name'].vs)
f.openByTypekeyInherit.value = pxrfmodell.aCols['open_by_typekey_inherit'].vs.join("<|>")
f.openByTypekey.value = getRequestString(pxrfmodell.aCols['open_by_typekey'].vs)
f.openByPathInvert.value = pxrfmodell.aCols['open_by_path_invert'].vs.join("<|>")
f.openByPath.value = getRequestString(pxrfmodell.aCols['open_by_path'].vs)
f.editByNameInherit.value = pxrfmodell.aCols['edit_by_name_inherit'].vs.join("<|>")
f.editByName.value = getRequestString(pxrfmodell.aCols['edit_by_name'].vs)
f.editByTypekeyInherit.value = pxrfmodell.aCols['edit_by_typekey_inherit'].vs.join("<|>")
f.editByTypekey.value = getRequestString(pxrfmodell.aCols['edit_by_typekey'].vs)
f.editByPathInvert.value = pxrfmodell.aCols['edit_by_path_invert'].vs.join("<|>")
f.editByPath.value = getRequestString(pxrfmodell.aCols['edit_by_path'].vs)
f.submit()
}
function init(){
var g = pxrfmodell;
g.rC = <?php echo sizeof($members) ?>
g.aCols['members'].vs = Array(<?php echo $strMembers ?>)
g.aCols['members'].options = Array('<?php echo implode("','", $memberOptions) ?>')
g.aCols['open_by_name_inherit'].vs = Array(<?php echo $strOpenByNameInherit ?>)
g.aCols['open_by_name'].vs = Array(<?php echo $strOpenByName ?>)
g.aCols['open_by_name'].options = Array('<?php echo implode("','", $arrFiles) ?>')
g.aCols['open_by_typekey_inherit'].vs = Array(<?php echo $strOpenByTypekeyInherit ?>)
g.aCols['open_by_typekey'].vs = Array(<?php echo $strOpenByTypekey ?>)
g.aCols['open_by_typekey'].options = Array('<?php echo implode("','", $arrTypekeyOptions) ?>')
g.aCols['open_by_typekey'].values = Array('<?php echo implode("','", $arrTypekeyValues) ?>')
g.aCols['open_by_path_invert'].vs = Array(<?php echo $strOpenByPathInvert ?>)
g.aCols['open_by_path'].vs = Array(<?php echo $strOpenByPath ?>)
g.aCols['open_by_path'].options = Array('<?php echo implode("','", $arrFiles) ?>')
g.aCols['edit_by_name_inherit'].vs = Array(<?php echo $strEditByNameInherit ?>)
g.aCols['edit_by_name'].vs = Array(<?php echo $strEditByName ?>)
g.aCols['edit_by_name'].options = Array('<?php echo implode("','", $arrFiles) ?>')
g.aCols['edit_by_typekey_inherit'].vs = Array(<?php echo $strEditByTypekeyInherit ?>)
g.aCols['edit_by_typekey'].vs = Array(<?php echo $strEditByTypekey ?>)
g.aCols['edit_by_typekey'].options = Array('<?php echo implode("','", $arrTypekeyOptions) ?>')
g.aCols['edit_by_typekey'].values = Array('<?php echo implode("','", $arrTypekeyValues) ?>')
g.aCols['edit_by_path_invert'].vs = Array(<?php echo $strEditByPathInvert ?>)
g.aCols['edit_by_path'].vs = Array(<?php echo $strEditByPath ?>)
g.aCols['edit_by_path'].options = Array('<?php echo implode("','", $arrFiles) ?>')
g.title = "<?php echo $PXP_languages[$PXP_language]['rights'] ?>"
g.aCols['members'].title = "<?php echo $PXP_languages[$PXP_language]['pxrText'] ?>"
g.aCols['open_by_name_inherit'].title = "<?php echo $PXP_languages[$PXP_language]['inherit'] ?>"
g.aCols['open_by_name'].title = "<?php echo $PXP_languages[$PXP_language]['name'] ?>"
g.aCols['open_by_typekey_inherit'].title = "<?php echo $PXP_languages[$PXP_language]['pxrOpenText'] ?>"
g.aCols['open_by_typekey'].title = "<?php echo $PXP_languages[$PXP_language]['type'] ?>"
g.aCols['open_by_path_invert'].title = "<?php echo $PXP_languages[$PXP_language]['invert'] ?>"
g.aCols['open_by_path'].title = "<?php echo $PXP_languages[$PXP_language]['path'] ?>"
g.aCols['edit_by_name_inherit'].title = "<?php echo $PXP_languages[$PXP_language]['inherit'] ?>"
g.aCols['edit_by_name'].title = "<?php echo $PXP_languages[$PXP_language]['name'] ?>"
g.aCols['edit_by_typekey_inherit'].title = "<?php echo $PXP_languages[$PXP_language]['pxrEditText'] ?>"
g.aCols['edit_by_typekey'].title = "<?php echo $PXP_languages[$PXP_language]['type'] ?>"
g.aCols['edit_by_path_invert'].title = "<?php echo $PXP_languages[$PXP_language]['invert'] ?>"
g.aCols['edit_by_path'].title = "<?php echo $PXP_languages[$PXP_language]['path'] ?>"
b.render(window.frames['wGB3252941500c0c533256Content'])
b.resize()
window.setInterval('wGB3252941500c0c533256.resize()', 444)
}
//]]>
</script>
</head>
<body onLoad="init()">
<form name="frm1" action="./edit.php" method="post" target="frmSave">
<input type="hidden" name="data">
<input type="hidden" name="rowActions" value="">
<input type="hidden" name="members" value="">
<input type="hidden" name="openByNameInherit" value="">
<input type="hidden" name="openByName" value="">
<input type="hidden" name="openByTypekeyInherit" value="">
<input type="hidden" name="openByTypekey" value="">
<input type="hidden" name="openByPathInvert" value="">
<input type="hidden" name="openByPath" value="">
<input type="hidden" name="editByNameInherit" value="">
<input type="hidden" name="editByName" value="">
<input type="hidden" name="editByTypekeyInherit" value="">
<input type="hidden" name="editByTypekey" value="">
<input type="hidden" name="editByPathInvert" value="">
<input type="hidden" name="editByPath" value="">
<input type="hidden" name="actionType" 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="keyGenList" value="">
<table style="background-color:#DDDDDD" cellspacing="0" cellpadding="1" width="100%">
<tr>
<td>
<iframe scrolling="auto" id="wGB3252941500c0c533256Content" name="wGB3252941500c0c533256Content" 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="wGB3252941500c0c533256.addRow()">
</td>
<td height="28">
<input type="button" value="<?php echo $PXP_languages[$PXP_language]['insert'] ?>" onClick="wGB3252941500c0c533256.insRow()">
</td>
<td height="28">
<input type="button" value="<?php echo $PXP_languages[$PXP_language]['delete'] ?>" onClick="wGB3252941500c0c533256.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>