Tidy up indenting, etc using perltidy
[squirrelmail.git] / config / conf.pl
1 #!/usr/bin/env perl
2 # conf.pl
3 # Luke Ehresman (luke@squirrelmail.org)
4 #
5 # A simple configure script to configure squirrelmail
6 #
7 # $Id$
8 ############################################################
9 $conf_pl_version = "1.2.0";
10
11 ############################################################
12 # Check what directory we're supposed to be running in, and
13 # change there if necessary. File::Basename has been in
14 # Perl since at least 5.003_7, and nobody sane runs anything
15 # before that, but just in case.
16 ############################################################
17
18 if ( eval q{require "File/Basename.pm"} ) {
19 my $dir = File::Basename::dirname($0);
20 chdir($dir);
21 }
22
23 ############################################################
24 # Some people try to run this as a CGI. That's wrong!
25 ############################################################
26 if ( defined( $ENV{'PATH_INFO'} )
27 || defined( $ENV{'QUERY_STRING'} )
28 || defined( $ENV{'REQUEST_METHOD'} ) ) {
29 print "Content-Type: text/html\n\n";
30 print "You must run this script from the command line.";
31 exit;
32 }
33
34 ############################################################
35 # First, lets read in the data already in there...
36 ############################################################
37 if ( -e "config.php" ) {
38 open( FILE, "config.php" );
39 while ( $line = <FILE> ) {
40 $line =~ s/^\s+//;
41 $line =~ s/^\$//;
42 $var = $line;
43
44 $var =~ s/=/EQUALS/;
45 if ( $var =~ /^([a-z]|[A-Z])/ ) {
46 @o = split ( /\s*EQUALS\s*/, $var );
47 if ( $o[0] eq "config_version" ) {
48 $o[1] =~ s/[\n|\r]//g;
49 $o[1] =~ s/[\'|\"];\s*$//;
50 $o[1] =~ s/;$//;
51 $o[1] =~ s/^[\'|\"]//;
52
53 $config_version = $o[1];
54 close(FILE);
55 }
56 }
57 }
58 close(FILE);
59
60 if ( $config_version ne $conf_pl_version ) {
61 system "clear";
62 print $WHT. "WARNING:\n" . $NRM;
63 print " The file \"config/config.php\" was found, but it is for\n";
64 print " an older version of SquirrelMail. It is possible to still\n";
65 print " read the defaults from this file but be warned that many\n";
66 print " preferences change between versions. It is recommended that\n";
67 print " you start with a clean config.php for each upgrade that you\n";
68 print " do. To do this, just move config/config.php out of the way.\n";
69 print "\n";
70 print "Continue loading with the old config.php [y/N]? ";
71 $ctu = <STDIN>;
72
73 if ( ( $ctu !~ /^y\n/i ) || ( $ctu =~ /^\n/ ) ) {
74 exit;
75 }
76
77 print "\nDo you want me to stop warning you [y/N]? ";
78 $ctu = <STDIN>;
79 if ( $ctu =~ /^y\n/i ) {
80 $print_config_version = $conf_pl_version;
81 } else {
82 $print_config_version = $config_version;
83 }
84 } else {
85 $print_config_version = $config_version;
86 }
87
88 $config = 1;
89 open( FILE, "config.php" );
90 } elsif ( -e "config_default.php" ) {
91 open( FILE, "config_default.php" );
92 while ( $line = <FILE> ) {
93 $line =~ s/^\s+//;
94 $line =~ s/^\$//;
95 $var = $line;
96
97 $var =~ s/=/EQUALS/;
98 if ( $var =~ /^([a-z]|[A-Z])/ ) {
99 @o = split ( /\s*EQUALS\s*/, $var );
100 if ( $o[0] eq "config_version" ) {
101 $o[1] =~ s/[\n|\r]//g;
102 $o[1] =~ s/[\'|\"];\s*$//;
103 $o[1] =~ s/;$//;
104 $o[1] =~ s/^[\'|\"]//;
105
106 $config_version = $o[1];
107 close(FILE);
108 }
109 }
110 }
111 close(FILE);
112
113 if ( $config_version ne $conf_pl_version ) {
114 system "clear";
115 print $WHT. "WARNING:\n" . $NRM;
116 print " You are trying to use a 'config_default.php' from an older\n";
117 print " version of SquirrelMail. This is HIGHLY unrecommended. You\n";
118 print " should get the 'config_default.php' that matches the version\n";
119 print " of SquirrelMail that you are running. You can get this from\n";
120 print " the SquirrelMail web page by going to the following URL:\n";
121 print " http://www.squirrelmail.org.\n";
122 print "\n";
123 print "Continue loading with old config_default.php (a bad idea) [y/N]? ";
124 $ctu = <STDIN>;
125
126 if ( ( $ctu !~ /^y\n/i ) || ( $ctu =~ /^\n/ ) ) {
127 exit;
128 }
129
130 print "\nDo you want me to stop warning you [y/N]? ";
131 $ctu = <STDIN>;
132 if ( $ctu =~ /^y\n/i ) {
133 $print_config_version = $conf_pl_version;
134 } else {
135 $print_config_version = $config_version;
136 }
137 } else {
138 $print_config_version = $config_version;
139 }
140 $config = 2;
141 open( FILE, "config_default.php" );
142 } else {
143 print "No configuration file found. Please get config_default.php\n";
144 print "or config.php before running this again. This program needs\n";
145 print "a default config file to get default values.\n";
146 exit;
147 }
148
149 # Read and parse the current configuration file
150 # (either config.php or config_default.php).
151 while ( $line = <FILE> ) {
152 $line =~ s/^\s+//;
153 $line =~ s/^\$//;
154 $var = $line;
155
156 $var =~ s/=/EQUALS/;
157 if ( $var =~ /^([a-z]|[A-Z])/ ) {
158 @options = split ( /\s*EQUALS\s*/, $var );
159 $options[1] =~ s/[\n|\r]//g;
160 $options[1] =~ s/[\'|\"];\s*$//;
161 $options[1] =~ s/;$//;
162 $options[1] =~ s/^[\'|\"]//;
163
164 if ( $options[0] =~ /^theme\[[0-9]+\]\[['|"]PATH['|"]\]/ ) {
165 $sub = $options[0];
166 $sub =~ s/\]\[['|"]PATH['|"]\]//;
167 $sub =~ s/.*\[//;
168 if ( -e "../themes" ) {
169 $options[1] =~ s/^\.\.\/config/\.\.\/themes/;
170 }
171 $theme_path[$sub] = $options[1];
172 } elsif ( $options[0] =~ /^theme\[[0-9]+\]\[['|"]NAME['|"]\]/ ) {
173 $sub = $options[0];
174 $sub =~ s/\]\[['|"]NAME['|"]\]//;
175 $sub =~ s/.*\[//;
176 $theme_name[$sub] = $options[1];
177 } elsif ( $options[0] =~ /^plugins\[[0-9]+\]/ ) {
178 $sub = $options[0];
179 $sub =~ s/\]//;
180 $sub =~ s/^plugins\[//;
181 $plugins[$sub] = $options[1];
182 } elsif ( $options[0] =~ /^ldap_server\[[0-9]+\]/ ) {
183 $sub = $options[0];
184 $sub =~ s/\]//;
185 $sub =~ s/^ldap_server\[//;
186 $continue = 0;
187 while ( ( $tmp = <FILE> ) && ( $continue != 1 ) ) {
188 if ( $tmp =~ /\);\s*$/ ) {
189 $continue = 1;
190 }
191
192 if ( $tmp =~ /^\s*[\'|\"]host[\'|\"]/i ) {
193 $tmp =~ s/^\s*[\'|\"]host[\'|\"]\s*=>\s*[\'|\"]//i;
194 $tmp =~ s/[\'|\"],?\s*$//;
195 $tmp =~ s/[\'|\"]\);\s*$//;
196 $host = $tmp;
197 } elsif ( $tmp =~ /^\s*[\'|\"]base[\'|\"]/i ) {
198 $tmp =~ s/^\s*[\'|\"]base[\'|\"]\s*=>\s*[\'|\"]//i;
199 $tmp =~ s/[\'|\"],?\s*$//;
200 $tmp =~ s/[\'|\"]\);\s*$//;
201 $base = $tmp;
202 } elsif ( $tmp =~ /^\s*[\'|\"]charset[\'|\"]/i ) {
203 $tmp =~ s/^\s*[\'|\"]charset[\'|\"]\s*=>\s*[\'|\"]//i;
204 $tmp =~ s/[\'|\"],?\s*$//;
205 $tmp =~ s/[\'|\"]\);\s*$//;
206 $charset = $tmp;
207 } elsif ( $tmp =~ /^\s*[\'|\"]port[\'|\"]/i ) {
208 $tmp =~ s/^\s*[\'|\"]port[\'|\"]\s*=>\s*[\'|\"]//i;
209 $tmp =~ s/[\'|\"],?\s*$//;
210 $tmp =~ s/[\'|\"]\);\s*$//;
211 $port = $tmp;
212 } elsif ( $tmp =~ /^\s*[\'|\"]maxrows[\'|\"]/i ) {
213 $tmp =~ s/^\s*[\'|\"]maxrows[\'|\"]\s*=>\s*[\'|\"]//i;
214 $tmp =~ s/[\'|\"],?\s*$//;
215 $tmp =~ s/[\'|\"]\);\s*$//;
216 $maxrows = $tmp;
217 } elsif ( $tmp =~ /^\s*[\'|\"]name[\'|\"]/i ) {
218 $tmp =~ s/^\s*[\'|\"]name[\'|\"]\s*=>\s*[\'|\"]//i;
219 $tmp =~ s/[\'|\"],?\s*$//;
220 $tmp =~ s/[\'|\"]\);\s*$//;
221 $name = $tmp;
222 }
223 }
224 $ldap_host[$sub] = $host;
225 $ldap_base[$sub] = $base;
226 $ldap_name[$sub] = $name;
227 $ldap_port[$sub] = $port;
228 $ldap_maxrows[$sub] = $maxrows;
229 $ldap_charset[$sub] = $charset;
230 } else {
231 ${ $options[0] } = $options[1];
232 }
233 }
234 }
235 close FILE;
236 if ( $useSendmail ne "true" ) {
237 $useSendmail = "false";
238 }
239 if ( !$sendmail_path ) {
240 $sendmail_path = "/usr/sbin/sendmail";
241 }
242 if ( !$default_unseen_notify ) {
243 $default_unseen_notify = 2;
244 }
245 if ( !$default_unseen_type ) {
246 $default_unseen_type = 1;
247 }
248 if ( !$config_use_color ) {
249 $config_use_color = 0;
250 }
251 if ( !$invert_time ) {
252 $invert_time = "false";
253 }
254 if ( !$force_username_lowercase ) {
255 $force_username_lowercase = "false";
256 }
257 if ( !$optional_delimiter ) {
258 $optional_delimiter = "detect";
259 }
260 if ( !$use_authenticated_smtp ) {
261 $use_authenticated_smtp = "false";
262 }
263 if ( !$auto_create_special ) {
264 $auto_create_special = "false";
265 }
266 if ( !$default_use_priority ) {
267 $default_use_priority = "true";
268 }
269 if ( !$hide_sm_attributions ) {
270 $hide_sm_attributions = "false";
271 }
272 if ( !$default_use_mdn ) {
273 $default_use_mdn = "true";
274 }
275 if ( !$frame_top ) {
276 $frame_top = "_top";
277 }
278 if ( !$edit_identity ) {
279 $edit_identity = "true";
280 }
281 if ( !$edit_name ) {
282 $edit_name = "true";
283 }
284
285 if ( $ARGV[0] eq '--install-plugin' ) {
286 print "Activating plugin " . $ARGV[1] . "\n";
287 push @plugins, $ARGV[1];
288 save_data();
289 exit(0);
290 } elsif ( $ARGV[0] eq '--remove-plugin' ) {
291 print "Removing plugin " . $ARGV[1] . "\n";
292 foreach $plugin (@plugins) {
293 if ( $plugin ne $ARGV[1] ) {
294 push @newplugins, $plugin;
295 }
296 }
297 @plugins = @newplugins;
298 save_data();
299 exit(0);
300 }
301
302 #####################################################################################
303 if ( $config_use_color == 1 ) {
304 $WHT = "\x1B[37;1m";
305 $NRM = "\x1B[0m";
306 } else {
307 $WHT = "";
308 $NRM = "";
309 $config_use_color = 2;
310 }
311
312 while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
313 system "clear";
314 print $WHT. "SquirrelMail Configuration : " . $NRM;
315 if ( $config == 1 ) { print "Read: config.php"; }
316 elsif ( $config == 2 ) { print "Read: config_default.php"; }
317 print " ($print_config_version)\n";
318 print "---------------------------------------------------------\n";
319
320 if ( $menu == 0 ) {
321 print $WHT. "Main Menu --\n" . $NRM;
322 print "1. Organization Preferences\n";
323 print "2. Server Settings\n";
324 print "3. Folder Defaults\n";
325 print "4. General Options\n";
326 print "5. Themes\n";
327 print "6. Address Books (LDAP)\n";
328 print "7. Message of the Day (MOTD)\n";
329 print "8. Plugins\n";
330 print "9. Database\n";
331 print "\n";
332 print "D. Set pre-defined settings for specific IMAP servers\n";
333 print "\n";
334 } elsif ( $menu == 1 ) {
335 print $WHT. "Organization Preferences\n" . $NRM;
336 print "1. Organization Name : $WHT$org_name$NRM\n";
337 print "2. Organization Logo : $WHT$org_logo$NRM\n";
338 print "3. Organization Title : $WHT$org_title$NRM\n";
339 print "4. Signout Page : $WHT$signout_page$NRM\n";
340 print "5. Default Language : $WHT$squirrelmail_default_language$NRM\n";
341 print "6. Top Frame : $WHT$frame_top$NRM\n";
342 print "\n";
343 print "R Return to Main Menu\n";
344 } elsif ( $menu == 2 ) {
345 print $WHT. "Server Settings\n" . $NRM;
346 print "1. Domain : $WHT$domain$NRM\n";
347 print "2. IMAP Server : $WHT$imapServerAddress$NRM\n";
348 print "3. IMAP Port : $WHT$imapPort$NRM\n";
349 print "4. Use Sendmail/SMTP : $WHT";
350 if ( lc($useSendmail) eq "true" ) {
351 print "Sendmail";
352 } else {
353 print "SMTP";
354 }
355 print "$NRM\n";
356 if ( lc($useSendmail) eq "true" ) {
357 print "5. Sendmail Path : $WHT$sendmail_path$NRM\n";
358 } else {
359 print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n";
360 print "7. SMTP Port : $WHT$smtpPort$NRM\n";
361 print "8. Authenticated SMTP : $WHT$use_authenticated_smtp$NRM\n";
362 }
363 print "9. Server : $WHT$imap_server_type$NRM\n";
364 print "10. Invert Time : $WHT$invert_time$NRM\n";
365 print "11. Delimiter : $WHT$optional_delimiter$NRM\n";
366 print "\n";
367 print "R Return to Main Menu\n";
368 } elsif ( $menu == 3 ) {
369 print $WHT. "Folder Defaults\n" . $NRM;
370 print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
371 print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
372 print "3. Trash Folder : $WHT$trash_folder$NRM\n";
373 print "4. Sent Folder : $WHT$sent_folder$NRM\n";
374 print "5. Drafts Folder : $WHT$draft_folder$NRM\n";
375 print "6. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
376 print "7. By default, move to sent : $WHT$default_move_to_sent$NRM\n";
377 print "8. By default, save as draft : $WHT$default_save_as_draft$NRM\n";
378 print "9. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
379 print "10. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
380 print "11. Auto Expunge : $WHT$auto_expunge$NRM\n";
381 print "12. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
382 print "13. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
383 print "14. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n";
384 print "15. Default Unseen Type : $WHT$default_unseen_type$NRM\n";
385 print "16. Auto Create Special Folders : $WHT$auto_create_special$NRM\n";
386 print "17. Don't move folders into Trash : $WHT$delete_folder$NRM\n";
387 print "\n";
388 print "R Return to Main Menu\n";
389 } elsif ( $menu == 4 ) {
390 print $WHT. "General Options\n" . $NRM;
391 print "1. Default Charset : $WHT$default_charset$NRM\n";
392 print "2. Data Directory : $WHT$data_dir$NRM\n";
393 print "3. Attachment Directory : $WHT$attachment_dir$NRM\n";
394 print "4. Directory Hash Level : $WHT$dir_hash_level$NRM\n";
395 print "5. Default Left Size : $WHT$default_left_size$NRM\n";
396 print "6. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n";
397 print "7. Allow use of priority : $WHT$default_use_priority$NRM\n";
398 print "8. Hide SM attributions : $WHT$hide_sm_attributions$NRM\n";
399 print "9. Allow use of receipts : $WHT$default_use_mdn$NRM\n";
400 print "10. Allow editing of identity : $WHT$edit_identity$NRM\n";
401
402 if ( lc($edit_identity) eq "false" ) {
403 print "11. Allow editing of name : $WHT$edit_name$NRM\n";
404 }
405 print "\n";
406 print "R Return to Main Menu\n";
407 } elsif ( $menu == 5 ) {
408 print $WHT. "Themes\n" . $NRM;
409 print "1. Change Themes\n";
410 for ( $count = 0 ; $count <= $#theme_name ; $count++ ) {
411 print " > $theme_name[$count]\n";
412 }
413 print "2. CSS File : $WHT$theme_css$NRM\n";
414 print "\n";
415 print "R Return to Main Menu\n";
416 } elsif ( $menu == 6 ) {
417 print $WHT. "Address Books (LDAP)\n" . $NRM;
418 print "1. Change Servers\n";
419 for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
420 print " > $ldap_host[$count]\n";
421 }
422 print
423 "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n";
424 print "\n";
425 print "R Return to Main Menu\n";
426 } elsif ( $menu == 7 ) {
427 print $WHT. "Message of the Day (MOTD)\n" . $NRM;
428 print "\n$motd\n";
429 print "\n";
430 print "1 Edit the MOTD\n";
431 print "\n";
432 print "R Return to Main Menu\n";
433 } elsif ( $menu == 8 ) {
434 print $WHT. "Plugins\n" . $NRM;
435 print " Installed Plugins\n";
436 $num = 0;
437 for ( $count = 0 ; $count <= $#plugins ; $count++ ) {
438 $num = $count + 1;
439 print " $num. $plugins[$count]\n";
440 }
441 print "\n Available Plugins:\n";
442 opendir( DIR, "../plugins" );
443 @files = readdir(DIR);
444 $pos = 0;
445 @unused_plugins = ();
446 for ( $i = 0 ; $i <= $#files ; $i++ ) {
447 if ( -d "../plugins/" . $files[$i] && $files[$i] !~ /^\./ && $files[$i] ne "CVS" ) {
448 $match = 0;
449 for ( $k = 0 ; $k <= $#plugins ; $k++ ) {
450 if ( $plugins[$k] eq $files[$i] ) {
451 $match = 1;
452 }
453 }
454 if ( $match == 0 ) {
455 $unused_plugins[$pos] = $files[$i];
456 $pos++;
457 }
458 }
459 }
460
461 for ( $i = 0 ; $i <= $#unused_plugins ; $i++ ) {
462 $num = $num + 1;
463 print " $num. $unused_plugins[$i]\n";
464 }
465 closedir DIR;
466
467 print "\n";
468 print "A Sanitize all plugins for use with Squirrelmail 1.2\n";
469 print "\n";
470 print "R Return to Main Menu\n";
471 } elsif ( $menu == 9 ) {
472 print $WHT. "Database\n" . $NRM;
473 print "1. DSN for Address Book : $WHT$addrbook_dsn$NRM\n";
474 print "2. Table for Address Book : $WHT$addrbook_table$NRM\n";
475 print "3. DSN for Preferences : $WHT$prefs_dsn$NRM\n";
476 print "4. Table for Preferences : $WHT$prefs_table$NRM\n";
477 print "\n";
478 print "S Save data\n";
479 print "R Return to Main Menu\n";
480 }
481 if ( $config_use_color == 1 ) {
482 print "C. Turn color off\n";
483 } else {
484 print "C. Turn color on\n";
485 }
486 print "S Save data\n";
487 print "Q Quit\n";
488
489 print "\n";
490 print "Command >> " . $WHT;
491 $command = <STDIN>;
492 $command =~ s/[\n|\r]//g;
493 $command =~ tr/A-Z/a-z/;
494 print "$NRM\n";
495
496 # Read the commands they entered.
497 if ( $command eq "r" ) {
498 $menu = 0;
499 } elsif ( $command eq "s" ) {
500 save_data();
501 print "Press enter to continue...";
502 $tmp = <STDIN>;
503 $saved = 1;
504 } elsif ( ( $command eq "q" ) && ( $saved == 0 ) ) {
505 print "You have not saved your data.\n";
506 print "Save? [" . $WHT . "Y" . $NRM . "/n]: ";
507 $save = <STDIN>;
508 if ( ( $save =~ /^y/i ) || ( $save =~ /^\s*$/ ) ) {
509 save_data();
510 }
511 } elsif ( $command eq "c" ) {
512 if ( $config_use_color == 1 ) {
513 $config_use_color = 2;
514 $WHT = "";
515 $NRM = "";
516 } else {
517 $config_use_color = 1;
518 $WHT = "\x1B[37;1m";
519 $NRM = "\x1B[0m";
520 }
521 } elsif ( $command eq "d" && $menu == 0 ) {
522 set_defaults();
523 } else {
524 $saved = 0;
525 if ( $menu == 0 ) {
526 if ( ( $command > 0 ) && ( $command < 10 ) ) {
527 $menu = $command;
528 }
529 } elsif ( $menu == 1 ) {
530 if ( $command == 1 ) { $org_name = command1(); }
531 elsif ( $command == 2 ) { $org_logo = command2(); }
532 elsif ( $command == 3 ) { $org_title = command3(); }
533 elsif ( $command == 4 ) { $signout_page = command4(); }
534 elsif ( $command == 5 ) { $squirrelmail_default_language = command5(); }
535 elsif ( $command == 6 ) { $frame_top = command6(); }
536 } elsif ( $menu == 2 ) {
537 if ( $command == 1 ) { $domain = command11(); }
538 elsif ( $command == 2 ) { $imapServerAddress = command12(); }
539 elsif ( $command == 3 ) { $imapPort = command13(); }
540 elsif ( $command == 4 ) { $useSendmail = command14(); }
541 elsif ( $command == 5 ) { $sendmail_path = command15(); }
542 elsif ( $command == 6 ) { $smtpServerAddress = command16(); }
543 elsif ( $command == 7 ) { $smtpPort = command17(); }
544 elsif ( $command == 8 ) { $use_authenticated_smtp = command18(); }
545 elsif ( $command == 9 ) { $imap_server_type = command19(); }
546 elsif ( $command == 10 ) { $invert_time = command110(); }
547 elsif ( $command == 11 ) { $optional_delimiter = command111(); }
548 } elsif ( $menu == 3 ) {
549 if ( $command == 1 ) { $default_folder_prefix = command21(); }
550 elsif ( $command == 2 ) { $show_prefix_option = command22(); }
551 elsif ( $command == 3 ) { $trash_folder = command23a(); }
552 elsif ( $command == 4 ) { $sent_folder = command23b(); }
553 elsif ( $command == 5 ) { $draft_folder = command23c(); }
554 elsif ( $command == 6 ) { $default_move_to_trash = command24a(); }
555 elsif ( $command == 7 ) { $default_move_to_sent = command24b(); }
556 elsif ( $command == 8 ) { $default_save_as_draft = command24c(); }
557 elsif ( $command == 9 ) { $list_special_folders_first = command27(); }
558 elsif ( $command == 10 ) { $use_special_folder_color = command28(); }
559 elsif ( $command == 11 ) { $auto_expunge = command29(); }
560 elsif ( $command == 12 ) { $default_sub_of_inbox = command210(); }
561 elsif ( $command == 13 ) { $show_contain_subfolders_option = command211(); }
562 elsif ( $command == 14 ) { $default_unseen_notify = command212(); }
563 elsif ( $command == 15 ) { $default_unseen_type = command213(); }
564 elsif ( $command == 16 ) { $auto_create_special = command214(); }
565 elsif ( $command == 17 ) { $delete_folder = command215(); }
566 } elsif ( $menu == 4 ) {
567 if ( $command == 1 ) { $default_charset = command31(); }
568 elsif ( $command == 2 ) { $data_dir = command33a(); }
569 elsif ( $command == 3 ) { $attachment_dir = command33b(); }
570 elsif ( $command == 4 ) { $dir_hash_level = command33c(); }
571 elsif ( $command == 5 ) { $default_left_size = command35(); }
572 elsif ( $command == 6 ) { $force_username_lowercase = command36(); }
573 elsif ( $command == 7 ) { $default_use_priority = command37(); }
574 elsif ( $command == 8 ) { $hide_sm_attributions = command38(); }
575 elsif ( $command == 9 ) { $default_use_mdn = command39(); }
576 elsif ( $command == 10 ) { $edit_identity = command310(); }
577 elsif ( $command == 11 ) { $edit_name = command311(); }
578 } elsif ( $menu == 5 ) {
579 if ( $command == 1 ) { command41(); }
580 elsif ( $command == 2 ) { $theme_css = command42(); }
581 } elsif ( $menu == 6 ) {
582 if ( $command == 1 ) { command61(); }
583 elsif ( $command == 2 ) { command62(); }
584 } elsif ( $menu == 7 ) {
585 if ( $command == 1 ) { $motd = command71(); }
586 } elsif ( $menu == 8 ) {
587 if ( $command =~ /^[0-9]+/ ) { @plugins = command81(); }
588 elsif ( $command eq "a" ) { command8s(); }
589 } elsif ( $menu == 9 ) {
590 if ( $command == 1 ) { $addrbook_dsn = command91(); }
591 elsif ( $command == 2 ) { $addrbook_table = command92(); }
592 elsif ( $command == 3 ) { $prefs_dsn = command93(); }
593 elsif ( $command == 4 ) { $prefs_table = command94(); }
594 }
595 }
596 }
597
598 ####################################################################################
599
600 # org_name
601 sub command1 {
602 print "We have tried to make the name SquirrelMail as transparent as\n";
603 print "possible. If you set up an organization name, most places where\n";
604 print "SquirrelMail would take credit will be credited to your organization.\n";
605 print "\n";
606 print "[$WHT$org_name$NRM]: $WHT";
607 $new_org_name = <STDIN>;
608 if ( $new_org_name eq "\n" ) {
609 $new_org_name = $org_name;
610 } else {
611 $new_org_name =~ s/[\r|\n]//g;
612 }
613 return $new_org_name;
614 }
615
616 # org_logo
617 sub command2 {
618 print "Your organization's logo is an image that will be displayed at\n";
619 print "different times throughout SquirrelMail. This is asking for the\n";
620 print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
621 print "(../images/logo.jpg) path to your logo.\n";
622 print "\n";
623 print "[$WHT$org_logo$NRM]: $WHT";
624 $new_org_logo = <STDIN>;
625 if ( $new_org_logo eq "\n" ) {
626 $new_org_logo = $org_logo;
627 } else {
628 $new_org_logo =~ s/[\r|\n]//g;
629 }
630 return $new_org_logo;
631 }
632
633 # org_title
634 sub command3 {
635 print "A title is what is displayed at the top of the browser window in\n";
636 print "the titlebar. Usually this will end up looking something like:\n";
637 print "\"Netscape: $org_title\"\n";
638 print "\n";
639 print "[$WHT$org_title$NRM]: $WHT";
640 $new_org_title = <STDIN>;
641 if ( $new_org_title eq "\n" ) {
642 $new_org_title = $org_title;
643 } else {
644 $new_org_title =~ s/[\r|\n]//g;
645 }
646 return $new_org_title;
647 }
648
649 # signout_page
650 sub command4 {
651 print "When users click the Sign Out button they will be logged out and\n";
652 print "then sent to signout_page. If signout_page is left empty,\n";
653 print "(hit space and then return) they will be taken, as normal,\n";
654 print "to the default and rather sparse SquirrelMail signout page.\n";
655 print "\n";
656 print "[$WHT$signout_page$NRM]: $WHT";
657 $new_signout_page = <STDIN>;
658 if ( $new_signout_page eq "\n" ) {
659 $new_signout_page = $signout_page;
660 } else {
661 $new_signout_page =~ s/[\r|\n]//g;
662 $new_signout_page =~ s/^\s+$//g;
663 }
664 return $new_signout_page;
665 }
666
667 # Default language
668 sub command5 {
669 print "SquirrelMail attempts to set the language in many ways. If it\n";
670 print "can not figure it out in another way, it will default to this\n";
671 print "language. Please use the two-letter code for the desired language.\n";
672 print "\n";
673 print "[$WHT$squirrelmail_default_language$NRM]: $WHT";
674 $new_signout_page = <STDIN>;
675 if ( $new_signout_page eq "\n" ) {
676 $new_signout_page = $squirrelmail_default_language;
677 } else {
678 $new_signout_page =~ s/[\r|\n]//g;
679 $new_signout_page =~ s/^\s+$//g;
680 }
681 return $new_signout_page;
682 }
683
684 # Default top frame
685 sub command6 {
686 print "SquirrelMail defaults to using the whole of the browser window.\n";
687 print "This allows you to keep it within a specified frame. The default\n";
688 print "is '_top'\n";
689 print "\n";
690 print "[$WHT$frame_top$NRM]: $WHT";
691 $new_frame_top = <STDIN>;
692 if ( $new_frame_top eq "\n" ) {
693 $new_frame_top = '_top';
694 } else {
695 $new_frame_top =~ s/[\r|\n]//g;
696 $new_frame_top =~ s/^\s+$//g;
697 }
698 return $new_frame_top;
699 }
700
701 ####################################################################################
702
703 # domain
704 sub command11 {
705 print "The domain name is the suffix at the end of all email messages. If\n";
706 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
707 print "would be myorg.com.\n";
708 print "\n";
709 print "[$WHT$domain$NRM]: $WHT";
710 $new_domain = <STDIN>;
711 if ( $new_domain eq "\n" ) {
712 $new_domain = $domain;
713 } else {
714 $new_domain =~ s/[\r|\n]//g;
715 }
716 return $new_domain;
717 }
718
719 # imapServerAddress
720 sub command12 {
721 print "This is the address where your IMAP server resides.\n";
722 print "[$WHT$imapServerAddress$NRM]: $WHT";
723 $new_imapServerAddress = <STDIN>;
724 if ( $new_imapServerAddress eq "\n" ) {
725 $new_imapServerAddress = $imapServerAddress;
726 } else {
727 $new_imapServerAddress =~ s/[\r|\n]//g;
728 }
729 return $new_imapServerAddress;
730 }
731
732 # imapPort
733 sub command13 {
734 print "This is the port that your IMAP server is on. Usually this is 143.\n";
735 print "[$WHT$imapPort$NRM]: $WHT";
736 $new_imapPort = <STDIN>;
737 if ( $new_imapPort eq "\n" ) {
738 $new_imapPort = $imapPort;
739 } else {
740 $new_imapPort =~ s/[\r|\n]//g;
741 }
742 return $new_imapPort;
743 }
744
745 # useSendmail
746 sub command14 {
747 print "You now need to choose the method that you will use for sending\n";
748 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
749 print "or use sendmail directly.\n";
750 if ( lc($useSendmail) eq "true" ) {
751 $default_value = "1";
752 } else {
753 $default_value = "2";
754 }
755 print "\n";
756 print " 1. Sendmail\n";
757 print " 2. SMTP\n";
758 print "Your choice [1/2] [$WHT$default_value$NRM]: $WHT";
759 $use_sendmail = <STDIN>;
760 if ( ( $use_sendmail =~ /^1\n/i )
761 || ( ( $use_sendmail =~ /^\n/ ) && ( $default_value eq "1" ) ) ) {
762 $useSendmail = "true";
763 } else {
764 $useSendmail = "false";
765 }
766 return $useSendmail;
767 }
768
769 # sendmail_path
770 sub command15 {
771 if ( $sendmail_path[0] !~ /./ ) {
772 $sendmail_path = "/usr/sbin/sendmail";
773 }
774 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
775 print "[$WHT$sendmail_path$NRM]: $WHT";
776 $new_sendmail_path = <STDIN>;
777 if ( $new_sendmail_path eq "\n" ) {
778 $new_sendmail_path = $sendmail_path;
779 } else {
780 $new_sendmail_path =~ s/[\r|\n]//g;
781 }
782 return $new_sendmail_path;
783 }
784
785 # smtpServerAddress
786 sub command16 {
787 print "This is the location of your SMTP server.\n";
788 print "[$WHT$smtpServerAddress$NRM]: $WHT";
789 $new_smtpServerAddress = <STDIN>;
790 if ( $new_smtpServerAddress eq "\n" ) {
791 $new_smtpServerAddress = $smtpServerAddress;
792 } else {
793 $new_smtpServerAddress =~ s/[\r|\n]//g;
794 }
795 return $new_smtpServerAddress;
796 }
797
798 # smtpPort
799 sub command17 {
800 print "This is the port to connect to for SMTP. Usually 25.\n";
801 print "[$WHT$smtpPort$NRM]: $WHT";
802 $new_smtpPort = <STDIN>;
803 if ( $new_smtpPort eq "\n" ) {
804 $new_smtpPort = $smtpPort;
805 } else {
806 $new_smtpPort =~ s/[\r|\n]//g;
807 }
808 return $new_smtpPort;
809 }
810
811 # authenticated server
812 sub command18 {
813 print "Do you wish to use an authenticated SMTP server? Your server must\n";
814 print "support this in order for SquirrelMail to work with it. We implemented\n";
815 print "it according to RFC 2554.\n";
816
817 $YesNo = 'n';
818 $YesNo = 'y' if ( lc($use_authenticated_smtp) eq "true" );
819
820 print "Use authenticated SMTP server (y/n) [$WHT$YesNo$NRM]: $WHT";
821
822 $new_use_authenticated_smtp = <STDIN>;
823 $new_use_authenticated_smtp =~ tr/yn//cd;
824 return "true" if ( $new_use_authenticated_smtp eq "y" );
825 return "false" if ( $new_use_authenticated_smtp eq "n" );
826 return $use_authenticated_smtp;
827 }
828
829 # imap_server_type
830 sub command19 {
831 print "Each IMAP server has its own quirks. As much as we tried to stick\n";
832 print "to standards, it doesn't help much if the IMAP server doesn't follow\n";
833 print "the same principles. We have made some work-arounds for some of\n";
834 print "these servers. If you would like to use them, please select your\n";
835 print "IMAP server. If you do not wish to use these work-arounds, you can\n";
836 print "set this to \"other\", and none will be used.\n";
837 print " cyrus = Cyrus IMAP server\n";
838 print " uw = University of Washington's IMAP server\n";
839 print " exchange = Microsoft Exchange IMAP server\n";
840 print " courier = Courier IMAP server\n";
841 print " other = Not one of the above servers\n";
842 print "[$WHT$imap_server_type$NRM]: $WHT";
843 $new_imap_server_type = <STDIN>;
844
845 if ( $new_imap_server_type eq "\n" ) {
846 $new_imap_server_type = $imap_server_type;
847 } else {
848 $new_imap_server_type =~ s/[\r|\n]//g;
849 }
850 return $new_imap_server_type;
851 }
852
853 # invert_time
854 sub command110 {
855 print "Sometimes the date of messages sent is messed up (off by a few hours\n";
856 print "on some machines). Typically this happens if the system doesn't support\n";
857 print "tm_gmtoff. It will happen only if your time zone is \"negative\".\n";
858 print "This most often occurs on Solaris 7 machines in the United States.\n";
859 print "By default, this is off. It should be kept off unless problems surface\n";
860 print "about the time that messages are sent.\n";
861 print " no = Do NOT fix time -- almost always correct\n";
862 print " yes = Fix the time for this system\n";
863
864 $YesNo = 'n';
865 $YesNo = 'y' if ( lc($invert_time) eq "true" );
866
867 print "Fix the time for this system (y/n) [$WHT$YesNo$NRM]: $WHT";
868
869 $new_invert_time = <STDIN>;
870 $new_invert_time =~ tr/yn//cd;
871 return "true" if ( $new_invert_time eq "y" );
872 return "false" if ( $new_invert_time eq "n" );
873 return $invert_time;
874 }
875
876 sub command111 {
877 print "This is the delimiter that your IMAP server uses to distinguish between\n";
878 print "folders. For example, Cyrus uses '.' as the delimiter and a complete\n";
879 print "folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would\n";
880 print "look like 'INBOX/Friends/Bob'. Normally this should be left at 'detect'\n";
881 print "but if you are sure you know what delimiter your server uses, you can\n";
882 print "specify it here.\n";
883 print "\nTo have it autodetect the delimiter, set it to 'detect'.\n\n";
884 print "[$WHT$optional_delimiter$NRM]: $WHT";
885 $new_optional_delimiter = <STDIN>;
886
887 if ( $new_optional_delimiter eq "\n" ) {
888 $new_optional_delimiter = $optional_delimiter;
889 } else {
890 $new_optional_delimiter =~ s/[\r|\n]//g;
891 }
892 return $new_optional_delimiter;
893 }
894
895 # MOTD
896 sub command71 {
897 print "\nYou can now create the welcome message that is displayed\n";
898 print "every time a user logs on. You can use HTML or just plain\n";
899 print
900 "text. If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n";
901
902 $new_motd = "";
903 do {
904 print "] ";
905 $line = <STDIN>;
906 $line =~ s/[\r|\n]//g;
907 if ( $line ne "@" ) {
908 $line =~ s/ /\&nbsp;\&nbsp;/g;
909 $line =~ s/\t/\&nbsp;\&nbsp;\&nbsp;\&nbsp;/g;
910 $line =~ s/$/ /;
911 $line =~ s/\'/\\\'/g;
912
913 $new_motd = $new_motd . $line;
914 }
915 } while ( $line ne "@" );
916 return $new_motd;
917 }
918
919 ################# PLUGINS ###################
920
921 sub command81 {
922 $command =~ s/[\s|\n|\r]*//g;
923 if ( $command > 0 ) {
924 $command = $command - 1;
925 if ( $command <= $#plugins ) {
926 @newplugins = ();
927 $ct = 0;
928 while ( $ct <= $#plugins ) {
929 if ( $ct != $command ) {
930 @newplugins = ( @newplugins, $plugins[$ct] );
931 }
932 $ct++;
933 }
934 @plugins = @newplugins;
935 } elsif ( $command <= $#plugins + $#unused_plugins + 1 ) {
936 $num = $command - $#plugins - 1;
937 @newplugins = @plugins;
938 $ct = 0;
939 while ( $ct <= $#unused_plugins ) {
940 if ( $ct == $num ) {
941 @newplugins = ( @newplugins, $unused_plugins[$ct] );
942
943 # sanitize the plugin
944 $dir = $unused_plugins[$ct];
945 `./ri_once.pl ../plugins/$dir`;
946 }
947 $ct++;
948 }
949 @plugins = @newplugins;
950 }
951 }
952 return @plugins;
953 }
954
955 sub command8s {
956 print "This command will sanitize all plugins for use with\n";
957 print "Squirrelmail 1.2. That is, it will rewrite some php-\n";
958 print "constructs that are *incompatible* with the 1.2 design\n";
959 print "into ones that are *compatible*\n";
960 print "Do you wish to issue this command [y/N]? ";
961 $ctu = <STDIN>;
962 if ( $ctu =~ /^y\n/i ) {
963 `./ri_once.pl ../plugins`;
964 }
965 }
966
967 ################# FOLDERS ###################
968
969 # default_folder_prefix
970 sub command21 {
971 print "Some IMAP servers (UW, for example) store mail and folders in\n";
972 print "your user space in a separate subdirectory. This is where you\n";
973 print "specify what that directory is.\n";
974 print "\n";
975 print "EXAMPLE: mail/";
976 print "\n";
977 print "NOTE: If you use Cyrus, or some server that would not use this\n";
978 print " option, you must set this to 'none'.\n";
979 print "\n";
980 print "[$WHT$default_folder_prefix$NRM]: $WHT";
981 $new_default_folder_prefix = <STDIN>;
982
983 if ( $new_default_folder_prefix eq "\n" ) {
984 $new_default_folder_prefix = $default_folder_prefix;
985 } else {
986 $new_default_folder_prefix =~ s/[\r|\n]//g;
987 }
988 if ( ( $new_default_folder_prefix =~ /^\s*$/ ) || ( $new_default_folder_prefix =~ /none/i ) ) {
989 $new_default_folder_prefix = "";
990 } else {
991 $new_default_folder_prefix =~ s/\/*$//g;
992 $new_default_folder_prefix =~ s/$/\//g;
993 }
994 return $new_default_folder_prefix;
995 }
996
997 # Show Folder Prefix
998 sub command22 {
999 print "It is possible to set up the default folder prefix as a user\n";
1000 print "specific option, where each user can specify what their mail\n";
1001 print "folder is. If you set this to false, they will never see the\n";
1002 print "option, but if it is true, this option will appear in the\n";
1003 print "'options' section.\n";
1004 print "\n";
1005 print "NOTE: You set the default folder prefix in option '1' of this\n";
1006 print " section. That will be the default if the user doesn't\n";
1007 print " specify anything different.\n";
1008 print "\n";
1009
1010 if ( lc($show_prefix_option) eq "true" ) {
1011 $default_value = "y";
1012 } else {
1013 $default_value = "n";
1014 }
1015 print "\n";
1016 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
1017 $new_show = <STDIN>;
1018 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1019 $show_prefix_option = "true";
1020 } else {
1021 $show_prefix_option = "false";
1022 }
1023 return $show_prefix_option;
1024 }
1025
1026 # Trash Folder
1027 sub command23a {
1028 print "You can now specify where the default trash folder is located.\n";
1029 print "On servers where you do not want this, you can set it to anything\n";
1030 print "and set option 6 to false.\n";
1031 print "\n";
1032 print "This is relative to where the rest of your email is kept. You do\n";
1033 print "not need to worry about their mail directory. If this folder\n";
1034 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
1035 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
1036 print "\n";
1037
1038 print "[$WHT$trash_folder$NRM]: $WHT";
1039 $new_trash_folder = <STDIN>;
1040 if ( $new_trash_folder eq "\n" ) {
1041 $new_trash_folder = $trash_folder;
1042 } else {
1043 $new_trash_folder =~ s/[\r|\n]//g;
1044 }
1045 return $new_trash_folder;
1046 }
1047
1048 # Sent Folder
1049 sub command23b {
1050 print "This is where messages that are sent will be stored. SquirrelMail\n";
1051 print "by default puts a copy of all outgoing messages in this folder.\n";
1052 print "\n";
1053 print "This is relative to where the rest of your email is kept. You do\n";
1054 print "not need to worry about their mail directory. If this folder\n";
1055 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
1056 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
1057 print "\n";
1058
1059 print "[$WHT$sent_folder$NRM]: $WHT";
1060 $new_sent_folder = <STDIN>;
1061 if ( $new_sent_folder eq "\n" ) {
1062 $new_sent_folder = $sent_folder;
1063 } else {
1064 $new_sent_folder =~ s/[\r|\n]//g;
1065 }
1066 return $new_sent_folder;
1067 }
1068
1069 # Draft Folder
1070 sub command23c {
1071 print "You can now specify where the default draft folder is located.\n";
1072 print "On servers where you do not want this, you can set it to anything\n";
1073 print "and set option 9 to false.\n";
1074 print "\n";
1075 print "This is relative to where the rest of your email is kept. You do\n";
1076 print "not need to worry about their mail directory. If this folder\n";
1077 print "would be ~/mail/drafts on the filesystem, you only need to specify\n";
1078 print "that this is 'drafts', and be sure to put 'mail/' in option 1.\n";
1079 print "\n";
1080
1081 print "[$WHT$draft_folder$NRM]: $WHT";
1082 $new_draft_folder = <STDIN>;
1083 if ( $new_draft_folder eq "\n" ) {
1084 $new_draft_folder = $draft_folder;
1085 } else {
1086 $new_draft_folder =~ s/[\r|\n]//g;
1087 }
1088 return $new_draft_folder;
1089 }
1090
1091 # default move to trash
1092 sub command24a {
1093 print "By default, should messages get moved to the trash folder? You\n";
1094 print "can specify the default trash folder in option 3. If this is set\n";
1095 print "to false, messages will get deleted immediately without moving\n";
1096 print "to the trash folder.\n";
1097 print "\n";
1098 print "Trash folder is currently: $trash_folder\n";
1099 print "\n";
1100
1101 if ( lc($default_move_to_trash) eq "true" ) {
1102 $default_value = "y";
1103 } else {
1104 $default_value = "n";
1105 }
1106 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
1107 $new_show = <STDIN>;
1108 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1109 $default_move_to_trash = "true";
1110 } else {
1111 $default_move_to_trash = "false";
1112 }
1113 return $default_move_to_trash;
1114 }
1115
1116 # default move to sent
1117 sub command24b {
1118 print "By default, should messages get moved to the sent folder? You\n";
1119 print "can specify the default sent folder in option 4. If this is set\n";
1120 print "to false, messages will get sent and no copy will be made.\n";
1121 print "\n";
1122 print "Trash folder is currently: $sent_folder\n";
1123 print "\n";
1124
1125 if ( lc($default_move_to_sent) eq "true" ) {
1126 $default_value = "y";
1127 } else {
1128 $default_value = "n";
1129 }
1130 print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT";
1131 $new_show = <STDIN>;
1132 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1133 $default_move_to_sent = "true";
1134 } else {
1135 $default_move_to_sent = "false";
1136 }
1137 return $default_move_to_sent;
1138 }
1139
1140 # default save as draft
1141 sub command24c {
1142 print "By default, should the save to draft option be shown? You can\n";
1143 print "specify the default drafts folder in option 5. If this is set\n";
1144 print "to false, users will not be shown the save to draft option.\n";
1145 print "\n";
1146 print "Drafts folder is currently: $draft_folder\n";
1147 print "\n";
1148
1149 if ( lc($default_move_to_draft) eq "true" ) {
1150 $default_value = "y";
1151 } else {
1152 $default_value = "n";
1153 }
1154 print "By default, save as draft (y/n) [$WHT$default_value$NRM]: $WHT";
1155 $new_show = <STDIN>;
1156 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1157 $default_save_as_draft = "true";
1158 } else {
1159 $default_save_as_draft = "false";
1160 }
1161 return $default_save_as_draft;
1162 }
1163
1164 # List special folders first
1165 sub command27 {
1166 print "SquirrelMail has what we call 'special folders' that are not\n";
1167 print "manipulated and viewed like normal folders. Some examples of\n";
1168 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1169 print "Simply asks if you want these folders listed first in the folder\n";
1170 print "listing.\n";
1171 print "\n";
1172
1173 if ( lc($list_special_folders_first) eq "true" ) {
1174 $default_value = "y";
1175 } else {
1176 $default_value = "n";
1177 }
1178 print "\n";
1179 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
1180 $new_show = <STDIN>;
1181 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1182 $list_special_folders_first = "true";
1183 } else {
1184 $list_special_folders_first = "false";
1185 }
1186 return $list_special_folders_first;
1187 }
1188
1189 # Show special folders color
1190 sub command28 {
1191 print "SquirrelMail has what we call 'special folders' that are not\n";
1192 print "manipulated and viewed like normal folders. Some examples of\n";
1193 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1194 print "wants to know if we should display special folders in a\n";
1195 print "color than the other folders.\n";
1196 print "\n";
1197
1198 if ( lc($use_special_folder_color) eq "true" ) {
1199 $default_value = "y";
1200 } else {
1201 $default_value = "n";
1202 }
1203 print "\n";
1204 print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
1205 $new_show = <STDIN>;
1206 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1207 $use_special_folder_color = "true";
1208 } else {
1209 $use_special_folder_color = "false";
1210 }
1211 return $use_special_folder_color;
1212 }
1213
1214 # Auto expunge
1215 sub command29 {
1216 print "The way that IMAP handles deleting messages is as follows. You\n";
1217 print "mark the message as deleted, and then to 'really' delete it, you\n";
1218 print "expunge it. This option asks if you want to just have messages\n";
1219 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
1220 print "messages too.\n";
1221 print "\n";
1222
1223 if ( lc($auto_expunge) eq "true" ) {
1224 $default_value = "y";
1225 } else {
1226 $default_value = "n";
1227 }
1228 print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
1229 $new_show = <STDIN>;
1230 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1231 $auto_expunge = "true";
1232 } else {
1233 $auto_expunge = "false";
1234 }
1235 return $auto_expunge;
1236 }
1237
1238 # Default sub of inbox
1239 sub command210 {
1240 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
1241 print "This can cause some confusion in folder creation for users when\n";
1242 print "they try to create folders and don't put it as a subfolder of INBOX\n";
1243 print "and get permission errors. This option asks if you want folders\n";
1244 print "to be subfolders of INBOX by default.\n";
1245 print "\n";
1246
1247 if ( lc($default_sub_of_inbox) eq "true" ) {
1248 $default_value = "y";
1249 } else {
1250 $default_value = "n";
1251 }
1252 print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
1253 $new_show = <STDIN>;
1254 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1255 $default_sub_of_inbox = "true";
1256 } else {
1257 $default_sub_of_inbox = "false";
1258 }
1259 return $default_sub_of_inbox;
1260 }
1261
1262 # Show contain subfolder option
1263 sub command211 {
1264 print "Some IMAP servers (UW) make it so that there are two types of\n";
1265 print "folders. Those that contain messages, and those that contain\n";
1266 print "subfolders. If this is the case for your server, set this to\n";
1267 print "true, and it will ask the user whether the folder they are\n";
1268 print "creating contains subfolders or messages.\n";
1269 print "\n";
1270
1271 if ( lc($show_contain_subfolders_option) eq "true" ) {
1272 $default_value = "y";
1273 } else {
1274 $default_value = "n";
1275 }
1276 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
1277 $new_show = <STDIN>;
1278 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1279 $show_contain_subfolders_option = "true";
1280 } else {
1281 $show_contain_subfolders_option = "false";
1282 }
1283 return $show_contain_subfolders_option;
1284 }
1285
1286 # Default Unseen Notify
1287 sub command212 {
1288 print "This option specifies where the users will receive notification\n";
1289 print "about unseen messages by default. This is of course an option that\n";
1290 print "can be changed on a user level.\n";
1291 print " 1 = No notification\n";
1292 print " 2 = Only on the INBOX\n";
1293 print " 3 = On all folders\n";
1294 print "\n";
1295
1296 print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT";
1297 $new_show = <STDIN>;
1298 if ( $new_show =~ /^[1|2|3]\n/i ) {
1299 $default_unseen_notify = $new_show;
1300 }
1301 $default_unseen_notify =~ s/[\r|\n]//g;
1302 return $default_unseen_notify;
1303 }
1304
1305 # Default Unseen Type
1306 sub command213 {
1307 print "Here you can define the default way that unseen messages will be displayed\n";
1308 print "to the user in the folder listing on the left side.\n";
1309 print " 1 = Only unseen messages (4)\n";
1310 print " 2 = Unseen and Total messages (4/27)\n";
1311 print "\n";
1312
1313 print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT";
1314 $new_show = <STDIN>;
1315 if ( $new_show =~ /^[1|2]\n/i ) {
1316 $default_unseen_type = $new_show;
1317 }
1318 $default_unseen_type =~ s/[\r|\n]//g;
1319 return $default_unseen_type;
1320 }
1321
1322 # Auto create special folders
1323 sub command214 {
1324 print "Would you like the Sent, Trash, and Drafts folders to be created\n";
1325 print "automatically print for you when a user logs in? If the user\n";
1326 print "accidentally deletes their special folders, this option will\n";
1327 print "automatically create it again for them.\n";
1328 print "\n";
1329
1330 if ( lc($auto_create_special) eq "true" ) {
1331 $default_value = "y";
1332 } else {
1333 $default_value = "n";
1334 }
1335 print "Auto create special folders? (y/n) [$WHT$default_value$NRM]: $WHT";
1336 $new_show = <STDIN>;
1337 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1338 $auto_create_special = "true";
1339 } else {
1340 $auto_create_special = "false";
1341 }
1342 return $auto_create_special;
1343 }
1344
1345 # Auto create special folders
1346 sub command215 {
1347 print "Would you like to automatically completely delete any deleted\n";
1348 print "folders? If not then they will be moved to the Trash folder\n";
1349 print "and can be deleted from there\n";
1350 print "\n";
1351
1352 if ( lc($delete_folder) eq "true" ) {
1353 $default_value = "y";
1354 } else {
1355 $default_value = "n";
1356 }
1357 print "Auto delete folders? (y/n) [$WHT$default_value$NRM]: $WHT";
1358 $new_delete = <STDIN>;
1359 if ( ( $new_delete =~ /^y\n/i ) || ( ( $new_delete =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1360 $delete_folder = "true";
1361 } else {
1362 $delete_folder = "false";
1363 }
1364 return $delete_folder;
1365 }
1366
1367 ############# GENERAL OPTIONS #####################
1368
1369 # Default Charset
1370 sub command31 {
1371 print "This option controls what character set is used when sending\n";
1372 print "mail and when sending HTML to the browser. Do not set this\n";
1373 print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n";
1374 print "to use KOI8-R, since this implementation is faster than most\n";
1375 print "of the alternatives\n";
1376 print "\n";
1377
1378 print "[$WHT$default_charset$NRM]: $WHT";
1379 $new_default_charset = <STDIN>;
1380 if ( $new_default_charset eq "\n" ) {
1381 $new_default_charset = $default_charset;
1382 } else {
1383 $new_default_charset =~ s/[\r|\n]//g;
1384 }
1385 return $new_default_charset;
1386 }
1387
1388 # Data directory
1389 sub command33a {
1390 print "It is a possible security hole to have a writable directory\n";
1391 print "under the web server's root directory (ex: /home/httpd/html).\n";
1392 print "For this reason, it is possible to put the data directory\n";
1393 print "anywhere you would like. The path name can be absolute or\n";
1394 print "relative (to the config directory). It doesn't matter. Here\n";
1395 print "are two examples:\n";
1396 print " Absolute: /usr/local/squirrelmail/data/\n";
1397 print " Relative: ../data/\n";
1398 print "\n";
1399
1400 print "[$WHT$data_dir$NRM]: $WHT";
1401 $new_data_dir = <STDIN>;
1402 if ( $new_data_dir eq "\n" ) {
1403 $new_data_dir = $data_dir;
1404 } else {
1405 $new_data_dir =~ s/[\r|\n]//g;
1406 }
1407 if ( $new_data_dir =~ /^\s*$/ ) {
1408 $new_data_dir = "";
1409 } else {
1410 $new_data_dir =~ s/\/*$//g;
1411 $new_data_dir =~ s/$/\//g;
1412 }
1413 return $new_data_dir;
1414 }
1415
1416 # Attachment directory
1417 sub command33b {
1418 print "Path to directory used for storing attachments while a mail is\n";
1419 print "being sent. There are a few security considerations regarding this\n";
1420 print "directory:\n";
1421 print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
1422 print " impossible for a random person with access to the webserver\n";
1423 print " to list files in this directory. Confidential data might\n";
1424 print " be laying around in there.\n";
1425 print " 2. Since the webserver is not able to list the files in the\n";
1426 print " content is also impossible for the webserver to delete files\n";
1427 print " lying around there for too long.\n";
1428 print " 3. It should probably be another directory than the data\n";
1429 print " directory specified in option 3.\n";
1430 print "\n";
1431
1432 print "[$WHT$attachment_dir$NRM]: $WHT";
1433 $new_attachment_dir = <STDIN>;
1434 if ( $new_attachment_dir eq "\n" ) {
1435 $new_attachment_dir = $attachment_dir;
1436 } else {
1437 $new_attachment_dir =~ s/[\r|\n]//g;
1438 }
1439 if ( $new_attachment_dir =~ /^\s*$/ ) {
1440 $new_attachment_dir = "";
1441 } else {
1442 $new_attachment_dir =~ s/\/*$//g;
1443 $new_attachment_dir =~ s/$/\//g;
1444 }
1445 return $new_attachment_dir;
1446 }
1447
1448 sub command33c {
1449 print "The directory hash level setting allows you to configure the level\n";
1450 print "of hashing that Squirremail employs in your data and attachment\n";
1451 print "directories. This value must be an integer ranging from 0 to 4.\n";
1452 print "When this value is set to 0, Squirrelmail will simply store all\n";
1453 print "files as normal in the data and attachment directories. However,\n";
1454 print "when set to a value from 1 to 4, a simple hashing scheme will be\n";
1455 print "used to organize the files in this directory. In short, the crc32\n";
1456 print "value for a username will be computed. Then, up to the first 4\n";
1457 print "digits of the hash, as set by this configuration value, will be\n";
1458 print "used to directory hash the files for that user in the data and\n";
1459 print "attachment directory. This allows for better performance on\n";
1460 print "servers with larger numbers of users.\n";
1461 print "\n";
1462
1463 print "[$WHT$dir_hash_level$NRM]: $WHT";
1464 $new_dir_hash_level = <STDIN>;
1465 if ( $new_dir_hash_level eq "\n" ) {
1466 $new_dir_hash_level = $dir_hash_level;
1467 } else {
1468 $new_dir_hash_level =~ s/[\r|\n]//g;
1469 }
1470 if ( ( int($new_dir_hash_level) < 0 )
1471 || ( int($new_dir_hash_level) > 4 )
1472 || !( int($new_dir_hash_level) eq $new_dir_hash_level ) ) {
1473 print "Invalid Directory Hash Level.\n";
1474 print "Value must be an integer ranging from 0 to 4\n";
1475 print "Hit enter to continue.\n";
1476 $enter_key = <STDIN>;
1477
1478 $new_dir_hash_level = $dir_hash_level;
1479 }
1480
1481 return $new_dir_hash_level;
1482 }
1483
1484 sub command35 {
1485 print "This is the default size (in pixels) of the left folder list.\n";
1486 print "Default is 200, but you can set it to whatever you wish. This\n";
1487 print "is a user preference, so this will only show up as their default.\n";
1488 print "\n";
1489 print "[$WHT$default_left_size$NRM]: $WHT";
1490 $new_default_left_size = <STDIN>;
1491 if ( $new_default_left_size eq "\n" ) {
1492 $new_default_left_size = $default_left_size;
1493 } else {
1494 $new_default_left_size =~ s/[\r|\n]//g;
1495 }
1496 return $new_default_left_size;
1497 }
1498
1499 sub command36 {
1500 print "Some IMAP servers only have lowercase letters in the usernames\n";
1501 print "but they still allow people with uppercase to log in. This\n";
1502 print "causes a problem with the user's preference files. This option\n";
1503 print "transparently changes all usernames to lowercase.";
1504 print "\n";
1505
1506 if ( lc($force_username_lowercase) eq "true" ) {
1507 $default_value = "y";
1508 } else {
1509 $default_value = "n";
1510 }
1511 print "Convert usernames to lowercase (y/n) [$WHT$default_value$NRM]: $WHT";
1512 $new_show = <STDIN>;
1513 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1514 return "true";
1515 }
1516 return "false";
1517 }
1518
1519 sub command37 {
1520 print "";
1521 print "\n";
1522
1523 if ( lc($default_use_priority) eq "true" ) {
1524 $default_value = "y";
1525 } else {
1526 $default_value = "n";
1527 }
1528
1529 print "Allow users to specify priority of outgoing mail (y/n) [$WHT$default_value$NRM]: $WHT";
1530 $new_show = <STDIN>;
1531 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1532 return "true";
1533 }
1534 return "false";
1535 }
1536
1537 sub command38 {
1538 print "";
1539 print "\n";
1540
1541 if ( lc($default_hide_attribution) eq "true" ) {
1542 $default_value = "y";
1543 } else {
1544 $default_value = "n";
1545 }
1546
1547 print "Hide SM attributions (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 return "true";
1551 }
1552 return "false";
1553 }
1554
1555 sub command39 {
1556 print "";
1557 print "\n";
1558
1559 if ( lc($default_use_mdn) eq "true" ) {
1560 $default_value = "y";
1561 } else {
1562 $default_value = "n";
1563 }
1564
1565 print "Enable support for read/delivery receipt support (y/n) [$WHT$default_value$NRM]: $WHT";
1566 $new_show = <STDIN>;
1567 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1568 return "true";
1569 }
1570 return "false";
1571 }
1572
1573 sub command310 {
1574 print "This allows you to prevent the editing of the users name and";
1575 print "email address. This is mainly useful when used with the";
1576 print "retrieveuserdata plugin\n";
1577 print "\n";
1578
1579 if ( lc($edit_identity) eq "true" ) {
1580 $default_value = "y";
1581 } else {
1582 $default_value = "n";
1583 }
1584 print "Allow editing? (y/n) [$WHT$default_value$NRM]: $WHT";
1585 $new_edit = <STDIN>;
1586 if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1587 $edit_identity = "true";
1588 } else {
1589 $edit_identity = "false";
1590 }
1591 return $edit_identity;
1592 }
1593
1594 sub command311 {
1595 print "This option allows you to choose if the user can edit their full name";
1596 print "even when you don't want them to change their username\n";
1597 print "\n";
1598
1599 if ( lc($edit_name) eq "true" ) {
1600 $default_value = "y";
1601 } else {
1602 $default_value = "n";
1603 }
1604 print "Allow editing of the users full name? (y/n) [$WHT$default_value$NRM]: $WHT";
1605 $new_edit = <STDIN>;
1606 if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1607 $edit_name = "true";
1608 } else {
1609 $edit_name = "false";
1610 }
1611 return $edit_name;
1612 }
1613
1614 sub command41 {
1615 print "\nNow we will define the themes that you wish to use. If you have added\n";
1616 print "a theme of your own, just follow the instructions (?) about how to add\n";
1617 print "them. You can also change the default theme.\n";
1618 print "[theme] command (?=help) > ";
1619 $input = <STDIN>;
1620 $input =~ s/[\r|\n]//g;
1621 while ( $input ne "d" ) {
1622 if ( $input =~ /^\s*l\s*/i ) {
1623 $count = 0;
1624 while ( $count <= $#theme_name ) {
1625 if ( $count == $theme_default ) {
1626 print " *";
1627 } else {
1628 print " ";
1629 }
1630 $name = $theme_name[$count];
1631 $num_spaces = 25 - length($name);
1632 for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
1633 $name = $name . " ";
1634 }
1635
1636 print " $count. $name";
1637 print "($theme_path[$count])\n";
1638
1639 $count++;
1640 }
1641 } elsif ( $input =~ /^\s*m\s*[0-9]+/i ) {
1642 $old_def = $theme_default;
1643 $theme_default = $input;
1644 $theme_default =~ s/^\s*m\s*//;
1645 if ( ( $theme_default > $#theme_name ) || ( $theme_default < 0 ) ) {
1646 print "Cannot set default theme to $theme_default. That theme does not exist.\n";
1647 $theme_default = $old_def;
1648 }
1649 } elsif ( $input =~ /^\s*\+/ ) {
1650 print "What is the name of this theme: ";
1651 $name = <STDIN>;
1652 $name =~ s/[\r|\n]//g;
1653 $theme_name[ $#theme_name + 1 ] = $name;
1654 print "Be sure to put ../themes/ before the filename.\n";
1655 print "What file is this stored in (ex: ../themes/default_theme.php): ";
1656 $name = <STDIN>;
1657 $name =~ s/[\r|\n]//g;
1658 $theme_path[ $#theme_path + 1 ] = $name;
1659 } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
1660 if ( $input =~ /[0-9]+\s*$/ ) {
1661 $rem_num = $input;
1662 $rem_num =~ s/^\s*-\s*//g;
1663 $rem_num =~ s/\s*$//;
1664 } else {
1665 $rem_num = $#theme_name;
1666 }
1667 if ( $rem_num == $theme_default ) {
1668 print "You cannot remove the default theme!\n";
1669 } else {
1670 $count = 0;
1671 @new_theme_name = ();
1672 @new_theme_path = ();
1673 while ( $count <= $#theme_name ) {
1674 if ( $count != $rem_num ) {
1675 @new_theme_name = ( @new_theme_name, $theme_name[$count] );
1676 @new_theme_path = ( @new_theme_path, $theme_path[$count] );
1677 }
1678 $count++;
1679 }
1680 @theme_name = @new_theme_name;
1681 @theme_path = @new_theme_path;
1682 if ( $theme_default > $rem_num ) {
1683 $theme_default--;
1684 }
1685 }
1686 } elsif ( $input =~ /^\s*t\s*/i ) {
1687 print "\nStarting detection...\n\n";
1688
1689 opendir( DIR, "../themes" );
1690 @files = grep { /\.php$/i } readdir(DIR);
1691 $cnt = 0;
1692 while ( $cnt <= $#files ) {
1693 $filename = "../themes/" . $files[$cnt];
1694 if ( $filename ne "../themes/index.php" ) {
1695 $found = 0;
1696 for ( $x = 0 ; $x <= $#theme_path ; $x++ ) {
1697 if ( $theme_path[$x] eq $filename ) {
1698 $found = 1;
1699 }
1700 }
1701 if ( $found != 1 ) {
1702 print "** Found theme: $filename\n";
1703 print " What is its name? ";
1704 $nm = <STDIN>;
1705 $nm =~ s/[\n|\r]//g;
1706 $theme_name[ $#theme_name + 1 ] = $nm;
1707 $theme_path[ $#theme_path + 1 ] = $filename;
1708 }
1709 }
1710 $cnt++;
1711 }
1712 print "\n";
1713 for ( $cnt = 0 ; $cnt <= $#theme_path ; $cnt++ ) {
1714 $filename = $theme_path[$cnt];
1715 if ( !( -e $filename ) ) {
1716 print " Removing $filename (file not found)\n";
1717 $offset = 0;
1718 @new_theme_name = ();
1719 @new_theme_path = ();
1720 for ( $x = 0 ; $x < $#theme_path ; $x++ ) {
1721 if ( $theme_path[$x] eq $filename ) {
1722 $offset = 1;
1723 }
1724 if ( $offset == 1 ) {
1725 $new_theme_name[$x] = $theme_name[ $x + 1 ];
1726 $new_theme_path[$x] = $theme_path[ $x + 1 ];
1727 } else {
1728 $new_theme_name[$x] = $theme_name[$x];
1729 $new_theme_path[$x] = $theme_path[$x];
1730 }
1731 }
1732 @theme_name = @new_theme_name;
1733 @theme_path = @new_theme_path;
1734 }
1735 }
1736 print "\nDetection complete!\n\n";
1737
1738 closedir DIR;
1739 } elsif ( $input =~ /^\s*\?\s*/ ) {
1740 print ".-------------------------.\n";
1741 print "| t (detect themes) |\n";
1742 print "| + (add theme) |\n";
1743 print "| - N (remove theme) |\n";
1744 print "| m N (mark default) |\n";
1745 print "| l (list themes) |\n";
1746 print "| d (done) |\n";
1747 print "`-------------------------'\n";
1748 }
1749 print "[theme] command (?=help) > ";
1750 $input = <STDIN>;
1751 $input =~ s/[\r|\n]//g;
1752 }
1753 }
1754
1755 # Theme - CSS file
1756 sub command42 {
1757 print "You may specify a cascading style-sheet (CSS) file to be included\n";
1758 print "on each html page generated by SquirrelMail. The CSS file is useful\n";
1759 print "for specifying a site-wide font. If you're not familiar with CSS\n";
1760 print "files, leave this blank.\n";
1761 print "\n";
1762 print "To clear out an existing value, just type a space for the input.\n";
1763 print "\n";
1764 print "[$WHT$theme_css$NRM]: $WHT";
1765 $new_theme_css = <STDIN>;
1766
1767 if ( $new_theme_css eq "\n" ) {
1768 $new_theme_css = $theme_css;
1769 } else {
1770 $new_theme_css =~ s/[\r|\n]//g;
1771 }
1772 $new_theme_css =~ s/^\s*//;
1773 return $new_theme_css;
1774 }
1775
1776 sub command61 {
1777 print "You can now define different LDAP servers.\n";
1778 print "[ldap] command (?=help) > ";
1779 $input = <STDIN>;
1780 $input =~ s/[\r|\n]//g;
1781 while ( $input ne "d" ) {
1782 if ( $input =~ /^\s*l\s*/i ) {
1783 $count = 0;
1784 while ( $count <= $#ldap_host ) {
1785 print "$count. $ldap_host[$count]\n";
1786 print " base: $ldap_base[$count]\n";
1787 if ( $ldap_charset[$count] ) {
1788 print " charset: $ldap_charset[$count]\n";
1789 }
1790 if ( $ldap_port[$count] ) {
1791 print " port: $ldap_port[$count]\n";
1792 }
1793 if ( $ldap_name[$count] ) {
1794 print " name: $ldap_name[$count]\n";
1795 }
1796 if ( $ldap_maxrows[$count] ) {
1797 print " maxrows: $ldap_maxrows[$count]\n";
1798 }
1799 print "\n";
1800 $count++;
1801 }
1802 } elsif ( $input =~ /^\s*\+/ ) {
1803 $sub = $#ldap_host + 1;
1804
1805 print "First, we need to have the hostname or the IP address where\n";
1806 print "this LDAP server resides. Example: ldap.bigfoot.com\n";
1807 print "hostname: ";
1808 $name = <STDIN>;
1809 $name =~ s/[\r|\n]//g;
1810 $ldap_host[$sub] = $name;
1811
1812 print "\n";
1813
1814 print "Next, we need the server root (base dn). For this, an empty\n";
1815 print "string is allowed.\n";
1816 print "Example: ou=member_directory,o=netcenter.com\n";
1817 print "base: ";
1818 $name = <STDIN>;
1819 $name =~ s/[\r|\n]//g;
1820 $ldap_base[$sub] = $name;
1821
1822 print "\n";
1823
1824 print "This is the TCP/IP port number for the LDAP server. Default\n";
1825 print "port is 389. This is optional. Press ENTER for default.\n";
1826 print "port: ";
1827 $name = <STDIN>;
1828 $name =~ s/[\r|\n]//g;
1829 $ldap_port[$sub] = $name;
1830
1831 print "\n";
1832
1833 print "This is the charset for the server. Default is utf-8. This\n";
1834 print "is also optional. Press ENTER for default.\n";
1835 print "charset: ";
1836 $name = <STDIN>;
1837 $name =~ s/[\r|\n]//g;
1838 $ldap_charset[$sub] = $name;
1839
1840 print "\n";
1841
1842 print "This is the name for the server, used to tag the results of\n";
1843 print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
1844 print "name: ";
1845 $name = <STDIN>;
1846 $name =~ s/[\r|\n]//g;
1847 $ldap_name[$sub] = $name;
1848
1849 print "\n";
1850
1851 print "You can specify the maximum number of rows in the search result.\n";
1852 print "Default is unlimited. Press ENTER for default.\n";
1853 print "maxrows: ";
1854 $name = <STDIN>;
1855 $name =~ s/[\r|\n]//g;
1856 $ldap_maxrows[$sub] = $name;
1857
1858 print "\n";
1859
1860 } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
1861 if ( $input =~ /[0-9]+\s*$/ ) {
1862 $rem_num = $input;
1863 $rem_num =~ s/^\s*-\s*//g;
1864 $rem_num =~ s/\s*$//;
1865 } else {
1866 $rem_num = $#ldap_host;
1867 }
1868 $count = 0;
1869 @new_ldap_host = ();
1870 @new_ldap_base = ();
1871 @new_ldap_port = ();
1872 @new_ldap_name = ();
1873 @new_ldap_charset = ();
1874 @new_ldap_maxrows = ();
1875
1876 while ( $count <= $#ldap_host ) {
1877 if ( $count != $rem_num ) {
1878 @new_ldap_host = ( @new_ldap_host, $ldap_host[$count] );
1879 @new_ldap_base = ( @new_ldap_base, $ldap_base[$count] );
1880 @new_ldap_port = ( @new_ldap_port, $ldap_port[$count] );
1881 @new_ldap_name = ( @new_ldap_name, $ldap_name[$count] );
1882 @new_ldap_charset = ( @new_ldap_charset, $ldap_charset[$count] );
1883 @new_ldap_maxrows = ( @new_ldap_maxrows, $ldap_maxrows[$count] );
1884 }
1885 $count++;
1886 }
1887 @ldap_host = @new_ldap_host;
1888 @ldap_base = @new_ldap_base;
1889 @ldap_port = @new_ldap_port;
1890 @ldap_name = @new_ldap_name;
1891 @ldap_charset = @new_ldap_charset;
1892 @ldap_maxrows = @new_ldap_maxrows;
1893 } elsif ( $input =~ /^\s*\?\s*/ ) {
1894 print ".-------------------------.\n";
1895 print "| + (add host) |\n";
1896 print "| - N (remove host) |\n";
1897 print "| l (list hosts) |\n";
1898 print "| d (done) |\n";
1899 print "`-------------------------'\n";
1900 }
1901 print "[ldap] command (?=help) > ";
1902 $input = <STDIN>;
1903 $input =~ s/[\r|\n]//g;
1904 }
1905 }
1906
1907 sub command62 {
1908 print "Some of our developers have come up with very good javascript interface\n";
1909 print "for searching through address books, however, our original goals said\n";
1910 print "that we would be 100% HTML. In order to make it possible to use their\n";
1911 print "interface, and yet stick with our goals, we have also written a plain\n";
1912 print "HTML version of the search. Here, you can choose which version to use.\n";
1913 print "\n";
1914 print "This is just the default value. It is also a user option that each\n";
1915 print "user can configure individually\n";
1916 print "\n";
1917
1918 if ( lc($default_use_javascript_addr_book) eq "true" ) {
1919 $default_value = "y";
1920 } else {
1921 $default_use_javascript_addr_book = "false";
1922 $default_value = "n";
1923 }
1924 print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
1925 $new_show = <STDIN>;
1926 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1927 $default_use_javascript_addr_book = "true";
1928 } else {
1929 $default_use_javascript_addr_book = "false";
1930 }
1931 return $default_use_javascript_addr_book;
1932 }
1933
1934 sub command91 {
1935 print "If you want to store your users address book details in a database then\n";
1936 print "you need to set this DSN to a valid value. The format for this is:\n";
1937 print "mysql://user:pass\@hostname/dbname\n";
1938 print "Where mysql can be one of the databases PHP supports, the most common\n";
1939 print "of these are mysql, msql and pgsql\n";
1940 print "If the DSN is left empty (hit space and then return) the database\n";
1941 print "related code for address books will not be used\n";
1942 print "\n";
1943
1944 if ( $addrbook_dsn eq "" ) {
1945 $default_value = "Disabled";
1946 } else {
1947 $default_value = $addrbook_dsn;
1948 }
1949 print "[$WHT$addrbook_dsn$NRM]: $WHT";
1950 $new_dsn = <STDIN>;
1951 if ( $new_dsn eq "\n" ) {
1952 $new_dsn = "";
1953 } else {
1954 $new_dsn =~ s/[\r|\n]//g;
1955 $new_dsn =~ s/^\s+$//g;
1956 }
1957 return $new_dsn;
1958 }
1959
1960 sub command92 {
1961 print "This is the name of the table you want to store the address book\n";
1962 print "data in, it defaults to 'address'\n";
1963 print "\n";
1964 print "[$WHT$addrbook_table$NRM]: $WHT";
1965 $new_table = <STDIN>;
1966 if ( $new_table eq "\n" ) {
1967 $new_table = $addrbook_table;
1968 } else {
1969 $new_table =~ s/[\r|\n]//g;
1970 }
1971 return $new_table;
1972 }
1973
1974 sub command93 {
1975 print "If you want to store your users preferences in a database then\n";
1976 print "you need to set this DSN to a valid value. The format for this is:\n";
1977 print "mysql://user:pass\@hostname/dbname\n";
1978 print "Where mysql can be one of the databases PHP supports, the most common\n";
1979 print "of these are mysql, msql and pgsql\n";
1980 print "If the DSN is left empty (hit space and then return) the database\n";
1981 print "related code for address books will not be used\n";
1982 print "\n";
1983
1984 if ( $prefs_dsn eq "" ) {
1985 $default_value = "Disabled";
1986 } else {
1987 $default_value = $prefs_dsn;
1988 }
1989 print "[$WHT$prefs_dsn$NRM]: $WHT";
1990 $new_dsn = <STDIN>;
1991 if ( $new_dsn eq "\n" ) {
1992 $new_dsn = "";
1993 } else {
1994 $new_dsn =~ s/[\r|\n]//g;
1995 $new_dsn =~ s/^\s+$//g;
1996 }
1997 return $new_dsn;
1998 }
1999
2000 sub command94 {
2001 print "This is the name of the table you want to store the preferences\n";
2002 print "data in, it defaults to 'address'\n";
2003 print "\n";
2004 print "[$WHT$prefs_table$NRM]: $WHT";
2005 $new_table = <STDIN>;
2006 if ( $new_table eq "\n" ) {
2007 $new_table = $prefs_table;
2008 } else {
2009 $new_table =~ s/[\r|\n]//g;
2010 }
2011 return $new_table;
2012 }
2013
2014 sub save_data {
2015 $tab = " ";
2016 if ( open( CF, ">config.php" ) ) {
2017 print CF "<?php\n";
2018 print CF "\n";
2019
2020 print CF "/**\n";
2021 print CF " * SquirrelMail Configuration File\n";
2022 print CF " * Created using the configure script, conf.pl\n";
2023 print CF " */\n";
2024 print CF "\n";
2025
2026 if ($print_config_version) {
2027 print CF "\$config_version = '$print_config_version';\n";
2028 }
2029 print CF "\$config_use_color = $config_use_color;\n";
2030 print CF "\n";
2031
2032 print CF "\$org_name = \"$org_name\";\n";
2033 print CF "\$org_logo = '$org_logo';\n";
2034 print CF "\$org_title = \"$org_title\";\n";
2035 print CF "\$signout_page = '$signout_page';\n";
2036 print CF "\$frame_top = '$frame_top';\n";
2037 print CF "\n";
2038
2039 print CF "\$motd = '$motd';\n";
2040 print CF "\n";
2041
2042 print CF "\$squirrelmail_default_language = '$squirrelmail_default_language';\n";
2043 print CF "\n";
2044
2045 print CF "\$domain = '$domain';\n";
2046 print CF "\$imapServerAddress = '$imapServerAddress';\n";
2047 print CF "\$imapPort = $imapPort;\n";
2048 print CF "\$useSendmail = $useSendmail;\n";
2049 print CF "\$smtpServerAddress = '$smtpServerAddress';\n";
2050 print CF "\$smtpPort = $smtpPort;\n";
2051 print CF "\$sendmail_path = '$sendmail_path';\n";
2052 print CF "\$use_authenticated_smtp = $use_authenticated_smtp;\n";
2053 print CF "\$imap_server_type = '$imap_server_type';\n";
2054 print CF "\$invert_time = $invert_time;\n";
2055 print CF "\$optional_delimiter = '$optional_delimiter';\n";
2056 print CF "\n";
2057
2058 print CF "\$default_folder_prefix = '$default_folder_prefix';\n";
2059 print CF "\$trash_folder = '$trash_folder';\n";
2060 print CF "\$sent_folder = '$sent_folder';\n";
2061 print CF "\$draft_folder = '$draft_folder';\n";
2062 print CF "\$default_move_to_trash = $default_move_to_trash;\n";
2063 print CF "\$default_move_to_sent = $default_move_to_sent;\n";
2064 print CF "\$default_save_as_draft = $default_save_as_draft;\n";
2065 print CF "\$show_prefix_option = $show_prefix_option;\n";
2066 print CF "\$list_special_folders_first = $list_special_folders_first;\n";
2067 print CF "\$use_special_folder_color = $use_special_folder_color;\n";
2068 print CF "\$auto_expunge = $auto_expunge;\n";
2069 print CF "\$default_sub_of_inbox = $default_sub_of_inbox;\n";
2070 print CF "\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
2071 print CF "\$default_unseen_notify = $default_unseen_notify;\n";
2072 print CF "\$default_unseen_type = $default_unseen_type;\n";
2073 print CF "\$auto_create_special = $auto_create_special;\n";
2074 print CF "\$delete_folder = $delete_folder;\n";
2075 print CF "\n";
2076
2077 print CF "\$default_charset = '$default_charset';\n";
2078 print CF "\$data_dir = '$data_dir';\n";
2079 print CF "\$attachment_dir = \"$attachment_dir\";\n";
2080 print CF "\$dir_hash_level = $dir_hash_level;\n";
2081 print CF "\$default_left_size = $default_left_size;\n";
2082 print CF "\$force_username_lowercase = $force_username_lowercase;\n";
2083 print CF "\$default_use_priority = $default_use_priority;\n";
2084 print CF "\$hide_sm_attributions = $hide_sm_attributions;\n";
2085 print CF "\$default_use_mdn = $default_use_mdn;\n";
2086 print CF "\$edit_identity = $edit_identity;\n";
2087 print CF "\$edit_name = $edit_name;\n";
2088 print CF "\n";
2089
2090 for ( $ct = 0 ; $ct <= $#plugins ; $ct++ ) {
2091 print CF "\$plugins[$ct] = '$plugins[$ct]';\n";
2092 }
2093 print CF "\n";
2094
2095 print CF "\$theme_css = '$theme_css';\n";
2096 for ( $count = 0 ; $count <= $#theme_name ; $count++ ) {
2097 print CF "\$theme[$count]['PATH'] = '$theme_path[$count]';\n";
2098 print CF "\$theme[$count]['NAME'] = '$theme_name[$count]';\n";
2099 }
2100 print CF "\n";
2101
2102 if ( $default_use_javascript_addr_book ne "true" ) {
2103 $default_use_javascript_addr_book = "false";
2104 }
2105 print CF "\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
2106 for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
2107 print CF "\$ldap_server[$count] = array(\n";
2108 print CF " 'host' => '$ldap_host[$count]',\n";
2109 print CF " 'base' => '$ldap_base[$count]'";
2110 if ( $ldap_name[$count] ) {
2111 print CF ",\n";
2112 print CF " 'name' => '$ldap_name[$count]'";
2113 }
2114 if ( $ldap_port[$count] ) {
2115 print CF ",\n";
2116 print CF " 'port' => '$ldap_port[$count]'";
2117 }
2118 if ( $ldap_charset[$count] ) {
2119 print CF ",\n";
2120 print CF " 'charset' => '$ldap_charset[$count]'";
2121 }
2122 if ( $ldap_maxrows[$count] ) {
2123 print CF ",\n";
2124 print CF " 'maxrows' => '$ldap_maxrows[$count]'";
2125 }
2126 print CF "\n";
2127 print CF ");\n";
2128 print CF "\n";
2129 }
2130
2131 print CF "\$addrbook_dsn = '$addrbook_dsn';\n";
2132 print CF "\$addrbook_table = '$addrbook_table';\n\n";
2133 print CF "\$prefs_dsn = '$prefs_dsn';\n";
2134 print CF "\$prefs_table = '$prefs_table';\n\n";
2135
2136 print CF "/**\n";
2137 print CF " * Make sure there are no characters after the PHP closing\n";
2138 print CF " * tag below (including newline characters and whitespace).\n";
2139 print CF " * Otherwise, that character will cause the headers to be\n";
2140 print CF " * sent and regular output to begin, which will majorly screw\n";
2141 print CF " * things up when we try to send more headers later.\n";
2142 print CF " */\n";
2143 print CF "?>";
2144
2145 close CF;
2146
2147 print "Data saved in config.php\n";
2148 } else {
2149 print "Error saving config.php: $!\n";
2150 }
2151 }
2152
2153 sub set_defaults {
2154 system "clear";
2155 print $WHT. "SquirrelMail Configuration : " . $NRM;
2156 if ( $config == 1 ) { print "Read: config.php"; }
2157 elsif ( $config == 2 ) { print "Read: config_default.php"; }
2158 print "\n";
2159 print "---------------------------------------------------------\n";
2160
2161 print "While we have been building SquirrelMail, we have discovered some\n";
2162 print "preferences that work better with some servers that don't work so\n";
2163 print "well with others. If you select your IMAP server, this option will\n";
2164 print "set some pre-defined settings for that server.\n";
2165 print "\n";
2166 print "Please note that you will still need to go through and make sure\n";
2167 print "everything is correct. This does not change everything. There are\n";
2168 print "only a few settings that this will change.\n";
2169 print "\n";
2170
2171 $continue = 0;
2172 while ( $continue != 1 ) {
2173 print "Please select your IMAP server:\n";
2174 print " cyrus = Cyrus IMAP server\n";
2175 print " uw = University of Washington's IMAP server\n";
2176 print " exchange = Microsoft Exchange IMAP server\n";
2177 print " courier = Courier IMAP server\n";
2178 print " quit = Do not change anything\n";
2179 print "Command >> ";
2180 $server = <STDIN>;
2181 $server =~ s/[\r|\n]//g;
2182
2183 print "\n";
2184 if ( $server eq "cyrus" ) {
2185 $imap_server_type = "cyrus";
2186 $default_folder_prefix = "";
2187 $trash_folder = "INBOX.Trash";
2188 $sent_folder = "INBOX.Sent";
2189 $draft_folder = "INBOX.Drafts";
2190 $show_prefix_option = false;
2191 $default_sub_of_inbox = true;
2192 $show_contain_subfolders_option = false;
2193 $optional_delimiter = ".";
2194 $disp_default_folder_prefix = "<none>";
2195
2196 $continue = 1;
2197 } elsif ( $server eq "uw" ) {
2198 $imap_server_type = "uw";
2199 $default_folder_prefix = "mail/";
2200 $trash_folder = "Trash";
2201 $sent_folder = "Sent";
2202 $draft_folder = "Drafts";
2203 $show_prefix_option = true;
2204 $default_sub_of_inbox = false;
2205 $show_contain_subfolders_option = true;
2206 $optional_delimiter = "/";
2207 $disp_default_folder_prefix = $default_folder_prefix;
2208
2209 $continue = 1;
2210 } elsif ( $server eq "exchange" ) {
2211 $imap_server_type = "exchange";
2212 $default_folder_prefix = "";
2213 $default_sub_of_inbox = true;
2214 $trash_folder = "INBOX/Deleted Items";
2215 $sent_folder = "INBOX/Sent Items";
2216 $drafts_folder = "INBOX/Drafts";
2217 $show_prefix_option = false;
2218 $show_contain_subfolders_option = false;
2219 $optional_delimiter = "detect";
2220 $disp_default_folder_prefix = "<none>";
2221
2222 $continue = 1;
2223 } elsif ( $server eq "courier" ) {
2224 $imap_server_type = "courier";
2225 $default_folder_prefix = "INBOX.";
2226 $trash_folder = "Trash";
2227 $sent_folder = "Sent";
2228 $draft_folder = "Drafts";
2229 $show_prefix_option = false;
2230 $default_sub_of_inbox = false;
2231 $show_contain_subfolders_option = false;
2232 $optional_delimiter = ".";
2233 $disp_default_folder_prefix = $default_folder_prefix;
2234
2235 $continue = 1;
2236 } elsif ( $server eq "quit" ) {
2237 $continue = 1;
2238 } else {
2239 $disp_default_folder_prefix = $default_folder_prefix;
2240 print "Unrecognized server: $server\n";
2241 print "\n";
2242 }
2243
2244 print " imap_server_type = $imap_server_type\n";
2245 print " default_folder_prefix = $disp_default_folder_prefix\n";
2246 print " trash_folder = $trash_folder\n";
2247 print " sent_folder = $sent_folder\n";
2248 print " draft_folder = $draft_folder\n";
2249 print " show_prefix_option = $show_prefix_option\n";
2250 print " default_sub_of_inbox = $default_sub_of_inbox\n";
2251 print "show_contain_subfolders_option = $show_contain_subfolders_option\n";
2252 print " optional_delimiter = $optional_delimiter\n";
2253 }
2254 print "\nPress any key to continue...";
2255 $tmp = <STDIN>;
2256 }