3 # Display a menu of spamassassin config category icons
5 require './spam-lib.pl';
7 $hsl = $module_info{'usermin'} ? undef :
8 &help_search_link("spamassassin", "perl", "google");
9 &set_config_file_in(\%in);
11 if (!&has_command($config{'spamassassin'}) ||
12 (!$module_info{'usermin'} && !($vers = &get_spamassassin_version(\$out)))) {
14 &ui_print_header($header_subtext, $text{'index_title'}, "", undef, 1, 1,
17 if ($module_info{'usermin'}) {
18 print &text('index_ecmd2',
19 "<tt>$config{'spamassassin'}</tt>"),"<p>\n";
22 print &text('index_ecmd', "<tt>$config{'spamassassin'}</tt>",
23 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
25 # Offer to install package
26 &foreign_require("software", "software-lib.pl");
27 $lnk = &software::missing_install_link(
28 "spamassassin", $text{'index_spamassassin'},
29 "../$module_name/", $text{'index_title'});
33 elsif (&foreign_available("cpan")) {
34 # Offer to install perl module
35 $modname = "Mail::SpamAssassin";
36 print &text('index_cpan', "<tt>$modname</tt>",
37 "../cpan/download.cgi?source=3&cpan=$modname&mode=2&return=/$module_name/&returndesc=".&urlize($module_info{'desc'})),"<p>\n";
42 $vtext = $module_info{'usermin'} ? undef :
43 &text('index_version', $vers);
44 &ui_print_header($header_subtext, $text{'index_title'}, "", undef,
45 1, 1, undef, $hsl, undef, undef, $vtext);
47 if (!-r $local_cf && !-d $local_cf && !$module_info{'usermin'}) {
49 print &text('index_econfig',
51 "../config.cgi?$module_name"),"<p>\n";
53 elsif ($dberr = &check_spamassassin_db()) {
54 # Cannot contact the DB
55 print &text('index_edb', $dberr,
56 "../config.cgi?$module_name"),"<p>\n";
59 # Work out if SpamAssassin is enabled in procmail
60 if ($warn_procmail && &foreign_check("procmail")) {
61 &foreign_require("procmail", "procmail-lib.pl");
62 $spam_enabled = 0; # Found call to spamassassin
63 $delivery_enabled = 0; # Found X-Spam: header rule
64 @pmrcs = &get_procmailrc();
65 foreach $pmrc (@pmrcs) {
67 &procmail::parse_procmail_file($pmrc);
68 local $isglobal = $pmrc eq
69 $config{'global_procmailrc'};
70 if (&find_spam_recipe(\@recipes)) {
73 if (&find_file_recipe(\@recipes)) {
75 # Enabled globally, and so
76 # cannot be changed by user
77 $delivery_enabled ||= -2;
80 $delivery_enabled ||= 1;
83 if (&find_virtualmin_recipe(\@recipes)) {
84 # Controlled by Virtualmin
86 &find_force_default_receipe(
88 # User .procmailrc files are
91 $delivery_enabled ||= -2;
94 # Users can have a .procmailrc
96 $delivery_enabled ||= 1;
102 # don't know, or checking disabled
104 $delivery_enabled = -1;
106 if ($spam_enabled == 0) {
107 if ($module_info{'usermin'}) {
108 print &text('index_warn_usermin',
109 "<tt>$pmrcs[0]</tt>",
110 "<tt>$pmrcs[1]</tt>"),"<p>\n";
113 print &text('index_warn_webmin',
114 "<tt>$pmrcs[0]</tt>"),"<p>\n";
118 # Check if razor is set up
119 if ($module_info{'usermin'} &&
120 -r "$remote_user_info[7]/.razor/identity") {
125 @pages = ( 'white', 'score', 'report', 'user' );
126 push(@pages, 'simple') if (!$module_info{'usermin'} ||
127 &find_default("allow_user_rules",0));
128 push(@pages, 'priv') if (!$module_info{'usermin'});
129 push(@pages, 'mail') if ($module_info{'usermin'} &&
130 $userconfig{'spam_file'});
131 push(@pages, 'razor') if (!$razor && $module_info{'usermin'});
132 push(@pages, 'setup') if ($spam_enabled == 0);
133 push(@pages, 'procmail') if ($delivery_enabled == 1);
134 push(@pages, 'db') if (!$module_info{'usermin'});
135 push(@pages, 'awl') if (&supports_auto_whitelist());
136 @pages = grep { &can_use_page($_) } @pages;
137 $sfolder = $module_info{'usermin'} ? &spam_file_folder()
140 @pages = grep { $_ ne 'mail' } @pages;
142 @links = map { $_ eq "mail" ? "../mailbox/index.cgi?folder=$sfolder->{'index'}" : "edit_${_}.cgi" } @pages;
144 foreach my $l (@links) {
146 $l .= "?file=".&urlize($in{'file'}).
147 "&title=".&urlize($in{'title'});
151 @icons = map { "images/${_}.gif" } @pages;
152 @titles = map { $text{"${_}_title"} } @pages;
153 &icons_table(\@links, \@titles, \@icons);
155 # Show buttons for HUPing spamd processes (if any)
156 if (!$module_info{'usermin'} &&
157 (@pids = &get_process_pids())) {
159 print "<form action=apply.cgi>\n";
161 print "<tr> <td><input type=submit ",
162 "value='$text{'index_apply'}'></td>\n";
163 print "<td>",&text('index_applydesc',
164 "<tt>".join(" and ", &unique(
165 map { $_->[1] } @pids))."</tt>"),"</td>\n";
171 &ui_print_footer("/", $text{'index'});