file_too_large = The file you want to view or edit is too large (max. {SIZE} Bytes).
remove_root = You are not allowed to remove the root directory.
rename_root = You are not allowed to move/rename the root directory.
+no_users = It seems that your system doesn't support users and groups.
+not_owner = You are not the owner of {FILE}, so you are not allowed to change the mode and the group.
# End of configuration file
\ No newline at end of file
# Execute Dev-Editor's commands
#
# Author: Patrick Canterino <patshaping@gmx.net>
-# Last modified: 2004-07-27
+# Last modified: 2004-07-28
#
use strict;
use Template;
my $script = $ENV{'SCRIPT_NAME'};
+my $users = eval("getpwuid(0)") && eval("getgrgid(0)");
my %dispatch = ('show' => \&exec_show,
'beginedit' => \&exec_beginedit,
'copy' => \&exec_copy,
'rename' => \&exec_rename,
'remove' => \&exec_remove,
+ 'chprop' => \&exec_chprop,
'unlock' => \&exec_unlock,
'about' => \&exec_about
);
$dtpl->fillin("DATE",strftime($config->{'timeformat'},localtime($stat[9])));
$dtpl->fillin("URL",equal_url($config->{'httproot'},$virt_path));
+ $dtpl->parse_if_block("users",$users && -o $physical."/".$dir);
+
$dirlist .= $dtpl->get_template;
}
$ftpl->parse_if_block("too_large",$config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'});
+ $ftpl->parse_if_block("users",$users && -o $phys_path);
+
$dirlist .= $ftpl->get_template;
}
}
}
+# exec_chprop()
+#
+# Change the mode and the group of a file or a directory
+#
+# Params: 1. Reference to user input hash
+# 2. Reference to config hash
+#
+# Return: Output of the command (Scalar Reference)
+
+sub exec_chprop($$)
+{
+ my ($data,$config) = @_;
+ my $physical = $data->{'physical'};
+ my $virtual = $data->{'virtual'};
+ my $dir = upper_path($virtual);
+ my $cgi = $data->{'cgi'};
+ my $mode = $cgi->param('mode');
+ my $group = $cgi->param('group');
+
+ if($users)
+ {
+ if(-o $physical)
+ {
+ if($mode || $group)
+ {
+ if($mode)
+ {
+ my $oct_mode = $mode;
+ $oct_mode = "0".$oct_mode if(length($oct_mode) == 3);
+ $oct_mode = oct($oct_mode);
+
+ chmod($oct_mode,$physical);
+ }
+
+ chgrp($group,$physical) if($group);
+
+ return devedit_reload({command => 'show', file => $dir});
+ }
+ else
+ {
+ my @stat = lstat($physical);
+
+ my $mode = $stat[2];
+ my $mode_oct = substr(sprintf("%04o",$mode),-4);
+ my $gid = $stat[5];
+ my $group = getgrgid($gid);
+
+ my $tpl = new Template;
+ $tpl->read_file($config->{'templates'}->{'chprop'});
+
+ $tpl->fillin("MODE_OCTAL",$mode_oct);
+ $tpl->fillin("MODE_STRING",mode_string($mode));
+ $tpl->fillin("GID",$gid);
+ $tpl->fillin("GROUP",$group);
+
+ $tpl->fillin("FILE",$virtual);
+ $tpl->fillin("DIR",$dir);
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
+
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
+
+ return \$output;
+ }
+ }
+ else
+ {
+ return error($config->{'errors'}->{'not_owner'},$dir,{FILE => $virtual});
+ }
+ }
+ else
+ {
+ return error($config->{'errors'}->{'no_users'},$dir,{FILE => $virtual});
+ }
+}
+
# exec_unlock()
#
# Remove a file from the list of used files and
# Check if the functions getpwuid() and getgrgid() are available
- if(eval("getpwuid(0)") && eval("getgrgid(0)"))
+ if($users)
{
# Dev-Editor is running on a system which allows users and groups
# So we display the user and the group of our process
# with only one command
#
# Author: Patrick Canterino <patshaping@gmx.net>
-# Last modified: 2004-07-21
+# Last modified: 2004-07-28
#
use strict;
use base qw(Exporter);
-@EXPORT = qw(dir_read
+@EXPORT = qw(chgrp
+ dir_read
file_create
file_read
file_save
file_unlock);
+# chgrp()
+#
+# Change the group of files or directories
+#
+# Params: 1. Group name
+# 2. List of files
+#
+# Return: Number of files group successfully changed
+# (or false)
+
+sub chgrp($@)
+{
+ my ($group,@files) = @_;
+ my $gid = getgrnam($group);
+
+ return unless($gid);
+ return chown(-1,$gid,@files);
+}
+
# dir_read()
#
# Collect the files and directories in a directory
# Some shared sub routines
#
# Author: Patrick Canterino <patshaping@gmx.net>
-# Last modified: 2004-07-17
+# Last modified: 2004-07-28
#
use strict;
devedit_reload
equal_url
file_name
+ mode_string
upper_path);
# check_path()
# and modified by Patrick Canterino
my $query = '?'.join ('&' =>
- map {
- (ref)
- ? map{escape ($_).'='.escape ($params -> {$_})} @{$params -> {$_}}
- : escape ($_).'='.escape ($params -> {$_})
- } keys %$params
- );
+ map {
+ (ref)
+ ? map{escape ($_).'='.escape ($params -> {$_})} @{$params -> {$_}}
+ : escape ($_).'='.escape ($params -> {$_})
+ } keys %$params
+ );
# Create the redirection header
return $path;
}
+# mode_string()
+#
+# Convert a binary file mode string into a human
+# readable string (rwxr-x-r-x)
+#
+# Params: Binary file mode string
+#
+# Return: Humand readable mode string
+
+sub mode_string($)
+{
+ my $mode = shift;
+
+ my $string = "";
+
+ # Owner
+ $string .= (($mode & 0x0100) ? 'r' : '-') .
+ (($mode & 0x0080) ? 'w' : '-') .
+ (($mode & 0x0040) ?
+ (($mode & 0x0800) ? 's' : 'x' ) :
+ (($mode & 0x0800) ? 'S' : '-')
+ );
+
+ # Group
+ $string .= (($mode & 0x0020) ? 'r' : '-') .
+ (($mode & 0x0010) ? 'w' : '-') .
+ (($mode & 0x0008) ?
+ (($mode & 0x0400) ? 's' : 'x') :
+ (($mode & 0x0400) ? 'S' : '-')
+ );
+
+ # World
+ $string .= (($mode & 0x0004) ? 'r' : '-') .
+ (($mode & 0x0002) ? 'w' : '-') .
+ (($mode & 0x0001) ?
+ (($mode & 0x0200) ? 't' : 'x' ) :
+ (($mode & 0x0200) ? 'T' : '-')
+ );
+
+ return $string;
+}
+
# upper_path()
#
# Cut away the last part of a path
dirlist_file = templates/dirlist_file.htm
dirlist_dir = templates/dirlist_dir.htm
dirlist_up = templates/dirlist_up.htm
+chprop = templates/chprop.htm
error = templates/error.htm
about = templates/about.htm
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+<title>Change properties of {FILE}</title>
+<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
+</head>
+<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
+
+<h1>Change properties of {FILE}</h1>
+
+<p>(equals <a href="{URL}" target="_blank">{URL}</a>)</p>
+
+<p><a href="{SCRIPT}?command=show&file={DIR}">Back to {DIR}</a></p>
+
+<p>Current mode: {MODE_STRING} (Octal: {MODE_OCTAL})</p>
+
+<p>Current group: {GROUP} (GID: {GID})</p>
+
+<hr>
+
+<table border="0">
+<tr>
+<td>Change mode:</td>
+<form action="{SCRIPT}" method="get">
+<input type="hidden" name="command" value="chprop">
+<input type="hidden" name="file" value="{FILE}">
+<td><input type="text" name="mode" value="{MODE_OCTAL}"> <input type="submit" value="Change!"></td>
+</form>
+</tr>
+<tr>
+<td>Change group:</td>
+<form action="{SCRIPT}" method="get">
+<input type="hidden" name="command" value="chprop">
+<input type="hidden" name="file" value="{FILE}">
+<td><input type="text" name="group" value="{GROUP}"> <input type="submit" value="Change!"></td>
+</form>
+</tr>
+</table>
+
+<hr>
+
+<p align="right"><a href="{SCRIPT}?command=about" target="_blank"><i>About Dev-Editor</i></a></p>
+</body>
+</html>
\ No newline at end of file
<tr>
-<td align="right">[SUBDIR]</td>
-<td style="padding-left:15pt">{DATE}</td>
-<td style="padding-left:15pt"><a href="{SCRIPT}?command=show&file={DIR}">{DIR_NAME}/</a></td>
-<td style="padding-left:15pt">(<a href="{SCRIPT}?command=rename&file={DIR}">Rename</a> | <a href="{SCRIPT}?command=remove&file={DIR}">Delete</a> | <a href="{URL}" target="_blank">View in Browser</a>)</td>
+<td align="right" style="white-space:nowrap">[SUBDIR]</td>
+<td style="padding-left:15pt;white-space:nowrap;">{DATE}</td>
+<td style="padding-left:15pt;white-space:nowrap;"><a href="{SCRIPT}?command=show&file={DIR}">{DIR_NAME}/</a></td>
+<td style="padding-left:15pt;white-space:nowrap;">(<a href="{SCRIPT}?command=rename&file={DIR}">Rename</a> | <a href="{SCRIPT}?command=remove&file={DIR}">Delete</a> |{IF users} <a href="{SCRIPT}?command=chprop&file={DIR}">Chmod/Chgrp</a> |{ENDIF} <a href="{URL}" target="_blank">View in Browser</a>)</td>
</tr>
<tr>
-<td align="right">{SIZE}</td>
-<td style="padding-left:15pt">{DATE}</td>
-<td style="padding-left:15pt">{FILE_NAME}</td>
-<td style="padding-left:15pt">({IF viewable}<a href="{SCRIPT}?command=show&file={FILE}">View</a>{ELSE}<span style="color:#C0C0C0" title="{IF not_readable}Not readable{ELSE}{IF binary}Binary file{ELSE}{IF too_large}File too large{ENDIF}{ENDIF}{ENDIF}">View</span>{ENDIF} | {IF editable}<a href="{SCRIPT}?command=beginedit&file={FILE}">Edit</a>{ELSE}<span style="color:#C0C0C0" title="{IF not_readable}Not readable{ELSE}{IF readonly}Read only{ELSE}{IF binary}Binary file{ELSE}{IF too_large}File too large{ENDIF}{IF in_use}In use{ENDIF}{ENDIF}{ENDIF}{ENDIF}">Edit</span>{ENDIF} | <a href="{SCRIPT}?command=copy&file={FILE}">Copy</a>{IF unused} | <a href="{SCRIPT}?command=rename&file={FILE}">Rename</a> | <a href="{SCRIPT}?command=remove&file={FILE}">Delete</a>{ENDIF}{IF in_use} | <a href="{SCRIPT}?command=unlock&file={FILE}">Unlock</a>{ENDIF} | <a href="{URL}" target="_blank">View in Browser</a>)</td>
+<td align="right" style="white-space:nowrap">{SIZE}</td>
+<td style="padding-left:15pt;white-space:nowrap;">{DATE}</td>
+<td style="padding-left:15pt;white-space:nowrap;">{FILE_NAME}</td>
+<td style="padding-left:15pt;white-space:nowrap;">({IF viewable}<a href="{SCRIPT}?command=show&file={FILE}">View</a>{ELSE}<span style="color:#C0C0C0" title="{IF not_readable}Not readable{ELSE}{IF binary}Binary file{ELSE}{IF too_large}File too large{ENDIF}{ENDIF}{ENDIF}">View</span>{ENDIF} | {IF editable}<a href="{SCRIPT}?command=beginedit&file={FILE}">Edit</a>{ELSE}<span style="color:#C0C0C0" title="{IF not_readable}Not readable{ELSE}{IF readonly}Read only{ELSE}{IF binary}Binary file{ELSE}{IF too_large}File too large{ENDIF}{IF in_use}In use{ENDIF}{ENDIF}{ENDIF}{ENDIF}">Edit</span>{ENDIF} | <a href="{SCRIPT}?command=copy&file={FILE}">Copy</a>{IF unused} | <a href="{SCRIPT}?command=rename&file={FILE}">Rename</a> | <a href="{SCRIPT}?command=remove&file={FILE}">Delete</a>{ENDIF}{IF in_use} | <a href="{SCRIPT}?command=unlock&file={FILE}">Unlock</a>{ENDIF} |{IF users} <a href="{SCRIPT}?command=chprop&file={FILE}">Chmod/Chgrp</a> |{ENDIF} <a href="{URL}" target="_blank">View in Browser</a>)</td>
</tr>
<tr>
-<td align="right">[SUBDIR]</td>
-<td style="padding-left:15pt">{DATE}</td>
-<td colspan="2" style="padding-left:15pt"><a href="{SCRIPT}?command=show&file={UPPER_DIR}">../</a></td>
+<td align="right" style="white-space:nowrap">[SUBDIR]</td>
+<td style="padding-left:15pt;white-space:nowrap;">{DATE}</td>
+<td colspan="2" style="padding-left:15pt;white-space:nowrap"><a href="{SCRIPT}?command=show&file={UPPER_DIR}">../</a></td>
</tr>