Apache2-FileManager
view release on metacpan or search on metacpan
FileManager.pm view on Meta::CPAN
<TR ALIGN=CENTER>
<TD ALIGN=CENTER>"
.join("</TD><TD> <B><FONT COLOR=#bcbcbc SIZE=+2>|</FONT> </B>"
."</TD><TD>",
@cmds)
."</TD></TR></TABLE>";
}
sub html_file_list {
my $o = shift;
my $up_a_href = shift || "";
my $bgcolor = "efefef";
#get the list in this directory
my $curr_dir = "";
$curr_dir = r->param('FILEMANAGER_curr_dir')."/"
if (r->param('FILEMANAGER_curr_dir') ne "");
#if there is a value for the ".." directory, then add a row for that link
#at the *top* of the list
my $acum = "";
if ($up_a_href ne "") {
$acum = "
<TR BGCOLOR=#$bgcolor>
<TD> </TD>
<TD>$up_a_href</TD>
<TD ALIGN=CENTER>--</TD>
<TD ALIGN=CENTER>--</TD>
</TR>";
$bgcolor = "ffffff";
}
my $ct_rows = 0;
foreach my $file (sort <*>) {
my ($link,$last_modified,$size,$type);
$ct_rows++;
#if directory?
if (-d $file) {
$last_modified = "--";
$size = "<TD ALIGN=CENTER>--</TD>";
$type = "/"; # "/" designates "directory"
$link = "<A HREF=#
onclick=\"
var f=window.document.FileManager;
f.FILEMANAGER_curr_dir.value='"
.Apache2::Util::escape_path($curr_dir.$file, r->pool)."';
f.submit();
return false;\">
<FONT COLOR=#006699>$file$type</FONT></A>";
}
#must be a file
elsif (-f $file) {
#get file size
my $stat = stat($file);
$size = $stat->size;
if ($size > 1024000) {
$size = sprintf("%0.2f",$size/1024000) . " <I>M</I>";
} elsif ($stat->size > 1024) {
$size = sprintf("%0.2f",$size/1024). " <I>K</I>";
} else {
$size = sprintf("%.2f",$size). " <I>b</I>";
}
$size =~ s/\.0{1,2}//;
$size = "<TD NOWRAP ALIGN=RIGHT>$size</TD>";
#get last modified
$last_modified = $o->formated_date($stat->mtime);
#get file type
if (-S $file) {
$type = "="; # "=" designates "socket"
}
elsif (-l $file) {
$type = "@"; # "@" designates "link"
}
elsif (-x $file) {
$type = "*"; # "*" designates "executable"
}
my $true_doc_root = r->document_root;
my $fake_doc_root = $$o{DR};
$fake_doc_root =~ s/^$true_doc_root//;
$fake_doc_root =~ s/^\///; $fake_doc_root =~ s/\/$//;
my $href = $curr_dir;
$href = $fake_doc_root."/".$href if $fake_doc_root;
$link = "
<A HREF=\"/$href"."$file?nossi=1\"
TARGET=_blank><FONT COLOR=BLACK>"
.Apache2::Util::escape_path($file.$type, r->pool).
"</FONT>
</A>";
}
$acum .= "
<TR BGCOLOR=#$bgcolor>
<TD><INPUT TYPE=CHECKBOX NAME=FILEMANAGER_sel_files
VALUE='$curr_dir"."$file'></TD>
<TD>$link</TD>
<TD ALIGN=CENTER NOWRAP>$last_modified</TD>
$size
</TR>";
#alternate bgcolor so it is easier to read
$bgcolor = ( ($bgcolor eq "ffffff") ? "efefef" : "ffffff" );
}
#print a message if there were no files in this directory
if ($ct_rows == 0) {
$acum .= "
<TR ALIGN=CENTER><TD COLSPAN=3>
<TABLE BORDER=1 WIDTH=100% BGCOLOR=WHITE>
<TR>
( run in 0.691 second using v1.01-cache-2.11-cpan-39bf76dae61 )