Click on the button below to remove the file '$virtual'.
+ return \$output;
+ }
+ }
-
-END
+ copy($physical,$new_physical) or return error($config->{'errors'}->{'copy_failed'},upper_path($virtual),{FILE => $virtual, NEW_FILE => $new_virtual});
+ return devedit_reload({command => 'show', file => $dir});
}
else
{
- # File is locked
- # Just display a button for unlocking it
+ my $tpl = new Template;
+ $tpl->read_file($config->{'templates'}->{'copyfile'});
- $output .= <Unlock file
+ $tpl->fillin("FILE",$virtual);
+ $tpl->fillin("DIR",upper_path($virtual));
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
-
Someone else is currently editing this file. At least, the file is marked so. Maybe, someone who was editing the file has forgotten to unlock it. In this case (and only in this case) you can unlock the file using this button:
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
-
-END
+ return \$output;
}
-
- $output .= "\n";
- $output .= htmlfoot;
-
- return \$output;
}
-# exec_workwithdir()
+# exec_rename()
#
-# Display a form for renaming/removing a directory
+# Rename/move a file and return to directory view
#
# Params: 1. Reference to user input hash
# 2. Reference to config hash
#
# Return: Output of the command (Scalar Reference)
-sub exec_workwithdir($$)
+sub exec_rename($$)
{
my ($data,$config) = @_;
my $physical = $data->{'physical'};
my $virtual = $data->{'virtual'};
+ my $new_physical = $data->{'new_physical'};
- my $dir = encode_entities(upper_path($virtual));
+ return error($config->{'errors'}->{'rename_root'},"/") if($virtual eq "/");
+ return error($config->{'errors'}->{'in_use'},upper_path($virtual),{FILE => $virtual}) if($data->{'uselist'}->in_use($virtual));
- my $output = htmlhead("Work with directory ".encode_entities($virtual));
- $output .= equal_url($config->{'httproot'},$virtual);
+ if($new_physical)
+ {
+ my $new_virtual = $data->{'new_virtual'};
+ my $dir = upper_path($new_virtual);
+ $new_virtual = encode_entities($new_virtual);
- $virtual = encode_entities($virtual);
+ if(-e $new_physical)
+ {
+ return error($config->{'errors'}->{'exist_edited'},$dir,{FILE => $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
- $output .= dir_link($virtual);
- $output .= "
Note: On UNIX systems, filenames are case-sensitive!
Click on the button below to completely remove the directory '$virtual' and oll of it's files and sub directories.
+ rename($physical,$new_physical) or return error($config->{'errors'}->{'rename_failed'},upper_path($virtual),{FILE => $virtual, NEW_FILE => $new_virtual});
+ return devedit_reload({command => 'show', file => $dir});
+ }
+ else
+ {
+ my $tpl = new Template;
+ $tpl->read_file($config->{'templates'}->{'renamefile'});
-
-END
+ $tpl->fillin("FILE",$virtual);
+ $tpl->fillin("DIR",upper_path($virtual));
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
- $output .= "\n";
- $output .= htmlfoot;
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
- return \$output;
+ return \$output;
+ }
}
-# exec_copy()
+# exec_remove()
#
-# Copy a file and return to directory view
+# Remove a file or a directory and return to directory view
#
# Params: 1. Reference to user input hash
# 2. Reference to config hash
#
# Return: Output of the command (Scalar Reference)
-sub exec_copy($$)
+sub exec_remove($$)
{
my ($data,$config) = @_;
my $physical = $data->{'physical'};
- my $virtual = encode_entities($data->{'virtual'});
- my $new_physical = $data->{'new_physical'};
- my $new_virtual = $data->{'new_virtual'};
- my $dir = upper_path($new_virtual);
- $new_virtual = encode_entities($new_virtual);
+ my $virtual = $data->{'virtual'};
- return error("This editor is not able to copy directories.") if(-d $physical);
- return error("You have not enough permissions to copy this file.") unless(-r $physical);
+ return error($config->{'errors'}->{'remove_root'},"/") if($virtual eq "/");
- if(-e $new_physical)
+ if(-d $physical)
{
- if(-d $new_physical)
+ # Remove a directory
+
+ if($data->{'cgi'}->param('confirmed'))
{
- return error("A directory called '$new_virtual' already exists. You cannot replace a directory by a file!",$dir);
+ rmtree($physical);
+ return devedit_reload({command => 'show', file => upper_path($virtual)});
}
- elsif(not $data->{'cgi'}->param('confirmed'))
+ else
{
- $dir = encode_entities($dir);
+ my $tpl = new Template;
+ $tpl->read_file($config->{'templates'}->{'confirm_rmdir'});
+
+ $tpl->fillin("DIR",$virtual);
+ $tpl->fillin("UPPER_DIR",upper_path($virtual));
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
- my $output = htmlhead("Replace existing file");
- $output .= <<"END";
-
A file called '$new_virtual' already exists. Do you want to replace it?
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
-
+ return error($config->{'errors'}->{'in_use'},upper_path($virtual),{FILE => $virtual}) if($data->{'uselist'}->in_use($virtual));
-
-END
+ $tpl->fillin("FILE",$virtual);
+ $tpl->fillin("DIR",upper_path($virtual));
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
- $output .= htmlfoot;
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
return \$output;
}
}
-
- if($data->{'uselist'}->in_use($data->{'new_virtual'}))
- {
- return error("The target file '$new_virtual' already exists and it is edited by someone else.",$dir);
- }
-
- copy($physical,$new_physical) or return error("Could not copy '$virtual' to '$new_virtual'",upper_path($virtual));
- return devedit_reload({command => 'show', file => $dir});
}
-# exec_rename()
+# exec_chprop()
#
-# Rename/move a file and return to directory view
+# 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_rename($$)
+sub exec_chprop($$)
{
my ($data,$config) = @_;
my $physical = $data->{'physical'};
my $virtual = $data->{'virtual'};
- my $new_physical = $data->{'new_physical'};
- my $new_virtual = $data->{'new_virtual'};
- my $dir = upper_path($new_virtual);
- $new_virtual = encode_entities($new_virtual);
+ my $dir = upper_path($virtual);
+ my $cgi = $data->{'cgi'};
+ my $mode = $cgi->param('mode');
+ my $group = $cgi->param('group');
- return error_in_use($virtual) if($data->{'uselist'}->in_use($virtual));
-
- if(-e $new_physical)
+ if($users)
{
- if(-d $new_physical)
+ if(-o $physical)
{
- return error("A directory called '$new_virtual' already exists. You cannot replace a directory!",upper_path($virtual));
- }
- elsif(not $data->{'cgi'}->param('confirmed'))
- {
- $dir = encode_entities($dir);
-
- my $output = htmlhead("Replace existing file");
- $output .= <<"END";
-
A file called '$new_virtual' already exists. Do you want to replace it?
+ 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);
+ }
+
+ if($group)
+ {
+ return error($config->{'errors'}->{'invalid_group'},$dir,{GROUP => $group}) unless($group =~ /^[a-z0-9_]+[a-z0-9_-]*$/i);
+ system("chgrp",$group,$physical);
+ }
+
+ return devedit_reload({command => 'show', file => $dir});
+ }
+ else
+ {
+ my @stat = stat($physical);
-
+ my $tpl = new Template;
+ $tpl->read_file($config->{'templates'}->{'chprop'});
-
-END
+ $tpl->fillin("FILE",$virtual);
+ $tpl->fillin("DIR",$dir);
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
- $output .= htmlfoot;
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
- return \$output;
+ return \$output;
+ }
+ }
+ else
+ {
+ return error($config->{'errors'}->{'not_owner'},$dir,{FILE => $virtual});
}
}
-
- if($data->{'uselist'}->in_use($data->{'new_virtual'}))
+ else
{
- return error("The target file '$new_virtual' already exists and it is edited by someone else.",$dir);
+ return error($config->{'errors'}->{'no_users'},$dir,{FILE => $virtual});
}
-
- rename($physical,$new_physical) or return error("Could not move/rename '".encode_entities($virtual)."' to '$new_virtual'.",upper_path($virtual));
- return devedit_reload({command => 'show', file => $dir});
}
-# exec_remove()
+# exec_unlock()
#
-# Remove a file and return to directory view
+# Remove a file from the list of used files and
+# return to directory view
#
# Params: 1. Reference to user input hash
# 2. Reference to config hash
#
# Return: Output of the command (Scalar Reference)
-sub exec_remove($$)
+sub exec_unlock($$)
{
my ($data,$config) = @_;
- my $physical = $data->{'physical'};
my $virtual = $data->{'virtual'};
+ my $uselist = $data->{'uselist'};
- return exec_rmdir($data,$config) if(-d $physical);
- return error_in_use($virtual) if($data->{'uselist'}->in_use($virtual));
+ return devedit_reload({command => 'show', file => upper_path($virtual)}) if($uselist->unused($virtual));
if($data->{'cgi'}->param('confirmed'))
{
- unlink($physical) or return error("Could not delete file '".encode_entities($virtual)."'.",upper_path($virtual));
+ file_unlock($uselist,$virtual);
return devedit_reload({command => 'show', file => upper_path($virtual)});
}
else
{
- my $dir = encode_entities(upper_path($virtual));
- my $output;
-
- $output = htmlhead("Remove file ".encode_entities($virtual));
- $output .= equal_url($config->{'httproot'},$virtual);
+ my $tpl = new Template;
+ $tpl->read_file($config->{'templates'}->{'confirm_unlock'});
- $virtual = encode_entities($virtual);
+ $tpl->fillin("FILE",$virtual);
+ $tpl->fillin("DIR",upper_path($virtual));
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
- $output .= dir_link($virtual);
-
- $output .= <<"END";
-
Do you really want to remove the file '$virtual'?
-
-
-
-
-END
-
- $output .= htmlfoot;
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
return \$output;
}
}
-# exec_rmdir()
+# exec_about()
#
-# Remove a directory and return to directory view
+# Display some information about Dev-Editor
#
# Params: 1. Reference to user input hash
# 2. Reference to config hash
#
# Return: Output of the command (Scalar Reference)
-sub exec_rmdir($$)
+sub exec_about($$)
{
my ($data,$config) = @_;
- my $physical = $data->{'physical'};
- my $virtual = $data->{'virtual'};
- return exec_remove($data,$config) if(not -d $physical);
+ my $tpl = new Template;
+ $tpl->read_file($config->{'templates'}->{'about'});
- if($data->{'cgi'}->param('confirmed'))
- {
- rmtree($physical);
- return devedit_reload({command => 'show', file => upper_path($virtual)});
- }
- else
- {
- my $dir = encode_entities(upper_path($virtual));
- my $output;
+ $tpl->fillin("SCRIPT",$script);
- $output = htmlhead("Remove directory ".encode_entities($virtual));
- $output .= equal_url($config->{'httproot'},$virtual);
+ # Dev-Editor's version number
- $virtual = encode_entities($virtual);
+ $tpl->fillin("VERSION",$data->{'version'});
- $output .= dir_link($virtual);
+ # Some path information
- $output .= <<"END";
-
Do you really want to remove the directory '$virtual' and all of it's files and sub directories?
+ $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("PERL_PROG",$^X);
+ $tpl->fillin("PERL_VER",sprintf("%vd",$^V));
-
-END
+ $tpl->fillin("HTTPD",$ENV{'SERVER_SOFTWARE'});
+ $tpl->fillin("OS",$^O);
+ $tpl->fillin("TIME",strftime($config->{'timeformat'},localtime));
- $output .= htmlfoot;
+ # Process information
- return \$output;
- }
-}
+ $tpl->fillin("PID",$$);
-# exec_unlock()
-#
-# Remove a file from the list of used files and
-# return to directory view
-#
-# Params: 1. Reference to user input hash
-# 2. Reference to config hash
-#
-# Return: Output of the command (Scalar Reference)
+ # Check if the functions getpwuid() and getgrgid() are available
-sub exec_unlock($$)
-{
- my ($data,$config) = @_;
- my $virtual = $data->{'virtual'};
- my $uselist = $data->{'uselist'};
+ 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
- $uselist->remove_file($virtual);
- $uselist->save;
+ my $uid = POSIX::getuid;
+ my $gid = POSIX::getgid;
- return devedit_reload({command => 'show', file => upper_path($virtual)});
+ $tpl->parse_if_block("users",1);
+
+ # ID's of user and group
+
+ $tpl->fillin("UID",$uid);
+ $tpl->fillin("GID",$gid);
+
+ # Names of user and group
+
+ $tpl->fillin("USER",getpwuid($uid));
+ $tpl->fillin("GROUP",getgrgid($gid));
+
+ # Process umask
+
+ $tpl->fillin("UMASK",sprintf("%04o",umask));
+ }
+ else
+ {
+ $tpl->parse_if_block("users",0);
+ }
+
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
+
+ return \$output;
}
# it's true, baby ;-)