source: npl/mailserver/dspam/dspam-3.10.2/webui/cgi-bin/configure.pl.in

Last change on this file was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100755
File size: 6.8 KB
RevLine 
[c5c522c]1#!/usr/bin/perl
2
3# $Id: configure.pl,v 1.07 2011/06/28 00:13:48 sbajic Exp $
4# DSPAM
5# COPYRIGHT (C) 2002-2012 DSPAM PROJECT
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19#
20# This configuration file is read by all the CGI scripts to configure both the
21# environment that DSPAM is working in and the way it will display information
22# to the web user.
23
24# Default DSPAM enviroment
25$CONFIG{'DSPAM_HOME'}   = "/home/system/dspam";
26$CONFIG{'DSPAM_BIN'}    = "/usr/bin";
27$CONFIG{'DSPAM'}        = $CONFIG{'DSPAM_BIN'} . "/dspam";
28$CONFIG{'DSPAM_STATS'}  = $CONFIG{'DSPAM_BIN'} . "/dspam_stats";
29$CONFIG{'DSPAM_ARGS'}   = "--deliver=innocent --class=innocent " .
30                          "--source=error --mail-from=quarantine\@spamfilter.lan --user %CURRENT_USER%";
31$CONFIG{'TEMPLATES'}    = "./templates";        # Location of HTML templates
32$CONFIG{'DSPAM_PROCESSES'} = "ps auxw | grep dspam | grep -v 'grep\|cgi\|sock' | wc -l"; # use ps -deaf for Solaris
33$CONFIG{'MAIL_QUEUE'}   = "mailq | grep '^[0-9,A-F]\{10,12\}[\t ][\t ]*[1-9]' | wc -l";
34
35$CONFIG{'WEB_ROOT'}     = ""; # URL location of included htdocs/ files
36
37# Default DSPAM display
38#$CONFIG{'DATE_FORMAT'} = "%d.%m.%Y %H:%M"; # Date format in strftime style
39                                             # if undefined use default DSPAM display format
40$CONFIG{'HISTORY_SIZE'} = 799;          # Number of items in history
41$CONFIG{'HISTORY_PER_PAGE'} = 100;      # Number of items per page
42$CONFIG{'HISTORY_DUPLICATES'} = "yes";  # Wether to show duplicate entries in history "yes" or "no"
43$CONFIG{'HISTORY_HTMLIZE'} = "no";      # Wether to HTML-ize sender and subject in history "yes" or "no"
44$CONFIG{'QUARANTINE_HTMLIZE'} = "no";   # Wether to HTML-ize sender and subject in quarantine "yes" or "no"
45$CONFIG{'MAX_COL_LEN'}  = 50;           # Max chars in list columns
46$CONFIG{'SORT_DEFAULT'} = "Rating";     # Show quarantine by "Date" or "Rating"
47$CONFIG{'3D_GRAPHS'}    = 1;            # 0=graphs in 2D, 1=graphs in 3D
48$CONFIG{'OPTMODE'}      = "NONE";       # OUT=OptOut IN=OptIn NONE=not selectable
49
50# Full path to TTF font(s) used for legend, x and y labels in Graphs. GD must be compiled
51# with TTF support if you want to use this feature.
52#$CONFIG{'GRAPHS_X_LABEL_FONT'} = "/usr/share/fonts/dejavu/DejaVuSans.ttf";
53#$CONFIG{'GRAPHS_Y_LABEL_FONT'} = "/usr/share/fonts/dejavu/DejaVuSans.ttf";
54#$CONFIG{'GRAPHS_LEGEND_FONT'}  = "/usr/share/fonts/dejavu/DejaVuSans-Bold.ttf";
55
56# Add customized settings below
57$CONFIG{'LOCAL_DOMAIN'} = "example.org";
58
59$ENV{'PATH'}            = "$ENV{'PATH'}:$CONFIG{'DSPAM_BIN'}";
60
61# Autodetect filesystem layout and preference options
62$CONFIG{'AUTODETECT'}   = 1;
63
64# Or, if you're running dspam.cgi as untrusted, it won't be able to auto-detect
65# so you will need to specify some features manually:
66#$CONFIG{'AUTODETECT'}  = 0;
67#$CONFIG{'LARGE_SCALE'} = 0;
68#$CONFIG{'DOMAIN_SCALE'}= 0;
69#$CONFIG{'PREFERENCES_EXTENSION'} = 0;
70
71# Get DSPAM version
72$CONFIG{'DSPAM_VERSION'} = "Unknown Version";
73open(PIPE, $CONFIG{'DSPAM'} . " --version|");
74while(<PIPE>) {
75  chomp;
76  if (/^(DSPAM Anti\-Spam Suite .*)$/) {
77    $CONFIG{'DSPAM_VERSION'} = $1;
78    last;
79  }
80}
81close(PIPE);
82
83# Make a list of available templates/languages
84my @dslanguages = ();
85undef %LANG;
86require "$CONFIG{'TEMPLATES'}/strings.pl";
87while (($key, $value) = each(%LANG)) {
88  $CONFIG{'LANG'}->{'en'}->{$key} = $value;
89}
90$CONFIG{'LANG'}->{'en'}->{'TEMPLATEDIR'} = $CONFIG{'TEMPLATES'};
91$CONFIG{'LANG'}->{'en'}->{'NAME'} = 'en';
92$CONFIG{'LANG'}->{'en'}->{'NAME'} = $LANG{'lang_name'} if (defined $LANG{'lang_name'});
93push(@dslanguages, qq!<option value="en">&nbsp;$CONFIG{'LANG'}->{'en'}->{'NAME'}</option>!);
94# Do now the other languages
95opendir TEMPLDIR, $CONFIG{'TEMPLATES'} or die "Can not open template directory";
96my @templatefiles = sort grep !/^\.\.?$/, readdir TEMPLDIR;
97closedir TEMPLDIR;
98foreach (@templatefiles) {
99  my $langcode = $_;
100  my $langname = $_;
101  if ($langcode ne "" && -d "$CONFIG{'TEMPLATES'}/$langcode") {
102    $CONFIG{'LANG'}->{$langcode}->{'TEMPLATEDIR'} = "$CONFIG{'TEMPLATES'}/$langcode";
103    $CONFIG{'LANG'}->{$langcode}->{'NAME'} = $langcode;
104    undef %LANG;
105    if (-s "$CONFIG{'TEMPLATES'}/$langcode/strings.pl") {
106      require "$CONFIG{'TEMPLATES'}/$langcode/strings.pl";
107    } else {
108      while (($key, $value) = each(%{$CONFIG{'LANG'}->{'en'}})) {
109        $LANG{$key} = $value if($key ne "NAME" && $key ne "TEMPLATEDIR");
110      }
111      delete($LANG{'lang_name'});
112    }
113    $CONFIG{'LANG'}->{$langcode}->{'NAME'} = $LANG{'lang_name'} if (defined $LANG{'lang_name'});
114    while (($key, $value) = each(%LANG)) {
115      $CONFIG{'LANG'}->{$langcode}->{$key} = $value;
116    }
117    push(@dslanguages, qq!<option value="$langcode">&nbsp;$CONFIG{'LANG'}->{$langcode}->{'NAME'}</option>!);
118  }
119}
120if (scalar(@dslanguages) == 0) {
121  $CONFIG{'LANGUAGES'} = "";
122} else {
123  unshift(@dslanguages, qq!&nbsp;&nbsp;<select name="language">!);
124  push(@dslanguages, qq!</select>!);
125  $CONFIG{'LANGUAGES'} = join("\n", @dslanguages);
126}
127@templatefiles=();
128
129# Determine if templates are available for the current
130# HTTP_ACCEPT_LANGUAGE (see RFC 4646 for more info).
131my $langlist = lc($ENV{'HTTP_ACCEPT_LANGUAGE'})||'';
132my $langpat = qr'[a-zA-Z]{1,8}(\-[a-zA-Z]{1,8})?';
133my $qvalpat = qr'(0(\.\d{0,3})?)|(1(\.0{0,3})?)';
134my $q = -1.0;
135my $templates = '';
136my $langused = '';
137for my $langpref (split /,\s*/, $langlist) {
138  $langpref =~ /^([^;]+)(;q=)?(.*)?/;
139  my $lang = $1 || '';
140  my $qval = $3 || 1.0;
141  my $langcode = '';
142  if ($lang =~ /^($langpat)|(x\-$langpat)|\*$/ && $qval =~ /^($qvalpat)$/) {
143    if ($q lt $qval) {
144      $lang =~ s/^x\-//;
145      if ($lang =~ /^(.*)\-.+$/) {
146        $langcode = $1;
147      }
148      if ($lang ne '' && $lang ne '*' && -e $CONFIG{'TEMPLATES'} . '/' . $lang . '/nav_performance.html') {
149        $q = $qval;
150        $templates = $CONFIG{'TEMPLATES'} . '/' . $lang;
151        $langused = $lang;
152      } elsif ($langcode eq 'en') {
153        $q = $qval;
154        $templates = $CONFIG{'TEMPLATES'};
155        $langused = 'en';
156      } elsif ($langcode ne '' && -e $CONFIG{'TEMPLATES'} . '/' . $langcode . '/nav_performance.html') {
157        $q = $qval;
158        $templates = $CONFIG{'TEMPLATES'} . '/' . $langcode;
159        $langused = $langcode;
160      }
161    }
162  }
163}
164if ($templates ne '') {
165  $CONFIG{'TEMPLATES'} = $templates;
166  $CONFIG{'LANGUAGE_USED'} = $langused;
167} else {
168  $CONFIG{'LANGUAGE_USED'} = 'en';
169}
170
171$CONFIG{'DSPAM_CGI'} = "dspam.cgi";
172
173# Configuration was successful
1741;
Note: See TracBrowser for help on using the repository browser.