File "edit.php"
Full Path: /home/analogde/www/filetypes/pxuf/edit.php
File size: 18.3 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["users"])){
require(dirname(__FILE__) . "/../../authentication/htaccess_editor.php");
$htEditor = new htaccessEditor(dirname(dirname(dirname(__FILE__))) . "/.htpasswd");
$rowActions = explode("<|>", $HTTP_POST_VARS["rowActions"]);
$users = explode("<|>", $HTTP_POST_VARS["users"]);
$passwords = explode("<|>", $HTTP_POST_VARS["passwords"]);
$languages = explode("<|>", $HTTP_POST_VARS["languages"]);
$styles = explode("<|>", $HTTP_POST_VARS["styles"]);
$defaultViews = explode("<|>", $HTTP_POST_VARS["defaultViews"]);
$dateFormats = explode("<|>", $HTTP_POST_VARS["dateFormats"]);
$timeFormats = explode("<|>", $HTTP_POST_VARS["timeFormats"]);
$defaultShares = explode("<|>", $HTTP_POST_VARS["defaultShares"]);
$trashcans = explode("<|>", $HTTP_POST_VARS["trashcans"]);
$firstnames = explode("<|>", $HTTP_POST_VARS["firstnames"]);
$names = explode("<|>", $HTTP_POST_VARS["names"]);
$emails = explode("<|>", $HTTP_POST_VARS["emails"]);
$phones = explode("<|>", $HTTP_POST_VARS["phones"]);
$mobiles = explode("<|>", $HTTP_POST_VARS["mobiles"]);
$pxuf = $currentDir . "/users.pxuf";
if(is_dir($pxuf)){
$d = dir($pxuf);
while($file = $d->read())
if($file != "." AND $file != "..")
if(is_dir($pxuf . "/" . $file))
rmdirRecursive($pxuf . "/" . $file);
$strDefaultUserFile = implode("", file(dirname(__FILE__) . "/../pxu/default.php"));
$strDefaultShareFile = implode("", file(dirname(__FILE__) . "/../pxs/default.php"));
foreach($users as $index => $user){
if($rowActions[$index] == "d"){
$htEditor->deleteUser($user);
if($PXP_createUserFolder)
if(file_exists($PXP_dir . "/shares.pxsf/" .$user))
rmdirRecursive($PXP_dir . "/shares.pxsf/" .$user);
continue;
}
mkdir($currentDir . "/users.pxuf/" . $user, 0755);
$strNewFile = $strDefaultUserFile;
$strNewFile = str_replace("{@pxuLanguage}", $languages[$index], $strNewFile);
$strNewFile = str_replace("{@pxuStyle}", $styles[$index], $strNewFile);
$strNewFile = str_replace("{@pxuDefaultView}", $defaultViews[$index], $strNewFile);
$strNewFile = str_replace("{@pxuDateFormat}", $dateFormats[$index], $strNewFile);
$strNewFile = str_replace("{@pxuTimeFormat}", $timeFormats[$index], $strNewFile);
$strNewFile = str_replace("{@pxuFirstName}", $firstnames[$index], $strNewFile);
$strNewFile = str_replace("{@pxuName}", $names[$index], $strNewFile);
$strNewFile = str_replace("{@pxuEmail}", $emails[$index], $strNewFile);
$strNewFile = str_replace("{@pxuPhone}", $phones[$index], $strNewFile);
$strNewFile = str_replace("{@pxuMobile}", $mobiles[$index], $strNewFile);
$strNewFile = str_replace("{@pxuTrashcan}", $trashcans[$index] == "true" ? "true" : "false", $strNewFile);
if($PXP_createUserFolder){
if($defaultShares[$index] == ""){
$strNewFile = str_replace("{@pxuDefaultShare}", $user, $strNewFile);
}else{
$strNewFile = str_replace("{@pxuDefaultShare}", $defaultShares[$index], $strNewFile);
}
}else{
$strNewFile = str_replace("{@pxuDefaultShare}", $defaultShares[$index], $strNewFile);
}
$handle = fopen($currentDir . "/users.pxuf/" . $user . "/config." . $user . ".pxu.php", "w");
fwrite($handle, $strNewFile);
fclose($handle);
if($passwords[$index] != "{__EMPTY__}")
$htEditor->addUser($user, $passwords[$index]);
if($PXP_createUserFolder){
if(!file_exists($PXP_user_folder . "/" . $user)){
if(!@mkdir($PXP_user_folder . "/" . $user, 0755)){
echo '<script>alert("Could not create user folder!")</script>';
}else{
mkdir($PXP_user_folder . "/" . $user . "/trash.pxtf", 0755);
if(!file_exists($PXP_dir . "/shares.pxsf/" . $user)){
if(!@mkdir($PXP_dir . "/shares.pxsf/" . $user, 0755)){
echo '<script>alert("Could not create share folder!")</script>';
}else{
$strNewFile = $strDefaultShareFile;
$strNewFile = str_replace("{@pxsId}", $user, $strNewFile);
$strNewFile = str_replace("{@pxsBasedir}", "{@PXP_user_folder}/" . $user, $strNewFile);
$strNewFile = str_replace("{@pxsShareUsers}", "'" . $user . "'", $strNewFile);
$strNewFile = str_replace("{@pxsShareRoles}", "", $strNewFile);
$strNewFile = str_replace("{@pxsRightsDir}", "rights.pxrf", $strNewFile);
$strNewFile = str_replace("{@pxsStartpage}", "./directory.php", $strNewFile);
$strNewFile = str_replace("{@pxsTreeReload}", "true", $strNewFile);
$strNewFile = str_replace("{@pxsKey}", "Hz76%gd;,g_h89", $strNewFile);
$strNewFile = str_replace("{@pxsCreateHtaccess}", "1", $strNewFile);
$handle = fopen($PXP_dir . "/shares.pxsf/" . $user . "/config." . $user . ".pxs.php", "w");
fwrite($handle, $strNewFile);
fclose($handle);
copy($PXP_dir . "/shares.pxsf/" . "default_index.php", $PXP_dir . "/shares.pxsf/" . $user . "/index.php");
}
}
}
}
}
}
}
$htEditor->writeFile();
require(dirname(__FILE__) . "/../pxsf/writeShareHtaccessFiles.php");
die();
}
$caption = $PXP_languages[$PXP_language]['filetype.' . $acronym] . " - " . str_replace($PXP_basedir, "", $currentDir) . "/" . $fileName;
if(file_exists(dirname(__FILE__) . "/../../lang.pxlf/" . $PXP_language . "_languageCodes.php")){
require(dirname(__FILE__) . "/../../lang.pxlf/" . $PXP_language . "_languageCodes.php");
}else{
require(dirname(__FILE__) . "/../../lang.pxlf/en_languageCodes.php");
}
# load values and options for selectboxes
$arrLanguageOptions = Array();
$arrLanguageValues = Array();
$arrStyleOptions = Array();
$arrViewOptions = Array();
$arrShareOptions = Array();
$pxuf = $PXP_dir . "/lang.pxlf";
$d = dir($pxuf);
while($file = $d->read())
if($file != "." and $file != "..")
if(!is_dir($pxuf . "/" . $file)){
$filename = basename($pxuf . "/" . $file);
$filename = str_replace(".pxl.php", "", $filename);
if(strlen($filename) == 2){
array_push($arrLanguageValues, $filename);
array_push($arrLanguageOptions, $lngCodes[$filename]);
}
}
$pxuf = $PXP_dir . "/styles";
$d = dir($pxuf);
while($file = $d->read())
if($file != "." and $file != "..")
if(is_dir($pxuf . "/" . $file))
array_push($arrStyleOptions, $file);
$pxuf = $PXP_dir . "/views";
$d = dir($pxuf);
while($file = $d->read())
if($file != "." and $file != "..")
if(is_dir($pxuf . "/" . $file))
array_push($arrViewOptions, $file);
array_push($arrShareOptions, "");
$pxuf = $PXP_dir . "/shares.pxsf";
$d = dir($pxuf);
while($file = $d->read())
if($file != "." and $file != "..")
if(is_dir($pxuf . "/" . $file))
array_push($arrShareOptions, $file);
$users = Array();
$languages = Array();
$styles = Array();
$defaultViews = Array();
$dateFormats = Array();
$timeFormats = Array();
$defaultShares = Array();
$trashcans = Array();
$firstnames = Array();
$names = Array();
$emails = Array();
$phones = Array();
$mobiles = Array();
$pxuf = $currentDir . "/users.pxuf";
$d = dir($pxuf);
while($file = $d->read())
if($file != "." and $file != "..")
if(is_dir($pxuf . "/" . $file))
array_push($users, $file);
# import existing users
foreach($users as $user){
require($currentDir . "/users.pxuf/" . $user . "/config." . $user . ".pxu.php");
$languages[$user] = $PXP_language;
$styles[$user] = $PXP_style;
$defaultViews[$user] = $PXP_view;
$dateFormats[$user] = $PXP_date_format;
$timeFormats[$user] = $PXP_time_format;
$defaultShares[$user] = $PXP_default_share;
$trashcans[$user] = $PXP_trashcan ? "true" : "false";
$firstnames[$user] = $PXP_firstname;
$names[$user] = $PXP_name;
$emails[$user] = $PXP_email;
$phones[$user] = $PXP_phone;
$mobiles[$user] = $PXP_mobile;
}
# load current users config values again
require($currentDir . "/users.pxuf/" . $PXP_user . "/config." . $PXP_user . ".pxu.php");
# build strings from arrays
$strUsers = sizeof($users) > 0 ? "'" . implode("','", $users) . "',null" : "null";
$strLanguages = sizeof($languages) > 0 ? "'" . implode("','", $languages) . "',null" : "null";
$strStyles = sizeof($styles) > 0 ? "'" . implode("','", $styles) . "',null" : "null";
$strDefaultViews = sizeof($defaultViews) > 0 ? "'" . implode("','", $defaultViews) . "',null" : "null";
$strDateFormats = sizeof($dateFormats) > 0 ? "'" . implode("','", $dateFormats) . "',null" : "null";
$strTimeFormats = sizeof($timeFormats) > 0 ? "'" . implode("','", $timeFormats) . "',null" : "null";
$strDefaultShares = sizeof($defaultShares) > 0 ? "'" . implode("','", $defaultShares) . "',null" : "null";
$strTrashcans = sizeof($trashcans) > 0 ? implode(",", $trashcans) . ",null" : "null";
$strFirstnames = sizeof($firstnames) > 0 ? "'" . implode("','", $firstnames) . "',null" : "null";
$strNames = sizeof($names) > 0 ? "'" . implode("','", $names) . "',null" : "null";
$strEmails = sizeof($emails) > 0 ? "'" . implode("','", $emails) . "',null" : "null";
$strPhones = sizeof($phones) > 0 ? "'" . implode("','", $phones) . "',null" : "null";
$strMobiles = sizeof($mobiles) > 0 ? "'" . implode("','", $mobiles) . "',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']=''
wGB264444151b9a1afe1a7 = new gridBox("wGB264444151b9a1afe1a7")
var b=wGB264444151b9a1afe1a7
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=wGB264444151b9a1afe1a7" 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
if(!b.onSync())
return false
var arrRA = new Array()
for(var y in pxufmodell.rows)
arrRA[arrRA.length] = pxufmodell.gRS(pxufmodell.rows[y])
f.rowActions.value = arrRA.join("<|>")
f.users.value = pxufmodell.aCols['user'].vs.join("<|>");
f.passwords.value = pxufmodell.aCols['password'].vs.join("<|>");
f.languages.value = pxufmodell.aCols['language'].vs.join("<|>");
f.styles.value = pxufmodell.aCols['style'].vs.join("<|>");
f.defaultViews.value = pxufmodell.aCols['default_view'].vs.join("<|>");
f.dateFormats.value = pxufmodell.aCols['date_format'].vs.join("<|>");
f.timeFormats.value = pxufmodell.aCols['time_format'].vs.join("<|>");
f.defaultShares.value = pxufmodell.aCols['default_share'].vs.join("<|>");
f.trashcans.value = pxufmodell.aCols['trashcan'].vs.join("<|>");
f.firstnames.value = pxufmodell.aCols['firstname'].vs.join("<|>");
f.names.value = pxufmodell.aCols['name'].vs.join("<|>");
f.emails.value = pxufmodell.aCols['email'].vs.join("<|>");
f.phones.value = pxufmodell.aCols['phone'].vs.join("<|>");
f.mobiles.value = pxufmodell.aCols['mobile'].vs.join("<|>");
f.submit()
}
<?php
$nullValues = Array();
for($i = 0; $i < sizeof($users) + 1; $i++)
array_push($nullValues, "'{__EMPTY__}'");
$strNullValues = implode(",", $nullValues);
?>//javascript
var confirmPasswordOfUser = "<?php echo $PXP_languages[$PXP_language]['confirmPasswordOfUser'] ?>"
var doesNotMatch = "<?php echo $PXP_languages[$PXP_language]['doesNotMatch'] ?>"
var passwordOfUser = "<?php echo $PXP_languages[$PXP_language]['passwordOfUser'] ?>"
var shouldNotEmpty = "<?php echo $PXP_languages[$PXP_language]['shouldNotEmpty'] ?>"
function init(){
var g = pxufmodell;
g.rC = <?php echo sizeof($users) ?>
g.aCols['user'].vs = Array(<?php echo $strUsers ?>)
g.aCols['password'].vs = Array(<?php echo $strNullValues ?>)
g.aCols['passwordConfirm'].vs = Array(<?php echo $strNullValues ?>)
g.aCols['language'].vs = Array(<?php echo $strLanguages ?>)
g.aCols['language'].options = Array('<?php echo implode("','", $arrLanguageOptions) ?>')
g.aCols['language'].values = Array('<?php echo implode("','", $arrLanguageValues) ?>')
g.aCols['style'].vs = Array(<?php echo $strStyles ?>)
g.aCols['style'].options = Array('<?php echo implode("','", $arrStyleOptions) ?>')
g.aCols['default_view'].vs = Array(<?php echo $strDefaultViews ?>)
g.aCols['default_view'].options = Array('<?php echo implode("','", $arrViewOptions) ?>')
g.aCols['date_format'].vs = Array(<?php echo $strDateFormats ?>)
g.aCols['time_format'].vs = Array(<?php echo $strTimeFormats ?>)
g.aCols['default_share'].vs = Array(<?php echo $strDefaultShares ?>)
g.aCols['default_share'].options = Array('<?php echo implode("','", $arrShareOptions) ?>')
g.aCols['trashcan'].vs = Array(<?php echo $strTrashcans ?>)
g.aCols['firstname'].vs = Array(<?php echo $strFirstnames ?>)
g.aCols['name'].vs = Array(<?php echo $strNames ?>)
g.aCols['email'].vs = Array(<?php echo $strEmails ?>)
g.aCols['phone'].vs = Array(<?php echo $strPhones ?>)
g.aCols['mobile'].vs = Array(<?php echo $strMobiles ?>)
g.title = "<?php echo $PXP_languages[$PXP_language]['user'] ?>"
g.aCols['user'].title = "<?php echo $PXP_languages[$PXP_language]['user'] ?>"
g.aCols['password'].title = "<?php echo $PXP_languages[$PXP_language]['password'] ?>"
g.aCols['passwordConfirm'].title = "<?php echo $PXP_languages[$PXP_language]['passwordConfirm'] ?>"
g.aCols['language'].title = "<?php echo $PXP_languages[$PXP_language]['language'] ?> "
g.aCols['style'].title = "<?php echo $PXP_languages[$PXP_language]['style'] ?>"
g.aCols['default_view'].title = "<?php echo $PXP_languages[$PXP_language]['defaultView'] ?>"
g.aCols['date_format'].title = "<?php echo $PXP_languages[$PXP_language]['dataFormat'] ?>"
g.aCols['time_format'].title = "<?php echo $PXP_languages[$PXP_language]['timeFormat'] ?>"
g.aCols['default_share'].title = "<?php echo $PXP_languages[$PXP_language]['defaultShare'] ?>"
g.aCols['trashcan'].title = "<?php echo $PXP_languages[$PXP_language]['trashcan'] ?>"
g.aCols['firstname'].title = "<?php echo $PXP_languages[$PXP_language]['firstname'] ?>"
g.aCols['name'].title = "<?php echo $PXP_languages[$PXP_language]['name'] ?>"
g.aCols['email'].title = "<?php echo $PXP_languages[$PXP_language]['email'] ?>"
g.aCols['phone'].title = "<?php echo $PXP_languages[$PXP_language]['phone'] ?>"
g.aCols['mobile'].title = "<?php echo $PXP_languages[$PXP_language]['mobile'] ?>"
b.render(window.frames['wGB264444151b9a1afe1a7Content'])
b.resize()
window.setInterval('wGB264444151b9a1afe1a7.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="users" value="">
<input type="hidden" name="passwords" value="">
<input type="hidden" name="languages" value="">
<input type="hidden" name="styles" value="">
<input type="hidden" name="defaultViews" value="">
<input type="hidden" name="dateFormats" value="">
<input type="hidden" name="timeFormats" value="">
<input type="hidden" name="defaultShares" value="">
<input type="hidden" name="trashcans" value="">
<input type="hidden" name="firstnames" value="">
<input type="hidden" name="names" value="">
<input type="hidden" name="emails" value="">
<input type="hidden" name="phones" value="">
<input type="hidden" name="mobiles" 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="wGB264444151b9a1afe1a7Content" name="wGB264444151b9a1afe1a7Content" 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="wGB264444151b9a1afe1a7.addRow()">
</td>
<td height="28">
<input type="button" value="<?php echo $PXP_languages[$PXP_language]['insert'] ?>" onClick="wGB264444151b9a1afe1a7.insRow()">
</td>
<td height="28">
<input type="button" value="<?php echo $PXP_languages[$PXP_language]['delete'] ?>" onClick="wGB264444151b9a1afe1a7.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>