bbd30ac8 |
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 |
ccfb2029 |
7 | ############################################################ |
bbd30ac8 |
8 | $WHT = "\x1B[37;1m"; |
9 | $NRM = "\x1B[0m"; |
10 | |
ccfb2029 |
11 | ############################################################ |
bbd30ac8 |
12 | # First, lets read in the data already in there... |
ccfb2029 |
13 | ############################################################ |
bbd30ac8 |
14 | if ( -e "config.php") { |
a93b12ba |
15 | $config = 1; |
ccfb2029 |
16 | open (FILE, "config.php"); |
1e0628fb |
17 | } elsif (-e "config_default.php") { |
a93b12ba |
18 | $config = 2; |
ccfb2029 |
19 | open (FILE, "config_default.php"); |
1e0628fb |
20 | } else { |
a93b12ba |
21 | print "No configuration file found. Please get config_default.php or\n"; |
22 | print "config.php before running this again. This program needs a\n"; |
23 | print "default config file to get default values.\n"; |
24 | exit; |
bbd30ac8 |
25 | } |
26 | |
27 | # Reads and parses the current configuration file (either |
28 | # config.php or config_default.php). |
29 | |
30 | while ($line = <FILE>) { |
ccfb2029 |
31 | if ($line =~ /^\s+\$/) { |
32 | $line =~ s/^\s+\$//; |
33 | $var = $line; |
34 | |
35 | if ($var =~ /^([a-z]|[A-Z])/) { |
36 | @options = split(/\s*=\s*/, $var); |
37 | $options[1] =~ s/[\n|\r]//g; |
38 | $options[1] =~ s/^"//g; |
39 | $options[1] =~ s/;.*$//g; |
40 | $options[1] =~ s/"$//g; |
41 | |
1e0628fb |
42 | if ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) { |
ccfb2029 |
43 | $sub = $options[0]; |
44 | $sub =~ s/\]\["PATH"\]//; |
45 | $sub = substr ($sub, @sub-1, 1); |
46 | $theme_path[$sub] = $options[1]; |
47 | } elsif ($options[0] =~ /^theme\[[0-9]+\]\["NAME"\]/) { |
48 | $sub = $options[0]; |
49 | $sub =~ s/\]\["NAME"\]//; |
50 | $sub = substr ($sub, @sub-1, 1); |
51 | $theme_name[$sub] = $options[1]; |
a93b12ba |
52 | } elsif ($options[0] =~ /^ldap_server\[[0-9]+\]/) { |
1e0628fb |
53 | $sub = $options[0]; |
54 | $sub = substr ($sub, length($sub)-2, 1); |
a93b12ba |
55 | $continue = 0; |
56 | while (($tmp = <FILE>) && ($continue != 1)) { |
57 | if ($tmp =~ /\);\s*$/) { |
58 | $continue = 1; |
59 | } |
60 | |
61 | if ($tmp =~ /^\s*"host"/i) { |
62 | $tmp =~ s/^\s*"host"\s*=>\s*"//i; |
63 | $tmp =~ s/",\s*$//; |
64 | $tmp =~ s/"\);\s*$//; |
65 | $host = $tmp; |
66 | } elsif ($tmp =~ /^\s*"base"/i) { |
67 | $tmp =~ s/^\s*"base"\s*=>\s*"//i; |
68 | $tmp =~ s/",\s*$//; |
69 | $tmp =~ s/"\);\s*$//; |
70 | print $tmp."\n"; |
71 | $base = $tmp; |
72 | } elsif ($tmp =~ /^\s*"charset"/i) { |
73 | $tmp =~ s/^\s*"charset"\s*=>\s*"//i; |
74 | $tmp =~ s/",\s*$//; |
75 | $tmp =~ s/"\);\s*$//; |
76 | $charset = $tmp; |
77 | } elsif ($tmp =~ /^\s*"port"/i) { |
78 | $tmp =~ s/^\s*"port"\s*=>\s*"//i; |
79 | $tmp =~ s/",\s*$//; |
80 | $tmp =~ s/"\);\s*$//; |
81 | $port = $tmp; |
82 | } elsif ($tmp =~ /^\s*"maxrows"/i) { |
83 | $tmp =~ s/^\s*"maxrows"\s*=>\s*"//i; |
84 | $tmp =~ s/",\s*$//; |
85 | $tmp =~ s/"\);\s*$//; |
86 | $maxrows = $tmp; |
87 | } elsif ($tmp =~ /^\s*"name"/i) { |
88 | $tmp =~ s/^\s*"name"\s*=>\s*"//i; |
89 | $tmp =~ s/",\s*$//; |
90 | $tmp =~ s/"\);\s*$//; |
91 | $name = $tmp; |
92 | } |
93 | } |
1e0628fb |
94 | $ldap_host[$sub] = $host; |
a93b12ba |
95 | $ldap_base[$sub] = $base; |
96 | $ldap_name[$sub] = $name; |
97 | $ldap_port[$sub] = $port; |
98 | $ldap_maxrows[$sub] = $maxrows; |
99 | $ldap_charset[$sub] = $charset; |
ccfb2029 |
100 | } else { |
101 | ${$options[0]} = $options[1]; |
102 | } |
103 | } |
104 | } |
bbd30ac8 |
105 | } |
828b4753 |
106 | if ($useSendmail ne "true") { |
ccfb2029 |
107 | $useSendmail = "false"; |
828b4753 |
108 | } |
109 | if (!$sendmail_path) { |
ccfb2029 |
110 | $sendmail_path = "/usr/sbin/sendmail"; |
828b4753 |
111 | } |
bbd30ac8 |
112 | |
5b6ae78a |
113 | ##################################################################################### |
114 | |
828b4753 |
115 | while (($command ne "q") && ($command ne "Q")) { |
ccfb2029 |
116 | system "clear"; |
117 | if ($menu == 0) { |
1e0628fb |
118 | print $WHT."SquirrelMail Configuration : ".$NRM; |
a93b12ba |
119 | if ($config == 1) { print "Read: config.php"; } |
120 | elsif ($config == 2) { print "Read: config_default.php"; } |
121 | print "\n"; |
1e0628fb |
122 | |
ccfb2029 |
123 | print $WHT."Main Menu --\n".$NRM; |
124 | print "1. Organization Preferences\n"; |
125 | print "2. Server Settings\n"; |
126 | print "3. Folder Defaults\n"; |
127 | print "4. General Options\n"; |
128 | print "5. Themes\n"; |
129 | print "6. Address Books (LDAP)\n"; |
130 | print "7. Message of the Day (MOTD)\n"; |
131 | print "\n"; |
a93b12ba |
132 | print "D. Set pre-defined settings for specific IMAP servers\n"; |
133 | print "\n"; |
ccfb2029 |
134 | } elsif ($menu == 1) { |
135 | print $WHT."Organization Preferences\n".$NRM; |
136 | print "1. Organization Name : $WHT$org_name$NRM\n"; |
137 | print "2. Organization Logo : $WHT$org_logo$NRM\n"; |
138 | print "3. Organization Title : $WHT$org_title$NRM\n"; |
139 | print "\n"; |
140 | print "R Return to Main Menu\n"; |
141 | } elsif ($menu == 2) { |
142 | print $WHT."Server Settings\n".$NRM; |
143 | print "1. Domain : $WHT$domain$NRM\n"; |
144 | print "2. IMAP Server : $WHT$imapServerAddress$NRM\n"; |
145 | print "3. IMAP Port : $WHT$imapPort$NRM\n"; |
146 | print "4. Use Sendmail : $WHT$useSendmail$NRM\n"; |
147 | if ($useSendmail eq "true") { |
148 | print "5. Sendmail Path : $WHT$sendmail_path$NRM\n"; |
149 | } else { |
150 | print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n"; |
151 | print "7. SMTP Port : $WHT$smtpPort$NRM\n"; |
152 | } |
a93b12ba |
153 | print "8. Server : $WHT$imap_server_type$NRM\n"; |
ccfb2029 |
154 | print "\n"; |
155 | print "R Return to Main Menu\n"; |
156 | } elsif ($menu == 3) { |
157 | print $WHT."Folder Defaults\n".$NRM; |
158 | print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n"; |
159 | print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n"; |
160 | print "3. Trash Folder : $WHT$trash_folder$NRM\n"; |
161 | print "4. Sent Folder : $WHT$sent_folder$NRM\n"; |
162 | print "5. List Special Folders First : $WHT$list_special_folders_first$NRM\n"; |
163 | print "6. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n"; |
164 | print "7. By default, move to trash : $WHT$default_move_to_trash$NRM\n"; |
165 | print "8. Auto Expunge : $WHT$auto_expunge$NRM\n"; |
166 | print "9. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n"; |
167 | print "10. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n"; |
ccfb2029 |
168 | print "\n"; |
169 | print "R Return to Main Menu\n"; |
170 | } elsif ($menu == 4) { |
171 | print $WHT."General Options\n".$NRM; |
172 | print "1. Default Charset : $WHT$default_charset$NRM\n"; |
173 | print "2. Auto Forward : $WHT$auto_forward$NRM\n"; |
174 | print "3. Data Directory : $WHT$data_dir$NRM\n"; |
175 | print "4. Attachment Directory : $WHT$attachment_dir$NRM\n"; |
176 | print "5. Default Left Size : $WHT$default_left_size$NRM\n"; |
177 | print "\n"; |
178 | print "R Return to Main Menu\n"; |
179 | } elsif ($menu == 5) { |
180 | print $WHT."Themes\n".$NRM; |
181 | print "1. Change Themes\n"; |
182 | for ($count = 0; $count <= $#theme_name; $count++) { |
70391dd0 |
183 | print " > $theme_name[$count]\n"; |
ccfb2029 |
184 | } |
185 | print "\n"; |
186 | print "R Return to Main Menu\n"; |
187 | } elsif ($menu == 6) { |
188 | print $WHT."Address Books (LDAP)\n".$NRM; |
1e0628fb |
189 | print "1. Change Servers\n"; |
190 | for ($count = 0; $count <= $#ldap_host; $count++) { |
191 | print " > $ldap_host[$count]\n"; |
192 | } |
ccfb2029 |
193 | print "\n"; |
194 | print "R Return to Main Menu\n"; |
195 | } elsif ($menu == 7) { |
196 | print $WHT."Message of the Day (MOTD)\n".$NRM; |
197 | print "\n$motd\n"; |
198 | print "\n"; |
199 | print "1 Edit the MOTD\n"; |
200 | print "\n"; |
201 | print "R Return to Main Menu\n"; |
202 | } |
203 | print "S Save data\n"; |
204 | print "Q Quit\n"; |
205 | |
206 | print "\n"; |
207 | print "Command >> ".$WHT; |
208 | $command = <STDIN>; |
209 | $command =~ s/[\n|\r]//g; |
210 | print "$NRM\n"; |
211 | |
212 | # Read the commands they entered. |
213 | if (($command eq "R") || ($command eq "r")) { |
214 | $menu = 0; |
215 | } elsif (($command eq "s") || ($command eq "S")) { |
216 | save_data (); |
8ad99a99 |
217 | print "Data saved in config.php\n"; |
ccfb2029 |
218 | print "Press any key to continue..."; |
219 | $tmp = <STDIN>; |
220 | $saved = 1; |
221 | } elsif ((($command eq "q") || ($command eq "Q")) && ($saved == 0)) { |
222 | print "You have not saved your data.\n"; |
223 | print "Save? (y/n) [".$WHT."y".$NRM."]: "; |
224 | $save = <STDIN>; |
225 | if (($save =~ /^y/i) || ($save =~ /^\s*$/)) { |
226 | save_data (); |
227 | } |
a93b12ba |
228 | } elsif (($command eq "d") || ($command eq "D")) { |
229 | set_defaults (); |
ccfb2029 |
230 | } else { |
231 | $saved = 0; |
232 | if ($menu == 0) { |
233 | if (($command > 0) && ($command < 8)) { |
234 | $menu = $command; |
235 | } |
236 | } elsif ($menu == 1) { |
237 | if ($command == 1) { $org_name = command1 (); } |
238 | elsif ($command == 2) { $org_logo = command2 (); } |
239 | elsif ($command == 3) { $org_title = command3 (); } |
240 | } elsif ($menu == 2) { |
241 | if ($command == 1) { $domain = command11 (); } |
242 | elsif ($command == 2) { $imapServerAddress = command12 (); } |
243 | elsif ($command == 3) { $imapPort = command13 (); } |
244 | elsif ($command == 4) { $useSendmail = command14 (); } |
245 | elsif ($command == 5) { $sendmail_path = command15 (); } |
246 | elsif ($command == 6) { $smtpServerAddress = command16 (); } |
247 | elsif ($command == 7) { $smtpPort = command17 (); } |
a93b12ba |
248 | elsif ($command == 8) { $imap_server_type = command18 (); } |
ccfb2029 |
249 | } elsif ($menu == 3) { |
250 | if ($command == 1) { $default_folder_prefix = command21 (); } |
251 | elsif ($command == 2) { $show_prefix_option = command22 (); } |
252 | elsif ($command == 3) { $trash_folder = command23 (); } |
253 | elsif ($command == 4) { $sent_folder = command24 (); } |
254 | elsif ($command == 5) { $list_special_folders_first = command25 (); } |
255 | elsif ($command == 6) { $use_special_folder_color = command26 (); } |
256 | elsif ($command == 7) { $default_move_to_trash = command27 (); } |
257 | elsif ($command == 8) { $auto_expunge = command28 (); } |
258 | elsif ($command == 9) { $default_sub_of_inbox = command29 (); } |
259 | elsif ($command == 10){ $show_contain_subfolders_option = command210(); } |
ccfb2029 |
260 | } elsif ($menu == 4) { |
261 | if ($command == 1) { $default_charset = command31 (); } |
262 | elsif ($command == 2) { $auto_forward = command32 (); } |
263 | elsif ($command == 3) { $data_dir = command33 (); } |
264 | elsif ($command == 4) { $attachment_dir = command34 (); } |
265 | elsif ($command == 5) { $default_left_size = command35 (); } |
266 | } elsif ($menu == 5) { |
267 | if ($command == 1) { |
268 | command41 (); |
269 | } |
270 | } elsif ($menu == 6) { |
a93b12ba |
271 | if ($command == 1) { command61(); } |
ccfb2029 |
272 | } elsif ($menu == 7) { |
8ad99a99 |
273 | if ($command == 1) { $motd = command71 (); $motd =~ s/"/\\"/g;} |
ccfb2029 |
274 | } |
275 | } |
828b4753 |
276 | } |
277 | |
278 | #################################################################################### |
279 | |
5b6ae78a |
280 | # org_name |
281 | sub command1 { |
282 | print "We have tried to make the name SquirrelMail as transparent as\n"; |
283 | print "possible. If you set up an organization name, most places where\n"; |
284 | print "SquirrelMail would take credit will be credited to your organization.\n"; |
285 | print "\n"; |
828b4753 |
286 | print "[$WHT$org_name$NRM]: $WHT"; |
287 | $new_org_name = <STDIN>; |
288 | if ($new_org_name eq "\n") { |
289 | $new_org_name = $org_name; |
290 | } else { |
291 | $new_org_name =~ s/[\r|\n]//g; |
292 | } |
5b6ae78a |
293 | return $new_org_name; |
294 | } |
295 | |
828b4753 |
296 | |
5b6ae78a |
297 | # org_logo |
298 | sub command2 { |
299 | print "Your organization's logo is an image that will be displayed at\n"; |
300 | print "different times throughout SquirrelMail. This is asking for the\n"; |
301 | print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n"; |
302 | print "(../images/logo.jpg) path to your logo.\n"; |
303 | print "\n"; |
828b4753 |
304 | print "[$WHT$org_logo$NRM]: $WHT"; |
5b6ae78a |
305 | $new_org_logo = <STDIN>; |
306 | if ($new_org_logo eq "\n") { |
307 | $new_org_logo = $org_logo; |
bbd30ac8 |
308 | } else { |
5b6ae78a |
309 | $new_org_logo =~ s/[\r|\n]//g; |
bbd30ac8 |
310 | } |
5b6ae78a |
311 | return $new_org_logo; |
312 | } |
313 | |
314 | # org_title |
315 | sub command3 { |
316 | print "A title is what is displayed at the top of the browser window in\n"; |
317 | print "the titlebar. Usually this will end up looking something like:\n"; |
318 | print "\"Netscape: $org_title\"\n"; |
319 | print "\n"; |
828b4753 |
320 | print "[$WHT$org_title$NRM]: $WHT"; |
5b6ae78a |
321 | $new_org_title = <STDIN>; |
322 | if ($new_org_title eq "\n") { |
323 | $new_org_title = $org_title; |
bbd30ac8 |
324 | } else { |
5b6ae78a |
325 | $new_org_title =~ s/[\r|\n]//g; |
bbd30ac8 |
326 | } |
5b6ae78a |
327 | return $new_org_title; |
328 | } |
5b6ae78a |
329 | |
828b4753 |
330 | #################################################################################### |
5b6ae78a |
331 | |
828b4753 |
332 | # domain |
333 | sub command11 { |
ccfb2029 |
334 | print "The domain name is the suffix at the end of all email messages. If\n"; |
335 | print "for example, your email address is jdoe\@myorg.com, then your domain\n"; |
336 | print "would be myorg.com.\n"; |
337 | print "\n"; |
338 | print "[$WHT$domain$NRM]: $WHT"; |
339 | $new_domain = <STDIN>; |
340 | if ($new_domain eq "\n") { |
341 | $new_domain = $domain; |
342 | } else { |
343 | $new_domain =~ s/[\r|\n]//g; |
344 | } |
345 | return $new_domain; |
828b4753 |
346 | } |
5b6ae78a |
347 | |
828b4753 |
348 | # imapServerAddress |
349 | sub command12 { |
ccfb2029 |
350 | print "This is the address where your IMAP server resides.\n"; |
351 | print "[$WHT$imapServerAddress$NRM]: $WHT"; |
352 | $new_imapServerAddress = <STDIN>; |
353 | if ($new_imapServerAddress eq "\n") { |
354 | $new_imapServerAddress = $imapServerAddress; |
355 | } else { |
356 | $new_imapServerAddress =~ s/[\r|\n]//g; |
357 | } |
358 | return $new_imapServerAddress; |
828b4753 |
359 | } |
5b6ae78a |
360 | |
828b4753 |
361 | # imapPort |
362 | sub command13 { |
ccfb2029 |
363 | print "This is the port that your IMAP server is on. Usually this is 143.\n"; |
364 | print "[$WHT$imapPort$NRM]: $WHT"; |
365 | $new_imapPort = <STDIN>; |
366 | if ($new_imapPort eq "\n") { |
367 | $new_imapPort = $imapPort; |
368 | } else { |
369 | $new_imapPort =~ s/[\r|\n]//g; |
370 | } |
371 | return $new_imapPort; |
828b4753 |
372 | } |
373 | |
374 | # useSendmail |
375 | sub command14 { |
ccfb2029 |
376 | print "You now need to choose the method that you will use for sending\n"; |
377 | print "messages in SquirrelMail. You can either connect to an SMTP server\n"; |
378 | print "or use sendmail directly.\n"; |
379 | if ($useSendmail eq "true") { |
380 | $default_value = "y"; |
381 | } else { |
382 | $default_value = "n"; |
383 | } |
384 | print "\n"; |
385 | print "Use Sendmail (y/n) [$WHT$default_value$NRM]: $WHT"; |
386 | $use_sendmail = <STDIN>; |
387 | if (($use_sendmail =~ /^y\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "y"))) { |
388 | $useSendmail = "true"; |
389 | } else { |
390 | $useSendmail = "false"; |
391 | } |
392 | return $useSendmail; |
828b4753 |
393 | } |
5b6ae78a |
394 | |
828b4753 |
395 | # sendmail_path |
396 | sub command15 { |
397 | if ($sendmail_path[0] !~ /./) { |
398 | $sendmail_path = "/usr/sbin/sendmail"; |
399 | } |
ccfb2029 |
400 | print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n"; |
828b4753 |
401 | print "[$WHT$sendmail_path$NRM]: $WHT"; |
402 | $new_sendmail_path = <STDIN>; |
403 | if ($new_sendmail_path eq "\n") { |
404 | $new_sendmail_path = $sendmail_path; |
405 | } else { |
406 | $new_sendmail_path =~ s/[\r|\n]//g; |
407 | } |
ccfb2029 |
408 | return $new_sendmail_path; |
828b4753 |
409 | } |
5b6ae78a |
410 | |
828b4753 |
411 | # smtpServerAddress |
412 | sub command16 { |
ccfb2029 |
413 | print "This is the location of your SMTP server.\n"; |
828b4753 |
414 | print "[$WHT$smtpServerAddress$NRM]: $WHT"; |
415 | $new_smtpServerAddress = <STDIN>; |
416 | if ($new_smtpServerAddress eq "\n") { |
417 | $new_smtpServerAddress = $smtpServerAddress; |
418 | } else { |
419 | $new_smtpServerAddress =~ s/[\r|\n]//g; |
420 | } |
ccfb2029 |
421 | return $new_smtpServerAddress; |
828b4753 |
422 | } |
423 | |
424 | # smtpPort |
425 | sub command17 { |
ccfb2029 |
426 | print "This is the port to connect to for SMTP. Usually 25.\n"; |
828b4753 |
427 | print "[$WHT$smtpPort$NRM]: $WHT"; |
428 | $new_smtpPort = <STDIN>; |
429 | if ($new_smtpPort eq "\n") { |
430 | $new_smtpPort = $smtpPort; |
431 | } else { |
432 | $new_smtpPort =~ s/[\r|\n]//g; |
433 | } |
ccfb2029 |
434 | return $new_smtpPort; |
bbd30ac8 |
435 | } |
a93b12ba |
436 | # imap_server_type |
437 | sub command18 { |
438 | print "Eash IMAP server has its own quirks. As much as we tried to stick\n"; |
439 | print "to standards, it doesn't help much if the IMAP server doesn't follow\n"; |
440 | print "the same principles. We have made some work-arounds for some of\n"; |
441 | print "these servers. If you would like to use them, please select your\n"; |
442 | print "IMAP server. If you do not wish to use these work-arounds, you can\n"; |
443 | print "set this to \"other\", and none will be used.\n"; |
444 | print " cyrus = Cyrus IMAP server\n"; |
445 | print " uw = University of Washington's IMAP server\n"; |
446 | print " exchange = Microsoft Exchange IMAP server\n"; |
447 | print " courier = Courier IMAP server\n"; |
448 | print "[$WHT$imap_server_type$NRM]: $WHT"; |
449 | $new_imap_server_type = <STDIN>; |
450 | if ($new_imap_server_type eq "\n") { |
451 | $new_imap_server_type = $imap_server_type; |
452 | } else { |
453 | $new_imap_server_type =~ s/[\r|\n]//g; |
454 | } |
455 | return $new_imap_server_type; |
456 | } |
3f8fe68e |
457 | |
458 | # MOTD |
459 | sub command71 { |
ccfb2029 |
460 | print "\nYou can now create the welcome message that is displayed\n"; |
461 | print "every time a user logs on. You can use HTML or just plain\n"; |
462 | print "text.\n\n(Type @ on a blank line to exit)\n"; |
463 | do { |
464 | print "] "; |
465 | $line = <STDIN>; |
466 | $line =~ s/[\r|\n]//g; |
467 | $line =~ s/ /\ \ /g; |
468 | if ($line ne "@") { |
469 | $new_motd = $new_motd . $line; |
470 | } |
471 | } while ($line ne "@"); |
472 | return $new_motd; |
3f8fe68e |
473 | } |
911ad01c |
474 | |
475 | ################# FOLDERS ################### |
476 | |
477 | # default_folder_prefix |
478 | sub command21 { |
ccfb2029 |
479 | print "Some IMAP servers (UW, for example) store mail and folders in\n"; |
480 | print "your user space in a separate subdirectory. This is where you\n"; |
481 | print "specify what that directory is.\n"; |
482 | print "\n"; |
483 | print "EXAMPLE: mail/"; |
484 | print "\n"; |
485 | print "NOTE: If you use Cyrus, or some server that would not use this\n"; |
486 | print " option, you must set this to 'none'.\n"; |
487 | print "\n"; |
911ad01c |
488 | print "[$WHT$default_folder_prefix$NRM]: $WHT"; |
489 | $new_default_folder_prefix = <STDIN>; |
490 | if ($new_default_folder_prefix eq "\n") { |
491 | $new_default_folder_prefix = $default_folder_prefix; |
492 | } else { |
493 | $new_default_folder_prefix =~ s/[\r|\n]//g; |
494 | } |
ccfb2029 |
495 | if (($new_default_folder_prefix =~ /^\s*$/) || ($new_default_folder_prefix =~ /none/i)) { |
496 | $new_default_folder_prefix = ""; |
497 | } else { |
498 | $new_default_folder_prefix =~ s/\/*$//g; |
499 | $new_default_folder_prefix =~ s/$/\//g; |
500 | } |
911ad01c |
501 | return $new_default_folder_prefix; |
502 | } |
503 | |
504 | # Show Folder Prefix |
505 | sub command22 { |
ccfb2029 |
506 | print "It is possible to set up the default folder prefix as a user\n"; |
507 | print "specific option, where each user can specify what their mail\n"; |
508 | print "folder is. If you set this to false, they will never see the\n"; |
509 | print "option, but if it is true, this option will appear in the\n"; |
510 | print "'options' section.\n"; |
511 | print "\n"; |
512 | print "NOTE: You set the default folder prefix in option '1' of this\n"; |
513 | print " section. That will be the default if the user doesn't\n"; |
514 | print " specify anything different.\n"; |
515 | print "\n"; |
516 | |
517 | if ($show_prefix_option eq "true") { |
518 | $default_value = "y"; |
519 | } else { |
520 | $default_value = "n"; |
521 | } |
522 | print "\n"; |
523 | print "Show option (y/n) [$WHT$default_value$NRM]: $WHT"; |
524 | $new_show = <STDIN>; |
525 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
526 | $show_prefix_option = "true"; |
527 | } else { |
528 | $show_prefix_option = "false"; |
529 | } |
530 | return $show_prefix_option; |
911ad01c |
531 | } |
532 | |
533 | # Trash Folder |
534 | sub command23 { |
ccfb2029 |
535 | print "You can now specify where the default trash folder is located.\n"; |
536 | print "On servers where you do not want this, you can set it to anything\n"; |
537 | print "and set option 7 to false.\n"; |
538 | print "\n"; |
539 | print "This is relative to where the rest of your email is kept. You do\n"; |
540 | print "not need to worry about their mail directory. If this folder\n"; |
541 | print "would be ~/mail/trash on the filesystem, you only need to specify\n"; |
542 | print "that this is 'trash', and be sure to put 'mail/' in option 1.\n"; |
543 | print "\n"; |
911ad01c |
544 | |
545 | print "[$WHT$trash_folder$NRM]: $WHT"; |
546 | $new_trash_folder = <STDIN>; |
547 | if ($new_trash_folder eq "\n") { |
548 | $new_trash_folder = $trash_folder; |
549 | } else { |
550 | $new_trash_folder =~ s/[\r|\n]//g; |
551 | } |
ccfb2029 |
552 | return $new_trash_folder; |
911ad01c |
553 | } |
554 | |
555 | # Sent Folder |
556 | sub command24 { |
ccfb2029 |
557 | print "This is where messages that are sent will be stored. SquirrelMail\n"; |
558 | print "by default puts a copy of all outgoing messages in this folder.\n"; |
559 | print "\n"; |
560 | print "This is relative to where the rest of your email is kept. You do\n"; |
561 | print "not need to worry about their mail directory. If this folder\n"; |
562 | print "would be ~/mail/sent on the filesystem, you only need to specify\n"; |
563 | print "that this is 'sent', and be sure to put 'mail/' in option 1.\n"; |
564 | print "\n"; |
911ad01c |
565 | |
566 | print "[$WHT$sent_folder$NRM]: $WHT"; |
567 | $new_sent_folder = <STDIN>; |
568 | if ($new_sent_folder eq "\n") { |
569 | $new_sent_folder = $sent_folder; |
570 | } else { |
571 | $new_sent_folder =~ s/[\r|\n]//g; |
572 | } |
ccfb2029 |
573 | return $new_sent_folder; |
911ad01c |
574 | } |
575 | |
576 | # List special folders first |
577 | sub command25 { |
ccfb2029 |
578 | print "SquirrelMail has what we call 'special folders' that are not\n"; |
579 | print "manipulated and viewed like normal folders. Some examples of\n"; |
580 | print "these folders would be INBOX, Trash, Sent, etc. This option\n"; |
581 | print "Simply asks if you want these folders listed first in the folder\n"; |
582 | print "listing.\n"; |
583 | print "\n"; |
584 | |
585 | if ($list_special_folders_first eq "true") { |
586 | $default_value = "y"; |
587 | } else { |
588 | $default_value = "n"; |
589 | } |
590 | print "\n"; |
591 | print "List first (y/n) [$WHT$default_value$NRM]: $WHT"; |
592 | $new_show = <STDIN>; |
593 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
594 | $list_special_folders_first = "true"; |
595 | } else { |
596 | $list_special_folders_first = "false"; |
597 | } |
598 | return $list_special_folders_first; |
911ad01c |
599 | } |
600 | |
601 | # Show special folders color |
602 | sub command26 { |
ccfb2029 |
603 | print "SquirrelMail has what we call 'special folders' that are not\n"; |
604 | print "manipulated and viewed like normal folders. Some examples of\n"; |
605 | print "these folders would be INBOX, Trash, Sent, etc. This option\n"; |
606 | print "wants to know if we should display special folders in a\n"; |
607 | print "color than the other folders.\n"; |
608 | print "\n"; |
609 | |
610 | if ($use_special_folder_color eq "true") { |
611 | $default_value = "y"; |
612 | } else { |
613 | $default_value = "n"; |
614 | } |
615 | print "\n"; |
616 | print "Show color (y/n) [$WHT$default_value$NRM]: $WHT"; |
617 | $new_show = <STDIN>; |
618 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
619 | $use_special_folder_color = "true"; |
620 | } else { |
621 | $use_special_folder_color = "false"; |
622 | } |
623 | return $use_special_folder_color; |
911ad01c |
624 | } |
625 | |
626 | # default move to trash |
627 | sub command27 { |
ccfb2029 |
628 | print "By default, should messages get moved to the trash folder? You\n"; |
629 | print "can specify the default trash folder in option 3. If this is set\n"; |
630 | print "to false, messages will get deleted immediately without moving\n"; |
631 | print "to the trash folder.\n"; |
632 | print "\n"; |
633 | print "Trash folder is currently: $trash_folder\n"; |
634 | print "\n"; |
635 | |
636 | if ($default_move_to_trash eq "true") { |
637 | $default_value = "y"; |
638 | } else { |
639 | $default_value = "n"; |
640 | } |
641 | print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT"; |
642 | $new_show = <STDIN>; |
643 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
644 | $default_move_to_trash = "true"; |
645 | } else { |
646 | $default_move_to_trash = "false"; |
647 | } |
648 | return $default_move_to_trash; |
911ad01c |
649 | } |
650 | |
651 | # Auto expunge |
652 | sub command28 { |
ccfb2029 |
653 | print "The way that IMAP handles deleting messages is as follows. You\n"; |
654 | print "mark the message as deleted, and then to 'really' delete it, you\n"; |
655 | print "expunge it. This option asks if you want to just have messages\n"; |
656 | print "marked as deleted, or if you want SquirrelMail to expunge the \n"; |
657 | print "messages too.\n"; |
658 | print "\n"; |
659 | |
660 | if ($auto_expunge eq "true") { |
661 | $default_value = "y"; |
662 | } else { |
663 | $default_value = "n"; |
664 | } |
665 | print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT"; |
666 | $new_show = <STDIN>; |
667 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
668 | $auto_expunge = "true"; |
669 | } else { |
670 | $auto_expunge = "false"; |
671 | } |
672 | return $auto_expunge; |
911ad01c |
673 | } |
674 | |
675 | # Default sub of inbox |
676 | sub command29 { |
ccfb2029 |
677 | print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n"; |
678 | print "This can cause some confusion in folder creation for users when\n"; |
679 | print "they try to create folders and don't put it as a subfolder of INBOX\n"; |
680 | print "and get permission errors. This option asks if you want folders\n"; |
681 | print "to be subfolders of INBOX by default.\n"; |
682 | print "\n"; |
683 | |
684 | if ($default_sub_of_inbox eq "true") { |
685 | $default_value = "y"; |
686 | } else { |
687 | $default_value = "n"; |
688 | } |
689 | print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT"; |
690 | $new_show = <STDIN>; |
691 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
692 | $default_sub_of_inbox = "true"; |
693 | } else { |
694 | $default_sub_of_inbox = "false"; |
695 | } |
696 | return $default_sub_of_inbox; |
911ad01c |
697 | } |
698 | |
699 | # Show contain subfolder option |
700 | sub command210 { |
ccfb2029 |
701 | print "Some IMAP servers (UW) make it so that there are two types of\n"; |
702 | print "folders. Those that contain messages, and those that contain\n"; |
703 | print "subfolders. If this is the case for your server, set this to\n"; |
704 | print "true, and it will ask the user whether the folder they are\n"; |
705 | print "creating contains subfolders or messages.\n"; |
706 | print "\n"; |
707 | |
708 | if ($show_contain_subfolders_option eq "true") { |
709 | $default_value = "y"; |
710 | } else { |
711 | $default_value = "n"; |
712 | } |
713 | print "Show option (y/n) [$WHT$default_value$NRM]: $WHT"; |
714 | $new_show = <STDIN>; |
715 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
716 | $show_contain_subfolders_option = "true"; |
717 | } else { |
718 | $show_contain_subfolders_option = "false"; |
719 | } |
720 | return $show_contain_subfolders_option; |
911ad01c |
721 | } |
722 | |
ccfb2029 |
723 | ############# GENERAL OPTIONS ##################### |
724 | |
725 | # Default Charset |
726 | sub command31 { |
727 | print "This option controls what character set is used when sending\n"; |
728 | print "mail and when sending HTML to the browser. Do not set this\n"; |
729 | print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n"; |
730 | print "to use KOI8-R, since this implementation is faster than most\n"; |
731 | print "of the alternatives\n"; |
732 | print "\n"; |
733 | |
734 | print "[$WHT$default_charset$NRM]: $WHT"; |
735 | $new_default_charset = <STDIN>; |
736 | if ($new_default_charset eq "\n") { |
737 | $new_default_charset = $default_charset; |
738 | } else { |
739 | $new_default_charset =~ s/[\r|\n]//g; |
740 | } |
741 | return $new_default_charset; |
742 | } |
743 | |
744 | # Auto Forward |
745 | sub command32 { |
746 | print "There are some places that we will automatically forward the user\n"; |
747 | print "rather than display pointless messages like 'Message sent!' or\n"; |
748 | print "stuff like that. Use this or not?\n"; |
749 | print "\n"; |
750 | print "NOTE: This is not working currently as we are trying to find a\n"; |
751 | print " better way to handle this. This option really doesn't do\n"; |
752 | print " much.\n"; |
753 | print "\n"; |
754 | |
755 | if ($auto_forward eq "true") { |
756 | $default_value = "y"; |
757 | } else { |
758 | $default_value = "n"; |
759 | } |
760 | print "Auto forward (y/n) [$WHT$default_value$NRM]: $WHT"; |
761 | $new_show = <STDIN>; |
762 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
763 | $auto_forward = "true"; |
764 | } else { |
765 | $auto_forward = "false"; |
766 | } |
767 | return $auto_forward; |
768 | } |
769 | |
770 | # Data directory |
771 | sub command33 { |
772 | print "It is a possible security hole to have a writable directory\n"; |
773 | print "under the web server's root directory (ex: /home/httpd/html).\n"; |
774 | print "For this reason, it is possible to put the data directory\n"; |
775 | print "anywhere you would like. The path name can be absolute or\n"; |
776 | print "relative (to the config directory). It doesn't matter. Here\n"; |
777 | print "are two examples:\n"; |
778 | print " Absolute: /usr/local/squirrelmail/data/\n"; |
779 | print " Relative: ../data/\n"; |
780 | print "\n"; |
781 | |
782 | print "[$WHT$data_dir$NRM]: $WHT"; |
783 | $new_data_dir = <STDIN>; |
784 | if ($new_data_dir eq "\n") { |
785 | $new_data_dir = $data_dir; |
786 | } else { |
787 | $new_data_dir =~ s/[\r|\n]//g; |
788 | } |
789 | if ($new_data_dir =~ /^\s*$/) { |
790 | $new_data_dir = ""; |
791 | } else { |
792 | $new_data_dir =~ s/\/*$//g; |
793 | $new_data_dir =~ s/$/\//g; |
794 | } |
795 | return $new_data_dir; |
796 | } |
797 | |
798 | # Attachment directory |
799 | sub command34 { |
800 | print "Path to directory used for storing attachments while a mail is\n"; |
801 | print "being sent. There are a few security considerations regarding this\n"; |
802 | print "directory:\n"; |
803 | print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n"; |
804 | print " impossible for a random person with access to the webserver\n"; |
805 | print " to list files in this directory. Confidential data might\n"; |
806 | print " be laying around in there.\n"; |
807 | print " 2. Since the webserver is not able to list the files in the\n"; |
808 | print " content is also impossible for the webserver to delete files\n"; |
809 | print " lying around there for too long.\n"; |
810 | print " 3. It should probably be another directory than the data\n"; |
811 | print " directory specified in option 3.\n"; |
812 | print "\n"; |
813 | |
814 | print "[$WHT$attachment_dir$NRM]: $WHT"; |
815 | $new_attachment_dir = <STDIN>; |
816 | if ($new_attachment_dir eq "\n") { |
817 | $new_attachment_dir = $attachment_dir; |
818 | } else { |
819 | $new_attachment_dir =~ s/[\r|\n]//g; |
820 | } |
821 | if ($new_attachment_dir =~ /^\s*$/) { |
822 | $new_attachment_dir = ""; |
823 | } else { |
824 | $new_attachment_dir =~ s/\/*$//g; |
825 | $new_attachment_dir =~ s/$/\//g; |
826 | } |
827 | return $new_attachment_dir; |
828 | } |
829 | |
830 | |
831 | sub command35 { |
832 | print "This is the default size (in pixels) of the left folder list.\n"; |
833 | print "Default is 200, but you can set it to whatever you wish. This\n"; |
834 | print "is a user preference, so this will only show up as their default.\n"; |
835 | print "\n"; |
836 | print "[$WHT$default_left_size$NRM]: $WHT"; |
837 | $new_default_left_size = <STDIN>; |
838 | if ($new_default_left_size eq "\n") { |
839 | $new_default_left_size = $default_left_size; |
840 | } else { |
841 | $new_default_left_size =~ s/[\r|\n]//g; |
842 | } |
843 | return $new_default_left_size; |
844 | } |
845 | |
846 | |
847 | sub command41 { |
848 | print "\nNow we will define the themes that you wish to use. If you have added\n"; |
849 | print "a theme of your own, just follow the instructions (?) about how to add\n"; |
850 | print "them. You can also change the default theme.\n"; |
851 | print "[theme] command (?=help) > "; |
852 | $input = <STDIN>; |
853 | $input =~ s/[\r|\n]//g; |
854 | while ($input ne "d") { |
855 | if ($input =~ /^\s*l\s*/i) { |
856 | $count = 0; |
857 | while ($count <= $#theme_name) { |
858 | if ($count == $theme_default) { |
859 | print " *"; |
860 | } else { |
861 | print " "; |
862 | } |
863 | $name = $theme_name[$count]; |
864 | $num_spaces = 25 - length($name); |
865 | for ($i = 0; $i < $num_spaces;$i++) { |
866 | $name = $name . " "; |
867 | } |
868 | |
869 | print " $count. $name"; |
870 | print "($theme_path[$count])\n"; |
871 | |
872 | $count++; |
873 | } |
874 | } elsif ($input =~ /^\s*m\s*[0-9]+/i) { |
875 | $old_def = $theme_default; |
876 | $theme_default = $input; |
877 | $theme_default =~ s/^\s*m\s*//; |
878 | if (($theme_default > $#theme_name) || ($theme_default < 0)) { |
879 | print "Cannot set default theme to $theme_default. That theme does not exist.\n"; |
880 | $theme_default = $old_def; |
881 | } |
882 | } elsif ($input =~ /^\s*\+/) { |
883 | print "What is the name of this theme: "; |
884 | $name = <STDIN>; |
885 | $name =~ s/[\r|\n]//g; |
886 | $theme_name[$#theme_name+1] = $name; |
887 | print "Be sure to put ../config/ before the filename.\n"; |
888 | print "What file is this stored in (ex: ../config/default_theme.php): "; |
889 | $name = <STDIN>; |
890 | $name =~ s/[\r|\n]//g; |
891 | $theme_path[$#theme_path+1] = $name; |
892 | } elsif ($input =~ /^\s*-\s*[0-9]?/) { |
893 | if ($input =~ /[0-9]+\s*$/) { |
894 | $rem_num = $input; |
895 | $rem_num =~ s/^\s*-\s*//g; |
896 | $rem_num =~ s/\s*$//; |
897 | } else { |
898 | $rem_num = $#theme_name; |
899 | } |
900 | if ($rem_num == $theme_default) { |
901 | print "You cannot remove the default theme!\n"; |
902 | } else { |
903 | $count = 0; |
904 | @new_theme_name = (); |
905 | @new_theme_path = (); |
906 | while ($count <= $#theme_name) { |
907 | if ($count != $rem_num) { |
908 | @new_theme_name = (@new_theme_name, $theme_name[$count]); |
909 | @new_theme_path = (@new_theme_path, $theme_path[$count]); |
910 | } |
911 | $count++; |
912 | } |
913 | @theme_name = @new_theme_name; |
914 | @theme_path = @new_theme_path; |
915 | if ($theme_default > $rem_num) { |
916 | $theme_default--; |
917 | } |
918 | } |
919 | } elsif ($input =~ /^\s*\?\s*/) { |
920 | print ".-------------------------.\n"; |
921 | print "| + (add theme) |\n"; |
922 | print "| - N (remove theme) |\n"; |
923 | print "| m N (mark default) |\n"; |
924 | print "| l (list themes) |\n"; |
925 | print "| d (done) |\n"; |
926 | print "`-------------------------'\n"; |
927 | } |
928 | print "[theme] command (?=help) > "; |
929 | $input = <STDIN>; |
930 | $input =~ s/[\r|\n]//g; |
931 | } |
932 | } |
933 | |
934 | |
1e0628fb |
935 | sub command61 { |
a93b12ba |
936 | print "You can now define different LDAP servers.\n"; |
1e0628fb |
937 | print "[ldap] command (?=help) > "; |
938 | $input = <STDIN>; |
939 | $input =~ s/[\r|\n]//g; |
940 | while ($input ne "d") { |
941 | if ($input =~ /^\s*l\s*/i) { |
942 | $count = 0; |
943 | while ($count <= $#ldap_host) { |
a93b12ba |
944 | print "$count. $ldap_host[$count]\n"; |
945 | print " base: $ldap_base[$count]\n"; |
946 | if ($ldap_charset[$count]) { |
947 | print " charset: $ldap_charset[$count]\n"; |
948 | } |
949 | if ($ldap_port[$count]) { |
950 | print " port: $ldap_port[$count]\n"; |
951 | } |
952 | if ($ldap_name[$count]) { |
953 | print " name: $ldap_name[$count]\n"; |
954 | } |
955 | if ($ldap_maxrows[$count]) { |
956 | print " maxrows: $ldap_maxrows[$count]\n"; |
957 | } |
958 | print "\n"; |
1e0628fb |
959 | $count++; |
960 | } |
961 | } elsif ($input =~ /^\s*\+/) { |
a93b12ba |
962 | $sub = $#ldap_host + 1; |
1e0628fb |
963 | |
a93b12ba |
964 | print "First, we need to have the hostname or the IP address where\n"; |
965 | print "this LDAP server resides. Example: ldap.bigfoot.com\n"; |
966 | print "hostname: "; |
1e0628fb |
967 | $name = <STDIN>; |
968 | $name =~ s/[\r|\n]//g; |
969 | $ldap_host[$sub] = $name; |
a93b12ba |
970 | |
971 | print "\n"; |
1e0628fb |
972 | |
a93b12ba |
973 | print "Next, we need the server root (base dn). For this, an empty\n"; |
974 | print "string is allowed.\n"; |
975 | print "Example: ou=member_directory,o=netcenter.com\n"; |
976 | print "base: "; |
1e0628fb |
977 | $name = <STDIN>; |
978 | $name =~ s/[\r|\n]//g; |
979 | $ldap_base[$sub] = $name; |
980 | |
a93b12ba |
981 | print "\n"; |
1e0628fb |
982 | |
a93b12ba |
983 | print "This is the TCP/IP port number for the LDAP server. Default\n"; |
984 | print "port is 389. This is optional. Press ENTER for default.\n"; |
985 | print "port: "; |
1e0628fb |
986 | $name = <STDIN>; |
987 | $name =~ s/[\r|\n]//g; |
988 | $ldap_port[$sub] = $name; |
989 | |
a93b12ba |
990 | print "\n"; |
1e0628fb |
991 | |
a93b12ba |
992 | print "This is the charset for the server. Default is utf-8. This\n"; |
993 | print "is also optional. Press ENTER for default.\n"; |
994 | print "charset: "; |
1e0628fb |
995 | $name = <STDIN>; |
996 | $name =~ s/[\r|\n]//g; |
997 | $ldap_charset[$sub] = $name; |
998 | |
a93b12ba |
999 | print "\n"; |
1e0628fb |
1000 | |
a93b12ba |
1001 | print "This is the name for the server, used to tag the results of\n"; |
1002 | print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n"; |
1003 | print "name: "; |
1e0628fb |
1004 | $name = <STDIN>; |
1005 | $name =~ s/[\r|\n]//g; |
1006 | $ldap_name[$sub] = $name; |
1007 | |
a93b12ba |
1008 | print "\n"; |
1e0628fb |
1009 | |
a93b12ba |
1010 | print "You can specify the maximum number of rows in the search result.\n"; |
1011 | print "Default is unlimited. Press ENTER for default.\n"; |
1012 | print "maxrows: "; |
1e0628fb |
1013 | $name = <STDIN>; |
1014 | $name =~ s/[\r|\n]//g; |
1015 | $ldap_maxrows[$sub] = $name; |
1016 | |
a93b12ba |
1017 | print "\n"; |
1e0628fb |
1018 | |
1019 | } elsif ($input =~ /^\s*-\s*[0-9]?/) { |
1020 | if ($input =~ /[0-9]+\s*$/) { |
1021 | $rem_num = $input; |
1022 | $rem_num =~ s/^\s*-\s*//g; |
1023 | $rem_num =~ s/\s*$//; |
1024 | } else { |
1025 | $rem_num = $#ldap_host; |
1026 | } |
1027 | $count = 0; |
1028 | @new_ldap_host = (); |
1029 | @new_ldap_base = (); |
1030 | @new_ldap_port = (); |
1031 | @new_ldap_name = (); |
1032 | @new_ldap_charset = (); |
1033 | @new_ldap_maxrows = (); |
1034 | while ($count <= $#ldap_host) { |
1035 | if ($count != $rem_num) { |
1036 | @new_ldap_host = (@new_ldap_host, $ldap_host[$count]); |
1037 | @new_ldap_base = (@new_ldap_base, $ldap_base[$count]); |
1038 | @new_ldap_port = (@new_ldap_port, $ldap_port[$count]); |
1039 | @new_ldap_name = (@new_ldap_name, $ldap_name[$count]); |
1040 | @new_ldap_charset = (@new_ldap_charset, $ldap_charset[$count]); |
1041 | @new_ldap_maxrows = (@new_ldap_maxrows, $ldap_maxrows[$count]); |
1042 | } |
1043 | $count++; |
1044 | } |
1045 | @ldap_host = @new_ldap_host; |
1046 | @ldap_base = @new_ldap_base; |
1047 | @ldap_port = @new_ldap_port; |
1048 | @ldap_name = @new_ldap_name; |
1049 | @ldap_charset = @new_ldap_charset; |
1050 | @ldap_maxrows = @new_ldap_maxrows; |
1051 | } elsif ($input =~ /^\s*\?\s*/) { |
1052 | print ".-------------------------.\n"; |
1053 | print "| + (add host) |\n"; |
1054 | print "| - N (remove host) |\n"; |
1055 | print "| l (list hosts) |\n"; |
1056 | print "| d (done) |\n"; |
1057 | print "`-------------------------'\n"; |
1058 | } |
1059 | print "[ldap] command (?=help) > "; |
1060 | $input = <STDIN>; |
1061 | $input =~ s/[\r|\n]//g; |
1062 | } |
1063 | } |
1064 | |
1065 | |
ccfb2029 |
1066 | |
1067 | sub save_data { |
1068 | open (FILE, ">config.php"); |
1069 | |
1070 | print FILE "<?\n\t/** SquirrelMail configuration\n"; |
1071 | print FILE "\t ** Created using the configure script, conf.pl\n\t **/\n\n"; |
1072 | |
1073 | print FILE "\t\$org_name = \"$org_name\";\n"; |
1074 | print FILE "\t\$org_logo = \"$org_logo\";\n"; |
1075 | print FILE "\t\$org_title = \"$org_title\";\n"; |
1076 | |
1077 | print FILE "\n"; |
1078 | |
c39a6b45 |
1079 | print FILE "\t\$domain = \"$domain\";\n"; |
1080 | print FILE "\t\$imapServerAddress = \"$imapServerAddress\";\n"; |
1081 | print FILE "\t\$imapPort = $imapPort;\n"; |
1082 | print FILE "\t\$useSendmail = $useSendmail;\n"; |
1083 | print FILE "\t\$smtpServerAddress = \"$smtpServerAddress\";\n"; |
1084 | print FILE "\t\$smtpPort = $smtpPort;\n"; |
1085 | print FILE "\t\$sendmailPath = \"$sendmail_path\";\n"; |
a93b12ba |
1086 | print FILE "\t\$imap_server_type = \"$imap_server_type\";\n"; |
ccfb2029 |
1087 | |
1088 | print FILE "\n"; |
1089 | |
1090 | print FILE "\t\$default_folder_prefix = \"$default_folder_prefix\";\n"; |
8ad99a99 |
1091 | print FILE "\t\$trash_folder = \"$trash_folder\";\n"; |
ccfb2029 |
1092 | print FILE "\t\$sent_folder = \"$sent_folder\";\n"; |
1093 | print FILE "\t\$show_prefix_option = $show_prefix_option;\n"; |
1094 | print FILE "\t\$list_special_folders_first = $list_special_folders_first;\n"; |
1095 | print FILE "\t\$use_special_folder_color = $use_special_folder_color;\n"; |
1096 | print FILE "\t\$default_move_to_trash = $default_move_to_trash;\n"; |
1097 | print FILE "\t\$auto_expunge = $auto_expunge;\n"; |
1098 | print FILE "\t\$default_sub_of_inbox = $default_sub_of_inbox;\n"; |
c39a6b45 |
1099 | print FILE "\t\$show_contain_subfolders_option = $show_contain_subfolders_option;\n"; |
ccfb2029 |
1100 | print FILE "\n"; |
1101 | |
8ad99a99 |
1102 | print FILE "\t\$default_charset = \"$default_charset\";\n"; |
1103 | print FILE "\t\$auto_forward = $auto_forward;\n"; |
1104 | print FILE "\t\$data_dir = \"$data_dir\";\n"; |
1105 | print FILE "\t\$attachment_dir = \"$attachment_dir\";\n"; |
1106 | print FILE "\t\$default_left_size = $default_left_size;\n"; |
ccfb2029 |
1107 | |
1108 | print FILE "\n"; |
1109 | |
1110 | for ($count=0; $count <= $#theme_name; $count++) { |
8ad99a99 |
1111 | print FILE "\t\$theme[$count][\"PATH\"] = \"$theme_path[$count]\";\n"; |
1112 | print FILE "\t\$theme[$count][\"NAME\"] = \"$theme_name[$count]\";\n"; |
1113 | } |
1114 | |
ccfb2029 |
1115 | print FILE "\n"; |
1116 | |
1e0628fb |
1117 | for ($count=0; $count <= $#ldap_host; $count++) { |
a93b12ba |
1118 | print FILE "\t\$ldap_server[$count] = Array(\n"; |
1119 | print FILE "\t\t\t\"host\" => \"$ldap_host[$count]\",\n"; |
1120 | print FILE "\t\t\t\"base\" => \"$ldap_base[$count]\""; |
1121 | if ($ldap_name[$count]) { |
1122 | print FILE ",\n\t\t\t\"name\" => \"$ldap_name[$count]\""; |
1123 | } |
1124 | if ($ldap_port[$count]) { |
1125 | print FILE ",\n\t\t\t\"port\" => \"$ldap_port[$count]\""; |
1126 | } |
1127 | if ($ldap_charset[$count]) { |
1128 | print FILE ",\n\t\t\t\"charset\" => \"$ldap_charset[$count]\""; |
1129 | } |
1130 | if ($ldap_maxrows[$count]) { |
1131 | print FILE ",\n\t\t\t\"maxrows\" => \"$ldap_maxrows[$count]\""; |
1132 | } |
1133 | print FILE ");\n\n"; |
1e0628fb |
1134 | } |
1135 | |
8ad99a99 |
1136 | print FILE "\t\$motd = \"$motd\";\n"; |
ccfb2029 |
1137 | |
1138 | print FILE "?>\n"; |
1139 | close FILE; |
911ad01c |
1140 | } |
a93b12ba |
1141 | |
1142 | sub set_defaults { |
1143 | system "clear"; |
1144 | print "While we have been building SquirrelMail, we have discovered some\n"; |
1145 | print "preferences that work better with some servers that don't work so\n"; |
1146 | print "well with others. If you select your IMAP server, this option will\n"; |
1147 | print "set some pre-defined settings for that server.\n"; |
1148 | print "\n"; |
1149 | print "Please note that you will still need to go through and make sure\n"; |
1150 | print "everything is correct. This does not change everything. There are\n"; |
1151 | print "only a few settings that thils will change.\n"; |
1152 | print "\n"; |
1153 | |
1154 | $continue = 0; |
1155 | while ($continue != 1) { |
1156 | print "Please select your IMAP server:\n"; |
1157 | print " cyrus = Cyrus IMAP server\n"; |
1158 | print " uw = University of Washington's IMAP server\n"; |
1159 | print " exchange = Microsoft Exchange IMAP server\n"; |
1160 | print " courier = Courier IMAP server\n"; |
1161 | print " quit = Do not change anything\n"; |
1162 | print "Command >> "; |
1163 | $server = <STDIN>; |
1164 | $server =~ s/[\r|\n]//g; |
1165 | |
1166 | if ($server eq "cyrus") { |
1167 | $default_folder_prefix = ""; |
1168 | $trash_folder = "INBOX.Trash"; |
1169 | $sent_folder = "INBOX.Sent"; |
1170 | $show_prefix_option = false; |
1171 | $default_sub_of_inbox = true; |
1172 | $show_contain_subfolders_option = false; |
1173 | $imap_server_type = "cyrus"; |
1174 | |
1175 | $continue = 1; |
1176 | } elsif ($server eq "uw") { |
1177 | $default_folder_prefix = "mail/"; |
1178 | $trash_folder = "Trash"; |
1179 | $sent_folder = "Sent"; |
1180 | $show_prefix_option = true; |
1181 | $default_sub_of_inbox = false; |
1182 | $show_contain_subfolders_option = true; |
1183 | $imap_server_type = "uw"; |
1184 | |
1185 | $continue = 1; |
1186 | } elsif ($server eq "exchange") { |
1187 | $default_folder_prefix = "INBOX/"; |
1188 | $default_sub_of_inbox = true; |
1189 | $trash_folder = "INBOX/Deleted Items"; |
1190 | $sent_folder = "INBOX/Sent Items"; |
1191 | $show_prefix_option = false; |
1192 | $show_contain_subfolders_option = false; |
1193 | |
1194 | $imap_server_type = "exchange"; |
1195 | |
1196 | $continue = 1; |
1197 | } elsif ($server eq "courier") { |
1198 | $imap_server_type = "courier"; |
1199 | |
1200 | $continue = 1; |
1201 | } elsif ($server eq "quit") { |
1202 | $continue = 1; |
1203 | } else { |
1204 | print "Unrecognized server: $server\n"; |
1205 | print "\n"; |
1206 | } |
1207 | } |
1208 | } |