+
+while (($command ne "q") && ($command ne "Q")) {
+ 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";
+
+ if ($menu == 0) {
+ print $WHT."Main Menu --\n".$NRM;
+ print "1. Organization Preferences\n";
+ print "2. Server Settings\n";
+ print "3. Folder Defaults\n";
+ print "4. General Options\n";
+ print "5. Themes\n";
+ print "6. Address Books (LDAP)\n";
+ print "7. Message of the Day (MOTD)\n";
+ print "8. Plugins\n";
+ print "\n";
+ print "D. Set pre-defined settings for specific IMAP servers\n";
+ print "\n";
+ } elsif ($menu == 1) {
+ print $WHT."Organization Preferences\n".$NRM;
+ print "1. Organization Name : $WHT$org_name$NRM\n";
+ print "2. Organization Logo : $WHT$org_logo$NRM\n";
+ print "3. Organization Title : $WHT$org_title$NRM\n";
+ print "\n";
+ print "R Return to Main Menu\n";
+ } elsif ($menu == 2) {
+ print $WHT."Server Settings\n".$NRM;
+ print "1. Domain : $WHT$domain$NRM\n";
+ print "2. IMAP Server : $WHT$imapServerAddress$NRM\n";
+ print "3. IMAP Port : $WHT$imapPort$NRM\n";
+ print "4. Use Sendmail/SMTP : $WHT";
+ if ($useSendmail eq "true") {
+ print "Sendmail";
+ } else {
+ print "SMTP";
+ }
+ print "$NRM\n";
+ if ($useSendmail eq "true") {
+ print "5. Sendmail Path : $WHT$sendmail_path$NRM\n";
+ } else {
+ print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n";
+ print "7. SMTP Port : $WHT$smtpPort$NRM\n";
+ }
+ print "8. Server : $WHT$imap_server_type$NRM\n";
+ print "\n";
+ 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. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
+ print "6. By default, move to sent : $WHT$default_move_to_sent$NRM\n";
+ print "7. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
+ print "8. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
+ print "9. Auto Expunge : $WHT$auto_expunge$NRM\n";
+ print "10. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
+ print "11. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
+ print "12. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n";
+ print "13. Default Unseen Type : $WHT$default_unseen_type$NRM\n";
+ print "\n";
+ print "R Return to Main Menu\n";
+ } elsif ($menu == 4) {
+ print $WHT."General Options\n".$NRM;
+ print "1. Default Charset : $WHT$default_charset$NRM\n";
+ print "2. Data Directory : $WHT$data_dir$NRM\n";
+ print "3. Attachment Directory : $WHT$attachment_dir$NRM\n";
+ print "4. Default Left Size : $WHT$default_left_size$NRM\n";
+ print "\n";
+ print "R Return to Main Menu\n";
+ } elsif ($menu == 5) {
+ print $WHT."Themes\n".$NRM;
+ print "1. Change Themes\n";
+ for ($count = 0; $count <= $#theme_name; $count++) {
+ print " > $theme_name[$count]\n";
+ }
+ print "\n";
+ print "R Return to Main Menu\n";
+ } elsif ($menu == 6) {
+ print $WHT."Address Books (LDAP)\n".$NRM;
+ print "1. Change Servers\n";
+ for ($count = 0; $count <= $#ldap_host; $count++) {
+ print " > $ldap_host[$count]\n";
+ }
+ print "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n";
+ print "\n";
+ print "R Return to Main Menu\n";
+ } elsif ($menu == 7) {
+ print $WHT."Message of the Day (MOTD)\n".$NRM;
+ print "\n$motd\n";
+ print "\n";
+ print "1 Edit the MOTD\n";
+ print "\n";
+ print "R Return to Main Menu\n";
+ } elsif ($menu == 8) {
+ print $WHT."Plugins\n".$NRM;
+ print " Installed Plugins\n";
+ $num = 0;
+ for ($count = 0; $count <= $#plugins; $count++) {
+ $num = $count + 1;
+ print " $num. $plugins[$count]\n";
+ }
+ print "\n Available Plugins:\n";
+ opendir(DIR, "../plugins");
+ @files = readdir(DIR);
+ $pos=0;
+ @unused_plugins = ();
+ chdir ("../plugins");
+ for ($i=0; $i <= $#files; $i++) {
+ if ( -d $files[$i] && $files[$i] !~ /^\./ && $files[$i] ne "CVS") {
+ $match = 0;
+ for ($k=0; $k<=$#plugins; $k++) {
+ if ($plugins[$k] eq $files[$i]) {
+ $match = 1;
+ }
+ }
+ if ($match == 0) {
+ $unused_plugins[$pos] = $files[$i];
+ $pos++;
+ }
+ }
+ }
+ chdir ("../config");
+
+ for ($i=0; $i<=$#unused_plugins; $i++) {
+ $num = $num + 1;
+ print " $num. $unused_plugins[$i]\n";
+ }
+ closedir DIR;
+
+ print "\n";
+ print "R Return to Main Menu\n";
+ }
+ if ($config_use_color == 1) {
+ print "C. Turn color off\n";
+ } else {
+ print "C. Turn color on\n";
+ }
+ print "S Save data\n";
+ print "Q Quit\n";
+
+ print "\n";
+ print "Command >> ".$WHT;
+ $command = <STDIN>;
+ $command =~ s/[\n|\r]//g;
+ print "$NRM\n";
+
+ # Read the commands they entered.
+ if (($command eq "R") || ($command eq "r")) {
+ $menu = 0;
+ } elsif (($command eq "s") || ($command eq "S")) {
+ save_data ();
+ print "Data saved in config.php\n";
+ print "Press any key to continue...";
+ $tmp = <STDIN>;
+ $saved = 1;
+ } elsif ((($command eq "q") || ($command eq "Q")) && ($saved == 0)) {
+ print "You have not saved your data.\n";
+ print "Save? (y/n) [".$WHT."y".$NRM."]: ";
+ $save = <STDIN>;
+ if (($save =~ /^y/i) || ($save =~ /^\s*$/)) {
+ save_data ();
+ }
+ } elsif (($command eq "c") || ($command eq "C")) {
+ if ($config_use_color == 1) {
+ $config_use_color = 2;
+ $WHT = "";
+ $NRM = "";
+ } else {
+ $config_use_color = 1;
+ $WHT = "\x1B[37;1m";
+ $NRM = "\x1B[0m";
+ }
+ } elsif ((($command eq "d") || ($command eq "D")) && $menu == 0) {
+ set_defaults ();
+ } else {
+ $saved = 0;
+ if ($menu == 0) {
+ if (($command > 0) && ($command < 9)) {
+ $menu = $command;
+ }
+ } elsif ($menu == 1) {
+ if ($command == 1) { $org_name = command1 (); }
+ elsif ($command == 2) { $org_logo = command2 (); }
+ elsif ($command == 3) { $org_title = command3 (); }
+ } elsif ($menu == 2) {
+ if ($command == 1) { $domain = command11 (); }
+ elsif ($command == 2) { $imapServerAddress = command12 (); }
+ elsif ($command == 3) { $imapPort = command13 (); }
+ elsif ($command == 4) { $useSendmail = command14 (); }
+ elsif ($command == 5) { $sendmail_path = command15 (); }
+ elsif ($command == 6) { $smtpServerAddress = command16 (); }
+ elsif ($command == 7) { $smtpPort = command17 (); }
+ elsif ($command == 8) { $imap_server_type = command18 (); }
+ } elsif ($menu == 3) {
+ if ($command == 1) { $default_folder_prefix = command21 (); }
+ elsif ($command == 2) { $show_prefix_option = command22 (); }
+ elsif ($command == 3) { $trash_folder = command23 (); }
+ elsif ($command == 4) { $sent_folder = command24 (); }
+ elsif ($command == 5) { $default_move_to_trash = command25 (); }
+ elsif ($command == 6) { $default_move_to_sent = command26 (); }
+ elsif ($command == 7) { $list_special_folders_first = command27 (); }
+ elsif ($command == 8) { $use_special_folder_color = command28 (); }
+ elsif ($command == 9) { $auto_expunge = command29 (); }
+ elsif ($command == 10){ $default_sub_of_inbox = command210(); }
+ elsif ($command == 11){ $show_contain_subfolders_option = command211(); }
+ elsif ($command == 12){ $default_unseen_notify = command212(); }
+ elsif ($command == 13){ $default_unseen_type = command213(); }
+ } elsif ($menu == 4) {
+ if ($command == 1) { $default_charset = command31 (); }
+ elsif ($command == 2) { $data_dir = command33 (); }
+ elsif ($command == 3) { $attachment_dir = command34 (); }
+ elsif ($command == 4) { $default_left_size = command35 (); }
+ } elsif ($menu == 5) {
+ if ($command == 1) {
+ command41 ();
+ }
+ } elsif ($menu == 6) {
+ if ($command == 1) { command61(); }
+ elsif ($command == 2) { command62(); }
+ } elsif ($menu == 7) {
+ if ($command == 1) { $motd = command71(); }
+ } elsif ($menu == 8) {
+ if ($command =~ /^[0-9]+/) { @plugins = command81(); }
+ }
+ }