-# Last modified: 2004-11-10
+# Last modified: 2004-11-23
#
use strict;
@@ -118,7 +118,7 @@ sub exec_show($$)
$udtpl->read_file($config->{'templates'}->{'dirlist_up'});
$udtpl->fillin("UPPER_DIR",encode_entities(upper_path($virtual)));
- $udtpl->fillin("DATE",strftime($config->{'timeformat'},localtime($stat[9])));
+ $udtpl->fillin("DATE",encode_entities(strftime($config->{'timeformat'},localtime($stat[9]))));
$dirlist .= $udtpl->get_template;
}
@@ -137,7 +137,7 @@ sub exec_show($$)
$dtpl->fillin("DIR",$virt_path);
$dtpl->fillin("DIR_NAME",$dir);
- $dtpl->fillin("DATE",strftime($config->{'timeformat'},localtime($stat[9])));
+ $dtpl->fillin("DATE",encode_entities(strftime($config->{'timeformat'},localtime($stat[9]))));
$dtpl->fillin("URL",equal_url($config->{'httproot'},$virt_path));
$dtpl->parse_if_block("readable",-r $phys_path && -x $phys_path);
@@ -162,7 +162,7 @@ sub exec_show($$)
$ftpl->fillin("FILE",$virt_path);
$ftpl->fillin("FILE_NAME",$file);
$ftpl->fillin("SIZE",$stat[7]);
- $ftpl->fillin("DATE",strftime($config->{'timeformat'},localtime($stat[9])));
+ $ftpl->fillin("DATE",encode_entities(strftime($config->{'timeformat'},localtime($stat[9]))));
$ftpl->fillin("URL",equal_url($config->{'httproot'},$virt_path));
$ftpl->parse_if_block("not_readable",not -r $phys_path);
@@ -255,11 +255,12 @@ sub exec_beginedit($$)
my ($data,$config) = @_;
my $physical = $data->{'physical'};
my $virtual = $data->{'virtual'};
+ my $dir = upper_path($virtual);
my $uselist = $data->{'uselist'};
- return error($config->{'errors'}->{'editdir'},upper_path($virtual)) if(-d $physical);
- return error($config->{'errors'}->{'in_use'},upper_path($virtual),{FILE => $virtual}) if($uselist->in_use($virtual));
- return error($config->{'errors'}->{'noedit'},upper_path($virtual)) unless(-r $physical && -w $physical);
+ return error($config->{'errors'}->{'editdir'},$dir) if(-d $physical);
+ return error($config->{'errors'}->{'in_use'}, $dir,{FILE => $virtual}) if($uselist->in_use($virtual));
+ return error($config->{'errors'}->{'noedit'}, $dir) unless(-r $physical && -w $physical);
# Check on binary files
@@ -267,13 +268,13 @@ sub exec_beginedit($$)
{
# Binary file
- return error($config->{'errors'}->{'binary'},upper_path($virtual));
+ return error($config->{'errors'}->{'binary'},$dir);
}
else
{
- if($config->{'max_file_size'} && (stat($physical))[7] > $config->{'max_file_size'})
+ if($config->{'max_file_size'} && (-s $physical) > $config->{'max_file_size'})
{
- return error($config->{'errors'}->{'file_too_large'},upper_path($virtual),{SIZE => $config->{'max_file_size'}})
+ return error($config->{'errors'}->{'file_too_large'},$dir,{SIZE => $config->{'max_file_size'}})
}
else
{
@@ -289,7 +290,7 @@ sub exec_beginedit($$)
$tpl->read_file($config->{'templates'}->{'editfile'});
$tpl->fillin("FILE",$virtual);
- $tpl->fillin("DIR",upper_path($virtual));
+ $tpl->fillin("DIR",$dir);
$tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
$tpl->fillin("SCRIPT",$script);
$tpl->fillin("CONTENT",encode_entities($$content));
@@ -334,6 +335,7 @@ sub exec_endedit($$)
my ($data,$config) = @_;
my $physical = $data->{'physical'};
my $virtual = $data->{'virtual'};
+ my $dir = upper_path($virtual);
my $content = $data->{'cgi'}->param('filecontent');
my $uselist = $data->{'uselist'};
@@ -365,22 +367,22 @@ sub exec_endedit($$)
# Check if someone else is editing the new file
- return error($config->{'errors'}->{'in_use'},upper_path($virtual),{FILE => $virtual}) if($uselist->in_use($virtual));
+ return error($config->{'errors'}->{'in_use'},$dir,{FILE => $virtual}) if($uselist->in_use($virtual));
}
- return error($config->{'errors'}->{'text_to_binary'},upper_path($virtual)) unless(-T $physical);
- return error($config->{'errors'}->{'editdir'},upper_path($virtual)) if(-d $physical);
- return error($config->{'errors'}->{'noedit'}, upper_path($virtual)) if(-e $physical && !(-r $physical && -w $physical));
+ return error($config->{'errors'}->{'text_to_binary'},$dir) unless(-T $physical);
+ return error($config->{'errors'}->{'editdir'},$dir) if(-d $physical);
+ return error($config->{'errors'}->{'noedit'}, $dir) if(-e $physical && !(-r $physical && -w $physical));
if(file_save($physical,\$content))
{
# Saving of the file was successful - so unlock it!
- return devedit_reload({command => 'show', file => upper_path($virtual)});
+ return devedit_reload({command => 'show', file => $dir});
}
else
{
- return error($config->{'errors'}->{'edit_failed'},upper_path($virtual),{FILE => $virtual});
+ return error($config->{'errors'}->{'edit_failed'},$dir,{FILE => $virtual});
}
}
@@ -779,7 +781,7 @@ sub exec_chprop($$)
if($group)
{
- return error($config->{'errors'}->{'invalid_group'},$dir,{GROUP => $group}) unless($group =~ /^[a-z0-9_]+[a-z0-9_-]*$/i);
+ return error($config->{'errors'}->{'invalid_group'},$dir,{GROUP => encode_entities($group)}) unless($group =~ /^[a-z0-9_]+[a-z0-9_-]*$/i);
system("chgrp",$group,$physical);
}
@@ -787,20 +789,34 @@ sub exec_chprop($$)
}
else
{
+ # Display the form
+
my @stat = stat($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'});
+ # Insert file properties into the template
+
$tpl->fillin("MODE_OCTAL",$mode_oct);
$tpl->fillin("MODE_STRING",mode_string($mode));
$tpl->fillin("GID",$gid);
- $tpl->fillin("GROUP",$group);
+
+ if(my $group = getgrgid($gid))
+ {
+ $tpl->fillin("GROUP",encode_entities($group));
+ $tpl->parse_if_block("group_detected",1);
+ }
+ else
+ {
+ $tpl->parse_if_block("group_detected",0);
+ }
+
+ # Insert other information
$tpl->fillin("FILE",$virtual);
$tpl->fillin("DIR",$dir);
@@ -888,21 +904,21 @@ sub exec_about($$)
# Some path information
- $tpl->fillin("SCRIPT_PHYS",$ENV{'SCRIPT_FILENAME'});
- $tpl->fillin("CONFIG_PATH",$data->{'configfile'});
- $tpl->fillin("FILE_ROOT",$config->{'fileroot'});
- $tpl->fillin("HTTP_ROOT",$config->{'httproot'});
+ $tpl->fillin("SCRIPT_PHYS",encode_entities($ENV{'SCRIPT_FILENAME'}));
+ $tpl->fillin("CONFIG_PATH",encode_entities($data->{'configfile'}));
+ $tpl->fillin("FILE_ROOT", encode_entities($config->{'fileroot'}));
+ $tpl->fillin("HTTP_ROOT", encode_entities($config->{'httproot'}));
# Perl
- $tpl->fillin("PERL_PROG",$^X);
+ $tpl->fillin("PERL_PROG",encode_entities($^X));
$tpl->fillin("PERL_VER",sprintf("%vd",$^V));
# Information about the server
- $tpl->fillin("HTTPD",$ENV{'SERVER_SOFTWARE'});
+ $tpl->fillin("HTTPD",encode_entities($ENV{'SERVER_SOFTWARE'}));
$tpl->fillin("OS",$^O);
- $tpl->fillin("TIME",strftime($config->{'timeformat'},localtime));
+ $tpl->fillin("TIME",encode_entities(strftime($config->{'timeformat'},localtime)));
# Process information
@@ -927,8 +943,25 @@ sub exec_about($$)
# Names of user and group
- $tpl->fillin("USER",getpwuid($uid));
- $tpl->fillin("GROUP",getgrgid($gid));
+ if(my $user = getpwuid($uid))
+ {
+ $tpl->fillin("USER",encode_entities($user));
+ $tpl->parse_if_block("user_detected",1);
+ }
+ else
+ {
+ $tpl->parse_if_block("user_detected",0);
+ }
+
+ if(my $group = getgrgid($gid))
+ {
+ $tpl->fillin("GROUP",encode_entities($group));
+ $tpl->parse_if_block("group_detected",1);
+ }
+ else
+ {
+ $tpl->parse_if_block("group_detected",0);
+ }
# Process umask
diff --git a/modules/Tool.pm b/modules/Tool.pm
index c3548b0..2b73423 100644
--- a/modules/Tool.pm
+++ b/modules/Tool.pm
@@ -35,7 +35,7 @@ use base qw(Exporter);
# check_path()
#
-# Check, if a virtual path is above a virtual root directory
+# Check if a virtual path is above a virtual root directory
# (currently no check if the path exists - check otherwise!)
#
# Params: 1. Virtual root directory
diff --git a/templates/about.htm b/templates/about.htm
index 761be8f..8f2778a 100644
--- a/templates/about.htm
+++ b/templates/about.htm
@@ -204,12 +204,12 @@ WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
{IF users}
User: |
-{USER} (UID: {UID}) |
+{IF user_detected}{USER} ({ENDIF}UID: {UID}{IF user_detected}){ENDIF} |
Group: |
-{GROUP} (GID: {GID}) |
+{IF group_detected}{GROUP} ({ENDIF}GID: {GID}{IF group_detected}){ENDIF} |
diff --git a/templates/chprop.htm b/templates/chprop.htm
index e9df5b0..4a9fc3f 100644
--- a/templates/chprop.htm
+++ b/templates/chprop.htm
@@ -16,7 +16,7 @@
Current mode: {MODE_STRING} (Octal: {MODE_OCTAL})
-Current group: {GROUP} (GID: {GID})
+Current group: {IF group_detected}{GROUP} ({ENDIF}GID: {GID}{IF group_detected}){ENDIF}
--
2.34.1
From ea86dd1c2b813a085290e0e24040122c2487182b Mon Sep 17 00:00:00 2001
From: pcanterino <>
Date: Wed, 24 Nov 2004 16:56:04 +0000
Subject: [PATCH 11/16] - Check if the user really wants to upload a file to a
directory - Cleaned exec_show()
---
errors.dat | 1 +
modules/Command.pm | 29 ++++++++++++++++++++---------
2 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/errors.dat b/errors.dat
index 4121842..b09148f 100644
--- a/errors.dat
+++ b/errors.dat
@@ -25,6 +25,7 @@ noedit = You have not enough permissions to edit this file.
nocopy = You have not enough permissions to copy this file.
noview = You have not enough permissions to view this file.
no_dir_access = You have not enough permissions to access this directory.
+no_directory = '{FILE}' is not a directory.
no_root_access = You have not enough permissions to access the root directory.
no_root_dir = The root directory does not exist or is not a directory.
no_users = It seems that your system doesn't support users and groups.
diff --git a/modules/Command.pm b/modules/Command.pm
index 26bc5c8..84a0378 100644
--- a/modules/Command.pm
+++ b/modules/Command.pm
@@ -6,7 +6,7 @@ package Command;
# Execute Dev-Editor's commands
#
# Author: Patrick Canterino
-# Last modified: 2004-11-23
+# Last modified: 2004-11-24
#
use strict;
@@ -89,6 +89,7 @@ sub exec_show($$)
my ($data,$config) = @_;
my $physical = $data->{'physical'};
my $virtual = $data->{'virtual'};
+ my $upper_path = upper_path($virtual);
my $uselist = $data->{'uselist'};
my $tpl = new Template;
@@ -97,10 +98,10 @@ sub exec_show($$)
{
# Create directory listing
- return error($config->{'errors'}->{'no_dir_access'},upper_path($virtual)) unless(-r $physical && -x $physical);
+ return error($config->{'errors'}->{'no_dir_access'},$upper_path) unless(-r $physical && -x $physical);
my $direntries = dir_read($physical);
- return error($config->{'dir_read_fail'},upper_path($virtual),{DIR => $virtual}) unless($direntries);
+ return error($config->{'dir_read_fail'},$upper_path,{DIR => $virtual}) unless($direntries);
my $files = $direntries->{'files'};
my $dirs = $direntries->{'dirs'};
@@ -117,7 +118,7 @@ sub exec_show($$)
my $udtpl = new Template;
$udtpl->read_file($config->{'templates'}->{'dirlist_up'});
- $udtpl->fillin("UPPER_DIR",encode_entities(upper_path($virtual)));
+ $udtpl->fillin("UPPER_DIR",encode_entities($upper_path));
$udtpl->fillin("DATE",encode_entities(strftime($config->{'timeformat'},localtime($stat[9]))));
$dirlist .= $udtpl->get_template;
@@ -194,7 +195,7 @@ sub exec_show($$)
{
# View a file
- return error($config->{'errors'}->{'noview'},upper_path($virtual)) unless(-r $physical);
+ return error($config->{'errors'}->{'noview'},$upper_path) unless(-r $physical);
# Check on binary files
# We have to do it in this way, or empty files
@@ -204,17 +205,17 @@ sub exec_show($$)
{
# Binary file
- return error($config->{'errors'}->{'binary'},upper_path($virtual));
+ return error($config->{'errors'}->{'binary'},$upper_path);
}
else
{
# Text file
- my $size = (stat($physical))[7];
+ my $size = -s $physical;
if($config->{'max_file_size'} && $size > $config->{'max_file_size'})
{
- return error($config->{'errors'}->{'file_too_large'},upper_path($virtual),{SIZE => $config->{'max_file_size'}})
+ return error($config->{'errors'}->{'file_too_large'},$upper_path,{SIZE => $config->{'max_file_size'}})
}
else
{
@@ -224,7 +225,7 @@ sub exec_show($$)
$tpl->read_file($config->{'templates'}->{'viewfile'});
$tpl->fillin("FILE",$virtual);
- $tpl->fillin("DIR",upper_path($virtual));
+ $tpl->fillin("DIR",$upper_path);
$tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
$tpl->fillin("SCRIPT",$script);
@@ -480,6 +481,8 @@ sub exec_upload($$)
my $virtual = $data->{'virtual'};
my $cgi = $data->{'cgi'};
+ return error($config->{'errors'}->{'no_directory'},upper_path($virtual),{FILE => $virtual}) unless(-d $physical);
+
if(my $uploaded_file = $cgi->param('uploaded_file'))
{
# Process file upload
@@ -766,12 +769,18 @@ sub exec_chprop($$)
if($users)
{
+ # System supports user and groups
+
if(-o $physical)
{
+ # We own this file
+
if($mode || $group)
{
if($mode)
{
+ # Change the mode
+
my $oct_mode = $mode;
$oct_mode = "0".$oct_mode if(length($oct_mode) == 3);
$oct_mode = oct($oct_mode);
@@ -781,6 +790,8 @@ sub exec_chprop($$)
if($group)
{
+ # Change the group using the `chgrp` system command
+
return error($config->{'errors'}->{'invalid_group'},$dir,{GROUP => encode_entities($group)}) unless($group =~ /^[a-z0-9_]+[a-z0-9_-]*$/i);
system("chgrp",$group,$physical);
}
--
2.34.1
From 0577a1ece82df55f43840d9187fd5b150ec25361 Mon Sep 17 00:00:00 2001
From: pcanterino <>
Date: Thu, 25 Nov 2004 15:19:50 +0000
Subject: [PATCH 12/16] Some small changes
---
modules/Command.pm | 19 ++++++++-----------
modules/Config/DevEdit.pm | 4 ++--
2 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/modules/Command.pm b/modules/Command.pm
index 84a0378..f2b1a04 100644
--- a/modules/Command.pm
+++ b/modules/Command.pm
@@ -6,7 +6,7 @@ package Command;
# Execute Dev-Editor's commands
#
# Author: Patrick Canterino
-# Last modified: 2004-11-24
+# Last modified: 2004-11-25
#
use strict;
@@ -171,7 +171,6 @@ sub exec_show($$)
$ftpl->parse_if_block("readonly",not -w $phys_path);
$ftpl->parse_if_block("viewable",-r $phys_path && -T $phys_path && not ($config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'}));
-
$ftpl->parse_if_block("editable",-r $phys_path && -w $phys_path && -T $phys_path && not ($config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'}) && not $in_use);
$ftpl->parse_if_block("in_use",$in_use);
@@ -211,9 +210,7 @@ sub exec_show($$)
{
# Text file
- my $size = -s $physical;
-
- if($config->{'max_file_size'} && $size > $config->{'max_file_size'})
+ if($config->{'max_file_size'} && -s $physical > $config->{'max_file_size'})
{
return error($config->{'errors'}->{'file_too_large'},$upper_path,{SIZE => $config->{'max_file_size'}})
}
@@ -229,7 +226,7 @@ sub exec_show($$)
$tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
$tpl->fillin("SCRIPT",$script);
- $tpl->parse_if_block("editable",-r $physical && -w $physical && -T $physical && not ($config->{'max_file_size'} && $size > $config->{'max_file_size'}) && $uselist->unused($virtual));
+ $tpl->parse_if_block("editable",-w $physical && $uselist->unused($virtual));
$tpl->fillin("CONTENT",encode_entities($$content));
}
@@ -273,7 +270,7 @@ sub exec_beginedit($$)
}
else
{
- if($config->{'max_file_size'} && (-s $physical) > $config->{'max_file_size'})
+ if($config->{'max_file_size'} && -s $physical > $config->{'max_file_size'})
{
return error($config->{'errors'}->{'file_too_large'},$dir,{SIZE => $config->{'max_file_size'}})
}
@@ -489,7 +486,7 @@ sub exec_upload($$)
my $filename = file_name($uploaded_file);
my $file_phys = $physical."/".$filename;
- my $file_virt = $virtual."".$filename;
+ my $file_virt = $virtual.$filename;
return error($config->{'errors'}->{'file_exists'},$virtual,{FILE => $file_virt}) if(-e $file_phys && not $cgi->param('overwrite'));
@@ -498,7 +495,7 @@ sub exec_upload($$)
local *FILE;
- open(FILE,">$file_phys") or return error($config->{'errors'}->{'mkfile_failed'},$virtual,{FILE => $file_virt});
+ open(FILE,">".$file_phys) or return error($config->{'errors'}->{'mkfile_failed'},$virtual,{FILE => $file_virt});
binmode(FILE) unless($ascii);
# Read transferred file and write it to disk
@@ -543,8 +540,8 @@ sub exec_copy($$)
my $virtual = encode_entities($data->{'virtual'});
my $new_physical = $data->{'new_physical'};
- return error($config->{'errors'}->{'dircopy'}) if(-d $physical);
- return error($config->{'errors'}->{'nocopy'}) unless(-r $physical);
+ return error($config->{'errors'}->{'dircopy'},upper_path($virtual)) if(-d $physical);
+ return error($config->{'errors'}->{'nocopy'},upper_path($virtual)) unless(-r $physical);
if($new_physical)
{
diff --git a/modules/Config/DevEdit.pm b/modules/Config/DevEdit.pm
index fcad456..0286f5a 100644
--- a/modules/Config/DevEdit.pm
+++ b/modules/Config/DevEdit.pm
@@ -6,7 +6,7 @@ package Config::DevEdit;
# Read and parse the configuration files
#
# Author: Patrick Canterino
-# Last modified: 2004-10-28
+# Last modified: 2004-11-24
#
use strict;
@@ -53,7 +53,7 @@ sub parse_config($)
my $file = shift;
local *CF;
- open(CF,"<$file") or croak("Open $file: $!");
+ open(CF,"<".$file) or croak("Open $file: $!");
read(CF, my $data, -s $file);
close(CF);
--
2.34.1
From 4fb80b78acb8c336200b5fe20403bcb94c0aed98 Mon Sep 17 00:00:00 2001
From: pcanterino <>
Date: Fri, 26 Nov 2004 16:00:27 +0000
Subject: [PATCH 13/16] - Check if we have enough permissions to write in
directory at the following points: - Before executing a command which
creates a new file - Before uploading a file - Before removing or
moving/renaming a file or directory - oct() does not care about leading
zeros, the resulting value is always the same. - The name of the variable
which will be replaced by a directory to go back to in error.htm was
renamed from "{DIR}" to "{BACK}". "{DIR}" caused some problems. - Changed
the names of some error messages: nocopy -> no_copy noedit -> no_edit
noview -> no_view
---
devedit.pl | 10 +++++++++-
errors.dat | 9 ++++++---
modules/Command.pm | 30 +++++++++++++++++-------------
modules/Output.pm | 4 ++--
templates/chprop.htm | 2 +-
templates/dirlist_dir.htm | 2 +-
templates/dirlist_file.htm | 2 +-
templates/error.htm | 2 +-
8 files changed, 38 insertions(+), 23 deletions(-)
diff --git a/devedit.pl b/devedit.pl
index aa7a3ca..3ec92df 100644
--- a/devedit.pl
+++ b/devedit.pl
@@ -6,7 +6,7 @@
# Dev-Editor's main program
#
# Author: Patrick Canterino
-# Last modified: 2004-11-13
+# Last modified: 2004-11-26
#
use strict;
@@ -82,6 +82,14 @@ if($newfile ne '' && $newfile !~ /^\s+$/)
abort($config->{'errors'}->{'create_ar'},"/");
}
+ # Check if we have enough permissions to create a file
+ # in this directory
+
+ unless(-r $new_physical && -w $new_physical && -x $new_physical)
+ {
+ abort($config->{'errors'}->{'dir_no_create'},"/",{DIR => $new_virtual});
+ }
+
# Create the physical and the virtual path
$new_physical = File::Spec->canonpath($new_physical."/".$file);
diff --git a/errors.dat b/errors.dat
index b09148f..995e5f8 100644
--- a/errors.dat
+++ b/errors.dat
@@ -7,6 +7,7 @@ copy_failed = Could not copy '{FILE}' to '{NEW_FILE}'.
create_ar = You aren't allowed to create files and directories above the virtual root directory.
delete_failed = Could not delete file '{FILE}'.
dircopy = This editor is not able to copy directories.
+dir_no_create = You have not enough permissions to create a file in the directory '{DIRECTORY}'.
dir_not_exist = The directory where you want to create this file or directory doesn't exist.
dir_read_fail = Reading of directory '{DIR}' failed.
dir_replace = You are not allowed to replace a directory.
@@ -21,14 +22,16 @@ invalid_group = '{GROUP}' seems to be an invalid group name. Please check it an
lock_failed = Locking of '{USELIST}' failed. Try it again in a moment. If the problem persists, ask someone to recreate the lock file ('{LOCK_FILE}').
mkdir_failed = Could not create directory '{DIR}'.
mkfile_failed = Could not create file '{FILE}'.
-noedit = You have not enough permissions to edit this file.
-nocopy = You have not enough permissions to copy this file.
-noview = You have not enough permissions to view this file.
+no_copy = You have not enough permissions to copy this file.
+no_delete = You have not enough permissions to delete this file.
no_dir_access = You have not enough permissions to access this directory.
no_directory = '{FILE}' is not a directory.
+no_edit = You have not enough permissions to edit this file.
+no_rename = You have not enough permissions to move/rename this file.
no_root_access = You have not enough permissions to access the root directory.
no_root_dir = The root directory does not exist or is not a directory.
no_users = It seems that your system doesn't support users and groups.
+no_view = You have not enough permissions to view this file.
not_exist = File/directory does not exist.
not_owner = You are not the owner of '{FILE}', so you are not allowed to change the mode and the group.
remove_root = You are not allowed to remove the root directory.
diff --git a/modules/Command.pm b/modules/Command.pm
index f2b1a04..83739f0 100644
--- a/modules/Command.pm
+++ b/modules/Command.pm
@@ -6,7 +6,7 @@ package Command;
# Execute Dev-Editor's commands
#
# Author: Patrick Canterino
-# Last modified: 2004-11-25
+# Last modified: 2004-11-26
#
use strict;
@@ -106,6 +106,8 @@ sub exec_show($$)
my $files = $direntries->{'files'};
my $dirs = $direntries->{'dirs'};
+ my $dir_writeable = -w $physical;
+
my $dirlist = "";
# Create the link to the upper directory
@@ -156,6 +158,7 @@ sub exec_show($$)
my @stat = stat($phys_path);
my $in_use = $uselist->in_use($virtual.$file);
+ my $too_large = $config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'};
my $ftpl = new Template;
$ftpl->read_file($config->{'templates'}->{'dirlist_file'});
@@ -170,8 +173,8 @@ sub exec_show($$)
$ftpl->parse_if_block("binary",-B $phys_path);
$ftpl->parse_if_block("readonly",not -w $phys_path);
- $ftpl->parse_if_block("viewable",-r $phys_path && -T $phys_path && not ($config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'}));
- $ftpl->parse_if_block("editable",-r $phys_path && -w $phys_path && -T $phys_path && not ($config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'}) && not $in_use);
+ $ftpl->parse_if_block("viewable",-r $phys_path && -T $phys_path && not $too_large);
+ $ftpl->parse_if_block("editable",-r $phys_path && -w $phys_path && -T $phys_path && not $too_large && not $in_use);
$ftpl->parse_if_block("in_use",$in_use);
$ftpl->parse_if_block("unused",not $in_use);
@@ -189,12 +192,14 @@ sub exec_show($$)
$tpl->fillin("DIR",$virtual);
$tpl->fillin("SCRIPT",$script);
$tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+
+ $tpl->parse_if_block("dir_writeable",$dir_writeable);
}
else
{
# View a file
- return error($config->{'errors'}->{'noview'},$upper_path) unless(-r $physical);
+ return error($config->{'errors'}->{'no_view'},$upper_path) unless(-r $physical);
# Check on binary files
# We have to do it in this way, or empty files
@@ -258,7 +263,7 @@ sub exec_beginedit($$)
return error($config->{'errors'}->{'editdir'},$dir) if(-d $physical);
return error($config->{'errors'}->{'in_use'}, $dir,{FILE => $virtual}) if($uselist->in_use($virtual));
- return error($config->{'errors'}->{'noedit'}, $dir) unless(-r $physical && -w $physical);
+ return error($config->{'errors'}->{'no_edit'},$dir) unless(-r $physical && -w $physical);
# Check on binary files
@@ -370,7 +375,7 @@ sub exec_endedit($$)
return error($config->{'errors'}->{'text_to_binary'},$dir) unless(-T $physical);
return error($config->{'errors'}->{'editdir'},$dir) if(-d $physical);
- return error($config->{'errors'}->{'noedit'}, $dir) if(-e $physical && !(-r $physical && -w $physical));
+ return error($config->{'errors'}->{'no_edit'},$dir) if(-e $physical && !(-r $physical && -w $physical));
if(file_save($physical,\$content))
{
@@ -479,6 +484,7 @@ sub exec_upload($$)
my $cgi = $data->{'cgi'};
return error($config->{'errors'}->{'no_directory'},upper_path($virtual),{FILE => $virtual}) unless(-d $physical);
+ return error($config->{'errors'}->{'dir_no_create'},$virtual,{DIR => $virtual});
if(my $uploaded_file = $cgi->param('uploaded_file'))
{
@@ -541,7 +547,7 @@ sub exec_copy($$)
my $new_physical = $data->{'new_physical'};
return error($config->{'errors'}->{'dircopy'},upper_path($virtual)) if(-d $physical);
- return error($config->{'errors'}->{'nocopy'},upper_path($virtual)) unless(-r $physical);
+ return error($config->{'errors'}->{'no_copy'},upper_path($virtual)) unless(-r $physical);
if($new_physical)
{
@@ -616,6 +622,7 @@ sub exec_rename($$)
my $new_physical = $data->{'new_physical'};
return error($config->{'errors'}->{'rename_root'},"/") if($virtual eq "/");
+ return error($config->{'errors'}->{'no_rename'},upper_path($virtual)) unless(-w upper_path($physical));
return error($config->{'errors'}->{'in_use'},upper_path($virtual),{FILE => $virtual}) if($data->{'uselist'}->in_use($virtual));
if($new_physical)
@@ -689,7 +696,8 @@ sub exec_remove($$)
my $physical = $data->{'physical'};
my $virtual = $data->{'virtual'};
- return error($config->{'errors'}->{'remove_root'},"/") if($virtual eq "/");
+ return error($config->{'errors'}->{'remove_root'},"/") if($virtual eq "/");
+ return error($config->{'errors'}->{'no_delete'},upper_path($virtual)) unless(-w upper_path($physical));
if(-d $physical)
{
@@ -778,11 +786,7 @@ sub exec_chprop($$)
{
# Change the mode
- my $oct_mode = $mode;
- $oct_mode = "0".$oct_mode if(length($oct_mode) == 3);
- $oct_mode = oct($oct_mode);
-
- chmod($oct_mode,$physical);
+ chmod(oct($mode),$physical);
}
if($group)
diff --git a/modules/Output.pm b/modules/Output.pm
index 5fd22bf..9ab8697 100644
--- a/modules/Output.pm
+++ b/modules/Output.pm
@@ -6,7 +6,7 @@ package Output;
# HTML generating routines
#
# Author: Patrick Canterino
-# Last modified: 2004-11-13
+# Last modified: 2004-11-26
#
use strict;
@@ -59,7 +59,7 @@ sub error($;$$)
$tpl->read_file($tpl_error);
$tpl->fillin("ERROR",$message);
- $tpl->fillin("DIR",$path);
+ $tpl->fillin("BACK",$path);
$tpl->fillin("SCRIPT",encode_entities($ENV{'SCRIPT_NAME'}));
$tpl->parse_if_block("dir",defined $path);
diff --git a/templates/chprop.htm b/templates/chprop.htm
index 4a9fc3f..e5ed8f5 100644
--- a/templates/chprop.htm
+++ b/templates/chprop.htm
@@ -43,7 +43,7 @@
- Change mode:
-Use an octal number to change the mode of the file. You may use the three or four number form. For this, SetUID, SetGID and Sticky Bit are also supported.
+Use an octal number to change the mode of the file. SetUID, SetGID and Sticky Bit are also supported.
- Change group:
Enter the group name or the group ID the file should be assigned to. If a group name is also a numeric group ID, the value is used as a group name.
diff --git a/templates/dirlist_dir.htm b/templates/dirlist_dir.htm
index 6a1a740..cfac797 100644
--- a/templates/dirlist_dir.htm
+++ b/templates/dirlist_dir.htm
@@ -2,5 +2,5 @@
[SUBDIR] |
{DATE} |
{IF readable}{DIR_NAME}/{ELSE}{DIR_NAME}/{ENDIF} |
-(Rename | Delete |{IF users} Chmod/Chgrp |{ENDIF} View in Browser) |
+({IF dir_writeable}Rename | Delete | {ENDIF}{IF users}Chmod/Chgrp | {ENDIF}View in Browser) |
diff --git a/templates/dirlist_file.htm b/templates/dirlist_file.htm
index 1de43ca..720ae17 100644
--- a/templates/dirlist_file.htm
+++ b/templates/dirlist_file.htm
@@ -2,5 +2,5 @@
{SIZE} |
{DATE} |
{FILE_NAME} |
-({IF viewable}View{ELSE}View{ENDIF} | {IF editable}Edit{ELSE}Edit{ENDIF} | Copy{IF unused} | Rename | Delete{ENDIF}{IF in_use} | Unlock{ENDIF} |{IF users} Chmod/Chgrp |{ENDIF} View in Browser) |
+({IF viewable}View{ELSE}View{ENDIF} | {IF editable}Edit{ELSE}Edit{ENDIF} | Copy{IF unused}{IF dir_writeable} | Rename | Delete{ENDIF}{ENDIF}{IF in_use} | Unlock{ENDIF} |{IF users} Chmod/Chgrp |{ENDIF} View in Browser) |
diff --git a/templates/error.htm b/templates/error.htm
index 5698904..17abf7f 100644
--- a/templates/error.htm
+++ b/templates/error.htm
@@ -12,6 +12,6 @@
{ERROR}
{IF dir}
-Back to {DIR}
{ENDIF}
+Back to {BACK}
{ENDIF}