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