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
# Dev-Editor's main program
#
# Author: Patrick Canterino <patshaping@gmx.net>
# Dev-Editor's main program
#
# Author: Patrick Canterino <patshaping@gmx.net>
-# Last modified: 2004-11-13
+# Last modified: 2004-11-26
abort($config->{'errors'}->{'create_ar'},"/");
}
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);
# Create the physical and the virtual path
$new_physical = File::Spec->canonpath($new_physical."/".$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.
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.
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.
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}'.
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_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_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.
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.
# Execute Dev-Editor's commands
#
# Author: Patrick Canterino <patshaping@gmx.net>
# Execute Dev-Editor's commands
#
# Author: Patrick Canterino <patshaping@gmx.net>
-# Last modified: 2004-11-25
+# Last modified: 2004-11-26
my $files = $direntries->{'files'};
my $dirs = $direntries->{'dirs'};
my $files = $direntries->{'files'};
my $dirs = $direntries->{'dirs'};
+ my $dir_writeable = -w $physical;
+
my $dirlist = "";
# Create the link to the upper directory
my $dirlist = "";
# Create the link to the upper directory
my @stat = stat($phys_path);
my $in_use = $uselist->in_use($virtual.$file);
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'});
my $ftpl = new Template;
$ftpl->read_file($config->{'templates'}->{'dirlist_file'});
$ftpl->parse_if_block("binary",-B $phys_path);
$ftpl->parse_if_block("readonly",not -w $phys_path);
$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);
$ftpl->parse_if_block("in_use",$in_use);
$ftpl->parse_if_block("unused",not $in_use);
$tpl->fillin("DIR",$virtual);
$tpl->fillin("SCRIPT",$script);
$tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
$tpl->fillin("DIR",$virtual);
$tpl->fillin("SCRIPT",$script);
$tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+
+ $tpl->parse_if_block("dir_writeable",$dir_writeable);
- 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
# Check on binary files
# We have to do it in this way, or empty files
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'}->{'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);
return error($config->{'errors'}->{'text_to_binary'},$dir) unless(-T $physical);
return error($config->{'errors'}->{'editdir'},$dir) if(-d $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));
+ return error($config->{'errors'}->{'no_edit'},$dir) if(-e $physical && !(-r $physical && -w $physical));
if(file_save($physical,\$content))
{
if(file_save($physical,\$content))
{
my $cgi = $data->{'cgi'};
return error($config->{'errors'}->{'no_directory'},upper_path($virtual),{FILE => $virtual}) unless(-d $physical);
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'))
{
if(my $uploaded_file = $cgi->param('uploaded_file'))
{
my $new_physical = $data->{'new_physical'};
return error($config->{'errors'}->{'dircopy'},upper_path($virtual)) if(-d $physical);
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);
my $new_physical = $data->{'new_physical'};
return error($config->{'errors'}->{'rename_root'},"/") if($virtual eq "/");
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)
return error($config->{'errors'}->{'in_use'},upper_path($virtual),{FILE => $virtual}) if($data->{'uselist'}->in_use($virtual));
if($new_physical)
my $physical = $data->{'physical'};
my $virtual = $data->{'virtual'};
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));
- 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);
# HTML generating routines
#
# Author: Patrick Canterino <patshaping@gmx.net>
# HTML generating routines
#
# Author: Patrick Canterino <patshaping@gmx.net>
-# Last modified: 2004-11-13
+# Last modified: 2004-11-26
$tpl->read_file($tpl_error);
$tpl->fillin("ERROR",$message);
$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);
$tpl->fillin("SCRIPT",encode_entities($ENV{'SCRIPT_NAME'}));
$tpl->parse_if_block("dir",defined $path);
<ul>
<li><b>Change mode:</b><br>
<ul>
<li><b>Change mode:</b><br>
-Use an <b>octal</b> 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.</li>
+Use an <b>octal</b> number to change the mode of the file. SetUID, SetGID and Sticky Bit are also supported.</li>
<li><b>Change group:</b><br>
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.</li>
</ul>
<li><b>Change group:</b><br>
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.</li>
</ul>
<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;">{IF readable}<a href="{SCRIPT}?command=show&file={DIR}">{DIR_NAME}/</a>{ELSE}<span style="color:#C0C0C0" title="Not accessible">{DIR_NAME}/</span>{ENDIF}</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;">{IF readable}<a href="{SCRIPT}?command=show&file={DIR}">{DIR_NAME}/</a>{ELSE}<span style="color:#C0C0C0" title="Not accessible">{DIR_NAME}/</span>{ENDIF}</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>
+<td style="padding-left:15pt;white-space:nowrap;">({IF dir_writeable}<a href="{SCRIPT}?command=rename&file={DIR}">Rename</a> | <a href="{SCRIPT}?command=remove&file={DIR}">Delete</a> | {ENDIF}{IF users}<a href="{SCRIPT}?command=chprop&file={DIR}">Chmod/Chgrp</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 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>
+<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}{IF dir_writeable} | <a href="{SCRIPT}?command=rename&file={FILE}">Rename</a> | <a href="{SCRIPT}?command=remove&file={FILE}">Delete</a>{ENDIF}{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>
-<p><a href="{SCRIPT}?command=show&file={DIR}">Back to {DIR}</a></p>{ENDIF}
+<p><a href="{SCRIPT}?command=show&file={BACK}">Back to {BACK}</a></p>{ENDIF}
</body>
</html>
\ No newline at end of file
</body>
</html>
\ No newline at end of file