3 # Display a menu of different kinds of options
5 require './squid-lib.pl';
7 # Check for the squid executable
8 if (!&has_command($config{'squid_path'})) {
9 &ui_print_header(undef, $text{'index_header'}, "", undef, 1, 1);
10 print &text('index_msgnoexe',$config{'squid_path'},
11 $module_name),"<p>\n";
13 &foreign_require("software", "software-lib.pl");
14 $lnk = &software::missing_install_link("squid", $text{'index_squid'},
15 "../$module_name/", $text{'index_header'});
16 print $lnk,"<p>\n" if ($lnk);
18 &ui_print_footer("/", $text{'index_return'});
22 # Check for squid config file
23 if (!-r $config{'squid_conf'}) {
24 &ui_print_header(undef, $text{'index_header'}, "", undef, 1, 1);
25 print &text('index_msgnoconfig',$config{'squid_conf'},
28 &ui_print_footer("/", $text{'index_return'});
32 # Check the version number
33 $fullver = $ver = `$config{'squid_path'} -v 2>&1`;
34 if ($ver =~ /version\s+(\S+)/i) {
37 if ($ver =~ /(1\.1)\.\d+/ || $ver =~ /(1)\.NOVM/ ||
38 $ver =~ /(2\.[01234567])\./ || $ver =~ /(3\.[01])/) {
40 open(VERSION, ">$module_config_directory/version");
41 print VERSION $1,"\n";
46 &ui_print_header(undef, $text{'index_header'}, "", undef, 1, 1);
47 print &text('index_msgnosupported2', "<tt>1.1</tt>", "<tt>2.7</tt>"),
49 print &text('index_squidver', "$config{'squid_path'} -v"),"\n";
50 print "<pre>$fullver</pre>\n";
51 &ui_print_footer("/", $text{'index_return'});
55 # Check for the cache directory
56 $conf = &get_config();
57 if (!&check_cache($conf, \@caches)) {
58 &ui_print_header(undef, $text{'index_header'}, "", undef, 1, 1);
61 print &text('index_msgnodir1', join(", ", @caches));
64 print &text('index_msgnodir2', $caches[0]);
66 print $text{'index_msgnodir3'},"<br>\n";
67 print "<form action=init_cache.cgi>\n";
68 print "<input type=submit value=\"$text{'index_buttinit'}\">\n";
69 local $def = defined(getpwnam("squid")) ? "squid" :
70 defined(getpwnam("httpd")) ? "httpd" : undef;
71 if (!&find_config("cache_effective_user", $conf)) {
72 print $text{'index_asuser'}," ",&unix_user_input("user", $def),
76 print "<input type=hidden name=nouser value=1>\n";
78 print "<input type=hidden name=caches value=\"",
79 join(" ",@caches),"\">\n";
80 print "</form></center>\n";
84 &ui_print_header(undef, $text{'index_header'}, "", "intro",
85 1, 1, 0, &restart_button()."<br>".
86 &help_search_link("squid", "doc", "google"),
87 undef, undef, &text('index_version', $squid_version));
90 if ($squid_version < 2) {
94 local $file = &get_auth_file($conf);
97 $calamaris = &has_command($config{'calamaris'});
98 $delay = $squid_version >= 2.3;
99 $authparam = $squid_version >= 2;
100 $headeracc = $squid_version >= 2.5;
101 $iptables = &foreign_check("firewall");
103 @otitles = ( 'portsnets', 'othercaches', 'musage', 'logging',
104 'copts', 'hprogs', 'actrl', 'admopts',
105 ( $auth ? ( 'proxyauth' ) : ( ) ),
106 ( $authparam ? ( 'authparam' ) : ( ) ),
107 ( $delay ? ( 'delay' ) : ( ) ),
108 ( $headeracc ? ( 'headeracc' ) : ( ) ),
111 ( $iptables ? ( 'iptables' ) : ( ) ),
112 'cms', 'cachemgr', 'rebuild',
113 ( $calamaris ? ( 'calamaris' ) : ( ) ) );
114 @olinks = ( "edit_ports.cgi", "edit_icp.cgi", "edit_mem.cgi",
115 "edit_logs.cgi", "edit_cache.cgi", "edit_progs.cgi",
116 "edit_acl.cgi", "edit_admin.cgi",
117 ( $auth == 1 ? ( "edit_auth.cgi" ) :
118 $auth == 2 ? ( "edit_nauth.cgi" ) : ( ) ),
119 ( $authparam ? ( "edit_authparam.cgi" ) : ( ) ),
120 ( $delay ? ( 'edit_delay.cgi' ) : ( ) ),
121 ( $headeracc ? ( 'list_headeracc.cgi' ) : ( ) ),
124 ( $iptables ? ( "edit_iptables.cgi" ) : ( ) ),
125 "cachemgr.cgi", "edit_cachemgr.cgi", "clear.cgi",
126 ( $calamaris ? ( "calamaris.cgi" ) : ( ) ) );
127 for($i=0; $i<@otitles; $i++) {
128 if (!$access{$otitles[$i]}) {
129 splice(@otitles, $i, 1);
130 splice(@olinks, $i, 1);
134 $otitles[$i] = $text{'index_'.$otitles[$i]};
137 @oicons = map { $t=$_; $t=~s/cgi/gif/; $t=~s/edit_// if ($t ne 'edit_cachemgr.gif'); "images/$t" } @olinks;
138 &icons_table(\@olinks, \@otitles, \@oicons);
140 # Show start/stop/apply buttons
141 if ($config{'restart_pos'} != 1) {
143 print &ui_buttons_start();
144 if ($pid = &is_squid_running()) {
145 if ($access{'restart'}) {
146 print &ui_buttons_row("restart.cgi", $text{'index_restart'},
147 $text{'index_restartdesc'},
148 &ui_hidden("pid", $pid).
149 &ui_hidden("redir", "index.cgi"));
151 if ($access{'start'}) {
152 print &ui_buttons_row("stop.cgi", $text{'index_stop'},
153 $text{'index_stopdesc'},
154 &ui_hidden("pid", $pid).
155 &ui_hidden("redir", "index.cgi"));
159 if ($access{'start'}) {
160 print &ui_buttons_row("start.cgi", $text{'index_start'},
161 $text{'index_startdesc'},
162 &ui_hidden("redir", "index.cgi"));
165 print &ui_buttons_end();
168 &ui_print_footer("/", $text{'index_return'});