#!/usr/bin/perl use CGI ':standard'; use Net::FTP; BEGIN { #flush STDOUT immediately $| = 1; print header(-type=>'text/html'); } open(PAGE,">time.txt"); $now=localtime; print PAGE $now; close PAGE; if ($ENV{REQUEST_METHOD} ne "POST") { exit; } $copy = param('copy'); $mode = param('mode'); $newdir = param('newdir'); $username = param('user'); $password = param('pass'); $target = param('target'); $newfile = param('newfile'); $file = param('file'); $dir = param('dir'); $type = param('type'); if(param('edite')) { &change_file; } if(param('create')) { &make_file; } if(param('cpy')) { &get_new_file; } &do_work; sub do_work { $session=rand($numbers=1000); open STDERR, ">tmp/$session.txt"; use Net::FTP; $ftp = Net::FTP->new("$target",Debug=>1); $ftp->login("$username","$password"); $ftp->cwd("$dir"); if(param('rename')) { $ftp->rename("$file","$newfile"); } if(param('make_new')) { $ftp->put("tmp/$copy","$copy"); } if(param('del')) { $ftp->delete("$file"); } if(param('new_dir')) { $ftp->mkdir("$newdir",[0755]); } if(param('remove')) { $ftp->rmdir("$file"); } if(param('new_mode')) { $ftp->site(CHMOD,$mode,"$file"); } $ftp->quit; } close STDERR; &show_data; sub show_data { print qq!
!; print "";
open(DATA," ";
print "Your transaction took $passed seconds to complete";
} print " ";
print qq!To return to your directory listing just click onto RETURN and continue managing your files and directories.
!;
sub get_new_file {
use LWP::Simple;
getstore("ftp://$username:$password\@$target/$dir/$file",
"tmp/$copy");
print qq!!;
exit;
}
sub change_file {
use LWP::Simple;
$change=rand($num=1000);
getstore("ftp://$username:$password\@$target/$dir/$file",
"tmp/$change.txt");
print qq! !;
exit;
}
sub make_file {
$change=rand($num=1000);
print qq! !;
exit;
}
unlink("tmp/$session.txt");
if(param('make_new')) {
unlink("tmp/$copy");
}
exit;