# Execute Dev-Editor's commands
#
# Author: Patrick Canterino <patrick@patshaping.de>
-# Last modified: 2004-12-16
+# Last modified: 2004-12-21
#
use strict;
}
}
- return error($config->{'errors'}->{'cmd_unknown'},'/',{COMMAND => $command});
+ return error($config->{'errors'}->{'cmd_unknown'},'/',{COMMAND => encode_entities($command)});
}
# exec_show()
$dtpl->fillin("DIR",$virt_path);
$dtpl->fillin("DIR_NAME",encode_entities($dir));
$dtpl->fillin("DATE",encode_entities(strftime($config->{'timeformat'},localtime($stat[9]))));
- $dtpl->fillin("URL",equal_url($config->{'httproot'},$virt_path));
+ $dtpl->fillin("URL",equal_url(encode_entities($config->{'httproot'}),$virt_path));
$dtpl->parse_if_block("readable",-r $phys_path && -x $phys_path);
$dtpl->parse_if_block("users",$users && -o $phys_path);
$ftpl->fillin("FILE_NAME",encode_entities($file));
$ftpl->fillin("SIZE",$stat[7]);
$ftpl->fillin("DATE",encode_entities(strftime($config->{'timeformat'},localtime($stat[9]))));
- $ftpl->fillin("URL",equal_url($config->{'httproot'},$virt_path));
+ $ftpl->fillin("URL",equal_url(encode_entities($config->{'httproot'}),$virt_path));
$ftpl->parse_if_block("not_readable",not -r $phys_path);
$ftpl->parse_if_block("binary",-B $phys_path);
$tpl->fillin("DIRLIST",$dirlist);
$tpl->fillin("DIR",encode_entities($virtual));
$tpl->fillin("SCRIPT",$script);
- $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("URL",encode_entities(equal_url($config->{'httproot'},$virtual)));
$tpl->parse_if_block("dir_writeable",$dir_writeable);
}
$tpl->fillin("FILE",encode_entities($virtual));
$tpl->fillin("DIR",$upper_path);
- $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("URL",encode_entities(equal_url($config->{'httproot'},$virtual)));
$tpl->fillin("SCRIPT",$script);
$tpl->parse_if_block("editable",-w $physical && $uselist->unused($virtual));
my $file_phys = $physical."/".$filename;
my $file_virt = $virtual.$filename;
- return error($config->{'errors'}->{'in_use'},$virtual,{FILE => $file_virt}) if($data->{'uselist'}->in_use($file_virt));
- return error($config->{'errors'}->{'file_exists'},$virtual,{FILE => $file_virt}) if(-e $file_phys && not $cgi->param('overwrite'));
+ return error($config->{'errors'}->{'in_use'},$virtual,{FILE => $file_virt}) if($data->{'uselist'}->in_use($file_virt));
+
+ if(-e $file_phys)
+ {
+ return error($config->{'errors'}->{'dir_replace'},$virtual) if(-d $file_phys);
+ return error($config->{'errors'}->{'exist_no_write'},$virtual,{FILE => $file_virt}) unless(-w $file_phys);
+ return error($config->{'errors'}->{'file_exists'},$virtual,{FILE => $file_virt}) unless($cgi->param('overwrite'));
+ }
my $ascii = $cgi->param('ascii');
my $handle = $cgi->upload('uploaded_file');
- local *FILE;
-
- 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
read($handle, my $data, -s $handle);
$data =~ s/\015\012|\012|\015/\n/g if($ascii); # Replace line separators if transferring in ASCII mode
- print FILE $data;
-
- close(FILE);
+ file_save($file_phys,\$data,not $ascii) or return error($config->{'errors'}->{'mkfile_failed'},$virtual,{FILE => $file_virt});
return devedit_reload({command => "show", file => $virtual});
}
my $dir = upper_path($virtual);
my $new_physical = $data->{'new_physical'};
- return error($config->{'errors'}->{'dircopy'},upper_path($virtual)) if(-d $physical);
- return error($config->{'errors'}->{'no_copy'},upper_path($virtual)) unless(-r $physical);
+ return error($config->{'errors'}->{'dircopy'},$dir) if(-d $physical);
+ return error($config->{'errors'}->{'no_copy'},$dir) unless(-r $physical);
if($new_physical)
{
if(-e $new_physical)
{
- return error($config->{'errors'}->{'exist_edited'},$new_dir,{FILE => $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
+ return error($config->{'errors'}->{'exist_edited'},$new_dir,{FILE => $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
+ return error($config->{'errors'}->{'dir_replace'},$new_dir) if(-d $new_physical);
+ return error($config->{'errors'}->{'exist_no_write'},$new_dir,{FILE => $new_virtual}) unless(-w $new_physical);
- if(-d $new_physical)
- {
- return error($config->{'errors'}->{'dir_replace'},$new_dir);
- }
- elsif(not $data->{'cgi'}->param('confirmed'))
+ if(not $data->{'cgi'}->param('confirmed'))
{
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'confirm_replace'});
my $dir = upper_path($virtual);
my $new_physical = $data->{'new_physical'};
- return error($config->{'errors'}->{'rename_root'},"/") if($virtual eq "/");
- return error($config->{'errors'}->{'no_rename'},$dir) unless(-w upper_path($physical));
+ return error($config->{'errors'}->{'rename_root'},"/") if($virtual eq "/");
+ return error($config->{'errors'}->{'no_rename'},$dir) unless(-w upper_path($physical));
return error($config->{'errors'}->{'in_use'},$dir,{FILE => $virtual}) if($data->{'uselist'}->in_use($virtual));
if($new_physical)
if(-e $new_physical)
{
- return error($config->{'errors'}->{'exist_edited'},$new_dir,{FILE => $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
+ return error($config->{'errors'}->{'exist_edited'},$new_dir,{FILE => $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
+ return error($config->{'errors'}->{'dir_replace'},$new_dir) if(-d $new_physical);
+ return error($config->{'errors'}->{'exist_no_write'},$new_dir,{FILE => $new_virtual}) unless(-w $new_physical);
- if(-d $new_physical)
- {
- return error($config->{'errors'}->{'dir_replace'},$new_dir);
- }
- elsif(not $data->{'cgi'}->param('confirmed'))
+ if(not $data->{'cgi'}->param('confirmed'))
{
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'confirm_replace'});