3 # Download and install a usermin module
5 require './usermin-lib.pl';
6 $access{'umods'} || &error($text{'acl_ecannot'});
7 if ($ENV{REQUEST_METHOD} eq "POST") { &ReadParseMime(); }
8 else { &ReadParse(); $no_upload = 1; }
11 $theme_no_table = 1 if ($in{'source'} == 2);
12 &ui_print_header(undef, $text{'install_title'}, "");
14 if ($in{'source'} == 0) {
16 &error_setup(&text('install_err1', $in{'file'}));
18 if (!(-r $file)) { &inst_error($text{'install_efile'}); }
20 elsif ($in{'source'} == 1) {
22 &error_setup($text{'install_err2'});
26 &inst_error($text{'install_ebrowser'});
28 &open_tempfile(MOD, ">$file", 0, 1);
29 &print_tempfile(MOD, $in{'upload'});
32 elsif ($in{'source'} == 2) {
33 # from ftp or http url
34 &error_setup(&text('install_err3', $in{'url'}));
38 $progress_callback_url = $in{'url'};
39 if ($in{'url'} =~ /^(http|https):\/\/([^\/]+)(\/.*)$/) {
41 $host = $2; $page = $3; $port = $ssl ? 443 : 80;
42 if ($host =~ /^(.*):(\d+)$/) { $host = $1; $port = $2; }
43 &http_download($host, $port, $page, $file, \$error,
44 \&progress_callback, $ssl);
46 elsif ($in{'url'} =~ /^ftp:\/\/([^\/]+)(:21)?\/(.*)$/) {
47 $host = $1; $ffile = $3;
48 &ftp_download($host, $ffile, $file, \$error, \&progress_callback);
50 else { &inst_error($text{'install_eurl'}); }
51 &inst_error($error) if ($error);
54 # Install the module(s)
55 $rv = &install_usermin_module($file, $need_unlink, $in{'nodeps'});
57 @mdescs = @{$rv->[0]};
59 @msizes = @{$rv->[2]};
65 # Display something nice for the user
66 print "$text{'install_desc'} <p>\n";
68 for($i=0; $i<@mdescs; $i++) {
69 $mdirs[$i] =~ /\/([^\/]+)$/;
70 if (%minfo = &get_usermin_module_info($1)) {
72 local $cat = $text{"category_".$minfo{'category'}};
73 $cat = $text{"category_"} if (!$cat);
74 print &text($minfo{'hidden'} ? 'install_line3' :
75 'install_line2', "<b>$mdescs[$i]</b>",
76 "<tt>$mdirs[$i]</tt>", $msizes[$i], $cat),
79 elsif (%tinfo = &get_usermin_theme_info($1)) {
81 print &text('themes_line', "<b>$mdescs[$i]</b>",
82 "<tt>$mdirs[$i]</tt>", $msizes[$i]),
87 &ui_print_footer("edit_mods.cgi?mode=install", $text{'mods_return'},
88 "", $text{'index_return'});
92 print "<b>$whatfailed : $_[0]</b> <p>\n";
93 &ui_print_footer("", $text{'index_return'});