| 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 | ############################################################ |
| 12 | # First, lets read in the data already in there... |
| 13 | ############################################################ |
| 14 | if ( -e "config.php") { |
| 15 | $config = 1; |
| 16 | open (FILE, "config.php"); |
| 17 | } elsif (-e "config_default.php") { |
| 18 | $config = 2; |
| 19 | open (FILE, "config_default.php"); |
| 20 | } else { |
| 21 | print "No configuration file found. Please get config_default.php or\n"; |
| 22 | print "config.php before running this again. This program needs a\n"; |
| 23 | print "default config file to get default values.\n"; |
| 24 | exit; |
| 25 | } |
| 26 | |
| 27 | # Reads and parses the current configuration file (either |
| 28 | # config.php or config_default.php). |
| 29 | |
| 30 | while ($line = <FILE>) { |
| 31 | if ($line =~ /^\s+\$/) { |
| 32 | $line =~ s/^\s+\$//; |
| 33 | $var = $line; |
| 34 | |
| 35 | if ($var =~ /^([a-z]|[A-Z])/) { |
| 36 | @options = split(/\s*=\s*/, $var); |
| 37 | $options[1] =~ s/[\n|\r]//g; |
| 38 | $options[1] =~ s/^"//g; |
| 39 | $options[1] =~ s/;.*$//g; |
| 40 | $options[1] =~ s/"$//g; |
| 41 | |
| 42 | if ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) { |
| 43 | $sub = $options[0]; |
| 44 | $sub =~ s/\]\["PATH"\]//; |
| 45 | $sub = substr ($sub, @sub-1, 1); |
| 46 | $theme_path[$sub] = $options[1]; |
| 47 | } elsif ($options[0] =~ /^theme\[[0-9]+\]\["NAME"\]/) { |
| 48 | $sub = $options[0]; |
| 49 | $sub =~ s/\]\["NAME"\]//; |
| 50 | $sub = substr ($sub, @sub-1, 1); |
| 51 | $theme_name[$sub] = $options[1]; |
| 52 | } elsif ($options[0] =~ /^ldap_server\[[0-9]+\]/) { |
| 53 | $sub = $options[0]; |
| 54 | $sub = substr ($sub, length($sub)-2, 1); |
| 55 | $continue = 0; |
| 56 | while (($tmp = <FILE>) && ($continue != 1)) { |
| 57 | if ($tmp =~ /\);\s*$/) { |
| 58 | $continue = 1; |
| 59 | } |
| 60 | |
| 61 | if ($tmp =~ /^\s*"host"/i) { |
| 62 | $tmp =~ s/^\s*"host"\s*=>\s*"//i; |
| 63 | $tmp =~ s/",\s*$//; |
| 64 | $tmp =~ s/"\);\s*$//; |
| 65 | $host = $tmp; |
| 66 | } elsif ($tmp =~ /^\s*"base"/i) { |
| 67 | $tmp =~ s/^\s*"base"\s*=>\s*"//i; |
| 68 | $tmp =~ s/",\s*$//; |
| 69 | $tmp =~ s/"\);\s*$//; |
| 70 | print $tmp."\n"; |
| 71 | $base = $tmp; |
| 72 | } elsif ($tmp =~ /^\s*"charset"/i) { |
| 73 | $tmp =~ s/^\s*"charset"\s*=>\s*"//i; |
| 74 | $tmp =~ s/",\s*$//; |
| 75 | $tmp =~ s/"\);\s*$//; |
| 76 | $charset = $tmp; |
| 77 | } elsif ($tmp =~ /^\s*"port"/i) { |
| 78 | $tmp =~ s/^\s*"port"\s*=>\s*"//i; |
| 79 | $tmp =~ s/",\s*$//; |
| 80 | $tmp =~ s/"\);\s*$//; |
| 81 | $port = $tmp; |
| 82 | } elsif ($tmp =~ /^\s*"maxrows"/i) { |
| 83 | $tmp =~ s/^\s*"maxrows"\s*=>\s*"//i; |
| 84 | $tmp =~ s/",\s*$//; |
| 85 | $tmp =~ s/"\);\s*$//; |
| 86 | $maxrows = $tmp; |
| 87 | } elsif ($tmp =~ /^\s*"name"/i) { |
| 88 | $tmp =~ s/^\s*"name"\s*=>\s*"//i; |
| 89 | $tmp =~ s/",\s*$//; |
| 90 | $tmp =~ s/"\);\s*$//; |
| 91 | $name = $tmp; |
| 92 | } |
| 93 | } |
| 94 | $ldap_host[$sub] = $host; |
| 95 | $ldap_base[$sub] = $base; |
| 96 | $ldap_name[$sub] = $name; |
| 97 | $ldap_port[$sub] = $port; |
| 98 | $ldap_maxrows[$sub] = $maxrows; |
| 99 | $ldap_charset[$sub] = $charset; |
| 100 | } else { |
| 101 | ${$options[0]} = $options[1]; |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | if ($useSendmail ne "true") { |
| 107 | $useSendmail = "false"; |
| 108 | } |
| 109 | if (!$sendmail_path) { |
| 110 | $sendmail_path = "/usr/sbin/sendmail"; |
| 111 | } |
| 112 | |
| 113 | ##################################################################################### |
| 114 | |
| 115 | while (($command ne "q") && ($command ne "Q")) { |
| 116 | system "clear"; |
| 117 | if ($menu == 0) { |
| 118 | print $WHT."SquirrelMail Configuration : ".$NRM; |
| 119 | if ($config == 1) { print "Read: config.php"; } |
| 120 | elsif ($config == 2) { print "Read: config_default.php"; } |
| 121 | print "\n"; |
| 122 | |
| 123 | print $WHT."Main Menu --\n".$NRM; |
| 124 | print "1. Organization Preferences\n"; |
| 125 | print "2. Server Settings\n"; |
| 126 | print "3. Folder Defaults\n"; |
| 127 | print "4. General Options\n"; |
| 128 | print "5. Themes\n"; |
| 129 | print "6. Address Books (LDAP)\n"; |
| 130 | print "7. Message of the Day (MOTD)\n"; |
| 131 | print "\n"; |
| 132 | print "D. Set pre-defined settings for specific IMAP servers\n"; |
| 133 | print "\n"; |
| 134 | } elsif ($menu == 1) { |
| 135 | print $WHT."Organization Preferences\n".$NRM; |
| 136 | print "1. Organization Name : $WHT$org_name$NRM\n"; |
| 137 | print "2. Organization Logo : $WHT$org_logo$NRM\n"; |
| 138 | print "3. Organization Title : $WHT$org_title$NRM\n"; |
| 139 | print "\n"; |
| 140 | print "R Return to Main Menu\n"; |
| 141 | } elsif ($menu == 2) { |
| 142 | print $WHT."Server Settings\n".$NRM; |
| 143 | print "1. Domain : $WHT$domain$NRM\n"; |
| 144 | print "2. IMAP Server : $WHT$imapServerAddress$NRM\n"; |
| 145 | print "3. IMAP Port : $WHT$imapPort$NRM\n"; |
| 146 | print "4. Use Sendmail : $WHT$useSendmail$NRM\n"; |
| 147 | if ($useSendmail eq "true") { |
| 148 | print "5. Sendmail Path : $WHT$sendmail_path$NRM\n"; |
| 149 | } else { |
| 150 | print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n"; |
| 151 | print "7. SMTP Port : $WHT$smtpPort$NRM\n"; |
| 152 | } |
| 153 | print "8. Server : $WHT$imap_server_type$NRM\n"; |
| 154 | print "\n"; |
| 155 | print "R Return to Main Menu\n"; |
| 156 | } elsif ($menu == 3) { |
| 157 | print $WHT."Folder Defaults\n".$NRM; |
| 158 | print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n"; |
| 159 | print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n"; |
| 160 | print "3. Trash Folder : $WHT$trash_folder$NRM\n"; |
| 161 | print "4. Sent Folder : $WHT$sent_folder$NRM\n"; |
| 162 | print "5. List Special Folders First : $WHT$list_special_folders_first$NRM\n"; |
| 163 | print "6. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n"; |
| 164 | print "7. By default, move to trash : $WHT$default_move_to_trash$NRM\n"; |
| 165 | print "8. Auto Expunge : $WHT$auto_expunge$NRM\n"; |
| 166 | print "9. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n"; |
| 167 | print "10. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n"; |
| 168 | print "\n"; |
| 169 | print "R Return to Main Menu\n"; |
| 170 | } elsif ($menu == 4) { |
| 171 | print $WHT."General Options\n".$NRM; |
| 172 | print "1. Default Charset : $WHT$default_charset$NRM\n"; |
| 173 | print "2. Auto Forward : $WHT$auto_forward$NRM\n"; |
| 174 | print "3. Data Directory : $WHT$data_dir$NRM\n"; |
| 175 | print "4. Attachment Directory : $WHT$attachment_dir$NRM\n"; |
| 176 | print "5. Default Left Size : $WHT$default_left_size$NRM\n"; |
| 177 | print "\n"; |
| 178 | print "R Return to Main Menu\n"; |
| 179 | } elsif ($menu == 5) { |
| 180 | print $WHT."Themes\n".$NRM; |
| 181 | print "1. Change Themes\n"; |
| 182 | for ($count = 0; $count <= $#theme_name; $count++) { |
| 183 | print " > $theme_name[$count]\n"; |
| 184 | } |
| 185 | print "\n"; |
| 186 | print "R Return to Main Menu\n"; |
| 187 | } elsif ($menu == 6) { |
| 188 | print $WHT."Address Books (LDAP)\n".$NRM; |
| 189 | print "1. Change Servers\n"; |
| 190 | for ($count = 0; $count <= $#ldap_host; $count++) { |
| 191 | print " > $ldap_host[$count]\n"; |
| 192 | } |
| 193 | print "\n"; |
| 194 | print "R Return to Main Menu\n"; |
| 195 | } elsif ($menu == 7) { |
| 196 | print $WHT."Message of the Day (MOTD)\n".$NRM; |
| 197 | print "\n$motd\n"; |
| 198 | print "\n"; |
| 199 | print "1 Edit the MOTD\n"; |
| 200 | print "\n"; |
| 201 | print "R Return to Main Menu\n"; |
| 202 | } |
| 203 | print "S Save data\n"; |
| 204 | print "Q Quit\n"; |
| 205 | |
| 206 | print "\n"; |
| 207 | print "Command >> ".$WHT; |
| 208 | $command = <STDIN>; |
| 209 | $command =~ s/[\n|\r]//g; |
| 210 | print "$NRM\n"; |
| 211 | |
| 212 | # Read the commands they entered. |
| 213 | if (($command eq "R") || ($command eq "r")) { |
| 214 | $menu = 0; |
| 215 | } elsif (($command eq "s") || ($command eq "S")) { |
| 216 | save_data (); |
| 217 | print "Data saved in config.php\n"; |
| 218 | print "Press any key to continue..."; |
| 219 | $tmp = <STDIN>; |
| 220 | $saved = 1; |
| 221 | } elsif ((($command eq "q") || ($command eq "Q")) && ($saved == 0)) { |
| 222 | print "You have not saved your data.\n"; |
| 223 | print "Save? (y/n) [".$WHT."y".$NRM."]: "; |
| 224 | $save = <STDIN>; |
| 225 | if (($save =~ /^y/i) || ($save =~ /^\s*$/)) { |
| 226 | save_data (); |
| 227 | } |
| 228 | } elsif (($command eq "d") || ($command eq "D")) { |
| 229 | set_defaults (); |
| 230 | } else { |
| 231 | $saved = 0; |
| 232 | if ($menu == 0) { |
| 233 | if (($command > 0) && ($command < 8)) { |
| 234 | $menu = $command; |
| 235 | } |
| 236 | } elsif ($menu == 1) { |
| 237 | if ($command == 1) { $org_name = command1 (); } |
| 238 | elsif ($command == 2) { $org_logo = command2 (); } |
| 239 | elsif ($command == 3) { $org_title = command3 (); } |
| 240 | } elsif ($menu == 2) { |
| 241 | if ($command == 1) { $domain = command11 (); } |
| 242 | elsif ($command == 2) { $imapServerAddress = command12 (); } |
| 243 | elsif ($command == 3) { $imapPort = command13 (); } |
| 244 | elsif ($command == 4) { $useSendmail = command14 (); } |
| 245 | elsif ($command == 5) { $sendmail_path = command15 (); } |
| 246 | elsif ($command == 6) { $smtpServerAddress = command16 (); } |
| 247 | elsif ($command == 7) { $smtpPort = command17 (); } |
| 248 | elsif ($command == 8) { $imap_server_type = command18 (); } |
| 249 | } elsif ($menu == 3) { |
| 250 | if ($command == 1) { $default_folder_prefix = command21 (); } |
| 251 | elsif ($command == 2) { $show_prefix_option = command22 (); } |
| 252 | elsif ($command == 3) { $trash_folder = command23 (); } |
| 253 | elsif ($command == 4) { $sent_folder = command24 (); } |
| 254 | elsif ($command == 5) { $list_special_folders_first = command25 (); } |
| 255 | elsif ($command == 6) { $use_special_folder_color = command26 (); } |
| 256 | elsif ($command == 7) { $default_move_to_trash = command27 (); } |
| 257 | elsif ($command == 8) { $auto_expunge = command28 (); } |
| 258 | elsif ($command == 9) { $default_sub_of_inbox = command29 (); } |
| 259 | elsif ($command == 10){ $show_contain_subfolders_option = command210(); } |
| 260 | } elsif ($menu == 4) { |
| 261 | if ($command == 1) { $default_charset = command31 (); } |
| 262 | elsif ($command == 2) { $auto_forward = command32 (); } |
| 263 | elsif ($command == 3) { $data_dir = command33 (); } |
| 264 | elsif ($command == 4) { $attachment_dir = command34 (); } |
| 265 | elsif ($command == 5) { $default_left_size = command35 (); } |
| 266 | } elsif ($menu == 5) { |
| 267 | if ($command == 1) { |
| 268 | command41 (); |
| 269 | } |
| 270 | } elsif ($menu == 6) { |
| 271 | if ($command == 1) { command61(); } |
| 272 | } elsif ($menu == 7) { |
| 273 | if ($command == 1) { $motd = command71 (); $motd =~ s/"/\\"/g;} |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | #################################################################################### |
| 279 | |
| 280 | # org_name |
| 281 | sub command1 { |
| 282 | print "We have tried to make the name SquirrelMail as transparent as\n"; |
| 283 | print "possible. If you set up an organization name, most places where\n"; |
| 284 | print "SquirrelMail would take credit will be credited to your organization.\n"; |
| 285 | print "\n"; |
| 286 | print "[$WHT$org_name$NRM]: $WHT"; |
| 287 | $new_org_name = <STDIN>; |
| 288 | if ($new_org_name eq "\n") { |
| 289 | $new_org_name = $org_name; |
| 290 | } else { |
| 291 | $new_org_name =~ s/[\r|\n]//g; |
| 292 | } |
| 293 | return $new_org_name; |
| 294 | } |
| 295 | |
| 296 | |
| 297 | # org_logo |
| 298 | sub command2 { |
| 299 | print "Your organization's logo is an image that will be displayed at\n"; |
| 300 | print "different times throughout SquirrelMail. This is asking for the\n"; |
| 301 | print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n"; |
| 302 | print "(../images/logo.jpg) path to your logo.\n"; |
| 303 | print "\n"; |
| 304 | print "[$WHT$org_logo$NRM]: $WHT"; |
| 305 | $new_org_logo = <STDIN>; |
| 306 | if ($new_org_logo eq "\n") { |
| 307 | $new_org_logo = $org_logo; |
| 308 | } else { |
| 309 | $new_org_logo =~ s/[\r|\n]//g; |
| 310 | } |
| 311 | return $new_org_logo; |
| 312 | } |
| 313 | |
| 314 | # org_title |
| 315 | sub command3 { |
| 316 | print "A title is what is displayed at the top of the browser window in\n"; |
| 317 | print "the titlebar. Usually this will end up looking something like:\n"; |
| 318 | print "\"Netscape: $org_title\"\n"; |
| 319 | print "\n"; |
| 320 | print "[$WHT$org_title$NRM]: $WHT"; |
| 321 | $new_org_title = <STDIN>; |
| 322 | if ($new_org_title eq "\n") { |
| 323 | $new_org_title = $org_title; |
| 324 | } else { |
| 325 | $new_org_title =~ s/[\r|\n]//g; |
| 326 | } |
| 327 | return $new_org_title; |
| 328 | } |
| 329 | |
| 330 | #################################################################################### |
| 331 | |
| 332 | # domain |
| 333 | sub command11 { |
| 334 | print "The domain name is the suffix at the end of all email messages. If\n"; |
| 335 | print "for example, your email address is jdoe\@myorg.com, then your domain\n"; |
| 336 | print "would be myorg.com.\n"; |
| 337 | print "\n"; |
| 338 | print "[$WHT$domain$NRM]: $WHT"; |
| 339 | $new_domain = <STDIN>; |
| 340 | if ($new_domain eq "\n") { |
| 341 | $new_domain = $domain; |
| 342 | } else { |
| 343 | $new_domain =~ s/[\r|\n]//g; |
| 344 | } |
| 345 | return $new_domain; |
| 346 | } |
| 347 | |
| 348 | # imapServerAddress |
| 349 | sub command12 { |
| 350 | print "This is the address where your IMAP server resides.\n"; |
| 351 | print "[$WHT$imapServerAddress$NRM]: $WHT"; |
| 352 | $new_imapServerAddress = <STDIN>; |
| 353 | if ($new_imapServerAddress eq "\n") { |
| 354 | $new_imapServerAddress = $imapServerAddress; |
| 355 | } else { |
| 356 | $new_imapServerAddress =~ s/[\r|\n]//g; |
| 357 | } |
| 358 | return $new_imapServerAddress; |
| 359 | } |
| 360 | |
| 361 | # imapPort |
| 362 | sub command13 { |
| 363 | print "This is the port that your IMAP server is on. Usually this is 143.\n"; |
| 364 | print "[$WHT$imapPort$NRM]: $WHT"; |
| 365 | $new_imapPort = <STDIN>; |
| 366 | if ($new_imapPort eq "\n") { |
| 367 | $new_imapPort = $imapPort; |
| 368 | } else { |
| 369 | $new_imapPort =~ s/[\r|\n]//g; |
| 370 | } |
| 371 | return $new_imapPort; |
| 372 | } |
| 373 | |
| 374 | # useSendmail |
| 375 | sub command14 { |
| 376 | print "You now need to choose the method that you will use for sending\n"; |
| 377 | print "messages in SquirrelMail. You can either connect to an SMTP server\n"; |
| 378 | print "or use sendmail directly.\n"; |
| 379 | if ($useSendmail eq "true") { |
| 380 | $default_value = "y"; |
| 381 | } else { |
| 382 | $default_value = "n"; |
| 383 | } |
| 384 | print "\n"; |
| 385 | print "Use Sendmail (y/n) [$WHT$default_value$NRM]: $WHT"; |
| 386 | $use_sendmail = <STDIN>; |
| 387 | if (($use_sendmail =~ /^y\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "y"))) { |
| 388 | $useSendmail = "true"; |
| 389 | } else { |
| 390 | $useSendmail = "false"; |
| 391 | } |
| 392 | return $useSendmail; |
| 393 | } |
| 394 | |
| 395 | # sendmail_path |
| 396 | sub command15 { |
| 397 | if ($sendmail_path[0] !~ /./) { |
| 398 | $sendmail_path = "/usr/sbin/sendmail"; |
| 399 | } |
| 400 | print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n"; |
| 401 | print "[$WHT$sendmail_path$NRM]: $WHT"; |
| 402 | $new_sendmail_path = <STDIN>; |
| 403 | if ($new_sendmail_path eq "\n") { |
| 404 | $new_sendmail_path = $sendmail_path; |
| 405 | } else { |
| 406 | $new_sendmail_path =~ s/[\r|\n]//g; |
| 407 | } |
| 408 | return $new_sendmail_path; |
| 409 | } |
| 410 | |
| 411 | # smtpServerAddress |
| 412 | sub command16 { |
| 413 | print "This is the location of your SMTP server.\n"; |
| 414 | print "[$WHT$smtpServerAddress$NRM]: $WHT"; |
| 415 | $new_smtpServerAddress = <STDIN>; |
| 416 | if ($new_smtpServerAddress eq "\n") { |
| 417 | $new_smtpServerAddress = $smtpServerAddress; |
| 418 | } else { |
| 419 | $new_smtpServerAddress =~ s/[\r|\n]//g; |
| 420 | } |
| 421 | return $new_smtpServerAddress; |
| 422 | } |
| 423 | |
| 424 | # smtpPort |
| 425 | sub command17 { |
| 426 | print "This is the port to connect to for SMTP. Usually 25.\n"; |
| 427 | print "[$WHT$smtpPort$NRM]: $WHT"; |
| 428 | $new_smtpPort = <STDIN>; |
| 429 | if ($new_smtpPort eq "\n") { |
| 430 | $new_smtpPort = $smtpPort; |
| 431 | } else { |
| 432 | $new_smtpPort =~ s/[\r|\n]//g; |
| 433 | } |
| 434 | return $new_smtpPort; |
| 435 | } |
| 436 | # imap_server_type |
| 437 | sub command18 { |
| 438 | print "Eash IMAP server has its own quirks. As much as we tried to stick\n"; |
| 439 | print "to standards, it doesn't help much if the IMAP server doesn't follow\n"; |
| 440 | print "the same principles. We have made some work-arounds for some of\n"; |
| 441 | print "these servers. If you would like to use them, please select your\n"; |
| 442 | print "IMAP server. If you do not wish to use these work-arounds, you can\n"; |
| 443 | print "set this to \"other\", and none will be used.\n"; |
| 444 | print " cyrus = Cyrus IMAP server\n"; |
| 445 | print " uw = University of Washington's IMAP server\n"; |
| 446 | print " exchange = Microsoft Exchange IMAP server\n"; |
| 447 | print " courier = Courier IMAP server\n"; |
| 448 | print "[$WHT$imap_server_type$NRM]: $WHT"; |
| 449 | $new_imap_server_type = <STDIN>; |
| 450 | if ($new_imap_server_type eq "\n") { |
| 451 | $new_imap_server_type = $imap_server_type; |
| 452 | } else { |
| 453 | $new_imap_server_type =~ s/[\r|\n]//g; |
| 454 | } |
| 455 | return $new_imap_server_type; |
| 456 | } |
| 457 | |
| 458 | # MOTD |
| 459 | sub command71 { |
| 460 | print "\nYou can now create the welcome message that is displayed\n"; |
| 461 | print "every time a user logs on. You can use HTML or just plain\n"; |
| 462 | print "text.\n\n(Type @ on a blank line to exit)\n"; |
| 463 | do { |
| 464 | print "] "; |
| 465 | $line = <STDIN>; |
| 466 | $line =~ s/[\r|\n]//g; |
| 467 | $line =~ s/ /\ \ /g; |
| 468 | if ($line ne "@") { |
| 469 | $new_motd = $new_motd . $line; |
| 470 | } |
| 471 | } while ($line ne "@"); |
| 472 | return $new_motd; |
| 473 | } |
| 474 | |
| 475 | ################# FOLDERS ################### |
| 476 | |
| 477 | # default_folder_prefix |
| 478 | sub command21 { |
| 479 | print "Some IMAP servers (UW, for example) store mail and folders in\n"; |
| 480 | print "your user space in a separate subdirectory. This is where you\n"; |
| 481 | print "specify what that directory is.\n"; |
| 482 | print "\n"; |
| 483 | print "EXAMPLE: mail/"; |
| 484 | print "\n"; |
| 485 | print "NOTE: If you use Cyrus, or some server that would not use this\n"; |
| 486 | print " option, you must set this to 'none'.\n"; |
| 487 | print "\n"; |
| 488 | print "[$WHT$default_folder_prefix$NRM]: $WHT"; |
| 489 | $new_default_folder_prefix = <STDIN>; |
| 490 | if ($new_default_folder_prefix eq "\n") { |
| 491 | $new_default_folder_prefix = $default_folder_prefix; |
| 492 | } else { |
| 493 | $new_default_folder_prefix =~ s/[\r|\n]//g; |
| 494 | } |
| 495 | if (($new_default_folder_prefix =~ /^\s*$/) || ($new_default_folder_prefix =~ /none/i)) { |
| 496 | $new_default_folder_prefix = ""; |
| 497 | } else { |
| 498 | $new_default_folder_prefix =~ s/\/*$//g; |
| 499 | $new_default_folder_prefix =~ s/$/\//g; |
| 500 | } |
| 501 | return $new_default_folder_prefix; |
| 502 | } |
| 503 | |
| 504 | # Show Folder Prefix |
| 505 | sub command22 { |
| 506 | print "It is possible to set up the default folder prefix as a user\n"; |
| 507 | print "specific option, where each user can specify what their mail\n"; |
| 508 | print "folder is. If you set this to false, they will never see the\n"; |
| 509 | print "option, but if it is true, this option will appear in the\n"; |
| 510 | print "'options' section.\n"; |
| 511 | print "\n"; |
| 512 | print "NOTE: You set the default folder prefix in option '1' of this\n"; |
| 513 | print " section. That will be the default if the user doesn't\n"; |
| 514 | print " specify anything different.\n"; |
| 515 | print "\n"; |
| 516 | |
| 517 | if ($show_prefix_option eq "true") { |
| 518 | $default_value = "y"; |
| 519 | } else { |
| 520 | $default_value = "n"; |
| 521 | } |
| 522 | print "\n"; |
| 523 | print "Show option (y/n) [$WHT$default_value$NRM]: $WHT"; |
| 524 | $new_show = <STDIN>; |
| 525 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
| 526 | $show_prefix_option = "true"; |
| 527 | } else { |
| 528 | $show_prefix_option = "false"; |
| 529 | } |
| 530 | return $show_prefix_option; |
| 531 | } |
| 532 | |
| 533 | # Trash Folder |
| 534 | sub command23 { |
| 535 | print "You can now specify where the default trash folder is located.\n"; |
| 536 | print "On servers where you do not want this, you can set it to anything\n"; |
| 537 | print "and set option 7 to false.\n"; |
| 538 | print "\n"; |
| 539 | print "This is relative to where the rest of your email is kept. You do\n"; |
| 540 | print "not need to worry about their mail directory. If this folder\n"; |
| 541 | print "would be ~/mail/trash on the filesystem, you only need to specify\n"; |
| 542 | print "that this is 'trash', and be sure to put 'mail/' in option 1.\n"; |
| 543 | print "\n"; |
| 544 | |
| 545 | print "[$WHT$trash_folder$NRM]: $WHT"; |
| 546 | $new_trash_folder = <STDIN>; |
| 547 | if ($new_trash_folder eq "\n") { |
| 548 | $new_trash_folder = $trash_folder; |
| 549 | } else { |
| 550 | $new_trash_folder =~ s/[\r|\n]//g; |
| 551 | } |
| 552 | return $new_trash_folder; |
| 553 | } |
| 554 | |
| 555 | # Sent Folder |
| 556 | sub command24 { |
| 557 | print "This is where messages that are sent will be stored. SquirrelMail\n"; |
| 558 | print "by default puts a copy of all outgoing messages in this folder.\n"; |
| 559 | print "\n"; |
| 560 | print "This is relative to where the rest of your email is kept. You do\n"; |
| 561 | print "not need to worry about their mail directory. If this folder\n"; |
| 562 | print "would be ~/mail/sent on the filesystem, you only need to specify\n"; |
| 563 | print "that this is 'sent', and be sure to put 'mail/' in option 1.\n"; |
| 564 | print "\n"; |
| 565 | |
| 566 | print "[$WHT$sent_folder$NRM]: $WHT"; |
| 567 | $new_sent_folder = <STDIN>; |
| 568 | if ($new_sent_folder eq "\n") { |
| 569 | $new_sent_folder = $sent_folder; |
| 570 | } else { |
| 571 | $new_sent_folder =~ s/[\r|\n]//g; |
| 572 | } |
| 573 | return $new_sent_folder; |
| 574 | } |
| 575 | |
| 576 | # List special folders first |
| 577 | sub command25 { |
| 578 | print "SquirrelMail has what we call 'special folders' that are not\n"; |
| 579 | print "manipulated and viewed like normal folders. Some examples of\n"; |
| 580 | print "these folders would be INBOX, Trash, Sent, etc. This option\n"; |
| 581 | print "Simply asks if you want these folders listed first in the folder\n"; |
| 582 | print "listing.\n"; |
| 583 | print "\n"; |
| 584 | |
| 585 | if ($list_special_folders_first eq "true") { |
| 586 | $default_value = "y"; |
| 587 | } else { |
| 588 | $default_value = "n"; |
| 589 | } |
| 590 | print "\n"; |
| 591 | print "List first (y/n) [$WHT$default_value$NRM]: $WHT"; |
| 592 | $new_show = <STDIN>; |
| 593 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
| 594 | $list_special_folders_first = "true"; |
| 595 | } else { |
| 596 | $list_special_folders_first = "false"; |
| 597 | } |
| 598 | return $list_special_folders_first; |
| 599 | } |
| 600 | |
| 601 | # Show special folders color |
| 602 | sub command26 { |
| 603 | print "SquirrelMail has what we call 'special folders' that are not\n"; |
| 604 | print "manipulated and viewed like normal folders. Some examples of\n"; |
| 605 | print "these folders would be INBOX, Trash, Sent, etc. This option\n"; |
| 606 | print "wants to know if we should display special folders in a\n"; |
| 607 | print "color than the other folders.\n"; |
| 608 | print "\n"; |
| 609 | |
| 610 | if ($use_special_folder_color eq "true") { |
| 611 | $default_value = "y"; |
| 612 | } else { |
| 613 | $default_value = "n"; |
| 614 | } |
| 615 | print "\n"; |
| 616 | print "Show color (y/n) [$WHT$default_value$NRM]: $WHT"; |
| 617 | $new_show = <STDIN>; |
| 618 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
| 619 | $use_special_folder_color = "true"; |
| 620 | } else { |
| 621 | $use_special_folder_color = "false"; |
| 622 | } |
| 623 | return $use_special_folder_color; |
| 624 | } |
| 625 | |
| 626 | # default move to trash |
| 627 | sub command27 { |
| 628 | print "By default, should messages get moved to the trash folder? You\n"; |
| 629 | print "can specify the default trash folder in option 3. If this is set\n"; |
| 630 | print "to false, messages will get deleted immediately without moving\n"; |
| 631 | print "to the trash folder.\n"; |
| 632 | print "\n"; |
| 633 | print "Trash folder is currently: $trash_folder\n"; |
| 634 | print "\n"; |
| 635 | |
| 636 | if ($default_move_to_trash eq "true") { |
| 637 | $default_value = "y"; |
| 638 | } else { |
| 639 | $default_value = "n"; |
| 640 | } |
| 641 | print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT"; |
| 642 | $new_show = <STDIN>; |
| 643 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
| 644 | $default_move_to_trash = "true"; |
| 645 | } else { |
| 646 | $default_move_to_trash = "false"; |
| 647 | } |
| 648 | return $default_move_to_trash; |
| 649 | } |
| 650 | |
| 651 | # Auto expunge |
| 652 | sub command28 { |
| 653 | print "The way that IMAP handles deleting messages is as follows. You\n"; |
| 654 | print "mark the message as deleted, and then to 'really' delete it, you\n"; |
| 655 | print "expunge it. This option asks if you want to just have messages\n"; |
| 656 | print "marked as deleted, or if you want SquirrelMail to expunge the \n"; |
| 657 | print "messages too.\n"; |
| 658 | print "\n"; |
| 659 | |
| 660 | if ($auto_expunge eq "true") { |
| 661 | $default_value = "y"; |
| 662 | } else { |
| 663 | $default_value = "n"; |
| 664 | } |
| 665 | print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT"; |
| 666 | $new_show = <STDIN>; |
| 667 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
| 668 | $auto_expunge = "true"; |
| 669 | } else { |
| 670 | $auto_expunge = "false"; |
| 671 | } |
| 672 | return $auto_expunge; |
| 673 | } |
| 674 | |
| 675 | # Default sub of inbox |
| 676 | sub command29 { |
| 677 | print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n"; |
| 678 | print "This can cause some confusion in folder creation for users when\n"; |
| 679 | print "they try to create folders and don't put it as a subfolder of INBOX\n"; |
| 680 | print "and get permission errors. This option asks if you want folders\n"; |
| 681 | print "to be subfolders of INBOX by default.\n"; |
| 682 | print "\n"; |
| 683 | |
| 684 | if ($default_sub_of_inbox eq "true") { |
| 685 | $default_value = "y"; |
| 686 | } else { |
| 687 | $default_value = "n"; |
| 688 | } |
| 689 | print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT"; |
| 690 | $new_show = <STDIN>; |
| 691 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
| 692 | $default_sub_of_inbox = "true"; |
| 693 | } else { |
| 694 | $default_sub_of_inbox = "false"; |
| 695 | } |
| 696 | return $default_sub_of_inbox; |
| 697 | } |
| 698 | |
| 699 | # Show contain subfolder option |
| 700 | sub command210 { |
| 701 | print "Some IMAP servers (UW) make it so that there are two types of\n"; |
| 702 | print "folders. Those that contain messages, and those that contain\n"; |
| 703 | print "subfolders. If this is the case for your server, set this to\n"; |
| 704 | print "true, and it will ask the user whether the folder they are\n"; |
| 705 | print "creating contains subfolders or messages.\n"; |
| 706 | print "\n"; |
| 707 | |
| 708 | if ($show_contain_subfolders_option eq "true") { |
| 709 | $default_value = "y"; |
| 710 | } else { |
| 711 | $default_value = "n"; |
| 712 | } |
| 713 | print "Show option (y/n) [$WHT$default_value$NRM]: $WHT"; |
| 714 | $new_show = <STDIN>; |
| 715 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
| 716 | $show_contain_subfolders_option = "true"; |
| 717 | } else { |
| 718 | $show_contain_subfolders_option = "false"; |
| 719 | } |
| 720 | return $show_contain_subfolders_option; |
| 721 | } |
| 722 | |
| 723 | ############# GENERAL OPTIONS ##################### |
| 724 | |
| 725 | # Default Charset |
| 726 | sub command31 { |
| 727 | print "This option controls what character set is used when sending\n"; |
| 728 | print "mail and when sending HTML to the browser. Do not set this\n"; |
| 729 | print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n"; |
| 730 | print "to use KOI8-R, since this implementation is faster than most\n"; |
| 731 | print "of the alternatives\n"; |
| 732 | print "\n"; |
| 733 | |
| 734 | print "[$WHT$default_charset$NRM]: $WHT"; |
| 735 | $new_default_charset = <STDIN>; |
| 736 | if ($new_default_charset eq "\n") { |
| 737 | $new_default_charset = $default_charset; |
| 738 | } else { |
| 739 | $new_default_charset =~ s/[\r|\n]//g; |
| 740 | } |
| 741 | return $new_default_charset; |
| 742 | } |
| 743 | |
| 744 | # Auto Forward |
| 745 | sub command32 { |
| 746 | print "There are some places that we will automatically forward the user\n"; |
| 747 | print "rather than display pointless messages like 'Message sent!' or\n"; |
| 748 | print "stuff like that. Use this or not?\n"; |
| 749 | print "\n"; |
| 750 | print "NOTE: This is not working currently as we are trying to find a\n"; |
| 751 | print " better way to handle this. This option really doesn't do\n"; |
| 752 | print " much.\n"; |
| 753 | print "\n"; |
| 754 | |
| 755 | if ($auto_forward eq "true") { |
| 756 | $default_value = "y"; |
| 757 | } else { |
| 758 | $default_value = "n"; |
| 759 | } |
| 760 | print "Auto forward (y/n) [$WHT$default_value$NRM]: $WHT"; |
| 761 | $new_show = <STDIN>; |
| 762 | if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { |
| 763 | $auto_forward = "true"; |
| 764 | } else { |
| 765 | $auto_forward = "false"; |
| 766 | } |
| 767 | return $auto_forward; |
| 768 | } |
| 769 | |
| 770 | # Data directory |
| 771 | sub command33 { |
| 772 | print "It is a possible security hole to have a writable directory\n"; |
| 773 | print "under the web server's root directory (ex: /home/httpd/html).\n"; |
| 774 | print "For this reason, it is possible to put the data directory\n"; |
| 775 | print "anywhere you would like. The path name can be absolute or\n"; |
| 776 | print "relative (to the config directory). It doesn't matter. Here\n"; |
| 777 | print "are two examples:\n"; |
| 778 | print " Absolute: /usr/local/squirrelmail/data/\n"; |
| 779 | print " Relative: ../data/\n"; |
| 780 | print "\n"; |
| 781 | |
| 782 | print "[$WHT$data_dir$NRM]: $WHT"; |
| 783 | $new_data_dir = <STDIN>; |
| 784 | if ($new_data_dir eq "\n") { |
| 785 | $new_data_dir = $data_dir; |
| 786 | } else { |
| 787 | $new_data_dir =~ s/[\r|\n]//g; |
| 788 | } |
| 789 | if ($new_data_dir =~ /^\s*$/) { |
| 790 | $new_data_dir = ""; |
| 791 | } else { |
| 792 | $new_data_dir =~ s/\/*$//g; |
| 793 | $new_data_dir =~ s/$/\//g; |
| 794 | } |
| 795 | return $new_data_dir; |
| 796 | } |
| 797 | |
| 798 | # Attachment directory |
| 799 | sub command34 { |
| 800 | print "Path to directory used for storing attachments while a mail is\n"; |
| 801 | print "being sent. There are a few security considerations regarding this\n"; |
| 802 | print "directory:\n"; |
| 803 | print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n"; |
| 804 | print " impossible for a random person with access to the webserver\n"; |
| 805 | print " to list files in this directory. Confidential data might\n"; |
| 806 | print " be laying around in there.\n"; |
| 807 | print " 2. Since the webserver is not able to list the files in the\n"; |
| 808 | print " content is also impossible for the webserver to delete files\n"; |
| 809 | print " lying around there for too long.\n"; |
| 810 | print " 3. It should probably be another directory than the data\n"; |
| 811 | print " directory specified in option 3.\n"; |
| 812 | print "\n"; |
| 813 | |
| 814 | print "[$WHT$attachment_dir$NRM]: $WHT"; |
| 815 | $new_attachment_dir = <STDIN>; |
| 816 | if ($new_attachment_dir eq "\n") { |
| 817 | $new_attachment_dir = $attachment_dir; |
| 818 | } else { |
| 819 | $new_attachment_dir =~ s/[\r|\n]//g; |
| 820 | } |
| 821 | if ($new_attachment_dir =~ /^\s*$/) { |
| 822 | $new_attachment_dir = ""; |
| 823 | } else { |
| 824 | $new_attachment_dir =~ s/\/*$//g; |
| 825 | $new_attachment_dir =~ s/$/\//g; |
| 826 | } |
| 827 | return $new_attachment_dir; |
| 828 | } |
| 829 | |
| 830 | |
| 831 | sub command35 { |
| 832 | print "This is the default size (in pixels) of the left folder list.\n"; |
| 833 | print "Default is 200, but you can set it to whatever you wish. This\n"; |
| 834 | print "is a user preference, so this will only show up as their default.\n"; |
| 835 | print "\n"; |
| 836 | print "[$WHT$default_left_size$NRM]: $WHT"; |
| 837 | $new_default_left_size = <STDIN>; |
| 838 | if ($new_default_left_size eq "\n") { |
| 839 | $new_default_left_size = $default_left_size; |
| 840 | } else { |
| 841 | $new_default_left_size =~ s/[\r|\n]//g; |
| 842 | } |
| 843 | return $new_default_left_size; |
| 844 | } |
| 845 | |
| 846 | |
| 847 | sub command41 { |
| 848 | print "\nNow we will define the themes that you wish to use. If you have added\n"; |
| 849 | print "a theme of your own, just follow the instructions (?) about how to add\n"; |
| 850 | print "them. You can also change the default theme.\n"; |
| 851 | print "[theme] command (?=help) > "; |
| 852 | $input = <STDIN>; |
| 853 | $input =~ s/[\r|\n]//g; |
| 854 | while ($input ne "d") { |
| 855 | if ($input =~ /^\s*l\s*/i) { |
| 856 | $count = 0; |
| 857 | while ($count <= $#theme_name) { |
| 858 | if ($count == $theme_default) { |
| 859 | print " *"; |
| 860 | } else { |
| 861 | print " "; |
| 862 | } |
| 863 | $name = $theme_name[$count]; |
| 864 | $num_spaces = 25 - length($name); |
| 865 | for ($i = 0; $i < $num_spaces;$i++) { |
| 866 | $name = $name . " "; |
| 867 | } |
| 868 | |
| 869 | print " $count. $name"; |
| 870 | print "($theme_path[$count])\n"; |
| 871 | |
| 872 | $count++; |
| 873 | } |
| 874 | } elsif ($input =~ /^\s*m\s*[0-9]+/i) { |
| 875 | $old_def = $theme_default; |
| 876 | $theme_default = $input; |
| 877 | $theme_default =~ s/^\s*m\s*//; |
| 878 | if (($theme_default > $#theme_name) || ($theme_default < 0)) { |
| 879 | print "Cannot set default theme to $theme_default. That theme does not exist.\n"; |
| 880 | $theme_default = $old_def; |
| 881 | } |
| 882 | } elsif ($input =~ /^\s*\+/) { |
| 883 | print "What is the name of this theme: "; |
| 884 | $name = <STDIN>; |
| 885 | $name =~ s/[\r|\n]//g; |
| 886 | $theme_name[$#theme_name+1] = $name; |
| 887 | print "Be sure to put ../config/ before the filename.\n"; |
| 888 | print "What file is this stored in (ex: ../config/default_theme.php): "; |
| 889 | $name = <STDIN>; |
| 890 | $name =~ s/[\r|\n]//g; |
| 891 | $theme_path[$#theme_path+1] = $name; |
| 892 | } elsif ($input =~ /^\s*-\s*[0-9]?/) { |
| 893 | if ($input =~ /[0-9]+\s*$/) { |
| 894 | $rem_num = $input; |
| 895 | $rem_num =~ s/^\s*-\s*//g; |
| 896 | $rem_num =~ s/\s*$//; |
| 897 | } else { |
| 898 | $rem_num = $#theme_name; |
| 899 | } |
| 900 | if ($rem_num == $theme_default) { |
| 901 | print "You cannot remove the default theme!\n"; |
| 902 | } else { |
| 903 | $count = 0; |
| 904 | @new_theme_name = (); |
| 905 | @new_theme_path = (); |
| 906 | while ($count <= $#theme_name) { |
| 907 | if ($count != $rem_num) { |
| 908 | @new_theme_name = (@new_theme_name, $theme_name[$count]); |
| 909 | @new_theme_path = (@new_theme_path, $theme_path[$count]); |
| 910 | } |
| 911 | $count++; |
| 912 | } |
| 913 | @theme_name = @new_theme_name; |
| 914 | @theme_path = @new_theme_path; |
| 915 | if ($theme_default > $rem_num) { |
| 916 | $theme_default--; |
| 917 | } |
| 918 | } |
| 919 | } elsif ($input =~ /^\s*\?\s*/) { |
| 920 | print ".-------------------------.\n"; |
| 921 | print "| + (add theme) |\n"; |
| 922 | print "| - N (remove theme) |\n"; |
| 923 | print "| m N (mark default) |\n"; |
| 924 | print "| l (list themes) |\n"; |
| 925 | print "| d (done) |\n"; |
| 926 | print "`-------------------------'\n"; |
| 927 | } |
| 928 | print "[theme] command (?=help) > "; |
| 929 | $input = <STDIN>; |
| 930 | $input =~ s/[\r|\n]//g; |
| 931 | } |
| 932 | } |
| 933 | |
| 934 | |
| 935 | sub command61 { |
| 936 | print "You can now define different LDAP servers.\n"; |
| 937 | print "[ldap] command (?=help) > "; |
| 938 | $input = <STDIN>; |
| 939 | $input =~ s/[\r|\n]//g; |
| 940 | while ($input ne "d") { |
| 941 | if ($input =~ /^\s*l\s*/i) { |
| 942 | $count = 0; |
| 943 | while ($count <= $#ldap_host) { |
| 944 | print "$count. $ldap_host[$count]\n"; |
| 945 | print " base: $ldap_base[$count]\n"; |
| 946 | if ($ldap_charset[$count]) { |
| 947 | print " charset: $ldap_charset[$count]\n"; |
| 948 | } |
| 949 | if ($ldap_port[$count]) { |
| 950 | print " port: $ldap_port[$count]\n"; |
| 951 | } |
| 952 | if ($ldap_name[$count]) { |
| 953 | print " name: $ldap_name[$count]\n"; |
| 954 | } |
| 955 | if ($ldap_maxrows[$count]) { |
| 956 | print " maxrows: $ldap_maxrows[$count]\n"; |
| 957 | } |
| 958 | print "\n"; |
| 959 | $count++; |
| 960 | } |
| 961 | } elsif ($input =~ /^\s*\+/) { |
| 962 | $sub = $#ldap_host + 1; |
| 963 | |
| 964 | print "First, we need to have the hostname or the IP address where\n"; |
| 965 | print "this LDAP server resides. Example: ldap.bigfoot.com\n"; |
| 966 | print "hostname: "; |
| 967 | $name = <STDIN>; |
| 968 | $name =~ s/[\r|\n]//g; |
| 969 | $ldap_host[$sub] = $name; |
| 970 | |
| 971 | print "\n"; |
| 972 | |
| 973 | print "Next, we need the server root (base dn). For this, an empty\n"; |
| 974 | print "string is allowed.\n"; |
| 975 | print "Example: ou=member_directory,o=netcenter.com\n"; |
| 976 | print "base: "; |
| 977 | $name = <STDIN>; |
| 978 | $name =~ s/[\r|\n]//g; |
| 979 | $ldap_base[$sub] = $name; |
| 980 | |
| 981 | print "\n"; |
| 982 | |
| 983 | print "This is the TCP/IP port number for the LDAP server. Default\n"; |
| 984 | print "port is 389. This is optional. Press ENTER for default.\n"; |
| 985 | print "port: "; |
| 986 | $name = <STDIN>; |
| 987 | $name =~ s/[\r|\n]//g; |
| 988 | $ldap_port[$sub] = $name; |
| 989 | |
| 990 | print "\n"; |
| 991 | |
| 992 | print "This is the charset for the server. Default is utf-8. This\n"; |
| 993 | print "is also optional. Press ENTER for default.\n"; |
| 994 | print "charset: "; |
| 995 | $name = <STDIN>; |
| 996 | $name =~ s/[\r|\n]//g; |
| 997 | $ldap_charset[$sub] = $name; |
| 998 | |
| 999 | print "\n"; |
| 1000 | |
| 1001 | print "This is the name for the server, used to tag the results of\n"; |
| 1002 | print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n"; |
| 1003 | print "name: "; |
| 1004 | $name = <STDIN>; |
| 1005 | $name =~ s/[\r|\n]//g; |
| 1006 | $ldap_name[$sub] = $name; |
| 1007 | |
| 1008 | print "\n"; |
| 1009 | |
| 1010 | print "You can specify the maximum number of rows in the search result.\n"; |
| 1011 | print "Default is unlimited. Press ENTER for default.\n"; |
| 1012 | print "maxrows: "; |
| 1013 | $name = <STDIN>; |
| 1014 | $name =~ s/[\r|\n]//g; |
| 1015 | $ldap_maxrows[$sub] = $name; |
| 1016 | |
| 1017 | print "\n"; |
| 1018 | |
| 1019 | } elsif ($input =~ /^\s*-\s*[0-9]?/) { |
| 1020 | if ($input =~ /[0-9]+\s*$/) { |
| 1021 | $rem_num = $input; |
| 1022 | $rem_num =~ s/^\s*-\s*//g; |
| 1023 | $rem_num =~ s/\s*$//; |
| 1024 | } else { |
| 1025 | $rem_num = $#ldap_host; |
| 1026 | } |
| 1027 | $count = 0; |
| 1028 | @new_ldap_host = (); |
| 1029 | @new_ldap_base = (); |
| 1030 | @new_ldap_port = (); |
| 1031 | @new_ldap_name = (); |
| 1032 | @new_ldap_charset = (); |
| 1033 | @new_ldap_maxrows = (); |
| 1034 | while ($count <= $#ldap_host) { |
| 1035 | if ($count != $rem_num) { |
| 1036 | @new_ldap_host = (@new_ldap_host, $ldap_host[$count]); |
| 1037 | @new_ldap_base = (@new_ldap_base, $ldap_base[$count]); |
| 1038 | @new_ldap_port = (@new_ldap_port, $ldap_port[$count]); |
| 1039 | @new_ldap_name = (@new_ldap_name, $ldap_name[$count]); |
| 1040 | @new_ldap_charset = (@new_ldap_charset, $ldap_charset[$count]); |
| 1041 | @new_ldap_maxrows = (@new_ldap_maxrows, $ldap_maxrows[$count]); |
| 1042 | } |
| 1043 | $count++; |
| 1044 | } |
| 1045 | @ldap_host = @new_ldap_host; |
| 1046 | @ldap_base = @new_ldap_base; |
| 1047 | @ldap_port = @new_ldap_port; |
| 1048 | @ldap_name = @new_ldap_name; |
| 1049 | @ldap_charset = @new_ldap_charset; |
| 1050 | @ldap_maxrows = @new_ldap_maxrows; |
| 1051 | } elsif ($input =~ /^\s*\?\s*/) { |
| 1052 | print ".-------------------------.\n"; |
| 1053 | print "| + (add host) |\n"; |
| 1054 | print "| - N (remove host) |\n"; |
| 1055 | print "| l (list hosts) |\n"; |
| 1056 | print "| d (done) |\n"; |
| 1057 | print "`-------------------------'\n"; |
| 1058 | } |
| 1059 | print "[ldap] command (?=help) > "; |
| 1060 | $input = <STDIN>; |
| 1061 | $input =~ s/[\r|\n]//g; |
| 1062 | } |
| 1063 | } |
| 1064 | |
| 1065 | |
| 1066 | |
| 1067 | sub save_data { |
| 1068 | open (FILE, ">config.php"); |
| 1069 | |
| 1070 | print FILE "<?\n\t/** SquirrelMail configuration\n"; |
| 1071 | print FILE "\t ** Created using the configure script, conf.pl\n\t **/\n\n"; |
| 1072 | |
| 1073 | print FILE "\t\$org_name = \"$org_name\";\n"; |
| 1074 | print FILE "\t\$org_logo = \"$org_logo\";\n"; |
| 1075 | print FILE "\t\$org_title = \"$org_title\";\n"; |
| 1076 | |
| 1077 | print FILE "\n"; |
| 1078 | |
| 1079 | print FILE "\t\$domain = \"$domain\";\n"; |
| 1080 | print FILE "\t\$imapServerAddress = \"$imapServerAddress\";\n"; |
| 1081 | print FILE "\t\$imapPort = $imapPort;\n"; |
| 1082 | print FILE "\t\$useSendmail = $useSendmail;\n"; |
| 1083 | print FILE "\t\$smtpServerAddress = \"$smtpServerAddress\";\n"; |
| 1084 | print FILE "\t\$smtpPort = $smtpPort;\n"; |
| 1085 | print FILE "\t\$sendmailPath = \"$sendmail_path\";\n"; |
| 1086 | print FILE "\t\$imap_server_type = \"$imap_server_type\";\n"; |
| 1087 | |
| 1088 | print FILE "\n"; |
| 1089 | |
| 1090 | print FILE "\t\$default_folder_prefix = \"$default_folder_prefix\";\n"; |
| 1091 | print FILE "\t\$trash_folder = \"$trash_folder\";\n"; |
| 1092 | print FILE "\t\$sent_folder = \"$sent_folder\";\n"; |
| 1093 | print FILE "\t\$show_prefix_option = $show_prefix_option;\n"; |
| 1094 | print FILE "\t\$list_special_folders_first = $list_special_folders_first;\n"; |
| 1095 | print FILE "\t\$use_special_folder_color = $use_special_folder_color;\n"; |
| 1096 | print FILE "\t\$default_move_to_trash = $default_move_to_trash;\n"; |
| 1097 | print FILE "\t\$auto_expunge = $auto_expunge;\n"; |
| 1098 | print FILE "\t\$default_sub_of_inbox = $default_sub_of_inbox;\n"; |
| 1099 | print FILE "\t\$show_contain_subfolders_option = $show_contain_subfolders_option;\n"; |
| 1100 | print FILE "\n"; |
| 1101 | |
| 1102 | print FILE "\t\$default_charset = \"$default_charset\";\n"; |
| 1103 | print FILE "\t\$auto_forward = $auto_forward;\n"; |
| 1104 | print FILE "\t\$data_dir = \"$data_dir\";\n"; |
| 1105 | print FILE "\t\$attachment_dir = \"$attachment_dir\";\n"; |
| 1106 | print FILE "\t\$default_left_size = $default_left_size;\n"; |
| 1107 | |
| 1108 | print FILE "\n"; |
| 1109 | |
| 1110 | for ($count=0; $count <= $#theme_name; $count++) { |
| 1111 | print FILE "\t\$theme[$count][\"PATH\"] = \"$theme_path[$count]\";\n"; |
| 1112 | print FILE "\t\$theme[$count][\"NAME\"] = \"$theme_name[$count]\";\n"; |
| 1113 | } |
| 1114 | |
| 1115 | print FILE "\n"; |
| 1116 | |
| 1117 | for ($count=0; $count <= $#ldap_host; $count++) { |
| 1118 | print FILE "\t\$ldap_server[$count] = Array(\n"; |
| 1119 | print FILE "\t\t\t\"host\" => \"$ldap_host[$count]\",\n"; |
| 1120 | print FILE "\t\t\t\"base\" => \"$ldap_base[$count]\""; |
| 1121 | if ($ldap_name[$count]) { |
| 1122 | print FILE ",\n\t\t\t\"name\" => \"$ldap_name[$count]\""; |
| 1123 | } |
| 1124 | if ($ldap_port[$count]) { |
| 1125 | print FILE ",\n\t\t\t\"port\" => \"$ldap_port[$count]\""; |
| 1126 | } |
| 1127 | if ($ldap_charset[$count]) { |
| 1128 | print FILE ",\n\t\t\t\"charset\" => \"$ldap_charset[$count]\""; |
| 1129 | } |
| 1130 | if ($ldap_maxrows[$count]) { |
| 1131 | print FILE ",\n\t\t\t\"maxrows\" => \"$ldap_maxrows[$count]\""; |
| 1132 | } |
| 1133 | print FILE ");\n\n"; |
| 1134 | } |
| 1135 | |
| 1136 | print FILE "\t\$motd = \"$motd\";\n"; |
| 1137 | |
| 1138 | print FILE "?>\n"; |
| 1139 | close FILE; |
| 1140 | } |
| 1141 | |
| 1142 | sub set_defaults { |
| 1143 | system "clear"; |
| 1144 | print "While we have been building SquirrelMail, we have discovered some\n"; |
| 1145 | print "preferences that work better with some servers that don't work so\n"; |
| 1146 | print "well with others. If you select your IMAP server, this option will\n"; |
| 1147 | print "set some pre-defined settings for that server.\n"; |
| 1148 | print "\n"; |
| 1149 | print "Please note that you will still need to go through and make sure\n"; |
| 1150 | print "everything is correct. This does not change everything. There are\n"; |
| 1151 | print "only a few settings that thils will change.\n"; |
| 1152 | print "\n"; |
| 1153 | |
| 1154 | $continue = 0; |
| 1155 | while ($continue != 1) { |
| 1156 | print "Please select your IMAP server:\n"; |
| 1157 | print " cyrus = Cyrus IMAP server\n"; |
| 1158 | print " uw = University of Washington's IMAP server\n"; |
| 1159 | print " exchange = Microsoft Exchange IMAP server\n"; |
| 1160 | print " courier = Courier IMAP server\n"; |
| 1161 | print " quit = Do not change anything\n"; |
| 1162 | print "Command >> "; |
| 1163 | $server = <STDIN>; |
| 1164 | $server =~ s/[\r|\n]//g; |
| 1165 | |
| 1166 | if ($server eq "cyrus") { |
| 1167 | $default_folder_prefix = ""; |
| 1168 | $trash_folder = "INBOX.Trash"; |
| 1169 | $sent_folder = "INBOX.Sent"; |
| 1170 | $show_prefix_option = false; |
| 1171 | $default_sub_of_inbox = true; |
| 1172 | $show_contain_subfolders_option = false; |
| 1173 | $imap_server_type = "cyrus"; |
| 1174 | |
| 1175 | $continue = 1; |
| 1176 | } elsif ($server eq "uw") { |
| 1177 | $default_folder_prefix = "mail/"; |
| 1178 | $trash_folder = "Trash"; |
| 1179 | $sent_folder = "Sent"; |
| 1180 | $show_prefix_option = true; |
| 1181 | $default_sub_of_inbox = false; |
| 1182 | $show_contain_subfolders_option = true; |
| 1183 | $imap_server_type = "uw"; |
| 1184 | |
| 1185 | $continue = 1; |
| 1186 | } elsif ($server eq "exchange") { |
| 1187 | $default_folder_prefix = "INBOX/"; |
| 1188 | $default_sub_of_inbox = true; |
| 1189 | $trash_folder = "INBOX/Deleted Items"; |
| 1190 | $sent_folder = "INBOX/Sent Items"; |
| 1191 | $show_prefix_option = false; |
| 1192 | $show_contain_subfolders_option = false; |
| 1193 | |
| 1194 | $imap_server_type = "exchange"; |
| 1195 | |
| 1196 | $continue = 1; |
| 1197 | } elsif ($server eq "courier") { |
| 1198 | $imap_server_type = "courier"; |
| 1199 | |
| 1200 | $continue = 1; |
| 1201 | } elsif ($server eq "quit") { |
| 1202 | $continue = 1; |
| 1203 | } else { |
| 1204 | print "Unrecognized server: $server\n"; |
| 1205 | print "\n"; |
| 1206 | } |
| 1207 | } |
| 1208 | } |