Click on the button below to remove the file '$virtual'.
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
+
+ return \$output;
+ }
+ }
-
-END
+ copy($physical,$new_physical) or return error($config->{'err_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->{'tpl_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->{'err_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->{'err_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->{'err_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->{'tpl_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);
-
- 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);
+ my $virtual = $data->{'virtual'};
- 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->{'tpl_confirm_rmdir'});
- my $output = htmlhead("Replace existing file");
- $output .= <<"END";
-
A file called '$new_virtual' already exists. Do you want to replace it?
+ $tpl->fillin("DIR",$virtual);
+ $tpl->fillin("UPPER_DIR",upper_path($virtual));
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
-
+ return \$output;
+ }
+ }
+ else
+ {
+ # Remove a file
-
-END
+ if($data->{'cgi'}->param('confirmed'))
+ {
+ unlink($physical) or return error($config->{'err_delete_failed'},upper_path($virtual),{FILE => $virtual});
+ return devedit_reload({command => 'show', file => upper_path($virtual)});
+ }
+ else
+ {
+ my $tpl = new Template;
+ $tpl->read_file($config->{'tpl_confirm_rmfile'});
+
+ $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_unlock()
#
-# Rename/move 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_rename($$)
+sub exec_unlock($$)
{
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);
- return error_in_use($virtual) if($data->{'uselist'}->in_use($virtual));
-
- if(-e $new_physical)
+ if($data->{'cgi'}->param('confirmed'))
{
- return error("A file or directory called '$new_virtual' already exists and this editor is currently not able to ask to overwrite the existing file or directory.",upper_path($virtual));
+ file_unlock($data->{'uselist'},$virtual);
+ return devedit_reload({command => 'show', file => upper_path($virtual)});
}
+ else
+ {
+ my $tpl = new Template;
+ $tpl->read_file($config->{'tpl_confirm_unlock'});
- 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});
+ $tpl->fillin("FILE",$virtual);
+ $tpl->fillin("DIR",upper_path($virtual));
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
+
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
+
+ return \$output;
+ }
}
-# exec_remove()
+# exec_about()
#
-# Remove a file 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_remove($$)
+sub exec_about($$)
{
my ($data,$config) = @_;
- my $physical = $data->{'physical'};
- my $virtual = $data->{'virtual'};
- return exec_rmdir($data,$config) if(-d $physical);
- return error_in_use($virtual) if($data->{'uselist'}->in_use($virtual));
+ my $tpl = new Template;
+ $tpl->read_file($config->{'tpl_about'});
- unlink($physical) or return error("Could not delete file '".encode_entities($virtual)."'.",upper_path($virtual));
- return devedit_reload({command => 'show', file => upper_path($virtual)});
-}
+ $tpl->fillin("SCRIPT",$script);
-# exec_rmdir()
-#
-# Remove 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)
+ # Dev-Editor's version number
-sub exec_rmdir($$)
-{
- my ($data,$config) = @_;
- my $physical = $data->{'physical'};
- my $virtual = $data->{'virtual'};
+ $tpl->fillin("VERSION",$data->{'version'});
- return exec_remove($data,$config) if(not -d $physical);
+ # Some path information
- 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_PHYS",$ENV{'SCRIPT_FILENAME'});
+ $tpl->fillin("CONFIG_PATH",$data->{'configfile'});
+ $tpl->fillin("FILE_ROOT",$config->{'fileroot'});
+ $tpl->fillin("HTTP_ROOT",$config->{'httproot'});
- $output = htmlhead("Remove directory $virtual");
- $output .= equal_url($config->{'httproot'},$virtual);
+ # Perl
- $virtual = encode_entities($virtual);
+ $tpl->fillin("PERL_PROG",$^X);
+ $tpl->fillin("PERL_VER",sprintf("%vd",$^V));
- $output .= dir_link($virtual);
+ # Information about the server
- $output .= <<"END";
-
Do you really want to remove the directory '$virtual' and all of it's files and sub directories?
+ $tpl->fillin("HTTPD",$ENV{'SERVER_SOFTWARE'});
+ $tpl->fillin("OS",$^O);
+ $tpl->fillin("TIME",strftime($config->{'timeformat'},localtime));
-
+ $tpl->fillin("PID",$$);
-
-END
+ if(eval("getpwuid(0)") && eval("getgrgid(0)"))
+ {
+ # Dev-Editor is running on a system which allows users and groups
+ # So we display the user and the group of our process
- $output .= htmlfoot;
+ $tpl->parse_if_block("users",1);
- return \$output;
- }
-}
+ # ID's of user and group
-# 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)
+ $tpl->fillin("UID",$<);
+ $tpl->fillin("GID",$();
-sub exec_unlock($$)
-{
- my ($data,$config) = @_;
- my $virtual = $data->{'virtual'};
- my $uselist = $data->{'uselist'};
+ # Names of user and group
+
+ $tpl->fillin("USER",getpwuid($<));
+ $tpl->fillin("GROUP",getgrgid($());
+ }
+ else
+ {
+ $tpl->parse_if_block("users",0);
+ }
- $uselist->remove_file($virtual);
- $uselist->save;
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
- return devedit_reload({command => 'show', file => upper_path($virtual)});
+ return \$output;
}
# it's true, baby ;-)