#
# A simple configure script to configure squirrelmail
############################################################
-$WHT = "\x1B[37;1m";
-$NRM = "\x1B[0m";
+$conf_pl_version = "x52";
############################################################
# First, lets read in the data already in there...
############################################################
if ( -e "config.php") {
+ open (FILE, "config.php");
+ while ($line = <FILE>) {
+ if ($line =~ /^\s+\$/) {
+ $line =~ s/^\s+\$//;
+ $var = $line;
+
+ $var =~ s/=/EQUALS/;
+ if ($var =~ /^([a-z]|[A-Z])/) {
+ @o = split(/\s*EQUALS\s*/, $var);
+ if ($o[0] eq "config_version") {
+ $o[1] =~ s/[\n|\r]//g;
+ $o[1] =~ s/\";\s*$//;
+ $o[1] =~ s/;$//;
+ $o[1] =~ s/^"//;
+
+ $config_version = $o[1];
+ close (FILE);
+ }
+ }
+ }
+ }
+ close (FILE);
+
+ if ($config_version ne $conf_pl_version) {
+ system "clear";
+ print $WHT."WARNING:\n".$NRM;
+ print " The file \"config/config.php\" was found, but it is for an older version of\n";
+ print " SquirrelMail. It is possible to still read the defaults from this file\n";
+ print " but be warned that many preferences change between versions. It is\n";
+ print " recommended that you start with a clean config.php for each upgrade that\n";
+ print " you do. To do this, just move config/config.php out of the way.\n\n";
+ print "Continue loading with the old config.php [y/n]? ";
+ $ctu = <STDIN>;
+ if (($ctu =~ /^n\n/i) || ($ctu =~ /^\n/)) {
+ exit;
+ }
+
+ print "\nDo you want me to stop warning you [y/n]? ";
+ $ctu = <STDIN>;
+ if ($ctu =~ /^y\n/i) {
+ $print_config_version = $conf_pl_version;
+ } else {
+ $print_config_version = $config_version;
+ }
+ } else {
+ $print_config_version = $config_version;
+ }
+
$config = 1;
open (FILE, "config.php");
} elsif (-e "config_default.php") {
+ open (FILE, "config_default.php");
+ while ($line = <FILE>) {
+ if ($line =~ /^\s+\$/) {
+ $line =~ s/^\s+\$//;
+ $var = $line;
+
+ $var =~ s/=/EQUALS/;
+ if ($var =~ /^([a-z]|[A-Z])/) {
+ @o = split(/\s*EQUALS\s*/, $var);
+ if ($o[0] eq "config_version") {
+ $o[1] =~ s/[\n|\r]//g;
+ $o[1] =~ s/\";\s*$//;
+ $o[1] =~ s/;$//;
+ $o[1] =~ s/^"//;
+
+ $config_version = $o[1];
+ close (FILE);
+ }
+ }
+ }
+ }
+ close (FILE);
+
+ if ($config_version ne $conf_pl_version) {
+ system "clear";
+ print $WHT."WARNING:\n".$NRM;
+ print " You are trying to use a \"config_default.php\" from an older version of\n";
+ print " SquirrelMail. This is HIGHLY unrecommended. You should get the\n";
+ print " \"config_default.php\" that matches the version of SquirrelMail that you\n";
+ print " are running. You can get this from the SquirrelMail web page by going\n";
+ print " to: http://www.squirrelmail.org.\n\n";
+ print "Continue loading with the old config_default.php (not a good idea) [y/n]? ";
+ $ctu = <STDIN>;
+ if (($ctu =~ /^n\n/i) || ($ctu =~ /^\n/)) {
+ exit;
+ }
+
+ print "\nDo you want me to stop warning you [y/n]? ";
+ $ctu = <STDIN>;
+ if ($ctu =~ /^y\n/i) {
+ $print_config_version = $conf_pl_version;
+ } else {
+ $print_config_version = $config_version;
+ }
+ } else {
+ $print_config_version = $config_version;
+ }
$config = 2;
open (FILE, "config_default.php");
} else {
if ($var =~ /^([a-z]|[A-Z])/) {
@options = split(/\s*EQUALS\s*/, $var);
$options[1] =~ s/[\n|\r]//g;
- $options[1] =~ s/\";$//;
+ $options[1] =~ s/\";\s*$//;
$options[1] =~ s/;$//;
$options[1] =~ s/^"//;
-# if (/"$/) {
-# $options[1] =~ s/"$//;
-# }
if ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) {
$sub = $options[0];
$sub =~ s/\]\["PATH"\]//;
- $sub = substr ($sub, @sub-1, 1);
+ $sub =~ s/.*\[//;
+ if (-e "../themes") {
+ $options[1] =~ s/^\.\.\/config/\.\.\/themes/;
+ }
$theme_path[$sub] = $options[1];
} elsif ($options[0] =~ /^theme\[[0-9]+\]\["NAME"\]/) {
$sub = $options[0];
$sub =~ s/\]\["NAME"\]//;
- $sub = substr ($sub, @sub-1, 1);
+ $sub =~ s/.*\[//;
$theme_name[$sub] = $options[1];
+ } elsif ($options[0] =~ /^plugins\[[0-9]+\]/) {
+ $sub = $options[0];
+ $sub =~ s/\]//;
+ $sub =~ s/^plugins\[//;
+ $plugins[$sub] = $options[1];
} elsif ($options[0] =~ /^ldap_server\[[0-9]+\]/) {
$sub = $options[0];
- $sub = substr ($sub, length($sub)-2, 1);
+ $sub =~ s/\]//;
+ $sub =~ s/^ldap_server\[//;
$continue = 0;
while (($tmp = <FILE>) && ($continue != 1)) {
if ($tmp =~ /\);\s*$/) {
}
}
}
+close FILE;
if ($useSendmail ne "true") {
$useSendmail = "false";
}
if (!$sendmail_path) {
$sendmail_path = "/usr/sbin/sendmail";
}
+if (!$default_unseen_notify) {
+ $default_unseen_notify = 2;
+}
+if (!$default_unseen_type) {
+ $default_unseen_type = 1;
+}
+if (!$config_use_color) {
+ $config_use_color = 1;
+}
#####################################################################################
+if ($config_use_color == 1) {
+ $WHT = "\x1B[37;1m";
+ $NRM = "\x1B[0m";
+} else {
+ $WHT = "";
+ $NRM = "";
+ $config_use_color = 2;
+}
while (($command ne "q") && ($command ne "Q")) {
system "clear";
- if ($menu == 0) {
- print $WHT."SquirrelMail Configuration : ".$NRM;
- if ($config == 1) { print "Read: config.php"; }
- elsif ($config == 2) { print "Read: config_default.php"; }
- print "\n";
+ 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 "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";
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 : $WHT$useSendmail$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 "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 "\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";
if (($save =~ /^y/i) || ($save =~ /^\s*$/)) {
save_data ();
}
- } elsif (($command eq "d") || ($command eq "D")) {
+ } 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 < 8)) {
+ if (($command > 0) && ($command < 9)) {
$menu = $command;
}
} elsif ($menu == 1) {
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 (); }
if ($command == 1) { command61(); }
elsif ($command == 2) { command62(); }
} elsif ($menu == 7) {
- if ($command == 1) { $motd = command71(); }
+ if ($command == 1) { $motd = command71(); }
+ } elsif ($menu == 8) {
+ if ($command =~ /^[0-9]+/) { @plugins = command81(); }
}
}
}
print "messages in SquirrelMail. You can either connect to an SMTP server\n";
print "or use sendmail directly.\n";
if ($useSendmail eq "true") {
- $default_value = "y";
+ $default_value = "1";
} else {
- $default_value = "n";
+ $default_value = "2";
}
print "\n";
- print "Use Sendmail (y/n) [$WHT$default_value$NRM]: $WHT";
+ print " 1. Sendmail\n";
+ print " 2. SMTP\n";
+ print "Your choice [1/2] [$WHT$default_value$NRM]: $WHT";
$use_sendmail = <STDIN>;
- if (($use_sendmail =~ /^y\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "y"))) {
+ if (($use_sendmail =~ /^1\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "1"))) {
$useSendmail = "true";
} else {
$useSendmail = "false";
sub command71 {
print "\nYou can now create the welcome message that is displayed\n";
print "every time a user logs on. You can use HTML or just plain\n";
- print "text.\n\n(Type @ on a blank line to exit)\n";
+ print "text. If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n";
$new_motd = "";
do {
return $new_motd;
}
+################# PLUGINS ###################
+
+sub command81 {
+ $command =~ s/[\s|\n|\r]*//g;
+ if ($command > 0) {
+ $command = $command - 1;
+ if ($command <= $#plugins) {
+ @newplugins = ();
+ $ct=0;
+ while ($ct <= $#plugins) {
+ if ($ct != $command) {
+ @newplugins = (@newplugins, $plugins[$ct]);
+ }
+ $ct++;
+ }
+ @plugins = @newplugins;
+ } elsif ($command <= $#plugins + $#unused_plugins + 1) {
+ $num = $command - $#plugins - 1;
+ @newplugins = @plugins;
+ $ct=0;
+ while ($ct <= $#unused_plugins) {
+ if ($ct == $num) {
+ @newplugins = (@newplugins, $unused_plugins[$ct]);
+ }
+ $ct++;
+ }
+ @plugins = @newplugins;
+ }
+ }
+ return @plugins;
+}
+
################# FOLDERS ###################
# default_folder_prefix
return $show_contain_subfolders_option;
}
+# Default Unseen Notify
+sub command212 {
+ print "This option specifies where the users will receive notification\n";
+ print "about unseen messages by default. This is of course an option that\n";
+ print "can be changed on a user level.\n";
+ print " 1 = No notification\n";
+ print " 2 = Only on the INBOX\n";
+ print " 3 = On all folders\n";
+ print "\n";
+
+ print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT";
+ $new_show = <STDIN>;
+ if ($new_show =~ /^[1|2|3]\n/i) {
+ $default_unseen_notify = $new_show;
+ }
+ $default_unseen_notify =~ s/[\r|\n]//g;
+ return $default_unseen_notify;
+}
+
+# Default Unseen Type
+sub command213 {
+ print "Here you can define the default way that unseen messages will be displayed\n";
+ print "to the user in the folder listing on the left side.\n";
+ print " 1 = Only unseen messages (4)\n";
+ print " 2 = Unseen and Total messages (4/27)\n";
+ print "\n";
+
+ print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT";
+ $new_show = <STDIN>;
+ if ($new_show =~ /^[1|2]\n/i) {
+ $default_unseen_type = $new_show;
+ }
+ $default_unseen_type =~ s/[\r|\n]//g;
+ return $default_unseen_type;
+}
+
+
############# GENERAL OPTIONS #####################
# Default Charset
$name = <STDIN>;
$name =~ s/[\r|\n]//g;
$theme_name[$#theme_name+1] = $name;
- print "Be sure to put ../config/ before the filename.\n";
- print "What file is this stored in (ex: ../config/default_theme.php): ";
+ print "Be sure to put ../themes/ before the filename.\n";
+ print "What file is this stored in (ex: ../themes/default_theme.php): ";
$name = <STDIN>;
$name =~ s/[\r|\n]//g;
$theme_path[$#theme_path+1] = $name;
$theme_default--;
}
}
+ } elsif ($input =~ /^\s*t\s*/i) {
+ print "\nStarting detection...\n\n";
+
+ opendir(DIR, "../themes");
+ @files = grep { /\.php$/i } readdir(DIR);
+ $cnt = 0;
+ while ($cnt <= $#files) {
+ $filename = "../themes/" . $files[$cnt];
+ $found = 0;
+ for ($x=0; $x <= $#theme_path; $x++) {
+ if ($theme_path[$x] eq $filename) {
+ $found = 1;
+ }
+ }
+ if ($found != 1) {
+ print "** Found theme: $filename\n";
+ print " What is its name? ";
+ $nm = <STDIN>;
+ $nm =~ s/[\n|\r]//g;
+ $theme_name[$#theme_name+1] = $nm;
+ $theme_path[$#theme_path+1] = $filename;
+ }
+ $cnt++;
+ }
+ print "\n";
+ for ($cnt=0; $cnt <= $#theme_path; $cnt++) {
+ $filename = $theme_path[$cnt];
+ if (! (-e $filename)) {
+ print " Removing $filename (file not found)\n";
+ $offset = 0;
+ @new_theme_name = ();
+ @new_theme_path = ();
+ for ($x=0; $x < $#theme_path; $x++) {
+ if ($theme_path[$x] eq $filename) {
+ $offset = 1;
+ }
+ if ($offset == 1) {
+ $new_theme_name[$x] = $theme_name[$x+1];
+ $new_theme_path[$x] = $theme_path[$x+1];
+ } else {
+ $new_theme_name[$x] = $theme_name[$x];
+ $new_theme_path[$x] = $theme_path[$x];
+ }
+ }
+ @theme_name = @new_theme_name;
+ @theme_path = @new_theme_path;
+ }
+ }
+ print "\nDetection complete!\n\n";
+
+ closedir DIR;
} elsif ($input =~ /^\s*\?\s*/) {
print ".-------------------------.\n";
+ print "| t (detect themes) |\n";
print "| + (add theme) |\n";
print "| - N (remove theme) |\n";
print "| m N (mark default) |\n";
print FILE "<?php\n\t/** SquirrelMail configuration\n";
print FILE "\t ** Created using the configure script, conf.pl\n\t **/\n\n";
+ if ($print_config_version) {
+ print FILE "\t\$config_version = \"$print_config_version\";\n";
+ }
+ print FILE "\t\$config_use_color = $config_use_color;\n";
+ print FILE "\n";
+
print FILE "\t\$org_name = \"$org_name\";\n";
print FILE "\t\$org_logo = \"$org_logo\";\n";
print FILE "\t\$org_title = \"$org_title\";\n";
print FILE "\t\$auto_expunge = $auto_expunge;\n";
print FILE "\t\$default_sub_of_inbox = $default_sub_of_inbox;\n";
print FILE "\t\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
+ print FILE "\t\$default_unseen_notify = $default_unseen_notify;\n";
+ print FILE "\t\$default_unseen_type = $default_unseen_type;\n";
print FILE "\n";
print FILE "\t\$default_charset = \"$default_charset\";\n";
print FILE "\n";
+ for ($ct=0; $ct <= $#plugins; $ct++) {
+ print FILE "\t\$plugins[$ct] = \"$plugins[$ct]\";\n";
+ }
+
+ print FILE "\n";
+
for ($count=0; $count <= $#theme_name; $count++) {
print FILE "\t\$theme[$count][\"PATH\"] = \"$theme_path[$count]\";\n";
print FILE "\t\$theme[$count][\"NAME\"] = \"$theme_name[$count]\";\n";
print FILE ");\n\n";
}
- print FILE "\n";
print FILE "\t\$motd = \"$motd\";\n";
print FILE "?>\n";
sub set_defaults {
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";
$sent_folder = "INBOX/Sent Items";
$show_prefix_option = false;
$show_contain_subfolders_option = false;
-
$imap_server_type = "exchange";
+ print " default_folder_prefix = INBOX/\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") {