X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=config%2Fconf.pl;h=7c37409ee58b9caaf5536a232e5562a5d6593166;hp=4d6f4972958c47d61e3f723fe5c0766823f11b73;hb=9ebace193471e0957e523805e59e8676a831c2b7;hpb=93d67e0d5939181eb6c57f6141b9f1786d784233 diff --git a/config/conf.pl b/config/conf.pl index 4d6f4972..7c37409e 100755 --- a/config/conf.pl +++ b/config/conf.pl @@ -1,7 +1,7 @@ #!/usr/bin/env perl # conf.pl # -# Copyright (c) 1999-2006 The SquirrelMail Project Team +# Copyright (c) 1999-2007 The SquirrelMail Project Team # Licensed under the GNU GPL. For full terms see COPYING. # # A simple configure script to configure SquirrelMail @@ -140,7 +140,7 @@ if ( -e "config.php" ) { print " should get the 'config_default.php' that matches the version\n"; print " of SquirrelMail that you are running. You can get this from\n"; print " the SquirrelMail web page by going to the following URL:\n"; - print " http://www.squirrelmail.org.\n"; + print " http://squirrelmail.org.\n"; print "\n"; print "Continue loading with old config_default.php (a bad idea) [y/N]? "; $ctu = ; @@ -385,7 +385,7 @@ $delete_folder = 'false' if ( !$delete_folder ); $noselect_fix_enable = 'false' if ( !$noselect_fix_enable ); $frame_top = "_top" if ( !$frame_top ); $provider_uri = '' if ( !$provider_uri ); -$provider_name = '' if ( !$provider_name ); +$provider_name = '' if ( !$provider_name || $provider_name eq 'SquirrelMail'); $no_list_for_subscribe = 'false' if ( !$no_list_for_subscribe ); $allow_charset_search = 'true' if ( !$allow_charset_search ); $allow_advanced_search = 0 if ( !$allow_advanced_search) ; @@ -424,6 +424,13 @@ $use_icons = 'false' if ( !$use_icons ); $use_iframe = 'false' if ( !$use_iframe ); $lossy_encoding = 'false' if ( !$lossy_encoding ); $allow_remote_configtest = 'false' if ( !$allow_remote_configtest ); +$secured_config = 'true' if ( !$secured_config ); + +$sm_debug_mode = 'SM_DEBUG_MODE_MODERATE' if ( !$sm_debug_mode ); +#FIXME: When this is STABLE software, remove the line above and uncomment the one below: +#$sm_debug_mode = 'SM_DEBUG_MODE_OFF' if ( !$sm_debug_mode ); +$sm_debug_mode = convert_debug_binary_integer_to_constants($sm_debug_mode); + $addrbook_global_table = 'global_abook' if ( !$addrbook_global_table ); $addrbook_global_writeable = 'false' if ( !$addrbook_global_writeable ); $addrbook_global_listing = 'false' if ( !$addrbook_global_listing ); @@ -471,12 +478,19 @@ $smtp_sitewide_pass = '' if ( !$smtp_sitewide_pass ); $icon_theme_def = '' if ( !$icon_theme_def ); $disable_plugins = 'false' if ( !$disable_plugins ); $disable_plugins_user = '' if ( !$disable_plugins_user ); +$only_secure_cookies = 'true' if ( !$only_secure_cookies ); +$ask_user_info = 'true' if ( !$ask_user_info ); if ( $ARGV[0] eq '--install-plugin' ) { print "Activating plugin " . $ARGV[1] . "\n"; - push @plugins, $ARGV[1]; - save_data(); - exit(0); + if ( -d "../plugins/" . $ARGV[1]) { + push @plugins, $ARGV[1]; + save_data(); + exit(0); + } else { + print "No such plugin.\n"; + exit(1); + } } elsif ( $ARGV[0] eq '--remove-plugin' ) { print "Removing plugin " . $ARGV[1] . "\n"; foreach $plugin (@plugins) { @@ -503,6 +517,22 @@ if ( $ARGV[0] eq '--install-plugin' ) { exit(0); } + + +#################################################################################### + +# used in multiple places, define once +$list_supported_imap_servers = + " bincimap = Binc IMAP server\n" . + " courier = Courier IMAP server\n" . + " cyrus = Cyrus IMAP server\n" . + " dovecot = Dovecot Secure IMAP server\n" . + " exchange = Microsoft Exchange IMAP server\n" . + " hmailserver = hMailServer\n" . + " macosx = Mac OS X Mailserver\n" . + " mercury32 = Mercury/32\n" . + " uw = University of Washington's IMAP server\n"; + ##################################################################################### if ( $config_use_color == 1 ) { $WHT = "\x1B[37;1m"; @@ -546,7 +576,7 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) { print "5. Signout Page : $WHT$signout_page$NRM\n"; print "6. Top Frame : $WHT$frame_top$NRM\n"; print "7. Provider link : $WHT$provider_uri$NRM\n"; - print "8. Provider name : $WHT$provider_name$NRM\n"; + print "8. Provider link text : $WHT$provider_name$NRM\n"; print "\n"; print "R Return to Main Menu\n"; @@ -619,46 +649,47 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) { print "R Return to Main Menu\n"; } elsif ( $menu == 3 ) { print $WHT. "Folder Defaults\n" . $NRM; - print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n"; - print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n"; - print "3. Trash Folder : $WHT$trash_folder$NRM\n"; - print "4. Sent Folder : $WHT$sent_folder$NRM\n"; - print "5. Drafts Folder : $WHT$draft_folder$NRM\n"; - print "6. By default, move to trash : $WHT$default_move_to_trash$NRM\n"; - print "7. By default, move to sent : $WHT$default_move_to_sent$NRM\n"; - print "8. By default, save as draft : $WHT$default_save_as_draft$NRM\n"; - print "9. List Special Folders First : $WHT$list_special_folders_first$NRM\n"; - print "10. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n"; - print "11. Auto Expunge : $WHT$auto_expunge$NRM\n"; - print "12. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n"; - print "13. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n"; - print "14. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n"; - print "15. Default Unseen Type : $WHT$default_unseen_type$NRM\n"; - print "16. Auto Create Special Folders : $WHT$auto_create_special$NRM\n"; - print "17. Folder Delete Bypasses Trash : $WHT$delete_folder$NRM\n"; - print "18. Enable /NoSelect folder fix : $WHT$noselect_fix_enable$NRM\n"; + print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n"; + print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n"; + print "3. Trash Folder : $WHT$trash_folder$NRM\n"; + print "4. Sent Folder : $WHT$sent_folder$NRM\n"; + print "5. Drafts Folder : $WHT$draft_folder$NRM\n"; + print "6. By default, move to trash : $WHT$default_move_to_trash$NRM\n"; + print "7. By default, save sent messages : $WHT$default_move_to_sent$NRM\n"; + print "8. By default, save as draft : $WHT$default_save_as_draft$NRM\n"; + print "9. List Special Folders First : $WHT$list_special_folders_first$NRM\n"; + print "10. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n"; + print "11. Auto Expunge : $WHT$auto_expunge$NRM\n"; + print "12. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n"; + print "13. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n"; + print "14. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n"; + print "15. Default Unseen Type : $WHT$default_unseen_type$NRM\n"; + print "16. Auto Create Special Folders : $WHT$auto_create_special$NRM\n"; + print "17. Folder Delete Bypasses Trash : $WHT$delete_folder$NRM\n"; + print "18. Enable /NoSelect folder fix : $WHT$noselect_fix_enable$NRM\n"; print "\n"; print "R Return to Main Menu\n"; } elsif ( $menu == 4 ) { print $WHT. "General Options\n" . $NRM; - print "1. Data Directory : $WHT$data_dir$NRM\n"; - print "2. Attachment Directory : $WHT$attachment_dir$NRM\n"; - print "3. Directory Hash Level : $WHT$dir_hash_level$NRM\n"; - print "4. Default Left Size : $WHT$default_left_size$NRM\n"; - print "5. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n"; - print "6. Allow use of priority : $WHT$default_use_priority$NRM\n"; - print "7. Hide SM attributions : $WHT$hide_sm_attributions$NRM\n"; - print "8. Allow use of receipts : $WHT$default_use_mdn$NRM\n"; - print "9. Allow editing of identity : $WHT$edit_identity$NRM\n"; - print " Allow editing of name : $WHT$edit_name$NRM\n"; - print " Remove username from header : $WHT$hide_auth_header$NRM\n"; - print "10. Disable server thread sort : $WHT$disable_thread_sort$NRM\n"; - print "11. Disable server-side sorting : $WHT$disable_server_sort$NRM\n"; - print "12. Allow server charset search : $WHT$allow_charset_search$NRM\n"; - print "13. Allow advanced search : $WHT$allow_advanced_search$NRM\n"; - print "14. PHP session name : $WHT$session_name$NRM\n"; - print "15. Time zone configuration : $WHT$time_zone_type$NRM\n"; - print "16. Location base : $WHT$config_location_base$NRM\n"; + print "1. Data Directory : $WHT$data_dir$NRM\n"; + print "2. Attachment Directory : $WHT$attachment_dir$NRM\n"; + print "3. Directory Hash Level : $WHT$dir_hash_level$NRM\n"; + print "4. Default Left Size : $WHT$default_left_size$NRM\n"; + print "5. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n"; + print "6. Allow use of priority : $WHT$default_use_priority$NRM\n"; + print "7. Hide SM attributions : $WHT$hide_sm_attributions$NRM\n"; + print "8. Allow use of receipts : $WHT$default_use_mdn$NRM\n"; + print "9. Allow editing of identity : $WHT$edit_identity$NRM\n"; + print " Allow editing of name : $WHT$edit_name$NRM\n"; + print " Remove username from header : $WHT$hide_auth_header$NRM\n"; + print "10. Disable server thread sort : $WHT$disable_thread_sort$NRM\n"; + print "11. Disable server-side sorting : $WHT$disable_server_sort$NRM\n"; + print "12. Allow server charset search : $WHT$allow_charset_search$NRM\n"; + print "13. Allow advanced search : $WHT$allow_advanced_search$NRM\n"; + print "14. PHP session name : $WHT$session_name$NRM\n"; + print "15. Time zone configuration : $WHT$time_zone_type$NRM\n"; + print "16. Location base : $WHT$config_location_base$NRM\n"; + print "17. Only secure cookies if poss. : $WHT$only_secure_cookies$NRM\n"; print "\n"; print "R Return to Main Menu\n"; } elsif ( $menu == 5 ) { @@ -666,7 +697,7 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) { print "1. Use Icons? : $WHT$use_icons$NRM\n"; # print "3. Default Icon Set : $WHT$icon_theme_def$NRM\n"; print "2. Default font size : $WHT$default_fontsize$NRM\n"; - print "3. Manage template sets\n"; + print "3. Manage template sets (skins)\n"; print "4. Manage user themes\n"; print "5. Manage font sets\n"; print "6. Manage icon themes\n"; @@ -705,15 +736,20 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) { $num = 0; for ( $count = 0 ; $count <= $#plugins ; $count++ ) { $num = $count + 1; - print " $num. $plugins[$count]\n"; + $english_name = get_plugin_english_name($plugins[$count]); + if ( $english_name eq "" ) { + print " $num. $plugins[$count]" . get_plugin_version($plugins[$count]) . "\n"; + } else { + print " $num. $english_name ($plugins[$count])" . get_plugin_version($plugins[$count]) . "\n"; + } } print "\n Available Plugins:\n"; opendir( DIR, "../plugins" ); - @files = readdir(DIR); + @files = sort(readdir(DIR)); $pos = 0; @unused_plugins = (); for ( $i = 0 ; $i <= $#files ; $i++ ) { - if ( -d "../plugins/" . $files[$i] && $files[$i] !~ /^\./ && $files[$i] ne "CVS" ) { + if ( -d "../plugins/" . $files[$i] && $files[$i] !~ /^\./ && $files[$i] ne ".svn" ) { $match = 0; for ( $k = 0 ; $k <= $#plugins ; $k++ ) { if ( $plugins[$k] eq $files[$i] ) { @@ -729,7 +765,12 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) { for ( $i = 0 ; $i <= $#unused_plugins ; $i++ ) { $num = $num + 1; - print " $num. $unused_plugins[$i]\n"; + $english_name = get_plugin_english_name($unused_plugins[$i]); + if ( $english_name eq "" ) { + print " $num. $unused_plugins[$i]" . get_plugin_version($unused_plugins[$i]) . "\n"; + } else { + print " $num. $english_name ($unused_plugins[$i])" . get_plugin_version($unused_plugins[$i]) . "\n"; + } } closedir DIR; @@ -772,6 +813,7 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) { } elsif ( $menu == 11 ) { print $WHT. "Interface tweaks\n" . $NRM; print "1. Display html mails in iframe : $WHT$use_iframe$NRM\n"; + print "2. Ask user info on first login : $WHT$ask_user_info$NRM\n"; print "\n"; print $WHT. "PHP tweaks\n" . $NRM; print "4. Use php recode functions : $WHT$use_php_recode$NRM\n"; @@ -779,6 +821,8 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) { print "\n"; print $WHT. "Configuration tweaks\n" . $NRM; print "6. Allow remote configtest : $WHT$allow_remote_configtest$NRM\n"; + print "7. Debug mode : $WHT$sm_debug_mode$NRM\n"; + print "8. Secured configuration mode : $WHT$secured_config$NRM\n"; print "\n"; print "R Return to Main Menu\n"; } @@ -904,6 +948,7 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) { elsif ( $command == 14 ) { $session_name = command317(); } elsif ( $command == 15 ) { $time_zone_type = command318(); } elsif ( $command == 16 ) { $config_location_base = command_config_location_base(); } + elsif ( $command == 17 ) { $only_secure_cookies = command319(); } } elsif ( $menu == 5 ) { if ( $command == 1 ) { $use_icons = commandB3(); } # elsif ( $command == 3 ) { $icon_theme_def = commandB7(); } @@ -946,9 +991,12 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) { elsif ( $command == 5 ) { $lossy_encoding = commandA5(); } } elsif ( $menu == 11 ) { if ( $command == 1 ) { $use_iframe = commandB2(); } + elsif ( $command == 2 ) { $ask_user_info = command_ask_user_info(); } elsif ( $command == 4 ) { $use_php_recode = commandB4(); } elsif ( $command == 5 ) { $use_php_iconv = commandB5(); } elsif ( $command == 6 ) { $allow_remote_configtest = commandB6(); } + elsif ( $command == 7 ) { $sm_debug_mode = commandB8(); } + elsif ( $command == 8 ) { $secured_config = commandB9(); } } } } @@ -993,7 +1041,7 @@ sub command2 { print " to use the default logo, use ../images/sm_logo.png\n"; print " - To specify a logo defined outside the SquirrelMail source tree\n"; print " use the absolute URL the webserver would use to include the file\n"; - print " e.g. http://www.example.com/images/mylogo.gif or /images/mylogo.jpg\n"; + print " e.g. http://example.com/images/mylogo.gif or /images/mylogo.jpg\n"; print "\n"; print "[$WHT$org_logo$NRM]: $WHT"; $new_org_logo = ; @@ -1088,8 +1136,8 @@ sub command6 { # Default link to provider sub command7 { - print "Here you can set the link on the right of the page.\n"; - print "If empty, it will link to the SquirrelMail About page.\n"; + print "Here you can set the link on the top-right of the message list.\n"; + print "If empty, it will not be displayed.\n"; print "\n"; print "[$WHT$provider_uri$NRM]: $WHT"; $new_provider_uri = ; @@ -1103,13 +1151,13 @@ sub command7 { } sub command8 { - print "Here you can set the name of the link on the right of the page.\n"; - print "The default is 'SquirrelMail'\n"; + print "Here you can set the name of the link on the top-right of the message list.\n"; + print "The default is empty (do not display anything).'\n"; print "\n"; print "[$WHT$provider_name$NRM]: $WHT"; $new_provider_name = ; if ( $new_provider_name eq "\n" ) { - $new_provider_name = 'SquirrelMail'; + $new_provider_name = ''; } else { $new_provider_name =~ s/[\r\n]//g; $new_provider_name =~ s/^\s+$//g; @@ -1131,7 +1179,7 @@ sub command11 { if ( $new_domain eq "\n" ) { $new_domain = $domain; } else { - $new_domain =~ s/[\r\n]//g; + $new_domain =~ s/\s//g; } return $new_domain; } @@ -1271,14 +1319,7 @@ sub command19 { print "these servers. If you would like to use them, please select your\n"; print "IMAP server. If you do not wish to use these work-arounds, you can\n"; print "set this to \"other\", and none will be used.\n"; - print " courier = Courier IMAP server\n"; - print " cyrus = Cyrus IMAP server\n"; - print " dovecot = Dovecot Secure IMAP server\n"; - print " exchange = Microsoft Exchange IMAP server\n"; - print " hmailserver = hMailServer\n"; - print " macosx = Mac OS X Mailserver\n"; - print " mercury32 = Mercury Mail Transport System\n"; - print " uw = University of Washington's IMAP server\n"; + print $list_supported_imap_servers; print "\n"; print " other = Not one of the above servers\n"; print "\n"; @@ -1428,6 +1469,7 @@ sub command112b { print " ERROR TESTING\n"; close $sock; } else { + $got = <$sock>; # Discard greeting print $sock "HELO $domain\r\n"; $got = <$sock>; # Discard print $sock "MAIL FROM:\r\n"; @@ -1528,10 +1570,10 @@ sub command_smtp_sitewide_userpass($) { print "SMTP connections?"; if ($smtp_sitewide_user ne '') { $default = 'y'; - print " [Yn]:"; + print " [Y/n]:"; } else { $default = 'n'; - print " [yN]:"; + print " [y/N]:"; } $tmp=; $tmp = trim($tmp); @@ -1897,11 +1939,12 @@ sub command24a { return $default_move_to_trash; } -# default move to sent +# default move to sent (save sent messages) sub command24b { - print "By default, should messages get moved to the sent folder? You\n"; - print "can specify the default sent folder in option 4. If this is set\n"; - print "to false, messages will get sent and no copy will be made.\n"; + print "By default, should copies of outgoing messages get saved in the\n"; + print "sent folder? You can specify the default sent folder in option 4.\n"; + print "If this is set to false, messages will get sent and no copy will\n"; + print "be made.\n"; print "\n"; print "Sent folder is currently: $sent_folder\n"; print "\n"; @@ -1911,7 +1954,7 @@ sub command24b { } else { $default_value = "n"; } - print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT"; + print "By default, save sent messages (y/n) [$WHT$default_value$NRM]: $WHT"; $new_show = ; if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { $default_move_to_sent = 'true'; @@ -1930,7 +1973,7 @@ sub command24c { print "Drafts folder is currently: $draft_folder\n"; print "\n"; - if ( lc($default_move_to_draft) eq 'true' ) { + if ( lc($default_save_as_draft) eq 'true' ) { $default_value = "y"; } else { $default_value = "n"; @@ -2172,7 +2215,7 @@ sub command215 { #noselect fix sub command216 { - print "Some IMAP server allow subfolders to exist even if the parent\n"; + print "Some IMAP servers allow subfolders to exist even if the parent\n"; print "folders do not. This fixes some problems with the folder list\n"; print "when this is the case, causing the /NoSelect folders to be displayed\n"; print "\n"; @@ -2358,7 +2401,7 @@ sub command38 { print ""; print "\n"; - if ( lc($default_hide_attribution) eq 'true' ) { + if ( lc($hide_sm_attributions) eq 'true' ) { $default_value = "y"; } else { $default_value = "n"; @@ -2583,7 +2626,7 @@ sub command318 { print "See SquirrelMail documentation about format of config/timezones.php file.\n"; print "\n"; - print "Used time zone configuration (0,1,2,3)? [$WHT$time_zone_type$NRM]: $WHT"; + print "Desired time zone configuration (0,1,2,3)? [$WHT$time_zone_type$NRM]: $WHT"; $new_time_zone_type = ; if ( $new_time_zone_type =~ /^[0123]\n/i ) { $time_zone_type = $new_time_zone_type; @@ -2614,6 +2657,32 @@ sub command_config_location_base { return $config_location_base; } +# only_secure_cookies (since 1.5.2) +sub command319 { + print "This option allows you to specify that if a user session is initiated\n"; + print "under a secure (HTTPS, SSL-encrypted) connection, the cookies given to\n"; + print "the browser will ONLY be transmitted via a secure connection henceforth.\n\n"; + print "Generally this is a Good Thing, and should NOT be disabled. However,\n"; + print "if you intend to use the Secure Login or Show SSL Link plugins to\n"; + print "encrypt the user login, but not the rest of the SquirrelMail session,\n"; + print "this can be turned off. Think twice before doing so.\n"; + print "\n"; + + if ( lc($only_secure_cookies) eq 'true' ) { + $default_value = "y"; + } else { + $default_value = "n"; + } + print "Transmit cookies only on secure connection when available? (y/n) [$WHT$default_value$NRM]: $WHT"; + $only_secure_cookies = ; + if ( ( $only_secure_cookies =~ /^y\n/i ) || ( ( $only_secure_cookies =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { + $only_secure_cookies = 'true'; + } else { + $only_secure_cookies = 'false'; + } + return $only_secure_cookies; +} + sub command_userThemes { print "\nDefine the user themes that you wish to use. If you have added\n"; @@ -2728,11 +2797,11 @@ sub command_userThemes { print "\nStarting detection...\n\n"; opendir( DIR, "../css" ); - @files = readdir(DIR); + @files = sort(readdir(DIR)); $cnt = 0; while ( $cnt <= $#files ) { $filename = "../css/" . $files[$cnt] .'/'; - if ( $filename ne "../css/rtl.css" && -e $filename . "default.css" ) { + if ( $files[$cnt] !~ /^\./ && $filename ne "../css/rtl.css" && -e $filename . "default.css" ) { $found = 0; for ( $x = 0 ; $x <= $#user_theme_path ; $x++ ) { if ( $user_theme_path[$x] eq $filename ) { @@ -2741,9 +2810,16 @@ sub command_userThemes { } if ( $found != 1 ) { print "** Found user theme: $filename\n"; - print " What is its name? "; + $def = $files[$cnt]; + $def =~ s/_/ /g; + $def = lc($def); + #$def =~ s/(^\w+)/ucfirst $1/eg; + #$def =~ s/(\s+)(\w+)/$1 . ucfirst $2/eg; + $def =~ s/(^\w+)|(\s+)(\w+)/ucfirst $1 . $2 . ucfirst $3/eg; + print " What is its name? [$def]: "; $nm = ; - $nm =~ s/[\n\r]//g; + $nm =~ s/^\s+|\s+$|[\n\r]//g; + if ( $nm eq '' ) { $nm = $def; } $user_theme_name[ $#user_theme_name + 1 ] = $nm; $user_theme_path[ $#user_theme_path + 1 ] = $filename; } @@ -2933,11 +3009,11 @@ sub command_iconSets { print "\nStarting detection...\n\n"; opendir( DIR, "../images/themes/" ); - @files = readdir(DIR); + @files = sort(readdir(DIR)); $cnt = 0; while ( $cnt <= $#files ) { $filename = "../images/themes/" . $files[$cnt] .'/'; - if ( -d "../images/themes/" . $files[$cnt] && $files[$cnt] !~ /^\./ && $files[$cnt] ne "CVS" ) { + if ( -d "../images/themes/" . $files[$cnt] && $files[$cnt] !~ /^\./ && $files[$cnt] ne ".svn" ) { $found = 0; for ( $x = 0 ; $x <= $#icon_theme_path ; $x++ ) { if ( $icon_theme_path[$x] eq $filename ) { @@ -2946,9 +3022,16 @@ sub command_iconSets { } if ( $found != 1 ) { print "** Found icon theme: $filename\n"; - print " What is its name? "; + $def = $files[$cnt]; + $def =~ s/_/ /g; + $def = lc($def); + #$def =~ s/(^\w+)/ucfirst $1/eg; + #$def =~ s/(\s+)(\w+)/$1 . ucfirst $2/eg; + $def =~ s/(^\w+)|(\s+)(\w+)/ucfirst $1 . $2 . ucfirst $3/eg; + print " What is its name? [$def]: "; $nm = ; - $nm =~ s/[\n\r]//g; + $nm =~ s/^\s+|\s+$|[\n\r]//g; + if ( $nm eq '' ) { $nm = $def; } $icon_theme_name[ $#icon_theme_name + 1 ] = $nm; $icon_theme_path[ $#icon_theme_path + 1 ] = $filename; } @@ -3000,7 +3083,7 @@ sub command_iconSets { } sub command_templates { - print "\nDefine the template sets that you wish to use. If you have added\n"; + print "\nDefine the template sets (skins) that you wish to use. If you have added\n"; print "a template set of your own, just follow the instructions (?) about\n"; print "how to add them. You can also change the default template.\n"; @@ -3041,7 +3124,7 @@ sub command_templates { . "| - N (remove template set) |\n" . "| m N (mark default template set) |\n" . "| f N (set fallback template set) |\n" - . "| l (list template sets) |\n" + . "| l (list template sets/skins) |\n" . "| d (done) |\n" . "|-------------------------------------|\n" . "| where N is a template set number |\n" @@ -3129,10 +3212,10 @@ sub command_templates { } elsif ( $input =~ /^\s*t\s*/i ) { print "\nStarting detection...\n\n"; opendir( DIR, "../templates" ); - @files = readdir(DIR); + @files = sort(readdir(DIR)); $cnt = 0; while ( $cnt <= $#files ) { - if ( -d "../templates/" . $files[$cnt] && $files[$cnt] !~ /^\./ && $files[$cnt] ne "CVS" ) { + if ( -d "../templates/" . $files[$cnt] && $files[$cnt] !~ /^\./ && $files[$cnt] ne ".svn" ) { $filename = $files[$cnt]; $found = 0; for ( $x = 0 ; $x <= $#templateset_id ; $x++ ) { @@ -3143,9 +3226,16 @@ sub command_templates { } if ( $found != 1) { print "** Found template set: $filename\n"; - print " What is it's name (as shown to your users)? "; + $def = $files[$cnt]; + $def =~ s/_/ /g; + $def = lc($def); + #$def =~ s/(^\w+)/ucfirst $1/eg; + #$def =~ s/(\s+)(\w+)/$1 . ucfirst $2/eg; + $def =~ s/(^\w+)|(\s+)(\w+)/ucfirst $1 . $2 . ucfirst $3/eg; + print " What is it's name (as shown to your users)? [$def]: "; $nm = ; - $nm =~ s/[\n\r]//g; + $nm =~ s/^\s+|\s+$|[\n\r]//g; + if ( $nm eq '' ) { $nm = $def; } $templateset_id[ $#templateset_id + 1 ] = $filename; $templateset_name[ $#templateset_name + 1 ] = $nm; } @@ -4118,6 +4208,30 @@ sub commandB2 { } return $use_iframe; } + +# ask user info +sub command_ask_user_info { + print "New users need to supply their real name and email address to\n"; + print "send out proper mails. When this option is enabled, a user that\n"; + print "logs in for the first time will be redirected to the Personal\n"; + print "Options screen and asked to supply their personal data.\n"; + print "\n"; + + if ( lc($ask_user_info) eq 'true' ) { + $default_value = "y"; + } else { + $default_value = "n"; + } + print "Ask user info? (y/n) [$WHT$default_value$NRM]: $WHT"; + $ask_user_info = ; + if ( ( $ask_user_info =~ /^y\n/i ) || ( ( $ask_user_info =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { + $ask_user_info = 'true'; + } else { + $ask_user_info = 'false'; + } + return $ask_user_info; +} + # use icons sub commandB3 { print "Enabling this option will cause icons to be used instead of text\n"; @@ -4239,6 +4353,112 @@ sub commandB7 { return $new_icon_theme_def; } +# SquirrelMail debug mode (since 1.5.2) +sub commandB8 { + print "When debugging or developing SquirrelMail, you may want to increase\n"; + print "the verbosity of certain kinds of errors, notices, and/or diagnostics.\n"; + print "You may enable one or more of the debugging modes here. Please make\n"; + print "sure that you have turned off debugging if you are using SquirrelMail\n"; + print "in a production environment.\n\n"; + + $input = ""; + while ( $input ne "d\n" ) { + $sm_debug_mode = convert_debug_constants_to_binary_integer($sm_debug_mode); + + # per include/constants.php, here are the debug mode values: + # + # 0 SM_DEBUG_MODE_OFF + # 1 SM_DEBUG_MODE_SIMPLE + # 512 SM_DEBUG_MODE_MODERATE + # 524288 SM_DEBUG_MODE_ADVANCED + # 536870912 SM_DEBUG_MODE_STRICT + # + print "\n# Enabled? Description\n"; + print "---------------------------------------------------------------------\n"; + print "0 " . ($sm_debug_mode == 0 ? "y" : " ") + . " No debugging (recommended in production environments)\n"; + print "1 " . ($sm_debug_mode & 1 ? "y" : " ") + . " Simple debugging (PHP E_ERROR)\n"; + print "2 " . ($sm_debug_mode & 512 ? "y" : " ") + . " Moderate debugging (PHP E_ALL)\n"; + print "3 " . ($sm_debug_mode & 524288 ? "y" : " ") + . " Advanced debugging (PHP E_ALL plus log errors\n"; + print " intentionally suppressed)\n"; + print "4 " . ($sm_debug_mode & 536870912 ? "y" : " ") + . " Strict debugging (PHP E_STRICT)\n"; + print "\n"; + + print "SquirrelMail debug mode (0,1,2,3,4) or d when done? : $WHT"; + $input = ; + if ( $input eq "d\n" ) { + # nothing + } elsif ($input !~ /^[0-9]+\n$/) { + print "\nInvalid configuration value.\n"; + print "\nPress enter to continue..."; + $tmp = ; + } elsif ( $input == "0\n" ) { + $sm_debug_mode = 0; + } elsif ( $input == "1\n" ) { + if ($sm_debug_mode & 1) { + $sm_debug_mode ^= 1; + } else { + $sm_debug_mode |= 1; + } + } elsif ( $input == "2\n" ) { + if ($sm_debug_mode & 512) { + $sm_debug_mode ^= 512; + } else { + $sm_debug_mode |= 512; + } + } elsif ( $input == "3\n" ) { + if ($sm_debug_mode & 524288) { + $sm_debug_mode ^= 524288; + } else { + $sm_debug_mode |= 524288; + } + } elsif ( $input == "4\n" ) { + if ($sm_debug_mode & 536870912) { + $sm_debug_mode ^= 536870912; + } else { + $sm_debug_mode |= 536870912; + } + } else { + print "\nInvalid configuration value.\n"; + print "\nPress enter to continue..."; + $tmp = ; + } + print "\n"; + } + $sm_debug_mode = convert_debug_binary_integer_to_constants($sm_debug_mode); + return $sm_debug_mode; +} + +# Secured configuration mode (since 1.5.2) +sub commandB9 { + print "This option allows you to enable \"Secured Configuration\" mode,\n"; + print "which will guarantee that certain settings made herein will be\n"; + print "made immutable and will not be subject to override by either friendly\n"; + print "or unfriendly code/plugins. Only a small number of settings herein\n"; + print "will be used in this manner - just those that are deemed to be a\n"; + print "potential security threat when rouge plugin or other code may be\n"; + print "executed inside SquirrelMail.\n"; + print "\n"; + + if ( lc($secured_config) eq 'true' ) { + $default_value = "y"; + } else { + $default_value = "n"; + } + print "Enable secured configuration mode? (y/n) [$WHT$default_value$NRM]: $WHT"; + $secured_config = ; + if ( ( $secured_config =~ /^y\n/i ) || ( ( $secured_config =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { + $secured_config = 'true'; + } else { + $secured_config = 'false'; + } + return $secured_config; +} + sub save_data { $tab = " "; if ( open( CF, ">config.php" ) ) { @@ -4250,7 +4470,6 @@ sub save_data { print CF " * Created using the configure script, conf.pl\n"; print CF " */\n"; print CF "\n"; - print CF "global \$version;\n"; if ($print_config_version) { print CF "\$config_version = '$print_config_version';\n"; @@ -4605,34 +4824,41 @@ sub save_data { print CF "\$no_list_for_subscribe = $no_list_for_subscribe;\n"; # string - print CF "\$smtp_auth_mech = '$smtp_auth_mech';\n"; - print CF "\$smtp_sitewide_user = '". quote_single($smtp_sitewide_user) ."';\n"; - print CF "\$smtp_sitewide_pass = '". quote_single($smtp_sitewide_pass) ."';\n"; + print CF "\$smtp_auth_mech = '$smtp_auth_mech';\n"; + print CF "\$smtp_sitewide_user = '". quote_single($smtp_sitewide_user) ."';\n"; + print CF "\$smtp_sitewide_pass = '". quote_single($smtp_sitewide_pass) ."';\n"; # string - print CF "\$imap_auth_mech = '$imap_auth_mech';\n"; + print CF "\$imap_auth_mech = '$imap_auth_mech';\n"; # boolean - print CF "\$use_imap_tls = $use_imap_tls;\n"; + print CF "\$use_imap_tls = $use_imap_tls;\n"; # boolean - print CF "\$use_smtp_tls = $use_smtp_tls;\n"; + print CF "\$use_smtp_tls = $use_smtp_tls;\n"; # string - print CF "\$session_name = '$session_name';\n"; + print CF "\$session_name = '$session_name';\n"; + # boolean + print CF "\$only_secure_cookies = $only_secure_cookies;\n"; print CF "\n"; # boolean print CF "\$use_iframe = $use_iframe;\n"; - print CF "\n"; + # boolean + print CF "\$ask_user_info = $ask_user_info;\n"; # boolean print CF "\$use_icons = $use_icons;\n"; print CF "\n"; # boolean print CF "\$use_php_recode = $use_php_recode;\n"; - print CF "\n"; # boolean print CF "\$use_php_iconv = $use_php_iconv;\n"; print CF "\n"; # boolean print CF "\$allow_remote_configtest = $allow_remote_configtest;\n"; + print CF "\$secured_config = $secured_config;\n"; + # (binary) integer or constant - convert integer + # values to constants before output + $sm_debug_mode = convert_debug_binary_integer_to_constants($sm_debug_mode); + print CF "\$sm_debug_mode = $sm_debug_mode;\n"; print CF "\n"; close CF; @@ -4667,15 +4893,7 @@ sub set_defaults { $continue = 0; while ( $continue != 1 ) { print "Please select your IMAP server:\n"; - print " bincimap = Binc IMAP server\n"; - print " courier = Courier IMAP server\n"; - print " cyrus = Cyrus IMAP server\n"; - print " dovecot = Dovecot Secure IMAP server\n"; - print " exchange = Microsoft Exchange IMAP server\n"; - print " hmailserver = hMailServer\n"; - print " macosx = Mac OS X Mailserver\n"; - print " mercury32 = Mercury/32\n"; - print " uw = University of Washington's IMAP server\n"; + print $list_supported_imap_servers; print "\n"; print " quit = Do not change anything\n"; print "\n"; @@ -4990,14 +5208,11 @@ sub detect_auth_support { # So at this point, we have a response, and it is (hopefully) valid. if ($service eq 'SMTP') { - if (($response =~ /^535/) or ($response =~/^502/)) { + if (!($response =~ /^334/)) { # Not supported print $sock $logout; close $sock; return 'NO'; - } elsif ($response =~ /^503/) { - #Something went wrong - return undef; } } elsif ($service eq 'IMAP') { if ($response =~ /^A01/) { @@ -5052,7 +5267,7 @@ sub check_imap_folder($) { } elsif ($folder_name =~ /[&\*\%]/) { # check for ampersand and list-wildcards print "Folder name contains special UTF7-IMAP characters.\n"; - print "Are you sure that folder name is correct? (yN): "; + print "Are you sure that folder name is correct? (y/N): "; my $tmp = ; $tmp = lc(trim($tmp)); if ($tmp =~ /^y$/) { @@ -5072,6 +5287,123 @@ sub quote_single($) { return $string; } +# determine a plugin's version number +# +# parses the setup.php file, looking for the +# version string in the _info() or the +# _version functions. +# +sub get_plugin_version() { + + my $plugin_name = shift(@_); + + $setup_file = '../plugins/' . $plugin_name . '/setup.php'; + if ( -e "$setup_file" ) { + # Make sure that file is readable + if (! -r "$setup_file") { + print "\n"; + print "WARNING:\n"; + print "The file \"$setup_file\" was found, but you don't\n"; + print "have rights to read it. The plugin \""; + print $plugin_name . "\" may not work correctly until you fix this.\n"; + print "\nPress enter to continue"; + $ctu = ; + print "\n"; + next; + } + + $version = ' '; +# FIXME: grep the file instead of reading it into memory? + $whole_file = ''; + open( FILE, "$setup_file" ); + while ( $line = ) { + $whole_file .= $line; + } + close(FILE); + + # ideally, there is a version in the _info function... + # + if ($whole_file =~ /('version'\s*=>\s*['"](.*?)['"])/) { + $version .= $2; + + # this assumes there is only one function that returns + # a static string in the setup file + # + } elsif ($whole_file =~ /(return\s*['"](.*?)['"])/) { + $version .= $2; + } + + return $version; + + } else { + print "\n"; + print "WARNING:\n"; + print "The file \"$setup_file\" was not found.\n"; + print "The plugin \"" . $plugin_name; + print "\" may not work correctly until you fix this.\n"; + print "\nPress enter to continue"; + $ctu = ; + print "\n"; + next; + } + +} + +# determine a plugin's English name +# +# parses the setup.php file, looking for the +# English name in the _info() function. +# +sub get_plugin_english_name() { + + my $plugin_name = shift(@_); + + $setup_file = '../plugins/' . $plugin_name . '/setup.php'; + if ( -e "$setup_file" ) { + # Make sure that file is readable + if (! -r "$setup_file") { + print "\n"; + print "WARNING:\n"; + print "The file \"$setup_file\" was found, but you don't\n"; + print "have rights to read it. The plugin \""; + print $plugin_name . "\" may not work correctly until you fix this.\n"; + print "\nPress enter to continue"; + $ctu = ; + print "\n"; + next; + } + + $english_name = ''; +# FIXME: grep the file instead of reading it into memory? + $whole_file = ''; + open( FILE, "$setup_file" ); + while ( $line = ) { + $whole_file .= $line; + } + close(FILE); + + # the English name is in the _info function or nothing... + # + if ($whole_file =~ /('english_name'\s*=>\s*['"](.*?)['"])/) { + $english_name .= $2; + } + + return $english_name; + + } else { + print "\n"; + print "WARNING:\n"; + print "The file \"$setup_file\" was not found.\n"; + print "The plugin \"" . $plugin_name; + print "\" may not work correctly until you fix this.\n"; + print "\nPress enter to continue"; + $ctu = ; + print "\n"; + next; + } + +} + # parses the setup.php files for all activated plugins and # builds static plugin hooks array so we don't have to load # ALL plugins are runtime and build the hook array on every @@ -5268,3 +5600,90 @@ PLUGIN: for ( $ct = 0 ; $ct <= $#plugins ; $ct++ ) { } +# converts (binary) integer values that correspond +# to the SquirrelMail debug mode constants (see +# include/constants.php) into those constant strings +# (bitwise or'd if more than one is enabled) +# +# if the value passed in is not an integer, it is +# returned unmolested +# +sub convert_debug_binary_integer_to_constants() { + + my ($debug_mode) = @_; + if ($debug_mode =~ /^[^0-9]/) { + return $debug_mode; + } + $debug_mode = int($debug_mode); + $new_debug_mode = ''; + + # per include/constants.php, here are their values: + # + # 0 SM_DEBUG_MODE_OFF + # 1 SM_DEBUG_MODE_SIMPLE + # 512 SM_DEBUG_MODE_MODERATE + # 524288 SM_DEBUG_MODE_ADVANCED + # 536870912 SM_DEBUG_MODE_STRICT + # + if ($debug_mode & 1) { + $new_debug_mode .= ' | SM_DEBUG_MODE_SIMPLE'; + } + if ($debug_mode & 512) { + $new_debug_mode .= ' | SM_DEBUG_MODE_MODERATE'; + } + if ($debug_mode & 524288) { + $new_debug_mode .= ' | SM_DEBUG_MODE_ADVANCED'; + } + if ($debug_mode & 536870912) { + $new_debug_mode .= ' | SM_DEBUG_MODE_STRICT'; + } + + $new_debug_mode =~ s/^ \| //; + if (!$new_debug_mode) { + $new_debug_mode = 'SM_DEBUG_MODE_OFF'; + } + + return $new_debug_mode; +} + +# converts SquirrelMail debug mode constants (see +# include/constants.php) into their corresponding +# (binary) integer values +# +# if the value passed in is an integer already, it +# is returned unmolested +# +sub convert_debug_constants_to_binary_integer() { + + my ($debug_mode) = @_; + if ($debug_mode =~ /^[0-9]/) { + return $debug_mode; + } + $new_debug_mode = 0; + + # per include/constants.php, here are their values: + # + # 0 SM_DEBUG_MODE_OFF + # 1 SM_DEBUG_MODE_SIMPLE + # 512 SM_DEBUG_MODE_MODERATE + # 524288 SM_DEBUG_MODE_ADVANCED + # 536870912 SM_DEBUG_MODE_STRICT + # + if ($debug_mode =~ /\bSM_DEBUG_MODE_OFF\b/) { + $new_debug_mode = 0; + } + if ($debug_mode =~ /\bSM_DEBUG_MODE_SIMPLE\b/) { + $new_debug_mode |= 1; + } + if ($debug_mode =~ /\bSM_DEBUG_MODE_MODERATE\b/) { + $new_debug_mode |= 512; + } + if ($debug_mode =~ /\bSM_DEBUG_MODE_ADVANCED\b/) { + $new_debug_mode |= 524288; + } + if ($debug_mode =~ /\bSM_DEBUG_MODE_STRICT\b/) { + $new_debug_mode |= 536870912; + } + + return $new_debug_mode; +}