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