X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=config%2Fconf.pl;h=2a6459e6c7119495eb0c073b02d955c93c4dbdc4;hb=fb351cd8b38af739b13883544aba380c35f8f4f8;hp=ec277285e5c279cc0ab55725faa4edc83bc0a093;hpb=3392dc867232037b2c6e2089ebcab9d64e154db7;p=squirrelmail.git diff --git a/config/conf.pl b/config/conf.pl index ec277285..2a6459e6 100755 --- a/config/conf.pl +++ b/config/conf.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # conf.pl # Luke Ehresman (luke@squirrelmail.org) # @@ -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") { @@ -231,28 +231,28 @@ if (!$default_unseen_type) { $default_unseen_type = 1; } if (!$config_use_color) { - $config_use_color = 1; + $config_use_color = 0; } 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"; @@ -817,7 +817,7 @@ sub command71 { $line =~ s/ /\ \ /g; $line =~ s/\t/\ \ \ \ /g; $line =~ s/$/ /; - $line =~ s/\"/\\\"/g; + $line =~ s/\'/\\\'/g; $new_motd = $new_motd . $line; } @@ -1353,7 +1353,9 @@ sub command33c { } else { $new_dir_hash_level =~ s/[\r|\n]//g; } - if (($new_dir_hash_level < 0) || ($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"); + $tab = " "; + open (CF, ">config.php"); - print FILE " \"$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 { @@ -1925,77 +1945,74 @@ sub set_defaults { print "\n"; if ($server eq "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; - $imap_server_type = "cyrus"; - - print " default_folder_prefix = none\n"; - print " trash_folder = INBOX.Trash\n"; - print " sent_folder = INBOX.Sent\n"; - print " draft_folder = INBOX.Drafts\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"; + $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 = ""; $continue = 1; } elsif ($server eq "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; - $imap_server_type = "uw"; - - print " default_folder_prefix = mail/\n"; - print " trash_folder = Trash\n"; - print " sent_folder = Sent\n"; - print " draft_folder = Drafts\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"; - + $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") { - $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; - $imap_server_type = "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 = ""; - print " default_folder_prefix = \n"; - print " default_sub_of_inbox = true\n"; - print " trash_folder = \"INBOX/Deleted Items\"\n"; - print " sent_folder = \"INBOX/Sent Items\"\n"; - print " draft_folder = \"INBOX/Drafts\"\n"; - print " show_prefix_option = false\n"; - print " show_contain_subfolders_option = false\n"; - print " imap_server_type = exchange\n"; - - $continue = 1; + $continue = 1; } elsif ($server eq "courier") { - $imap_server_type = "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; - print " imap_server_type = courier\n"; - $continue = 1; - } elsif ($server eq "quit") { - $continue = 1; + } elsif ($server eq "quit") { + $continue = 1; } else { + $disp_default_folder_prefix = $default_folder_prefix; print "Unrecognized server: $server\n"; - print "\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 = ;