Handle hostnames with upper-case letters
[webmin.git] / webmin / change_osdn.cgi
1 #!/usr/local/bin/perl
2 # Change OSDN download settings
3
4 require './webmin-lib.pl';
5 &error_setup($text{'proxy_err'});
6 &ReadParse();
7
8 if ($in{'clear'}) {
9         # Just clearing Webmin's cache
10         &ui_print_header(undef, $text{'clear_title'}, "");
11
12         $sz = &disk_usage_kb($main::http_cache_directory)*1024;
13         if ($sz > 0) {
14                 opendir(DIR, $main::http_cache_directory);
15                 @files = readdir(DIR);
16                 closedir(DIR);
17                 &system_logged("rm -rf ".
18                                quotemeta($main::http_cache_directory));
19                 print &text('clear_done', &nice_size($sz), @files-2),"<p>\n";
20                 &webmin_log("osdnclear");
21                 }
22         else {
23                 print &text('clear_none'),"<p>\n";
24                 }
25         
26         &ui_print_footer("", $text{'index_return'});
27         exit;
28         }
29
30 &lock_file("$config_directory/config");
31
32 # Save cache size
33 if ($in{'cache_def'}) {
34         delete($gconfig{'cache_size'});
35         }
36 else {
37         $in{'cache'} =~ /^\d+$/ || &error($text{'proxy_ecache'});
38         $gconfig{'cache_size'} = $in{'cache_units'}*$in{'cache'};
39         }
40
41 # Save cache days
42 if ($in{'days_def'}) {
43         delete($gconfig{'cache_days'});
44         }
45 else {
46         $in{'days'} =~ /^\d+$/ || &error($text{'proxy_edays'});
47         $gconfig{'cache_days'} = $in{'days'};
48         }
49
50 # Save modules
51 if ($in{'mods_def'} == 0) {
52         delete($gconfig{'cache_mods'});
53         }
54 else {
55         @mods = split(/\0/, $in{'mods'});
56         @mods || &error($text{'proxy_emods'});
57         if ($in{'mods_def'} == 1) {
58                 $gconfig{'cache_mods'} = join(" ", @mods);
59                 }
60         else {
61                 $gconfig{'cache_mods'} = "!".join(" ", @mods);
62                 }
63         }
64
65 # Write out the file
66 &write_file("$config_directory/config", \%gconfig);
67 &unlock_file("$config_directory/config");
68 &webmin_log('osdn', undef, undef, \%in);
69
70 &redirect("");
71