added the BUG file, updated config script
[squirrelmail.git] / config / conf.pl
1 #!/usr/bin/perl
2 # conf.pl
3 # Written March 26, 2000
4 # Luke Ehresman (lehresma@css.tayloru.edu)
5 #
6 # A simple configure script to configure squirrelmail
7 ############################################################
8 $WHT = "\x1B[37;1m";
9 $NRM = "\x1B[0m";
10
11 ############################################################
12 # First, lets read in the data already in there...
13 ############################################################
14 if ( -e "config.php") {
15 print "The file \"config.php\" exists. Using it for defaults.\n\n";
16 open (FILE, "config.php");
17 } else {
18 print "No config file found. Reading from config_defaults.php.\n\n";
19 open (FILE, "config_default.php");
20 }
21
22 # Reads and parses the current configuration file (either
23 # config.php or config_default.php).
24
25 while ($line = <FILE>) {
26 if ($line =~ /^\s+\$/) {
27 $line =~ s/^\s+\$//;
28 $var = $line;
29
30 if ($var =~ /^([a-z]|[A-Z])/) {
31 @options = split(/\s=\s/, $var);
32 $options[1] =~ s/[\n|\r]//g;
33 $options[1] =~ s/^"//g;
34 $options[1] =~ s/;.*$//g;
35 $options[1] =~ s/"$//g;
36
37 if ($options[0] =~ /^special_folders/) {
38 if ($options[0] =~ /\[.*\]$/) {
39 $sub = $options[0];
40 $sub =~ s/\]$//;
41 $sub = substr ($sub, @sub-1, 1);
42
43 $special_folders[$sub] = $options[1];
44 }
45 } elsif ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) {
46 $sub = $options[0];
47 $sub =~ s/\]\["PATH"\]//;
48 $sub = substr ($sub, @sub-1, 1);
49 $theme_path[$sub] = $options[1];
50 } elsif ($options[0] =~ /^theme\[[0-9]+\]\["NAME"\]/) {
51 $sub = $options[0];
52 $sub =~ s/\]\["NAME"\]//;
53 $sub = substr ($sub, @sub-1, 1);
54 $theme_name[$sub] = $options[1];
55 } else {
56 ${$options[0]} = $options[1];
57 }
58 }
59 }
60 }
61 if ($useSendmail ne "true") {
62 $useSendmail = "false";
63 }
64 if (!$sendmail_path) {
65 $sendmail_path = "/usr/sbin/sendmail";
66 }
67
68
69 #####################################################################################
70
71 while (($command ne "q") && ($command ne "Q")) {
72 system "clear";
73 if ($menu == 0) {
74 print $WHT."Main Menu --\n".$NRM;
75 print "1. Organization Preferences\n";
76 print "2. Server Settings\n";
77 print "3. Folder Defaults\n";
78 print "4. General Options\n";
79 print "5. Themes\n";
80 print "6. Address Books (LDAP)\n";
81 print "7. Message of the Day (MOTD)\n";
82 print "\n";
83 } elsif ($menu == 1) {
84 print $WHT."Organization Preferences\n".$NRM;
85 print "1. Organization Name : $WHT$org_name$NRM\n";
86 print "2. Organization Logo : $WHT$org_logo$NRM\n";
87 print "3. Organization Title : $WHT$org_title$NRM\n";
88 print "\n";
89 print "R Return to Main Menu\n";
90 } elsif ($menu == 2) {
91 print $WHT."Server Settings\n".$NRM;
92 print "1. Domain : $WHT$domain$NRM\n";
93 print "2. IMAP Server : $WHT$imapServerAddress$NRM\n";
94 print "3. IMAP Port : $WHT$imapPort$NRM\n";
95 print "4. Use Sendmail : $WHT$useSendmail$NRM\n";
96 if ($useSendmail eq "true") {
97 print "5. Sendmail Path : $WHT$sendmail_path$NRM\n";
98 } else {
99 print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n";
100 print "7. SMTP Port : $WHT$smtpPort$NRM\n";
101 }
102 print "\n";
103 print "R Return to Main Menu\n";
104 } elsif ($menu == 3) {
105 print $WHT."Folder Defaults\n".$NRM;
106 print "\n";
107 print "R Return to Main Menu\n";
108 } elsif ($menu == 4) {
109 print $WHT."General Options\n".$NRM;
110 print "\n";
111 print "R Return to Main Menu\n";
112 } elsif ($menu == 5) {
113 print $WHT."Themes\n".$NRM;
114 print "\n";
115 print "R Return to Main Menu\n";
116 } elsif ($menu == 6) {
117 print $WHT."Address Books (LDAP)\n".$NRM;
118 print "\n";
119 print "R Return to Main Menu\n";
120 } elsif ($menu == 7) {
121 print $WHT."Message of the Day (MOTD)\n".$NRM;
122 print "\n$motd\n";
123 print "\n";
124 print "1 Edit the MOTD\n";
125 print "\n";
126 print "R Return to Main Menu\n";
127 }
128 print "X Quit without saving\n";
129 print "Q Save and exit\n";
130
131 print "\n";
132 print "Command >> ".$WHT;
133 $command = <STDIN>;
134 $command =~ s/[\n|\r]//g;
135 print "$NRM\n";
136
137 # Read the commands they entered.
138 if (($command eq "R") || ($command eq "r")) {
139 $menu = 0;
140 } else {
141 if ($menu == 0) {
142 if (($command > 0) && ($command < 8)) {
143 $menu = $command;
144 }
145 } elsif ($menu == 1) {
146 if ($command == 1) { $org_name = command1 (); }
147 elsif ($command == 2) { $org_logo = command2 (); }
148 elsif ($command == 3) { $org_title = command3 (); }
149 } elsif ($menu == 2) {
150 if ($command == 1) { $domain = command11 (); }
151 elsif ($command == 2) { $imapServerAddress = command12 (); }
152 elsif ($command == 3) { $imapPort = command13 (); }
153 elsif ($command == 4) { $useSendmail = command14 (); }
154 elsif ($command == 5) { $sendmail_path = command15 (); }
155 elsif ($command == 6) { $smtpServerAddress = command16 (); }
156 elsif ($command == 7) { $smtpPort = command17 (); }
157 } elsif ($menu == 3) {
158 } elsif ($menu == 4) {
159 } elsif ($menu == 5) {
160 } elsif ($menu == 6) {
161 } elsif ($menu == 7) {
162 if ($command == 1) { $motd = command71 (); }
163 }
164 }
165 }
166
167 ####################################################################################
168
169 # org_name
170 sub command1 {
171 print "We have tried to make the name SquirrelMail as transparent as\n";
172 print "possible. If you set up an organization name, most places where\n";
173 print "SquirrelMail would take credit will be credited to your organization.\n";
174 print "\n";
175 print "[$WHT$org_name$NRM]: $WHT";
176 $new_org_name = <STDIN>;
177 if ($new_org_name eq "\n") {
178 $new_org_name = $org_name;
179 } else {
180 $new_org_name =~ s/[\r|\n]//g;
181 }
182 return $new_org_name;
183 }
184
185
186 # org_logo
187 sub command2 {
188 print "Your organization's logo is an image that will be displayed at\n";
189 print "different times throughout SquirrelMail. This is asking for the\n";
190 print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
191 print "(../images/logo.jpg) path to your logo.\n";
192 print "\n";
193 print "[$WHT$org_logo$NRM]: $WHT";
194 $new_org_logo = <STDIN>;
195 if ($new_org_logo eq "\n") {
196 $new_org_logo = $org_logo;
197 } else {
198 $new_org_logo =~ s/[\r|\n]//g;
199 }
200 return $new_org_logo;
201 }
202
203 # org_title
204 sub command3 {
205 print "A title is what is displayed at the top of the browser window in\n";
206 print "the titlebar. Usually this will end up looking something like:\n";
207 print "\"Netscape: $org_title\"\n";
208 print "\n";
209 print "[$WHT$org_title$NRM]: $WHT";
210 $new_org_title = <STDIN>;
211 if ($new_org_title eq "\n") {
212 $new_org_title = $org_title;
213 } else {
214 $new_org_title =~ s/[\r|\n]//g;
215 }
216 return $new_org_title;
217 }
218
219 ####################################################################################
220
221 # domain
222 sub command11 {
223 print "The domain name is the suffix at the end of all email messages. If\n";
224 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
225 print "would be myorg.com.\n";
226 print "\n";
227 print "[$WHT$domain$NRM]: $WHT";
228 $new_domain = <STDIN>;
229 if ($new_domain eq "\n") {
230 $new_domain = $domain;
231 } else {
232 $new_domain =~ s/[\r|\n]//g;
233 }
234 return $new_domain;
235 }
236
237 # imapServerAddress
238 sub command12 {
239 print "This is the address where your IMAP server resides.\n";
240 print "[$WHT$imapServerAddress$NRM]: $WHT";
241 $new_imapServerAddress = <STDIN>;
242 if ($new_imapServerAddress eq "\n") {
243 $new_imapServerAddress = $imapServerAddress;
244 } else {
245 $new_imapServerAddress =~ s/[\r|\n]//g;
246 }
247 return $new_imapServerAddress;
248 }
249
250 # imapPort
251 sub command13 {
252 print "This is the port that your IMAP server is on. Usually this is 143.\n";
253 print "[$WHT$imapPort$NRM]: $WHT";
254 $new_imapPort = <STDIN>;
255 if ($new_imapPort eq "\n") {
256 $new_imapPort = $imapPort;
257 } else {
258 $new_imapPort =~ s/[\r|\n]//g;
259 }
260 return $new_imapPort;
261 }
262
263 # useSendmail
264 sub command14 {
265 print "You now need to choose the method that you will use for sending\n";
266 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
267 print "or use sendmail directly.\n";
268 if ($useSendmail eq "true") {
269 $default_value = "y";
270 } else {
271 $default_value = "n";
272 }
273 print "\n";
274 print "Use Sendmail (y/n) [$WHT$default_value$NRM]: $WHT";
275 $use_sendmail = <STDIN>;
276 if (($use_sendmail =~ /^y\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "y"))) {
277 $useSendmail = "true";
278 } else {
279 $useSendmail = "false";
280 }
281 return $useSendmail;
282 }
283
284 # sendmail_path
285 sub command15 {
286 if ($sendmail_path[0] !~ /./) {
287 $sendmail_path = "/usr/sbin/sendmail";
288 }
289 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
290 print "[$WHT$sendmail_path$NRM]: $WHT";
291 $new_sendmail_path = <STDIN>;
292 if ($new_sendmail_path eq "\n") {
293 $new_sendmail_path = $sendmail_path;
294 } else {
295 $new_sendmail_path =~ s/[\r|\n]//g;
296 }
297 return $new_sendmail_path;
298 }
299
300 # smtpServerAddress
301 sub command16 {
302 print "This is the location of your SMTP server.\n";
303 print "[$WHT$smtpServerAddress$NRM]: $WHT";
304 $new_smtpServerAddress = <STDIN>;
305 if ($new_smtpServerAddress eq "\n") {
306 $new_smtpServerAddress = $smtpServerAddress;
307 } else {
308 $new_smtpServerAddress =~ s/[\r|\n]//g;
309 }
310 return $new_smtpServerAddress;
311 }
312
313 # smtpPort
314 sub command17 {
315 print "This is the port to connect to for SMTP. Usually 25.\n";
316 print "[$WHT$smtpPort$NRM]: $WHT";
317 $new_smtpPort = <STDIN>;
318 if ($new_smtpPort eq "\n") {
319 $new_smtpPort = $smtpPort;
320 } else {
321 $new_smtpPort =~ s/[\r|\n]//g;
322 }
323 return $new_smtpPort;
324 }
325
326 # MOTD
327 sub command71 {
328 print "\nYou can now create the welcome message that is displayed\n";
329 print "every time a user logs on. You can use HTML or just plain\n";
330 print "text.\n\n(Type @ on a blank line to exit)\n";
331 do {
332 print "] ";
333 $line = <STDIN>;
334 $line =~ s/[\r|\n]//g;
335 $line =~ s/ /\&nbsp;\&nbsp;/g;
336 if ($line ne "@") {
337 $new_motd = $new_motd . $line;
338 }
339 } while ($line ne "@");
340 return $new_motd;
341 }