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 | ############################################################ |
985f7c88 |
7 | $conf_pl_version = "x62"; |
bbd30ac8 |
8 | |
d595e32e |
9 | ############################################################ |
10 | # Some people try to run this as a CGI. That's wrong! |
11 | ############################################################ |
12 | if(defined($ENV{'PATH_INFO'}) || defined($ENV{'QUERY_STRING'}) || |
13 | defined($ENV{'REQUEST_METHOD'})) { |
14 | print "Content-Type: text/html\n\n"; |
15 | print "You must run this script from the command line."; |
16 | exit; |
17 | } |
18 | |
ccfb2029 |
19 | ############################################################ |
bbd30ac8 |
20 | # First, lets read in the data already in there... |
ccfb2029 |
21 | ############################################################ |
bbd30ac8 |
22 | if ( -e "config.php") { |
4011c3ca |
23 | open (FILE, "config.php"); |
24 | while ($line = <FILE>) { |
25 | if ($line =~ /^\s+\$/) { |
26 | $line =~ s/^\s+\$//; |
27 | $var = $line; |
28 | |
29 | $var =~ s/=/EQUALS/; |
30 | if ($var =~ /^([a-z]|[A-Z])/) { |
31 | @o = split(/\s*EQUALS\s*/, $var); |
32 | if ($o[0] eq "config_version") { |
33 | $o[1] =~ s/[\n|\r]//g; |
34 | $o[1] =~ s/\";\s*$//; |
35 | $o[1] =~ s/;$//; |
36 | $o[1] =~ s/^"//; |
37 | |
38 | $config_version = $o[1]; |
39 | close (FILE); |
40 | } |
41 | } |
42 | } |
43 | } |
44 | close (FILE); |
45 | |
46 | if ($config_version ne $conf_pl_version) { |
47 | system "clear"; |
48 | print $WHT."WARNING:\n".$NRM; |
6b638171 |
49 | print " The file \"config/config.php\" was found, but it is for an older version of\n"; |
4011c3ca |
50 | print " SquirrelMail. It is possible to still read the defaults from this file\n"; |
51 | print " but be warned that many preferences change between versions. It is\n"; |
52 | print " recommended that you start with a clean config.php for each upgrade that\n"; |
6b638171 |
53 | print " you do. To do this, just move config/config.php out of the way.\n\n"; |
f0bc4d36 |
54 | print "Continue loading with the old config.php [y/N]? "; |
4011c3ca |
55 | $ctu = <STDIN>; |
f0bc4d36 |
56 | if (($ctu !~ /^y\n/i) || ($ctu =~ /^\n/)) { |
4011c3ca |
57 | exit; |
58 | } |
59 | |
f0bc4d36 |
60 | print "\nDo you want me to stop warning you [y/N]? "; |
4011c3ca |
61 | $ctu = <STDIN>; |
62 | if ($ctu =~ /^y\n/i) { |
63 | $print_config_version = $conf_pl_version; |
64 | } else { |
65 | $print_config_version = $config_version; |
66 | } |
67 | } else { |
68 | $print_config_version = $config_version; |
69 | } |
70 | |
a93b12ba |
71 | $config = 1; |
ccfb2029 |
72 | open (FILE, "config.php"); |
1e0628fb |
73 | } elsif (-e "config_default.php") { |
4011c3ca |
74 | open (FILE, "config_default.php"); |
75 | while ($line = <FILE>) { |
76 | if ($line =~ /^\s+\$/) { |
77 | $line =~ s/^\s+\$//; |
78 | $var = $line; |
79 | |
80 | $var =~ s/=/EQUALS/; |
81 | if ($var =~ /^([a-z]|[A-Z])/) { |
82 | @o = split(/\s*EQUALS\s*/, $var); |
83 | if ($o[0] eq "config_version") { |
84 | $o[1] =~ s/[\n|\r]//g; |
85 | $o[1] =~ s/\";\s*$//; |
86 | $o[1] =~ s/;$//; |
87 | $o[1] =~ s/^"//; |
88 | |
89 | $config_version = $o[1]; |
90 | close (FILE); |
91 | } |
92 | } |
93 | } |
94 | } |
95 | close (FILE); |
96 | |
97 | if ($config_version ne $conf_pl_version) { |
98 | system "clear"; |
99 | print $WHT."WARNING:\n".$NRM; |
100 | print " You are trying to use a \"config_default.php\" from an older version of\n"; |
101 | print " SquirrelMail. This is HIGHLY unrecommended. You should get the\n"; |
102 | print " \"config_default.php\" that matches the version of SquirrelMail that you\n"; |
103 | print " are running. You can get this from the SquirrelMail web page by going\n"; |
104 | print " to: http://www.squirrelmail.org.\n\n"; |
f0bc4d36 |
105 | print "Continue loading with the old config_default.php (not a good idea) [y/N]? "; |
4011c3ca |
106 | $ctu = <STDIN>; |
f0bc4d36 |
107 | if (($ctu !~ /^y\n/i) || ($ctu =~ /^\n/)) { |
4011c3ca |
108 | exit; |
109 | } |
110 | |
f0bc4d36 |
111 | print "\nDo you want me to stop warning you [y/N]? "; |
4011c3ca |
112 | $ctu = <STDIN>; |
113 | if ($ctu =~ /^y\n/i) { |
114 | $print_config_version = $conf_pl_version; |
115 | } else { |
116 | $print_config_version = $config_version; |
117 | } |
118 | } else { |
119 | $print_config_version = $config_version; |
120 | } |
a93b12ba |
121 | $config = 2; |
ccfb2029 |
122 | open (FILE, "config_default.php"); |
1e0628fb |
123 | } else { |
a93b12ba |
124 | print "No configuration file found. Please get config_default.php or\n"; |
125 | print "config.php before running this again. This program needs a\n"; |
126 | print "default config file to get default values.\n"; |
127 | exit; |
bbd30ac8 |
128 | } |
129 | |
130 | # Reads and parses the current configuration file (either |
131 | # config.php or config_default.php). |
132 | |
133 | while ($line = <FILE>) { |
ccfb2029 |
134 | if ($line =~ /^\s+\$/) { |
135 | $line =~ s/^\s+\$//; |
136 | $var = $line; |
137 | |
e9f8ea4e |
138 | $var =~ s/=/EQUALS/; |
ccfb2029 |
139 | if ($var =~ /^([a-z]|[A-Z])/) { |
e9f8ea4e |
140 | @options = split(/\s*EQUALS\s*/, $var); |
ccfb2029 |
141 | $options[1] =~ s/[\n|\r]//g; |
9d0c7bee |
142 | $options[1] =~ s/\";\s*$//; |
e9f8ea4e |
143 | $options[1] =~ s/;$//; |
f0bc4d36 |
144 | $options[1] =~ s/^\"//; |
ccfb2029 |
145 | |
1e0628fb |
146 | if ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) { |
ccfb2029 |
147 | $sub = $options[0]; |
148 | $sub =~ s/\]\["PATH"\]//; |
1fe8fc34 |
149 | $sub =~ s/.*\[//; |
98fe1e9f |
150 | if (-e "../themes") { |
151 | $options[1] =~ s/^\.\.\/config/\.\.\/themes/; |
152 | } |
ccfb2029 |
153 | $theme_path[$sub] = $options[1]; |
154 | } elsif ($options[0] =~ /^theme\[[0-9]+\]\["NAME"\]/) { |
155 | $sub = $options[0]; |
156 | $sub =~ s/\]\["NAME"\]//; |
aa8dcbd5 |
157 | $sub =~ s/.*\[//; |
ccfb2029 |
158 | $theme_name[$sub] = $options[1]; |
9d0c7bee |
159 | } elsif ($options[0] =~ /^plugins\[[0-9]+\]/) { |
160 | $sub = $options[0]; |
161 | $sub =~ s/\]//; |
162 | $sub =~ s/^plugins\[//; |
163 | $plugins[$sub] = $options[1]; |
a93b12ba |
164 | } elsif ($options[0] =~ /^ldap_server\[[0-9]+\]/) { |
1e0628fb |
165 | $sub = $options[0]; |
1fe8fc34 |
166 | $sub =~ s/\]//; |
167 | $sub =~ s/^ldap_server\[//; |
a93b12ba |
168 | $continue = 0; |
169 | while (($tmp = <FILE>) && ($continue != 1)) { |
170 | if ($tmp =~ /\);\s*$/) { |
171 | $continue = 1; |
172 | } |
173 | |
f0bc4d36 |
174 | if ($tmp =~ /^\s*\"host\"/i) { |
175 | $tmp =~ s/^\s*\"host\"\s*=>\s*\"//i; |
176 | $tmp =~ s/\",\s*$//; |
177 | $tmp =~ s/\"\);\s*$//; |
a93b12ba |
178 | $host = $tmp; |
f0bc4d36 |
179 | } elsif ($tmp =~ /^\s*\"base\"/i) { |
180 | $tmp =~ s/^\s*\"base\"\s*=>\s*\"//i; |
181 | $tmp =~ s/\",\s*$//; |
182 | $tmp =~ s/\"\);\s*$//; |
a93b12ba |
183 | $base = $tmp; |
f0bc4d36 |
184 | } elsif ($tmp =~ /^\s*\"charset\"/i) { |
185 | $tmp =~ s/^\s*\"charset\"\s*=>\s*\"//i; |
186 | $tmp =~ s/\",\s*$//; |
187 | $tmp =~ s/\"\);\s*$//; |
a93b12ba |
188 | $charset = $tmp; |
f0bc4d36 |
189 | } elsif ($tmp =~ /^\s*\"port\"/i) { |
190 | $tmp =~ s/^\s*\"port\"\s*=>\s*\"//i; |
191 | $tmp =~ s/\",\s*$//; |
192 | $tmp =~ s/\"\);\s*$//; |
a93b12ba |
193 | $port = $tmp; |
f0bc4d36 |
194 | } elsif ($tmp =~ /^\s*\"maxrows\"/i) { |
195 | $tmp =~ s/^\s*\"maxrows\"\s*=>\s*\"//i; |
196 | $tmp =~ s/\",\s*$//; |
197 | $tmp =~ s/\"\);\s*$//; |
a93b12ba |
198 | $maxrows = $tmp; |
f0bc4d36 |
199 | } elsif ($tmp =~ /^\s*\"name\"/i) { |
200 | $tmp =~ s/^\s*\"name\"\s*=>\s*\"//i; |
201 | $tmp =~ s/\",\s*$//; |
202 | $tmp =~ s/\"\);\s*$//; |
a93b12ba |
203 | $name = $tmp; |
204 | } |
205 | } |
1e0628fb |
206 | $ldap_host[$sub] = $host; |
a93b12ba |
207 | $ldap_base[$sub] = $base; |
208 | $ldap_name[$sub] = $name; |
209 | $ldap_port[$sub] = $port; |
210 | $ldap_maxrows[$sub] = $maxrows; |
211 | $ldap_charset[$sub] = $charset; |
ccfb2029 |
212 | } else { |
213 | ${$options[0]} = $options[1]; |
214 | } |
215 | } |
216 | } |
bbd30ac8 |
217 | } |
1a7a2fcc |
218 | close FILE; |
828b4753 |
219 | if ($useSendmail ne "true") { |
ccfb2029 |
220 | $useSendmail = "false"; |
828b4753 |
221 | } |
222 | if (!$sendmail_path) { |
ccfb2029 |
223 | $sendmail_path = "/usr/sbin/sendmail"; |
828b4753 |
224 | } |
24fc5dd2 |
225 | if (!$default_unseen_notify) { |
226 | $default_unseen_notify = 2; |
227 | } |
228 | if (!$default_unseen_type) { |
229 | $default_unseen_type = 1; |
230 | } |
0ecb47e5 |
231 | if (!$config_use_color) { |
232 | $config_use_color = 1; |
233 | } |
a1f1f9bc |
234 | if (!$invert_time) { |
235 | $invert_time = "false"; |
236 | } |
23a8095f |
237 | if (!$force_username_lowercase) { |
238 | $force_username_lowercase = "false"; |
239 | } |
40ba4d36 |
240 | if (!$optional_delimiter) { |
241 | $optional_delimiter = "detect"; |
242 | } |
bbd30ac8 |
243 | |
5b6ae78a |
244 | ##################################################################################### |
0ecb47e5 |
245 | if ($config_use_color == 1) { |
246 | $WHT = "\x1B[37;1m"; |
247 | $NRM = "\x1B[0m"; |
248 | } else { |
249 | $WHT = ""; |
250 | $NRM = ""; |
251 | $config_use_color = 2; |
252 | } |
5b6ae78a |
253 | |
828b4753 |
254 | while (($command ne "q") && ($command ne "Q")) { |
ccfb2029 |
255 | system "clear"; |
612eda0a |
256 | print $WHT."SquirrelMail Configuration : ".$NRM; |
257 | if ($config == 1) { print "Read: config.php"; } |
258 | elsif ($config == 2) { print "Read: config_default.php"; } |
259 | print "\n"; |
260 | print "---------------------------------------------------------\n"; |
1e0628fb |
261 | |
612eda0a |
262 | if ($menu == 0) { |
ccfb2029 |
263 | print $WHT."Main Menu --\n".$NRM; |
264 | print "1. Organization Preferences\n"; |
265 | print "2. Server Settings\n"; |
266 | print "3. Folder Defaults\n"; |
267 | print "4. General Options\n"; |
268 | print "5. Themes\n"; |
269 | print "6. Address Books (LDAP)\n"; |
270 | print "7. Message of the Day (MOTD)\n"; |
9d0c7bee |
271 | print "8. Plugins\n"; |
ccfb2029 |
272 | print "\n"; |
a93b12ba |
273 | print "D. Set pre-defined settings for specific IMAP servers\n"; |
274 | print "\n"; |
ccfb2029 |
275 | } elsif ($menu == 1) { |
276 | print $WHT."Organization Preferences\n".$NRM; |
277 | print "1. Organization Name : $WHT$org_name$NRM\n"; |
278 | print "2. Organization Logo : $WHT$org_logo$NRM\n"; |
279 | print "3. Organization Title : $WHT$org_title$NRM\n"; |
280 | print "\n"; |
281 | print "R Return to Main Menu\n"; |
282 | } elsif ($menu == 2) { |
283 | print $WHT."Server Settings\n".$NRM; |
284 | print "1. Domain : $WHT$domain$NRM\n"; |
285 | print "2. IMAP Server : $WHT$imapServerAddress$NRM\n"; |
286 | print "3. IMAP Port : $WHT$imapPort$NRM\n"; |
996d34de |
287 | print "4. Use Sendmail/SMTP : $WHT"; |
288 | if ($useSendmail eq "true") { |
289 | print "Sendmail"; |
290 | } else { |
291 | print "SMTP"; |
292 | } |
293 | print "$NRM\n"; |
ccfb2029 |
294 | if ($useSendmail eq "true") { |
295 | print "5. Sendmail Path : $WHT$sendmail_path$NRM\n"; |
296 | } else { |
297 | print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n"; |
298 | print "7. SMTP Port : $WHT$smtpPort$NRM\n"; |
299 | } |
a93b12ba |
300 | print "8. Server : $WHT$imap_server_type$NRM\n"; |
d47b2518 |
301 | print "9. Invert Time : $WHT$invert_time$NRM\n"; |
40ba4d36 |
302 | print "10. Delimiter : $WHT$optional_delimiter$NRM\n"; |
ccfb2029 |
303 | print "\n"; |
304 | print "R Return to Main Menu\n"; |
305 | } elsif ($menu == 3) { |
306 | print $WHT."Folder Defaults\n".$NRM; |
307 | print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n"; |
308 | print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n"; |
309 | print "3. Trash Folder : $WHT$trash_folder$NRM\n"; |
310 | print "4. Sent Folder : $WHT$sent_folder$NRM\n"; |
2f287147 |
311 | print "5. By default, move to trash : $WHT$default_move_to_trash$NRM\n"; |
312 | print "6. By default, move to sent : $WHT$default_move_to_sent$NRM\n"; |
313 | print "7. List Special Folders First : $WHT$list_special_folders_first$NRM\n"; |
314 | print "8. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n"; |
315 | print "9. Auto Expunge : $WHT$auto_expunge$NRM\n"; |
316 | print "10. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n"; |
317 | print "11. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n"; |
24fc5dd2 |
318 | print "12. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n"; |
319 | print "13. Default Unseen Type : $WHT$default_unseen_type$NRM\n"; |
ccfb2029 |
320 | print "\n"; |
321 | print "R Return to Main Menu\n"; |
322 | } elsif ($menu == 4) { |
323 | print $WHT."General Options\n".$NRM; |
985f7c88 |
324 | print "1. Default Charset : $WHT$default_charset$NRM\n"; |
325 | print "2. Data Directory : $WHT$data_dir$NRM\n"; |
326 | print "3. Attachment Directory : $WHT$attachment_dir$NRM\n"; |
327 | print "4. Default Left Size : $WHT$default_left_size$NRM\n"; |
328 | print "5. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n"; |
ccfb2029 |
329 | print "\n"; |
330 | print "R Return to Main Menu\n"; |
331 | } elsif ($menu == 5) { |
332 | print $WHT."Themes\n".$NRM; |
333 | print "1. Change Themes\n"; |
334 | for ($count = 0; $count <= $#theme_name; $count++) { |
70391dd0 |
335 | print " > $theme_name[$count]\n"; |
ccfb2029 |
336 | } |
6f3bfa54 |
337 | print "2. CSS File : $WHT$theme_css$NRM\n"; |
ccfb2029 |
338 | print "\n"; |
339 | print "R Return to Main Menu\n"; |
340 | } elsif ($menu == 6) { |
341 | print $WHT."Address Books (LDAP)\n".$NRM; |
1e0628fb |
342 | print "1. Change Servers\n"; |
343 | for ($count = 0; $count <= $#ldap_host; $count++) { |
344 | print " > $ldap_host[$count]\n"; |
345 | } |
3806fa52 |
346 | print "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n"; |
ccfb2029 |
347 | print "\n"; |
348 | print "R Return to Main Menu\n"; |
349 | } elsif ($menu == 7) { |
350 | print $WHT."Message of the Day (MOTD)\n".$NRM; |
351 | print "\n$motd\n"; |
352 | print "\n"; |
353 | print "1 Edit the MOTD\n"; |
354 | print "\n"; |
355 | print "R Return to Main Menu\n"; |
9d0c7bee |
356 | } elsif ($menu == 8) { |
357 | print $WHT."Plugins\n".$NRM; |
1a7a2fcc |
358 | print " Installed Plugins\n"; |
359 | $num = 0; |
9d0c7bee |
360 | for ($count = 0; $count <= $#plugins; $count++) { |
1a7a2fcc |
361 | $num = $count + 1; |
362 | print " $num. $plugins[$count]\n"; |
9d0c7bee |
363 | } |
1a7a2fcc |
364 | print "\n Available Plugins:\n"; |
365 | opendir(DIR, "../plugins"); |
366 | @files = readdir(DIR); |
367 | $pos=0; |
368 | @unused_plugins = (); |
1a7a2fcc |
369 | for ($i=0; $i <= $#files; $i++) { |
f0bc4d36 |
370 | if ( -d "../plugins/" . $files[$i] && |
2a15d00c |
371 | $files[$i] !~ /^\./ && $files[$i] ne "CVS") { |
1a7a2fcc |
372 | $match = 0; |
373 | for ($k=0; $k<=$#plugins; $k++) { |
374 | if ($plugins[$k] eq $files[$i]) { |
375 | $match = 1; |
376 | } |
377 | } |
378 | if ($match == 0) { |
379 | $unused_plugins[$pos] = $files[$i]; |
380 | $pos++; |
381 | } |
382 | } |
383 | } |
1a7a2fcc |
384 | |
385 | for ($i=0; $i<=$#unused_plugins; $i++) { |
386 | $num = $num + 1; |
387 | print " $num. $unused_plugins[$i]\n"; |
388 | } |
389 | closedir DIR; |
390 | |
9d0c7bee |
391 | print "\n"; |
392 | print "R Return to Main Menu\n"; |
ccfb2029 |
393 | } |
3ed2faff |
394 | if ($config_use_color == 1) { |
395 | print "C. Turn color off\n"; |
396 | } else { |
397 | print "C. Turn color on\n"; |
398 | } |
ccfb2029 |
399 | print "S Save data\n"; |
400 | print "Q Quit\n"; |
401 | |
402 | print "\n"; |
403 | print "Command >> ".$WHT; |
404 | $command = <STDIN>; |
f0bc4d36 |
405 | $command =~ s/[\n|\r]//g; |
406 | $command =~ tr/A-Z/a-z/; |
ccfb2029 |
407 | print "$NRM\n"; |
408 | |
409 | # Read the commands they entered. |
f0bc4d36 |
410 | if ($command eq "r") { |
ccfb2029 |
411 | $menu = 0; |
f0bc4d36 |
412 | } elsif ($command eq "s") { |
ccfb2029 |
413 | save_data (); |
8ad99a99 |
414 | print "Data saved in config.php\n"; |
f0bc4d36 |
415 | print "Press enter to continue..."; |
ccfb2029 |
416 | $tmp = <STDIN>; |
417 | $saved = 1; |
f0bc4d36 |
418 | } elsif (($command eq "q") && ($saved == 0)) { |
ccfb2029 |
419 | print "You have not saved your data.\n"; |
f0bc4d36 |
420 | print "Save? [".$WHT."Y".$NRM."/n]: "; |
ccfb2029 |
421 | $save = <STDIN>; |
422 | if (($save =~ /^y/i) || ($save =~ /^\s*$/)) { |
423 | save_data (); |
424 | } |
f0bc4d36 |
425 | } elsif ($command eq "c") { |
0ecb47e5 |
426 | if ($config_use_color == 1) { |
427 | $config_use_color = 2; |
428 | $WHT = ""; |
429 | $NRM = ""; |
430 | } else { |
431 | $config_use_color = 1; |
432 | $WHT = "\x1B[37;1m"; |
433 | $NRM = "\x1B[0m"; |
434 | } |
f0bc4d36 |
435 | } elsif ($command eq "d" && $menu == 0) { |
a93b12ba |
436 | set_defaults (); |
ccfb2029 |
437 | } else { |
438 | $saved = 0; |
439 | if ($menu == 0) { |
9d0c7bee |
440 | if (($command > 0) && ($command < 9)) { |
ccfb2029 |
441 | $menu = $command; |
442 | } |
443 | } elsif ($menu == 1) { |
444 | if ($command == 1) { $org_name = command1 (); } |
445 | elsif ($command == 2) { $org_logo = command2 (); } |
446 | elsif ($command == 3) { $org_title = command3 (); } |
447 | } elsif ($menu == 2) { |
40ba4d36 |
448 | if ($command == 1) { $domain = command11 (); } |
449 | elsif ($command == 2) { $imapServerAddress = command12 (); } |
450 | elsif ($command == 3) { $imapPort = command13 (); } |
451 | elsif ($command == 4) { $useSendmail = command14 (); } |
452 | elsif ($command == 5) { $sendmail_path = command15 (); } |
453 | elsif ($command == 6) { $smtpServerAddress = command16 (); } |
454 | elsif ($command == 7) { $smtpPort = command17 (); } |
455 | elsif ($command == 8) { $imap_server_type = command18 (); } |
456 | elsif ($command == 9) { $invert_time = command19 (); } |
457 | elsif ($command == 10) { $optional_delimiter = command110 (); } |
ccfb2029 |
458 | } elsif ($menu == 3) { |
459 | if ($command == 1) { $default_folder_prefix = command21 (); } |
460 | elsif ($command == 2) { $show_prefix_option = command22 (); } |
461 | elsif ($command == 3) { $trash_folder = command23 (); } |
462 | elsif ($command == 4) { $sent_folder = command24 (); } |
2f287147 |
463 | elsif ($command == 5) { $default_move_to_trash = command25 (); } |
464 | elsif ($command == 6) { $default_move_to_sent = command26 (); } |
465 | elsif ($command == 7) { $list_special_folders_first = command27 (); } |
466 | elsif ($command == 8) { $use_special_folder_color = command28 (); } |
467 | elsif ($command == 9) { $auto_expunge = command29 (); } |
468 | elsif ($command == 10){ $default_sub_of_inbox = command210(); } |
469 | elsif ($command == 11){ $show_contain_subfolders_option = command211(); } |
24fc5dd2 |
470 | elsif ($command == 12){ $default_unseen_notify = command212(); } |
471 | elsif ($command == 13){ $default_unseen_type = command213(); } |
ccfb2029 |
472 | } elsif ($menu == 4) { |
985f7c88 |
473 | if ($command == 1) { $default_charset = command31 (); } |
474 | elsif ($command == 2) { $data_dir = command33 (); } |
475 | elsif ($command == 3) { $attachment_dir = command34 (); } |
476 | elsif ($command == 4) { $default_left_size = command35 (); } |
477 | elsif ($command == 5) { $force_username_lowercase = command36 (); } |
ccfb2029 |
478 | } elsif ($menu == 5) { |
6f3bfa54 |
479 | if ($command == 1) { command41 (); } |
480 | elsif ($command == 2) { $theme_css = command42 (); } |
ccfb2029 |
481 | } elsif ($menu == 6) { |
3806fa52 |
482 | if ($command == 1) { command61(); } |
483 | elsif ($command == 2) { command62(); } |
ccfb2029 |
484 | } elsif ($menu == 7) { |
a37f3771 |
485 | if ($command == 1) { $motd = command71(); } |
9d0c7bee |
486 | } elsif ($menu == 8) { |
1a7a2fcc |
487 | if ($command =~ /^[0-9]+/) { @plugins = command81(); } |
ccfb2029 |
488 | } |
489 | } |
828b4753 |
490 | } |
491 | |
492 | #################################################################################### |
493 | |
5b6ae78a |
494 | # org_name |
495 | sub command1 { |
496 | print "We have tried to make the name SquirrelMail as transparent as\n"; |
497 | print "possible. If you set up an organization name, most places where\n"; |
498 | print "SquirrelMail would take credit will be credited to your organization.\n"; |
499 | print "\n"; |
828b4753 |
500 | print "[$WHT$org_name$NRM]: $WHT"; |
501 | $new_org_name = <STDIN>; |
502 | if ($new_org_name eq "\n") { |
503 | $new_org_name = $org_name; |
504 | } else { |
505 | $new_org_name =~ s/[\r|\n]//g; |
506 | } |
5b6ae78a |
507 | return $new_org_name; |
508 | } |
509 | |
828b4753 |
510 | |
5b6ae78a |
511 | # org_logo |
512 | sub command2 { |
513 | print "Your organization's logo is an image that will be displayed at\n"; |
514 | print "different times throughout SquirrelMail. This is asking for the\n"; |
515 | print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n"; |
516 | print "(../images/logo.jpg) path to your logo.\n"; |
517 | print "\n"; |
828b4753 |
518 | print "[$WHT$org_logo$NRM]: $WHT"; |
5b6ae78a |
519 | $new_org_logo = <STDIN>; |
520 | if ($new_org_logo eq "\n") { |
521 | $new_org_logo = $org_logo; |
bbd30ac8 |
522 | } else { |
5b6ae78a |
523 | $new_org_logo =~ s/[\r|\n]//g; |
bbd30ac8 |
524 | } |
5b6ae78a |
525 | return $new_org_logo; |
526 | } |
527 | |
528 | # org_title |
529 | sub command3 { |
530 | print "A title is what is displayed at the top of the browser window in\n"; |
531 | print "the titlebar. Usually this will end up looking something like:\n"; |
532 | print "\"Netscape: $org_title\"\n"; |
533 | print "\n"; |
828b4753 |
534 | print "[$WHT$org_title$NRM]: $WHT"; |
5b6ae78a |
535 | $new_org_title = <STDIN>; |
536 | if ($new_org_title eq "\n") { |
537 | $new_org_title = $org_title; |
bbd30ac8 |
538 | } else { |
5b6ae78a |
539 | $new_org_title =~ s/[\r|\n]//g; |
bbd30ac8 |
540 | } |
5b6ae78a |
541 | return $new_org_title; |
542 | } |
5b6ae78a |
543 | |
828b4753 |
544 | #################################################################################### |
5b6ae78a |
545 | |
828b4753 |
546 | # domain |
547 | sub command11 { |
ccfb2029 |
548 | print "The domain name is the suffix at the end of all email messages. If\n"; |
549 | print "for example, your email address is jdoe\@myorg.com, then your domain\n"; |
550 | print "would be myorg.com.\n"; |
551 | print "\n"; |
552 | print "[$WHT$domain$NRM]: $WHT"; |
553 | $new_domain = <STDIN>; |
554 | if ($new_domain eq "\n") { |
555 | $new_domain = $domain; |
556 | } else { |
557 | $new_domain =~ s/[\r|\n]//g; |
558 | } |
559 | return $new_domain; |
828b4753 |
560 | } |
5b6ae78a |
561 | |
828b4753 |
562 | # imapServerAddress |
563 | sub command12 { |
ccfb2029 |
564 | print "This is the address where your IMAP server resides.\n"; |
565 | print "[$WHT$imapServerAddress$NRM]: $WHT"; |
566 | $new_imapServerAddress = <STDIN>; |
567 | if ($new_imapServerAddress eq "\n") { |
568 | $new_imapServerAddress = $imapServerAddress; |
569 | } else { |
570 | $new_imapServerAddress =~ s/[\r|\n]//g; |
571 | } |
572 | return $new_imapServerAddress; |
828b4753 |
573 | } |
5b6ae78a |
574 | |
828b4753 |
575 | # imapPort |
576 | sub command13 { |
ccfb2029 |
577 | print "This is the port that your IMAP server is on. Usually this is 143.\n"; |
578 | print "[$WHT$imapPort$NRM]: $WHT"; |
579 | $new_imapPort = <STDIN>; |
580 | if ($new_imapPort eq "\n") { |
581 | $new_imapPort = $imapPort; |
582 | } else { |
583 | $new_imapPort =~ s/[\r|\n]//g; |
584 | } |
585 | return $new_imapPort; |
828b4753 |
586 | } |
587 | |
588 | # useSendmail |
589 | sub command14 { |
ccfb2029 |
590 | print "You now need to choose the method that you will use for sending\n"; |
591 | print "messages in SquirrelMail. You can either connect to an SMTP server\n"; |
592 | print "or use sendmail directly.\n"; |
593 | if ($useSendmail eq "true") { |
996d34de |
594 | $default_value = "1"; |
ccfb2029 |
595 | } else { |
996d34de |
596 | $default_value = "2"; |
ccfb2029 |
597 | } |
598 | print "\n"; |
996d34de |
599 | print " 1. Sendmail\n"; |
600 | print " 2. SMTP\n"; |
601 | print "Your choice [1/2] [$WHT$default_value$NRM]: $WHT"; |
ccfb2029 |
602 | $use_sendmail = <STDIN>; |
996d34de |
603 | if (($use_sendmail =~ /^1\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "1"))) { |
ccfb2029 |
604 | $useSendmail = "true"; |
605 | } else { |
606 | $useSendmail = "false"; |
607 | } |
608 | return $useSendmail; |
828b4753 |
609 | } |
5b6ae78a |
610 | |
828b4753 |
611 | # sendmail_path |
612 | sub command15 { |
613 | if ($sendmail_path[0] !~ /./) { |
614 | $sendmail_path = "/usr/sbin/sendmail"; |
615 | } |
ccfb2029 |
616 | print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n"; |
828b4753 |
617 | print "[$WHT$sendmail_path$NRM]: $WHT"; |
618 | $new_sendmail_path = <STDIN>; |
619 | if ($new_sendmail_path eq "\n") { |
620 | $new_sendmail_path = $sendmail_path; |
621 | } else { |
622 | $new_sendmail_path =~ s/[\r|\n]//g; |
623 | } |
ccfb2029 |
624 | return $new_sendmail_path; |
828b4753 |
625 | } |
5b6ae78a |
626 | |
828b4753 |
627 | # smtpServerAddress |
628 | sub command16 { |
ccfb2029 |
629 | print "This is the location of your SMTP server.\n"; |
828b4753 |
630 | print "[$WHT$smtpServerAddress$NRM]: $WHT"; |
631 | $new_smtpServerAddress = <STDIN>; |
632 | if ($new_smtpServerAddress eq "\n") { |
633 | $new_smtpServerAddress = $smtpServerAddress; |
634 | } else { |
635 | $new_smtpServerAddress =~ s/[\r|\n]//g; |
636 | } |
ccfb2029 |
637 | return $new_smtpServerAddress; |
828b4753 |
638 | } |
639 | |
640 | # smtpPort |
641 | sub command17 { |
ccfb2029 |
642 | print "This is the port to connect to for SMTP. Usually 25.\n"; |
828b4753 |
643 | print "[$WHT$smtpPort$NRM]: $WHT"; |
644 | $new_smtpPort = <STDIN>; |
645 | if ($new_smtpPort eq "\n") { |
646 | $new_smtpPort = $smtpPort; |
647 | } else { |
648 | $new_smtpPort =~ s/[\r|\n]//g; |
649 | } |
ccfb2029 |
650 | return $new_smtpPort; |
bbd30ac8 |
651 | } |
a93b12ba |
652 | # imap_server_type |
653 | sub command18 { |
d47b2518 |
654 | print "Each IMAP server has its own quirks. As much as we tried to stick\n"; |
a93b12ba |
655 | print "to standards, it doesn't help much if the IMAP server doesn't follow\n"; |
656 | print "the same principles. We have made some work-arounds for some of\n"; |
657 | print "these servers. If you would like to use them, please select your\n"; |
658 | print "IMAP server. If you do not wish to use these work-arounds, you can\n"; |
659 | print "set this to \"other\", and none will be used.\n"; |
660 | print " cyrus = Cyrus IMAP server\n"; |
661 | print " uw = University of Washington's IMAP server\n"; |
662 | print " exchange = Microsoft Exchange IMAP server\n"; |
663 | print " courier = Courier IMAP server\n"; |
664 | print "[$WHT$imap_server_type$NRM]: $WHT"; |
665 | $new_imap_server_type = <STDIN>; |
666 | if ($new_imap_server_type eq "\n") { |
667 | $new_imap_server_type = $imap_server_type; |
668 | } else { |
669 | $new_imap_server_type =~ s/[\r|\n]//g; |
670 | } |
671 | return $new_imap_server_type; |
672 | } |
3f8fe68e |
673 | |
d47b2518 |
674 | # invert_time |
675 | sub command19 { |
676 | print "Sometimes the date of messages sent is messed up (off by a few hours\n"; |
677 | print "on some machines). Typically this happens if the system doesn't support\n"; |
678 | print "tm_gmtoff. It will happen only if your time zone is \"negative\".\n"; |
679 | print "This most often occurs on Solaris 7 machines in the United States.\n"; |
680 | print "By default, this is off. It should be kept off unless problems surface\n"; |
681 | print "about the time that messages are sent.\n"; |
682 | print " no = Do NOT fix time -- almost always correct\n"; |
683 | print " yes = Fix the time for this system\n"; |
684 | |
685 | $YesNo = 'n'; |
686 | $YesNo = 'y' if ($invert_time eq "true"); |
687 | |
688 | print "Fix the time for this system (y/n) [$WHT$YesNo$NRM]: $WHT"; |
689 | |
690 | $new_invert_time = <STDIN>; |
691 | $new_invert_time =~ tr/yn//cd; |
692 | return "true" if ($new_invert_time eq "y"); |
693 | return "false" if ($new_invert_time eq "n"); |
694 | return $invert_time; |
695 | } |
696 | |
40ba4d36 |
697 | sub command110 { |
698 | print "This is the delimiter that your IMAP server uses to distinguish between\n"; |
699 | print "folders. For example, Cyrus uses '.' as the delimiter and a complete\n"; |
700 | print "folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would\n"; |
701 | print "look like 'INBOX/Friends/Bob'. Normally this should be left at 'detect'\n"; |
702 | print "but if you are sure you konw what delimiter your server uses, you can\n"; |
703 | print "specify it here.\n"; |
704 | print "\nTo have it autodetect the delimiter, set it to 'detect'.\n\n"; |
705 | print "[$WHT$optional_delimiter$NRM]: $WHT"; |
706 | $new_optional_delimiter = <STDIN>; |
707 | if ($new_optional_delimiter eq "\n") { |
708 | $new_optional_delimiter = $optional_delimiter; |
709 | } else { |
710 | $new_optional_delimiter =~ s/[\r|\n]//g; |
711 | } |
712 | return $new_optional_delimiter; |
713 | } |
714 | |
3f8fe68e |
715 | # MOTD |
716 | sub command71 { |
ccfb2029 |
717 | print "\nYou can now create the welcome message that is displayed\n"; |
718 | print "every time a user logs on. You can use HTML or just plain\n"; |
a37f3771 |
719 | print "text. If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n"; |
c4809aca |
720 | |
e9f8ea4e |
721 | $new_motd = ""; |
ccfb2029 |
722 | do { |
723 | print "] "; |
724 | $line = <STDIN>; |
725 | $line =~ s/[\r|\n]//g; |
ccfb2029 |
726 | if ($line ne "@") { |
c4809aca |
727 | $line =~ s/ /\ \ /g; |
728 | $line =~ s/\t/\ \ \ \ /g; |
729 | $line =~ s/$/ /; |
e9f8ea4e |
730 | $line =~ s/\"/\\\"/g; |
c4809aca |
731 | |
ccfb2029 |
732 | $new_motd = $new_motd . $line; |
733 | } |
734 | } while ($line ne "@"); |
735 | return $new_motd; |
3f8fe68e |
736 | } |
911ad01c |
737 | |
9d0c7bee |
738 | ################# PLUGINS ################### |
739 | |
740 | sub command81 { |
1a7a2fcc |
741 | $command =~ s/[\s|\n|\r]*//g; |
742 | if ($command > 0) { |
743 | $command = $command - 1; |
744 | if ($command <= $#plugins) { |
745 | @newplugins = (); |
746 | $ct=0; |
747 | while ($ct <= $#plugins) { |
748 | if ($ct != $command) { |
749 | @newplugins = (@newplugins, $plugins[$ct]); |
9d0c7bee |
750 | } |
1a7a2fcc |
751 | $ct++; |
9d0c7bee |
752 | } |
1a7a2fcc |
753 | @plugins = @newplugins; |
754 | } elsif ($command <= $#plugins + $#unused_plugins + 1) { |
755 | $num = $command - $#plugins - 1; |
756 | @newplugins = @plugins; |
757 | $ct=0; |
758 | while ($ct <= $#unused_plugins) { |
759 | if ($ct == $num) { |
760 | @newplugins = (@newplugins, $unused_plugins[$ct]); |
9d0c7bee |
761 | } |
1a7a2fcc |
762 | $ct++; |
9d0c7bee |
763 | } |
1a7a2fcc |
764 | @plugins = @newplugins; |
9d0c7bee |
765 | } |
1a7a2fcc |
766 | } |
767 | return @plugins; |
9d0c7bee |
768 | } |
769 | |
911ad01c |
770 | ################# FOLDERS ################### |
771 | |
772 | # default_folder_prefix |
773 | sub command21 { |
ccfb2029 |
774 | print "Some IMAP servers (UW, for example) store mail and folders in\n"; |
775 | print "your user space in a separate subdirectory. This is where you\n"; |
776 | print "specify what that directory is.\n"; |
777 | print "\n"; |
778 | print "EXAMPLE: mail/"; |
779 | print "\n"; |
780 | print "NOTE: If you use Cyrus, or some server that would not use this\n"; |
781 | print " option, you must set this to 'none'.\n"; |
782 | print "\n"; |
911ad01c |
783 | print "[$WHT$default_folder_prefix$NRM]: $WHT"; |
784 | $new_default_folder_prefix = <STDIN>; |
785 | if ($new_default_folder_prefix eq "\n") { |
786 | $new_default_folder_prefix = $default_folder_prefix; |
787 | } else { |
788 | $new_default_folder_prefix =~ s/[\r|\n]//g; |
789 | } |
ccfb2029 |
790 | if (($new_default_folder_prefix =~ /^\s*$/) || ($new_default_folder_prefix =~ /none/i)) { |
791 | $new_default_folder_prefix = ""; |
792 | } else { |
793 | $new_default_folder_prefix =~ s/\/*$//g; |
794 | $new_default_folder_prefix =~ s/$/\//g; |
795 | } |
911ad01c |
796 | return $new_default_folder_prefix; |
797 | } |
798 | |
799 | # Show Folder Prefix |
800 | sub command22 { |
ccfb2029 |
801 | print "It is possible to set up the default folder prefix as a user\n"; |
802 | print "specific option, where each user can specify what their mail\n"; |
803 | print "folder is. If you set this to false, they will never see the\n"; |
804 | print "option, but if it is true, this option will appear in the\n"; |
805 | print "'options' section.\n"; |
806 | print "\n"; |
807 | print "NOTE: You set the default folder prefix in option '1' of this\n"; |
808 | print " section. That will be the default if the user doesn't\n"; |
809 | print " specify anything different.\n"; |
810 | print "\n"; |
811 | |
812 | if ($show_prefix_option eq "true") { |
813 | $default_value = "y"; |
814 | } else { |
815 | $default_value = "n"; |
816 | } |
817 | print "\n"; |
818 | print "Show option (y/n) [$WHT$default_value$NRM]: $WHT"; |
819 | $new_show = <STDIN>; |
820 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
821 | $show_prefix_option = "true"; |
822 | } else { |
823 | $show_prefix_option = "false"; |
824 | } |
825 | return $show_prefix_option; |
911ad01c |
826 | } |
827 | |
828 | # Trash Folder |
829 | sub command23 { |
ccfb2029 |
830 | print "You can now specify where the default trash folder is located.\n"; |
831 | print "On servers where you do not want this, you can set it to anything\n"; |
832 | print "and set option 7 to false.\n"; |
833 | print "\n"; |
834 | print "This is relative to where the rest of your email is kept. You do\n"; |
835 | print "not need to worry about their mail directory. If this folder\n"; |
836 | print "would be ~/mail/trash on the filesystem, you only need to specify\n"; |
837 | print "that this is 'trash', and be sure to put 'mail/' in option 1.\n"; |
838 | print "\n"; |
911ad01c |
839 | |
840 | print "[$WHT$trash_folder$NRM]: $WHT"; |
841 | $new_trash_folder = <STDIN>; |
842 | if ($new_trash_folder eq "\n") { |
843 | $new_trash_folder = $trash_folder; |
844 | } else { |
845 | $new_trash_folder =~ s/[\r|\n]//g; |
846 | } |
ccfb2029 |
847 | return $new_trash_folder; |
911ad01c |
848 | } |
849 | |
850 | # Sent Folder |
851 | sub command24 { |
ccfb2029 |
852 | print "This is where messages that are sent will be stored. SquirrelMail\n"; |
853 | print "by default puts a copy of all outgoing messages in this folder.\n"; |
854 | print "\n"; |
855 | print "This is relative to where the rest of your email is kept. You do\n"; |
856 | print "not need to worry about their mail directory. If this folder\n"; |
857 | print "would be ~/mail/sent on the filesystem, you only need to specify\n"; |
858 | print "that this is 'sent', and be sure to put 'mail/' in option 1.\n"; |
859 | print "\n"; |
911ad01c |
860 | |
861 | print "[$WHT$sent_folder$NRM]: $WHT"; |
862 | $new_sent_folder = <STDIN>; |
863 | if ($new_sent_folder eq "\n") { |
864 | $new_sent_folder = $sent_folder; |
865 | } else { |
866 | $new_sent_folder =~ s/[\r|\n]//g; |
867 | } |
ccfb2029 |
868 | return $new_sent_folder; |
911ad01c |
869 | } |
870 | |
2f287147 |
871 | # default move to trash |
911ad01c |
872 | sub command25 { |
2f287147 |
873 | print "By default, should messages get moved to the trash folder? You\n"; |
874 | print "can specify the default trash folder in option 3. If this is set\n"; |
875 | print "to false, messages will get deleted immediately without moving\n"; |
876 | print "to the trash folder.\n"; |
877 | print "\n"; |
878 | print "Trash folder is currently: $trash_folder\n"; |
879 | print "\n"; |
880 | |
881 | if ($default_move_to_trash eq "true") { |
882 | $default_value = "y"; |
883 | } else { |
884 | $default_value = "n"; |
885 | } |
886 | print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT"; |
887 | $new_show = <STDIN>; |
888 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
889 | $default_move_to_trash = "true"; |
890 | } else { |
891 | $default_move_to_trash = "false"; |
892 | } |
893 | return $default_move_to_trash; |
894 | } |
895 | |
896 | # default move to sent |
897 | sub command26 { |
898 | print "By default, should messages get moved to the sent folder? You\n"; |
899 | print "can specify the default sent folder in option 4. If this is set\n"; |
776c7431 |
900 | print "to false, messages will get sent an no copy will be made.\n"; |
2f287147 |
901 | print "\n"; |
902 | print "Trash folder is currently: $sent_folder\n"; |
903 | print "\n"; |
904 | |
905 | if ($default_move_to_sent eq "true") { |
906 | $default_value = "y"; |
907 | } else { |
908 | $default_value = "n"; |
909 | } |
910 | print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT"; |
911 | $new_show = <STDIN>; |
912 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
913 | $default_move_to_sent = "true"; |
914 | } else { |
915 | $default_move_to_sent = "false"; |
916 | } |
917 | return $default_move_to_sent; |
918 | } |
919 | |
920 | # List special folders first |
921 | sub command27 { |
ccfb2029 |
922 | print "SquirrelMail has what we call 'special folders' that are not\n"; |
923 | print "manipulated and viewed like normal folders. Some examples of\n"; |
924 | print "these folders would be INBOX, Trash, Sent, etc. This option\n"; |
925 | print "Simply asks if you want these folders listed first in the folder\n"; |
926 | print "listing.\n"; |
927 | print "\n"; |
928 | |
929 | if ($list_special_folders_first eq "true") { |
930 | $default_value = "y"; |
931 | } else { |
932 | $default_value = "n"; |
933 | } |
934 | print "\n"; |
935 | print "List first (y/n) [$WHT$default_value$NRM]: $WHT"; |
936 | $new_show = <STDIN>; |
937 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
938 | $list_special_folders_first = "true"; |
939 | } else { |
940 | $list_special_folders_first = "false"; |
941 | } |
942 | return $list_special_folders_first; |
911ad01c |
943 | } |
944 | |
945 | # Show special folders color |
2f287147 |
946 | sub command28 { |
ccfb2029 |
947 | print "SquirrelMail has what we call 'special folders' that are not\n"; |
948 | print "manipulated and viewed like normal folders. Some examples of\n"; |
949 | print "these folders would be INBOX, Trash, Sent, etc. This option\n"; |
950 | print "wants to know if we should display special folders in a\n"; |
951 | print "color than the other folders.\n"; |
952 | print "\n"; |
953 | |
954 | if ($use_special_folder_color eq "true") { |
955 | $default_value = "y"; |
956 | } else { |
957 | $default_value = "n"; |
958 | } |
959 | print "\n"; |
960 | print "Show color (y/n) [$WHT$default_value$NRM]: $WHT"; |
961 | $new_show = <STDIN>; |
962 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
963 | $use_special_folder_color = "true"; |
964 | } else { |
965 | $use_special_folder_color = "false"; |
966 | } |
967 | return $use_special_folder_color; |
911ad01c |
968 | } |
969 | |
911ad01c |
970 | # Auto expunge |
2f287147 |
971 | sub command29 { |
ccfb2029 |
972 | print "The way that IMAP handles deleting messages is as follows. You\n"; |
973 | print "mark the message as deleted, and then to 'really' delete it, you\n"; |
974 | print "expunge it. This option asks if you want to just have messages\n"; |
975 | print "marked as deleted, or if you want SquirrelMail to expunge the \n"; |
976 | print "messages too.\n"; |
977 | print "\n"; |
978 | |
979 | if ($auto_expunge eq "true") { |
980 | $default_value = "y"; |
981 | } else { |
982 | $default_value = "n"; |
983 | } |
984 | print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT"; |
985 | $new_show = <STDIN>; |
986 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
987 | $auto_expunge = "true"; |
988 | } else { |
989 | $auto_expunge = "false"; |
990 | } |
991 | return $auto_expunge; |
911ad01c |
992 | } |
993 | |
994 | # Default sub of inbox |
2f287147 |
995 | sub command210 { |
ccfb2029 |
996 | print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n"; |
997 | print "This can cause some confusion in folder creation for users when\n"; |
998 | print "they try to create folders and don't put it as a subfolder of INBOX\n"; |
999 | print "and get permission errors. This option asks if you want folders\n"; |
1000 | print "to be subfolders of INBOX by default.\n"; |
1001 | print "\n"; |
1002 | |
1003 | if ($default_sub_of_inbox eq "true") { |
1004 | $default_value = "y"; |
1005 | } else { |
1006 | $default_value = "n"; |
1007 | } |
1008 | print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT"; |
1009 | $new_show = <STDIN>; |
1010 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
1011 | $default_sub_of_inbox = "true"; |
1012 | } else { |
1013 | $default_sub_of_inbox = "false"; |
1014 | } |
1015 | return $default_sub_of_inbox; |
911ad01c |
1016 | } |
1017 | |
1018 | # Show contain subfolder option |
2f287147 |
1019 | sub command211 { |
ccfb2029 |
1020 | print "Some IMAP servers (UW) make it so that there are two types of\n"; |
1021 | print "folders. Those that contain messages, and those that contain\n"; |
1022 | print "subfolders. If this is the case for your server, set this to\n"; |
1023 | print "true, and it will ask the user whether the folder they are\n"; |
1024 | print "creating contains subfolders or messages.\n"; |
1025 | print "\n"; |
1026 | |
1027 | if ($show_contain_subfolders_option eq "true") { |
1028 | $default_value = "y"; |
1029 | } else { |
1030 | $default_value = "n"; |
1031 | } |
1032 | print "Show option (y/n) [$WHT$default_value$NRM]: $WHT"; |
1033 | $new_show = <STDIN>; |
1034 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
1035 | $show_contain_subfolders_option = "true"; |
1036 | } else { |
1037 | $show_contain_subfolders_option = "false"; |
1038 | } |
1039 | return $show_contain_subfolders_option; |
911ad01c |
1040 | } |
1041 | |
24fc5dd2 |
1042 | # Default Unseen Notify |
1043 | sub command212 { |
1044 | print "This option specifies where the users will receive notification\n"; |
1045 | print "about unseen messages by default. This is of course an option that\n"; |
1046 | print "can be changed on a user level.\n"; |
1047 | print " 1 = No notification\n"; |
1048 | print " 2 = Only on the INBOX\n"; |
1049 | print " 3 = On all folders\n"; |
1050 | print "\n"; |
1051 | |
1052 | print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT"; |
1053 | $new_show = <STDIN>; |
1054 | if ($new_show =~ /^[1|2|3]\n/i) { |
1055 | $default_unseen_notify = $new_show; |
1056 | } |
1057 | $default_unseen_notify =~ s/[\r|\n]//g; |
1058 | return $default_unseen_notify; |
1059 | } |
1060 | |
1061 | # Default Unseen Type |
1062 | sub command213 { |
1063 | print "Here you can define the default way that unseen messages will be displayed\n"; |
1064 | print "to the user in the folder listing on the left side.\n"; |
1065 | print " 1 = Only unseen messages (4)\n"; |
1066 | print " 2 = Unseen and Total messages (4/27)\n"; |
1067 | print "\n"; |
1068 | |
1069 | print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT"; |
1070 | $new_show = <STDIN>; |
1071 | if ($new_show =~ /^[1|2]\n/i) { |
1072 | $default_unseen_type = $new_show; |
1073 | } |
1074 | $default_unseen_type =~ s/[\r|\n]//g; |
1075 | return $default_unseen_type; |
1076 | } |
1077 | |
1078 | |
ccfb2029 |
1079 | ############# GENERAL OPTIONS ##################### |
1080 | |
1081 | # Default Charset |
1082 | sub command31 { |
1083 | print "This option controls what character set is used when sending\n"; |
1084 | print "mail and when sending HTML to the browser. Do not set this\n"; |
1085 | print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n"; |
1086 | print "to use KOI8-R, since this implementation is faster than most\n"; |
1087 | print "of the alternatives\n"; |
1088 | print "\n"; |
1089 | |
1090 | print "[$WHT$default_charset$NRM]: $WHT"; |
1091 | $new_default_charset = <STDIN>; |
1092 | if ($new_default_charset eq "\n") { |
1093 | $new_default_charset = $default_charset; |
1094 | } else { |
1095 | $new_default_charset =~ s/[\r|\n]//g; |
1096 | } |
1097 | return $new_default_charset; |
1098 | } |
1099 | |
ccfb2029 |
1100 | # Data directory |
1101 | sub command33 { |
1102 | print "It is a possible security hole to have a writable directory\n"; |
1103 | print "under the web server's root directory (ex: /home/httpd/html).\n"; |
1104 | print "For this reason, it is possible to put the data directory\n"; |
1105 | print "anywhere you would like. The path name can be absolute or\n"; |
1106 | print "relative (to the config directory). It doesn't matter. Here\n"; |
1107 | print "are two examples:\n"; |
1108 | print " Absolute: /usr/local/squirrelmail/data/\n"; |
1109 | print " Relative: ../data/\n"; |
1110 | print "\n"; |
1111 | |
1112 | print "[$WHT$data_dir$NRM]: $WHT"; |
1113 | $new_data_dir = <STDIN>; |
1114 | if ($new_data_dir eq "\n") { |
1115 | $new_data_dir = $data_dir; |
1116 | } else { |
1117 | $new_data_dir =~ s/[\r|\n]//g; |
1118 | } |
1119 | if ($new_data_dir =~ /^\s*$/) { |
1120 | $new_data_dir = ""; |
1121 | } else { |
1122 | $new_data_dir =~ s/\/*$//g; |
1123 | $new_data_dir =~ s/$/\//g; |
1124 | } |
1125 | return $new_data_dir; |
1126 | } |
1127 | |
1128 | # Attachment directory |
1129 | sub command34 { |
1130 | print "Path to directory used for storing attachments while a mail is\n"; |
1131 | print "being sent. There are a few security considerations regarding this\n"; |
1132 | print "directory:\n"; |
1133 | print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n"; |
1134 | print " impossible for a random person with access to the webserver\n"; |
1135 | print " to list files in this directory. Confidential data might\n"; |
1136 | print " be laying around in there.\n"; |
1137 | print " 2. Since the webserver is not able to list the files in the\n"; |
1138 | print " content is also impossible for the webserver to delete files\n"; |
1139 | print " lying around there for too long.\n"; |
1140 | print " 3. It should probably be another directory than the data\n"; |
1141 | print " directory specified in option 3.\n"; |
1142 | print "\n"; |
1143 | |
1144 | print "[$WHT$attachment_dir$NRM]: $WHT"; |
1145 | $new_attachment_dir = <STDIN>; |
1146 | if ($new_attachment_dir eq "\n") { |
1147 | $new_attachment_dir = $attachment_dir; |
1148 | } else { |
1149 | $new_attachment_dir =~ s/[\r|\n]//g; |
1150 | } |
1151 | if ($new_attachment_dir =~ /^\s*$/) { |
1152 | $new_attachment_dir = ""; |
1153 | } else { |
1154 | $new_attachment_dir =~ s/\/*$//g; |
1155 | $new_attachment_dir =~ s/$/\//g; |
1156 | } |
1157 | return $new_attachment_dir; |
1158 | } |
1159 | |
1160 | |
1161 | sub command35 { |
1162 | print "This is the default size (in pixels) of the left folder list.\n"; |
1163 | print "Default is 200, but you can set it to whatever you wish. This\n"; |
1164 | print "is a user preference, so this will only show up as their default.\n"; |
1165 | print "\n"; |
1166 | print "[$WHT$default_left_size$NRM]: $WHT"; |
1167 | $new_default_left_size = <STDIN>; |
1168 | if ($new_default_left_size eq "\n") { |
1169 | $new_default_left_size = $default_left_size; |
1170 | } else { |
1171 | $new_default_left_size =~ s/[\r|\n]//g; |
1172 | } |
1173 | return $new_default_left_size; |
1174 | } |
1175 | |
1176 | |
985f7c88 |
1177 | sub command36 { |
1178 | print "Some IMAP servers only have lowercase letters in the usernames\n"; |
1179 | print "but they still allow people with uppercase to log in. This\n"; |
1180 | print "causes a problem with the user's preference files. This option\n"; |
1181 | print "transparently changes all usernames to lowercase."; |
1182 | print "\n"; |
1183 | |
1184 | if ($force_username_lowercase eq "true") { |
1185 | $default_value = "y"; |
1186 | } else { |
1187 | $default_value = "n"; |
1188 | } |
1189 | print "Convert usernames to lowercase (y/n) [$WHT$default_value$NRM]: $WHT"; |
1190 | $new_show = <STDIN>; |
1191 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
1192 | return "true"; |
1193 | } |
1194 | return "false"; |
1195 | } |
1196 | |
1197 | |
ccfb2029 |
1198 | sub command41 { |
1199 | print "\nNow we will define the themes that you wish to use. If you have added\n"; |
1200 | print "a theme of your own, just follow the instructions (?) about how to add\n"; |
1201 | print "them. You can also change the default theme.\n"; |
1202 | print "[theme] command (?=help) > "; |
1203 | $input = <STDIN>; |
1204 | $input =~ s/[\r|\n]//g; |
1205 | while ($input ne "d") { |
1206 | if ($input =~ /^\s*l\s*/i) { |
1207 | $count = 0; |
1208 | while ($count <= $#theme_name) { |
1209 | if ($count == $theme_default) { |
1210 | print " *"; |
1211 | } else { |
1212 | print " "; |
1213 | } |
1214 | $name = $theme_name[$count]; |
1215 | $num_spaces = 25 - length($name); |
1216 | for ($i = 0; $i < $num_spaces;$i++) { |
1217 | $name = $name . " "; |
1218 | } |
1219 | |
1220 | print " $count. $name"; |
1221 | print "($theme_path[$count])\n"; |
1222 | |
1223 | $count++; |
1224 | } |
1225 | } elsif ($input =~ /^\s*m\s*[0-9]+/i) { |
1226 | $old_def = $theme_default; |
1227 | $theme_default = $input; |
1228 | $theme_default =~ s/^\s*m\s*//; |
1229 | if (($theme_default > $#theme_name) || ($theme_default < 0)) { |
1230 | print "Cannot set default theme to $theme_default. That theme does not exist.\n"; |
1231 | $theme_default = $old_def; |
1232 | } |
1233 | } elsif ($input =~ /^\s*\+/) { |
1234 | print "What is the name of this theme: "; |
1235 | $name = <STDIN>; |
1236 | $name =~ s/[\r|\n]//g; |
1237 | $theme_name[$#theme_name+1] = $name; |
390372b4 |
1238 | print "Be sure to put ../themes/ before the filename.\n"; |
1239 | print "What file is this stored in (ex: ../themes/default_theme.php): "; |
ccfb2029 |
1240 | $name = <STDIN>; |
1241 | $name =~ s/[\r|\n]//g; |
1242 | $theme_path[$#theme_path+1] = $name; |
1243 | } elsif ($input =~ /^\s*-\s*[0-9]?/) { |
1244 | if ($input =~ /[0-9]+\s*$/) { |
1245 | $rem_num = $input; |
1246 | $rem_num =~ s/^\s*-\s*//g; |
1247 | $rem_num =~ s/\s*$//; |
1248 | } else { |
1249 | $rem_num = $#theme_name; |
1250 | } |
1251 | if ($rem_num == $theme_default) { |
1252 | print "You cannot remove the default theme!\n"; |
1253 | } else { |
1254 | $count = 0; |
1255 | @new_theme_name = (); |
1256 | @new_theme_path = (); |
1257 | while ($count <= $#theme_name) { |
1258 | if ($count != $rem_num) { |
1259 | @new_theme_name = (@new_theme_name, $theme_name[$count]); |
1260 | @new_theme_path = (@new_theme_path, $theme_path[$count]); |
1261 | } |
1262 | $count++; |
1263 | } |
1264 | @theme_name = @new_theme_name; |
1265 | @theme_path = @new_theme_path; |
1266 | if ($theme_default > $rem_num) { |
1267 | $theme_default--; |
1268 | } |
1269 | } |
8442ac08 |
1270 | } elsif ($input =~ /^\s*t\s*/i) { |
1271 | print "\nStarting detection...\n\n"; |
1272 | |
1273 | opendir(DIR, "../themes"); |
1274 | @files = grep { /\.php$/i } readdir(DIR); |
1275 | $cnt = 0; |
1276 | while ($cnt <= $#files) { |
1277 | $filename = "../themes/" . $files[$cnt]; |
5cb1d69b |
1278 | if ($filename ne "../themes/index.php") { |
1279 | $found = 0; |
1280 | for ($x=0; $x <= $#theme_path; $x++) { |
1281 | if ($theme_path[$x] eq $filename) { |
1282 | $found = 1; |
1283 | } |
1284 | } |
1285 | if ($found != 1) { |
1286 | print "** Found theme: $filename\n"; |
1287 | print " What is its name? "; |
1288 | $nm = <STDIN>; |
1289 | $nm =~ s/[\n|\r]//g; |
1290 | $theme_name[$#theme_name+1] = $nm; |
1291 | $theme_path[$#theme_path+1] = $filename; |
8442ac08 |
1292 | } |
8442ac08 |
1293 | } |
1294 | $cnt++; |
1295 | } |
1296 | print "\n"; |
1297 | for ($cnt=0; $cnt <= $#theme_path; $cnt++) { |
1298 | $filename = $theme_path[$cnt]; |
1299 | if (! (-e $filename)) { |
1300 | print " Removing $filename (file not found)\n"; |
1301 | $offset = 0; |
1302 | @new_theme_name = (); |
1303 | @new_theme_path = (); |
1304 | for ($x=0; $x < $#theme_path; $x++) { |
1305 | if ($theme_path[$x] eq $filename) { |
1306 | $offset = 1; |
1307 | } |
1308 | if ($offset == 1) { |
1309 | $new_theme_name[$x] = $theme_name[$x+1]; |
1310 | $new_theme_path[$x] = $theme_path[$x+1]; |
1311 | } else { |
1312 | $new_theme_name[$x] = $theme_name[$x]; |
1313 | $new_theme_path[$x] = $theme_path[$x]; |
1314 | } |
1315 | } |
1316 | @theme_name = @new_theme_name; |
1317 | @theme_path = @new_theme_path; |
1318 | } |
1319 | } |
1320 | print "\nDetection complete!\n\n"; |
1321 | |
1322 | closedir DIR; |
ccfb2029 |
1323 | } elsif ($input =~ /^\s*\?\s*/) { |
1324 | print ".-------------------------.\n"; |
8442ac08 |
1325 | print "| t (detect themes) |\n"; |
ccfb2029 |
1326 | print "| + (add theme) |\n"; |
1327 | print "| - N (remove theme) |\n"; |
1328 | print "| m N (mark default) |\n"; |
1329 | print "| l (list themes) |\n"; |
1330 | print "| d (done) |\n"; |
1331 | print "`-------------------------'\n"; |
1332 | } |
1333 | print "[theme] command (?=help) > "; |
1334 | $input = <STDIN>; |
1335 | $input =~ s/[\r|\n]//g; |
1336 | } |
1337 | } |
1338 | |
1339 | |
6f3bfa54 |
1340 | # Theme - CSS file |
1341 | sub command42 { |
1342 | print "You may specify a cascading style-sheet (CSS) file to be included\n"; |
1343 | print "on each html page generated by SquirrelMail. The CSS file is useful\n"; |
1344 | print "for specifying a site-wide font. If you're not familiar with CSS\n"; |
1345 | print "files, leave this blank.\n"; |
1346 | print "\n"; |
1347 | print "To clear out an existing value, just type a space for the input.\n"; |
1348 | print "\n"; |
1349 | print "[$WHT$theme_css$NRM]: $WHT"; |
1350 | $new_theme_css = <STDIN>; |
1351 | if ($new_theme_css eq "\n") { |
1352 | $new_theme_css = $theme_css; |
1353 | } else { |
1354 | $new_theme_css =~ s/[\r|\n]//g; |
1355 | } |
1356 | $new_theme_css =~ s/^\s*//; |
1357 | return $new_theme_css; |
1358 | } |
1359 | |
1360 | |
1e0628fb |
1361 | sub command61 { |
a93b12ba |
1362 | print "You can now define different LDAP servers.\n"; |
1e0628fb |
1363 | print "[ldap] command (?=help) > "; |
1364 | $input = <STDIN>; |
1365 | $input =~ s/[\r|\n]//g; |
1366 | while ($input ne "d") { |
1367 | if ($input =~ /^\s*l\s*/i) { |
1368 | $count = 0; |
1369 | while ($count <= $#ldap_host) { |
a93b12ba |
1370 | print "$count. $ldap_host[$count]\n"; |
1371 | print " base: $ldap_base[$count]\n"; |
1372 | if ($ldap_charset[$count]) { |
1373 | print " charset: $ldap_charset[$count]\n"; |
1374 | } |
1375 | if ($ldap_port[$count]) { |
1376 | print " port: $ldap_port[$count]\n"; |
1377 | } |
1378 | if ($ldap_name[$count]) { |
1379 | print " name: $ldap_name[$count]\n"; |
1380 | } |
1381 | if ($ldap_maxrows[$count]) { |
1382 | print " maxrows: $ldap_maxrows[$count]\n"; |
1383 | } |
1384 | print "\n"; |
1e0628fb |
1385 | $count++; |
1386 | } |
1387 | } elsif ($input =~ /^\s*\+/) { |
a93b12ba |
1388 | $sub = $#ldap_host + 1; |
1e0628fb |
1389 | |
a93b12ba |
1390 | print "First, we need to have the hostname or the IP address where\n"; |
1391 | print "this LDAP server resides. Example: ldap.bigfoot.com\n"; |
1392 | print "hostname: "; |
1e0628fb |
1393 | $name = <STDIN>; |
1394 | $name =~ s/[\r|\n]//g; |
1395 | $ldap_host[$sub] = $name; |
a93b12ba |
1396 | |
1397 | print "\n"; |
1e0628fb |
1398 | |
a93b12ba |
1399 | print "Next, we need the server root (base dn). For this, an empty\n"; |
1400 | print "string is allowed.\n"; |
1401 | print "Example: ou=member_directory,o=netcenter.com\n"; |
1402 | print "base: "; |
1e0628fb |
1403 | $name = <STDIN>; |
1404 | $name =~ s/[\r|\n]//g; |
1405 | $ldap_base[$sub] = $name; |
1406 | |
a93b12ba |
1407 | print "\n"; |
1e0628fb |
1408 | |
a93b12ba |
1409 | print "This is the TCP/IP port number for the LDAP server. Default\n"; |
1410 | print "port is 389. This is optional. Press ENTER for default.\n"; |
1411 | print "port: "; |
1e0628fb |
1412 | $name = <STDIN>; |
1413 | $name =~ s/[\r|\n]//g; |
1414 | $ldap_port[$sub] = $name; |
1415 | |
a93b12ba |
1416 | print "\n"; |
1e0628fb |
1417 | |
a93b12ba |
1418 | print "This is the charset for the server. Default is utf-8. This\n"; |
1419 | print "is also optional. Press ENTER for default.\n"; |
1420 | print "charset: "; |
1e0628fb |
1421 | $name = <STDIN>; |
1422 | $name =~ s/[\r|\n]//g; |
1423 | $ldap_charset[$sub] = $name; |
1424 | |
a93b12ba |
1425 | print "\n"; |
1e0628fb |
1426 | |
a93b12ba |
1427 | print "This is the name for the server, used to tag the results of\n"; |
1428 | print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n"; |
1429 | print "name: "; |
1e0628fb |
1430 | $name = <STDIN>; |
1431 | $name =~ s/[\r|\n]//g; |
1432 | $ldap_name[$sub] = $name; |
1433 | |
a93b12ba |
1434 | print "\n"; |
1e0628fb |
1435 | |
a93b12ba |
1436 | print "You can specify the maximum number of rows in the search result.\n"; |
1437 | print "Default is unlimited. Press ENTER for default.\n"; |
1438 | print "maxrows: "; |
1e0628fb |
1439 | $name = <STDIN>; |
1440 | $name =~ s/[\r|\n]//g; |
1441 | $ldap_maxrows[$sub] = $name; |
1442 | |
a93b12ba |
1443 | print "\n"; |
1e0628fb |
1444 | |
1445 | } elsif ($input =~ /^\s*-\s*[0-9]?/) { |
1446 | if ($input =~ /[0-9]+\s*$/) { |
1447 | $rem_num = $input; |
1448 | $rem_num =~ s/^\s*-\s*//g; |
1449 | $rem_num =~ s/\s*$//; |
1450 | } else { |
1451 | $rem_num = $#ldap_host; |
1452 | } |
1453 | $count = 0; |
1454 | @new_ldap_host = (); |
1455 | @new_ldap_base = (); |
1456 | @new_ldap_port = (); |
1457 | @new_ldap_name = (); |
1458 | @new_ldap_charset = (); |
1459 | @new_ldap_maxrows = (); |
1460 | while ($count <= $#ldap_host) { |
1461 | if ($count != $rem_num) { |
1462 | @new_ldap_host = (@new_ldap_host, $ldap_host[$count]); |
1463 | @new_ldap_base = (@new_ldap_base, $ldap_base[$count]); |
1464 | @new_ldap_port = (@new_ldap_port, $ldap_port[$count]); |
1465 | @new_ldap_name = (@new_ldap_name, $ldap_name[$count]); |
1466 | @new_ldap_charset = (@new_ldap_charset, $ldap_charset[$count]); |
1467 | @new_ldap_maxrows = (@new_ldap_maxrows, $ldap_maxrows[$count]); |
1468 | } |
1469 | $count++; |
1470 | } |
1471 | @ldap_host = @new_ldap_host; |
1472 | @ldap_base = @new_ldap_base; |
1473 | @ldap_port = @new_ldap_port; |
1474 | @ldap_name = @new_ldap_name; |
1475 | @ldap_charset = @new_ldap_charset; |
1476 | @ldap_maxrows = @new_ldap_maxrows; |
1477 | } elsif ($input =~ /^\s*\?\s*/) { |
1478 | print ".-------------------------.\n"; |
1479 | print "| + (add host) |\n"; |
1480 | print "| - N (remove host) |\n"; |
1481 | print "| l (list hosts) |\n"; |
1482 | print "| d (done) |\n"; |
1483 | print "`-------------------------'\n"; |
1484 | } |
1485 | print "[ldap] command (?=help) > "; |
1486 | $input = <STDIN>; |
1487 | $input =~ s/[\r|\n]//g; |
1488 | } |
1489 | } |
1490 | |
3806fa52 |
1491 | sub command62 { |
591000ec |
1492 | print "Some of our developers have come up with very good javascript interface\n"; |
1493 | print "for searching through address books, however, our original goals said\n"; |
1494 | print "that we would be 100% HTML. In order to make it possible to use their\n"; |
1495 | print "interface, and yet stick with our goals, we have also written a plain\n"; |
1496 | print "HTML version of the search. Here, you can choose which version to use.\n"; |
3806fa52 |
1497 | print "\n"; |
1498 | print "This is just the default value. It is also a user option that each\n"; |
1499 | print "user can configure individually\n"; |
1500 | print "\n"; |
1501 | |
1502 | if ($default_use_javascript_addr_book eq "true") { |
1503 | $default_value = "y"; |
1504 | } else { |
1505 | $default_use_javascript_addr_book = "false"; |
1506 | $default_value = "n"; |
1507 | } |
c4809aca |
1508 | print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT"; |
3806fa52 |
1509 | $new_show = <STDIN>; |
1510 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
1511 | $default_use_javascript_addr_book = "true"; |
1512 | } else { |
1513 | $default_use_javascript_addr_book = "false"; |
1514 | } |
1515 | return $default_use_javascript_addr_book; |
1516 | } |
1e0628fb |
1517 | |
ccfb2029 |
1518 | |
1519 | sub save_data { |
1520 | open (FILE, ">config.php"); |
1521 | |
349ca9f7 |
1522 | print FILE "<?php\n\t/** SquirrelMail configuration\n"; |
ccfb2029 |
1523 | print FILE "\t ** Created using the configure script, conf.pl\n\t **/\n\n"; |
1524 | |
6b638171 |
1525 | if ($print_config_version) { |
1526 | print FILE "\t\$config_version = \"$print_config_version\";\n"; |
6b638171 |
1527 | } |
0ecb47e5 |
1528 | print FILE "\t\$config_use_color = $config_use_color;\n"; |
1529 | print FILE "\n"; |
4011c3ca |
1530 | |
ccfb2029 |
1531 | print FILE "\t\$org_name = \"$org_name\";\n"; |
1532 | print FILE "\t\$org_logo = \"$org_logo\";\n"; |
1533 | print FILE "\t\$org_title = \"$org_title\";\n"; |
1534 | |
1535 | print FILE "\n"; |
1536 | |
c39a6b45 |
1537 | print FILE "\t\$domain = \"$domain\";\n"; |
1538 | print FILE "\t\$imapServerAddress = \"$imapServerAddress\";\n"; |
1539 | print FILE "\t\$imapPort = $imapPort;\n"; |
1540 | print FILE "\t\$useSendmail = $useSendmail;\n"; |
1541 | print FILE "\t\$smtpServerAddress = \"$smtpServerAddress\";\n"; |
1542 | print FILE "\t\$smtpPort = $smtpPort;\n"; |
d47b2518 |
1543 | print FILE "\t\$sendmail_path = \"$sendmail_path\";\n"; |
a93b12ba |
1544 | print FILE "\t\$imap_server_type = \"$imap_server_type\";\n"; |
d47b2518 |
1545 | print FILE "\t\$invert_time = $invert_time;\n"; |
40ba4d36 |
1546 | print FILE "\t\$optional_delimiter = \"$optional_delimiter\";\n"; |
ccfb2029 |
1547 | |
1548 | print FILE "\n"; |
1549 | |
1550 | print FILE "\t\$default_folder_prefix = \"$default_folder_prefix\";\n"; |
8ad99a99 |
1551 | print FILE "\t\$trash_folder = \"$trash_folder\";\n"; |
ccfb2029 |
1552 | print FILE "\t\$sent_folder = \"$sent_folder\";\n"; |
2f287147 |
1553 | print FILE "\t\$default_move_to_trash = $default_move_to_trash;\n"; |
1554 | print FILE "\t\$default_move_to_sent = $default_move_to_sent;\n"; |
ccfb2029 |
1555 | print FILE "\t\$show_prefix_option = $show_prefix_option;\n"; |
1556 | print FILE "\t\$list_special_folders_first = $list_special_folders_first;\n"; |
1557 | print FILE "\t\$use_special_folder_color = $use_special_folder_color;\n"; |
ccfb2029 |
1558 | print FILE "\t\$auto_expunge = $auto_expunge;\n"; |
1559 | print FILE "\t\$default_sub_of_inbox = $default_sub_of_inbox;\n"; |
c39a6b45 |
1560 | print FILE "\t\$show_contain_subfolders_option = $show_contain_subfolders_option;\n"; |
24fc5dd2 |
1561 | print FILE "\t\$default_unseen_notify = $default_unseen_notify;\n"; |
1562 | print FILE "\t\$default_unseen_type = $default_unseen_type;\n"; |
ccfb2029 |
1563 | print FILE "\n"; |
1564 | |
985f7c88 |
1565 | print FILE "\t\$default_charset = \"$default_charset\";\n"; |
1566 | print FILE "\t\$data_dir = \"$data_dir\";\n"; |
1567 | print FILE "\t\$attachment_dir = \"$attachment_dir\";\n"; |
1568 | print FILE "\t\$default_left_size = $default_left_size;\n"; |
1569 | print FILE "\t\$force_username_lowercase = $force_username_lowercase;\n"; |
ccfb2029 |
1570 | |
1571 | print FILE "\n"; |
1572 | |
1a7a2fcc |
1573 | for ($ct=0; $ct <= $#plugins; $ct++) { |
1574 | print FILE "\t\$plugins[$ct] = \"$plugins[$ct]\";\n"; |
9d0c7bee |
1575 | } |
1576 | |
1577 | print FILE "\n"; |
1578 | |
6f3bfa54 |
1579 | print FILE "\t\$theme_css = \"$theme_css\";\n"; |
ccfb2029 |
1580 | for ($count=0; $count <= $#theme_name; $count++) { |
8ad99a99 |
1581 | print FILE "\t\$theme[$count][\"PATH\"] = \"$theme_path[$count]\";\n"; |
1582 | print FILE "\t\$theme[$count][\"NAME\"] = \"$theme_name[$count]\";\n"; |
1583 | } |
1584 | |
ccfb2029 |
1585 | print FILE "\n"; |
1586 | |
3806fa52 |
1587 | if ($default_use_javascript_addr_book ne "true") { |
1588 | $default_use_javascript_addr_book = "false"; |
1589 | } |
1590 | print FILE "\t\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n"; |
1e0628fb |
1591 | for ($count=0; $count <= $#ldap_host; $count++) { |
a93b12ba |
1592 | print FILE "\t\$ldap_server[$count] = Array(\n"; |
1593 | print FILE "\t\t\t\"host\" => \"$ldap_host[$count]\",\n"; |
1594 | print FILE "\t\t\t\"base\" => \"$ldap_base[$count]\""; |
1595 | if ($ldap_name[$count]) { |
1596 | print FILE ",\n\t\t\t\"name\" => \"$ldap_name[$count]\""; |
1597 | } |
1598 | if ($ldap_port[$count]) { |
1599 | print FILE ",\n\t\t\t\"port\" => \"$ldap_port[$count]\""; |
1600 | } |
1601 | if ($ldap_charset[$count]) { |
1602 | print FILE ",\n\t\t\t\"charset\" => \"$ldap_charset[$count]\""; |
1603 | } |
1604 | if ($ldap_maxrows[$count]) { |
1605 | print FILE ",\n\t\t\t\"maxrows\" => \"$ldap_maxrows[$count]\""; |
1606 | } |
1607 | print FILE ");\n\n"; |
1e0628fb |
1608 | } |
1609 | |
8ad99a99 |
1610 | print FILE "\t\$motd = \"$motd\";\n"; |
ccfb2029 |
1611 | |
1612 | print FILE "?>\n"; |
1613 | close FILE; |
911ad01c |
1614 | } |
a93b12ba |
1615 | |
1616 | sub set_defaults { |
1617 | system "clear"; |
612eda0a |
1618 | print $WHT."SquirrelMail Configuration : ".$NRM; |
1619 | if ($config == 1) { print "Read: config.php"; } |
1620 | elsif ($config == 2) { print "Read: config_default.php"; } |
1621 | print "\n"; |
1622 | print "---------------------------------------------------------\n"; |
1623 | |
a93b12ba |
1624 | print "While we have been building SquirrelMail, we have discovered some\n"; |
1625 | print "preferences that work better with some servers that don't work so\n"; |
1626 | print "well with others. If you select your IMAP server, this option will\n"; |
1627 | print "set some pre-defined settings for that server.\n"; |
1628 | print "\n"; |
1629 | print "Please note that you will still need to go through and make sure\n"; |
1630 | print "everything is correct. This does not change everything. There are\n"; |
e9f8ea4e |
1631 | print "only a few settings that this will change.\n"; |
a93b12ba |
1632 | print "\n"; |
1633 | |
1634 | $continue = 0; |
1635 | while ($continue != 1) { |
1636 | print "Please select your IMAP server:\n"; |
1637 | print " cyrus = Cyrus IMAP server\n"; |
1638 | print " uw = University of Washington's IMAP server\n"; |
1639 | print " exchange = Microsoft Exchange IMAP server\n"; |
1640 | print " courier = Courier IMAP server\n"; |
1641 | print " quit = Do not change anything\n"; |
1642 | print "Command >> "; |
1643 | $server = <STDIN>; |
1644 | $server =~ s/[\r|\n]//g; |
1645 | |
c4809aca |
1646 | print "\n"; |
1647 | if ($server eq "cyrus") { |
1648 | $default_folder_prefix = "INBOX"; |
a93b12ba |
1649 | $trash_folder = "INBOX.Trash"; |
1650 | $sent_folder = "INBOX.Sent"; |
1651 | $show_prefix_option = false; |
1652 | $default_sub_of_inbox = true; |
1653 | $show_contain_subfolders_option = false; |
1654 | $imap_server_type = "cyrus"; |
1655 | |
c4809aca |
1656 | print " default_folder_prefix = INBOX\n"; |
1657 | print " trash_folder = INBOX.Trash\n"; |
1658 | print " sent_folder = INBOX.Sent\n"; |
e9f8ea4e |
1659 | print " show_prefix_option = false\n"; |
c4809aca |
1660 | print " default_sub_of_inbox = true\n"; |
1661 | print "show_contain_subfolders_option = false\n"; |
1662 | print " imap_server_type = cyrus\n"; |
1663 | |
a93b12ba |
1664 | $continue = 1; |
1665 | } elsif ($server eq "uw") { |
1666 | $default_folder_prefix = "mail/"; |
1667 | $trash_folder = "Trash"; |
1668 | $sent_folder = "Sent"; |
1669 | $show_prefix_option = true; |
1670 | $default_sub_of_inbox = false; |
1671 | $show_contain_subfolders_option = true; |
1672 | $imap_server_type = "uw"; |
c4809aca |
1673 | |
1674 | print " default_folder_prefix = mail/\n"; |
1675 | print " trash_folder = Trash\n"; |
1676 | print " sent_folder = Sent\n"; |
1677 | print " show_prefix_option = true\n"; |
1678 | print " default_sub_of_inbox = false\n"; |
1679 | print "show_contain_subfolders_option = true\n"; |
1680 | print " imap_server_type = uw\n"; |
a93b12ba |
1681 | |
1682 | $continue = 1; |
1683 | } elsif ($server eq "exchange") { |
1684 | $default_folder_prefix = "INBOX/"; |
1685 | $default_sub_of_inbox = true; |
1686 | $trash_folder = "INBOX/Deleted Items"; |
1687 | $sent_folder = "INBOX/Sent Items"; |
1688 | $show_prefix_option = false; |
1689 | $show_contain_subfolders_option = false; |
a93b12ba |
1690 | $imap_server_type = "exchange"; |
1691 | |
612eda0a |
1692 | print " default_folder_prefix = INBOX/\n"; |
1693 | print " default_sub_of_inbox = true\n"; |
1694 | print " trash_folder = \"INBOX/Deleted Items\"\n"; |
1695 | print " sent_folder = \"INBOX/Sent Items\"\n"; |
1696 | print " show_prefix_option = false\n"; |
1697 | print " show_contain_subfolders_option = false\n"; |
1698 | print " imap_server_type = exchange\n"; |
1699 | |
a93b12ba |
1700 | $continue = 1; |
1701 | } elsif ($server eq "courier") { |
1702 | $imap_server_type = "courier"; |
612eda0a |
1703 | |
1704 | print " imap_server_type = courier\n"; |
a93b12ba |
1705 | |
1706 | $continue = 1; |
1707 | } elsif ($server eq "quit") { |
1708 | $continue = 1; |
1709 | } else { |
1710 | print "Unrecognized server: $server\n"; |
1711 | print "\n"; |
1712 | } |
1713 | } |
c4809aca |
1714 | print "\nPress any key to continue..."; |
1715 | $tmp = <STDIN>; |
a93b12ba |
1716 | } |