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