-
Notifications
You must be signed in to change notification settings - Fork 16
/
http_download.cgi
43 lines (36 loc) · 1.07 KB
/
http_download.cgi
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
#!/usr/bin/perl
require './filemin-lib.pl';
use lib './lib';
&ReadParse();
get_paths();
print_ajax_header();
my $mode;
my @errors;
my ($host, $port, $page, $ssl) = &parse_http_url($in{'link'});
if (!$host || !$in{'link'}) {
# Not an HTTP or FTP URL
push @errors, $text{'error_invalid_uri'};
} else {
# Looks like a valid URL
my $file = $page;
$file =~ s/^.*\///;
$file ||= "index.html";
if(-e "$cwd/$file") {
push @errors, "<b>$file</b> $text{'file_already_exists'} <b>$path</b>";
} else {
if ($ssl == 0 || $ssl == 1) {
# HTTP or HTTPS download
&http_download($host, $port, $page, "$cwd/$file", undef,
\&filemin_progress_callback, $ssl,
$in{'username'}, $in{'password'});
} else {
# Actually an FTP download
&ftp_download($host, $page, "$cwd/$file", undef,
\&filemin_progress_callback,
$in{'username'}, $in{'password'}, $port);
}
}
}
if (scalar(@errors) > 0) {
print status('error', \@errors);
}