Apache-FileManager
view release on metacpan or search on metacpan
0.16 Philip Collins
- 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
Apache::FileManager was written by Philip Collins
E<lt>pmc@cpan.orgE<gt>.
=cut
use strict;
#use warnings;
use IO::File;
use Apache::Request;
use Apache::Util qw(escape_html);
use Apache::File;
use File::NCopy qw(copy);
use File::Copy qw(move);
use File::Remove qw(remove);
use File::stat;
use Archive::Any;
use POSIX qw(strftime);
use CGI::Cookie;
use Apache::Constants ':common';
#use Data::Dumper;
FileManager.pm view on Meta::CPAN
UTCstring = Today.toUTCString();
return UTCstring;
}
function getcookie(cookiename) {
var cookiestring=''+document.cookie;
var index1=cookiestring.indexOf(cookiename);
if (index1==-1 || cookiename=='') return '';
var index2=cookiestring.indexOf(';',index1);
if (index2==-1) index2=cookiestring.length;
return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}
function setcookie(name,value,duration){
cookiestring=name+'='+escape(value)+';EXPIRES='+getexpirydate(duration);
document.cookie=cookiestring;
if(!getcookie(name)){ return false; }
else{ return true; }
}
function print_upload () {
var w = window.open('','FileManagerUpload','scrollbars=yes,resizable=yes,width=500,height=440');
var d = w.document.open();
d.write(\"<HTML><BODY><CENTER><H1>Upload Files</H1><FORM NAME=UploadForm ACTION='".r->uri."' METHOD=POST onsubmit='window.opener.focus();' ENCTYPE=multipart/form-data><INPUT TYPE=HIDDEN NAME=FILEMANAGER_curr_dir VALUE='".r->param('FILEMANAGER_cur...
for (var i=1; i <= 10; i++) {
FileManager.pm view on Meta::CPAN
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 = '';
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
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='".&escape_html($curr_dir.$file)."'; 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>";
FileManager.pm view on Meta::CPAN
}
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>".&escape_html($file.$type)."</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>";
FileManager.pm view on Meta::CPAN
$o->$method($arg);
}
}
sub get_selected_files {
my $o = shift;
my @sel_files = r->param('FILEMANAGER_sel_files');
return \ @sel_files;
}
#escape spaces in filename
sub filename_esc {
my $o = shift;
my $f = shift;
$f =~ s/\ /\\\ /g;
return $f;
}
sub formated_date {
my $o = shift;
my $date = shift || time;
( run in 1.021 second using v1.01-cache-2.11-cpan-c21f80fb71c )