Handle hostnames with upper-case letters
[webmin.git] / squid / purge.cgi
1 #!/usr/local/bin/perl
2 # Call squidclient to remove just one URL
3
4 require './squid-lib.pl';
5 &error_setup($text{'purge_err'});
6 $access{'rebuild'} || &error($text{'clear_ecannot'});
7 &ReadParse();
8 $in{'url'} || &error($text{'purge_eurl'});
9
10 &ui_print_header(undef, $text{'purge_title'}, "");
11
12 # Get the port number
13 $conf = &get_config();
14 if ($squid_version >= 2.3) {
15         @ports = &find_config("http_port", $conf);
16         foreach $p (@ports) {
17                 if ($p->{'values'}->[0] =~ /(\d+)$/) {
18                         $port = $1;
19                         last;
20                         }
21                 }
22         }
23 else {
24         $port = &find_value("http_port", $conf);
25         $port ||= 3128;
26         }
27
28 # Run it
29 print &text('purge_doing', "<tt>$in{'url'}</tt>"),"\n";
30 $cmd = "$config{'squidclient'} -p $port -m PURGE ".quotemeta($in{'url'});
31 $out = &backquote_logged("$cmd 2>&1");
32 print "<pre>$out</pre>\n";
33 if ($?) {
34         print $text{'purge_failed'},"<br>\n";
35         }
36 else {
37         print $text{'purge_done'},"<br>\n";
38         }
39 &webmin_log("purge", undef, $in{'url'});
40
41 &ui_print_footer("", $text{'index_return'});
42