- system "clear";
- print $WHT."SquirrelMail Configuration : ".$NRM;
- if ($config == 1) { print "Read: config.php"; }
- elsif ($config == 2) { print "Read: config_default.php"; }
- print "\n";
- print "---------------------------------------------------------\n";
-
- print "While we have been building SquirrelMail, we have discovered some\n";
- print "preferences that work better with some servers that don't work so\n";
- print "well with others. If you select your IMAP server, this option will\n";
- print "set some pre-defined settings for that server.\n";
- print "\n";
- print "Please note that you will still need to go through and make sure\n";
- print "everything is correct. This does not change everything. There are\n";
- print "only a few settings that this will change.\n";
- print "\n";
-
- $continue = 0;
- while ($continue != 1) {
- print "Please select your IMAP server:\n";
- print " cyrus = Cyrus IMAP server\n";
- print " uw = University of Washington's IMAP server\n";
- print " exchange = Microsoft Exchange IMAP server\n";
- print " courier = Courier IMAP server\n";
- print " quit = Do not change anything\n";
- print "Command >> ";
- $server = <STDIN>;
- $server =~ s/[\r|\n]//g;
-
- print "\n";
- if ($server eq "cyrus") {
- $default_folder_prefix = "INBOX";
- $trash_folder = "INBOX.Trash";
- $sent_folder = "INBOX.Sent";
- $show_prefix_option = false;
- $default_sub_of_inbox = true;
- $show_contain_subfolders_option = false;
- $imap_server_type = "cyrus";
-
- print " default_folder_prefix = INBOX\n";
- print " trash_folder = INBOX.Trash\n";
- print " sent_folder = INBOX.Sent\n";
- print " show_prefix_option = false\n";
- print " default_sub_of_inbox = true\n";
- print "show_contain_subfolders_option = false\n";
- print " imap_server_type = cyrus\n";
-
- $continue = 1;
- } elsif ($server eq "uw") {
- $default_folder_prefix = "mail/";
- $trash_folder = "Trash";
- $sent_folder = "Sent";
- $show_prefix_option = true;
- $default_sub_of_inbox = false;
- $show_contain_subfolders_option = true;
- $imap_server_type = "uw";
-
- print " default_folder_prefix = mail/\n";
- print " trash_folder = Trash\n";
- print " sent_folder = Sent\n";
- print " show_prefix_option = true\n";
- print " default_sub_of_inbox = false\n";
- print "show_contain_subfolders_option = true\n";
- print " imap_server_type = uw\n";
-
- $continue = 1;
- } elsif ($server eq "exchange") {
- $default_folder_prefix = "";
- $default_sub_of_inbox = true;
- $trash_folder = "INBOX/Deleted Items";
- $sent_folder = "INBOX/Sent Items";
- $show_prefix_option = false;
- $show_contain_subfolders_option = false;
- $imap_server_type = "exchange";
-
- print " default_folder_prefix = <none>\n";
- print " default_sub_of_inbox = true\n";
- print " trash_folder = \"INBOX/Deleted Items\"\n";
- print " sent_folder = \"INBOX/Sent Items\"\n";
- print " show_prefix_option = false\n";
- print " show_contain_subfolders_option = false\n";
- print " imap_server_type = exchange\n";
-
- $continue = 1;
- } elsif ($server eq "courier") {
- $imap_server_type = "courier";
-
- print " imap_server_type = courier\n";
-
- $continue = 1;
- } elsif ($server eq "quit") {
- $continue = 1;
- } else {
- print "Unrecognized server: $server\n";
- print "\n";
- }
- }
- print "\nPress any key to continue...";
- $tmp = <STDIN>;
+ system "clear";
+ print $WHT. "SquirrelMail Configuration : " . $NRM;
+ if ( $config == 1 ) { print "Read: config.php"; }
+ elsif ( $config == 2 ) { print "Read: config_default.php"; }
+ print "\n";
+ print "---------------------------------------------------------\n";
+
+ print "While we have been building SquirrelMail, we have discovered some\n";
+ print "preferences that work better with some servers that don't work so\n";
+ print "well with others. If you select your IMAP server, this option will\n";
+ print "set some pre-defined settings for that server.\n";
+ print "\n";
+ print "Please note that you will still need to go through and make sure\n";
+ print "everything is correct. This does not change everything. There are\n";
+ print "only a few settings that this will change.\n";
+ print "\n";
+
+ $continue = 0;
+ while ( $continue != 1 ) {
+ print "Please select your IMAP server:\n";
+ print " cyrus = Cyrus IMAP server\n";
+ print " uw = University of Washington's IMAP server\n";
+ print " exchange = Microsoft Exchange IMAP server\n";
+ print " courier = Courier IMAP server\n";
+ print " macosx = Mac OS X Mailserver\n";
+ print " quit = Do not change anything\n";
+ print "Command >> ";
+ $server = <STDIN>;
+ $server =~ s/[\r|\n]//g;
+
+ print "\n";
+ if ( $server eq "cyrus" ) {
+ $imap_server_type = "cyrus";
+ $default_folder_prefix = "";
+ $trash_folder = "INBOX.Trash";
+ $sent_folder = "INBOX.Sent";
+ $draft_folder = "INBOX.Drafts";
+ $show_prefix_option = false;
+ $default_sub_of_inbox = true;
+ $show_contain_subfolders_option = false;
+ $optional_delimiter = ".";
+ $disp_default_folder_prefix = "<none>";
+
+ $continue = 1;
+ } elsif ( $server eq "uw" ) {
+ $imap_server_type = "uw";
+ $default_folder_prefix = "mail/";
+ $trash_folder = "Trash";
+ $sent_folder = "Sent";
+ $draft_folder = "Drafts";
+ $show_prefix_option = true;
+ $default_sub_of_inbox = false;
+ $show_contain_subfolders_option = true;
+ $optional_delimiter = "/";
+ $disp_default_folder_prefix = $default_folder_prefix;
+
+ $continue = 1;
+ } elsif ( $server eq "exchange" ) {
+ $imap_server_type = "exchange";
+ $default_folder_prefix = "";
+ $default_sub_of_inbox = true;
+ $trash_folder = "INBOX/Deleted Items";
+ $sent_folder = "INBOX/Sent Items";
+ $drafts_folder = "INBOX/Drafts";
+ $show_prefix_option = false;
+ $show_contain_subfolders_option = false;
+ $optional_delimiter = "detect";
+ $disp_default_folder_prefix = "<none>";
+
+ $continue = 1;
+ } elsif ( $server eq "courier" ) {
+ $imap_server_type = "courier";
+ $default_folder_prefix = "INBOX.";
+ $trash_folder = "Trash";
+ $sent_folder = "Sent";
+ $draft_folder = "Drafts";
+ $show_prefix_option = false;
+ $default_sub_of_inbox = false;
+ $show_contain_subfolders_option = false;
+ $optional_delimiter = ".";
+ $disp_default_folder_prefix = $default_folder_prefix;
+
+ $continue = 1;
+ } elsif ( $server eq "macosx" ) {
+ $imap_server_type = "macosx";
+ $default_folder_prefix = "INBOX/";
+ $trash_folder = "Trash";
+ $sent_folder = "Sent";
+ $draft_folder = "Drafts";
+ $show_prefix_option = false;
+ $default_sub_of_inbox = true;
+ $show_contain_subfolders_option = false;
+ $optional_delimiter = "detect";
+ $allow_charset_search = false;
+ $disp_default_folder_prefix = $default_folder_prefix;
+
+ $continue = 1;
+ } elsif ( $server eq "quit" ) {
+ $continue = 1;
+ } else {
+ $disp_default_folder_prefix = $default_folder_prefix;
+ print "Unrecognized server: $server\n";
+ print "\n";
+ }
+
+ print " imap_server_type = $imap_server_type\n";
+ print " default_folder_prefix = $disp_default_folder_prefix\n";
+ print " trash_folder = $trash_folder\n";
+ print " sent_folder = $sent_folder\n";
+ print " draft_folder = $draft_folder\n";
+ print " show_prefix_option = $show_prefix_option\n";
+ print " default_sub_of_inbox = $default_sub_of_inbox\n";
+ print "show_contain_subfolders_option = $show_contain_subfolders_option\n";
+ print " optional_delimiter = $optional_delimiter\n";
+ }
+ print "\nPress any key to continue...";
+ $tmp = <STDIN>;
+}
+
+############################################################
+# This subroutine corrects relative paths to ensure they
+# will work within the SM space. If the path falls within
+# the SM directory tree, the SM_PATH variable will be
+# prepended to the path, if not, then the path will be
+# converted to an absolute path.
+############################################################
+sub change_to_SM_path() {
+ my ($old_path) = @_;
+ my $new_path = '';
+ my @rel_path;
+ my @abs_path;
+ my $subdir;
+
+ # If the path is absolute, don't bother.
+ return "\'" . $old_path . "\'" if ( $old_path eq '');
+ return "\'" . $old_path . "\'" if ( $old_path =~ /^\// );
+ return $old_path if ( $old_path =~ /^SM_PATH/ );
+
+ # For relative paths, split on '../'
+ @rel_path = split(/\.\.\//, $old_path);
+
+ if ( $#rel_path > 1 ) {
+ # more than two levels away. Make it absolute.
+ @abs_path = split(/\//, $dir);
+ foreach $subdir (@rel_path) {
+ if ($subdir eq '') {
+ pop @abs_path;
+ } else {
+ push @abs_path, $subdir;
+ }
+ }
+ foreach $subdir (@abs_path) {
+ $new_path .= $subdir . '/';
+ }
+ } elsif ( $#rel_path > 0 ) {
+ # it's within the SM tree, prepend SM_PATH
+ $new_path = $old_path;
+ $new_path =~ s/^\.\.\//SM_PATH . \'/;
+ $new_path .= '\'';
+ } else {
+ # Last, it's a relative path without any leading '.'
+ # Prepend SM_PATH (no substitution required)
+ $new_path = "SM_PATH . \'" . $old_path . "\'";
+ }
+
+ return $new_path;
+}
+
+sub change_to_rel_path() {
+ my ($old_path) = @_;
+ my $new_path = '';
+
+ return $old_path if ( $old_path eq '');
+ return $old_path if ( $old_path =~ /^\// );
+ return $old_path if ( $old_path =~ /^\.\./ );
+
+ if ( $old_path =~ /^SM_PATH/ ) {
+ $new_path = $old_path;
+ $new_path =~ s/^SM_PATH . \'/\.\.\//;
+ }
+
+ return $new_path;