3 # Download and install a usermin theme
5 require './usermin-lib.pl';
6 $access{'themes'} || &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('themes_err1', $in{'file'}));
18 if (!(-r $file)) { &inst_error($text{'themes_efile'}); }
20 elsif ($in{'source'} == 1) {
22 &error_setup($text{'themes_err2'});
26 &inst_error($text{'themes_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('themes_err3', $in{'url'}));
37 $progress_callback_url = $in{'url'};
38 if ($in{'url'} =~ /^(http|https):\/\/([^\/]+)(\/.*)$/) {
40 $host = $2; $page = $3; $port = $ssl ? 443 : 80;
41 if ($host =~ /^(.*):(\d+)$/) { $host = $1; $port = $2; }
42 &http_download($host, $port, $page, $file, \$error,
43 \&progress_callback, $ssl);
45 elsif ($in{'url'} =~ /^ftp:\/\/([^\/]+)(:21)?\/(.*)$/) {
46 $host = $1; $ffile = $3;
47 &ftp_download($host, $ffile, $file, \$error,
50 else { &inst_error($text{'themes_eurl'}); }
51 &inst_error($error) if ($error);
54 # Install the theme(s)
55 $rv = &install_usermin_module($file, $need_unlink, 0);
57 @mdescs = @{$rv->[0]};
59 @msizes = @{$rv->[2]};
65 # Display something nice for the user
66 print "$text{'themes_done'} <p>\n";
68 for($i=0; $i<@mdescs; $i++) {
69 print &text('themes_line', "<b>$mdescs[$i]</b>",
70 "<tt>$mdirs[$i]</tt>", $msizes[$i]),"<p>\n";
73 &ui_print_footer("", $text{'index_return'});
77 print "<br><b>$whatfailed : $_[0]</b> <p>\n";
79 &ui_print_footer("", $text{'index_return'});