Apache2-FileManager
view release on metacpan or search on metacpan
FileManager.pm view on Meta::CPAN
return $o;
}
# ---- If this was called directly via a perl content handler by apache -------
sub handler {
my $r = Apache2::Request->new(@_);
return Apache2::Const::DECLINED if defined r->param('nossi');
my $package = __PACKAGE__;
my $obj = $package->new();
r->content_type('text/html');
r->print("<HTML><HEAD><TITLE>"
.r->hostname." File Manager $VERSION</TITLE></HEAD>");
$obj->print();
r->print("</HTML>");
return Apache2::Const::OK;
}
# ---- Call the view ----------------------------------------------
sub print {
my $o = shift;
my $view = "view_".$$o{'view'};
$o->$view();
}
# ------------ Intialize object -----------------------------------------
sub intialize {
my $o = shift;
$$o{MESSAGE} = "";
$$o{JS} = "";
$$o{EDIT_COLS} ||= 75;
$$o{EDIT_ROWS} ||= 22;
# Is this filemanager rsync capable?
$$o{RSYNC_TO} ||= r->dir_config('RSYNC_TO') || undef;
#set some defaults (for warnings sake)
$$o{FILEMANAGER_cmd} = r->param('FILEMANAGER_cmd') || "";
$$o{FILEMANAGER_arg} = r->param('FILEMANAGER_arg') || "";
$$o{FILEMANAGER_curr_dir} = r->param('FILEMANAGER_curr_dir') || "";
$$o{FILEMANAGER_sel_files} => r->param('FILEMANAGER_sel_files') || [];
#document root
my $dr = r->document_root;
$$o{DR} ||= r->dir_config('DOCUMENT_ROOT') || r->document_root;
#does user defined document root lie inside real doc root?
if ($$o{DR} !~ /^$dr/) {
$$o{DR} = r->document_root;
r->log_error("Warning: Document root changed to $dr.".
" Custom document root must lie inside of ".
"real document root.");
}
#verify current working directory
$_ = r->param('FILEMANAGER_curr_dir');
s/\.\.//g; s/^\///; s/\/$//;
my $curr_dir = $_;
#set current directory
if (! chdir $$o{DR}."/$curr_dir") {
chdir $$o{DR};
$curr_dir = "";
}
$$o{FILEMANAGER_curr_dir} = $curr_dir;
#set default view method
$$o{'view'} = "filemanager";
return undef;
}
###############################################################################
# ----- Views --------------------------------------------------------------- #
###############################################################################
#after upload files - view
sub view_post_upload {
r->print(q{
<SCRIPT>
window.opener.document.FileManager.submit();
window.opener.focus();
window.close();
</SCRIPT>
});
return undef;
}
#after rsync transacation - view
sub view_post_rsync {
my $o = shift;
r->print(qq{
<CENTER>
<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>
<TR><TD>$$o{MESSAGE}</TD></TR>
<TR>
<FORM>
<TD ALIGN=RIGHT>
<INPUT TYPE=BUTTON VALUE='close'
onclick="window.close();">
</TD>
</FORM>
</TR>
</TABLE>
</CENTER>
});
return undef;
}
( run in 1.079 second using v1.01-cache-2.11-cpan-e1769b4cff6 )