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