X-Git-Url: https://git.p6c8.net/devedit.git/blobdiff_plain/4114079ae7f2e8879071e7ae7c535c6e1416abf8..89269f652fc46e65006b9aead5eb1ae61ebc311e:/modules/Command.pm
diff --git a/modules/Command.pm b/modules/Command.pm
index ad660c3..363cffe 100644
--- a/modules/Command.pm
+++ b/modules/Command.pm
@@ -6,7 +6,7 @@ package Command;
# Execute Dev-Editor's commands
#
# Author: Patrick Canterino
\n\n\n";
+ $output .= "
\n\n\n";
# Create the link to the upper directory
# (only if we are not in the root directory)
@@ -83,10 +82,10 @@ sub exec_show($$$)
$output .= " [SUBDIR] ";
$output .= strftime("%d.%m.%Y %H:%M",localtime($stat[9]));
$output .= " " x 10;
- $output .= "../\n";
+ $output .= "../\n";
}
- # Get the longest file/directory name
+ # Get the length of the longest file/directory name
my $max_name_len = 0;
@@ -104,9 +103,9 @@ sub exec_show($$$)
$output .= " ";
$output .= "[SUBDIR] ";
- $output .= strftime("%d.%m.%Y %H:%M",localtime($stat[9]));
+ $output .= strftime($config->{'timeformat'},localtime($stat[9]));
$output .= " " x 10;
- $output .= "".encode_entities($dir)."/\n";
+ $output .= "".encode_entities($dir)."/\n";
}
# Files
@@ -114,7 +113,7 @@ sub exec_show($$$)
foreach my $file(@$files)
{
my $phys_path = $physical."/".$file; # Not exactly...
- my $virt_path = $virtual.$file;
+ my $virt_path = encode_entities($virtual.$file);
my @stat = stat($phys_path);
my $in_use = $data->{'uselist'}->in_use($virtual.$file);
@@ -122,8 +121,8 @@ sub exec_show($$$)
$output .= " " x (10 - length($stat[7]));
$output .= $stat[7];
$output .= " ";
- $output .= strftime("%d.%m.%Y %H:%M",localtime($stat[9]));
- $output .= ($in_use) ? " (IN USE) " : (-B $phys_path) ? " (BINARY) " : " " x 10;
+ $output .= strftime($config->{'timeformat'},localtime($stat[9]));
+ $output .= ($in_use) ? " (IN USE) " : (not -T $phys_path) ? " (BINARY) " : " " x 10;
$output .= encode_entities($file);
$output .= " " x ($max_name_len - length($file))."\t (";
@@ -133,7 +132,7 @@ sub exec_show($$$)
$output .= " | ";
- $output .= ($in_use || -B $phys_path)
+ $output .= ($in_use || not -T $phys_path)
? 'Edit'
: "Edit";
@@ -141,15 +140,27 @@ sub exec_show($$$)
}
$output .= "
\n\n
\n\n";
+
+ # Bottom of directory listing
+ # (Fields for creating files and directories)
+
$output .= <
+
@@ -162,8 +173,10 @@ END
# View a file
# Check on binary files
+ # We have to do it in this way, or empty files
+ # will be recognized as binary files
- if(-B $physical)
+ unless(-T $physical)
{
# Binary file
@@ -173,7 +186,7 @@ END
{
# Text file
- $output = htmlhead("Contents of file $virtual");
+ $output = htmlhead("Contents of file ".encode_entities($virtual));
$output .= equal_url($config->{'httproot'},$virtual);
$output .= dir_link($virtual);
@@ -186,7 +199,7 @@ END
}
}
- return \$output
+ return \$output;
}
# exec_beginedit
@@ -210,7 +223,7 @@ sub exec_beginedit($$)
# Check on binary files
- if(-B $physical)
+ unless(-T $physical)
{
# Binary file
@@ -223,27 +236,33 @@ sub exec_beginedit($$)
$uselist->add_file($virtual);
$uselist->save;
- my $dir = upper_path($virtual);
- my $content = encode_entities(${file_read($physical)});
+ my $dir = upper_path($virtual);
+ my $content = encode_entities(${file_read($physical)});
+
+ my $equal_url = equal_url($config->{'httproot'},$virtual);
+
+ $virtual = encode_entities($virtual);
my $output = htmlhead("Edit file $virtual");
- $output .= equal_url($config->{'httproot'},$virtual);
+ $output .= $equal_url;
$output .= <Create new file:
-$virtual
+