############################################################
$WHT = "\x1B[37;1m";
$NRM = "\x1B[0m";
+$conf_pl_version = "x51";
############################################################
# 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.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.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/.*\[//;
$theme_path[$sub] = $options[1];
} elsif ($options[0] =~ /^theme\[[0-9]+\]\["NAME"\]/) {
$sub = $options[0];
$sub =~ s/\]\["NAME"\]//;
$sub =~ s/.*\[//;
- #$sub = substr ($sub, @sub-1, 1);
$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*$/) {
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 Edit the MOTD\n";
print "\n";
print "R Return to Main Menu\n";
+ } elsif ($menu == 8) {
+ print $WHT."Plugins\n".$NRM;
+ print "1 Change Plugins\n";
+ for ($count = 0; $count <= $#plugins; $count++) {
+ print " > $plugins[$count]\n";
+ }
+ print "\n";
+ print "R Return to Main Menu\n";
}
print "S Save data\n";
print "Q Quit\n";
} else {
$saved = 0;
if ($menu == 0) {
- if (($command > 0) && ($command < 8)) {
+ if (($command > 0) && ($command < 9)) {
$menu = $command;
}
} elsif ($menu == 1) {
elsif ($command == 2) { command62(); }
} elsif ($menu == 7) {
if ($command == 1) { $motd = command71(); }
+ } elsif ($menu == 8) {
+ if ($command == 1) { $motd = command81(); }
}
}
}
return $new_motd;
}
+################# PLUGINS ###################
+
+sub command81 {
+ print "\nThis is where you can define plugins. The plugin must already exist in the\n";
+ print "plugins/ directory in order to add them here. A plugin name is the name of the\n";
+ print "directory that it resides in. For example, if you have a plugin in the directory\n";
+ print "plugins/myplug, the name is \"myplug\".\n\n";
+ print "[plugins] command (?=help) > ";
+ $input = <STDIN>;
+ $input =~ s/[\r|\n]//g;
+ while ($input ne "d") {
+ if ($input =~ /^\s*l\s*/i) {
+ $count = 0;
+ while ($count <= $#plugins) {
+ print " $count. $plugins[$count]\n";
+ $count++;
+ }
+ print "\n";
+ } elsif ($input =~ /^\s*\+/) {
+ print "What is the name of this plugin: ";
+ $name = <STDIN>;
+ $name =~ s/[\r|\n]//g;
+
+ if (-e "../plugins/$name") {
+ $exists = 0;
+ for ($m=0; $m <= $#plugins; $m++) {
+ if ($plugins[$m] eq $name) {
+ $exists = 1;
+ }
+ }
+ if ($exists == 1) {
+ print "\nThat plugin already exists in the list!\n";
+ } else {
+ $plugins[$#plugins+1] = $name;
+ }
+ print "\n";
+ } else {
+ print "\nThat plugin does not exist in the plugins/ directory!\n\n";
+ }
+ } elsif ($input =~ /^\s*-\s*[0-9]?/) {
+ if ($input =~ /[0-9]+\s*$/) {
+ $rem_num = $input;
+ $rem_num =~ s/^\s*-\s*//g;
+ $rem_num =~ s/\s*$//;
+ } else {
+ $rem_num = $#plugins;
+ }
+
+ $count = 0;
+ @new_plugins = ();
+ while ($count <= $#plugins) {
+ if ($count != $rem_num) {
+ @new_plugins = (@new_plugins, $plugins[$count]);
+ }
+ $count++;
+ }
+ @plugins = @new_plugins;
+ } elsif ($input =~ /^\s*\?\s*/) {
+ print ".-------------------------.\n";
+ print "| + (add plugin) |\n";
+ print "| - N (remove plugin) |\n";
+ print "| l (list plugins) |\n";
+ print "| d (done) |\n";
+ print "`-------------------------'\n";
+ }
+ print "[plugins] command (?=help) > ";
+ $input = <STDIN>;
+ $input =~ s/[\r|\n]//g;
+ }
+}
+
################# FOLDERS ###################
# default_folder_prefix
$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;
print FILE "<?php\n\t/** SquirrelMail configuration\n";
print FILE "\t ** Created using the configure script, conf.pl\n\t **/\n\n";
+ print FILE "\t\$config_version = \"$print_config_version\";\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 "\n";
+ for ($count=0; $count <= $#plugins; $count++) {
+ print FILE "\t\$plugins[$count] = \"$plugins[$count]\";\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";