23afd0bd |
1 | #!/usr/bin/env perl |
bbd30ac8 |
2 | # conf.pl |
bbd30ac8 |
3 | # |
6614128e |
4 | # Copyright (c) 1999-2003 The SquirrelMail Project Team |
5 | # Licensed under the GNU GPL. For full terms see COPYING. |
6 | # |
7 | # A simple configure script to configure SquirrelMail |
245a6892 |
8 | # |
9 | # $Id$ |
ccfb2029 |
10 | ############################################################ |
6614128e |
11 | $conf_pl_version = "1.4.0"; |
bbd30ac8 |
12 | |
38b69acb |
13 | ############################################################ |
14 | # Check what directory we're supposed to be running in, and |
15 | # change there if necessary. File::Basename has been in |
16 | # Perl since at least 5.003_7, and nobody sane runs anything |
17 | # before that, but just in case. |
18 | ############################################################ |
8bd9e0dd |
19 | my $dir; |
eaace00e |
20 | if ( eval q{require "File/Basename.pm"} ) { |
8bd9e0dd |
21 | $dir = File::Basename::dirname($0); |
38b69acb |
22 | chdir($dir); |
23 | } |
24 | |
d595e32e |
25 | ############################################################ |
26 | # Some people try to run this as a CGI. That's wrong! |
27 | ############################################################ |
eaace00e |
28 | if ( defined( $ENV{'PATH_INFO'} ) |
29 | || defined( $ENV{'QUERY_STRING'} ) |
30 | || defined( $ENV{'REQUEST_METHOD'} ) ) { |
31 | print "Content-Type: text/html\n\n"; |
32 | print "You must run this script from the command line."; |
33 | exit; |
34 | } |
d595e32e |
35 | |
8bd9e0dd |
36 | ############################################################ |
37 | # If we got here, use Cwd to get the full directory path |
38 | # (the Basename stuff above will sometimes return '.' as |
39 | # the base directory, which is not helpful here). |
40 | ############################################################ |
41 | use Cwd; |
42 | $dir = cwd(); |
43 | |
ccfb2029 |
44 | ############################################################ |
bbd30ac8 |
45 | # First, lets read in the data already in there... |
ccfb2029 |
46 | ############################################################ |
eaace00e |
47 | if ( -e "config.php" ) { |
48 | open( FILE, "config.php" ); |
49 | while ( $line = <FILE> ) { |
50 | $line =~ s/^\s+//; |
51 | $line =~ s/^\$//; |
52 | $var = $line; |
53 | |
54 | $var =~ s/=/EQUALS/; |
55 | if ( $var =~ /^([a-z]|[A-Z])/ ) { |
56 | @o = split ( /\s*EQUALS\s*/, $var ); |
57 | if ( $o[0] eq "config_version" ) { |
58 | $o[1] =~ s/[\n|\r]//g; |
59 | $o[1] =~ s/[\'|\"];\s*$//; |
60 | $o[1] =~ s/;$//; |
61 | $o[1] =~ s/^[\'|\"]//; |
62 | |
63 | $config_version = $o[1]; |
64 | close(FILE); |
65 | } |
66 | } |
67 | } |
68 | close(FILE); |
69 | |
70 | if ( $config_version ne $conf_pl_version ) { |
71 | system "clear"; |
72 | print $WHT. "WARNING:\n" . $NRM; |
73 | print " The file \"config/config.php\" was found, but it is for\n"; |
74 | print " an older version of SquirrelMail. It is possible to still\n"; |
75 | print " read the defaults from this file but be warned that many\n"; |
76 | print " preferences change between versions. It is recommended that\n"; |
77 | print " you start with a clean config.php for each upgrade that you\n"; |
78 | print " do. To do this, just move config/config.php out of the way.\n"; |
79 | print "\n"; |
80 | print "Continue loading with the old config.php [y/N]? "; |
81 | $ctu = <STDIN>; |
82 | |
83 | if ( ( $ctu !~ /^y\n/i ) || ( $ctu =~ /^\n/ ) ) { |
84 | exit; |
85 | } |
86 | |
87 | print "\nDo you want me to stop warning you [y/N]? "; |
88 | $ctu = <STDIN>; |
89 | if ( $ctu =~ /^y\n/i ) { |
90 | $print_config_version = $conf_pl_version; |
91 | } else { |
92 | $print_config_version = $config_version; |
93 | } |
94 | } else { |
95 | $print_config_version = $config_version; |
96 | } |
97 | |
98 | $config = 1; |
99 | open( FILE, "config.php" ); |
100 | } elsif ( -e "config_default.php" ) { |
101 | open( FILE, "config_default.php" ); |
102 | while ( $line = <FILE> ) { |
103 | $line =~ s/^\s+//; |
104 | $line =~ s/^\$//; |
105 | $var = $line; |
106 | |
107 | $var =~ s/=/EQUALS/; |
108 | if ( $var =~ /^([a-z]|[A-Z])/ ) { |
109 | @o = split ( /\s*EQUALS\s*/, $var ); |
110 | if ( $o[0] eq "config_version" ) { |
111 | $o[1] =~ s/[\n|\r]//g; |
112 | $o[1] =~ s/[\'|\"];\s*$//; |
113 | $o[1] =~ s/;$//; |
114 | $o[1] =~ s/^[\'|\"]//; |
115 | |
116 | $config_version = $o[1]; |
117 | close(FILE); |
118 | } |
119 | } |
120 | } |
121 | close(FILE); |
122 | |
123 | if ( $config_version ne $conf_pl_version ) { |
124 | system "clear"; |
125 | print $WHT. "WARNING:\n" . $NRM; |
126 | print " You are trying to use a 'config_default.php' from an older\n"; |
127 | print " version of SquirrelMail. This is HIGHLY unrecommended. You\n"; |
128 | print " should get the 'config_default.php' that matches the version\n"; |
129 | print " of SquirrelMail that you are running. You can get this from\n"; |
130 | print " the SquirrelMail web page by going to the following URL:\n"; |
131 | print " http://www.squirrelmail.org.\n"; |
132 | print "\n"; |
133 | print "Continue loading with old config_default.php (a bad idea) [y/N]? "; |
134 | $ctu = <STDIN>; |
135 | |
136 | if ( ( $ctu !~ /^y\n/i ) || ( $ctu =~ /^\n/ ) ) { |
137 | exit; |
138 | } |
139 | |
140 | print "\nDo you want me to stop warning you [y/N]? "; |
141 | $ctu = <STDIN>; |
142 | if ( $ctu =~ /^y\n/i ) { |
143 | $print_config_version = $conf_pl_version; |
144 | } else { |
145 | $print_config_version = $config_version; |
146 | } |
147 | } else { |
148 | $print_config_version = $config_version; |
149 | } |
150 | $config = 2; |
151 | open( FILE, "config_default.php" ); |
1e0628fb |
152 | } else { |
eaace00e |
153 | print "No configuration file found. Please get config_default.php\n"; |
154 | print "or config.php before running this again. This program needs\n"; |
155 | print "a default config file to get default values.\n"; |
156 | exit; |
bbd30ac8 |
157 | } |
158 | |
a3439b27 |
159 | # Read and parse the current configuration file |
160 | # (either config.php or config_default.php). |
eaace00e |
161 | while ( $line = <FILE> ) { |
8bd9e0dd |
162 | $line =~ s/^\s+//; |
eaace00e |
163 | $line =~ s/^\$//; |
164 | $var = $line; |
165 | |
166 | $var =~ s/=/EQUALS/; |
167 | if ( $var =~ /^([a-z]|[A-Z])/ ) { |
168 | @options = split ( /\s*EQUALS\s*/, $var ); |
169 | $options[1] =~ s/[\n|\r]//g; |
170 | $options[1] =~ s/[\'|\"];\s*$//; |
171 | $options[1] =~ s/;$//; |
172 | $options[1] =~ s/^[\'|\"]//; |
173 | |
174 | if ( $options[0] =~ /^theme\[[0-9]+\]\[['|"]PATH['|"]\]/ ) { |
175 | $sub = $options[0]; |
176 | $sub =~ s/\]\[['|"]PATH['|"]\]//; |
177 | $sub =~ s/.*\[//; |
178 | if ( -e "../themes" ) { |
179 | $options[1] =~ s/^\.\.\/config/\.\.\/themes/; |
a3439b27 |
180 | } |
8bd9e0dd |
181 | $theme_path[$sub] = &change_to_rel_path($options[1]); |
eaace00e |
182 | } elsif ( $options[0] =~ /^theme\[[0-9]+\]\[['|"]NAME['|"]\]/ ) { |
183 | $sub = $options[0]; |
184 | $sub =~ s/\]\[['|"]NAME['|"]\]//; |
185 | $sub =~ s/.*\[//; |
186 | $theme_name[$sub] = $options[1]; |
187 | } elsif ( $options[0] =~ /^plugins\[[0-9]+\]/ ) { |
188 | $sub = $options[0]; |
189 | $sub =~ s/\]//; |
190 | $sub =~ s/^plugins\[//; |
191 | $plugins[$sub] = $options[1]; |
192 | } elsif ( $options[0] =~ /^ldap_server\[[0-9]+\]/ ) { |
193 | $sub = $options[0]; |
194 | $sub =~ s/\]//; |
195 | $sub =~ s/^ldap_server\[//; |
196 | $continue = 0; |
197 | while ( ( $tmp = <FILE> ) && ( $continue != 1 ) ) { |
198 | if ( $tmp =~ /\);\s*$/ ) { |
199 | $continue = 1; |
200 | } |
201 | |
202 | if ( $tmp =~ /^\s*[\'|\"]host[\'|\"]/i ) { |
203 | $tmp =~ s/^\s*[\'|\"]host[\'|\"]\s*=>\s*[\'|\"]//i; |
204 | $tmp =~ s/[\'|\"],?\s*$//; |
205 | $tmp =~ s/[\'|\"]\);\s*$//; |
206 | $host = $tmp; |
207 | } elsif ( $tmp =~ /^\s*[\'|\"]base[\'|\"]/i ) { |
208 | $tmp =~ s/^\s*[\'|\"]base[\'|\"]\s*=>\s*[\'|\"]//i; |
209 | $tmp =~ s/[\'|\"],?\s*$//; |
210 | $tmp =~ s/[\'|\"]\);\s*$//; |
211 | $base = $tmp; |
212 | } elsif ( $tmp =~ /^\s*[\'|\"]charset[\'|\"]/i ) { |
213 | $tmp =~ s/^\s*[\'|\"]charset[\'|\"]\s*=>\s*[\'|\"]//i; |
214 | $tmp =~ s/[\'|\"],?\s*$//; |
215 | $tmp =~ s/[\'|\"]\);\s*$//; |
216 | $charset = $tmp; |
217 | } elsif ( $tmp =~ /^\s*[\'|\"]port[\'|\"]/i ) { |
748c796b |
218 | $tmp =~ s/^\s*[\'|\"]port[\'|\"]\s*=>\s*[\'|\"]?//i; |
219 | $tmp =~ s/[\'|\"]?,?\s*$//; |
220 | $tmp =~ s/[\'|\"]?\);\s*$//; |
eaace00e |
221 | $port = $tmp; |
222 | } elsif ( $tmp =~ /^\s*[\'|\"]maxrows[\'|\"]/i ) { |
748c796b |
223 | $tmp =~ s/^\s*[\'|\"]maxrows[\'|\"]\s*=>\s*[\'|\"]?//i; |
224 | $tmp =~ s/[\'|\"]?,?\s*$//; |
225 | $tmp =~ s/[\'|\"]?\);\s*$//; |
eaace00e |
226 | $maxrows = $tmp; |
227 | } elsif ( $tmp =~ /^\s*[\'|\"]name[\'|\"]/i ) { |
228 | $tmp =~ s/^\s*[\'|\"]name[\'|\"]\s*=>\s*[\'|\"]//i; |
229 | $tmp =~ s/[\'|\"],?\s*$//; |
230 | $tmp =~ s/[\'|\"]\);\s*$//; |
231 | $name = $tmp; |
232 | } |
a3439b27 |
233 | } |
eaace00e |
234 | $ldap_host[$sub] = $host; |
235 | $ldap_base[$sub] = $base; |
236 | $ldap_name[$sub] = $name; |
237 | $ldap_port[$sub] = $port; |
238 | $ldap_maxrows[$sub] = $maxrows; |
239 | $ldap_charset[$sub] = $charset; |
8bd9e0dd |
240 | } elsif ( $options[0] =~ /^(data_dir|attachment_dir|theme_css|org_logo|signout_page)$/ ) { |
241 | ${ $options[0] } = &change_to_rel_path($options[1]); |
eaace00e |
242 | } else { |
243 | ${ $options[0] } = $options[1]; |
244 | } |
245 | } |
bbd30ac8 |
246 | } |
1a7a2fcc |
247 | close FILE; |
eaace00e |
248 | if ( $useSendmail ne "true" ) { |
249 | $useSendmail = "false"; |
828b4753 |
250 | } |
eaace00e |
251 | if ( !$sendmail_path ) { |
252 | $sendmail_path = "/usr/sbin/sendmail"; |
828b4753 |
253 | } |
254ded61 |
254 | if ( !$pop_before_smtp ) { |
255 | $pop_before_smtp = "false"; |
256 | } |
eaace00e |
257 | if ( !$default_unseen_notify ) { |
258 | $default_unseen_notify = 2; |
24fc5dd2 |
259 | } |
eaace00e |
260 | if ( !$default_unseen_type ) { |
261 | $default_unseen_type = 1; |
24fc5dd2 |
262 | } |
eaace00e |
263 | if ( !$config_use_color ) { |
264 | $config_use_color = 0; |
0ecb47e5 |
265 | } |
eaace00e |
266 | if ( !$invert_time ) { |
267 | $invert_time = "false"; |
a1f1f9bc |
268 | } |
eaace00e |
269 | if ( !$force_username_lowercase ) { |
a3439b27 |
270 | $force_username_lowercase = "false"; |
23a8095f |
271 | } |
eaace00e |
272 | if ( !$optional_delimiter ) { |
a3439b27 |
273 | $optional_delimiter = "detect"; |
40ba4d36 |
274 | } |
eaace00e |
275 | if ( !$auto_create_special ) { |
a3439b27 |
276 | $auto_create_special = "false"; |
f7bfc9de |
277 | } |
eaace00e |
278 | if ( !$default_use_priority ) { |
a3439b27 |
279 | $default_use_priority = "true"; |
0d15cd19 |
280 | } |
eaace00e |
281 | if ( !$hide_sm_attributions ) { |
a3439b27 |
282 | $hide_sm_attributions = "false"; |
826b7f71 |
283 | } |
eaace00e |
284 | if ( !$default_use_mdn ) { |
8c21da0c |
285 | $default_use_mdn = "true"; |
286 | } |
6517cfd0 |
287 | if ( !$delete_folder ) { |
288 | $delete_folder = "false"; |
289 | } |
ca85aabe |
290 | if ( !$noselect_fix_enable ) { |
291 | $noselect_fix_enable = "false"; |
292 | } |
eaace00e |
293 | if ( !$frame_top ) { |
3d043efc |
294 | $frame_top = "_top"; |
295 | } |
0ae4c1f2 |
296 | |
297 | if ( !$provider_uri ) { |
298 | $provider_uri = "http://www.squirrelmail.org/"; |
299 | } |
300 | |
301 | if ( !$provider_name ) { |
302 | $provider_name = "SquirrelMail"; |
303 | } |
304 | |
eaace00e |
305 | if ( !$edit_identity ) { |
8a7d0669 |
306 | $edit_identity = "true"; |
307 | } |
eaace00e |
308 | if ( !$edit_name ) { |
8a7d0669 |
309 | $edit_name = "true"; |
310 | } |
7c612fdd |
311 | if ( !$allow_thread_sort ) { |
312 | $allow_thread_sort = 'false'; |
313 | } |
aa0da530 |
314 | if ( !$allow_server_sort ) { |
315 | $allow_server_sort = 'false'; |
316 | } |
3c7ee482 |
317 | if ( !$uid_support ) { |
bb425d06 |
318 | $uid_support = 'true'; |
3c7ee482 |
319 | } |
69ea91ae |
320 | if ( !$no_list_for_subscribe ) { |
321 | $no_list_for_subscribe = 'false'; |
322 | } |
296f4c20 |
323 | if ( !$allow_charset_search ) { |
324 | $allow_charset_search = 'true'; |
325 | } |
99a6c222 |
326 | if ( !$prefs_user_field ) { |
327 | $prefs_user_field = 'user'; |
328 | } |
329 | if ( !$prefs_key_field ) { |
330 | $prefs_key_field = 'prefkey'; |
331 | } |
332 | if ( !$prefs_val_field ) { |
333 | $prefs_val_field = 'prefval'; |
334 | } |
bbd30ac8 |
335 | |
47a29326 |
336 | if ( !$use_smtp_tls) { |
337 | $use_smtp_tls= 'false'; |
338 | } |
339 | |
340 | if ( !$smtp_auth_mech ) { |
341 | $smtp_auth_mech = 'none'; |
342 | } |
343 | |
344 | if ( !$use_imap_tls ) { |
345 | $use_imap_tls = 'false'; |
346 | } |
347 | |
348 | if ( !$imap_auth_mech ) { |
fe0b18b3 |
349 | $imap_auth_mech = 'login'; |
47a29326 |
350 | } |
351 | |
6c499577 |
352 | if (!$session_name ) { |
353 | $session_name = 'SQMSESSID'; |
354 | } |
355 | |
eaace00e |
356 | if ( $ARGV[0] eq '--install-plugin' ) { |
357 | print "Activating plugin " . $ARGV[1] . "\n"; |
ebd13f55 |
358 | push @plugins, $ARGV[1]; |
359 | save_data(); |
360 | exit(0); |
eaace00e |
361 | } elsif ( $ARGV[0] eq '--remove-plugin' ) { |
362 | print "Removing plugin " . $ARGV[1] . "\n"; |
ebd13f55 |
363 | foreach $plugin (@plugins) { |
eaace00e |
364 | if ( $plugin ne $ARGV[1] ) { |
365 | push @newplugins, $plugin; |
ebd13f55 |
366 | } |
367 | } |
368 | @plugins = @newplugins; |
369 | save_data(); |
370 | exit(0); |
371 | } |
372 | |
5b6ae78a |
373 | ##################################################################################### |
eaace00e |
374 | if ( $config_use_color == 1 ) { |
375 | $WHT = "\x1B[37;1m"; |
376 | $NRM = "\x1B[0m"; |
0ecb47e5 |
377 | } else { |
eaace00e |
378 | $WHT = ""; |
379 | $NRM = ""; |
380 | $config_use_color = 2; |
381 | } |
382 | |
383 | while ( ( $command ne "q" ) && ( $command ne "Q" ) ) { |
384 | system "clear"; |
385 | print $WHT. "SquirrelMail Configuration : " . $NRM; |
386 | if ( $config == 1 ) { print "Read: config.php"; } |
387 | elsif ( $config == 2 ) { print "Read: config_default.php"; } |
388 | print " ($print_config_version)\n"; |
389 | print "---------------------------------------------------------\n"; |
390 | |
391 | if ( $menu == 0 ) { |
392 | print $WHT. "Main Menu --\n" . $NRM; |
393 | print "1. Organization Preferences\n"; |
394 | print "2. Server Settings\n"; |
395 | print "3. Folder Defaults\n"; |
396 | print "4. General Options\n"; |
397 | print "5. Themes\n"; |
398 | print "6. Address Books (LDAP)\n"; |
399 | print "7. Message of the Day (MOTD)\n"; |
400 | print "8. Plugins\n"; |
401 | print "9. Database\n"; |
402 | print "\n"; |
403 | print "D. Set pre-defined settings for specific IMAP servers\n"; |
404 | print "\n"; |
405 | } elsif ( $menu == 1 ) { |
406 | print $WHT. "Organization Preferences\n" . $NRM; |
b6e0c3b6 |
407 | print "1. Organization Name : $WHT$org_name$NRM\n"; |
408 | print "2. Organization Logo : $WHT$org_logo$NRM\n"; |
409 | print "3. Org. Logo Width/Height : $WHT($org_logo_width/$org_logo_height)$NRM\n"; |
410 | print "4. Organization Title : $WHT$org_title$NRM\n"; |
411 | print "5. Signout Page : $WHT$signout_page$NRM\n"; |
412 | print "6. Default Language : $WHT$squirrelmail_default_language$NRM\n"; |
413 | print "7. Top Frame : $WHT$frame_top$NRM\n"; |
0ae4c1f2 |
414 | print "8. Provider link : $WHT$provider_uri$NRM\n"; |
415 | print "9. Provider name : $WHT$provider_name$NRM\n"; |
416 | |
eaace00e |
417 | print "\n"; |
418 | print "R Return to Main Menu\n"; |
419 | } elsif ( $menu == 2 ) { |
47a29326 |
420 | print $WHT. "Server Settings\n\n" . $NRM; |
421 | print $WHT . "General" . $NRM . "\n"; |
422 | print "-------\n"; |
423 | print "1. Domain : $WHT$domain$NRM\n"; |
424 | print "2. Invert Time : $WHT$invert_time$NRM\n"; |
425 | print "3. Sendmail or SMTP : $WHT"; |
eaace00e |
426 | if ( lc($useSendmail) eq "true" ) { |
427 | print "Sendmail"; |
428 | } else { |
429 | print "SMTP"; |
430 | } |
431 | print "$NRM\n"; |
47a29326 |
432 | print "\n"; |
433 | |
434 | if ( $show_imap_settings ) { |
435 | print $WHT . "IMAP Settings". $NRM . "\n--------------\n"; |
436 | print "4. IMAP Server : $WHT$imapServerAddress$NRM\n"; |
437 | print "5. IMAP Port : $WHT$imapPort$NRM\n"; |
438 | print "6. Authentication type : $WHT$imap_auth_mech$NRM\n"; |
439 | print "7. Secure IMAP (TLS) : $WHT$use_imap_tls$NRM\n"; |
440 | print "8. Server software : $WHT$imap_server_type$NRM\n"; |
441 | print "9. Delimiter : $WHT$optional_delimiter$NRM\n"; |
442 | print "\n"; |
443 | } elsif ( $show_smtp_settings ) { |
444 | if ( lc($useSendmail) eq "true" ) { |
445 | print $WHT . "Sendmail" . $NRM . "\n--------\n"; |
446 | print "4. Sendmail Path : $WHT$sendmail_path$NRM\n"; |
447 | print "\n"; |
448 | } else { |
449 | print $WHT . "SMTP Settings" . $NRM . "\n-------------\n"; |
450 | print "4. SMTP Server : $WHT$smtpServerAddress$NRM\n"; |
451 | print "5. SMTP Port : $WHT$smtpPort$NRM\n"; |
452 | print "6. POP before SMTP : $WHT$pop_before_smtp$NRM\n"; |
453 | print "7. SMTP Authentication : $WHT$smtp_auth_mech$NRM\n"; |
454 | print "8. Secure SMTP (TLS) : $WHT$use_smtp_tls$NRM\n"; |
455 | print "\n"; |
456 | } |
eaace00e |
457 | } |
47a29326 |
458 | |
459 | if ($show_imap_settings == 0) { |
460 | print "A. Update IMAP Settings : "; |
461 | print "$WHT$imapServerAddress$NRM:"; |
462 | print "$WHT$imapPort$NRM "; |
463 | print "($WHT$imap_server_type$NRM)\n"; |
464 | } |
465 | if ($show_smtp_settings == 0) { |
466 | if ( lc($useSendmail) eq "true" ) { |
467 | print "B. Change Sendmail Config : $WHT$sendmail_path$NRM\n"; |
468 | } else { |
469 | print "B. Update SMTP Settings : "; |
470 | print "$WHT$smtpServerAddress$NRM:"; |
471 | print "$WHT$smtpPort$NRM\n"; |
472 | } |
473 | } |
474 | if ( $show_smtp_settings || $show_imap_settings ) |
475 | { |
476 | print "H. Hide " . |
477 | ($show_imap_settings ? "IMAP Server" : |
478 | (lc($useSendmail) eq "true") ? "Sendmail" : "SMTP") . " Settings\n"; |
479 | } |
480 | |
eaace00e |
481 | print "\n"; |
482 | print "R Return to Main Menu\n"; |
483 | } elsif ( $menu == 3 ) { |
484 | print $WHT. "Folder Defaults\n" . $NRM; |
485 | print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n"; |
486 | print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n"; |
487 | print "3. Trash Folder : $WHT$trash_folder$NRM\n"; |
488 | print "4. Sent Folder : $WHT$sent_folder$NRM\n"; |
489 | print "5. Drafts Folder : $WHT$draft_folder$NRM\n"; |
490 | print "6. By default, move to trash : $WHT$default_move_to_trash$NRM\n"; |
491 | print "7. By default, move to sent : $WHT$default_move_to_sent$NRM\n"; |
492 | print "8. By default, save as draft : $WHT$default_save_as_draft$NRM\n"; |
493 | print "9. List Special Folders First : $WHT$list_special_folders_first$NRM\n"; |
494 | print "10. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n"; |
495 | print "11. Auto Expunge : $WHT$auto_expunge$NRM\n"; |
496 | print "12. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n"; |
497 | print "13. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n"; |
498 | print "14. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n"; |
499 | print "15. Default Unseen Type : $WHT$default_unseen_type$NRM\n"; |
500 | print "16. Auto Create Special Folders : $WHT$auto_create_special$NRM\n"; |
501 | print "17. Don't move folders into Trash : $WHT$delete_folder$NRM\n"; |
ca85aabe |
502 | print "18. Enable /NoSelect folder fix : $WHT$noselect_fix_enable$NRM\n"; |
eaace00e |
503 | print "\n"; |
504 | print "R Return to Main Menu\n"; |
505 | } elsif ( $menu == 4 ) { |
506 | print $WHT. "General Options\n" . $NRM; |
6c499577 |
507 | print "1. Default Charset : $WHT$default_charset$NRM\n"; |
508 | print "2. Data Directory : $WHT$data_dir$NRM\n"; |
509 | print "3. Attachment Directory : $WHT$attachment_dir$NRM\n"; |
510 | print "4. Directory Hash Level : $WHT$dir_hash_level$NRM\n"; |
511 | print "5. Default Left Size : $WHT$default_left_size$NRM\n"; |
512 | print "6. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n"; |
513 | print "7. Allow use of priority : $WHT$default_use_priority$NRM\n"; |
514 | print "8. Hide SM attributions : $WHT$hide_sm_attributions$NRM\n"; |
515 | print "9. Allow use of receipts : $WHT$default_use_mdn$NRM\n"; |
516 | print "10. Allow editing of identity : $WHT$edit_identity$NRM\n"; |
517 | print "11. Allow server thread sort : $WHT$allow_thread_sort$NRM\n"; |
518 | print "12. Allow server-side sorting : $WHT$allow_server_sort$NRM\n"; |
eaace00e |
519 | if ( lc($edit_identity) eq "false" ) { |
aa0da530 |
520 | print "13. Allow editing of name : $WHT$edit_name$NRM\n"; |
eaace00e |
521 | } |
65ffb3ce |
522 | print "14. Allow server charset search : $WHT$allow_charset_search$NRM\n"; |
6c499577 |
523 | print "15. Enable UID support : $WHT$uid_support$NRM\n"; |
524 | print "16. PHP session name : $WHT$session_name$NRM\n"; |
eaace00e |
525 | print "\n"; |
526 | print "R Return to Main Menu\n"; |
527 | } elsif ( $menu == 5 ) { |
528 | print $WHT. "Themes\n" . $NRM; |
529 | print "1. Change Themes\n"; |
530 | for ( $count = 0 ; $count <= $#theme_name ; $count++ ) { |
531 | print " > $theme_name[$count]\n"; |
532 | } |
533 | print "2. CSS File : $WHT$theme_css$NRM\n"; |
534 | print "\n"; |
535 | print "R Return to Main Menu\n"; |
536 | } elsif ( $menu == 6 ) { |
537 | print $WHT. "Address Books (LDAP)\n" . $NRM; |
538 | print "1. Change Servers\n"; |
539 | for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) { |
540 | print " > $ldap_host[$count]\n"; |
541 | } |
542 | print |
543 | "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n"; |
544 | print "\n"; |
545 | print "R Return to Main Menu\n"; |
546 | } elsif ( $menu == 7 ) { |
547 | print $WHT. "Message of the Day (MOTD)\n" . $NRM; |
548 | print "\n$motd\n"; |
549 | print "\n"; |
550 | print "1 Edit the MOTD\n"; |
551 | print "\n"; |
552 | print "R Return to Main Menu\n"; |
553 | } elsif ( $menu == 8 ) { |
554 | print $WHT. "Plugins\n" . $NRM; |
555 | print " Installed Plugins\n"; |
556 | $num = 0; |
557 | for ( $count = 0 ; $count <= $#plugins ; $count++ ) { |
558 | $num = $count + 1; |
559 | print " $num. $plugins[$count]\n"; |
560 | } |
561 | print "\n Available Plugins:\n"; |
562 | opendir( DIR, "../plugins" ); |
563 | @files = readdir(DIR); |
564 | $pos = 0; |
565 | @unused_plugins = (); |
566 | for ( $i = 0 ; $i <= $#files ; $i++ ) { |
567 | if ( -d "../plugins/" . $files[$i] && $files[$i] !~ /^\./ && $files[$i] ne "CVS" ) { |
568 | $match = 0; |
569 | for ( $k = 0 ; $k <= $#plugins ; $k++ ) { |
570 | if ( $plugins[$k] eq $files[$i] ) { |
571 | $match = 1; |
572 | } |
573 | } |
574 | if ( $match == 0 ) { |
575 | $unused_plugins[$pos] = $files[$i]; |
576 | $pos++; |
577 | } |
1a7a2fcc |
578 | } |
eaace00e |
579 | } |
580 | |
581 | for ( $i = 0 ; $i <= $#unused_plugins ; $i++ ) { |
582 | $num = $num + 1; |
583 | print " $num. $unused_plugins[$i]\n"; |
584 | } |
585 | closedir DIR; |
586 | |
eaace00e |
587 | print "\n"; |
588 | print "R Return to Main Menu\n"; |
589 | } elsif ( $menu == 9 ) { |
590 | print $WHT. "Database\n" . $NRM; |
591 | print "1. DSN for Address Book : $WHT$addrbook_dsn$NRM\n"; |
592 | print "2. Table for Address Book : $WHT$addrbook_table$NRM\n"; |
99a6c222 |
593 | print "\n"; |
eaace00e |
594 | print "3. DSN for Preferences : $WHT$prefs_dsn$NRM\n"; |
595 | print "4. Table for Preferences : $WHT$prefs_table$NRM\n"; |
99a6c222 |
596 | print "5. Field for username : $WHT$prefs_user_field$NRM\n"; |
597 | print "6. Field for prefs key : $WHT$prefs_key_field$NRM\n"; |
598 | print "7. Field for prefs value : $WHT$prefs_val_field$NRM\n"; |
eaace00e |
599 | print "\n"; |
eaace00e |
600 | print "R Return to Main Menu\n"; |
601 | } |
602 | if ( $config_use_color == 1 ) { |
603 | print "C. Turn color off\n"; |
604 | } else { |
605 | print "C. Turn color on\n"; |
606 | } |
607 | print "S Save data\n"; |
608 | print "Q Quit\n"; |
609 | |
610 | print "\n"; |
611 | print "Command >> " . $WHT; |
612 | $command = <STDIN>; |
613 | $command =~ s/[\n|\r]//g; |
614 | $command =~ tr/A-Z/a-z/; |
615 | print "$NRM\n"; |
616 | |
617 | # Read the commands they entered. |
618 | if ( $command eq "r" ) { |
619 | $menu = 0; |
620 | } elsif ( $command eq "s" ) { |
621 | save_data(); |
622 | print "Press enter to continue..."; |
623 | $tmp = <STDIN>; |
624 | $saved = 1; |
625 | } elsif ( ( $command eq "q" ) && ( $saved == 0 ) ) { |
626 | print "You have not saved your data.\n"; |
627 | print "Save? [" . $WHT . "Y" . $NRM . "/n]: "; |
628 | $save = <STDIN>; |
629 | if ( ( $save =~ /^y/i ) || ( $save =~ /^\s*$/ ) ) { |
630 | save_data(); |
631 | } |
632 | } elsif ( $command eq "c" ) { |
633 | if ( $config_use_color == 1 ) { |
634 | $config_use_color = 2; |
635 | $WHT = ""; |
636 | $NRM = ""; |
637 | } else { |
638 | $config_use_color = 1; |
639 | $WHT = "\x1B[37;1m"; |
640 | $NRM = "\x1B[0m"; |
641 | } |
642 | } elsif ( $command eq "d" && $menu == 0 ) { |
643 | set_defaults(); |
644 | } else { |
645 | $saved = 0; |
646 | if ( $menu == 0 ) { |
647 | if ( ( $command > 0 ) && ( $command < 10 ) ) { |
648 | $menu = $command; |
1a7a2fcc |
649 | } |
eaace00e |
650 | } elsif ( $menu == 1 ) { |
651 | if ( $command == 1 ) { $org_name = command1(); } |
652 | elsif ( $command == 2 ) { $org_logo = command2(); } |
b6e0c3b6 |
653 | elsif ( $command == 3 ) { ($org_logo_width,$org_logo_height) = command2a(); } |
654 | elsif ( $command == 4 ) { $org_title = command3(); } |
655 | elsif ( $command == 5 ) { $signout_page = command4(); } |
656 | elsif ( $command == 6 ) { $squirrelmail_default_language = command5(); } |
657 | elsif ( $command == 7 ) { $frame_top = command6(); } |
0ae4c1f2 |
658 | elsif ( $command == 8 ) { $provider_uri = command7(); } |
659 | elsif ( $command == 9 ) { $provider_name = command8(); } |
660 | |
eaace00e |
661 | } elsif ( $menu == 2 ) { |
47a29326 |
662 | if ( $command eq "a" ) { $show_imap_settings = 1; $show_smtp_settings = 0; } |
663 | elsif ( $command eq "b" ) { $show_imap_settings = 0; $show_smtp_settings = 1; } |
664 | elsif ( $command eq "h" ) { $show_imap_settings = 0; $show_smtp_settings = 0; } |
665 | elsif ( $command <= 3 ) { |
666 | if ( $command == 1 ) { $domain = command11(); } |
667 | elsif ( $command == 2 ) { $invert_time = command110(); } |
668 | elsif ( $command == 3 ) { $useSendmail = command14(); } |
669 | $show_imap_settings = 0; $show_smtp_settings = 0; |
670 | } elsif ( $show_imap_settings ) { |
671 | if ( $command == 4 ) { $imapServerAddress = command12(); } |
672 | elsif ( $command == 5 ) { $imapPort = command13(); } |
b47821fb |
673 | elsif ( $command == 6 ) { $imap_auth_mech = command112a(); } |
47a29326 |
674 | elsif ( $command == 7 ) { $use_imap_tls = command113("IMAP",$use_imap_tls); } |
675 | elsif ( $command == 8 ) { $imap_server_type = command19(); } |
676 | elsif ( $command == 9 ) { $optional_delimiter = command111(); } |
677 | } elsif ( $show_smtp_settings && lc($useSendmail) eq "true" ) { |
678 | if ( $command == 4 ) { $sendmail_path = command15(); } |
679 | } elsif ( $show_smtp_settings ) { |
680 | if ( $command == 4 ) { $smtpServerAddress = command16(); } |
681 | elsif ( $command == 5 ) { $smtpPort = command17(); } |
682 | elsif ( $command == 6 ) { $pop_before_smtp = command18a(); } |
b47821fb |
683 | elsif ( $command == 7 ) { $smtp_auth_mech = command112b(); } |
47a29326 |
684 | elsif ( $command == 8 ) { $use_smtp_tls = command113("SMTP",$use_smtp_tls); } |
685 | } |
eaace00e |
686 | } elsif ( $menu == 3 ) { |
687 | if ( $command == 1 ) { $default_folder_prefix = command21(); } |
688 | elsif ( $command == 2 ) { $show_prefix_option = command22(); } |
689 | elsif ( $command == 3 ) { $trash_folder = command23a(); } |
690 | elsif ( $command == 4 ) { $sent_folder = command23b(); } |
691 | elsif ( $command == 5 ) { $draft_folder = command23c(); } |
692 | elsif ( $command == 6 ) { $default_move_to_trash = command24a(); } |
693 | elsif ( $command == 7 ) { $default_move_to_sent = command24b(); } |
694 | elsif ( $command == 8 ) { $default_save_as_draft = command24c(); } |
695 | elsif ( $command == 9 ) { $list_special_folders_first = command27(); } |
696 | elsif ( $command == 10 ) { $use_special_folder_color = command28(); } |
697 | elsif ( $command == 11 ) { $auto_expunge = command29(); } |
698 | elsif ( $command == 12 ) { $default_sub_of_inbox = command210(); } |
699 | elsif ( $command == 13 ) { $show_contain_subfolders_option = command211(); } |
700 | elsif ( $command == 14 ) { $default_unseen_notify = command212(); } |
701 | elsif ( $command == 15 ) { $default_unseen_type = command213(); } |
702 | elsif ( $command == 16 ) { $auto_create_special = command214(); } |
703 | elsif ( $command == 17 ) { $delete_folder = command215(); } |
ca85aabe |
704 | elsif ( $command == 18 ) { $noselect_fix_enable = command216(); } |
eaace00e |
705 | } elsif ( $menu == 4 ) { |
706 | if ( $command == 1 ) { $default_charset = command31(); } |
707 | elsif ( $command == 2 ) { $data_dir = command33a(); } |
708 | elsif ( $command == 3 ) { $attachment_dir = command33b(); } |
709 | elsif ( $command == 4 ) { $dir_hash_level = command33c(); } |
710 | elsif ( $command == 5 ) { $default_left_size = command35(); } |
711 | elsif ( $command == 6 ) { $force_username_lowercase = command36(); } |
712 | elsif ( $command == 7 ) { $default_use_priority = command37(); } |
713 | elsif ( $command == 8 ) { $hide_sm_attributions = command38(); } |
714 | elsif ( $command == 9 ) { $default_use_mdn = command39(); } |
715 | elsif ( $command == 10 ) { $edit_identity = command310(); } |
7c612fdd |
716 | elsif ( $command == 11 ) { $allow_thread_sort = command312(); } |
aa0da530 |
717 | elsif ( $command == 12 ) { $allow_server_sort = command313(); } |
718 | elsif ( $command == 13 ) { $edit_name = command311(); } |
65ffb3ce |
719 | elsif ( $command == 14 ) { $allow_charset_search = command314(); } |
3c7ee482 |
720 | elsif ( $command == 15 ) { $uid_support = command315(); } |
6c499577 |
721 | elsif ( $command == 16 ) { $session_name = command316(); } |
eaace00e |
722 | } elsif ( $menu == 5 ) { |
723 | if ( $command == 1 ) { command41(); } |
724 | elsif ( $command == 2 ) { $theme_css = command42(); } |
725 | } elsif ( $menu == 6 ) { |
726 | if ( $command == 1 ) { command61(); } |
727 | elsif ( $command == 2 ) { command62(); } |
728 | } elsif ( $menu == 7 ) { |
729 | if ( $command == 1 ) { $motd = command71(); } |
730 | } elsif ( $menu == 8 ) { |
731 | if ( $command =~ /^[0-9]+/ ) { @plugins = command81(); } |
eaace00e |
732 | } elsif ( $menu == 9 ) { |
99a6c222 |
733 | if ( $command == 1 ) { $addrbook_dsn = command91(); } |
734 | elsif ( $command == 2 ) { $addrbook_table = command92(); } |
735 | elsif ( $command == 3 ) { $prefs_dsn = command93(); } |
736 | elsif ( $command == 4 ) { $prefs_table = command94(); } |
737 | elsif ( $command == 5 ) { $prefs_user_field = command95(); } |
738 | elsif ( $command == 6 ) { $prefs_key_field = command96(); } |
739 | elsif ( $command == 7 ) { $prefs_val_field = command97(); } |
eaace00e |
740 | } |
741 | } |
828b4753 |
742 | } |
743 | |
744 | #################################################################################### |
745 | |
5b6ae78a |
746 | # org_name |
747 | sub command1 { |
eaace00e |
748 | print "We have tried to make the name SquirrelMail as transparent as\n"; |
749 | print "possible. If you set up an organization name, most places where\n"; |
750 | print "SquirrelMail would take credit will be credited to your organization.\n"; |
751 | print "\n"; |
360ef370 |
752 | print "If your Organization Name includes a '\$', please precede it with a \\. \n"; |
753 | print "Other '\$' will be considered the beginning of a variable that\n"; |
754 | print "must be defined before the \$org_name is printed.\n"; |
755 | print "\$version, for example, is included by default, and will print the\n"; |
756 | print "string representing the current SquirrelMail version.\n"; |
757 | print "\n"; |
eaace00e |
758 | print "[$WHT$org_name$NRM]: $WHT"; |
759 | $new_org_name = <STDIN>; |
760 | if ( $new_org_name eq "\n" ) { |
761 | $new_org_name = $org_name; |
762 | } else { |
763 | $new_org_name =~ s/[\r|\n]//g; |
d756b071 |
764 | $new_org_name =~ s/\"/"/g; |
eaace00e |
765 | } |
766 | return $new_org_name; |
5b6ae78a |
767 | } |
768 | |
769 | # org_logo |
770 | sub command2 { |
eaace00e |
771 | print "Your organization's logo is an image that will be displayed at\n"; |
772 | print "different times throughout SquirrelMail. This is asking for the\n"; |
27921903 |
773 | print "literal (/usr/local/squirrelmail/images/logo.png) or relative\n"; |
e6566358 |
774 | print "(../images/logo.png) path from the config directory to your logo.\n"; |
8bd9e0dd |
775 | print "Relative paths to files outside the SquirrelMail distribution\n"; |
776 | print "will be converted to their absolute path equivalents in config.php.\n"; |
eaace00e |
777 | print "\n"; |
778 | print "[$WHT$org_logo$NRM]: $WHT"; |
779 | $new_org_logo = <STDIN>; |
780 | if ( $new_org_logo eq "\n" ) { |
781 | $new_org_logo = $org_logo; |
782 | } else { |
783 | $new_org_logo =~ s/[\r|\n]//g; |
784 | } |
785 | return $new_org_logo; |
5b6ae78a |
786 | } |
787 | |
b6e0c3b6 |
788 | # org_logo_width |
789 | sub command2a { |
790 | print "Your organization's logo is an image that will be displayed at\n"; |
791 | print "different times throughout SquirrelMail. Width\n"; |
792 | print "and Height of your logo image. Use '0' to disable.\n"; |
793 | print "\n"; |
794 | print "Width: [$WHT$org_logo_width$NRM]: $WHT"; |
795 | $new_org_logo_width = <STDIN>; |
796 | $new_org_logo_width =~ tr/0-9//cd; # only want digits! |
797 | if ( $new_org_logo_width eq '' ) { |
798 | $new_org_logo_width = $org_logo_width; |
799 | } |
0e21688d |
800 | if ( $new_org_logo_width > 0 ) { |
801 | print "Height: [$WHT$org_logo_height$NRM]: $WHT"; |
802 | $new_org_logo_height = <STDIN>; |
803 | $new_org_logo_height =~ tr/0-9//cd; # only want digits! |
e03345e1 |
804 | if( $new_org_logo_height eq '' ) { |
805 | $new_org_logo_height = $org_logo_height; |
806 | } |
00c4b08d |
807 | } else { |
0e21688d |
808 | $new_org_logo_height = 0; |
b6e0c3b6 |
809 | } |
810 | return ($new_org_logo_width, $new_org_logo_height); |
811 | } |
812 | |
5b6ae78a |
813 | # org_title |
814 | sub command3 { |
eaace00e |
815 | print "A title is what is displayed at the top of the browser window in\n"; |
816 | print "the titlebar. Usually this will end up looking something like:\n"; |
817 | print "\"Netscape: $org_title\"\n"; |
818 | print "\n"; |
360ef370 |
819 | print "If your Organization Title includes a '\$', please precede it with a \\. \n"; |
820 | print "Other '\$' will be considered the beginning of a variable that\n"; |
821 | print "must be defined before the \$org_title is printed.\n"; |
822 | print "\$version, for example, is included by default, and will print the\n"; |
823 | print "string representing the current SquirrelMail version.\n"; |
824 | print "\n"; |
eaace00e |
825 | print "[$WHT$org_title$NRM]: $WHT"; |
826 | $new_org_title = <STDIN>; |
827 | if ( $new_org_title eq "\n" ) { |
828 | $new_org_title = $org_title; |
829 | } else { |
830 | $new_org_title =~ s/[\r|\n]//g; |
d756b071 |
831 | $new_org_title =~ s/\"/\'/g; |
eaace00e |
832 | } |
833 | return $new_org_title; |
5b6ae78a |
834 | } |
5b6ae78a |
835 | |
f923b93d |
836 | # signout_page |
837 | sub command4 { |
eaace00e |
838 | print "When users click the Sign Out button they will be logged out and\n"; |
839 | print "then sent to signout_page. If signout_page is left empty,\n"; |
840 | print "(hit space and then return) they will be taken, as normal,\n"; |
841 | print "to the default and rather sparse SquirrelMail signout page.\n"; |
842 | print "\n"; |
843 | print "[$WHT$signout_page$NRM]: $WHT"; |
844 | $new_signout_page = <STDIN>; |
845 | if ( $new_signout_page eq "\n" ) { |
846 | $new_signout_page = $signout_page; |
847 | } else { |
848 | $new_signout_page =~ s/[\r|\n]//g; |
849 | $new_signout_page =~ s/^\s+$//g; |
850 | } |
851 | return $new_signout_page; |
6ef7145f |
852 | } |
853 | |
854 | # Default language |
855 | sub command5 { |
eaace00e |
856 | print "SquirrelMail attempts to set the language in many ways. If it\n"; |
857 | print "can not figure it out in another way, it will default to this\n"; |
e1e4f932 |
858 | print "language. Please use the code for the desired language.\n"; |
eaace00e |
859 | print "\n"; |
860 | print "[$WHT$squirrelmail_default_language$NRM]: $WHT"; |
861 | $new_signout_page = <STDIN>; |
862 | if ( $new_signout_page eq "\n" ) { |
863 | $new_signout_page = $squirrelmail_default_language; |
864 | } else { |
865 | $new_signout_page =~ s/[\r|\n]//g; |
866 | $new_signout_page =~ s/^\s+$//g; |
867 | } |
868 | return $new_signout_page; |
f923b93d |
869 | } |
870 | |
80e86e94 |
871 | # Default top frame |
872 | sub command6 { |
873 | print "SquirrelMail defaults to using the whole of the browser window.\n"; |
874 | print "This allows you to keep it within a specified frame. The default\n"; |
875 | print "is '_top'\n"; |
876 | print "\n"; |
877 | print "[$WHT$frame_top$NRM]: $WHT"; |
878 | $new_frame_top = <STDIN>; |
eaace00e |
879 | if ( $new_frame_top eq "\n" ) { |
80e86e94 |
880 | $new_frame_top = '_top'; |
881 | } else { |
882 | $new_frame_top =~ s/[\r|\n]//g; |
883 | $new_frame_top =~ s/^\s+$//g; |
884 | } |
885 | return $new_frame_top; |
886 | } |
887 | |
0ae4c1f2 |
888 | # Default link to provider |
889 | sub command7 { |
890 | print "Here you can set the link on the right of the page.\n"; |
891 | print "The default is 'http://www.squirrelmail.org/'\n"; |
892 | print "\n"; |
893 | print "[$WHT$provider_uri$NRM]: $WHT"; |
894 | $new_provider_uri = <STDIN>; |
895 | if ( $new_provider_uri eq "\n" ) { |
896 | $new_provider_uri = 'http://www.squirrelmail.org/'; |
897 | } else { |
898 | $new_provider_uri =~ s/[\r|\n]//g; |
899 | $new_provider_uri =~ s/^\s+$//g; |
900 | } |
7b6563c0 |
901 | return $new_provider_uri; |
0ae4c1f2 |
902 | } |
903 | |
904 | sub command8 { |
905 | print "Here you can set the name of the link on the right of the page.\n"; |
906 | print "The default is 'SquirrelMail/'\n"; |
907 | print "\n"; |
908 | print "[$WHT$provider_name$NRM]: $WHT"; |
909 | $new_provider_name = <STDIN>; |
910 | if ( $new_provider_name eq "\n" ) { |
911 | $new_provider_name = 'SquirrelMail'; |
912 | } else { |
913 | $new_provider_name =~ s/[\r|\n]//g; |
914 | $new_provider_name =~ s/^\s+$//g; |
915 | } |
7b6563c0 |
916 | return $new_provider_name; |
0ae4c1f2 |
917 | } |
918 | |
828b4753 |
919 | #################################################################################### |
5b6ae78a |
920 | |
828b4753 |
921 | # domain |
922 | sub command11 { |
e1e4f932 |
923 | print "The domain name is the suffix at the end of all email addresses. If\n"; |
eaace00e |
924 | print "for example, your email address is jdoe\@myorg.com, then your domain\n"; |
925 | print "would be myorg.com.\n"; |
926 | print "\n"; |
927 | print "[$WHT$domain$NRM]: $WHT"; |
928 | $new_domain = <STDIN>; |
929 | if ( $new_domain eq "\n" ) { |
930 | $new_domain = $domain; |
931 | } else { |
932 | $new_domain =~ s/[\r|\n]//g; |
933 | } |
934 | return $new_domain; |
828b4753 |
935 | } |
5b6ae78a |
936 | |
828b4753 |
937 | # imapServerAddress |
938 | sub command12 { |
47a29326 |
939 | print "This is the hostname where your IMAP server can be contacted.\n"; |
eaace00e |
940 | print "[$WHT$imapServerAddress$NRM]: $WHT"; |
941 | $new_imapServerAddress = <STDIN>; |
942 | if ( $new_imapServerAddress eq "\n" ) { |
943 | $new_imapServerAddress = $imapServerAddress; |
944 | } else { |
945 | $new_imapServerAddress =~ s/[\r|\n]//g; |
946 | } |
947 | return $new_imapServerAddress; |
828b4753 |
948 | } |
5b6ae78a |
949 | |
828b4753 |
950 | # imapPort |
951 | sub command13 { |
eaace00e |
952 | print "This is the port that your IMAP server is on. Usually this is 143.\n"; |
953 | print "[$WHT$imapPort$NRM]: $WHT"; |
954 | $new_imapPort = <STDIN>; |
955 | if ( $new_imapPort eq "\n" ) { |
956 | $new_imapPort = $imapPort; |
957 | } else { |
958 | $new_imapPort =~ s/[\r|\n]//g; |
959 | } |
960 | return $new_imapPort; |
828b4753 |
961 | } |
962 | |
963 | # useSendmail |
964 | sub command14 { |
eaace00e |
965 | print "You now need to choose the method that you will use for sending\n"; |
966 | print "messages in SquirrelMail. You can either connect to an SMTP server\n"; |
967 | print "or use sendmail directly.\n"; |
968 | if ( lc($useSendmail) eq "true" ) { |
969 | $default_value = "1"; |
970 | } else { |
971 | $default_value = "2"; |
972 | } |
973 | print "\n"; |
974 | print " 1. Sendmail\n"; |
975 | print " 2. SMTP\n"; |
976 | print "Your choice [1/2] [$WHT$default_value$NRM]: $WHT"; |
977 | $use_sendmail = <STDIN>; |
978 | if ( ( $use_sendmail =~ /^1\n/i ) |
979 | || ( ( $use_sendmail =~ /^\n/ ) && ( $default_value eq "1" ) ) ) { |
980 | $useSendmail = "true"; |
981 | } else { |
982 | $useSendmail = "false"; |
983 | } |
984 | return $useSendmail; |
828b4753 |
985 | } |
5b6ae78a |
986 | |
828b4753 |
987 | # sendmail_path |
988 | sub command15 { |
eaace00e |
989 | if ( $sendmail_path[0] !~ /./ ) { |
990 | $sendmail_path = "/usr/sbin/sendmail"; |
991 | } |
992 | print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n"; |
993 | print "[$WHT$sendmail_path$NRM]: $WHT"; |
994 | $new_sendmail_path = <STDIN>; |
995 | if ( $new_sendmail_path eq "\n" ) { |
996 | $new_sendmail_path = $sendmail_path; |
997 | } else { |
998 | $new_sendmail_path =~ s/[\r|\n]//g; |
999 | } |
1000 | return $new_sendmail_path; |
828b4753 |
1001 | } |
5b6ae78a |
1002 | |
828b4753 |
1003 | # smtpServerAddress |
1004 | sub command16 { |
47a29326 |
1005 | print "This is the hostname of your SMTP server.\n"; |
eaace00e |
1006 | print "[$WHT$smtpServerAddress$NRM]: $WHT"; |
1007 | $new_smtpServerAddress = <STDIN>; |
1008 | if ( $new_smtpServerAddress eq "\n" ) { |
1009 | $new_smtpServerAddress = $smtpServerAddress; |
1010 | } else { |
1011 | $new_smtpServerAddress =~ s/[\r|\n]//g; |
1012 | } |
1013 | return $new_smtpServerAddress; |
828b4753 |
1014 | } |
1015 | |
1016 | # smtpPort |
1017 | sub command17 { |
eaace00e |
1018 | print "This is the port to connect to for SMTP. Usually 25.\n"; |
1019 | print "[$WHT$smtpPort$NRM]: $WHT"; |
1020 | $new_smtpPort = <STDIN>; |
1021 | if ( $new_smtpPort eq "\n" ) { |
1022 | $new_smtpPort = $smtpPort; |
1023 | } else { |
1024 | $new_smtpPort =~ s/[\r|\n]//g; |
1025 | } |
1026 | return $new_smtpPort; |
bbd30ac8 |
1027 | } |
d2f4c914 |
1028 | |
1029 | # authenticated server |
a93b12ba |
1030 | sub command18 { |
47a29326 |
1031 | return; |
1032 | # This sub disabled by tassium - it has been replaced with smtp_auth_mech |
eaace00e |
1033 | print "Do you wish to use an authenticated SMTP server? Your server must\n"; |
1034 | print "support this in order for SquirrelMail to work with it. We implemented\n"; |
1035 | print "it according to RFC 2554.\n"; |
1036 | |
1037 | $YesNo = 'n'; |
1038 | $YesNo = 'y' if ( lc($use_authenticated_smtp) eq "true" ); |
1039 | |
1040 | print "Use authenticated SMTP server (y/n) [$WHT$YesNo$NRM]: $WHT"; |
1041 | |
1042 | $new_use_authenticated_smtp = <STDIN>; |
1043 | $new_use_authenticated_smtp =~ tr/yn//cd; |
1044 | return "true" if ( $new_use_authenticated_smtp eq "y" ); |
1045 | return "false" if ( $new_use_authenticated_smtp eq "n" ); |
1046 | return $use_authenticated_smtp; |
1047 | } |
d2f4c914 |
1048 | |
2044f95a |
1049 | # pop before SMTP |
1050 | sub command18a { |
1051 | print "Do you wish to use POP3 before SMTP? Your server must\n"; |
1052 | print "support this in order for SquirrelMail to work with it.\n"; |
1053 | |
1054 | $YesNo = 'n'; |
1055 | $YesNo = 'y' if ( lc($pop_before_smtp) eq "true" ); |
1056 | |
1057 | print "Use pop before SMTP (y/n) [$WHT$YesNo$NRM]: $WHT"; |
1058 | |
1059 | $new_pop_before_smtp = <STDIN>; |
1060 | $new_pop_before_smtp =~ tr/yn//cd; |
1061 | return "true" if ( $new_pop_before_smtp eq "y" ); |
1062 | return "false" if ( $new_pop_before_smtp eq "n" ); |
1063 | return $pop_before_smtp; |
1064 | } |
1065 | |
d2f4c914 |
1066 | # imap_server_type |
1067 | sub command19 { |
eaace00e |
1068 | print "Each IMAP server has its own quirks. As much as we tried to stick\n"; |
1069 | print "to standards, it doesn't help much if the IMAP server doesn't follow\n"; |
1070 | print "the same principles. We have made some work-arounds for some of\n"; |
1071 | print "these servers. If you would like to use them, please select your\n"; |
1072 | print "IMAP server. If you do not wish to use these work-arounds, you can\n"; |
1073 | print "set this to \"other\", and none will be used.\n"; |
1074 | print " cyrus = Cyrus IMAP server\n"; |
1075 | print " uw = University of Washington's IMAP server\n"; |
1076 | print " exchange = Microsoft Exchange IMAP server\n"; |
1077 | print " courier = Courier IMAP server\n"; |
d50e52d1 |
1078 | print " macosx = Mac OS X Mailserver\n"; |
eaace00e |
1079 | print " other = Not one of the above servers\n"; |
1080 | print "[$WHT$imap_server_type$NRM]: $WHT"; |
1081 | $new_imap_server_type = <STDIN>; |
1082 | |
1083 | if ( $new_imap_server_type eq "\n" ) { |
1084 | $new_imap_server_type = $imap_server_type; |
1085 | } else { |
1086 | $new_imap_server_type =~ s/[\r|\n]//g; |
1087 | } |
1088 | return $new_imap_server_type; |
a93b12ba |
1089 | } |
3f8fe68e |
1090 | |
d47b2518 |
1091 | # invert_time |
d2f4c914 |
1092 | sub command110 { |
eaace00e |
1093 | print "Sometimes the date of messages sent is messed up (off by a few hours\n"; |
1094 | print "on some machines). Typically this happens if the system doesn't support\n"; |
1095 | print "tm_gmtoff. It will happen only if your time zone is \"negative\".\n"; |
1096 | print "This most often occurs on Solaris 7 machines in the United States.\n"; |
1097 | print "By default, this is off. It should be kept off unless problems surface\n"; |
1098 | print "about the time that messages are sent.\n"; |
1099 | print " no = Do NOT fix time -- almost always correct\n"; |
1100 | print " yes = Fix the time for this system\n"; |
1101 | |
1102 | $YesNo = 'n'; |
1103 | $YesNo = 'y' if ( lc($invert_time) eq "true" ); |
1104 | |
1105 | print "Fix the time for this system (y/n) [$WHT$YesNo$NRM]: $WHT"; |
1106 | |
1107 | $new_invert_time = <STDIN>; |
1108 | $new_invert_time =~ tr/yn//cd; |
1109 | return "true" if ( $new_invert_time eq "y" ); |
1110 | return "false" if ( $new_invert_time eq "n" ); |
1111 | return $invert_time; |
1112 | } |
d47b2518 |
1113 | |
d2f4c914 |
1114 | sub command111 { |
eaace00e |
1115 | print "This is the delimiter that your IMAP server uses to distinguish between\n"; |
1116 | print "folders. For example, Cyrus uses '.' as the delimiter and a complete\n"; |
1117 | print "folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would\n"; |
1118 | print "look like 'INBOX/Friends/Bob'. Normally this should be left at 'detect'\n"; |
1119 | print "but if you are sure you know what delimiter your server uses, you can\n"; |
1120 | print "specify it here.\n"; |
1121 | print "\nTo have it autodetect the delimiter, set it to 'detect'.\n\n"; |
1122 | print "[$WHT$optional_delimiter$NRM]: $WHT"; |
1123 | $new_optional_delimiter = <STDIN>; |
1124 | |
1125 | if ( $new_optional_delimiter eq "\n" ) { |
1126 | $new_optional_delimiter = $optional_delimiter; |
1127 | } else { |
1128 | $new_optional_delimiter =~ s/[\r|\n]//g; |
1129 | } |
1130 | return $new_optional_delimiter; |
40ba4d36 |
1131 | } |
b47821fb |
1132 | # IMAP authentication type |
fe0b18b3 |
1133 | # Possible values: login, cram-md5, digest-md5 |
b47821fb |
1134 | # Now offers to detect supported mechs, assuming server & port are set correctly |
1135 | |
1136 | sub command112a { |
1137 | print "If you have already set the hostname and port number, I can try to\n"; |
1c6d997a |
1138 | print "detect the mechanisms your IMAP server supports.\n"; |
b47821fb |
1139 | print "I will try to detect CRAM-MD5 and DIGEST-MD5 support. I can't test\n"; |
fe0b18b3 |
1140 | print "for \"login\" without knowing a username and password.\n"; |
1c6d997a |
1141 | print "Auto-detecting is optional - you can safely say \"n\" here.\n"; |
1142 | print "\nTry to detect supported mechanisms? [y/N]: "; |
b47821fb |
1143 | $inval=<STDIN>; |
1144 | chomp($inval); |
1145 | if ($inval =~ /^y\b/i) { |
1146 | # Yes, let's try to detect. |
1147 | print "Trying to detect IMAP capabilities...\n"; |
1148 | my $host = $imapServerAddress . ':'. $imapPort; |
1149 | print "CRAM-MD5:\t"; |
1150 | my $tmp = detect_auth_support('IMAP',$host,'CRAM-MD5'); |
1151 | if (defined($tmp)) { |
1152 | if ($tmp eq 'YES') { |
1153 | print "$WHT SUPPORTED$NRM\n"; |
1154 | } else { |
1155 | print "$WHT NOT SUPPORTED$NRM\n"; |
1156 | } |
1157 | } else { |
1158 | print $WHT . " ERROR DETECTING$NRM\n"; |
1159 | } |
1160 | |
1161 | print "DIGEST-MD5:\t"; |
1162 | $tmp = detect_auth_support('IMAP',$host,'DIGEST-MD5'); |
1163 | if (defined($tmp)) { |
1164 | if ($tmp eq 'YES') { |
1165 | print "$WHT SUPPORTED$NRM\n"; |
1166 | } else { |
1167 | print "$WHT NOT SUPPORTED$NRM\n"; |
1168 | } |
1169 | } else { |
1170 | print $WHT . " ERROR DETECTING$NRM\n"; |
1171 | } |
1172 | |
1173 | } |
1174 | print "\nWhat authentication mechanism do you want to use for IMAP connections?\n\n"; |
fe0b18b3 |
1175 | print $WHT . "login" . $NRM . " - Plaintext. If you can do better, you probably should.\n"; |
1176 | print $WHT . "cram-md5" . $NRM . " - Slightly better than plaintext methods.\n"; |
639c7164 |
1177 | print $WHT . "digest-md5" . $NRM . " - Privacy protection - better than cram-md5.\n"; |
b47821fb |
1178 | print "\n*** YOUR IMAP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***\n"; |
fe0b18b3 |
1179 | print "If you don't understand or are unsure, you probably want \"login\"\n\n"; |
1180 | print "login, cram-md5, or digest-md5 [$WHT$imap_auth_mech$NRM]: $WHT"; |
b47821fb |
1181 | $inval=<STDIN>; |
1182 | chomp($inval); |
fe0b18b3 |
1183 | if ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) || ($inval =~ /^login\b/i)) { |
b47821fb |
1184 | return lc($inval); |
1185 | } else { |
1186 | # user entered garbage or default value so nothing needs to be set |
1187 | return $imap_auth_mech; |
1188 | } |
1189 | } |
40ba4d36 |
1190 | |
b47821fb |
1191 | |
1192 | # SMTP authentication type |
1193 | # Possible choices: none, plain, cram-md5, digest-md5 |
1194 | sub command112b { |
1195 | print "If you have already set the hostname and port number, I can try to\n"; |
1c6d997a |
1196 | print "automatically detect the mechanisms your SMTP server supports.\n"; |
1197 | print "Auto-detection is *optional* - you can safely say \"n\" here.\n"; |
1198 | print "\nTry to detect auth mechanisms? [y/N]: "; |
b47821fb |
1199 | $inval=<STDIN>; |
1200 | chomp($inval); |
1201 | if ($inval =~ /^y\b/i) { |
1202 | # Yes, let's try to detect. |
1c6d997a |
1203 | print "Trying to detect supported methods (SMTP)...\n"; |
b47821fb |
1204 | |
1205 | # Special case! |
fe0b18b3 |
1206 | # Check none by trying to relay to junk@microsoft.com |
b47821fb |
1207 | $host = $smtpServerAddress . ':' . $smtpPort; |
1208 | use IO::Socket; |
1209 | my $sock = IO::Socket::INET->new($host); |
1210 | print "Testing none:\t\t$WHT"; |
1211 | if (!defined($sock)) { |
1212 | print " ERROR TESTING\n"; |
1213 | close $sock; |
1214 | } else { |
1215 | print $sock "mail from: tester\@squirrelmail.org\n"; |
1216 | $got = <$sock>; # Discard |
fe0b18b3 |
1217 | print $sock "rcpt to: junk\@microsoft.com\n"; |
b47821fb |
1218 | $got = <$sock>; # This is the important line |
1219 | if ($got =~ /^250\b/) { # SMTP will relay without auth |
1220 | print "SUPPORTED$NRM\n"; |
1221 | } else { |
1222 | print "NOT SUPPORTED$NRM\n"; |
1223 | } |
1224 | print $sock "rset\n"; |
1225 | print $sock "quit\n"; |
1226 | close $sock; |
1227 | } |
fe0b18b3 |
1228 | # Try login (SquirrelMail default) |
1229 | print "Testing login:\t\t"; |
b47821fb |
1230 | $tmp=detect_auth_support('SMTP',$host,'LOGIN'); |
1231 | if (defined($tmp)) { |
1232 | if ($tmp eq 'YES') { |
1233 | print $WHT . "SUPPORTED$NRM\n"; |
1234 | } else { |
1235 | print $WHT . "NOT SUPPORTED$NRM\n"; |
1236 | } |
1237 | } else { |
1238 | print $WHT . "ERROR DETECTING$NRM\n"; |
1239 | } |
1240 | |
1241 | # Try CRAM-MD5 |
1242 | print "Testing CRAM-MD5:\t"; |
1243 | $tmp=detect_auth_support('SMTP',$host,'CRAM-MD5'); |
1244 | if (defined($tmp)) { |
1245 | if ($tmp eq 'YES') { |
1246 | print $WHT . "SUPPORTED$NRM\n"; |
1247 | } else { |
1248 | print $WHT . "NOT SUPPORTED$NRM\n"; |
1249 | } |
1250 | } else { |
1251 | print $WHT . "ERROR DETECTING$NRM\n"; |
1252 | } |
1253 | |
1254 | |
1255 | print "Testing DIGEST-MD5:\t"; |
1256 | $tmp=detect_auth_support('SMTP',$host,'DIGEST-MD5'); |
1257 | if (defined($tmp)) { |
1258 | if ($tmp eq 'YES') { |
1259 | print $WHT . "SUPPORTED$NRM\n"; |
1260 | } else { |
1261 | print $WHT . "NOT SUPPORTED$NRM\n"; |
1262 | } |
1263 | } else { |
1264 | print $WHT . "ERROR DETECTING$NRM\n"; |
1265 | } |
1266 | } |
1267 | print "\tWhat authentication mechanism do you want to use for SMTP connections?\n"; |
1268 | print $WHT . "none" . $NRM . " - Your SMTP server does not require authorization.\n"; |
fe0b18b3 |
1269 | print $WHT . "login" . $NRM . " - Plaintext. If you can do better, you probably should.\n"; |
639c7164 |
1270 | print $WHT . "cram-md5" . $NRM . " - Slightly better than plaintext.\n"; |
1271 | print $WHT . "digest-md5" . $NRM . " - Privacy protection - better than cram-md5.\n"; |
fe0b18b3 |
1272 | print $WHT . "\n*** YOUR SMTP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***\n" . $NRM; |
b47821fb |
1273 | print "If you don't understand or are unsure, you probably want \"none\"\n\n"; |
fe0b18b3 |
1274 | print "none, login, cram-md5, or digest-md5 [$WHT$smtp_auth_mech$NRM]: $WHT"; |
47a29326 |
1275 | $inval=<STDIN>; |
1276 | chomp($inval); |
b47821fb |
1277 | if ($inval =~ /^none\b/i) { |
47a29326 |
1278 | # SMTP doesn't necessarily require logins |
1279 | return "none"; |
1280 | } |
1281 | if ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) || |
fe0b18b3 |
1282 | ($inval =~ /^login\b/i)) { |
47a29326 |
1283 | return lc($inval); |
1284 | } else { |
b47821fb |
1285 | # user entered garbage, or default value so nothing needs to be set |
1c6d997a |
1286 | return $smtp_auth_mech; |
47a29326 |
1287 | } |
1288 | } |
1289 | |
1290 | # TLS |
1291 | # This sub is reused for IMAP and SMTP |
1292 | # Args: service name, default value |
1293 | sub command113 { |
1294 | my($default_val,$service,$inval); |
1295 | $service=$_[0]; |
1296 | $default_val=$_[1]; |
1297 | print "TLS (Transport Layer Security) encrypts the traffic between server and client.\n"; |
1298 | print "If you're familiar with SSL, you get the idea.\n"; |
1299 | print "To use this feature, your " . $service . " server must offer TLS\n"; |
1300 | print "capability, plus PHP 4.3.x with OpenSSL support.\n"; |
1301 | print "\nIf your " . $service . " server is localhost, you can safely disable this.\n"; |
1302 | print "If it is remote, you may wish to seriously consider enabling this.\n"; |
1303 | print "Enable TLS (y/n) [$WHT"; |
1304 | if ($default_val eq "true") { |
1305 | print "y"; |
1306 | } else { |
1307 | print "n"; |
1308 | } |
1309 | print "$NRM]: $WHT"; |
1310 | $inval=<STDIN>; |
1311 | $inval =~ tr/yn//cd; |
1312 | return "true" if ( $inval eq "y" ); |
1313 | return "false" if ( $inval eq "n" ); |
1314 | return $default_val; |
1315 | |
1316 | |
1317 | } |
1318 | |
1319 | |
3f8fe68e |
1320 | # MOTD |
1321 | sub command71 { |
eaace00e |
1322 | print "\nYou can now create the welcome message that is displayed\n"; |
1323 | print "every time a user logs on. You can use HTML or just plain\n"; |
1324 | print |
1325 | "text. If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n"; |
1326 | |
1327 | $new_motd = ""; |
1328 | do { |
1329 | print "] "; |
1330 | $line = <STDIN>; |
1331 | $line =~ s/[\r|\n]//g; |
1332 | if ( $line ne "@" ) { |
1333 | $line =~ s/ /\ \ /g; |
1334 | $line =~ s/\t/\ \ \ \ /g; |
1335 | $line =~ s/$/ /; |
d756b071 |
1336 | $line =~ s/\"/"/g; |
eaace00e |
1337 | |
1338 | $new_motd = $new_motd . $line; |
1339 | } |
1340 | } while ( $line ne "@" ); |
1341 | return $new_motd; |
3f8fe68e |
1342 | } |
911ad01c |
1343 | |
9d0c7bee |
1344 | ################# PLUGINS ################### |
1345 | |
1346 | sub command81 { |
eaace00e |
1347 | $command =~ s/[\s|\n|\r]*//g; |
1348 | if ( $command > 0 ) { |
1349 | $command = $command - 1; |
1350 | if ( $command <= $#plugins ) { |
1351 | @newplugins = (); |
1352 | $ct = 0; |
1353 | while ( $ct <= $#plugins ) { |
1354 | if ( $ct != $command ) { |
1355 | @newplugins = ( @newplugins, $plugins[$ct] ); |
1356 | } |
1357 | $ct++; |
9d0c7bee |
1358 | } |
eaace00e |
1359 | @plugins = @newplugins; |
1360 | } elsif ( $command <= $#plugins + $#unused_plugins + 1 ) { |
1361 | $num = $command - $#plugins - 1; |
1362 | @newplugins = @plugins; |
1363 | $ct = 0; |
1364 | while ( $ct <= $#unused_plugins ) { |
1365 | if ( $ct == $num ) { |
1366 | @newplugins = ( @newplugins, $unused_plugins[$ct] ); |
eaace00e |
1367 | } |
1368 | $ct++; |
9d0c7bee |
1369 | } |
eaace00e |
1370 | @plugins = @newplugins; |
1371 | } |
1372 | } |
1373 | return @plugins; |
1374 | } |
9d0c7bee |
1375 | |
911ad01c |
1376 | ################# FOLDERS ################### |
1377 | |
1378 | # default_folder_prefix |
1379 | sub command21 { |
eaace00e |
1380 | print "Some IMAP servers (UW, for example) store mail and folders in\n"; |
1381 | print "your user space in a separate subdirectory. This is where you\n"; |
1382 | print "specify what that directory is.\n"; |
1383 | print "\n"; |
1384 | print "EXAMPLE: mail/"; |
1385 | print "\n"; |
1386 | print "NOTE: If you use Cyrus, or some server that would not use this\n"; |
1387 | print " option, you must set this to 'none'.\n"; |
1388 | print "\n"; |
1389 | print "[$WHT$default_folder_prefix$NRM]: $WHT"; |
1390 | $new_default_folder_prefix = <STDIN>; |
1391 | |
1392 | if ( $new_default_folder_prefix eq "\n" ) { |
1393 | $new_default_folder_prefix = $default_folder_prefix; |
1394 | } else { |
d52532d5 |
1395 | $new_default_folder_prefix =~ s/[\r\n]//g; |
eaace00e |
1396 | } |
d52532d5 |
1397 | if ( ( $new_default_folder_prefix =~ /^\s*$/ ) || ( $new_default_folder_prefix =~ m/^none$/i ) ) { |
eaace00e |
1398 | $new_default_folder_prefix = ""; |
1399 | } else { |
d52532d5 |
1400 | # add the trailing delimiter only if we know what the server is. |
ce9f808b |
1401 | if (($imap_server_type eq 'cyrus' and |
1402 | $optional_delimiter eq 'detect') or |
1403 | ($imap_server_type eq 'courier' and |
1404 | $optional_delimiter eq 'detect')) { |
d52532d5 |
1405 | $new_default_folder_prefix =~ s/\.*$/\./; |
ce9f808b |
1406 | } elsif ($imap_server_type eq 'uw' and |
1407 | $optional_delimiter eq 'detect') { |
d52532d5 |
1408 | $new_default_folder_prefix =~ s/\/*$/\//; |
0e21688d |
1409 | } |
eaace00e |
1410 | } |
1411 | return $new_default_folder_prefix; |
911ad01c |
1412 | } |
1413 | |
1414 | # Show Folder Prefix |
1415 | sub command22 { |
eaace00e |
1416 | print "It is possible to set up the default folder prefix as a user\n"; |
1417 | print "specific option, where each user can specify what their mail\n"; |
1418 | print "folder is. If you set this to false, they will never see the\n"; |
1419 | print "option, but if it is true, this option will appear in the\n"; |
1420 | print "'options' section.\n"; |
1421 | print "\n"; |
1422 | print "NOTE: You set the default folder prefix in option '1' of this\n"; |
1423 | print " section. That will be the default if the user doesn't\n"; |
1424 | print " specify anything different.\n"; |
1425 | print "\n"; |
1426 | |
1427 | if ( lc($show_prefix_option) eq "true" ) { |
1428 | $default_value = "y"; |
1429 | } else { |
1430 | $default_value = "n"; |
1431 | } |
1432 | print "\n"; |
1433 | print "Show option (y/n) [$WHT$default_value$NRM]: $WHT"; |
1434 | $new_show = <STDIN>; |
1435 | if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
1436 | $show_prefix_option = "true"; |
1437 | } else { |
1438 | $show_prefix_option = "false"; |
1439 | } |
1440 | return $show_prefix_option; |
911ad01c |
1441 | } |
1442 | |
1443 | # Trash Folder |
f7b1b3b1 |
1444 | sub command23a { |
eaace00e |
1445 | print "You can now specify where the default trash folder is located.\n"; |
1446 | print "On servers where you do not want this, you can set it to anything\n"; |
1447 | print "and set option 6 to false.\n"; |
1448 | print "\n"; |
1449 | print "This is relative to where the rest of your email is kept. You do\n"; |
1450 | print "not need to worry about their mail directory. If this folder\n"; |
1451 | print "would be ~/mail/trash on the filesystem, you only need to specify\n"; |
1452 | print "that this is 'trash', and be sure to put 'mail/' in option 1.\n"; |
1453 | print "\n"; |
1454 | |
1455 | print "[$WHT$trash_folder$NRM]: $WHT"; |
1456 | $new_trash_folder = <STDIN>; |
1457 | if ( $new_trash_folder eq "\n" ) { |
1458 | $new_trash_folder = $trash_folder; |
1459 | } else { |
1460 | $new_trash_folder =~ s/[\r|\n]//g; |
1461 | } |
1462 | return $new_trash_folder; |
911ad01c |
1463 | } |
1464 | |
1465 | # Sent Folder |
f7b1b3b1 |
1466 | sub command23b { |
eaace00e |
1467 | print "This is where messages that are sent will be stored. SquirrelMail\n"; |
1468 | print "by default puts a copy of all outgoing messages in this folder.\n"; |
1469 | print "\n"; |
1470 | print "This is relative to where the rest of your email is kept. You do\n"; |
1471 | print "not need to worry about their mail directory. If this folder\n"; |
1472 | print "would be ~/mail/sent on the filesystem, you only need to specify\n"; |
1473 | print "that this is 'sent', and be sure to put 'mail/' in option 1.\n"; |
1474 | print "\n"; |
1475 | |
1476 | print "[$WHT$sent_folder$NRM]: $WHT"; |
1477 | $new_sent_folder = <STDIN>; |
1478 | if ( $new_sent_folder eq "\n" ) { |
1479 | $new_sent_folder = $sent_folder; |
1480 | } else { |
1481 | $new_sent_folder =~ s/[\r|\n]//g; |
1482 | } |
1483 | return $new_sent_folder; |
911ad01c |
1484 | } |
1485 | |
f7b1b3b1 |
1486 | # Draft Folder |
1487 | sub command23c { |
eaace00e |
1488 | print "You can now specify where the default draft folder is located.\n"; |
1489 | print "On servers where you do not want this, you can set it to anything\n"; |
1490 | print "and set option 9 to false.\n"; |
1491 | print "\n"; |
1492 | print "This is relative to where the rest of your email is kept. You do\n"; |
1493 | print "not need to worry about their mail directory. If this folder\n"; |
1494 | print "would be ~/mail/drafts on the filesystem, you only need to specify\n"; |
1495 | print "that this is 'drafts', and be sure to put 'mail/' in option 1.\n"; |
1496 | print "\n"; |
1497 | |
1498 | print "[$WHT$draft_folder$NRM]: $WHT"; |
1499 | $new_draft_folder = <STDIN>; |
1500 | if ( $new_draft_folder eq "\n" ) { |
1501 | $new_draft_folder = $draft_folder; |
1502 | } else { |
1503 | $new_draft_folder =~ s/[\r|\n]//g; |
1504 | } |
1505 | return $new_draft_folder; |
f7b1b3b1 |
1506 | } |
1507 | |
2f287147 |
1508 | # default move to trash |
f7b1b3b1 |
1509 | sub command24a { |
eaace00e |
1510 | print "By default, should messages get moved to the trash folder? You\n"; |
1511 | print "can specify the default trash folder in option 3. If this is set\n"; |
1512 | print "to false, messages will get deleted immediately without moving\n"; |
1513 | print "to the trash folder.\n"; |
1514 | print "\n"; |
1515 | print "Trash folder is currently: $trash_folder\n"; |
1516 | print "\n"; |
1517 | |
1518 | if ( lc($default_move_to_trash) eq "true" ) { |
1519 | $default_value = "y"; |
1520 | } else { |
1521 | $default_value = "n"; |
1522 | } |
1523 | print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT"; |
1524 | $new_show = <STDIN>; |
1525 | if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
1526 | $default_move_to_trash = "true"; |
1527 | } else { |
1528 | $default_move_to_trash = "false"; |
1529 | } |
1530 | return $default_move_to_trash; |
2f287147 |
1531 | } |
1532 | |
1533 | # default move to sent |
f7b1b3b1 |
1534 | sub command24b { |
eaace00e |
1535 | print "By default, should messages get moved to the sent folder? You\n"; |
1536 | print "can specify the default sent folder in option 4. If this is set\n"; |
1537 | print "to false, messages will get sent and no copy will be made.\n"; |
1538 | print "\n"; |
6517cfd0 |
1539 | print "Sent folder is currently: $sent_folder\n"; |
eaace00e |
1540 | print "\n"; |
1541 | |
1542 | if ( lc($default_move_to_sent) eq "true" ) { |
1543 | $default_value = "y"; |
1544 | } else { |
1545 | $default_value = "n"; |
1546 | } |
1547 | print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT"; |
1548 | $new_show = <STDIN>; |
1549 | if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
1550 | $default_move_to_sent = "true"; |
1551 | } else { |
1552 | $default_move_to_sent = "false"; |
1553 | } |
1554 | return $default_move_to_sent; |
2f287147 |
1555 | } |
1556 | |
f7b1b3b1 |
1557 | # default save as draft |
1558 | sub command24c { |
eaace00e |
1559 | print "By default, should the save to draft option be shown? You can\n"; |
1560 | print "specify the default drafts folder in option 5. If this is set\n"; |
1561 | print "to false, users will not be shown the save to draft option.\n"; |
1562 | print "\n"; |
1563 | print "Drafts folder is currently: $draft_folder\n"; |
1564 | print "\n"; |
1565 | |
1566 | if ( lc($default_move_to_draft) eq "true" ) { |
1567 | $default_value = "y"; |
1568 | } else { |
1569 | $default_value = "n"; |
1570 | } |
1571 | print "By default, save as draft (y/n) [$WHT$default_value$NRM]: $WHT"; |
1572 | $new_show = <STDIN>; |
1573 | if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
1574 | $default_save_as_draft = "true"; |
1575 | } else { |
1576 | $default_save_as_draft = "false"; |
1577 | } |
1578 | return $default_save_as_draft; |
f7b1b3b1 |
1579 | } |
1580 | |
2f287147 |
1581 | # List special folders first |
1582 | sub command27 { |
eaace00e |
1583 | print "SquirrelMail has what we call 'special folders' that are not\n"; |
1584 | print "manipulated and viewed like normal folders. Some examples of\n"; |
1585 | print "these folders would be INBOX, Trash, Sent, etc. This option\n"; |
1586 | print "Simply asks if you want these folders listed first in the folder\n"; |
1587 | print "listing.\n"; |
1588 | print "\n"; |
1589 | |
1590 | if ( lc($list_special_folders_first) eq "true" ) { |
1591 | $default_value = "y"; |
1592 | } else { |
1593 | $default_value = "n"; |
1594 | } |
1595 | print "\n"; |
1596 | print "List first (y/n) [$WHT$default_value$NRM]: $WHT"; |
1597 | $new_show = <STDIN>; |
1598 | if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
1599 | $list_special_folders_first = "true"; |
1600 | } else { |
1601 | $list_special_folders_first = "false"; |
1602 | } |
1603 | return $list_special_folders_first; |
911ad01c |
1604 | } |
1605 | |
1606 | # Show special folders color |
2f287147 |
1607 | sub command28 { |
eaace00e |
1608 | print "SquirrelMail has what we call 'special folders' that are not\n"; |
1609 | print "manipulated and viewed like normal folders. Some examples of\n"; |
1610 | print "these folders would be INBOX, Trash, Sent, etc. This option\n"; |
1611 | print "wants to know if we should display special folders in a\n"; |
1612 | print "color than the other folders.\n"; |
1613 | print "\n"; |
1614 | |
1615 | if ( lc($use_special_folder_color) eq "true" ) { |
1616 | $default_value = "y"; |
1617 | } else { |
1618 | $default_value = "n"; |
1619 | } |
1620 | print "\n"; |
1621 | print "Show color (y/n) [$WHT$default_value$NRM]: $WHT"; |
1622 | $new_show = <STDIN>; |
1623 | if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
1624 | $use_special_folder_color = "true"; |
1625 | } else { |
1626 | $use_special_folder_color = "false"; |
1627 | } |
1628 | return $use_special_folder_color; |
911ad01c |
1629 | } |
1630 | |
911ad01c |
1631 | # Auto expunge |
2f287147 |
1632 | sub command29 { |
eaace00e |
1633 | print "The way that IMAP handles deleting messages is as follows. You\n"; |
1634 | print "mark the message as deleted, and then to 'really' delete it, you\n"; |
1635 | print "expunge it. This option asks if you want to just have messages\n"; |
1636 | print "marked as deleted, or if you want SquirrelMail to expunge the \n"; |
1637 | print "messages too.\n"; |
1638 | print "\n"; |
1639 | |
1640 | if ( lc($auto_expunge) eq "true" ) { |
1641 | $default_value = "y"; |
1642 | } else { |
1643 | $default_value = "n"; |
1644 | } |
1645 | print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT"; |
1646 | $new_show = <STDIN>; |
1647 | if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
1648 | $auto_expunge = "true"; |
1649 | } else { |
1650 | $auto_expunge = "false"; |
1651 | } |
1652 | return $auto_expunge; |
911ad01c |
1653 | } |
1654 | |
1655 | # Default sub of inbox |
2f287147 |
1656 | sub command210 { |
eaace00e |
1657 | print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n"; |
1658 | print "This can cause some confusion in folder creation for users when\n"; |
1659 | print "they try to create folders and don't put it as a subfolder of INBOX\n"; |
1660 | print "and get permission errors. This option asks if you want folders\n"; |
1661 | print "to be subfolders of INBOX by default.\n"; |
1662 | print "\n"; |
1663 | |
1664 | if ( lc($default_sub_of_inbox) eq "true" ) { |
1665 | $default_value = "y"; |
1666 | } else { |
1667 | $default_value = "n"; |
1668 | } |
1669 | print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT"; |
1670 | $new_show = <STDIN>; |
1671 | if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
1672 | $default_sub_of_inbox = "true"; |
1673 | } else { |
1674 | $default_sub_of_inbox = "false"; |
1675 | } |
1676 | return $default_sub_of_inbox; |
911ad01c |
1677 | } |
1678 | |
1679 | # Show contain subfolder option |
2f287147 |
1680 | sub command211 { |
eaace00e |
1681 | print "Some IMAP servers (UW) make it so that there are two types of\n"; |
1682 | print "folders. Those that contain messages, and those that contain\n"; |
1683 | print "subfolders. If this is the case for your server, set this to\n"; |
1684 | print "true, and it will ask the user whether the folder they are\n"; |
1685 | print "creating contains subfolders or messages.\n"; |
1686 | print "\n"; |
1687 | |
1688 | if ( lc($show_contain_subfolders_option) eq "true" ) { |
1689 | $default_value = "y"; |
1690 | } else { |
1691 | $default_value = "n"; |
1692 | } |
1693 | print "Show option (y/n) [$WHT$default_value$NRM]: $WHT"; |
1694 | $new_show = <STDIN>; |
1695 | if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
1696 | $show_contain_subfolders_option = "true"; |
1697 | } else { |
1698 | $show_contain_subfolders_option = "false"; |
1699 | } |
1700 | return $show_contain_subfolders_option; |
911ad01c |
1701 | } |
1702 | |
24fc5dd2 |
1703 | # Default Unseen Notify |
1704 | sub command212 { |
eaace00e |
1705 | print "This option specifies where the users will receive notification\n"; |
1706 | print "about unseen messages by default. This is of course an option that\n"; |
1707 | print "can be changed on a user level.\n"; |
1708 | print " 1 = No notification\n"; |
1709 | print " 2 = Only on the INBOX\n"; |
1710 | print " 3 = On all folders\n"; |
1711 | print "\n"; |
1712 | |
1713 | print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT"; |
1714 | $new_show = <STDIN>; |
1715 | if ( $new_show =~ /^[1|2|3]\n/i ) { |
1716 | $default_unseen_notify = $new_show; |
1717 | } |
1718 | $default_unseen_notify =~ s/[\r|\n]//g; |
1719 | return $default_unseen_notify; |
24fc5dd2 |
1720 | } |
1721 | |
1722 | # Default Unseen Type |
1723 | sub command213 { |
eaace00e |
1724 | print "Here you can define the default way that unseen messages will be displayed\n"; |
1725 | print "to the user in the folder listing on the left side.\n"; |
1726 | print " 1 = Only unseen messages (4)\n"; |
1727 | print " 2 = Unseen and Total messages (4/27)\n"; |
1728 | print "\n"; |
1729 | |
1730 | print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT"; |
1731 | $new_show = <STDIN>; |
1732 | if ( $new_show =~ /^[1|2]\n/i ) { |
1733 | $default_unseen_type = $new_show; |
1734 | } |
1735 | $default_unseen_type =~ s/[\r|\n]//g; |
1736 | return $default_unseen_type; |
24fc5dd2 |
1737 | } |
1738 | |
f7bfc9de |
1739 | # Auto create special folders |
1740 | sub command214 { |
eaace00e |
1741 | print "Would you like the Sent, Trash, and Drafts folders to be created\n"; |
1742 | print "automatically print for you when a user logs in? If the user\n"; |
1743 | print "accidentally deletes their special folders, this option will\n"; |
1744 | print "automatically create it again for them.\n"; |
1745 | print "\n"; |
1746 | |
1747 | if ( lc($auto_create_special) eq "true" ) { |
1748 | $default_value = "y"; |
1749 | } else { |
1750 | $default_value = "n"; |
1751 | } |
1752 | print "Auto create special folders? (y/n) [$WHT$default_value$NRM]: $WHT"; |
1753 | $new_show = <STDIN>; |
1754 | if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
1755 | $auto_create_special = "true"; |
1756 | } else { |
1757 | $auto_create_special = "false"; |
1758 | } |
1759 | return $auto_create_special; |
f7bfc9de |
1760 | } |
1761 | |
4e85a37f |
1762 | # Auto create special folders |
1763 | sub command215 { |
eaace00e |
1764 | print "Would you like to automatically completely delete any deleted\n"; |
1765 | print "folders? If not then they will be moved to the Trash folder\n"; |
1766 | print "and can be deleted from there\n"; |
1767 | print "\n"; |
4e85a37f |
1768 | |
eaace00e |
1769 | if ( lc($delete_folder) eq "true" ) { |
1770 | $default_value = "y"; |
1771 | } else { |
1772 | $default_value = "n"; |
1773 | } |
1774 | print "Auto delete folders? (y/n) [$WHT$default_value$NRM]: $WHT"; |
1775 | $new_delete = <STDIN>; |
1776 | if ( ( $new_delete =~ /^y\n/i ) || ( ( $new_delete =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
1777 | $delete_folder = "true"; |
1778 | } else { |
1779 | $delete_folder = "false"; |
1780 | } |
1781 | return $delete_folder; |
1782 | } |
24fc5dd2 |
1783 | |
ca85aabe |
1784 | #noselect fix |
1785 | sub command216 { |
1786 | print "Some IMAP server allow subfolders to exist even if the parent\n"; |
1787 | print "folders do not. This fixes some problems with the folder list\n"; |
1788 | print "when this is the case, causing the /NoSelect folders to be displayed\n"; |
1789 | print "\n"; |
1790 | |
1791 | if ( lc($noselect_fix_enable) eq "true" ) { |
1792 | $default_value = "y"; |
1793 | } else { |
1794 | $default_value = "n"; |
1795 | } |
1796 | print "enable noselect fix? (y/n) [$WHT$noselect_fix_enable$NRM]: $WHT"; |
1797 | $noselect_fix_enable = <STDIN>; |
1798 | if ( ( $noselect_fix_enable =~ /^y\n/i ) || ( ( $noselect_fix_enable =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
1799 | $noselect_fix_enable = "true"; |
1800 | } else { |
1801 | $noselect_fix_enable = "false"; |
1802 | } |
1803 | return $noselect_fix_enable; |
1804 | } |
ccfb2029 |
1805 | ############# GENERAL OPTIONS ##################### |
1806 | |
1807 | # Default Charset |
1808 | sub command31 { |
eaace00e |
1809 | print "This option controls what character set is used when sending\n"; |
1810 | print "mail and when sending HTML to the browser. Do not set this\n"; |
1811 | print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n"; |
1812 | print "to use KOI8-R, since this implementation is faster than most\n"; |
1813 | print "of the alternatives\n"; |
1814 | print "\n"; |
1815 | |
1816 | print "[$WHT$default_charset$NRM]: $WHT"; |
1817 | $new_default_charset = <STDIN>; |
1818 | if ( $new_default_charset eq "\n" ) { |
1819 | $new_default_charset = $default_charset; |
1820 | } else { |
1821 | $new_default_charset =~ s/[\r|\n]//g; |
1822 | } |
1823 | return $new_default_charset; |
ccfb2029 |
1824 | } |
1825 | |
ccfb2029 |
1826 | # Data directory |
3392dc86 |
1827 | sub command33a { |
e6566358 |
1828 | print "Specify the location for your data directory.\n"; |
1829 | print "The path name can be absolute or relative (to the config directory).\n"; |
1830 | print "It doesn't matter. Here are two examples:\n"; |
1831 | print " Absolute: /var/spool/data/\n"; |
1832 | print " Relative: ../data/\n"; |
8bd9e0dd |
1833 | print "Relative paths to directories outside of the SquirrelMail distribution\n"; |
e6566358 |
1834 | print "will be converted to their absolute path equivalents in config.php.\n\n"; |
1835 | print "Note: There are potential security risks with having a writable directory\n"; |
1836 | print "under the web server's root directory (ex: /home/httpd/html).\n"; |
1837 | print "For this reason, it is recommended to put the data directory\n"; |
1838 | print "in an alternate location of your choice. \n"; |
eaace00e |
1839 | print "\n"; |
1840 | |
1841 | print "[$WHT$data_dir$NRM]: $WHT"; |
1842 | $new_data_dir = <STDIN>; |
1843 | if ( $new_data_dir eq "\n" ) { |
1844 | $new_data_dir = $data_dir; |
1845 | } else { |
1846 | $new_data_dir =~ s/[\r|\n]//g; |
1847 | } |
1848 | if ( $new_data_dir =~ /^\s*$/ ) { |
1849 | $new_data_dir = ""; |
1850 | } else { |
1851 | $new_data_dir =~ s/\/*$//g; |
1852 | $new_data_dir =~ s/$/\//g; |
1853 | } |
1854 | return $new_data_dir; |
ccfb2029 |
1855 | } |
1856 | |
1857 | # Attachment directory |
3392dc86 |
1858 | sub command33b { |
eaace00e |
1859 | print "Path to directory used for storing attachments while a mail is\n"; |
e6566358 |
1860 | print "being sent. The path name can be absolute or relative (to the config directory).\n"; |
1861 | print "It doesn't matter. Here are two examples:\n"; |
1862 | print " Absolute: /var/spool/attach/\n"; |
1863 | print " Relative: ../attach/\n"; |
1864 | print "Relative paths to directories outside of the SquirrelMail distribution\n"; |
1865 | print "will be converted to their absolute path equivalents in config.php.\n\n"; |
1866 | print "Note: There are a few security considerations regarding this\n"; |
eaace00e |
1867 | print "directory:\n"; |
1868 | print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n"; |
1869 | print " impossible for a random person with access to the webserver\n"; |
1870 | print " to list files in this directory. Confidential data might\n"; |
1871 | print " be laying around in there.\n"; |
e6566358 |
1872 | print " Depending on your user:group assignments, 730 (rwx-wx---)\n"; |
1873 | print " may be possible, and more secure (e.g. root:apache)\n"; |
eaace00e |
1874 | print " 2. Since the webserver is not able to list the files in the\n"; |
1875 | print " content is also impossible for the webserver to delete files\n"; |
1876 | print " lying around there for too long.\n"; |
1877 | print " 3. It should probably be another directory than the data\n"; |
1878 | print " directory specified in option 3.\n"; |
1879 | print "\n"; |
1880 | |
1881 | print "[$WHT$attachment_dir$NRM]: $WHT"; |
1882 | $new_attachment_dir = <STDIN>; |
1883 | if ( $new_attachment_dir eq "\n" ) { |
1884 | $new_attachment_dir = $attachment_dir; |
1885 | } else { |
1886 | $new_attachment_dir =~ s/[\r|\n]//g; |
1887 | } |
1888 | if ( $new_attachment_dir =~ /^\s*$/ ) { |
1889 | $new_attachment_dir = ""; |
1890 | } else { |
1891 | $new_attachment_dir =~ s/\/*$//g; |
1892 | $new_attachment_dir =~ s/$/\//g; |
1893 | } |
1894 | return $new_attachment_dir; |
ccfb2029 |
1895 | } |
1896 | |
3392dc86 |
1897 | sub command33c { |
eaace00e |
1898 | print "The directory hash level setting allows you to configure the level\n"; |
1899 | print "of hashing that Squirremail employs in your data and attachment\n"; |
1900 | print "directories. This value must be an integer ranging from 0 to 4.\n"; |
1901 | print "When this value is set to 0, Squirrelmail will simply store all\n"; |
1902 | print "files as normal in the data and attachment directories. However,\n"; |
1903 | print "when set to a value from 1 to 4, a simple hashing scheme will be\n"; |
1904 | print "used to organize the files in this directory. In short, the crc32\n"; |
1905 | print "value for a username will be computed. Then, up to the first 4\n"; |
1906 | print "digits of the hash, as set by this configuration value, will be\n"; |
1907 | print "used to directory hash the files for that user in the data and\n"; |
1908 | print "attachment directory. This allows for better performance on\n"; |
1909 | print "servers with larger numbers of users.\n"; |
1910 | print "\n"; |
1911 | |
1912 | print "[$WHT$dir_hash_level$NRM]: $WHT"; |
1913 | $new_dir_hash_level = <STDIN>; |
1914 | if ( $new_dir_hash_level eq "\n" ) { |
1915 | $new_dir_hash_level = $dir_hash_level; |
1916 | } else { |
1917 | $new_dir_hash_level =~ s/[\r|\n]//g; |
1918 | } |
1919 | if ( ( int($new_dir_hash_level) < 0 ) |
1920 | || ( int($new_dir_hash_level) > 4 ) |
1921 | || !( int($new_dir_hash_level) eq $new_dir_hash_level ) ) { |
1922 | print "Invalid Directory Hash Level.\n"; |
1923 | print "Value must be an integer ranging from 0 to 4\n"; |
1924 | print "Hit enter to continue.\n"; |
1925 | $enter_key = <STDIN>; |
1926 | |
1927 | $new_dir_hash_level = $dir_hash_level; |
1928 | } |
1929 | |
1930 | return $new_dir_hash_level; |
3392dc86 |
1931 | } |
ccfb2029 |
1932 | |
1933 | sub command35 { |
eaace00e |
1934 | print "This is the default size (in pixels) of the left folder list.\n"; |
1935 | print "Default is 200, but you can set it to whatever you wish. This\n"; |
1936 | print "is a user preference, so this will only show up as their default.\n"; |
1937 | print "\n"; |
1938 | print "[$WHT$default_left_size$NRM]: $WHT"; |
1939 | $new_default_left_size = <STDIN>; |
1940 | if ( $new_default_left_size eq "\n" ) { |
1941 | $new_default_left_size = $default_left_size; |
1942 | } else { |
1943 | $new_default_left_size =~ s/[\r|\n]//g; |
1944 | } |
1945 | return $new_default_left_size; |
ccfb2029 |
1946 | } |
1947 | |
985f7c88 |
1948 | sub command36 { |
eaace00e |
1949 | print "Some IMAP servers only have lowercase letters in the usernames\n"; |
1950 | print "but they still allow people with uppercase to log in. This\n"; |
1951 | print "causes a problem with the user's preference files. This option\n"; |
1952 | print "transparently changes all usernames to lowercase."; |
1953 | print "\n"; |
1954 | |
1955 | if ( lc($force_username_lowercase) eq "true" ) { |
1956 | $default_value = "y"; |
1957 | } else { |
1958 | $default_value = "n"; |
1959 | } |
1960 | print "Convert usernames to lowercase (y/n) [$WHT$default_value$NRM]: $WHT"; |
1961 | $new_show = <STDIN>; |
1962 | if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
1963 | return "true"; |
1964 | } |
1965 | return "false"; |
985f7c88 |
1966 | } |
1967 | |
0d15cd19 |
1968 | sub command37 { |
eaace00e |
1969 | print ""; |
1970 | print "\n"; |
985f7c88 |
1971 | |
eaace00e |
1972 | if ( lc($default_use_priority) eq "true" ) { |
1973 | $default_value = "y"; |
1974 | } else { |
1975 | $default_value = "n"; |
1976 | } |
1977 | |
1978 | print "Allow users to specify priority of outgoing mail (y/n) [$WHT$default_value$NRM]: $WHT"; |
1979 | $new_show = <STDIN>; |
1980 | if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
1981 | return "true"; |
1982 | } |
1983 | return "false"; |
826b7f71 |
1984 | } |
1985 | |
eaace00e |
1986 | sub command38 { |
1987 | print ""; |
1988 | print "\n"; |
1989 | |
1990 | if ( lc($default_hide_attribution) eq "true" ) { |
1991 | $default_value = "y"; |
1992 | } else { |
1993 | $default_value = "n"; |
1994 | } |
1995 | |
1996 | print "Hide SM attributions (y/n) [$WHT$default_value$NRM]: $WHT"; |
1997 | $new_show = <STDIN>; |
1998 | if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
1999 | return "true"; |
2000 | } |
2001 | return "false"; |
2002 | } |
826b7f71 |
2003 | |
8c21da0c |
2004 | sub command39 { |
eaace00e |
2005 | print ""; |
2006 | print "\n"; |
2007 | |
2008 | if ( lc($default_use_mdn) eq "true" ) { |
2009 | $default_value = "y"; |
2010 | } else { |
2011 | $default_value = "n"; |
2012 | } |
2013 | |
2014 | print "Enable support for read/delivery receipt support (y/n) [$WHT$default_value$NRM]: $WHT"; |
2015 | $new_show = <STDIN>; |
2016 | if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
2017 | return "true"; |
2018 | } |
2019 | return "false"; |
8c21da0c |
2020 | } |
2021 | |
8a7d0669 |
2022 | sub command310 { |
2023 | print "This allows you to prevent the editing of the users name and"; |
2024 | print "email address. This is mainly useful when used with the"; |
2025 | print "retrieveuserdata plugin\n"; |
2026 | print "\n"; |
eaace00e |
2027 | |
2028 | if ( lc($edit_identity) eq "true" ) { |
8a7d0669 |
2029 | $default_value = "y"; |
2030 | } else { |
2031 | $default_value = "n"; |
2032 | } |
2033 | print "Allow editing? (y/n) [$WHT$default_value$NRM]: $WHT"; |
2034 | $new_edit = <STDIN>; |
eaace00e |
2035 | if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
8a7d0669 |
2036 | $edit_identity = "true"; |
2037 | } else { |
2038 | $edit_identity = "false"; |
2039 | } |
2040 | return $edit_identity; |
2041 | } |
2042 | |
2043 | sub command311 { |
2044 | print "This option allows you to choose if the user can edit their full name"; |
2045 | print "even when you don't want them to change their username\n"; |
2046 | print "\n"; |
2047 | |
eaace00e |
2048 | if ( lc($edit_name) eq "true" ) { |
8a7d0669 |
2049 | $default_value = "y"; |
2050 | } else { |
2051 | $default_value = "n"; |
2052 | } |
2053 | print "Allow editing of the users full name? (y/n) [$WHT$default_value$NRM]: $WHT"; |
2054 | $new_edit = <STDIN>; |
eaace00e |
2055 | if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
8a7d0669 |
2056 | $edit_name = "true"; |
2057 | } else { |
2058 | $edit_name = "false"; |
2059 | } |
2060 | return $edit_name; |
2061 | } |
8c21da0c |
2062 | |
7c612fdd |
2063 | sub command312 { |
2064 | print "This option allows you to choose if users can use thread sorting\n"; |
2065 | print "Your IMAP server must support the THREAD command for this to work\n"; |
aa0da530 |
2066 | print "PHP versions later than 4.0.3 recommended\n"; |
7c612fdd |
2067 | print "\n"; |
2068 | |
2069 | if ( lc($allow_thread_sort) eq "true" ) { |
2070 | $default_value = "y"; |
2071 | } else { |
2072 | $default_value = "n"; |
2073 | } |
2074 | print "Allow server side thread sorting? (y/n) [$WHT$default_value$NRM]: $WHT"; |
2075 | $allow_thread_sort = <STDIN>; |
2076 | if ( ( $allow_thread_sort =~ /^y\n/i ) || ( ( $allow_thread_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
2077 | $allow_thread_sort = "true"; |
2078 | } else { |
2079 | $allow_thread_sort = "false"; |
2080 | } |
2081 | return $allow_thread_sort; |
2082 | } |
2083 | |
aa0da530 |
2084 | sub command313 { |
2085 | print "This option allows you to choose if SM uses server-side sorting\n"; |
2086 | print "Your IMAP server must support the SORT command for this to work\n"; |
2087 | print "\n"; |
2088 | |
2089 | if ( lc($allow_server_sort) eq "true" ) { |
2090 | $default_value = "y"; |
2091 | } else { |
2092 | $default_value = "n"; |
2093 | } |
2094 | print "Allow server-side sorting? (y/n) [$WHT$default_value$NRM]: $WHT"; |
2095 | $allow_server_sort = <STDIN>; |
2096 | if ( ( $allow_server_sort =~ /^y\n/i ) || ( ( $allow_server_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
2097 | $allow_server_sort = "true"; |
2098 | } else { |
2099 | $allow_server_sort = "false"; |
2100 | } |
2101 | return $allow_server_sort; |
2102 | } |
2103 | |
65ffb3ce |
2104 | sub command314 { |
2105 | print "This option allows you to choose if SM uses charset search\n"; |
2106 | print "Your IMAP server must support the SEARCH CHARSET command for this to work\n"; |
2107 | print "\n"; |
2108 | |
2109 | if ( lc($allow_charset_search) eq "true" ) { |
2110 | $default_value = "y"; |
2111 | } else { |
2112 | $default_value = "n"; |
2113 | } |
2114 | print "Allow charset searching? (y/n) [$WHT$default_value$NRM]: $WHT"; |
2115 | $allow_charset_search = <STDIN>; |
2116 | if ( ( $allow_charset_search =~ /^y\n/i ) || ( ( $allow_charset_search =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
2117 | $allow_charset_search = "true"; |
2118 | } else { |
2119 | $allow_charset_search = "false"; |
2120 | } |
2121 | return $allow_charset_search; |
2122 | } |
2123 | |
3c7ee482 |
2124 | sub command315 { |
2125 | print "This option allows you to enable unique identifier (UID) support.\n"; |
2126 | print "\n"; |
2127 | |
2128 | if ( lc($uid_support) eq "true" ) { |
2129 | $default_value = "y"; |
2130 | } else { |
2131 | $default_value = "n"; |
2132 | } |
2133 | print "Enable Unique identifier (UID) support? (y/n) [$WHT$default_value$NRM]: $WHT"; |
2134 | $uid_support = <STDIN>; |
2135 | if ( ( $uid_support =~ /^y\n/i ) || ( ( $uid_support =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
2136 | $uid_support = "true"; |
2137 | } else { |
2138 | $uid_support = "false"; |
2139 | } |
2140 | return $uid_support; |
2141 | } |
2142 | |
6c499577 |
2143 | sub command316 { |
2144 | print "This option allows you to change the name of the PHP session used\n"; |
2145 | print "by SquirrelMail. Unless you know what you are doing, you probably\n"; |
2146 | print "don't need or want to change this from the default of SQMSESSID.\n"; |
2147 | print "[$WHT$session_name$NRM]: $WHT"; |
2148 | $new_session_name = <STDIN>; |
2149 | chomp($new_session_name); |
6614128e |
2150 | if ( $new_session_name eq "" ) { |
6c499577 |
2151 | $new_session_name = $session_name; |
2152 | } |
2153 | return $new_session_name; |
2154 | } |
2155 | |
2156 | |
65ffb3ce |
2157 | |
ccfb2029 |
2158 | sub command41 { |
eaace00e |
2159 | print "\nNow we will define the themes that you wish to use. If you have added\n"; |
2160 | print "a theme of your own, just follow the instructions (?) about how to add\n"; |
2161 | print "them. You can also change the default theme.\n"; |
2162 | print "[theme] command (?=help) > "; |
2163 | $input = <STDIN>; |
2164 | $input =~ s/[\r|\n]//g; |
2165 | while ( $input ne "d" ) { |
2166 | if ( $input =~ /^\s*l\s*/i ) { |
2167 | $count = 0; |
2168 | while ( $count <= $#theme_name ) { |
2169 | if ( $count == $theme_default ) { |
2170 | print " *"; |
2171 | } else { |
2172 | print " "; |
2173 | } |
2174 | $name = $theme_name[$count]; |
2175 | $num_spaces = 25 - length($name); |
2176 | for ( $i = 0 ; $i < $num_spaces ; $i++ ) { |
2177 | $name = $name . " "; |
2178 | } |
2179 | |
2180 | print " $count. $name"; |
2181 | print "($theme_path[$count])\n"; |
2182 | |
2183 | $count++; |
ccfb2029 |
2184 | } |
eaace00e |
2185 | } elsif ( $input =~ /^\s*m\s*[0-9]+/i ) { |
2186 | $old_def = $theme_default; |
2187 | $theme_default = $input; |
2188 | $theme_default =~ s/^\s*m\s*//; |
2189 | if ( ( $theme_default > $#theme_name ) || ( $theme_default < 0 ) ) { |
2190 | print "Cannot set default theme to $theme_default. That theme does not exist.\n"; |
2191 | $theme_default = $old_def; |
ccfb2029 |
2192 | } |
eaace00e |
2193 | } elsif ( $input =~ /^\s*\+/ ) { |
2194 | print "What is the name of this theme: "; |
2195 | $name = <STDIN>; |
2196 | $name =~ s/[\r|\n]//g; |
2197 | $theme_name[ $#theme_name + 1 ] = $name; |
2198 | print "Be sure to put ../themes/ before the filename.\n"; |
2199 | print "What file is this stored in (ex: ../themes/default_theme.php): "; |
2200 | $name = <STDIN>; |
2201 | $name =~ s/[\r|\n]//g; |
2202 | $theme_path[ $#theme_path + 1 ] = $name; |
2203 | } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) { |
2204 | if ( $input =~ /[0-9]+\s*$/ ) { |
2205 | $rem_num = $input; |
2206 | $rem_num =~ s/^\s*-\s*//g; |
2207 | $rem_num =~ s/\s*$//; |
2208 | } else { |
2209 | $rem_num = $#theme_name; |
ccfb2029 |
2210 | } |
eaace00e |
2211 | if ( $rem_num == $theme_default ) { |
2212 | print "You cannot remove the default theme!\n"; |
2213 | } else { |
2214 | $count = 0; |
2215 | @new_theme_name = (); |
2216 | @new_theme_path = (); |
2217 | while ( $count <= $#theme_name ) { |
2218 | if ( $count != $rem_num ) { |
2219 | @new_theme_name = ( @new_theme_name, $theme_name[$count] ); |
2220 | @new_theme_path = ( @new_theme_path, $theme_path[$count] ); |
2221 | } |
2222 | $count++; |
2223 | } |
2224 | @theme_name = @new_theme_name; |
2225 | @theme_path = @new_theme_path; |
2226 | if ( $theme_default > $rem_num ) { |
2227 | $theme_default--; |
2228 | } |
8442ac08 |
2229 | } |
eaace00e |
2230 | } elsif ( $input =~ /^\s*t\s*/i ) { |
2231 | print "\nStarting detection...\n\n"; |
2232 | |
2233 | opendir( DIR, "../themes" ); |
2234 | @files = grep { /\.php$/i } readdir(DIR); |
2235 | $cnt = 0; |
2236 | while ( $cnt <= $#files ) { |
2237 | $filename = "../themes/" . $files[$cnt]; |
2238 | if ( $filename ne "../themes/index.php" ) { |
2239 | $found = 0; |
2240 | for ( $x = 0 ; $x <= $#theme_path ; $x++ ) { |
2241 | if ( $theme_path[$x] eq $filename ) { |
2242 | $found = 1; |
2243 | } |
2244 | } |
2245 | if ( $found != 1 ) { |
2246 | print "** Found theme: $filename\n"; |
2247 | print " What is its name? "; |
2248 | $nm = <STDIN>; |
2249 | $nm =~ s/[\n|\r]//g; |
2250 | $theme_name[ $#theme_name + 1 ] = $nm; |
2251 | $theme_path[ $#theme_path + 1 ] = $filename; |
2252 | } |
2253 | } |
2254 | $cnt++; |
8442ac08 |
2255 | } |
eaace00e |
2256 | print "\n"; |
2257 | for ( $cnt = 0 ; $cnt <= $#theme_path ; $cnt++ ) { |
2258 | $filename = $theme_path[$cnt]; |
2259 | if ( !( -e $filename ) ) { |
2260 | print " Removing $filename (file not found)\n"; |
2261 | $offset = 0; |
2262 | @new_theme_name = (); |
2263 | @new_theme_path = (); |
2264 | for ( $x = 0 ; $x < $#theme_path ; $x++ ) { |
2265 | if ( $theme_path[$x] eq $filename ) { |
2266 | $offset = 1; |
2267 | } |
2268 | if ( $offset == 1 ) { |
2269 | $new_theme_name[$x] = $theme_name[ $x + 1 ]; |
2270 | $new_theme_path[$x] = $theme_path[ $x + 1 ]; |
2271 | } else { |
2272 | $new_theme_name[$x] = $theme_name[$x]; |
2273 | $new_theme_path[$x] = $theme_path[$x]; |
2274 | } |
2275 | } |
2276 | @theme_name = @new_theme_name; |
2277 | @theme_path = @new_theme_path; |
2278 | } |
2279 | } |
2280 | print "\nDetection complete!\n\n"; |
2281 | |
2282 | closedir DIR; |
2283 | } elsif ( $input =~ /^\s*\?\s*/ ) { |
2284 | print ".-------------------------.\n"; |
2285 | print "| t (detect themes) |\n"; |
2286 | print "| + (add theme) |\n"; |
2287 | print "| - N (remove theme) |\n"; |
2288 | print "| m N (mark default) |\n"; |
2289 | print "| l (list themes) |\n"; |
2290 | print "| d (done) |\n"; |
2291 | print "`-------------------------'\n"; |
2292 | } |
2293 | print "[theme] command (?=help) > "; |
2294 | $input = <STDIN>; |
2295 | $input =~ s/[\r|\n]//g; |
2296 | } |
2297 | } |
ccfb2029 |
2298 | |
6f3bfa54 |
2299 | # Theme - CSS file |
2300 | sub command42 { |
eaace00e |
2301 | print "You may specify a cascading style-sheet (CSS) file to be included\n"; |
2302 | print "on each html page generated by SquirrelMail. The CSS file is useful\n"; |
2303 | print "for specifying a site-wide font. If you're not familiar with CSS\n"; |
2304 | print "files, leave this blank.\n"; |
2305 | print "\n"; |
2306 | print "To clear out an existing value, just type a space for the input.\n"; |
2307 | print "\n"; |
8bd9e0dd |
2308 | print "Relative links to files outside the SquirrelMail distribution\n"; |
2309 | print "will be converted to their absolute path equivalents in config.php.\n"; |
2310 | print "\n"; |
eaace00e |
2311 | print "[$WHT$theme_css$NRM]: $WHT"; |
2312 | $new_theme_css = <STDIN>; |
6f3bfa54 |
2313 | |
eaace00e |
2314 | if ( $new_theme_css eq "\n" ) { |
2315 | $new_theme_css = $theme_css; |
2316 | } else { |
2317 | $new_theme_css =~ s/[\r|\n]//g; |
2318 | } |
2319 | $new_theme_css =~ s/^\s*//; |
2320 | return $new_theme_css; |
2321 | } |
6f3bfa54 |
2322 | |
1e0628fb |
2323 | sub command61 { |
eaace00e |
2324 | print "You can now define different LDAP servers.\n"; |
2325 | print "[ldap] command (?=help) > "; |
2326 | $input = <STDIN>; |
2327 | $input =~ s/[\r|\n]//g; |
2328 | while ( $input ne "d" ) { |
2329 | if ( $input =~ /^\s*l\s*/i ) { |
2330 | $count = 0; |
2331 | while ( $count <= $#ldap_host ) { |
2332 | print "$count. $ldap_host[$count]\n"; |
2333 | print " base: $ldap_base[$count]\n"; |
2334 | if ( $ldap_charset[$count] ) { |
2335 | print " charset: $ldap_charset[$count]\n"; |
2336 | } |
2337 | if ( $ldap_port[$count] ) { |
2338 | print " port: $ldap_port[$count]\n"; |
2339 | } |
2340 | if ( $ldap_name[$count] ) { |
2341 | print " name: $ldap_name[$count]\n"; |
2342 | } |
2343 | if ( $ldap_maxrows[$count] ) { |
2344 | print " maxrows: $ldap_maxrows[$count]\n"; |
2345 | } |
2346 | print "\n"; |
2347 | $count++; |
a93b12ba |
2348 | } |
eaace00e |
2349 | } elsif ( $input =~ /^\s*\+/ ) { |
2350 | $sub = $#ldap_host + 1; |
2351 | |
2352 | print "First, we need to have the hostname or the IP address where\n"; |
2353 | print "this LDAP server resides. Example: ldap.bigfoot.com\n"; |
2354 | print "hostname: "; |
2355 | $name = <STDIN>; |
2356 | $name =~ s/[\r|\n]//g; |
2357 | $ldap_host[$sub] = $name; |
2358 | |
2359 | print "\n"; |
2360 | |
2361 | print "Next, we need the server root (base dn). For this, an empty\n"; |
2362 | print "string is allowed.\n"; |
2363 | print "Example: ou=member_directory,o=netcenter.com\n"; |
2364 | print "base: "; |
2365 | $name = <STDIN>; |
2366 | $name =~ s/[\r|\n]//g; |
2367 | $ldap_base[$sub] = $name; |
2368 | |
2369 | print "\n"; |
2370 | |
2371 | print "This is the TCP/IP port number for the LDAP server. Default\n"; |
2372 | print "port is 389. This is optional. Press ENTER for default.\n"; |
2373 | print "port: "; |
2374 | $name = <STDIN>; |
2375 | $name =~ s/[\r|\n]//g; |
2376 | $ldap_port[$sub] = $name; |
2377 | |
2378 | print "\n"; |
2379 | |
2380 | print "This is the charset for the server. Default is utf-8. This\n"; |
2381 | print "is also optional. Press ENTER for default.\n"; |
2382 | print "charset: "; |
2383 | $name = <STDIN>; |
2384 | $name =~ s/[\r|\n]//g; |
2385 | $ldap_charset[$sub] = $name; |
2386 | |
2387 | print "\n"; |
2388 | |
2389 | print "This is the name for the server, used to tag the results of\n"; |
2390 | print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n"; |
2391 | print "name: "; |
2392 | $name = <STDIN>; |
2393 | $name =~ s/[\r|\n]//g; |
2394 | $ldap_name[$sub] = $name; |
2395 | |
2396 | print "\n"; |
2397 | |
2398 | print "You can specify the maximum number of rows in the search result.\n"; |
2399 | print "Default is unlimited. Press ENTER for default.\n"; |
2400 | print "maxrows: "; |
2401 | $name = <STDIN>; |
2402 | $name =~ s/[\r|\n]//g; |
2403 | $ldap_maxrows[$sub] = $name; |
2404 | |
a93b12ba |
2405 | print "\n"; |
eaace00e |
2406 | |
2407 | } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) { |
2408 | if ( $input =~ /[0-9]+\s*$/ ) { |
2409 | $rem_num = $input; |
2410 | $rem_num =~ s/^\s*-\s*//g; |
2411 | $rem_num =~ s/\s*$//; |
2412 | } else { |
2413 | $rem_num = $#ldap_host; |
2414 | } |
2415 | $count = 0; |
2416 | @new_ldap_host = (); |
2417 | @new_ldap_base = (); |
2418 | @new_ldap_port = (); |
2419 | @new_ldap_name = (); |
2420 | @new_ldap_charset = (); |
2421 | @new_ldap_maxrows = (); |
2422 | |
2423 | while ( $count <= $#ldap_host ) { |
2424 | if ( $count != $rem_num ) { |
2425 | @new_ldap_host = ( @new_ldap_host, $ldap_host[$count] ); |
2426 | @new_ldap_base = ( @new_ldap_base, $ldap_base[$count] ); |
2427 | @new_ldap_port = ( @new_ldap_port, $ldap_port[$count] ); |
2428 | @new_ldap_name = ( @new_ldap_name, $ldap_name[$count] ); |
2429 | @new_ldap_charset = ( @new_ldap_charset, $ldap_charset[$count] ); |
2430 | @new_ldap_maxrows = ( @new_ldap_maxrows, $ldap_maxrows[$count] ); |
2431 | } |
2432 | $count++; |
1e0628fb |
2433 | } |
eaace00e |
2434 | @ldap_host = @new_ldap_host; |
2435 | @ldap_base = @new_ldap_base; |
2436 | @ldap_port = @new_ldap_port; |
2437 | @ldap_name = @new_ldap_name; |
2438 | @ldap_charset = @new_ldap_charset; |
2439 | @ldap_maxrows = @new_ldap_maxrows; |
2440 | } elsif ( $input =~ /^\s*\?\s*/ ) { |
2441 | print ".-------------------------.\n"; |
2442 | print "| + (add host) |\n"; |
2443 | print "| - N (remove host) |\n"; |
2444 | print "| l (list hosts) |\n"; |
2445 | print "| d (done) |\n"; |
2446 | print "`-------------------------'\n"; |
2447 | } |
2448 | print "[ldap] command (?=help) > "; |
2449 | $input = <STDIN>; |
2450 | $input =~ s/[\r|\n]//g; |
2451 | } |
2452 | } |
1e0628fb |
2453 | |
3806fa52 |
2454 | sub command62 { |
eaace00e |
2455 | print "Some of our developers have come up with very good javascript interface\n"; |
2456 | print "for searching through address books, however, our original goals said\n"; |
2457 | print "that we would be 100% HTML. In order to make it possible to use their\n"; |
2458 | print "interface, and yet stick with our goals, we have also written a plain\n"; |
2459 | print "HTML version of the search. Here, you can choose which version to use.\n"; |
2460 | print "\n"; |
2461 | print "This is just the default value. It is also a user option that each\n"; |
2462 | print "user can configure individually\n"; |
2463 | print "\n"; |
2464 | |
2465 | if ( lc($default_use_javascript_addr_book) eq "true" ) { |
2466 | $default_value = "y"; |
2467 | } else { |
2468 | $default_use_javascript_addr_book = "false"; |
2469 | $default_value = "n"; |
2470 | } |
2471 | print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT"; |
2472 | $new_show = <STDIN>; |
2473 | if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { |
2474 | $default_use_javascript_addr_book = "true"; |
2475 | } else { |
2476 | $default_use_javascript_addr_book = "false"; |
2477 | } |
2478 | return $default_use_javascript_addr_book; |
3806fa52 |
2479 | } |
1e0628fb |
2480 | |
497203d4 |
2481 | sub command91 { |
eaace00e |
2482 | print "If you want to store your users address book details in a database then\n"; |
2483 | print "you need to set this DSN to a valid value. The format for this is:\n"; |
2484 | print "mysql://user:pass\@hostname/dbname\n"; |
2485 | print "Where mysql can be one of the databases PHP supports, the most common\n"; |
2486 | print "of these are mysql, msql and pgsql\n"; |
2487 | print "If the DSN is left empty (hit space and then return) the database\n"; |
2488 | print "related code for address books will not be used\n"; |
2489 | print "\n"; |
2490 | |
2491 | if ( $addrbook_dsn eq "" ) { |
2492 | $default_value = "Disabled"; |
2493 | } else { |
2494 | $default_value = $addrbook_dsn; |
2495 | } |
2496 | print "[$WHT$addrbook_dsn$NRM]: $WHT"; |
2497 | $new_dsn = <STDIN>; |
2498 | if ( $new_dsn eq "\n" ) { |
2499 | $new_dsn = ""; |
2500 | } else { |
2501 | $new_dsn =~ s/[\r|\n]//g; |
2502 | $new_dsn =~ s/^\s+$//g; |
2503 | } |
2504 | return $new_dsn; |
497203d4 |
2505 | } |
ccfb2029 |
2506 | |
4f40a59d |
2507 | sub command92 { |
eaace00e |
2508 | print "This is the name of the table you want to store the address book\n"; |
2509 | print "data in, it defaults to 'address'\n"; |
2510 | print "\n"; |
2511 | print "[$WHT$addrbook_table$NRM]: $WHT"; |
2512 | $new_table = <STDIN>; |
2513 | if ( $new_table eq "\n" ) { |
2514 | $new_table = $addrbook_table; |
2515 | } else { |
2516 | $new_table =~ s/[\r|\n]//g; |
2517 | } |
2518 | return $new_table; |
4f40a59d |
2519 | } |
2520 | |
3499f99f |
2521 | sub command93 { |
2522 | print "If you want to store your users preferences in a database then\n"; |
2523 | print "you need to set this DSN to a valid value. The format for this is:\n"; |
2524 | print "mysql://user:pass\@hostname/dbname\n"; |
2525 | print "Where mysql can be one of the databases PHP supports, the most common\n"; |
2526 | print "of these are mysql, msql and pgsql\n"; |
2527 | print "If the DSN is left empty (hit space and then return) the database\n"; |
2528 | print "related code for address books will not be used\n"; |
2529 | print "\n"; |
2530 | |
eaace00e |
2531 | if ( $prefs_dsn eq "" ) { |
3499f99f |
2532 | $default_value = "Disabled"; |
2533 | } else { |
2534 | $default_value = $prefs_dsn; |
2535 | } |
2536 | print "[$WHT$prefs_dsn$NRM]: $WHT"; |
2537 | $new_dsn = <STDIN>; |
eaace00e |
2538 | if ( $new_dsn eq "\n" ) { |
3499f99f |
2539 | $new_dsn = ""; |
2540 | } else { |
2541 | $new_dsn =~ s/[\r|\n]//g; |
2542 | $new_dsn =~ s/^\s+$//g; |
2543 | } |
2544 | return $new_dsn; |
2545 | } |
2546 | |
2547 | sub command94 { |
2548 | print "This is the name of the table you want to store the preferences\n"; |
99a6c222 |
2549 | print "data in, it defaults to 'userprefs'\n"; |
3499f99f |
2550 | print "\n"; |
2551 | print "[$WHT$prefs_table$NRM]: $WHT"; |
2552 | $new_table = <STDIN>; |
eaace00e |
2553 | if ( $new_table eq "\n" ) { |
3499f99f |
2554 | $new_table = $prefs_table; |
2555 | } else { |
2556 | $new_table =~ s/[\r|\n]//g; |
2557 | } |
2558 | return $new_table; |
eaace00e |
2559 | } |
3499f99f |
2560 | |
99a6c222 |
2561 | sub command95 { |
2562 | print "This is the name of the field in which you want to store the\n"; |
2563 | print "username of the person the prefs are for. It default to 'user'\n"; |
2564 | print "which clashes with a reserved keyword in PostgreSQL so this\n"; |
2565 | print "will need to be changed for that database at least\n"; |
2566 | print "\n"; |
2567 | print "[$WHT$prefs_user_field$NRM]: $WHT"; |
2568 | $new_field = <STDIN>; |
2569 | if ( $new_field eq "\n" ) { |
2570 | $new_field = $prefs_user_field; |
2571 | } else { |
2572 | $new_field =~ s/[\r|\n]//g; |
2573 | } |
2574 | return $new_field; |
2575 | } |
2576 | |
2577 | sub command96 { |
2578 | print "This is the name of the field in which you want to store the\n"; |
2579 | print "preferences keyword. It defaults to 'prefkey'\n"; |
2580 | print "\n"; |
2581 | print "[$WHT$prefs_key_field$NRM]: $WHT"; |
2582 | $new_field = <STDIN>; |
2583 | if ( $new_field eq "\n" ) { |
2584 | $new_field = $prefs_key_field; |
2585 | } else { |
2586 | $new_field =~ s/[\r|\n]//g; |
2587 | } |
2588 | return $new_field; |
2589 | } |
2590 | |
2591 | sub command97 { |
2592 | print "This is the name of the field in which you want to store the\n"; |
2593 | print "preferences value. It defaults to 'prefval'\n"; |
2594 | print "\n"; |
2595 | print "[$WHT$prefs_val_field$NRM]: $WHT"; |
2596 | $new_field = <STDIN>; |
2597 | if ( $new_field eq "\n" ) { |
2598 | $new_field = $prefs_val_field; |
2599 | } else { |
2600 | $new_field =~ s/[\r|\n]//g; |
2601 | } |
2602 | return $new_field; |
2603 | } |
2604 | |
ccfb2029 |
2605 | sub save_data { |
ebd13f55 |
2606 | $tab = " "; |
eaace00e |
2607 | if ( open( CF, ">config.php" ) ) { |
ebd13f55 |
2608 | print CF "<?php\n"; |
2609 | print CF "\n"; |
eaace00e |
2610 | |
ebd13f55 |
2611 | print CF "/**\n"; |
2612 | print CF " * SquirrelMail Configuration File\n"; |
2613 | print CF " * Created using the configure script, conf.pl\n"; |
2614 | print CF " */\n"; |
2615 | print CF "\n"; |
93c06fa2 |
2616 | print CF "global \$version;\n"; |
2617 | |
ebd13f55 |
2618 | if ($print_config_version) { |
eaace00e |
2619 | print CF "\$config_version = '$print_config_version';\n"; |
ebd13f55 |
2620 | } |
254ded61 |
2621 | # integer |
2622 | print CF "\$config_use_color = $config_use_color;\n"; |
ebd13f55 |
2623 | print CF "\n"; |
254ded61 |
2624 | |
2625 | # string |
d756b071 |
2626 | print CF "\$org_name = \"$org_name\";\n"; |
254ded61 |
2627 | # string |
8bd9e0dd |
2628 | print CF "\$org_logo = " . &change_to_SM_path($org_logo) . ";\n"; |
b6e0c3b6 |
2629 | $org_logo_width |= 0; |
2630 | $org_logo_height |= 0; |
254ded61 |
2631 | # string |
80519ece |
2632 | print CF "\$org_logo_width = '$org_logo_width';\n"; |
254ded61 |
2633 | # string |
2634 | print CF "\$org_logo_height = '$org_logo_height';\n"; |
2635 | # string that can contain variables. |
12947430 |
2636 | print CF "\$org_title = \"$org_title\";\n"; |
254ded61 |
2637 | # string |
8bd9e0dd |
2638 | print CF "\$signout_page = " . &change_to_SM_path($signout_page) . ";\n"; |
254ded61 |
2639 | # string |
3d043efc |
2640 | print CF "\$frame_top = '$frame_top';\n"; |
ebd13f55 |
2641 | print CF "\n"; |
eaace00e |
2642 | |
0ae4c1f2 |
2643 | print CF "\$provider_uri = '$provider_uri';\n"; |
2644 | print CF "\n"; |
2645 | |
2646 | print CF "\$provider_name = '$provider_name';\n"; |
2647 | print CF "\n"; |
2648 | |
254ded61 |
2649 | # string that can contain variables |
2650 | print CF "\$motd = \"$motd\";\n"; |
ebd13f55 |
2651 | print CF "\n"; |
254ded61 |
2652 | |
2653 | # string |
ebd13f55 |
2654 | print CF "\$squirrelmail_default_language = '$squirrelmail_default_language';\n"; |
2655 | print CF "\n"; |
eaace00e |
2656 | |
254ded61 |
2657 | # string |
ebd13f55 |
2658 | print CF "\$domain = '$domain';\n"; |
254ded61 |
2659 | # string |
ebd13f55 |
2660 | print CF "\$imapServerAddress = '$imapServerAddress';\n"; |
254ded61 |
2661 | # integer |
2662 | print CF "\$imapPort = $imapPort;\n"; |
2663 | # boolean |
2664 | print CF "\$useSendmail = $useSendmail;\n"; |
2665 | # string |
ebd13f55 |
2666 | print CF "\$smtpServerAddress = '$smtpServerAddress';\n"; |
254ded61 |
2667 | # integer |
2668 | print CF "\$smtpPort = $smtpPort;\n"; |
2669 | # string |
ebd13f55 |
2670 | print CF "\$sendmail_path = '$sendmail_path';\n"; |
254ded61 |
2671 | # boolean |
47a29326 |
2672 | # print CF "\$use_authenticated_smtp = $use_authenticated_smtp;\n"; |
254ded61 |
2673 | # boolean |
2674 | print CF "\$pop_before_smtp = $pop_before_smtp;\n"; |
2675 | # string |
ebd13f55 |
2676 | print CF "\$imap_server_type = '$imap_server_type';\n"; |
254ded61 |
2677 | # boolean |
374726c9 |
2678 | print CF "\$invert_time = $invert_time;\n"; |
254ded61 |
2679 | # string |
ebd13f55 |
2680 | print CF "\$optional_delimiter = '$optional_delimiter';\n"; |
2681 | print CF "\n"; |
eaace00e |
2682 | |
254ded61 |
2683 | # string |
ebd13f55 |
2684 | print CF "\$default_folder_prefix = '$default_folder_prefix';\n"; |
254ded61 |
2685 | # string |
ebd13f55 |
2686 | print CF "\$trash_folder = '$trash_folder';\n"; |
254ded61 |
2687 | # string |
ebd13f55 |
2688 | print CF "\$sent_folder = '$sent_folder';\n"; |
254ded61 |
2689 | # string |
ebd13f55 |
2690 | print CF "\$draft_folder = '$draft_folder';\n"; |
254ded61 |
2691 | # boolean |
2692 | print CF "\$default_move_to_trash = $default_move_to_trash;\n"; |
2693 | # boolean |
2694 | print CF "\$default_move_to_sent = $default_move_to_sent;\n"; |
2695 | # boolean |
2696 | print CF "\$default_save_as_draft = $default_save_as_draft;\n"; |
2697 | # boolean |
2698 | print CF "\$show_prefix_option = $show_prefix_option;\n"; |
2699 | # boolean |
2700 | print CF "\$list_special_folders_first = $list_special_folders_first;\n"; |
2701 | # boolean |
2702 | print CF "\$use_special_folder_color = $use_special_folder_color;\n"; |
2703 | # boolean |
2704 | print CF "\$auto_expunge = $auto_expunge;\n"; |
2705 | # boolean |
2706 | print CF "\$default_sub_of_inbox = $default_sub_of_inbox;\n"; |
2707 | # boolean |
2708 | print CF "\$show_contain_subfolders_option = $show_contain_subfolders_option;\n"; |
2709 | # integer |
2710 | print CF "\$default_unseen_notify = $default_unseen_notify;\n"; |
2711 | # integer |
2712 | print CF "\$default_unseen_type = $default_unseen_type;\n"; |
2713 | # boolean |
2714 | print CF "\$auto_create_special = $auto_create_special;\n"; |
2715 | # boolean |
2716 | print CF "\$delete_folder = $delete_folder;\n"; |
ca85aabe |
2717 | # boolean |
2718 | print CF "\$noselect_fix_enable = $noselect_fix_enable;\n"; |
2719 | |
ebd13f55 |
2720 | print CF "\n"; |
eaace00e |
2721 | |
254ded61 |
2722 | # string |
ebd13f55 |
2723 | print CF "\$default_charset = '$default_charset';\n"; |
254ded61 |
2724 | # string |
8bd9e0dd |
2725 | print CF "\$data_dir = " . &change_to_SM_path($data_dir) . ";\n"; |
254ded61 |
2726 | # string that can contain a variable |
8bd9e0dd |
2727 | print CF "\$attachment_dir = " . &change_to_SM_path($attachment_dir) . ";\n"; |
254ded61 |
2728 | # integer |
2729 | print CF "\$dir_hash_level = $dir_hash_level;\n"; |
2730 | # string |
80519ece |
2731 | print CF "\$default_left_size = '$default_left_size';\n"; |
254ded61 |
2732 | # boolean |
2733 | print CF "\$force_username_lowercase = $force_username_lowercase;\n"; |
2734 | # boolean |
2735 | print CF "\$default_use_priority = $default_use_priority;\n"; |
2736 | # boolean |
2737 | print CF "\$hide_sm_attributions = $hide_sm_attributions;\n"; |
2738 | # boolean |
2739 | print CF "\$default_use_mdn = $default_use_mdn;\n"; |
2740 | # boolean |
2741 | print CF "\$edit_identity = $edit_identity;\n"; |
2742 | # boolean |
2743 | print CF "\$edit_name = $edit_name;\n"; |
2744 | # boolean |
2745 | print CF "\$allow_thread_sort = $allow_thread_sort;\n"; |
2746 | # boolean |
2747 | print CF "\$allow_server_sort = $allow_server_sort;\n"; |
65ffb3ce |
2748 | # boolean |
3c7ee482 |
2749 | print CF "\$allow_charset_search = $allow_charset_search;\n"; |
2750 | # boolean |
2751 | print CF "\$uid_support = $uid_support;\n"; |
ebd13f55 |
2752 | print CF "\n"; |
254ded61 |
2753 | |
2754 | # all plugins are strings |
eaace00e |
2755 | for ( $ct = 0 ; $ct <= $#plugins ; $ct++ ) { |
2756 | print CF "\$plugins[$ct] = '$plugins[$ct]';\n"; |
ebd13f55 |
2757 | } |
2758 | print CF "\n"; |
eaace00e |
2759 | |
254ded61 |
2760 | # strings |
8bd9e0dd |
2761 | print CF "\$theme_css = " . &change_to_SM_path($theme_css) . ";\n"; |
a73af766 |
2762 | if ( $theme_default eq '' ) { $theme_default = '0'; } |
57c6fabc |
2763 | print CF "\$theme_default = $theme_default;\n"; |
2764 | |
eaace00e |
2765 | for ( $count = 0 ; $count <= $#theme_name ; $count++ ) { |
8bd9e0dd |
2766 | print CF "\$theme[$count]['PATH'] = " . &change_to_SM_path($theme_path[$count]) . ";\n"; |
eaace00e |
2767 | print CF "\$theme[$count]['NAME'] = '$theme_name[$count]';\n"; |
ebd13f55 |
2768 | } |
2769 | print CF "\n"; |
eaace00e |
2770 | |
2771 | if ( $default_use_javascript_addr_book ne "true" ) { |
2772 | $default_use_javascript_addr_book = "false"; |
2773 | } |
254ded61 |
2774 | |
2775 | # boolean |
ebd13f55 |
2776 | print CF "\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n"; |
eaace00e |
2777 | for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) { |
2778 | print CF "\$ldap_server[$count] = array(\n"; |
254ded61 |
2779 | # string |
eaace00e |
2780 | print CF " 'host' => '$ldap_host[$count]',\n"; |
254ded61 |
2781 | # string |
eaace00e |
2782 | print CF " 'base' => '$ldap_base[$count]'"; |
2783 | if ( $ldap_name[$count] ) { |
2784 | print CF ",\n"; |
254ded61 |
2785 | # string |
eaace00e |
2786 | print CF " 'name' => '$ldap_name[$count]'"; |
2787 | } |
2788 | if ( $ldap_port[$count] ) { |
2789 | print CF ",\n"; |
254ded61 |
2790 | # integer |
2791 | print CF " 'port' => $ldap_port[$count]"; |
eaace00e |
2792 | } |
2793 | if ( $ldap_charset[$count] ) { |
2794 | print CF ",\n"; |
254ded61 |
2795 | # string |
eaace00e |
2796 | print CF " 'charset' => '$ldap_charset[$count]'"; |
2797 | } |
2798 | if ( $ldap_maxrows[$count] ) { |
2799 | print CF ",\n"; |
254ded61 |
2800 | # integer |
2801 | print CF " 'maxrows' => $ldap_maxrows[$count]"; |
eaace00e |
2802 | } |
2803 | print CF "\n"; |
2804 | print CF ");\n"; |
2805 | print CF "\n"; |
ebd13f55 |
2806 | } |
b622e1b8 |
2807 | |
254ded61 |
2808 | # string |
4f40a59d |
2809 | print CF "\$addrbook_dsn = '$addrbook_dsn';\n"; |
254ded61 |
2810 | # string |
4f40a59d |
2811 | print CF "\$addrbook_table = '$addrbook_table';\n\n"; |
254ded61 |
2812 | # string |
3499f99f |
2813 | print CF "\$prefs_dsn = '$prefs_dsn';\n"; |
254ded61 |
2814 | # string |
99a6c222 |
2815 | print CF "\$prefs_table = '$prefs_table';\n"; |
254ded61 |
2816 | # string |
99a6c222 |
2817 | print CF "\$prefs_user_field = '$prefs_user_field';\n"; |
254ded61 |
2818 | # string |
99a6c222 |
2819 | print CF "\$prefs_key_field = '$prefs_key_field';\n"; |
254ded61 |
2820 | # string |
99a6c222 |
2821 | print CF "\$prefs_val_field = '$prefs_val_field';\n"; |
52ed2f88 |
2822 | # boolean |
3d01b823 |
2823 | print CF "\$no_list_for_subscribe = $no_list_for_subscribe;\n"; |
47a29326 |
2824 | |
2825 | # string |
3d01b823 |
2826 | print CF "\$smtp_auth_mech = '$smtp_auth_mech';\n"; |
2827 | print CF "\$imap_auth_mech = '$imap_auth_mech';\n"; |
47a29326 |
2828 | # boolean |
3d01b823 |
2829 | print CF "\$use_imap_tls = $use_imap_tls;\n"; |
2830 | print CF "\$use_smtp_tls = $use_smtp_tls;\n"; |
2831 | |
6c499577 |
2832 | print CF "\$session_name = '$session_name';\n"; |
2833 | |
3d01b823 |
2834 | print CF "\n"; |
4a809164 |
2835 | print CF "\@include SM_PATH . 'config/config_local.php';\n"; |
3d01b823 |
2836 | |
2837 | print CF "\n/**\n"; |
2838 | print CF " * Make sure there are no characters after the PHP closing\n"; |
2839 | print CF " * tag below (including newline characters and whitespace).\n"; |
2840 | print CF " * Otherwise, that character will cause the headers to be\n"; |
2841 | print CF " * sent and regular output to begin, which will majorly screw\n"; |
2842 | print CF " * things up when we try to send more headers later.\n"; |
2843 | print CF " */\n"; |
2844 | print CF "?>"; |
2845 | |
2846 | close CF; |
ebd13f55 |
2847 | |
3d01b823 |
2848 | print "Data saved in config.php\n"; |
ebd13f55 |
2849 | } else { |
2850 | print "Error saving config.php: $!\n"; |
2851 | } |
911ad01c |
2852 | } |
a93b12ba |
2853 | |
2854 | sub set_defaults { |
eaace00e |
2855 | system "clear"; |
2856 | print $WHT. "SquirrelMail Configuration : " . $NRM; |
2857 | if ( $config == 1 ) { print "Read: config.php"; } |
2858 | elsif ( $config == 2 ) { print "Read: config_default.php"; } |
2859 | print "\n"; |
2860 | print "---------------------------------------------------------\n"; |
2861 | |
2862 | print "While we have been building SquirrelMail, we have discovered some\n"; |
2863 | print "preferences that work better with some servers that don't work so\n"; |
2864 | print "well with others. If you select your IMAP server, this option will\n"; |
2865 | print "set some pre-defined settings for that server.\n"; |
2866 | print "\n"; |
2867 | print "Please note that you will still need to go through and make sure\n"; |
2868 | print "everything is correct. This does not change everything. There are\n"; |
2869 | print "only a few settings that this will change.\n"; |
2870 | print "\n"; |
2871 | |
2872 | $continue = 0; |
2873 | while ( $continue != 1 ) { |
2874 | print "Please select your IMAP server:\n"; |
2875 | print " cyrus = Cyrus IMAP server\n"; |
2876 | print " uw = University of Washington's IMAP server\n"; |
2877 | print " exchange = Microsoft Exchange IMAP server\n"; |
2878 | print " courier = Courier IMAP server\n"; |
cfe486a7 |
2879 | print " macosx = Mac OS X Mailserver\n"; |
eaace00e |
2880 | print " quit = Do not change anything\n"; |
2881 | print "Command >> "; |
2882 | $server = <STDIN>; |
2883 | $server =~ s/[\r|\n]//g; |
2884 | |
2885 | print "\n"; |
2886 | if ( $server eq "cyrus" ) { |
2887 | $imap_server_type = "cyrus"; |
2888 | $default_folder_prefix = ""; |
2889 | $trash_folder = "INBOX.Trash"; |
2890 | $sent_folder = "INBOX.Sent"; |
2891 | $draft_folder = "INBOX.Drafts"; |
2892 | $show_prefix_option = false; |
2893 | $default_sub_of_inbox = true; |
2894 | $show_contain_subfolders_option = false; |
2895 | $optional_delimiter = "."; |
2896 | $disp_default_folder_prefix = "<none>"; |
2897 | |
2898 | $continue = 1; |
2899 | } elsif ( $server eq "uw" ) { |
2900 | $imap_server_type = "uw"; |
2901 | $default_folder_prefix = "mail/"; |
2902 | $trash_folder = "Trash"; |
2903 | $sent_folder = "Sent"; |
2904 | $draft_folder = "Drafts"; |
2905 | $show_prefix_option = true; |
2906 | $default_sub_of_inbox = false; |
2907 | $show_contain_subfolders_option = true; |
2908 | $optional_delimiter = "/"; |
2909 | $disp_default_folder_prefix = $default_folder_prefix; |
2910 | |
2911 | $continue = 1; |
2912 | } elsif ( $server eq "exchange" ) { |
2913 | $imap_server_type = "exchange"; |
2914 | $default_folder_prefix = ""; |
2915 | $default_sub_of_inbox = true; |
2916 | $trash_folder = "INBOX/Deleted Items"; |
2917 | $sent_folder = "INBOX/Sent Items"; |
2918 | $drafts_folder = "INBOX/Drafts"; |
2919 | $show_prefix_option = false; |
2920 | $show_contain_subfolders_option = false; |
2921 | $optional_delimiter = "detect"; |
2922 | $disp_default_folder_prefix = "<none>"; |
2923 | |
2924 | $continue = 1; |
2925 | } elsif ( $server eq "courier" ) { |
2926 | $imap_server_type = "courier"; |
2927 | $default_folder_prefix = "INBOX."; |
2928 | $trash_folder = "Trash"; |
2929 | $sent_folder = "Sent"; |
2930 | $draft_folder = "Drafts"; |
2931 | $show_prefix_option = false; |
2932 | $default_sub_of_inbox = false; |
2933 | $show_contain_subfolders_option = false; |
2934 | $optional_delimiter = "."; |
2935 | $disp_default_folder_prefix = $default_folder_prefix; |
cfe486a7 |
2936 | |
2937 | $continue = 1; |
2938 | } elsif ( $server eq "macosx" ) { |
2939 | $imap_server_type = "macosx"; |
2940 | $default_folder_prefix = "INBOX/"; |
2941 | $trash_folder = "Trash"; |
2942 | $sent_folder = "Sent"; |
2943 | $draft_folder = "Drafts"; |
2944 | $show_prefix_option = false; |
2945 | $default_sub_of_inbox = true; |
2946 | $show_contain_subfolders_option = false; |
2947 | $optional_delimiter = "detect"; |
2948 | $allow_charset_search = false; |
2949 | $disp_default_folder_prefix = $default_folder_prefix; |
eaace00e |
2950 | |
2951 | $continue = 1; |
2952 | } elsif ( $server eq "quit" ) { |
2953 | $continue = 1; |
2954 | } else { |
2955 | $disp_default_folder_prefix = $default_folder_prefix; |
2956 | print "Unrecognized server: $server\n"; |
2957 | print "\n"; |
2958 | } |
2959 | |
2960 | print " imap_server_type = $imap_server_type\n"; |
2961 | print " default_folder_prefix = $disp_default_folder_prefix\n"; |
2962 | print " trash_folder = $trash_folder\n"; |
2963 | print " sent_folder = $sent_folder\n"; |
2964 | print " draft_folder = $draft_folder\n"; |
2965 | print " show_prefix_option = $show_prefix_option\n"; |
2966 | print " default_sub_of_inbox = $default_sub_of_inbox\n"; |
2967 | print "show_contain_subfolders_option = $show_contain_subfolders_option\n"; |
2968 | print " optional_delimiter = $optional_delimiter\n"; |
2969 | } |
2970 | print "\nPress any key to continue..."; |
2971 | $tmp = <STDIN>; |
a93b12ba |
2972 | } |
8bd9e0dd |
2973 | |
8bd9e0dd |
2974 | # This subroutine corrects relative paths to ensure they |
2975 | # will work within the SM space. If the path falls within |
2976 | # the SM directory tree, the SM_PATH variable will be |
2977 | # prepended to the path, if not, then the path will be |
e6566358 |
2978 | # converted to an absolute path, e.g. |
2222aed0 |
2979 | # '../images/logo.gif' --> SM_PATH . 'images/logo.gif' |
2980 | # 'images/logo.gif' --> SM_PATH . 'config/images/logo.gif' |
2981 | # '/absolute/path/logo.gif' --> '/absolute/path/logo.gif' |
2982 | # 'http://whatever/' --> 'http://whatever' |
8bd9e0dd |
2983 | sub change_to_SM_path() { |
2984 | my ($old_path) = @_; |
2985 | my $new_path = ''; |
2986 | my @rel_path; |
2987 | my @abs_path; |
2988 | my $subdir; |
2989 | |
2990 | # If the path is absolute, don't bother. |
2991 | return "\'" . $old_path . "\'" if ( $old_path eq ''); |
a28a56da |
2992 | return "\'" . $old_path . "\'" if ( $old_path =~ /^(\/|http)/ ); |
2993 | return $old_path if ( $old_path =~ /^(\$|SM_PATH)/); |
93c06fa2 |
2994 | |
8bd9e0dd |
2995 | # For relative paths, split on '../' |
2996 | @rel_path = split(/\.\.\//, $old_path); |
2997 | |
2998 | if ( $#rel_path > 1 ) { |
2999 | # more than two levels away. Make it absolute. |
3000 | @abs_path = split(/\//, $dir); |
3001 | foreach $subdir (@rel_path) { |
3002 | if ($subdir eq '') { |
3003 | pop @abs_path; |
3004 | } else { |
3005 | push @abs_path, $subdir; |
3006 | } |
3007 | } |
3008 | foreach $subdir (@abs_path) { |
3009 | $new_path .= $subdir . '/'; |
3010 | } |
3011 | } elsif ( $#rel_path > 0 ) { |
3012 | # it's within the SM tree, prepend SM_PATH |
3013 | $new_path = $old_path; |
3014 | $new_path =~ s/^\.\.\//SM_PATH . \'/; |
3015 | $new_path .= '\''; |
3016 | } else { |
3017 | # Last, it's a relative path without any leading '.' |
e6566358 |
3018 | # Prepend SM_PATH and config, since the paths are |
3019 | # relative to the config directory |
3020 | $new_path = "SM_PATH . \'config/" . $old_path . "\'"; |
8bd9e0dd |
3021 | } |
3022 | |
3023 | return $new_path; |
3024 | } |
3025 | |
e6566358 |
3026 | |
3027 | # Change SM_PATH to admin-friendly version, e.g.: |
3028 | # SM_PATH . 'images/logo.gif' --> '../images/logo.gif' |
3029 | # SM_PATH . 'config/some.php' --> 'some.php' |
3030 | # '/absolute/path/logo.gif' --> '/absolute/path/logo.gif' |
3031 | # 'http://whatever/' --> 'http://whatever' |
8bd9e0dd |
3032 | sub change_to_rel_path() { |
3033 | my ($old_path) = @_; |
e6566358 |
3034 | my $new_path = $old_path; |
8bd9e0dd |
3035 | |
3036 | if ( $old_path =~ /^SM_PATH/ ) { |
8bd9e0dd |
3037 | $new_path =~ s/^SM_PATH . \'/\.\.\//; |
e6566358 |
3038 | $new_path =~ s/\.\.\/config\///; |
8bd9e0dd |
3039 | } |
3040 | |
3041 | return $new_path; |
3042 | } |
b47821fb |
3043 | |
3044 | sub detect_auth_support { |
3045 | # Attempts to auto-detect if a specific auth mechanism is supported. |
3046 | # Called by 'command112a' and 'command112b' |
3047 | # ARGS: service-name (IMAP or SMTP), host:port, mech-name (ie. CRAM-MD5) |
3048 | |
3049 | # Misc setup |
3050 | use IO::Socket; |
3051 | my $service = shift; |
3052 | my $host = shift; |
3053 | my $mech = shift; |
3054 | # Sanity checks |
3055 | if ((!defined($service)) or (!defined($host)) or (!defined($mech))) { |
3056 | # Error - wrong # of args |
3057 | print "BAD ARGS!\n"; |
3058 | return undef; |
3059 | } |
3060 | |
3061 | if ($service eq 'SMTP') { |
3062 | $cmd = "AUTH $mech\n"; |
3063 | $logout = "QUIT\n"; |
3064 | } elsif ($service eq 'IMAP') { |
3065 | $cmd = "A01 AUTHENTICATE $mech\n"; |
3066 | $logout = "C01 LOGOUT\n"; |
3067 | } else { |
3068 | # unknown service - whoops. |
3069 | return undef; |
3070 | } |
3071 | |
3072 | # Get this show on the road |
3073 | my $sock=IO::Socket::INET->new($host); |
3074 | if (!defined($sock)) { |
3075 | # Connect failed |
3076 | return undef; |
3077 | } |
3078 | my $discard = <$sock>; # Server greeting/banner - who cares.. |
fe0b18b3 |
3079 | |
3080 | if ($service eq 'SMTP') { |
3081 | # Say hello first.. |
3082 | print $sock "helo $domain\n"; |
3083 | $discard = <$sock>; # Yeah yeah, you're happy to see me.. |
3084 | } |
b47821fb |
3085 | print $sock $cmd; |
3086 | |
3087 | my $response = <$sock>; |
fe0b18b3 |
3088 | chomp($response); |
b47821fb |
3089 | if (!defined($response)) { |
3090 | return undef; |
3091 | } |
3092 | |
3093 | # So at this point, we have a response, and it is (hopefully) valid. |
3094 | if ($service eq 'SMTP') { |
3095 | if (($response =~ /^535/) or ($response =~/^502/)) { |
3096 | # Not supported |
3097 | close $sock; |
3098 | return 'NO'; |
fe0b18b3 |
3099 | } elsif ($response =~ /^503/) { |
3100 | #Something went wrong |
3101 | return undef; |
b47821fb |
3102 | } |
3103 | } elsif ($service eq 'IMAP') { |
3104 | if ($response =~ /^A01/) { |
3105 | # Not supported |
3106 | close $sock; |
3107 | return 'NO'; |
3108 | } |
3109 | } else { |
3110 | # Unknown service - this shouldn't be able to happen. |
3111 | close $sock; |
3112 | return undef; |
3113 | } |
3114 | |
3115 | # If it gets here, the mech is supported |
3116 | print $sock "*\n"; # Attempt to cancel authentication |
3117 | print $sock $logout; # Try to log out, but we don't really care if this fails |
3118 | close $sock; |
3119 | return 'YES'; |
3120 | } |