-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserftp.pl
More file actions
61 lines (56 loc) · 2.06 KB
/
userftp.pl
File metadata and controls
61 lines (56 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/perl -w
$|=1;
use strict;
use warnings;
use CGI::Simple;
use Net::FTP;
my $q = CGI::Simple->new();
my %in = $q->Vars();
my $output = qq();
if($in{server} && $in{login} && $in{pass}) {
if($in{file}) {
print $q->redirect(-charset => 'utf-8', -uri => "http://localhost/tv/rh.pl?act=offline&file=$in{file}&server=$in{server}&login=$in{login}&passwd=$in{pass}");
#print qq(<h2>Файл к закачке: $in{file}</h2>);
exit 0;
}
my $ftp = Net::FTP->new($in{server}) or $output.=qq(<h2>Cannot connect to $in{server}: $@</h2>);
# логин
$ftp->login($in{login},$in{pass}) or $output.=qq(<h2>Cannot login:). $ftp->message().qq(</h2>);
if($in{dir}) {# если передана папка, то переходим в нее
$ftp->cwd($in{dir}) or $output.=qq(<h2>Cannot change working directory on $in{dir}:). $ftp->message() .qq(</h2>);
} else {
$in{dir} = ".";
}
my @files=$ftp->ls();
$output.=qq(<h1><a href ="?server=$in{server}&login=$in{login}&pass=$in{pass}&dir=$in{dir}">$in{dir}</a></h1>);
$output.=qq(<form name="upload" method="get">
<input type="hidden" name="server" value="$in{server}">
<input type="hidden" name="login" value="$in{login}">
<input type="hidden" name="pass" value="$in{pass}">
);
foreach my $file(@files) {
if($file=~/\.\S{3,}$/g) {
$ftp->binary;
my $size = $ftp->size($file);
$output.=qq(<input type="radio" name="file" value="$in{dir}/$file|$size">$file<br>);
} else {
$output.=qq(<a href="?server=$in{server}&login=$in{login}&pass=$in{pass}&dir=$in{dir}/$file" target="_self">$file</a><br>);
}
}
$output.=qq(<input type="submit" value="загрузить"></form>);
$ftp->quit;
}
#else {
# $output = qq(
# <body>
# <form name="ftp" method="post">
# Сервер: <input type="text" name="server"><br>
# Пользователь: <input type="text" name="login"><br>
# Пароль: <input type="password" name="pass"><br>
# <input type="submit" name="submit" value="check">
# </form>
#</body>
# );
#}
print $q->header(-charset => 'utf-8');
print $output;