File "edit.php"

Full Path: /home/analogde/www/Ebook/htgroups/edit.php
File size: 6.31 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 user
if(isset($HTTP_POST_VARS["groups"])){

	$rowActions = explode("<|>", $HTTP_POST_VARS["rowActions"]);

	$groups = explode("<|>", $HTTP_POST_VARS["groups"]);
	$groupUsers = explode("<|>", $HTTP_POST_VARS["groupUsers"]);
	
	$groupFileContent = "";

	foreach($groups as $index => $group){

		if($rowActions[$index] != "d")
			$groupFileContent .= $group . ":" . str_replace("|", " ", $groupUsers[$index]) . "\n";
	}
	
	$handle = fopen($currentDir . "/" . $fileName, "w");
	fwrite($handle, $groupFileContent);
	fclose($handle);

	die();
}


$caption = $PXP_languages[$PXP_language]['filetype.' . $acronym] . " - " . str_replace($PXP_basedir, "", $currentDir) . "/" . $fileName;

$groups = Array();
$groupUsers = Array();

$lines = file($currentDir . "/" . $fileName);

foreach($lines as $line){
	$values = explode(":", $line);

	array_push($groups, trim($values[0]));
	array_push($groupUsers, str_replace(" ", "|", trim($values[1])));
}

# build strings from arrays
$strGroups = sizeof($groups) > 0 ? "'" . implode("','", $groups) . "',null" : "null";
$strGroupUsers = sizeof($groupUsers) > 0 ? "'" . implode("','", $groupUsers) . "',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']=''

wGB66288810440f4d67ce2b604 = new gridBox("wGB66288810440f4d67ce2b604")
var b=wGB66288810440f4d67ce2b604

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=wGB66288810440f4d67ce2b604" type="text/javascript" language="JavaScript"></script>
<style type="text/css">
/*<![CDATA[*/
body{margin:0px}
/*]]>*/
</style>
<script language="JavaScript" type="text/javascript">
//<![CDATA[

function save(){
	var f = document.frm1

	var arrRA = new Array()
	for(var y in htgroups.rows)
		arrRA[arrRA.length] = htgroups.gRS(htgroups.rows[y])
		
	f.rowActions.value = arrRA.join("<|>")
	
	f.groups.value = htgroups.aCols['groupname'].vs.join("<|>");
	f.groupUsers.value = htgroups.aCols['users'].vs.join("<|>");

	f.submit()
}

function init(){

	var g = htgroups;
	g.rC = <?php echo sizeof($groups) ?>
	
	g.aCols['groupname'].vs = Array(<?php echo $strGroups ?>)
	g.aCols['users'].vs = Array(<?php echo $strGroupUsers ?>)
	g.aCols['users'].options = Array('<?php echo implode("','", $PXP_users) ?>')


	g.title = "<?php echo $PXP_languages[$PXP_language]['roles'] ?>"
	g.aCols['groupname'].title = "<?php echo $PXP_languages[$PXP_language]['name'] ?>"
	g.aCols['users'].title = "<?php echo $PXP_languages[$PXP_language]['users'] ?>"

	b.render(window.frames['wGB66288810440f4d67ce2b604Content'])
	b.resize()
	window.setInterval('wGB66288810440f4d67ce2b604.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="groups" value="">
<input type="hidden" name="groupUsers" 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="wGB66288810440f4d67ce2b604Content" name="wGB66288810440f4d67ce2b604Content" 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="wGB66288810440f4d67ce2b604.addRow()">
			</td>
			<td height="28">
				<input type="button" value="<?php echo $PXP_languages[$PXP_language]['insert'] ?>" onClick="wGB66288810440f4d67ce2b604.insRow()">
			</td>
			<td height="28">
				<input type="button" value="<?php echo $PXP_languages[$PXP_language]['delete'] ?>" onClick="wGB66288810440f4d67ce2b604.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>