X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=config%2Fconf.pl;h=6f142521170d1ee3105a98738b02038660171f29;hb=a3439b271e1b5fa7e61362970dbbcc5bfc75e5b1;hp=eb9fe8dcdb505c0baaa3f0516a63f3a511708c45;hpb=06c5423e19f5ce25d760deb5fb27c9912ebcc3f3;p=squirrelmail.git diff --git a/config/conf.pl b/config/conf.pl index eb9fe8dc..6f142521 100755 --- a/config/conf.pl +++ b/config/conf.pl @@ -6,7 +6,7 @@ # # $Id$ ############################################################ -$conf_pl_version = "x64"; +$conf_pl_version = "1.2.0"; ############################################################ # Some people try to run this as a CGI. That's wrong! @@ -24,22 +24,21 @@ if(defined($ENV{'PATH_INFO'}) || defined($ENV{'QUERY_STRING'}) || if ( -e "config.php") { open (FILE, "config.php"); while ($line = ) { - if ($line =~ /^\s+\$/) { - $line =~ s/^\s+\$//; - $var = $line; + $line =~ s/^\s+//; + $line =~ 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); - } + $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); } } } @@ -48,11 +47,13 @@ if ( -e "config.php") { 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 " The file \"config/config.php\" was found, but it is for\n"; + print " an older version of SquirrelMail. It is possible to still\n"; + print " read the defaults from this file but be warned that many\n"; + print " preferences change between versions. It is recommended that\n"; + print " you start with a clean config.php for each upgrade that you\n"; + print " do. To do this, just move config/config.php out of the way.\n"; + print "\n"; print "Continue loading with the old config.php [y/N]? "; $ctu = ; if (($ctu !~ /^y\n/i) || ($ctu =~ /^\n/)) { @@ -75,22 +76,21 @@ if ( -e "config.php") { } elsif (-e "config_default.php") { open (FILE, "config_default.php"); while ($line = ) { - if ($line =~ /^\s+\$/) { - $line =~ s/^\s+\$//; - $var = $line; + $line =~ s/^\s+//; + $line =~ 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); - } + $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); } } } @@ -99,12 +99,14 @@ if ( -e "config.php") { 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]? "; + print " You are trying to use a 'config_default.php' from an older\n"; + print " version of SquirrelMail. This is HIGHLY unrecommended. You\n"; + 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 "\n"; + print "Continue loading with old config_default.php (a bad idea) [y/N]? "; $ctu = ; if (($ctu !~ /^y\n/i) || ($ctu =~ /^\n/)) { exit; @@ -123,99 +125,97 @@ if ( -e "config.php") { $config = 2; open (FILE, "config_default.php"); } else { - print "No configuration file found. Please get config_default.php or\n"; - print "config.php before running this again. This program needs a\n"; - print "default config file to get default values.\n"; + print "No configuration file found. Please get config_default.php\n"; + print "or config.php before running this again. This program needs\n"; + print "a default config file to get default values.\n"; exit; } -# Reads and parses the current configuration file (either -# config.php or config_default.php). - +# Read and parse the current configuration file +# (either config.php or config_default.php). while ($line = ) { - if ($line =~ /^\s+\$/) { - $line =~ s/^\s+\$//; - $var = $line; + $line =~ s/^\s+//; + $line =~ s/^\$//; + $var = $line; - $var =~ s/=/EQUALS/; - if ($var =~ /^([a-z]|[A-Z])/) { - @options = split(/\s*EQUALS\s*/, $var); - $options[1] =~ s/[\n|\r]//g; - $options[1] =~ s/\";\s*$//; - $options[1] =~ s/;$//; - $options[1] =~ s/^\"//; - - if ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) { - $sub = $options[0]; - $sub =~ s/\]\["PATH"\]//; - $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 =~ 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 =~ s/\]//; - $sub =~ s/^ldap_server\[//; - $continue = 0; - while (($tmp = ) && ($continue != 1)) { - if ($tmp =~ /\);\s*$/) { - $continue = 1; - } - - if ($tmp =~ /^\s*\"host\"/i) { - $tmp =~ s/^\s*\"host\"\s*=>\s*\"//i; - $tmp =~ s/\",\s*$//; - $tmp =~ s/\"\);\s*$//; - $host = $tmp; - } elsif ($tmp =~ /^\s*\"base\"/i) { - $tmp =~ s/^\s*\"base\"\s*=>\s*\"//i; - $tmp =~ s/\",\s*$//; - $tmp =~ s/\"\);\s*$//; - $base = $tmp; - } elsif ($tmp =~ /^\s*\"charset\"/i) { - $tmp =~ s/^\s*\"charset\"\s*=>\s*\"//i; - $tmp =~ s/\",\s*$//; - $tmp =~ s/\"\);\s*$//; - $charset = $tmp; - } elsif ($tmp =~ /^\s*\"port\"/i) { - $tmp =~ s/^\s*\"port\"\s*=>\s*\"//i; - $tmp =~ s/\",\s*$//; - $tmp =~ s/\"\);\s*$//; - $port = $tmp; - } elsif ($tmp =~ /^\s*\"maxrows\"/i) { - $tmp =~ s/^\s*\"maxrows\"\s*=>\s*\"//i; - $tmp =~ s/\",\s*$//; - $tmp =~ s/\"\);\s*$//; - $maxrows = $tmp; - } elsif ($tmp =~ /^\s*\"name\"/i) { - $tmp =~ s/^\s*\"name\"\s*=>\s*\"//i; - $tmp =~ s/\",\s*$//; - $tmp =~ s/\"\);\s*$//; - $name = $tmp; - } - } - $ldap_host[$sub] = $host; - $ldap_base[$sub] = $base; - $ldap_name[$sub] = $name; - $ldap_port[$sub] = $port; - $ldap_maxrows[$sub] = $maxrows; - $ldap_charset[$sub] = $charset; - } else { - ${$options[0]} = $options[1]; + $var =~ s/=/EQUALS/; + if ($var =~ /^([a-z]|[A-Z])/) { + @options = split(/\s*EQUALS\s*/, $var); + $options[1] =~ s/[\n|\r]//g; + $options[1] =~ s/[\'|\"];\s*$//; + $options[1] =~ s/;$//; + $options[1] =~ s/^[\'|\"]//; + + if ($options[0] =~ /^theme\[[0-9]+\]\[['|"]PATH['|"]\]/) { + $sub = $options[0]; + $sub =~ s/\]\[['|"]PATH['|"]\]//; + $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 =~ 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 =~ s/\]//; + $sub =~ s/^ldap_server\[//; + $continue = 0; + while (($tmp = ) && ($continue != 1)) { + if ($tmp =~ /\);\s*$/) { + $continue = 1; + } + + if ($tmp =~ /^\s*[\'|\"]host[\'|\"]/i) { + $tmp =~ s/^\s*[\'|\"]host[\'|\"]\s*=>\s*[\'|\"]//i; + $tmp =~ s/[\'|\"],?\s*$//; + $tmp =~ s/[\'|\"]\);\s*$//; + $host = $tmp; + } elsif ($tmp =~ /^\s*[\'|\"]base[\'|\"]/i) { + $tmp =~ s/^\s*[\'|\"]base[\'|\"]\s*=>\s*[\'|\"]//i; + $tmp =~ s/[\'|\"],?\s*$//; + $tmp =~ s/[\'|\"]\);\s*$//; + $base = $tmp; + } elsif ($tmp =~ /^\s*[\'|\"]charset[\'|\"]/i) { + $tmp =~ s/^\s*[\'|\"]charset[\'|\"]\s*=>\s*[\'|\"]//i; + $tmp =~ s/[\'|\"],?\s*$//; + $tmp =~ s/[\'|\"]\);\s*$//; + $charset = $tmp; + } elsif ($tmp =~ /^\s*[\'|\"]port[\'|\"]/i) { + $tmp =~ s/^\s*[\'|\"]port[\'|\"]\s*=>\s*[\'|\"]//i; + $tmp =~ s/[\'|\"],?\s*$//; + $tmp =~ s/[\'|\"]\);\s*$//; + $port = $tmp; + } elsif ($tmp =~ /^\s*[\'|\"]maxrows[\'|\"]/i) { + $tmp =~ s/^\s*[\'|\"]maxrows[\'|\"]\s*=>\s*[\'|\"]//i; + $tmp =~ s/[\'|\"],?\s*$//; + $tmp =~ s/[\'|\"]\);\s*$//; + $maxrows = $tmp; + } elsif ($tmp =~ /^\s*[\'|\"]name[\'|\"]/i) { + $tmp =~ s/^\s*[\'|\"]name[\'|\"]\s*=>\s*[\'|\"]//i; + $tmp =~ s/[\'|\"],?\s*$//; + $tmp =~ s/[\'|\"]\);\s*$//; + $name = $tmp; + } + } + $ldap_host[$sub] = $host; + $ldap_base[$sub] = $base; + $ldap_name[$sub] = $name; + $ldap_port[$sub] = $port; + $ldap_maxrows[$sub] = $maxrows; + $ldap_charset[$sub] = $charset; + } else { + ${$options[0]} = $options[1]; } - } + } } close FILE; if ($useSendmail ne "true") { @@ -237,22 +237,22 @@ if (!$invert_time) { $invert_time = "false"; } if (!$force_username_lowercase) { - $force_username_lowercase = "false"; + $force_username_lowercase = "false"; } if (!$optional_delimiter) { - $optional_delimiter = "detect"; + $optional_delimiter = "detect"; } if (!$use_authenticated_smtp) { $use_authenticated_smtp = "false"; } if (!$auto_create_special) { - $auto_create_special = "false"; + $auto_create_special = "false"; } if(!$default_use_priority) { - $default_use_priority = "true"; + $default_use_priority = "true"; } if(!$hide_sm_attributions) { - $hide_sm_attributions = "false"; + $hide_sm_attributions = "false"; } ##################################################################################### @@ -270,7 +270,7 @@ while (($command ne "q") && ($command ne "Q")) { print $WHT."SquirrelMail Configuration : ".$NRM; if ($config == 1) { print "Read: config.php"; } elsif ($config == 2) { print "Read: config_default.php"; } - print "\n"; + print " ($print_config_version)\n"; print "---------------------------------------------------------\n"; if ($menu == 0) { @@ -789,7 +789,7 @@ sub command111 { print "folders. For example, Cyrus uses '.' as the delimiter and a complete\n"; print "folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would\n"; print "look like 'INBOX/Friends/Bob'. Normally this should be left at 'detect'\n"; - print "but if you are sure you konw what delimiter your server uses, you can\n"; + print "but if you are sure you know what delimiter your server uses, you can\n"; print "specify it here.\n"; print "\nTo have it autodetect the delimiter, set it to 'detect'.\n\n"; print "[$WHT$optional_delimiter$NRM]: $WHT"; @@ -1353,7 +1353,9 @@ sub command33c { } else { $new_dir_hash_level =~ s/[\r|\n]//g; } - if ((int($new_dir_hash_level) < 0) || (int($new_dir_hash_level) > 4)) { + if ((int($new_dir_hash_level) < 0) || + (int($new_dir_hash_level) > 4) || + !(int($new_dir_hash_level) eq $new_dir_hash_level )) { print "Invalid Directory Hash Level.\n"; print "Value must be an integer ranging from 0 to 4\n"; print "Hit enter to continue.\n"; @@ -1761,136 +1763,154 @@ sub command62 { sub save_data { - open (FILE, ">config.php"); - - print FILE "config.php"); - print FILE "\tglobal \$print_config_version, \$config_version, \$config_use_color;\n"; + print CF " \"$ldap_host[$count]\",\n"; - print FILE "\t\t\t\"base\" => \"$ldap_base[$count]\""; + print CF "\$ldap_server[$count] = array(\n"; + print CF " 'host' => '$ldap_host[$count]',\n"; + print CF " 'base' => '$ldap_base[$count]'"; if ($ldap_name[$count]) { - print FILE ",\n\t\t\t\"name\" => \"$ldap_name[$count]\""; + print CF ",\n"; + print CF " 'name' => '$ldap_name[$count]'"; } if ($ldap_port[$count]) { - print FILE ",\n\t\t\t\"port\" => \"$ldap_port[$count]\""; + print CF ",\n"; + print CF " 'port' => '$ldap_port[$count]'"; } if ($ldap_charset[$count]) { - print FILE ",\n\t\t\t\"charset\" => \"$ldap_charset[$count]\""; + print CF ",\n"; + print CF " 'charset' => '$ldap_charset[$count]'"; } if ($ldap_maxrows[$count]) { - print FILE ",\n\t\t\t\"maxrows\" => \"$ldap_maxrows[$count]\""; + print CF ",\n"; + print CF " 'maxrows' => '$ldap_maxrows[$count]'"; } - print FILE ");\n\n"; + print CF "\n"; + print CF ");\n"; + print CF "\n"; } - print FILE "\tglobal \$motd;\n"; - print FILE "\t\$motd = \"$motd\";\n"; - - print FILE "\tglobal \$squirrelmail_default_language;\n"; - print FILE "\t\$squirrelmail_default_language = \"$squirrelmail_default_language\";\n"; + print CF "/**\n"; + print CF " * Make sure there are no characters after the PHP closing\n"; + print CF " * tag below (including newline characters and whitespace).\n"; + print CF " * Otherwise, that character will cause the headers to be\n"; + print CF " * sent and regular output to begin, which will majorly screw\n"; + print CF " * things up when we try to send more headers later.\n"; + print CF " */\n"; + print CF "?>"; - close FILE; + close CF; } sub set_defaults {