| 1 | #!/usr/bin/perl |
| 2 | # conf.pl |
| 3 | # Written March 26, 2000 |
| 4 | # Luke Ehresman (lehresma@css.tayloru.edu) |
| 5 | # |
| 6 | # A simple configure script to configure squirrelmail |
| 7 | ############################################################ |
| 8 | $WHT = "\x1B[37;1m"; |
| 9 | $NRM = "\x1B[0m"; |
| 10 | |
| 11 | system "clear"; |
| 12 | print "\n\n--------------------------------------------------------\n"; |
| 13 | print "SquirrelMail version 0.4 -- Configure script\n"; |
| 14 | print "by SquirrelMail Development Team\n"; |
| 15 | print "http://squirrelmail.sourceforge.net\n"; |
| 16 | print "--------------------------------------------------------\n"; |
| 17 | print "\n"; |
| 18 | |
| 19 | ############################################################ |
| 20 | # First, lets read in the data already in there... |
| 21 | ############################################################ |
| 22 | if ( -e "config.php") { |
| 23 | print "The file \"config.php\" exists. Using it for defaults.\n\n"; |
| 24 | open (FILE, "config.php"); |
| 25 | } else { |
| 26 | print "No config file found. Reading from config_defaults.php.\n\n"; |
| 27 | open (FILE, "config_default.php"); |
| 28 | } |
| 29 | |
| 30 | # Reads and parses the current configuration file (either |
| 31 | # config.php or config_default.php). |
| 32 | |
| 33 | while ($line = <FILE>) { |
| 34 | if ($line =~ /^\s+\$/) { |
| 35 | $line =~ s/^\s+\$//; |
| 36 | $var = $line; |
| 37 | |
| 38 | if ($var =~ /^([a-z]|[A-Z])/) { |
| 39 | @options = split(/\s=\s/, $var); |
| 40 | $options[1] =~ s/[\n|\r]//g; |
| 41 | $options[1] =~ s/^"//g; |
| 42 | $options[1] =~ s/;.*$//g; |
| 43 | $options[1] =~ s/"$//g; |
| 44 | |
| 45 | if ($options[0] =~ /^special_folders/) { |
| 46 | if ($options[0] =~ /\[.*\]$/) { |
| 47 | $sub = $options[0]; |
| 48 | $sub =~ s/\]$//; |
| 49 | $sub = substr ($sub, @sub-1, 1); |
| 50 | |
| 51 | $special_folders[$sub] = $options[1]; |
| 52 | } |
| 53 | } elsif ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) { |
| 54 | $sub = $options[0]; |
| 55 | $sub =~ s/\]\["PATH"\]//; |
| 56 | $sub = substr ($sub, @sub-1, 1); |
| 57 | $theme_path[$sub] = $options[1]; |
| 58 | } elsif ($options[0] =~ /^theme\[[0-9]+\]\["NAME"\]/) { |
| 59 | $sub = $options[0]; |
| 60 | $sub =~ s/\]\["NAME"\]//; |
| 61 | $sub = substr ($sub, @sub-1, 1); |
| 62 | $theme_name[$sub] = $options[1]; |
| 63 | } else { |
| 64 | ${$options[0]} = $options[1]; |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | open (FILE, ">cf.php"); |
| 71 | print FILE "<?\n\t/** SquirrelMail configure script\n"; |
| 72 | print FILE " ** Created using the configure script, config.pl.\n\t **/\n\n"; |
| 73 | |
| 74 | |
| 75 | ##################################################################################### |
| 76 | |
| 77 | # org_name |
| 78 | sub command1 { |
| 79 | print "We have tried to make the name SquirrelMail as transparent as\n"; |
| 80 | print "possible. If you set up an organization name, most places where\n"; |
| 81 | print "SquirrelMail would take credit will be credited to your organization.\n"; |
| 82 | print "\n"; |
| 83 | print "What is the name of your organization [$org_name]: "; |
| 84 | $new_org_name = <STDIN>; |
| 85 | if ($new_org_name eq "\n") { |
| 86 | $new_org_name = $org_name; |
| 87 | } else { |
| 88 | $new_org_name =~ s/[\r|\n]//g; |
| 89 | } |
| 90 | return $new_org_name; |
| 91 | } |
| 92 | |
| 93 | # org_logo |
| 94 | sub command2 { |
| 95 | print "Your organization's logo is an image that will be displayed at\n"; |
| 96 | print "different times throughout SquirrelMail. This is asking for the\n"; |
| 97 | print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n"; |
| 98 | print "(../images/logo.jpg) path to your logo.\n"; |
| 99 | print "\n"; |
| 100 | print "Where is the logo for your organization [$org_logo]: "; |
| 101 | $new_org_logo = <STDIN>; |
| 102 | if ($new_org_logo eq "\n") { |
| 103 | $new_org_logo = $org_logo; |
| 104 | } else { |
| 105 | $new_org_logo =~ s/[\r|\n]//g; |
| 106 | } |
| 107 | return $new_org_logo; |
| 108 | } |
| 109 | |
| 110 | # org_title |
| 111 | sub command3 { |
| 112 | print "A title is what is displayed at the top of the browser window in\n"; |
| 113 | print "the titlebar. Usually this will end up looking something like:\n"; |
| 114 | print "\"Netscape: $org_title\"\n"; |
| 115 | print "\n"; |
| 116 | print "The title of the web page [$org_title]: "; |
| 117 | $new_org_title = <STDIN>; |
| 118 | if ($new_org_title eq "\n") { |
| 119 | $new_org_title = $org_title; |
| 120 | } else { |
| 121 | $new_org_title =~ s/[\r|\n]//g; |
| 122 | } |
| 123 | return $new_org_title; |
| 124 | } |
| 125 | |
| 126 | # domain |
| 127 | sub command10 { |
| 128 | print "The domain is what is on the right side of the \@ in the email\n"; |
| 129 | print "address. If your address is somebody\@somewhere.com, then your\n"; |
| 130 | print "domain would be \"somewhere.com\".\n"; |
| 131 | print "\n"; |
| 132 | print "Your domain [$WHT$domain$NRM]: ".$WHT; |
| 133 | $new_domain = <STDIN>; |
| 134 | if ($new_domain eq "\n") { |
| 135 | $new_domain = $domain; |
| 136 | } else { |
| 137 | $new_domain =~ s/[\r|\n]//g; |
| 138 | } |
| 139 | return $new_domain; |
| 140 | } |
| 141 | |
| 142 | ##################################################################################### |
| 143 | |
| 144 | while (($command ne "q") && ($command ne "Q")) { |
| 145 | system "clear"; |
| 146 | print $WHT."General Information --\n".$NRM; |
| 147 | print "1 Name of organization : $WHT$org_name$NRM\n"; |
| 148 | print "2 Where is your logo : $WHT$org_logo$NRM\n"; |
| 149 | print "3 Title of web page : $WHT$org_title$NRM\n"; |
| 150 | print "\n"; |
| 151 | print $WHT."Server Information --\n".$NRM; |
| 152 | print "10 Domain : $WHT$domain$NRM\n"; |
| 153 | print "11 IMAP server : \n"; |
| 154 | print "12 IMAP port : \n"; |
| 155 | print "13 Use Sendmail? : \n"; |
| 156 | if (@vars[4] eq "true") { |
| 157 | print "14 Sendmail path : \n"; |
| 158 | } else { |
| 159 | print "15 SMTP server : \n"; |
| 160 | print "16 SMTP port : \n"; |
| 161 | } |
| 162 | print "\n"; |
| 163 | print $WHT."General Options --\n".$NRM; |
| 164 | print "20 Welcome message\n"; |
| 165 | print "21 Auto expunge : @vars[10]\n"; |
| 166 | print "22 Fodlers sub of INBOX : @vars[11]\n"; |
| 167 | print "\n"; |
| 168 | print "x Exit without saving\n"; |
| 169 | print "q Save and exit\n"; |
| 170 | print "\n"; |
| 171 | print "Command: "; |
| 172 | |
| 173 | $command = <STDIN>; |
| 174 | $command =~ s/[\n|\r]//g; |
| 175 | |
| 176 | print "\n"; |
| 177 | |
| 178 | if ($command eq "1" ) { $org_name = command1 (); } |
| 179 | elsif ($command eq "2" ) { $org_logo = command2 (); } |
| 180 | elsif ($command eq "3" ) { $org_title = command3 (); } |
| 181 | |
| 182 | elsif ($command eq "10") { $domain = command10 (); } |
| 183 | elsif ($command eq "11") { $imapServerAddress = command11 (); } |
| 184 | elsif ($command eq "12") { $imapPort = command12 (); } |
| 185 | elsif ($command eq "13") { $use_sendmail = command3 (); } |
| 186 | elsif ($command eq "14") { $org_title = command3 (); } |
| 187 | elsif ($command eq "15") { $org_title = command3 (); } |
| 188 | } |