summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
f9e51fc)
clean_path(). It is unnecessary and it also caused a problem if this path
would begin with /../, because on UNIX systems, canonpath() removes /../ at
the beginning of a path. So if a user wanted to create the file /../file.ext
(which he wasn't allowed to), he created /file.ext.
- file_name() and upper_path() now remove multiple trailing slashes
- Improved configuration file parser:
- Allow configuration options with empty values
- If a option is defined twice, the line number is shown in the error message
- Static values are now surrounded by single quotes. Maybe it helps to increase
the speed of Dev-Editor, because Perl doesn't have to try to interpolate
variables in the values.
# Dev-Editor's main program
#
# Author: Patrick Canterino <patrick@patshaping.de>
# Dev-Editor's main program
#
# Author: Patrick Canterino <patrick@patshaping.de>
-# Last modified: 2004-12-29
+# Last modified: 2005-01-06
if($newfile ne '' && $newfile !~ /^\s+$/)
{
$curdir = upper_path($file) if($curdir eq '');
if($newfile ne '' && $newfile !~ /^\s+$/)
{
$curdir = upper_path($file) if($curdir eq '');
- my $path = clean_path($curdir.$newfile);
+ my $path = $curdir.$newfile;
# Extract file and directory name...
# Extract file and directory name...
# ... check if the directory exists ...
# ... check if the directory exists ...
- unless(-d clean_path($config->{'fileroot'}."/".$dir))
+ unless(-d clean_path($config->{'fileroot'}.'/'.$dir))
- abort($config->{'errors'}->{'dir_not_exist'},"/");
+ abort($config->{'errors'}->{'dir_not_exist'},'/');
}
# ... and check if the path is above the root directory
unless(($new_physical,$new_virtual) = check_path($config->{'fileroot'},$dir))
{
}
# ... and check if the path is above the root directory
unless(($new_physical,$new_virtual) = check_path($config->{'fileroot'},$dir))
{
- abort($config->{'errors'}->{'create_ar'},"/");
+ abort($config->{'errors'}->{'create_ar'},'/');
}
# Check if we have enough permissions to create a file
}
# Check if we have enough permissions to create a file
unless(-r $new_physical && -w $new_physical && -x $new_physical)
{
unless(-r $new_physical && -w $new_physical && -x $new_physical)
{
- abort($config->{'errors'}->{'dir_no_create'},"/",{DIR => $new_virtual});
+ abort($config->{'errors'}->{'dir_no_create'},'/',{DIR => $new_virtual});
}
# Create the physical and the virtual path
}
# Create the physical and the virtual path
- $new_physical = File::Spec->canonpath($new_physical."/".$file);
+ $new_physical = File::Spec->canonpath($new_physical.'/'.$file);
$new_virtual .= $file;
}
# This check has to be performed first or abs_path() will be confused
$new_virtual .= $file;
}
# This check has to be performed first or abs_path() will be confused
-if(-e clean_path($config->{'fileroot'}."/".$file))
+if(-e clean_path($config->{'fileroot'}.'/'.$file))
{
if(my ($physical,$virtual) = check_path($config->{'fileroot'},$file))
{
{
if(my ($physical,$virtual) = check_path($config->{'fileroot'},$file))
{
- abort($config->{'errors'}->{'above_root'},"/");
+ abort($config->{'errors'}->{'above_root'},'/');
- abort($config->{'errors'}->{'not_exist'},"/");
+ abort($config->{'errors'}->{'not_exist'},'/');
# Execute Dev-Editor's commands
#
# Author: Patrick Canterino <patrick@patshaping.de>
# Execute Dev-Editor's commands
#
# Author: Patrick Canterino <patrick@patshaping.de>
-# Last modified: 2005-01-05
+# Last modified: 2005-01-06
use Template;
my $script = encode_entities($ENV{'SCRIPT_NAME'});
use Template;
my $script = encode_entities($ENV{'SCRIPT_NAME'});
-my $users = eval("getpwuid(0)") && eval("getgrgid(0)");
+my $users = eval('getpwuid(0)') && eval('getgrgid(0)');
my %dispatch = ('show' => \&exec_show,
'beginedit' => \&exec_beginedit,
my %dispatch = ('show' => \&exec_show,
'beginedit' => \&exec_beginedit,
my $dir_writeable = -w $physical;
my $dir_writeable = -w $physical;
my $filter1 = $data->{'cgi'}->param('filter') || '*'; # The real wildcard
my $filter2 = ($filter1 && $filter1 ne '*') ? $filter1 : ''; # Wildcard for output
my $filter1 = $data->{'cgi'}->param('filter') || '*'; # The real wildcard
my $filter2 = ($filter1 && $filter1 ne '*') ? $filter1 : ''; # Wildcard for output
# Create the link to the upper directory
# (only if we are not in the root directory)
# Create the link to the upper directory
# (only if we are not in the root directory)
- unless($virtual eq "/")
+ unless($virtual eq '/')
- my @stat = stat($physical."/..");
+ my @stat = stat($physical.'/..');
my $udtpl = new Template;
$udtpl->read_file($config->{'templates'}->{'dirlist_up'});
my $udtpl = new Template;
$udtpl->read_file($config->{'templates'}->{'dirlist_up'});
- $udtpl->fillin("UPPER_DIR",$upper_path);
- $udtpl->fillin("DATE",encode_entities(strftime($config->{'timeformat'},localtime($stat[9]))));
+ $udtpl->fillin('UPPER_DIR',$upper_path);
+ $udtpl->fillin('DATE',encode_entities(strftime($config->{'timeformat'},localtime($stat[9]))));
$dirlist .= $udtpl->get_template;
}
$dirlist .= $udtpl->get_template;
}
{
next unless(dos_wildcard_match($filter1,$dir));
{
next unless(dos_wildcard_match($filter1,$dir));
- my $phys_path = $physical."/".$dir;
- my $virt_path = encode_entities($virtual.$dir."/");
+ my $phys_path = $physical.'/'.$dir;
+ my $virt_path = encode_entities($virtual.$dir.'/');
my @stat = stat($phys_path);
my $dtpl = new Template;
$dtpl->read_file($config->{'templates'}->{'dirlist_dir'});
my @stat = stat($phys_path);
my $dtpl = new Template;
$dtpl->read_file($config->{'templates'}->{'dirlist_dir'});
- $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(encode_entities($config->{'httproot'}),$virt_path));
+ $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(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);
+ $dtpl->parse_if_block('readable',-r $phys_path && -x $phys_path);
+ $dtpl->parse_if_block('users',$users && -o $phys_path);
$dirlist .= $dtpl->get_template;
}
$dirlist .= $dtpl->get_template;
}
{
next unless(dos_wildcard_match($filter1,$file));
{
next unless(dos_wildcard_match($filter1,$file));
- my $phys_path = $physical."/".$file;
+ my $phys_path = $physical.'/'.$file;
my $virt_path = encode_entities($virtual.$file);
my @stat = stat($phys_path);
my $virt_path = encode_entities($virtual.$file);
my @stat = stat($phys_path);
my $ftpl = new Template;
$ftpl->read_file($config->{'templates'}->{'dirlist_file'});
my $ftpl = new Template;
$ftpl->read_file($config->{'templates'}->{'dirlist_file'});
- $ftpl->fillin("FILE",$virt_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(encode_entities($config->{'httproot'}),$virt_path));
+ $ftpl->fillin('FILE',$virt_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(encode_entities($config->{'httproot'}),$virt_path));
- $ftpl->parse_if_block("not_readable",not -r $phys_path);
- $ftpl->parse_if_block("binary",-B $phys_path);
- $ftpl->parse_if_block("readonly",not -w $phys_path);
+ $ftpl->parse_if_block('not_readable',not -r $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 $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('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);
- $ftpl->parse_if_block("too_large",$config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'});
+ $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);
+ $ftpl->parse_if_block('users',$users && -o $phys_path);
$dirlist .= $ftpl->get_template;
}
$tpl->read_file($config->{'templates'}->{'dirlist'});
$dirlist .= $ftpl->get_template;
}
$tpl->read_file($config->{'templates'}->{'dirlist'});
- $tpl->fillin("DIRLIST",$dirlist);
- $tpl->fillin("DIR",encode_entities($virtual));
- $tpl->fillin("SCRIPT",$script);
- $tpl->fillin("URL",encode_entities(equal_url($config->{'httproot'},$virtual)));
+ $tpl->fillin('DIRLIST',$dirlist);
+ $tpl->fillin('DIR',encode_entities($virtual));
+ $tpl->fillin('SCRIPT',$script);
+ $tpl->fillin('URL',encode_entities(equal_url($config->{'httproot'},$virtual)));
- $tpl->fillin("FILTER",encode_entities($filter2));
- $tpl->fillin("FILTER_URL",escape($filter2));
+ $tpl->fillin('FILTER',encode_entities($filter2));
+ $tpl->fillin('FILTER_URL',escape($filter2));
- $tpl->parse_if_block("dir_writeable",$dir_writeable);
- $tpl->parse_if_block("filter",$filter2);
+ $tpl->parse_if_block('dir_writeable',$dir_writeable);
+ $tpl->parse_if_block('filter',$filter2);
$tpl->read_file($config->{'templates'}->{'viewfile'});
$tpl->read_file($config->{'templates'}->{'viewfile'});
- $tpl->fillin("FILE",encode_entities($virtual));
- $tpl->fillin("DIR",$upper_path);
- $tpl->fillin("URL",encode_entities(equal_url($config->{'httproot'},$virtual)));
- $tpl->fillin("SCRIPT",$script);
+ $tpl->fillin('FILE',encode_entities($virtual));
+ $tpl->fillin('DIR',$upper_path);
+ $tpl->fillin('URL',encode_entities(equal_url($config->{'httproot'},$virtual)));
+ $tpl->fillin('SCRIPT',$script);
- $tpl->parse_if_block("editable",-w $physical && $uselist->unused($virtual));
+ $tpl->parse_if_block('editable',-w $physical && $uselist->unused($virtual));
- $tpl->fillin("CONTENT",encode_entities($$content));
+ $tpl->fillin('CONTENT',encode_entities($$content));
- my $output = header(-type => "text/html");
+ my $output = header(-type => 'text/html');
$output .= $tpl->get_template;
return \$output;
$output .= $tpl->get_template;
return \$output;
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'editfile'});
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'editfile'});
- $tpl->fillin("FILE",$virtual);
- $tpl->fillin("DIR",$dir);
- $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
- $tpl->fillin("SCRIPT",$script);
- $tpl->fillin("CONTENT",encode_entities($$content));
+ $tpl->fillin('FILE',$virtual);
+ $tpl->fillin('DIR',$dir);
+ $tpl->fillin('URL',equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin('SCRIPT',$script);
+ $tpl->fillin('CONTENT',encode_entities($$content));
- my $output = header(-type => "text/html");
+ my $output = header(-type => 'text/html');
$output .= $tpl->get_template;
return \$output;
$output .= $tpl->get_template;
return \$output;
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'mkfile'});
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'mkfile'});
- $tpl->fillin("DIR","/");
- $tpl->fillin("SCRIPT",$script);
+ $tpl->fillin('DIR','/');
+ $tpl->fillin('SCRIPT',$script);
- my $output = header(-type => "text/html");
+ my $output = header(-type => 'text/html');
$output .= $tpl->get_template;
return \$output;
$output .= $tpl->get_template;
return \$output;
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'mkdir'});
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'mkdir'});
- $tpl->fillin("DIR","/");
- $tpl->fillin("SCRIPT",$script);
+ $tpl->fillin('DIR','/');
+ $tpl->fillin('SCRIPT',$script);
- my $output = header(-type => "text/html");
+ my $output = header(-type => 'text/html');
$output .= $tpl->get_template;
return \$output;
$output .= $tpl->get_template;
return \$output;
# Process file upload
my $filename = file_name($uploaded_file);
# Process file upload
my $filename = file_name($uploaded_file);
- my $file_phys = $physical."/".$filename;
+ 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));
my $file_virt = $virtual.$filename;
return error($config->{'errors'}->{'in_use'},$virtual,{FILE => $file_virt}) if($data->{'uselist'}->in_use($file_virt));
$data =~ s/\015\012|\012|\015/\n/g if($ascii); # Replace line separators if transferring in ASCII mode
file_save($file_phys,\$data,not $ascii) or return error($config->{'errors'}->{'mkfile_failed'},$virtual,{FILE => $file_virt});
$data =~ s/\015\012|\012|\015/\n/g if($ascii); # Replace line separators if transferring in ASCII mode
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});
+ return devedit_reload({command => 'show', file => $virtual});
}
else
{
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'upload'});
}
else
{
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'upload'});
- $tpl->fillin("DIR",$virtual);
- $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
- $tpl->fillin("SCRIPT",$script);
+ $tpl->fillin('DIR',$virtual);
+ $tpl->fillin('URL',equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin('SCRIPT',$script);
- my $output = header(-type => "text/html");
+ my $output = header(-type => 'text/html');
$output .= $tpl->get_template;
return \$output;
$output .= $tpl->get_template;
return \$output;
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'confirm_replace'});
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'confirm_replace'});
- $tpl->fillin("FILE",$virtual);
- $tpl->fillin("NEW_FILE",$new_virtual);
- $tpl->fillin("NEW_FILENAME",file_name($new_virtual));
- $tpl->fillin("NEW_DIR",$new_dir);
- $tpl->fillin("DIR",$dir);
+ $tpl->fillin('FILE',$virtual);
+ $tpl->fillin('NEW_FILE',$new_virtual);
+ $tpl->fillin('NEW_FILENAME',file_name($new_virtual));
+ $tpl->fillin('NEW_DIR',$new_dir);
+ $tpl->fillin('DIR',$dir);
- $tpl->fillin("COMMAND","copy");
- $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
- $tpl->fillin("SCRIPT",$script);
+ $tpl->fillin('COMMAND','copy');
+ $tpl->fillin('URL',equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin('SCRIPT',$script);
- my $output = header(-type => "text/html");
+ my $output = header(-type => 'text/html');
$output .= $tpl->get_template;
return \$output;
$output .= $tpl->get_template;
return \$output;
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'copyfile'});
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'copyfile'});
- $tpl->fillin("FILE",$virtual);
- $tpl->fillin("DIR",$dir);
- $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
- $tpl->fillin("SCRIPT",$script);
+ $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");
+ my $output = header(-type => 'text/html');
$output .= $tpl->get_template;
return \$output;
$output .= $tpl->get_template;
return \$output;
my $dir = upper_path($virtual);
my $new_physical = $data->{'new_physical'};
my $dir = upper_path($virtual);
my $new_physical = $data->{'new_physical'};
- return error($config->{'errors'}->{'rename_root'},"/") if($virtual eq "/");
+ 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));
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));
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'confirm_replace'});
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'confirm_replace'});
- $tpl->fillin("FILE",$virtual);
- $tpl->fillin("NEW_FILE",$new_virtual);
- $tpl->fillin("NEW_FILENAME",file_name($new_virtual));
- $tpl->fillin("NEW_DIR",$new_dir);
- $tpl->fillin("DIR",$dir);
+ $tpl->fillin('FILE',$virtual);
+ $tpl->fillin('NEW_FILE',$new_virtual);
+ $tpl->fillin('NEW_FILENAME',file_name($new_virtual));
+ $tpl->fillin('NEW_DIR',$new_dir);
+ $tpl->fillin('DIR',$dir);
- $tpl->fillin("COMMAND","rename");
- $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
- $tpl->fillin("SCRIPT",$script);
+ $tpl->fillin('COMMAND','rename');
+ $tpl->fillin('URL',equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin('SCRIPT',$script);
- my $output = header(-type => "text/html");
+ my $output = header(-type => 'text/html');
$output .= $tpl->get_template;
return \$output;
$output .= $tpl->get_template;
return \$output;
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'renamefile'});
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'renamefile'});
- $tpl->fillin("FILE",$virtual);
- $tpl->fillin("DIR",$dir);
- $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
- $tpl->fillin("SCRIPT",$script);
+ $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");
+ my $output = header(-type => 'text/html');
$output .= $tpl->get_template;
return \$output;
$output .= $tpl->get_template;
return \$output;
my $virtual = $data->{'virtual'};
my $dir = upper_path($virtual);
my $virtual = $data->{'virtual'};
my $dir = upper_path($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'},$dir) unless(-w upper_path($physical));
if(-d $physical)
return error($config->{'errors'}->{'no_delete'},$dir) unless(-w upper_path($physical));
if(-d $physical)
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'confirm_rmdir'});
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'confirm_rmdir'});
- $tpl->fillin("DIR",$virtual);
- $tpl->fillin("UPPER_DIR",$dir);
- $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
- $tpl->fillin("SCRIPT",$script);
+ $tpl->fillin('DIR',$virtual);
+ $tpl->fillin('UPPER_DIR',$dir);
+ $tpl->fillin('URL',equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin('SCRIPT',$script);
- my $output = header(-type => "text/html");
+ my $output = header(-type => 'text/html');
$output .= $tpl->get_template;
return \$output;
$output .= $tpl->get_template;
return \$output;
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'confirm_rmfile'});
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'confirm_rmfile'});
- $tpl->fillin("FILE",$virtual);
- $tpl->fillin("DIR",$dir);
- $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
- $tpl->fillin("SCRIPT",$script);
+ $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");
+ my $output = header(-type => 'text/html');
$output .= $tpl->get_template;
return \$output;
$output .= $tpl->get_template;
return \$output;
my $dir = upper_path($virtual);
return error($config->{'errors'}->{'no_users'},$dir,{FILE => $virtual}) unless($users);
my $dir = upper_path($virtual);
return error($config->{'errors'}->{'no_users'},$dir,{FILE => $virtual}) unless($users);
- return error($config->{'errors'}->{'chprop_root'},"/") if($virtual eq "/");
+ return error($config->{'errors'}->{'chprop_root'},'/') if($virtual eq '/');
return error($config->{'errors'}->{'not_owner'},$dir,{FILE => $virtual}) unless(-o $physical);
return error($config->{'errors'}->{'in_use'},$dir,{FILE => $virtual}) if($data->{'uselist'}->in_use($virtual));
return error($config->{'errors'}->{'not_owner'},$dir,{FILE => $virtual}) unless(-o $physical);
return error($config->{'errors'}->{'in_use'},$dir,{FILE => $virtual}) if($data->{'uselist'}->in_use($virtual));
# 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);
# 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);
+ system('chgrp',$group,$physical);
}
return devedit_reload({command => 'show', file => $dir});
}
return devedit_reload({command => 'show', file => $dir});
# Insert file properties into the template
# Insert file properties into the template
- $tpl->fillin("MODE_OCTAL",substr(sprintf("%04o",$mode),-4));
- $tpl->fillin("MODE_STRING",mode_string($mode));
- $tpl->fillin("GID",$gid);
+ $tpl->fillin('MODE_OCTAL',substr(sprintf('%04o',$mode),-4));
+ $tpl->fillin('MODE_STRING',mode_string($mode));
+ $tpl->fillin('GID',$gid);
if(my $group = getgrgid($gid))
{
if(my $group = getgrgid($gid))
{
- $tpl->fillin("GROUP",encode_entities($group));
- $tpl->parse_if_block("group_detected",1);
+ $tpl->fillin('GROUP',encode_entities($group));
+ $tpl->parse_if_block('group_detected',1);
- $tpl->parse_if_block("group_detected",0);
+ $tpl->parse_if_block('group_detected',0);
}
# Insert other information
}
# Insert other information
- $tpl->fillin("FILE",$virtual);
- $tpl->fillin("DIR",$dir);
- $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
- $tpl->fillin("SCRIPT",$script);
+ $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");
+ my $output = header(-type => 'text/html');
$output .= $tpl->get_template;
return \$output;
$output .= $tpl->get_template;
return \$output;
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'confirm_unlock'});
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'confirm_unlock'});
- $tpl->fillin("FILE",$virtual);
- $tpl->fillin("DIR",$dir);
- $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
- $tpl->fillin("SCRIPT",$script);
+ $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");
+ my $output = header(-type => 'text/html');
$output .= $tpl->get_template;
return \$output;
$output .= $tpl->get_template;
return \$output;
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'about'});
my $tpl = new Template;
$tpl->read_file($config->{'templates'}->{'about'});
- $tpl->fillin("SCRIPT",$script);
+ $tpl->fillin('SCRIPT',$script);
# Dev-Editor's version number
# Dev-Editor's version number
- $tpl->fillin("VERSION",$data->{'version'});
+ $tpl->fillin('VERSION',$data->{'version'});
- $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'}));
+ $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'}));
- $tpl->fillin("PERL_PROG",encode_entities($^X));
- $tpl->fillin("PERL_VER", sprintf("%vd",$^V));
+ $tpl->fillin('PERL_PROG',encode_entities($^X));
+ $tpl->fillin('PERL_VER', sprintf('%vd',$^V));
# Information about the server
# Information about the server
- $tpl->fillin("HTTPD",encode_entities($ENV{'SERVER_SOFTWARE'}));
- $tpl->fillin("OS", encode_entities($^O));
- $tpl->fillin("TIME", encode_entities(strftime($config->{'timeformat'},localtime)));
+ $tpl->fillin('HTTPD',encode_entities($ENV{'SERVER_SOFTWARE'}));
+ $tpl->fillin('OS', encode_entities($^O));
+ $tpl->fillin('TIME', encode_entities(strftime($config->{'timeformat'},localtime)));
- $tpl->fillin("PID",$$);
+ $tpl->fillin('PID',$$);
# Check if the functions getpwuid() and getgrgid() are available
# Check if the functions getpwuid() and getgrgid() are available
my $uid = POSIX::getuid;
my $gid = POSIX::getgid;
my $uid = POSIX::getuid;
my $gid = POSIX::getgid;
- $tpl->parse_if_block("users",1);
+ $tpl->parse_if_block('users',1);
- $tpl->fillin("UID",$uid);
- $tpl->fillin("GID",$gid);
+ $tpl->fillin('UID',$uid);
+ $tpl->fillin('GID',$gid);
# Names of user and group
if(my $user = getpwuid($uid))
{
# Names of user and group
if(my $user = getpwuid($uid))
{
- $tpl->fillin("USER",encode_entities($user));
- $tpl->parse_if_block("user_detected",1);
+ $tpl->fillin('USER',encode_entities($user));
+ $tpl->parse_if_block('user_detected',1);
- $tpl->parse_if_block("user_detected",0);
+ $tpl->parse_if_block('user_detected',0);
}
if(my $group = getgrgid($gid))
{
}
if(my $group = getgrgid($gid))
{
- $tpl->fillin("GROUP",encode_entities($group));
- $tpl->parse_if_block("group_detected",1);
+ $tpl->fillin('GROUP',encode_entities($group));
+ $tpl->parse_if_block('group_detected',1);
- $tpl->parse_if_block("group_detected",0);
+ $tpl->parse_if_block('group_detected',0);
- $tpl->fillin("UMASK",sprintf("%04o",umask));
+ $tpl->fillin('UMASK',sprintf('%04o',umask));
- $tpl->parse_if_block("users",0);
+ $tpl->parse_if_block('users',0);
- my $output = header(-type => "text/html");
+ my $output = header(-type => 'text/html');
$output .= $tpl->get_template;
return \$output;
$output .= $tpl->get_template;
return \$output;
# Read and parse the configuration files
#
# Author: Patrick Canterino <patrick@patshaping.de>
# Read and parse the configuration files
#
# Author: Patrick Canterino <patrick@patshaping.de>
-# Last modified: 2004-12-31
+# Last modified: 2005-01-06
my $file = shift;
local *CF;
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);
my @lines = split(/\015\012|\012|\015/,$data);
my $config = {};
read(CF, my $data, -s $file);
close(CF);
my @lines = split(/\015\012|\012|\015/,$data);
my $config = {};
foreach my $line(@lines)
{
foreach my $line(@lines)
{
next if($line =~ /^\s*#/);
next if($line =~ /^\s*#/);
- next if($line !~ /^\s*\S+\s*=.+$/);
+ next if($line !~ /^\s*\S+\s*=.*$/);
my ($key,$value) = split(/=/,$line,2);
my ($key,$value) = split(/=/,$line,2);
$value =~ s/^\s+//g;
$value =~ s/\s+$//g;
$value =~ s/^\s+//g;
$value =~ s/\s+$//g;
- croak "Double defined value '$key' in configuration file '$file'" if($config->{$key});
+ croak "Configuration option '$key' defined twice in line $count of configuration file '$file'" if($config->{$key});
$config->{$key} = $value;
}
$config->{$key} = $value;
}
# using only one command
#
# Author: Patrick Canterino <patrick@patshaping.de>
# using only one command
#
# Author: Patrick Canterino <patrick@patshaping.de>
-# Last modified: 2004-12-17
+# Last modified: 2005-01-06
foreach my $entry(@entries)
{
foreach my $entry(@entries)
{
- next if($entry eq "." || $entry eq "..");
+ next if($entry eq '.' || $entry eq '..');
# HTML generating routines
#
# Author: Patrick Canterino <patrick@patshaping.de>
# HTML generating routines
#
# Author: Patrick Canterino <patrick@patshaping.de>
-# Last modified: 2004-12-17
+# Last modified: 2005-01-06
my $tpl = new Template;
$tpl->read_file($tpl_error);
my $tpl = new Template;
$tpl->read_file($tpl_error);
- $tpl->fillin("ERROR",$message);
- $tpl->fillin("BACK",$path);
- $tpl->fillin("SCRIPT",encode_entities($ENV{'SCRIPT_NAME'}));
+ $tpl->fillin('ERROR',$message);
+ $tpl->fillin('BACK',$path);
+ $tpl->fillin('SCRIPT',encode_entities($ENV{'SCRIPT_NAME'}));
- $tpl->parse_if_block("dir",defined $path);
+ $tpl->parse_if_block('dir',defined $path);
- if(ref($vars) eq "HASH")
+ if(ref($vars) eq 'HASH')
{
while(my ($key,$value) = each(%$vars))
{
{
while(my ($key,$value) = each(%$vars))
{
- my $output = header(-type => "text/html");
+ my $output = header(-type => 'text/html');
$output .= $tpl->get_template;
return \$output;
$output .= $tpl->get_template;
return \$output;
# Some shared sub routines
#
# Author: Patrick Canterino <patrick@patshaping.de>
# Some shared sub routines
#
# Author: Patrick Canterino <patrick@patshaping.de>
-# Last modified: 2005-01-04
+# Last modified: 2005-01-06
$path =~ tr!\\!/!;
$path =~ s!^/+!!;
$path =~ tr!\\!/!;
$path =~ s!^/+!!;
- $path = $root."/".$path;
+ $path = $root.'/'.$path;
# We extract the last part of the path and create the absolute path
# We extract the last part of the path and create the absolute path
my $last = file_name($path);
$first = abs_path($first);
my $last = file_name($path);
$first = abs_path($first);
- $path = $first."/".$last;
+ $path = $first.'/'.$last;
$first = File::Spec->canonpath($first);
$path = File::Spec->canonpath($path);
$first = File::Spec->canonpath($first);
$path = File::Spec->canonpath($path);
my $short_path = substr($path,length($root));
$short_path =~ tr!\\!/!;
my $short_path = substr($path,length($root));
$short_path =~ tr!\\!/!;
- $short_path = "/".$short_path if($short_path !~ m!^/!);
- $short_path = $short_path."/" if($short_path !~ m!/$! && -d $path);
+ $short_path = '/'.$short_path if($short_path !~ m!^/!);
+ $short_path = $short_path.'/' if($short_path !~ m!/$! && -d $path);
return ($path,$short_path);
}
return ($path,$short_path);
}
# Detect the protocol (simple HTTP or SSL encrypted HTTP)
# and check if the server listens on the default port
# Detect the protocol (simple HTTP or SSL encrypted HTTP)
# and check if the server listens on the default port
- my $protocol = "";
- my $port = "";
+ my $protocol = '';
+ my $port = '';
if(https)
{
# SSL encrypted HTTP (HTTPS)
if(https)
{
# SSL encrypted HTTP (HTTPS)
- $protocol = "https";
- $port = ":".$ENV{'SERVER_PORT'} if($ENV{'SERVER_PORT'} != 443);
+ $protocol = 'https';
+ $port = ':'.$ENV{'SERVER_PORT'} if($ENV{'SERVER_PORT'} != 443);
- $protocol = "http";
- $port = ":".$ENV{'SERVER_PORT'} if($ENV{'SERVER_PORT'} != 80);
+ $protocol = 'http';
+ $port = ':'.$ENV{'SERVER_PORT'} if($ENV{'SERVER_PORT'} != 80);
}
# The following code is grabbed from Template::_query of
# Andre Malo's selfforum (http://sourceforge.net/projects/selfforum/)
# and modified by Patrick Canterino
}
# The following code is grabbed from Template::_query of
# Andre Malo's selfforum (http://sourceforge.net/projects/selfforum/)
# and modified by Patrick Canterino
- if(ref($params) eq "HASH")
+ if(ref($params) eq 'HASH')
{
$query = '?'.join ('&' =>
map {
{
$query = '?'.join ('&' =>
map {
# Create the redirection header
# Create the redirection header
- my $header = redirect($protocol."://".virtual_host.$port.$ENV{'SCRIPT_NAME'}.$query);
+ my $header = redirect($protocol.'://'.virtual_host.$port.$ENV{'SCRIPT_NAME'}.$query);
$root =~ s!/+$!!;
$path =~ s!^/+!!;
$root =~ s!/+$!!;
$path =~ s!^/+!!;
- $url = $root."/".$path;
+ $url = $root.'/'.$path;
my $path = shift;
$path =~ tr!\\!/!;
my $path = shift;
$path =~ tr!\\!/!;
- $path = substr($path,0,-1) if($path =~ m!/$!);
- $path = substr($path,rindex($path,"/")+1);
+ $path =~ s!/+$!!;
+ $path = substr($path,rindex($path,'/')+1);
sub mode_string($)
{
my $mode = shift;
sub mode_string($)
{
my $mode = shift;
- $string = ($mode & 00400) ? "r" : "-";
- $string .= ($mode & 00200) ? "w" : "-";
- $string .= ($mode & 00100) ? (($mode & 04000) ? "s" : "x") :
- ($mode & 04000) ? "S" : "-";
+ $string = ($mode & 00400) ? 'r' : '-';
+ $string .= ($mode & 00200) ? 'w' : '-';
+ $string .= ($mode & 00100) ? (($mode & 04000) ? 's' : 'x') :
+ ($mode & 04000) ? 'S' : '-';
- $string .= ($mode & 00040) ? "r" : "-";
- $string .= ($mode & 00020) ? "w" : "-";
- $string .= ($mode & 00010) ? (($mode & 02000) ? "s" : "x") :
- ($mode & 02000) ? "S" : "-";
+ $string .= ($mode & 00040) ? 'r' : '-';
+ $string .= ($mode & 00020) ? 'w' : '-';
+ $string .= ($mode & 00010) ? (($mode & 02000) ? 's' : 'x') :
+ ($mode & 02000) ? 'S' : '-';
- $string .= ($mode & 00004) ? "r" : "-";
- $string .= ($mode & 00002) ? "w" : "-";
- $string .= ($mode & 00001) ? (($mode & 01000) ? "t" : "x") :
- ($mode & 01000) ? "T" : "-";
+ $string .= ($mode & 00004) ? 'r' : '-';
+ $string .= ($mode & 00002) ? 'w' : '-';
+ $string .= ($mode & 00001) ? (($mode & 01000) ? 't' : 'x') :
+ ($mode & 01000) ? 'T' : '-';
my $path = shift;
$path =~ tr!\\!/!;
my $path = shift;
$path =~ tr!\\!/!;
- $path = substr($path,0,-1) if($path =~ m!/$!);
- $path = substr($path,0,rindex($path,"/")+1);
+ $path =~ s!/+$!!;
+ $path = substr($path,0,rindex($path,'/')+1);