Apache-FileManager
view release on metacpan or search on metacpan
- Added close button to upload window
- cleaned up the documentation a bit
0.17 Philip Collins
- added return declined stmt if we see nossi param
0.18 Tue Nov 19 15:00 Philip Collins
- fixed extract to report error when trying to extract invalid archives
- Apache::Util::escape_html on all files names
- added ability to mass select and deselect shown files
- added ability to edit and preview edited files
- added error message for rename and edit operation when selected filed != 1
- fixed bad error after canceling a rename file dialog then refreshing
- print error dialog when trying to create blank directory name
- added time to date stamp
0.19 Philip Collins
- prevented file edit screen from opening when cancel is clicked when creating new filenames
- fixed up documentation
FileManager.pm view on Meta::CPAN
print "</HTML>";
}
# .. overload the methods ..
=head1 DESCRIPTION
The Apache::FileManager module is a simple HTML file manager. It provides
file manipulations such as cut, copy, paste, delete, rename, extract archive,
create directory, create file, edit file, and upload files.
Apache::FileManager also has the ability to rsync the server htdocs tree to
another server. With the click of a button.
=head1 PREREQUISITES
The following (non-core) perl modules must be installed before installing
Apache::FileManager.
Apache::Request => 1.00
FileManager.pm view on Meta::CPAN
To get the rsync feature to work do the following:
#1 log onto the production server
#2 become root
#3 give web server user (typically nobody) a home area
I made mine /usr/local/apache/nobody
- production_server> mkdir /usr/local/apache/nobody
- edit passwd file and set new home area for nobody
- production_server> mkdir /usr/local/apache/nobody/.ssh
#4 log onto the development server
#5 become root
#6 give web server user (typically nobody) a home area
- dev_server> mkdir /usr/local/apache/nobody
- dev_server> chown -R nobody.nobody /usr/local/apache/nobody
- edit passwd file and set new home area for nobody
- dev_server> su - nobody
- dev_server> ssh-keygen -t dsa (don't use passphrase)
- dev_server> ssh production_server
(will fail but will make known_hosts file)
- log out from user nobody back to root user
- dev_server> cd /usr/local/apache/nobody/.ssh
- dev_server> scp id_dsa.pub production_server:/usr/local/apache/nobody/.ssh/authorized_keys
- dev_server> chown -R nobody.nobody /usr/local/apache/nobody
- dev_server> chmod -R 700 /usr/local/apache/nobody
FileManager.pm view on Meta::CPAN
return undef;
}
sub view_pre_editfile {
my $o = shift;
my $editfile = r->param('FILEMANAGER_editfile');
my $base = "http://".r->server->server_hostname."/$editfile";
$editfile =~ /([^\/]+)$/;
my $filename = $1;
my $fh;
if (-T $filename && -w $filename) {
$fh = IO::File->new("< ".$filename);
}
my $message = "<I><FONT COLOR=#990000>".$$o{MESSAGE}."</FONT></I><BR>" if $$o{MESSAGE};
if (! $fh) {
FileManager.pm view on Meta::CPAN
w.focus();
}
$$o{JS}
</SCRIPT>
<!-- Styles -->
".$o->html_style_sheet()."
<FORM NAME=FileManagerEditFile ACTION='".r->uri."' METHOD=POST>
".$o->html_hidden_fields()."
<INPUT TYPE=HIDDEN NAME=FILEMANAGER_editfile VALUE=\"".r->param('FILEMANAGER_editfile')."\">
<!-- Header -->
<TABLE WIDTH=100% CELLPADDING=0 CELLSPAING=0><TR>
<TD><FONT COLOR=#3a3a3a><B>$base</B></FONT></TD>
</TR></TABLE>
<!-- Special message -->
$message
<TABLE CELLPADDING=2 CELLSPACING=2 BORDER=0 WIDTH=100% BGCOLOR=#606060>
FileManager.pm view on Meta::CPAN
<TD ALIGN=CENTER><INPUT TYPE=BUTTON VALUE='cancel' onclick=\"window.close(); return false;\"></TD>
<TD ALIGN=CENTER><INPUT TYPE=BUTTON VALUE='preview' onclick=\"window.show_preview(); return false;\"></TD>
<TD ALIGN=CENTER><INPUT TYPE=BUTTON VALUE='save' onclick=\"var f = window.document.FileManagerEditFile; f.FILEMANAGER_cmd.value = 'savefiledata'; f.submit(); return false;\"></TD>
</TR></TABLE>
</TD></TR>
<!-- file edit box -->
<TR><TD ALIGN=CENTER BGCOLOR=#efefef>
<TEXTAREA NAME=FILEMANAGER_filedata COLS=$$o{EDIT_COLS} ROWS=$$o{EDIT_ROWS}>$data</TEXTAREA>
</TD></TR>
<!-- Toolbar -->
<TR><TD ALIGN=CENTER>
<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 WIDTH=90%><TR ALIGN=CENTER>
<TD ALIGN=CENTER><INPUT TYPE=BUTTON VALUE='cancel' onclick=\"window.close(); return false;\"></TD>
FileManager.pm view on Meta::CPAN
// get the number checked
function get_num_checked() {
var sel_ar = get_sel_ckbox_array();
return sel_ar.length;
}
//function to edit file
function edit_file () {
var sel_ar = get_sel_ckbox_array();
//make sure there is 1 and only 1 selected file
if (sel_ar.length != 1) {
window.alert('Please select ONE file to edit by clicking on a check box with the mouse.');
}
else {
var f= window.document.FileManager;
var cd = escape(f.FILEMANAGER_curr_dir.value);
var editfile = escape(sel_ar[0].value);
var w = window.open('".r->uri."?FILEMANAGER_cmd=editfile&FILEMANAGER_curr_dir='+cd+'&FILEMANAGER_editfile='+editfile, 'FileManagerEditFile', 'scrollbars,resizable');
sel_ar[0].checked = false;
w.focus();
}
}
// make cookie for checked filenames
function save_names (type) {
var cb = get_sel_ckbox_array();
var ac = '';
for (var i=0; i < cb.length; i++) {
FileManager.pm view on Meta::CPAN
sub html_cmd_toolbar {
my $o = shift;
my @cmds = (
#Refresh
"<A HREF=# onclick=\"var f=window.document.FileManager; f.submit(); return false;\"><FONT COLOR=WHITE><B>refresh</B></FONT></A>",
#Edit
"<A HREF=# onclick=\"window.edit_file(); return false;\"><FONT COLOR=WHITE><B>edit</B></FONT></A>",
#Cut
"<A HREF=# onclick=\"window.save_names('cut'); return false;\"><FONT COLOR=WHITE><B>cut</B></FONT></A>",
#Copy
"<A HREF=# onclick=\"window.save_names('copy'); return false;\"><FONT COLOR=WHITE><B>copy</B></FONT></A>",
#Paste
"<A HREF=# onclick=\"if (window.getcookie(cookie_name) != '') { var f=window.document.FileManager; f.FILEMANAGER_cmd.value='paste'; f.submit(); } else { window.alert('Please select file(s) to paste by checking the file(s) first and clicking copy or...
FileManager.pm view on Meta::CPAN
#New File
"<A HREF=# onclick=\"
var f=window.document.FileManager;
var rv = window.prompt('new file name','');
var cd = f.FILEMANAGER_curr_dir.value;
if (cd != '') {
rv = cd+'/'+rv;
}
if ((rv != null)&&(rv != '')) {
var w = window.open('".r->uri."?FILEMANAGER_cmd=editfile&FILEMANAGER_curr_dir='+escape(cd)+'&FILEMANAGER_editfile='+escape(rv), 'FileManagerEditFile', 'scrollbars,resizable');
w.focus();
} else if (rv == '') {
window.alert('can not create blank file names');
}
return false;
\"><FONT COLOR=WHITE><B>new file</B></FONT></A>",
#New Directory
"<A HREF=# onclick=\"var f=window.document.FileManager; var rv=window.prompt('new directory name',''); if ((rv != null)&&(rv != '')) { f.FILEMANAGER_arg.value=rv; f.FILEMANAGER_cmd.value='mkdir'; f.submit(); } else if (rv == '') { window.alert('can...
FileManager.pm view on Meta::CPAN
###############################################################################
# -- Commands (called via form input from method execute_cmds or manually) -- #
###############################################################################
sub cmd_savefiledata {
my $o = shift;
my $base = r->param('FILEMANAGER_editfile');
$base =~ /([^\/]+)$/;
my $filename = $1;
remove $filename;
my $fh = IO::File->new("> ".$filename);
print $fh scalar(r->param('FILEMANAGER_filedata'));
$$o{MESSAGE} = "file saved";
$$o{view} = "pre_editfile";
return undef;
}
sub cmd_editfile {
my $o = shift;
my $base = r->param('FILEMANAGER_editfile');
$base =~ /([^\/]+)$/;
my $filename = $1;
if (! -e $filename) {
my $fh = IO::File->new("> ".$filename);
if ($fh) {
$$o{JS} .= ("
if (window.opener && window.opener.document.FileManager) {
window.opener.document.FileManager.submit();
}
");
}
}
$$o{view} = "pre_editfile";
}
sub cmd_paste {
my $o = shift;
my $arg1 = shift;
my ($buffer_type, $files) = $o->get_clip_board();
my $count = 0;
( run in 0.635 second using v1.01-cache-2.11-cpan-de7293f3b23 )