3 # Download and install a webmin theme
5 require './webmin-lib.pl';
6 if ($ENV{REQUEST_METHOD} eq "POST") { &ReadParseMime(); }
7 else { &ReadParse(); $no_upload = 1; }
10 $theme_no_table = 1 if ($in{'source'} == 2);
11 &ui_print_header(undef, $text{'install_title'}, "");
13 if ($in{'source'} == 0) {
15 &error_setup(&text('themes_err1', $in{'file'}));
17 if (!(-r $file)) { &inst_error($text{'themes_efile'}); }
19 elsif ($in{'source'} == 1) {
21 &error_setup($text{'themes_err2'});
24 &inst_error($text{'themes_ebrowser'});
26 $file = &transname(&file_basename($in{'upload_filename'}));
28 print MOD $in{'upload'};
31 elsif ($in{'source'} == 2) {
32 # from ftp or http url
33 &error_setup(&text('themes_err3', $in{'url'}));
34 $file = &transname(&file_basename($in{'url'}));
36 $progress_callback_url = $in{'url'};
37 if ($in{'url'} =~ /^(http|https):\/\/([^\/]+)(\/.*)$/) {
39 $host = $2; $page = $3; $port = $ssl ? 443 : 80;
40 if ($host =~ /^(.*):(\d+)$/) { $host = $1; $port = $2; }
41 &http_download($host, $port, $page, $file, \$error,
42 \&progress_callback, $ssl);
44 elsif ($in{'url'} =~ /^ftp:\/\/([^\/]+)(:21)?\/(.*)$/) {
45 $host = $1; $ffile = $3;
46 &ftp_download($host, $ffile, $file, \$error,
49 else { &inst_error($text{'themes_eurl'}); }
50 &inst_error($error) if ($error);
53 # Install the theme(s)
54 $rv = &install_webmin_module($file, $need_unlink, 0, undef);
56 @mdescs = @{$rv->[0]};
58 @msizes = @{$rv->[2]};
64 # Display something nice for the user
65 print "$text{'themes_done'} <p>\n";
67 for($i=0; $i<@mdescs; $i++) {
68 print &text('themes_line', "<b>$mdescs[$i]</b>",
69 "<tt>$mdirs[$i]</tt>", $msizes[$i]),"<p>\n";
72 &ui_print_footer("edit_themes.cgi", $text{'themes_return'},
73 "", $text{'index_return'});
77 print "<br><b>$whatfailed : $_[0]</b> <p>\n";
78 &ui_print_footer("", $text{'index_return'});