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'});
- 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
+
+ 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');
+
+ if($users)
+ {
+ if(-o $physical)
+ {
+ 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);
+ }
+
+ chgrp($group,$physical) if($group);
+
+ return devedit_reload({command => 'show', file => $dir});
+ }
+ else
+ {
+ my @stat = stat($physical);
+
+ my $mode = $stat[2];
+ my $mode_oct = substr(sprintf("%04o",$mode),-4);
+ my $gid = $stat[5];
+ my $group = getgrgid($gid);
+
+ my $tpl = new Template;
+ $tpl->read_file($config->{'templates'}->{'chprop'});
+
+ $tpl->fillin("MODE_OCTAL",$mode_oct);
+ $tpl->fillin("MODE_STRING",mode_string($mode));
+ $tpl->fillin("GID",$gid);
+ $tpl->fillin("GROUP",$group);
+
+ $tpl->fillin("FILE",$virtual);
+ $tpl->fillin("DIR",$dir);
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
- return error_in_use($virtual) if($data->{'uselist'}->in_use($virtual));
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
- if(-e $new_physical)
+ return \$output;
+ }
+ }
+ else
+ {
+ return error($config->{'errors'}->{'not_owner'},$dir,{FILE => $virtual});
+ }
+ }
+ else
{
- 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));
+ 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'};
- return exec_rmdir($data,$config) if(-d $physical);
- return error_in_use($virtual) if($data->{'uselist'}->in_use($virtual));
+ if($data->{'cgi'}->param('confirmed'))
+ {
+ file_unlock($data->{'uselist'},$virtual);
+ return devedit_reload({command => 'show', file => upper_path($virtual)});
+ }
+ else
+ {
+ my $tpl = new Template;
+ $tpl->read_file($config->{'templates'}->{'confirm_unlock'});
+
+ $tpl->fillin("FILE",$virtual);
+ $tpl->fillin("DIR",upper_path($virtual));
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
- unlink($physical) or return error("Could not delete file '".encode_entities($virtual)."'.",upper_path($virtual));
- return devedit_reload({command => 'show', file => upper_path($virtual)});
+ 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 $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;
+ $tpl->parse_if_block("users",1);
- return devedit_reload({command => 'show', file => upper_path($virtual)});
+ # ID's of user and group
+
+ $tpl->fillin("UID",$<);
+ $tpl->fillin("GID",$();
+
+ # Names of user and group
+
+ $tpl->fillin("USER",getpwuid($<));
+ $tpl->fillin("GROUP",getgrgid($());
+ }
+ else
+ {
+ $tpl->parse_if_block("users",0);
+ }
+
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
+
+ return \$output;
}
# it's true, baby ;-)