Sharedwww / cgi-bin / openwebmail / openwebmail-prefs.plOpen in CoCalc
Author: William A. Stein
1
#!/usr/bin/perl
2
#
3
# openwebmail-prefs.pl - preference configuration, book editing program
4
#
5
6
use vars qw($SCRIPT_DIR);
7
if ( $0 =~ m!^(\S*)/[\w\d\-\.]+\.pl! ) { $SCRIPT_DIR=$1 }
8
if ($SCRIPT_DIR eq '' && open(F, '/etc/openwebmail/openwebmail_path.conf')) {
9
$_=<F>; close(F); if ( $_=~/^(\S*)/) { $SCRIPT_DIR=$1 }
10
}
11
if ($SCRIPT_DIR eq '') { print "Content-type: text/html\n\nSCRIPT_DIR not set in /etc/openwebmail/openwebmail_path.conf !\n"; exit 0; }
12
push (@INC, $SCRIPT_DIR);
13
14
foreach (qw(ENV BASH_ENV CDPATH IFS TERM)) {delete $ENV{$_}}; $ENV{PATH}='/bin:/usr/bin'; # secure ENV
15
umask(0002); # make sure the openwebmail group can write
16
17
use strict;
18
use Fcntl qw(:DEFAULT :flock);
19
use CGI qw(-private_tempfiles :standard);
20
use CGI::Carp qw(fatalsToBrowser carpout);
21
22
require "modules/dbm.pl";
23
require "modules/suid.pl";
24
require "modules/filelock.pl";
25
require "modules/tool.pl";
26
require "modules/datetime.pl";
27
require "modules/lang.pl";
28
require "modules/mime.pl";
29
require "modules/htmltext.pl";
30
require "auth/auth.pl";
31
require "quota/quota.pl";
32
require "shares/ow-shared.pl";
33
require "shares/iconv.pl";
34
require "shares/pop3book.pl";
35
36
# common globals
37
use vars qw(%config %config_raw);
38
use vars qw($thissession);
39
use vars qw($loginname $logindomain $loginuser);
40
use vars qw($domain $user $userrealname $uuid $ugid $homedir);
41
use vars qw(%prefs %style %icontext);
42
use vars qw($quotausage $quotalimit);
43
44
# extern vars
45
use vars qw($persistence_count);
46
use vars qw(@openwebmailrcitem); # defined in ow-shared.pl
47
use vars qw(%lang_folders %lang_sizes %lang_text %lang_err
48
%lang_calendar %lang_onofflabels %lang_sortlabels
49
%lang_disableemblinklabels %lang_msgformatlabels
50
%lang_withoriglabels %lang_receiptlabels
51
%lang_ctrlpositionlabels %lang_sendpositionlabels
52
%lang_checksourcelabels
53
%lang_abookbuttonpositionlabels
54
%lang_timelabels %lang_wday); # defined in lang/xy
55
use vars qw(%charset_convlist); # defined in iconv.pl
56
use vars qw(%fontsize); # defined in ow-shared.pl
57
58
# local globals
59
use vars qw($folder $messageid);
60
use vars qw($sort $page);
61
use vars qw($userfirsttime $prefs_caller);
62
use vars qw($urlparmstr $formparmstr);
63
use vars qw($escapedfolder $escapedmessageid);
64
65
# const globals
66
use vars qw(%op_order %ruletype_order %folder_order); # filterrule prefered order, the smaller one is prefered
67
%op_order=(
68
copy => 0,
69
move => 1,
70
delete => 2,
71
);
72
%ruletype_order=(
73
from => 0,
74
to => 1,
75
subject => 2,
76
header => 3,
77
smtprelay => 4,
78
attfilename => 5,
79
textcontent => 6
80
);
81
%folder_order=( # folders not listed have order 0
82
INBOX => -1,
83
DELETE => 1,
84
'virus-mail' => 2,
85
'spam-mail' => 3,
86
'mail-trash' => 4
87
);
88
89
########## MAIN ##################################################
90
openwebmail_requestbegin();
91
$SIG{PIPE}=\&openwebmail_exit; # for user stop
92
$SIG{TERM}=\&openwebmail_exit; # for user stop
93
$SIG{CHLD}='IGNORE'; # prevent zombie
94
95
userenv_init();
96
97
$folder = param('folder') || 'INBOX';
98
$messageid=param('message_id') || '';
99
$page = param('page') || 1;
100
$sort = param('sort') || $prefs{'sort'} || 'date';
101
$userfirsttime = param('userfirsttime')||0;
102
103
$prefs_caller = param('prefs_caller')||''; # passed from the caller
104
$prefs_caller='main' if ($prefs_caller eq '' && $config{'enable_webmail'});
105
$prefs_caller='cal' if ($prefs_caller eq '' && $config{'enable_calendar'});
106
$prefs_caller='webdisk' if ($prefs_caller eq '' && $config{'enable_webdisk'});
107
108
$escapedfolder=ow::tool::escapeURL($folder);
109
$escapedmessageid=ow::tool::escapeURL($messageid);
110
111
$urlparmstr=qq|&amp;sessionid=$thissession&amp;folder=$escapedfolder&amp;message_id=$escapedmessageid&amp;sort=$sort&amp;page=$page&amp;userfirsttime=$userfirsttime&amp;prefs_caller=$prefs_caller|;
112
$formparmstr=ow::tool::hiddens(sessionid=>$thissession,
113
folder=>$folder,
114
message_id=>$messageid,
115
sort=>$sort,
116
page=>$page,
117
userfirsttime=>$userfirsttime,
118
prefs_caller=>$prefs_caller);
119
120
my $action = param('action')||'';
121
if ($action eq "about" && $config{'enable_about'}) {
122
about();
123
} elsif ($action eq "userfirsttime") {
124
userfirsttime();
125
} elsif ($action eq "timeoutwarning") {
126
timeoutwarning();
127
} elsif ($action eq "editprefs" && $config{'enable_preference'}) {
128
editprefs();
129
} elsif ($action eq "saveprefs" && $config{'enable_preference'}) {
130
saveprefs();
131
} elsif ($action eq "editpassword" && $config{'enable_changepwd'}) {
132
editpassword();
133
} elsif ($action eq "changepassword" && $config{'enable_changepwd'}) {
134
changepassword();
135
} elsif ($action eq "viewhistory" && $config{'enable_history'}) {
136
viewhistory();
137
} elsif ($config{'enable_webmail'}) {
138
if ($action eq "editfroms" && $config{'enable_editfrombook'}) {
139
editfroms();
140
} elsif ($action eq "addfrom" && $config{'enable_editfrombook'}) {
141
modfrom("add");
142
} elsif ($action eq "deletefrom" && $config{'enable_editfrombook'}) {
143
modfrom("delete");
144
} elsif ($action eq "editpop3" && $config{'enable_pop3'}) {
145
editpop3();
146
} elsif ($action eq "addpop3" && $config{'enable_pop3'}) {
147
modpop3("add");
148
} elsif ($action eq "deletepop3" && $config{'enable_pop3'}) {
149
modpop3("delete");
150
} elsif ($action eq "editfilter" && $config{'enable_userfilter'}) {
151
editfilter();
152
} elsif ($action eq "addfilter" && $config{'enable_userfilter'}) {
153
modfilter("add");
154
} elsif ($action eq "deletefilter" && $config{'enable_userfilter'}) {
155
modfilter("delete");
156
} elsif (param('delstatbutton') && $config{'enable_stationery'}) {
157
delstat();
158
} elsif ((param('editstatbutton')||$action eq "editstat") && $config{'enable_stationery'}) {
159
editstat();
160
} elsif ($action eq "clearstat" && $config{'enable_stationery'}) {
161
clearstat();
162
} elsif ($action eq "addstat" && $config{'enable_stationery'}) {
163
addstat();
164
} else {
165
openwebmailerror(__FILE__, __LINE__, "Action $lang_err{'has_illegal_chars'}");
166
}
167
} else {
168
openwebmailerror(__FILE__, __LINE__, "Action $lang_err{'has_illegal_chars'}");
169
}
170
171
openwebmail_requestend();
172
########## END MAIN ##############################################
173
174
########## ABOUT #################################################
175
sub about {
176
my ($html, $temphtml);
177
$html = applystyle(readtemplate("about.template"));
178
179
$temphtml = iconlink("backtofolder.gif", "$lang_text{'backto'} $lang_text{'userprefs'}", qq|accesskey="F" href="$config{'ow_cgiurl'}/openwebmail-prefs.pl?action=editprefs&amp;$urlparmstr"|);
180
$html =~ s/\@\@\@MENUBARLINKS\@\@\@/$temphtml/;
181
182
if ($config{'about_info_software'}) {
183
templateblock_enable($html, 'INFOSOFTWARE');
184
my $os=`/bin/uname -srm`; $os=`/usr/bin/uname -srm` if ( -f "/usr/bin/uname");
185
my $flag; $flag.='Persistence' if ($persistence_count>0);
186
if (is_http_compression_enabled()) {
187
$flag.=', ' if ($flag ne '');
188
$flag.='HTTP Compression';
189
}
190
$flag="( $flag )" if ($flag);
191
$temphtml = attr_html('OS' , $os).
192
attr_html('PERL' , "$^X $]").
193
attr_html('WebMail', "$config{'name'} $config{'version'} $config{'releasedate'} $flag");
194
$html=~s/\@\@\@INFOSOFTWARE\@\@\@/$temphtml/;
195
} else {
196
templateblock_disable($html, 'INFOSOFTWARE');
197
}
198
199
if ($config{'about_info_protocol'}) {
200
templateblock_enable($html, 'INFOPROTOCOL');
201
$temphtml = '';
202
foreach my $attr ( qw(SERVER_PROTOCOL HTTP_CONNECTION HTTP_KEEP_ALIVE) ) {
203
$temphtml.= attr_html($attr, $ENV{$attr}) if (defined($ENV{$attr}));
204
}
205
$html=~s/\@\@\@INFOPROTOCOL\@\@\@/$temphtml/;
206
} else {
207
templateblock_disable($html, 'INFOPROTOCOL');
208
}
209
210
if ($config{'about_info_server'}) {
211
templateblock_enable($html, 'INFOSERVER');
212
$temphtml = '';
213
foreach my $attr ( qw(HTTP_HOST SCRIPT_NAME) ) {
214
$temphtml.= attr_html($attr, $ENV{$attr}) if (defined($ENV{$attr}));
215
}
216
if ($config{'about_info_scriptfilename'}) {
217
$temphtml.= attr_html('SCRIPT_FILENAME', $ENV{'SCRIPT_FILENAME'}) if (defined($ENV{'SCRIPT_FILENAME'}));
218
}
219
foreach my $attr ( qw(SERVER_NAME SERVER_ADDR SERVER_PORT SERVER_SOFTWARE) ) {
220
$temphtml.= attr_html($attr, $ENV{$attr}) if (defined($ENV{$attr}));
221
}
222
$html=~s/\@\@\@INFOSERVER\@\@\@/$temphtml/;
223
} else {
224
templateblock_disable($html, 'INFOSERVER');
225
}
226
227
if ($config{'about_info_client'}) {
228
templateblock_enable($html, 'INFOCLIENT');
229
$temphtml = '';
230
foreach my $attr ( qw(REMOTE_ADDR REMOTE_PORT HTTP_CLIENT_IP
231
HTTP_X_FORWARDED_FOR HTTP_VIA
232
HTTP_USER_AGENT HTTP_ACCEPT_ENCODING HTTP_ACCEPT_LANGUAGE) ) {
233
$temphtml.= attr_html($attr, $ENV{$attr}) if (defined($ENV{$attr}));
234
}
235
$html=~s/\@\@\@INFOCLIENT\@\@\@/$temphtml/;
236
} else {
237
templateblock_disable($html, 'INFOCLIENT');
238
}
239
240
httpprint([], [htmlheader(), $html, htmlfooter(1)]);
241
}
242
243
sub attr_html {
244
my $temphtml = qq|<tr>|.
245
qq|<td bgcolor=$style{'window_dark'}>$_[0]</td>|.
246
qq|<td bgcolor=$style{'window_dark'}>$_[1]</td>|.
247
qq|</tr>\n|;
248
return($temphtml);
249
}
250
########## END ABOUT #############################################
251
252
########## FIRSTTIMEUSER #########################################
253
sub userfirsttime {
254
my ($html, $temphtml);
255
$html = applystyle(readtemplate("userfirsttime.template"));
256
257
$temphtml = startform(-action=>"$config{'ow_cgiurl'}/openwebmail-prefs.pl").
258
ow::tool::hiddens(action=>'editprefs',
259
sessionid=>$thissession,
260
userfirsttime=>'1').
261
submit("$lang_text{'continue'}").
262
end_form();
263
$html =~ s/\@\@\@CONTINUEBUTTON\@\@\@/$temphtml/;
264
265
httpprint([], [htmlheader(), $html, htmlfooter(2)]);
266
}
267
########## END FIRSTTIMEUSER #####################################
268
269
########## EDITPREFS #############################################
270
sub editprefs {
271
if (param('language') =~ /^([\d\w\.\-_]+)$/ ) {
272
my $language=$1;
273
if ( -f "$config{'ow_langdir'}/$language" ) {
274
$prefs{'language'}=$language;
275
$prefs{'charset'}=$ow::lang::languagecharsets{$language};
276
loadlang($language);
277
}
278
}
279
280
my ($html, $temphtml);
281
$html = applystyle(readtemplate("prefs.template"));
282
283
if ($userfirsttime) { # simple prefs menu, most items become hidden
284
templateblock_disable($html, 'FULLPREFS');
285
$html =~ s/\@\@\@DESCWIDTH\@\@\@/width="40%"/;
286
287
my (%is_firsttimercitem, %hiddenvalue);
288
foreach (qw(language charset timeoffset daylightsaving email replyto signature)) { $is_firsttimercitem{$_}=1 }
289
foreach (@openwebmailrcitem) {
290
next if ($is_firsttimercitem{$_});
291
if ($_ eq 'bgurl') {
292
my ($background, $bgurl)=($prefs{'bgurl'}, '');
293
if ($background !~ s!$config{'ow_htmlurl'}/images/backgrounds/!!) {
294
($background, $bgurl)=('USERDEFINE', $prefs{'bgurl'});
295
}
296
@hiddenvalue{'background', 'bgurl'}=($background, $bgurl);
297
} else {
298
$hiddenvalue{$_}=$prefs{$_};
299
}
300
}
301
$temphtml = start_form(-action=>"$config{'ow_cgiurl'}/openwebmail-prefs.pl",
302
-name=>'prefsform').
303
ow::tool::hiddens(action=>'saveprefs').
304
ow::tool::hiddens(%hiddenvalue).
305
$formparmstr;
306
307
} else { # full prefs menu
308
templateblock_enable($html, 'FULLPREFS');
309
$html =~ s/\@\@\@DESCWIDTH\@\@\@//;
310
311
$temphtml = start_form(-action=>"$config{'ow_cgiurl'}/openwebmail-prefs.pl",
312
-name=>'prefsform').
313
ow::tool::hiddens(action=>'saveprefs').
314
$formparmstr;
315
}
316
$html =~ s/\@\@\@STARTPREFSFORM\@\@\@/$temphtml/;
317
318
if ($config{'quota_module'} ne "none") {
319
$temphtml='';
320
my $overthreshold=($quotalimit>0 && $quotausage/$quotalimit>$config{'quota_threshold'}/100);
321
if ($config{'quota_threshold'}==0 || $overthreshold) {
322
$temphtml = "$lang_text{'quotausage'}: ".lenstr($quotausage*1024,1);
323
}
324
if ($overthreshold) {
325
$temphtml.=" (".(int($quotausage*1000/$quotalimit)/10)."%) ";
326
}
327
} else {
328
$temphtml="&nbsp;";
329
}
330
$html =~ s/\@\@\@QUOTAUSAGE\@\@\@/$temphtml/;
331
332
my %userfrom=get_userfrom($logindomain, $loginuser, $user, $userrealname, dotpath('from.book'));
333
334
if ($userfrom{$prefs{'email'}}) {
335
$temphtml = $userfrom{$prefs{'email'}};
336
} else {
337
$temphtml = "&nbsp;";
338
}
339
$html =~ s/\@\@\@REALNAME\@\@\@/$temphtml/;
340
341
$temphtml = '';
342
if (!$userfirsttime) {
343
if ($prefs_caller eq "cal") {
344
$temphtml .= iconlink("backtofolder.gif", "$lang_text{'backto'} $lang_text{'calendar'}", qq|accesskey="B" href="$config{'ow_cgiurl'}/openwebmail-cal.pl?action=$prefs{'calendar_defaultview'}&amp;$urlparmstr"|);
345
} elsif ($prefs_caller eq "webdisk") {
346
$temphtml .= iconlink("backtofolder.gif", "$lang_text{'backto'} $lang_text{'webdisk'}", qq|accesskey="B" href="$config{'ow_cgiurl'}/openwebmail-webdisk.pl?action=showdir&amp;$urlparmstr"|);
347
} elsif ($prefs_caller eq "read") {
348
$temphtml .= iconlink("backtofolder.gif", "$lang_text{'backto'} ".($lang_folders{$folder}||$folder), qq|accesskey="B" href="$config{'ow_cgiurl'}/openwebmail-read.pl?action=readmessage&amp;$urlparmstr"|);
349
} else {
350
$temphtml .= iconlink("backtofolder.gif", "$lang_text{'backto'} ".($lang_folders{$folder}||$folder), qq|accesskey="B" href="$config{'ow_cgiurl'}/openwebmail-main.pl?action=listmessages&amp;$urlparmstr"|);
351
}
352
$temphtml .= qq|&nbsp;\n|;
353
354
if ($config{'enable_webmail'}) {
355
if ($config{'enable_editfrombook'}) {
356
$temphtml .= iconlink("editfroms.gif", $lang_text{'editfroms'}, qq|accesskey="F" href="$config{'ow_cgiurl'}/openwebmail-prefs.pl?action=editfroms&amp;$urlparmstr"|);
357
}
358
if ($config{'enable_stationery'}) {
359
$temphtml .= iconlink("editst.gif", $lang_text{'editstat'}, qq|accesskey="S" href="$config{'ow_cgiurl'}/openwebmail-prefs.pl?action=editstat&amp;$urlparmstr"|);
360
}
361
if ($config{'enable_pop3'}) {
362
$temphtml .= iconlink("pop3setup.gif", $lang_text{'pop3book'}, qq|accesskey="G" href="$config{'ow_cgiurl'}/openwebmail-prefs.pl?action=editpop3&amp;$urlparmstr"|);
363
}
364
}
365
$temphtml .= qq|&nbsp;\n|;
366
367
if ( $config{'enable_changepwd'}) {
368
$temphtml .= iconlink("chpwd.gif", $lang_text{'changepwd'}, qq|accesskey="P" href="$config{'ow_cgiurl'}/openwebmail-prefs.pl?action=editpassword&amp;$urlparmstr"|);
369
}
370
if ( $config{'enable_vdomain'} ) {
371
if (is_vdomain_adm($user)) {
372
$temphtml .= iconlink("vdusers.gif", $lang_text{'vdomain_usermgr'}, qq|accesskey="P" href="$config{'ow_cgiurl'}/openwebmail-vdomain.pl?action=display_vuserlist&amp;$urlparmstr"|);
373
}
374
}
375
if ($config{'enable_history'}) {
376
$temphtml .= iconlink("history.gif", $lang_text{'viewhistory'}, qq|accesskey="V" href="$config{'ow_cgiurl'}/openwebmail-prefs.pl?action=viewhistory&amp;$urlparmstr"|);
377
}
378
}
379
380
if ($config{'enable_about'}) {
381
$temphtml .= iconlink("info.gif", $lang_text{'about'}, qq|accesskey="I" href="$config{'ow_cgiurl'}/openwebmail-prefs.pl?action=about&amp;$urlparmstr"|);
382
}
383
$html =~ s/\@\@\@MENUBARLINKS\@\@\@/$temphtml/;
384
385
386
my $defaultlanguage=$prefs{'language'};
387
my $defaultcharset=$prefs{'charset'}||$ow::lang::languagecharsets{$prefs{'language'}};
388
my $defaultsendcharset=$prefs{'sendcharset'}||'sameascomposing';
389
if (param('language') =~ /^([\d\w\.\-_]+)$/ ) {
390
$defaultlanguage=$1;
391
$defaultcharset=$ow::lang::languagecharsets{$1};
392
if ($defaultlanguage =~ /^ja_JP/ ) {
393
$defaultsendcharset='iso-2022-jp';
394
} else {
395
$defaultsendcharset='sameascomposing';
396
}
397
}
398
399
my @availablelanguages = sort {
400
$ow::lang::languagenames{$a} cmp $ow::lang::languagenames{$b}
401
} keys(%ow::lang::languagenames);
402
$temphtml = popup_menu(-name=>'language',
403
-values=>\@availablelanguages,
404
-default=>$defaultlanguage,
405
-labels=>\%ow::lang::languagenames,
406
-onChange=>"javascript:if (this.value != null) { window.location.href='$config{'ow_cgiurl'}/openwebmail-prefs.pl?action=editprefs&amp;$urlparmstr&amp;language='+this.value; }",
407
-accesskey=>'1',
408
-override=>'1',
409
defined($config_raw{'DEFAULT_language'})?('-disabled'=>'1'):());
410
$html =~ s/\@\@\@LANGUAGEMENU\@\@\@/$temphtml/;
411
412
my %tmpset=reverse %ow::lang::languagecharsets;
413
my @charset=sort keys %tmpset;
414
$temphtml = popup_menu(-name=>'charset',
415
-values=>\@charset,
416
-default=>$defaultcharset,
417
-override=>'1');
418
$html =~ s/\@\@\@CHARSETMENU\@\@\@/$temphtml/;
419
420
my @timeoffsets=qw( -1200 -1100 -1000 -0900 -0800 -0700
421
-0600 -0500 -0400 -0330 -0300 -0230 -0200 -0100
422
+0000 +0100 +0200 +0300 +0330 +0400 +0500 +0530 +0600 +0630
423
+0700 +0800 +0900 +0930 +1000 +1030 +1100 +1200 +1300 );
424
$temphtml = popup_menu(-name=>'timeoffset',
425
-values=>\@timeoffsets,
426
-default=>$prefs{'timeoffset'},
427
-override=>'1',
428
defined($config_raw{'DEFAULT_timeoffset'})?('-disabled'=>'1'):()).
429
qq|&nbsp;|. iconlink("earth.gif", $lang_text{'tzmap'}, qq|href="$config{'ow_htmlurl'}/images/timezone.jpg" target="_timezonemap"|). qq|\n|;
430
$html =~ s/\@\@\@TIMEOFFSETMENU\@\@\@/$temphtml/;
431
432
$temphtml = popup_menu(-name=>'daylightsaving',
433
-values=>[ 'auto', 'on', 'off' ],
434
-labels=>\%lang_onofflabels,
435
-default=>$prefs{'daylightsaving'},
436
-override=>'1',
437
defined($config_raw{'DEFAULT_daylightsaving'})?('-disabled'=>'1'):());
438
$html =~ s/\@\@\@DAYLIGHTSAVINGMENU\@\@\@/$temphtml/;
439
440
if ($config{'enable_webmail'}) {
441
templateblock_enable($html, 'WEBMAIL');
442
my @fromemails=sort_emails_by_domainnames($config{'domainnames'}, keys %userfrom);
443
my %fromlabels;
444
foreach (@fromemails) {
445
if ($userfrom{$_}) {
446
$fromlabels{$_}=qq|"$userfrom{$_}" <$_>|;
447
} else {
448
$fromlabels{$_}=qq|$_|;
449
}
450
}
451
$temphtml = popup_menu(-name=>'email',
452
-values=>\@fromemails,
453
-labels=>\%fromlabels,
454
-default=>$prefs{'email'},
455
-override=>'1');
456
if ($config{'enable_editfrombook'}) {
457
$temphtml .= "&nbsp;".iconlink("editfroms.s.gif", $lang_text{'editfroms'}, qq|href="$config{'ow_cgiurl'}/openwebmail-prefs.pl?action=editfroms&amp;$urlparmstr"|). qq| \n|;
458
}
459
$html =~ s/\@\@\@FROMEMAILMENU\@\@\@/$temphtml/;
460
461
$temphtml = textfield(-name=>'replyto',
462
-default=>$prefs{'replyto'} || '',
463
-size=>'40',
464
-override=>'1');
465
$html =~ s/\@\@\@REPLYTOFIELD\@\@\@/$temphtml/;
466
467
# read .forward, also see if autoforwarding is on
468
my ($autoreply, $keeplocalcopy, @forwards)=readdotforward();
469
if ($config{'enable_setforward'}) {
470
templateblock_enable($html, 'FORWARD');
471
my $forwardaddress='';
472
$forwardaddress = join(",", @forwards) if ($#forwards >= 0);
473
$temphtml = textfield(-name=>'forwardaddress',
474
-default=>$forwardaddress,
475
-size=>'30',
476
-override=>'1');
477
$html =~ s/\@\@\@FORWARDADDRESS\@\@\@/$temphtml/;
478
479
$temphtml = checkbox(-name=>'keeplocalcopy',
480
-value=>'1',
481
-checked=>$keeplocalcopy,
482
-label=>'');
483
$html =~ s/\@\@\@KEEPLOCALCOPY\@\@\@/$temphtml/;
484
} else {
485
templateblock_disable($html, 'FORWARD');
486
}
487
488
if ($config{'enable_autoreply'}) {
489
templateblock_enable($html, 'AUTOREPLY');
490
# whether autoreply active or not is determined by
491
# if .forward is set to call vacation program, not in .openwebmailrc
492
my ($autoreplysubject, $autoreplytext)=readdotvacationmsg();
493
494
$temphtml = checkbox(-name=>'autoreply',
495
-value=>'1',
496
-checked=>$autoreply,
497
-label=>'');
498
$html =~ s/\@\@\@AUTOREPLYCHECKBOX\@\@\@/$temphtml/;
499
500
$temphtml = textfield(-name=>'autoreplysubject',
501
-default=>$autoreplysubject,
502
-size=>'40',
503
-override=>'1');
504
$html =~ s/\@\@\@AUTOREPLYSUBJECT\@\@\@/$temphtml/;
505
506
$temphtml = textarea(-name=>'autoreplytext',
507
-default=>$autoreplytext,
508
-rows=>'5',
509
-columns=>$prefs{'editcolumns'}||'78',
510
-wrap=>'hard',
511
-override=>'1');
512
$html =~ s/\@\@\@AUTOREPLYTEXT\@\@\@/$temphtml/;
513
} else {
514
templateblock_disable($html, 'AUTOREPLY');
515
$html =~ s/\@\@\@AUTOREPLYCHECKBOX\@\@\@/not available/;
516
$html =~ s/\@\@\@AUTOREPLYSUBJECT\@\@\@/not available/;
517
$html =~ s/\@\@\@AUTOREPLYTEXT\@\@\@/not available/;
518
}
519
520
$temphtml = textarea(-name=>'signature',
521
-default=>$prefs{'signature'},
522
-rows=>'5',
523
-columns=>$prefs{'editcolumns'}||'78',
524
-wrap=>'hard',
525
-override=>'1',
526
defined($config_raw{'DEFAULT_signature'})?('-disabled'=>'1'):());
527
$html =~ s/\@\@\@SIGAREA\@\@\@/$temphtml/;
528
} else {
529
templateblock_disable($html, 'WEBMAIL');
530
}
531
532
if (!$userfirsttime) {
533
# Get a list of valid style files
534
my @styles;
535
opendir(STYLESDIR, "$config{'ow_stylesdir'}") or
536
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $config{'ow_stylesdir'} directory for reading! ($!)");
537
while (defined(my $currstyle = readdir(STYLESDIR))) {
538
if ($currstyle =~ /^([^\.].*)$/) {
539
push (@styles, $1);
540
}
541
}
542
@styles = sort(@styles);
543
closedir(STYLESDIR) or
544
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_close'} $config{'ow_stylesdir'}! ($!)");
545
546
$temphtml = popup_menu(-name=>'style',
547
-values=>\@styles,
548
-default=>$prefs{'style'},
549
-accesskey=>'2',
550
-override=>'1',
551
defined($config_raw{'DEFAULT_style'})?('-disabled'=>'1'):());
552
$html =~ s/\@\@\@STYLEMENU\@\@\@/$temphtml/;
553
554
# Get a list of valid iconset
555
my @iconsets;
556
opendir(ICONSETSDIR, "$config{'ow_htmldir'}/images/iconsets") or
557
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $config{'ow_htmldir'}/images/iconsets directory for reading! ($!)");
558
while (defined(my $currset = readdir(ICONSETSDIR))) {
559
if (-d "$config{'ow_htmldir'}/images/iconsets/$currset" && $currset =~ /^([^\.].*)$/) {
560
push (@iconsets, $1);
561
}
562
}
563
@iconsets = sort(@iconsets);
564
closedir(ICONSETSDIR) or
565
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_close'} $config{'ow_htmldir'}/images/iconsets! ($!)");
566
567
$temphtml = popup_menu(-name=>'iconset',
568
-values=>\@iconsets,
569
-default=>$prefs{'iconset'},
570
-override=>'1',
571
defined($config_raw{'DEFAULT_iconset'})?('-disabled'=>'1'):());
572
$html =~ s/\@\@\@ICONSETMENU\@\@\@/$temphtml/;
573
574
# Get a list of valid background images
575
my @backgrounds;
576
opendir(BACKGROUNDSDIR, "$config{'ow_htmldir'}/images/backgrounds") or
577
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $config{'ow_htmldir'}/images/backgrounds directory for reading! ($!)");
578
while (defined(my $currbackground = readdir(BACKGROUNDSDIR))) {
579
if ($currbackground =~ /^([^\.].*)$/) {
580
push (@backgrounds, $1);
581
}
582
}
583
closedir(BACKGROUNDSDIR) or
584
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_close'} $config{'ow_htmldir'}/images/backgrounds! ($!)");
585
@backgrounds = sort(@backgrounds);
586
push(@backgrounds, "USERDEFINE");
587
588
my ($background, $bgurl)=($prefs{'bgurl'}, '');
589
if ($background !~ s!$config{'ow_htmlurl'}/images/backgrounds/!!) {
590
($background, $bgurl)=('USERDEFINE', $prefs{'bgurl'});
591
}
592
$temphtml = popup_menu(-name=>'background',
593
-values=>\@backgrounds,
594
-labels=>{ 'USERDEFINE'=>"--$lang_text{'userdef'}--" },
595
-default=>$background,
596
-onChange=>"JavaScript:document.prefsform.bgurl.value='';",
597
-override=>'1',
598
defined($config_raw{'DEFAULT_bgurl'})?('-disabled'=>'1'):());
599
$html =~ s/\@\@\@BACKGROUNDMENU\@\@\@/$temphtml/;
600
601
$temphtml = checkbox(-name=>'bgrepeat',
602
-value=>'1',
603
-checked=>$prefs{'bgrepeat'},
604
-label=>'',
605
defined($config_raw{'DEFAULT_bgrepeat'})?('-disabled'=>'1'):());
606
$html =~ s/\@\@\@BGREPEATCHECKBOX\@\@\@/$temphtml/;
607
608
$temphtml = textfield(-name=>'bgurl',
609
-default=>$bgurl,
610
-size=>'35',
611
-override=>'1',
612
defined($config_raw{'DEFAULT_bgurl'})?('-disabled'=>'1'):());
613
$html =~ s/\@\@\@BGURLFIELD\@\@\@/$temphtml/;
614
615
my @fontsize=sort { ($a=~/px$/ - $b=~/px$/) || $a<=>$b } keys %fontsize;
616
my %fontsizelabels;
617
foreach (@fontsize) {
618
$fontsizelabels{$_}=$_;
619
$fontsizelabels{$_}=~s/pt/ $lang_text{'point'}/;
620
$fontsizelabels{$_}=~s/px/ $lang_text{'pixel'}/;
621
}
622
$temphtml = popup_menu(-name=>'fontsize',
623
-values=>\@fontsize,
624
-default=>$prefs{'fontsize'},
625
-labels=>\%fontsizelabels,
626
-override=>'1',
627
defined($config_raw{'DEFAULT_font'})?('-disabled'=>'1'):());
628
$html =~ s/\@\@\@FONTSIZEMENU\@\@\@/$temphtml/;
629
630
$temphtml = popup_menu(-name=>'dateformat',
631
-values=>['mm/dd/yyyy', 'dd/mm/yyyy', 'yyyy/mm/dd',
632
'mm-dd-yyyy', 'dd-mm-yyyy', 'yyyy-mm-dd',
633
'mm.dd.yyyy', 'dd.mm.yyyy', 'yyyy.mm.dd'],
634
-default=>$prefs{'dateformat'},
635
-override=>'1',
636
defined($config_raw{'DEFAULT_dateformat'})?('-disabled'=>'1'):());
637
$html =~ s/\@\@\@DATEFORMATMENU\@\@\@/$temphtml/;
638
639
$temphtml = popup_menu(-name=>'hourformat',
640
-values=>[12, 24],
641
-default=>$prefs{'hourformat'},
642
-override=>'1',
643
defined($config_raw{'DEFAULT_hourformat'})?('-disabled'=>'1'):());
644
$html =~ s/\@\@\@HOURFORMATMENU\@\@\@/$temphtml/;
645
646
647
if ($config{'enable_webmail'}) {
648
$temphtml = popup_menu(-name=>'ctrlposition_folderview',
649
-values=>['top', 'bottom'],
650
-default=>$prefs{'ctrlposition_folderview'} || 'bottom',
651
-labels=>\%lang_ctrlpositionlabels,
652
-accesskey=>'3',
653
-override=>'1',
654
defined($config_raw{'DEFAULT_ctrlposition_folderview'})?('-disabled'=>'1'):());
655
$html =~ s/\@\@\@CTRLPOSITIONFOLDERVIEWMENU\@\@\@/$temphtml/;
656
657
$temphtml = popup_menu(-name=>'msgsperpage',
658
-values=>[8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,50,100,500,1000],
659
-default=>$prefs{'msgsperpage'},
660
-override=>'1',
661
defined($config_raw{'DEFAULT_msgsperpage'})?('-disabled'=>'1'):());
662
$html =~ s/\@\@\@HEADERSPERPAGE\@\@\@/$temphtml/;
663
664
my %orderlabels = (
665
'date from subject size' =>
666
"$lang_text{'date'}, $lang_text{'from'}, $lang_text{'subject'}, $lang_text{'size'}",
667
'date subject from size' =>
668
"$lang_text{'date'}, $lang_text{'subject'}, $lang_text{'from'}, $lang_text{'size'}",
669
'subject from date size' =>
670
"$lang_text{'subject'}, $lang_text{'from'}, $lang_text{'date'}, $lang_text{'size'}",
671
'from subject date size' =>
672
"$lang_text{'from'}, $lang_text{'subject'}, $lang_text{'date'}, $lang_text{'size'}"
673
);
674
my @ordervalues=sort keys(%orderlabels);
675
$temphtml = popup_menu(-name=>'fieldorder',
676
-default=>$prefs{'fieldorder'},
677
-values=>\@ordervalues,
678
-labels=>\%orderlabels,
679
-override=>'1',
680
defined($config_raw{'DEFAULT_fieldorder'})?('-disabled'=>'1'):());
681
$html =~ s/\@\@\@FIELDORDERMENU\@\@\@/$temphtml/;
682
683
# since there is already sort param inherited from outside prefs form,
684
# so the prefs form pass the sort param as msgsort
685
$temphtml = popup_menu(-name=>'msgsort',
686
-values=>['date','date_rev','sender','sender_rev',
687
'size','size_rev','subject','subject_rev',
688
'status'],
689
-default=>$prefs{'sort'},
690
-labels=>\%lang_sortlabels,
691
-override=>'1',
692
defined($config_raw{'DEFAULT_msgsort'})?('-disabled'=>'1'):());
693
$html =~ s/\@\@\@SORTMENU\@\@\@/$temphtml/;
694
695
$temphtml = iconlink("search.s.gif", '', '');
696
$html =~ s/\@\@\@MINISEARCHICON\@\@\@/$temphtml/;
697
$temphtml = checkbox(-name=>'useminisearchicon',
698
-value=>'1',
699
-checked=>$prefs{'useminisearchicon'},
700
-label=>'',
701
defined($config_raw{'DEFAULT_useminisearchicon'})?('-disabled'=>'1'):());
702
$html =~ s/\@\@\@USEMINISEARCHICONCHECKBOX\@\@\@/$temphtml/;
703
704
705
$temphtml = checkbox(-name=>'confirmmsgmovecopy',
706
-value=>'1',
707
-checked=>$prefs{'confirmmsgmovecopy'},
708
-accesskey=>'4',
709
-label=>'',
710
defined($config_raw{'DEFAULT_confirmmsgmovecopy'})?('-disabled'=>'1'):());
711
$html =~ s/\@\@\@CONFIRMMSGMOVECOPY\@\@\@/$temphtml/;
712
713
$temphtml = popup_menu(-name=>'defaultdestination',
714
-values=>['saved-messages','mail-trash', 'DELETE'],
715
-default=>$prefs{'defaultdestination'} || 'mail-trash',
716
-labels=>\%lang_folders,
717
-override=>'1',
718
defined($config_raw{'DEFAULT_defaultdestination'})?('-disabled'=>'1'):());
719
$html =~ s/\@\@\@DEFAULTDESTINATIONMENU\@\@\@/$temphtml/;
720
721
$temphtml = checkbox(-name=>'smartdestination',
722
-value=>'1',
723
-checked=>$prefs{'smartdestination'},
724
-label=>'',
725
defined($config_raw{'DEFAULT_smartdestination'})?('-disabled'=>'1'):());
726
$html =~ s/\@\@\@SMARTDESTINATION\@\@\@/$temphtml/;
727
728
$temphtml = checkbox(-name=>'viewnextaftermsgmovecopy',
729
-value=>'1',
730
-checked=>$prefs{'viewnextaftermsgmovecopy'},
731
-label=>'',
732
defined($config_raw{'DEFAULT_viewnextaftermsgmovecopy'})?('-disabled'=>'1'):());
733
$html =~ s/\@\@\@VIEWNEXTAFTERMSGMOVECOPY\@\@\@/$temphtml/;
734
735
if ($config{'enable_pop3'}) {
736
templateblock_enable($html, 'AUTOPOP3');
737
$temphtml = checkbox(-name=>'autopop3',
738
-value=>'1',
739
-checked=>$prefs{'autopop3'},
740
-label=>'',
741
defined($config_raw{'DEFAULT_autopop3'})?('-disabled'=>'1'):());
742
$html =~ s/\@\@\@AUTOPOP3CHECKBOX\@\@\@/$temphtml/;
743
$temphtml = popup_menu(-name=>'autopop3wait',
744
-values=>[0,1,2,3,4,5,6,7,8,9,10,15,20,25,30],
745
-default=>$prefs{'autopop3wait'},
746
-override=>'1',
747
defined($config_raw{'DEFAULT_autopop3wait'})?('-disabled'=>'1'):());
748
$html =~ s/\@\@\@AUTOPOP3WAITMENU\@\@\@/$temphtml/;
749
} else {
750
templateblock_disable($html, 'AUTOPOP3');
751
}
752
753
$temphtml = popup_menu(-name=>'bgfilterwait',
754
-values=>[5,10,15,20,25,30,35,40,45,50,55,60,90,120],
755
-default=>$prefs{'bgfilterwait'},
756
-override=>'1',
757
defined($config_raw{'DEFAULT_bgfilterwait'})?('-disabled'=>'1'):());
758
$html =~ s/\@\@\@BGFILTERWAITMENU\@\@\@/$temphtml/;
759
760
if ($config{'forced_moveoldmsgfrominbox'}) {
761
templateblock_disable($html, 'MOVEOLD');
762
} else {
763
templateblock_enable($html, 'MOVEOLD');
764
$temphtml = checkbox(-name=>'moveoldmsgfrominbox',
765
-value=>'1',
766
-checked=>$prefs{'moveoldmsgfrominbox'},
767
-label=>'',
768
defined($config_raw{'DEFAULT_moveoldmsgfrominbox'})?('-disabled'=>'1'):());
769
$html =~ s/\@\@\@MOVEOLDMSGFROMINBOX\@\@\@/$temphtml/;
770
}
771
772
773
$temphtml = popup_menu(-name=>'ctrlposition_msgread',
774
-values=>['top', 'bottom'],
775
-default=>$prefs{'ctrlposition_msgread'} || 'bottom',
776
-labels=>\%lang_ctrlpositionlabels,
777
-accesskey=>'5',
778
-override=>'1',
779
defined($config_raw{'DEFAULT_ctrlposition_msgread'})?('-disabled'=>'1'):());
780
$html =~ s/\@\@\@CTRLPOSITIONMSGREADMENU\@\@\@/$temphtml/;
781
782
my %headerlabels = ('simple'=>$lang_text{'simplehead'},
783
'all'=>$lang_text{'allhead'} );
784
$temphtml = popup_menu(-name=>'headers',
785
-values=>['simple','all'],
786
-default=>$prefs{'headers'} || 'simple',
787
-labels=>\%headerlabels,
788
-override=>'1',
789
defined($config_raw{'DEFAULT_headers'})?('-disabled'=>'1'):());
790
$html =~ s/\@\@\@HEADERSMENU\@\@\@/$temphtml/;
791
792
$temphtml = checkbox(-name=>'usefixedfont',
793
-value=>'1',
794
-checked=>$prefs{'usefixedfont'},
795
-label=>'',
796
defined($config_raw{'DEFAULT_usefixedfont'})?('-disabled'=>'1'):());
797
$html =~ s/\@\@\@USEFIXEDFONT\@\@\@/$temphtml/;
798
799
$temphtml = checkbox(-name=>'usesmileicon',
800
-value=>'1',
801
-checked=>$prefs{'usesmileicon'},
802
-label=>'',
803
defined($config_raw{'DEFAULT_usesmileicon'})?('-disabled'=>'1'):());
804
$html =~ s/\@\@\@USESMILEICON\@\@\@/$temphtml/;
805
806
$temphtml = checkbox(-name=>'disablejs',
807
-value=>'1',
808
-checked=>$prefs{'disablejs'},
809
-label=>'',
810
defined($config_raw{'DEFAULT_disablejs'})?('-disabled'=>'1'):());
811
$html =~ s/\@\@\@DISABLEJS\@\@\@/$temphtml/;
812
813
$temphtml = checkbox(-name=>'disableembcode',
814
-value=>'1',
815
-checked=>$prefs{'disableembcode'},
816
-label=>'',
817
defined($config_raw{'DEFAULT_disableembcode'})?('-disabled'=>'1'):());
818
$html =~ s/\@\@\@DISABLEEMBCODE\@\@\@/$temphtml/;
819
820
$temphtml = popup_menu(-name=>'disableemblink',
821
-values=>['none', 'cgionly', 'all'],
822
-default=>$prefs{'disableemblink'},
823
-labels=>\%lang_disableemblinklabels,
824
-override=>'1',
825
defined($config_raw{'DEFAULT_disableemblink'})?('-disabled'=>'1'):());
826
$html =~ s/\@\@\@DISABLEEMBLINKMENU\@\@\@/$temphtml/;
827
828
$temphtml = checkbox(-name=>'showhtmlastext',
829
-value=>'1',
830
-checked=>$prefs{'showhtmlastext'},
831
-label=>'',
832
defined($config_raw{'DEFAULT_showhtmlastext'})?('-disabled'=>'1'):());
833
$html =~ s/\@\@\@SHOWHTMLASTEXT\@\@\@/$temphtml/;
834
835
$temphtml = checkbox(-name=>'showimgaslink',
836
-value=>'1',
837
-checked=>$prefs{'showimgaslink'},
838
-label=>'',
839
defined($config_raw{'DEFAULT_showimgaslink'})?('-disabled'=>'1'):());
840
$html =~ s/\@\@\@SHOWIMGASLINK\@\@\@/$temphtml/;
841
842
$temphtml = popup_menu(-name=>'sendreceipt',
843
-values=>['ask', 'yes', 'no'],
844
-default=>$prefs{'sendreceipt'} || 'ask',
845
-labels=>\%lang_receiptlabels,
846
-override=>'1',
847
defined($config_raw{'DEFAULT_sendreceipt'})?('-disabled'=>'1'):());
848
$html =~ s/\@\@\@SENDRECEIPTMENU\@\@\@/$temphtml/;
849
850
851
$temphtml = popup_menu(-name=>'msgformat',
852
-values=>['auto', 'text', 'html', 'both'],
853
-default=>$prefs{'msgformat'},
854
-labels=>\%lang_msgformatlabels,
855
-accesskey=>'6',
856
-override=>'1',
857
defined($config_raw{'DEFAULT_msgformat'})?('-disabled'=>'1'):());
858
$html =~ s/\@\@\@MSGFORMATMENU\@\@\@/$temphtml/;
859
860
$temphtml = popup_menu(-name=>'editcolumns',
861
-values=>[60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,100,110,120],
862
-default=>$prefs{'editcolumns'},
863
-override=>'1',
864
defined($config_raw{'DEFAULT_editcolumns'})?('-disabled'=>'1'):());
865
$html =~ s/\@\@\@EDITCOLUMNSMENU\@\@\@/$temphtml/;
866
867
$temphtml = popup_menu(-name=>'editrows',
868
-values=>[10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,50,60,70,80],
869
-default=>$prefs{'editrows'},
870
-override=>'1',
871
defined($config_raw{'DEFAULT_editrows'})?('-disabled'=>'1'):());
872
$html =~ s/\@\@\@EDITROWSMENU\@\@\@/$temphtml/;
873
874
$temphtml = popup_menu(-name=>'sendbuttonposition',
875
-values=>['before', 'after', 'both'],
876
-default=>$prefs{'sendbuttonposition'} || 'before',
877
-labels=>\%lang_sendpositionlabels,
878
-override=>'1',
879
defined($config_raw{'DEFAULT_sendbuttonposition'})?('-disabled'=>'1'):());
880
$html =~ s/\@\@\@SENDBUTTONPOSITIONMENU\@\@\@/$temphtml/;
881
882
$temphtml = checkbox(-name=>'reparagraphorigmsg',
883
-value=>'1',
884
-checked=>$prefs{'reparagraphorigmsg'},
885
-label=>'',
886
defined($config_raw{'DEFAULT_reparagraphorigmsg'})?('-disabled'=>'1'):());
887
$html =~ s/\@\@\@REPARAGRAPHORIGMSG\@\@\@/$temphtml/;
888
889
$temphtml = popup_menu(-name=>'replywithorigmsg',
890
-values=>['at_beginning', 'at_end', 'none'],
891
-default=>$prefs{'replywithorigmsg'} || 'at_beginning',
892
-labels=>\%lang_withoriglabels,
893
-override=>'1',
894
defined($config_raw{'DEFAULT_replywithorigmsg'})?('-disabled'=>'1'):());
895
$html =~ s/\@\@\@REPLYWITHORIGMSGMENU\@\@\@/$temphtml/;
896
897
$temphtml = checkbox(-name=>'backupsentmsg',
898
-value=>'1',
899
-checked=>$prefs{'backupsentmsg'},
900
-label=>'',
901
defined($config_raw{'DEFAULT_backupsentmsg'})?('-disabled'=>'1'):());
902
$html =~ s/\@\@\@BACKUPSENTMSG\@\@\@/$temphtml/;
903
904
my %ctlabels=( 'sameascomposing' => $lang_text{'samecharset'} );
905
my @ctlist=('sameascomposing', $prefs{charset});
906
foreach my $ct (@{$charset_convlist{$prefs{charset}}}) {
907
push(@ctlist, $ct) if (is_convertable($prefs{charset}, $ct));
908
}
909
$temphtml = popup_menu(-name=>'sendcharset',
910
-values=>\@ctlist,
911
-labels=>\%ctlabels,
912
-default=>$defaultsendcharset,
913
-override=>'1',
914
defined($config_raw{'DEFAULT_sendcharset'})?('-disabled'=>'1'):());
915
$html =~ s/\@\@\@SENDCHARSETMENU\@\@\@/$temphtml/;
916
917
918
if ($config{'enable_viruscheck'}) {
919
templateblock_enable($html, 'VIRUSCHECK');
920
921
my @source=('none');
922
if ($config{'viruscheck_source_allowed'} eq 'pop3') {
923
@source=('none', 'pop3');
924
} elsif ($config{'viruscheck_source_allowed'} eq 'all') {
925
@source=('none', 'pop3', 'all');
926
}
927
$temphtml = popup_menu(-name=>'viruscheck_source',
928
-values=> \@source,
929
-labels=> \%lang_checksourcelabels,
930
-default=>$prefs{'viruscheck_source'},
931
-accesskey=>'7',
932
-override=>'1',
933
defined($config_raw{'DEFAULT_viruscheck_source'})?('-disabled'=>'1'):());
934
$html =~ s/\@\@\@VIRUSCHECKSOURCEMENU\@\@\@/$temphtml/;
935
936
my (@maxsize, $defmaxsize);
937
foreach my $n (250, 500, 1000, 2000, 3000, 4000, 5000, 10000, 20000, 50000) {
938
if ($n <= $config{'viruscheck_maxsize_allowed'}) {
939
push(@maxsize, $n);
940
$defmaxsize=$n if ($n <= $prefs{'viruscheck_maxsize'});
941
}
942
}
943
$temphtml = popup_menu(-name=>'viruscheck_maxsize',
944
-values=> \@maxsize,
945
-default=> $defmaxsize
946
-override=>'1',
947
defined($config_raw{'DEFAULT_viruscheck_maxsize'})?('-disabled'=>'1'):());
948
$html =~ s/\@\@\@VIRUSCHECKMAXSIZEMENU\@\@\@/$temphtml/;
949
950
$temphtml = popup_menu(-name=>'viruscheck_minbodysize',
951
-values=> [0, 0.5, 1, 1.5, 2],
952
-default=>$prefs{'viruscheck_minbodysize'},
953
-override=>'1',
954
defined($config_raw{'DEFAULT_viruscheck_minbodysize'})?('-disabled'=>'1'):());
955
$html =~ s/\@\@\@VIRUSCHECKMINBODYSIZEMENU\@\@\@/$temphtml/;
956
957
} else {
958
templateblock_disable($html, 'VIRUSCHECK');
959
}
960
961
962
if ($config{'enable_spamcheck'}) {
963
templateblock_enable($html, 'SPAMCHECK');
964
965
my @source=('none');
966
if ($config{'spamcheck_source_allowed'} eq 'pop3') {
967
@source=('none', 'pop3');
968
} elsif ($config{'spamcheck_source_allowed'} eq 'all') {
969
@source=('none', 'pop3', 'all');
970
}
971
$temphtml = popup_menu(-name=>'spamcheck_source',
972
-values=> \@source,
973
-labels=> \%lang_checksourcelabels,
974
-default=>$prefs{'spamcheck_source'},
975
-accesskey=>'7',
976
-override=>'1',
977
defined($config_raw{'DEFAULT_spamcheck_source'})?('-disabled'=>'1'):());
978
$html =~ s/\@\@\@SPAMCHECKSOURCEMENU\@\@\@/$temphtml/;
979
980
my (@maxsize, $defmaxsize);
981
foreach my $n (100, 150, 200, 250, 300, 350, 400, 450, 500, 600, 700, 800, 900, 1000) {
982
if ($n <= $config{'spamcheck_maxsize_allowed'}) {
983
push(@maxsize, $n);
984
$defmaxsize=$n if ($n <= $prefs{'spamcheck_maxsize'});
985
}
986
}
987
$temphtml = popup_menu(-name=>'spamcheck_maxsize',
988
-values=> \@maxsize,
989
-default=> $defmaxsize
990
-override=>'1',
991
defined($config_raw{'DEFAULT_spamcheck_maxsize'})?('-disabled'=>'1'):());
992
$html =~ s/\@\@\@SPAMCHECKMAXSIZEMENU\@\@\@/$temphtml/;
993
994
$temphtml = popup_menu(-name=>'spamcheck_threshold',
995
-values=> [5..30],
996
-default=>$prefs{'spamcheck_threshold'},
997
-override=>'1',
998
defined($config_raw{'DEFAULT_spamcheck_threshold'})?('-disabled'=>'1'):());
999
$html =~ s/\@\@\@SPAMCHECKTHRESHOLDMENU\@\@\@/$temphtml/;
1000
1001
} else {
1002
templateblock_disable($html, 'SPAMCHECK');
1003
}
1004
1005
1006
if ($config{'enable_smartfilter'}) {
1007
templateblock_enable($html, 'FILTER');
1008
1009
my $filterruledb=dotpath('filter.ruledb');
1010
my (%FILTERRULEDB, $matchcount, $matchdate);
1011
ow::dbm::open(\%FILTERRULEDB, $filterruledb, LOCK_SH) or
1012
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_locksh'} db $filterruledb");
1013
1014
$temphtml = popup_menu(-name=>'filter_repeatlimit',
1015
-values=>['0','5','10','20','30','40','50','100'],
1016
-default=>$prefs{'filter_repeatlimit'},
1017
-accesskey=>'7',
1018
-override=>'1',
1019
defined($config_raw{'DEFAULT_filter_repeatlimit'})?('-disabled'=>'1'):());
1020
($matchcount, $matchdate)=split(":", $FILTERRULEDB{"filter_repeatlimit"});
1021
if ($matchdate) {
1022
$matchdate=ow::datetime::dateserial2str($matchdate,
1023
$prefs{'timeoffset'}, $prefs{'daylightsaving'},
1024
$prefs{'dateformat'}, $prefs{'hourformat'});
1025
$temphtml .= "&nbsp;(<a title='$matchdate'>$lang_text{'filtered'}: $matchcount</a>)";
1026
}
1027
$html =~ s/\@\@\@FILTERREPEATLIMIT\@\@\@/$temphtml/;
1028
1029
$temphtml = checkbox(-name=>'filter_badaddrformat',
1030
-value=>'1',
1031
-checked=>$prefs{'filter_badaddrformat'},
1032
-label=>'',
1033
defined($config_raw{'DEFAULT_filter_badaddrformat'})?('-disabled'=>'1'):());
1034
($matchcount, $matchdate)=split(":", $FILTERRULEDB{'filter_badaddrformat'});
1035
if ($matchdate) {
1036
$matchdate=ow::datetime::dateserial2str($matchdate,
1037
$prefs{'timeoffset'}, $prefs{'daylightsaving'},
1038
$prefs{'dateformat'}, $prefs{'hourformat'});
1039
$temphtml .= "&nbsp;(<a title='$matchdate'>$lang_text{'filtered'}: $matchcount</a>)";
1040
}
1041
$html =~ s/\@\@\@FILTERBADADDRFORMAT\@\@\@/$temphtml/;
1042
1043
$temphtml = checkbox(-name=>'filter_fakedsmtp',
1044
-value=>'1',
1045
-checked=>$prefs{'filter_fakedsmtp'},
1046
-label=>'',
1047
defined($config_raw{'DEFAULT_filter_fakedsmtp'})?('-disabled'=>'1'):());
1048
($matchcount, $matchdate)=split(":", $FILTERRULEDB{'filter_fakedsmtp'});
1049
if ($matchdate) {
1050
$matchdate=ow::datetime::dateserial2str($matchdate,
1051
$prefs{'timeoffset'}, $prefs{'daylightsaving'},
1052
$prefs{'dateformat'}, $prefs{'hourformat'});
1053
$temphtml .= "&nbsp;(<a title='$matchdate'>$lang_text{'filtered'}: $matchcount</a>)";
1054
}
1055
$html =~ s/\@\@\@FILTERFAKEDSMTP\@\@\@/$temphtml/;
1056
1057
$temphtml = checkbox(-name=>'filter_fakedfrom',
1058
-value=>'1',
1059
-checked=>$prefs{'filter_fakedfrom'},
1060
-label=>'',
1061
defined($config_raw{'DEFAULT_filter_fakedfrom'})?('-disabled'=>'1'):());
1062
($matchcount, $matchdate)=split(":", $FILTERRULEDB{'filter_fakedfrom'});
1063
if ($matchdate) {
1064
$matchdate=ow::datetime::dateserial2str($matchdate,
1065
$prefs{'timeoffset'}, $prefs{'daylightsaving'},
1066
$prefs{'dateformat'}, $prefs{'hourformat'});
1067
$temphtml .= "&nbsp;(<a title='$matchdate'>$lang_text{'filtered'}: $matchcount</a>)";
1068
}
1069
$html =~ s/\@\@\@FILTERFAKEDFROM\@\@\@/$temphtml/;
1070
1071
$temphtml = checkbox(-name=>'filter_fakedexecontenttype',
1072
-value=>'1',
1073
-checked=>$prefs{'filter_fakedexecontenttype'},
1074
-label=>'',
1075
defined($config_raw{'DEFAULT_filter_fakedexecontenttype'})?('-disabled'=>'1'):());
1076
($matchcount, $matchdate)=split(":", $FILTERRULEDB{'filter_fakedexecontenttype'});
1077
if ($matchdate) {
1078
$matchdate=ow::datetime::dateserial2str($matchdate,
1079
$prefs{'timeoffset'}, $prefs{'daylightsaving'},
1080
$prefs{'dateformat'}, $prefs{'hourformat'});
1081
$temphtml .= "&nbsp;(<a title='$matchdate'>$lang_text{'filtered'}: $matchcount</a>)";
1082
}
1083
$html =~ s/\@\@\@FILTERFAKEDEXECONTENTTYPE\@\@\@/$temphtml/;
1084
1085
ow::dbm::close(\%FILTERRULEDB, $filterruledb);
1086
1087
} else {
1088
templateblock_disable($html, 'FILTER');
1089
}
1090
1091
my @pvalues=(300,320,340,360,380,400,420,440,460,480,500,600,700,800,900,1000);
1092
my %plabels;
1093
foreach (@pvalues) {
1094
$plabels{$_}="$_ $lang_text{'pixel'}";
1095
}
1096
push (@pvalues, 'max');
1097
$plabels{'max'}=$lang_text{'max'};
1098
1099
$temphtml = popup_menu(-name=>'abook_width',
1100
-values=>\@pvalues,
1101
-labels=>\%plabels,
1102
-default=>$prefs{'abook_width'},
1103
-override=>'1',
1104
defined($config_raw{'DEFAULT_abook_width'})?('-disabled'=>'1'):());
1105
$html =~ s/\@\@\@ABOOKWIDTHMENU\@\@\@/$temphtml/;
1106
1107
$temphtml = popup_menu(-name=>'abook_height',
1108
-values=>\@pvalues,
1109
-labels=>\%plabels,
1110
-default=>$prefs{'abook_height'},
1111
-override=>'1',
1112
defined($config_raw{'DEFAULT_abook_height'})?('-disabled'=>'1'):());
1113
$html =~ s/\@\@\@ABOOKHEIGHTMENU\@\@\@/$temphtml/;
1114
1115
$temphtml = popup_menu(-name=>'abook_buttonposition',
1116
-values=>['before', 'after', 'both'],
1117
-default=>$prefs{'abook_buttonposition'} || 'before',
1118
-labels=>\%lang_abookbuttonpositionlabels,
1119
-override=>'1',
1120
defined($config_raw{'DEFAULT_abook_buttonposition'})?('-disabled'=>'1'):());
1121
$html =~ s/\@\@\@ABOOKBUTTONPOSITIONMENU\@\@\@/$temphtml/;
1122
1123
$temphtml = "$lang_text{'enable'}&nbsp;";
1124
$temphtml .= checkbox(-name=>'abook_defaultfilter',
1125
-value=>'1',
1126
-checked=>$prefs{'abook_defaultfilter'},
1127
-label=>'',
1128
defined($config_raw{'DEFAULT_abook_defaultfilter'})?('-disabled'=>'1'):());
1129
$temphtml .= "&nbsp;";
1130
my %searchtypelabels = ('name'=>$lang_text{'name'},
1131
'email'=>$lang_text{'email'},
1132
'note'=>$lang_text{'note'},
1133
'all'=>$lang_text{'all'});
1134
$temphtml .= popup_menu(-name=>'abook_defaultsearchtype',
1135
-default=>$prefs{'abook_defaultsearchtype'} || 'name',
1136
-values=>['name', 'email', 'note', 'all'],
1137
-labels=>\%searchtypelabels,
1138
defined($config_raw{'DEFAULT_abook_defaultsearchtype'})?('-disabled'=>'1'):());
1139
$temphtml .= textfield(-name=>'abook_defaultkeyword',
1140
-default=>$prefs{'abook_defaultkeyword'},
1141
-size=>'16',
1142
-override=>'1',
1143
defined($config_raw{'DEFAULT_abook_defaultkeyword'})?('-disabled'=>'1'):());
1144
$html =~ s/\@\@\@ABOOKDEFAULTFILTER\@\@\@/$temphtml/;
1145
}
1146
1147
if ($config{'enable_calendar'}) {
1148
templateblock_enable($html, 'CALENDAR');
1149
1150
my %calendarview_labels=(
1151
calyear => $lang_calendar{'yearview'},
1152
calmonth => $lang_calendar{'monthview'},
1153
calweek => $lang_calendar{'weekview'},
1154
calday => $lang_calendar{'dayview'},
1155
callist => $lang_calendar{'listview'}
1156
);
1157
$temphtml = popup_menu(-name=>'calendar_defaultview',
1158
-values=>['calyear', 'calmonth', 'calweek', 'calday', 'callist'],
1159
-labels=>\%calendarview_labels,
1160
-default=>$prefs{'calendar_defaultview'},
1161
-accesskey=>'8',
1162
-override=>'1',
1163
defined($config_raw{'DEFAULT_calendar_defaultview'})?('-disabled'=>'1'):());
1164
$html =~ s/\@\@\@DEFAULTVIEWMENU\@\@\@/$temphtml/;
1165
1166
# Get a list of valid holiday files
1167
my @holidays;
1168
opendir(HOLIDAYSDIR, "$config{'ow_holidaysdir'}") or
1169
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $config{'ow_holidaysdir'} directory for reading! ($!)");
1170
while (defined(my $currholiday = readdir(HOLIDAYSDIR))) {
1171
if ($currholiday =~ /^([^\.].*)$/) {
1172
push (@holidays, $1);
1173
}
1174
}
1175
closedir(HOLIDAYSDIR) or
1176
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_close'} $config{'ow_holidaysdir'}! ($!)");
1177
@holidays = ('auto', sort(@holidays), 'none');
1178
1179
$temphtml = popup_menu(-name=>'calendar_holidaydef',
1180
-values=>\@holidays,
1181
-labels=>{ 'auto'=>$lang_text{'autosel'},
1182
'none'=>$lang_text{'none'} },
1183
-default=>$prefs{'calendar_holidaydef'},
1184
-override=>'1',
1185
defined($config_raw{'DEFAULT_calendar_holidaydef'})?('-disabled'=>'1'):());
1186
$html =~ s/\@\@\@HOLIDAYDEFMENU\@\@\@/$temphtml/;
1187
1188
$temphtml = popup_menu(-name=>'calendar_monthviewnumitems',
1189
-values=>[3, 4, 5, 6, 7, 8, 9, 10],
1190
-default=>$prefs{'calendar_monthviewnumitems'},
1191
-override=>'1',
1192
defined($config_raw{'DEFAULT_calendar_monthviewnumitems'})?('-disabled'=>'1'):());
1193
$html =~ s/\@\@\@MONTHVIEWNUMITEMSMENU\@\@\@/$temphtml/;
1194
1195
$temphtml = popup_menu(-name=>'calendar_weekstart',
1196
-values=>[1, 2, 3, 4, 5, 6, 0],
1197
-labels=>\%lang_wday,
1198
-default=>$prefs{'calendar_weekstart'},
1199
-override=>'1',
1200
defined($config_raw{'DEFAULT_calendar_weekstart'})?('-disabled'=>'1'):());
1201
$html =~ s/\@\@\@WEEKSTARTMENU\@\@\@/$temphtml/;
1202
1203
my @militaryhours;
1204
for (my $i=0; $i<24; $i++) {
1205
push(@militaryhours, sprintf("%02d00", $i));
1206
}
1207
$temphtml = popup_menu(-name=>'calendar_starthour',
1208
-values=>\@militaryhours,
1209
-default=>$prefs{'calendar_starthour'},
1210
-override=>'1',
1211
defined($config_raw{'DEFAULT_calendar_starthour'})?('-disabled'=>'1'):());
1212
$html =~ s/\@\@\@STARTHOURMENU\@\@\@/$temphtml/;
1213
1214
$temphtml = popup_menu(-name=>'calendar_endhour',
1215
-values=>\@militaryhours,
1216
-default=>$prefs{'calendar_endhour'},
1217
-override=>'1',
1218
defined($config_raw{'DEFAULT_calendar_endhour'})?('-disabled'=>'1'):());
1219
$html =~ s/\@\@\@ENDHOURMENU\@\@\@/$temphtml/;
1220
1221
$temphtml = popup_menu(-name=>'calendar_interval',
1222
-values=>[5, 10, 15, 20, 30, 45, 60, 90, 120],
1223
-default=>$prefs{'calendar_interval'},
1224
-override=>'1',
1225
defined($config_raw{'DEFAULT_calendar_interval'})?('-disabled'=>'1'):());
1226
$html =~ s/\@\@\@INTERVALMENU\@\@\@/$temphtml/;
1227
1228
$temphtml = checkbox(-name=>'calendar_showemptyhours',
1229
-value=>'1',
1230
-checked=>$prefs{'calendar_showemptyhours'},
1231
-label=>'',
1232
defined($config_raw{'DEFAULT_calendar_showemptyhours'})?('-disabled'=>'1'):());
1233
$html =~ s/\@\@\@SHOWEMPTYHOURSCHECKBOX\@\@\@/$temphtml/;
1234
1235
if ($config{'enable_webmail'}) {
1236
templateblock_enable($html, 'REMINDER');
1237
$temphtml = popup_menu(-name=>'calendar_reminderdays',
1238
-values=>[0, 1, 2, 3, 4, 5, 6 ,7, 14, 21, 30, 60],
1239
-labels=>{ 0=>$lang_text{'none'} },
1240
-default=>$prefs{'calendar_reminderdays'},
1241
-override=>'1',
1242
defined($config_raw{'DEFAULT_calendar_reminderdays'})?('-disabled'=>'1'):());
1243
$html =~ s/\@\@\@REMINDERDAYSMENU\@\@\@/$temphtml/;
1244
1245
$temphtml = checkbox(-name=>'calendar_reminderforglobal',
1246
-value=>'1',
1247
-checked=>$prefs{'calendar_reminderforglobal'},
1248
-label=>'',
1249
defined($config_raw{'DEFAULT_calendar_reminderforglobal'})?('-disabled'=>'1'):());
1250
$html =~ s/\@\@\@REMINDERFORGLOBALCHECKBOX\@\@\@/$temphtml/;
1251
} else {
1252
templateblock_disable($html, 'REMINDER');
1253
}
1254
1255
} else {
1256
templateblock_disable($html, 'CALENDAR');
1257
}
1258
1259
1260
if ($config{'enable_webdisk'}) {
1261
templateblock_enable($html, 'WEBDISK');
1262
$temphtml = popup_menu(-name=>'webdisk_dirnumitems',
1263
-values=>[10,12,14,16,18,20,22,24,26,28,30, 40, 50, 60, 70, 80, 90, 100, 150, 200, 500, 1000, 5000],
1264
-default=>$prefs{'webdisk_dirnumitems'},
1265
-accesskey=>'9',
1266
-override=>'1',
1267
defined($config_raw{'DEFAULT_webdisk_dirnumitems'})?('-disabled'=>'1'):());
1268
$html =~ s/\@\@\@DIRNUMITEMSMENU\@\@\@/$temphtml/;
1269
1270
$temphtml = checkbox(-name=>'webdisk_confirmmovecopy',
1271
-value=>'1',
1272
-checked=>$prefs{'webdisk_confirmmovecopy'},
1273
-label=>'',
1274
defined($config_raw{'DEFAULT_webdisk_confirmmovecopy'})?('-disabled'=>'1'):());
1275
$html =~ s/\@\@\@CONFIRMFILEMOVECOPY\@\@\@/$temphtml/;
1276
1277
$temphtml = checkbox(-name=>'webdisk_confirmdel',
1278
-value=>'1',
1279
-checked=>$prefs{'webdisk_confirmdel'},
1280
-label=>'',
1281
defined($config_raw{'DEFAULT_webdisk_confirmdel'})?('-disabled'=>'1'):());
1282
$html =~ s/\@\@\@CONFIRMFILEDEL\@\@\@/$temphtml/;
1283
1284
$temphtml = checkbox(-name=>'webdisk_confirmcompress',
1285
-value=>'1',
1286
-checked=>$prefs{'webdisk_confirmcompress'},
1287
-label=>'',
1288
defined($config_raw{'DEFAULT_webdisk_confirmcompress'})?('-disabled'=>'1'):());
1289
$html =~ s/\@\@\@CONFIRMFILECOMPRESS\@\@\@/$temphtml/;
1290
1291
$temphtml = popup_menu(-name=>'webdisk_fileeditcolumns',
1292
-values=>[80,82,84,86,88,90,92,94,96,98,100,110,120,160,192,256,512,1024,2048],
1293
-default=>$prefs{'webdisk_fileeditcolumns'},
1294
-override=>'1',
1295
defined($config_raw{'DEFAULT_webdisk_fileeditcolumns'})?('-disabled'=>'1'):());
1296
$html =~ s/\@\@\@FILEEDITCOLUMNSMENU\@\@\@/$temphtml/;
1297
1298
$temphtml = popup_menu(-name=>'webdisk_fileeditrows',
1299
-values=>[10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,50,60,70,80],
1300
-default=>$prefs{'webdisk_fileeditrows'},
1301
-override=>'1',
1302
defined($config_raw{'DEFAULT_webdisk_fileeditrows'})?('-disabled'=>'1'):());
1303
$html =~ s/\@\@\@FILEEDITROWSMENU\@\@\@/$temphtml/;
1304
1305
} else {
1306
templateblock_disable($html, 'WEBDISK');
1307
}
1308
1309
1310
$temphtml = checkbox(-name=>'uselightbar',
1311
-value=>'1',
1312
-checked=>$prefs{'uselightbar'},
1313
-label=>'',
1314
defined($config_raw{'DEFAULT_uselightbar'})?('-disabled'=>'1'):());
1315
$html =~ s/\@\@\@USELIGHTBARCHECKBOX\@\@\@/$temphtml/;
1316
1317
if ($config{'enable_webmail'}) {
1318
$temphtml = checkbox(-name=>'regexmatch',
1319
-value=>'1',
1320
-checked=>$prefs{'regexmatch'},
1321
-accesskey=>'0',
1322
-label=>'',
1323
defined($config_raw{'DEFAULT_regexmatch'})?('-disabled'=>'1'):());
1324
$html =~ s/\@\@\@REGEXMATCH\@\@\@/$temphtml/;
1325
1326
$temphtml = checkbox(-name=>'hideinternal',
1327
-value=>'1',
1328
-checked=>$prefs{'hideinternal'},
1329
-label=>'',
1330
defined($config_raw{'DEFAULT_hideinternal'})?('-disabled'=>'1'):());
1331
$html =~ s/\@\@\@HIDEINTERNAL\@\@\@/$temphtml/;
1332
1333
# Get a list of new mail sound
1334
my @sounds;
1335
opendir(SOUNDDIR, "$config{'ow_htmldir'}/sounds") or
1336
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $config{'ow_htmldir'}/sounds directory for reading! ($!)");
1337
while (defined(my $currsnd = readdir(SOUNDDIR))) {
1338
if (-f "$config{'ow_htmldir'}/sounds/$currsnd" && $currsnd =~ /^([^\.].*)$/) {
1339
push (@sounds, $1);
1340
}
1341
}
1342
closedir(SOUNDDIR) or
1343
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_close'} $config{'ow_htmldir'}/sounds! ($!)");
1344
1345
@sounds = sort(@sounds);
1346
unshift(@sounds, 'NONE');
1347
1348
$temphtml = popup_menu(-name=>'newmailsound',
1349
-labels=>{ 'NONE'=>$lang_text{'none'} },
1350
-values=>\@sounds,
1351
-default=>$prefs{'newmailsound'},
1352
-override=>'1',
1353
defined($config_raw{'DEFAULT_newmailsound'})?('-disabled'=>'1'):());
1354
my $soundurl="$config{'ow_htmlurl'}/sounds/";
1355
$temphtml .= "&nbsp;". iconlink("sound.gif", $lang_text{'testsound'}, qq|onclick="playsound('$soundurl', document.prefsform.newmailsound[document.prefsform.newmailsound.selectedIndex].value);"|);
1356
$html =~ s/\@\@\@NEWMAILSOUNDMENU\@\@\@/$temphtml/;
1357
1358
$temphtml = popup_menu(-name=>'newmailwindowtime',
1359
-values=>[0, 3, 5, 7, 10, 20, 30, 60, 120, 300, 600],
1360
-default=>$prefs{'newmailwindowtime'},
1361
-override=>'1',
1362
defined($config_raw{'DEFAULT_newmailwindowtime'})?('-disabled'=>'1'):());
1363
$html =~ s/\@\@\@NEWMAILWINDOWTIMEMENU\@\@\@/$temphtml/;
1364
1365
$temphtml = popup_menu(-name=>'mailsentwindowtime',
1366
-values=>[0, 3, 5, 7, 10, 20, 30],
1367
-default=>$prefs{'mailsentwindowtime'},
1368
-override=>'1',
1369
defined($config_raw{'DEFAULT_mailsentwindowtime'})?('-disabled'=>'1'):());
1370
$html =~ s/\@\@\@MAILSENTWINDOWTIMEMENU\@\@\@/$temphtml/;
1371
1372
if ($config{'enable_spellcheck'}) {
1373
templateblock_enable($html, 'SPELLCHECK');
1374
$temphtml = popup_menu(-name=>'dictionary',
1375
-values=>$config{'spellcheck_dictionaries'},
1376
-default=>$prefs{'dictionary'},
1377
-override=>'1',
1378
defined($config_raw{'DEFAULT_dictionary'})?('-disabled'=>'1'):());
1379
$html =~ s/\@\@\@DICTIONARYMENU\@\@\@/$temphtml/;
1380
} else {
1381
templateblock_disable($html, 'SPELLCHECK');
1382
}
1383
1384
my %dayslabels = ('0'=>$lang_text{'delatlogout'},'999999'=>$lang_text{'forever'} );
1385
$temphtml = popup_menu(-name=>'trashreserveddays',
1386
-values=>[0,1,2,3,4,5,6,7,14,21,30,60,90,180,999999],
1387
-default=>$prefs{'trashreserveddays'},
1388
-labels=>\%dayslabels,
1389
-override=>'1',
1390
defined($config_raw{'DEFAULT_trashreserveddays'})?('-disabled'=>'1'):());
1391
$html =~ s/\@\@\@TRASHRESERVEDDAYSMENU\@\@\@/$temphtml/;
1392
1393
$temphtml = popup_menu(-name=>'spamvirusreserveddays',
1394
-values=>[0,1,2,3,4,5,6,7,14,21,30,60,90,180,999999],
1395
-default=>$prefs{'spamvirusreserveddays'},
1396
-labels=>\%dayslabels,
1397
-override=>'1',
1398
defined($config_raw{'DEFAULT_spamvirusreserveddays'})?('-disabled'=>'1'):());
1399
$html =~ s/\@\@\@SPAMVIRUSRESERVEDDAYSMENU\@\@\@/$temphtml/;
1400
}
1401
1402
my @intervals;
1403
foreach my $value (3, 5, 10, 20, 30, 60, 120, 180) {
1404
push(@intervals, $value) if ($value>=$config{'min_refreshinterval'});
1405
}
1406
$temphtml = popup_menu(-name=>'refreshinterval',
1407
-values=>\@intervals,
1408
-default=>$prefs{'refreshinterval'},
1409
-labels=>\%lang_timelabels,
1410
-override=>'1',
1411
defined($config_raw{'DEFAULT_refreshinterval'})?('-disabled'=>'1'):());
1412
$html =~ s/\@\@\@REFRESHINTERVALMENU\@\@\@/$temphtml/;
1413
1414
$temphtml = popup_menu(-name=>'sessiontimeout',
1415
-values=>[10,30,60,120,180,360,720,1440],
1416
-default=>$prefs{'sessiontimeout'},
1417
-labels=>\%lang_timelabels,
1418
-override=>'1',
1419
defined($config_raw{'DEFAULT_sessiontimeout'})?('-disabled'=>'1'):());
1420
$html =~ s/\@\@\@SESSIONTIMEOUTMENU\@\@\@/$temphtml/;
1421
1422
# cancel button
1423
if ($prefs_caller eq "cal") {
1424
$temphtml = startform(-action=>"$config{'ow_cgiurl'}/openwebmail-cal.pl").
1425
ow::tool::hiddens(action=>$prefs{'calendar_defaultview'});
1426
} elsif ($prefs_caller eq "webdisk") {
1427
$temphtml = startform(-action=>"$config{'ow_cgiurl'}/openwebmail-webdisk.pl").
1428
ow::tool::hiddens(action=>'showdir');
1429
} elsif ($prefs_caller eq "read") {
1430
$temphtml = startform(-action=>"$config{'ow_cgiurl'}/openwebmail-read.pl").
1431
ow::tool::hiddens(action=>'readmessage');
1432
} else {
1433
$temphtml = startform(-action=>"$config{'ow_cgiurl'}/openwebmail-main.pl").
1434
ow::tool::hiddens(action=>'listmessages');
1435
}
1436
$temphtml .= $formparmstr;
1437
$html =~ s/\@\@\@STARTCANCELFORM\@\@\@/$temphtml/;
1438
$temphtml = submit(-name=>'cancelbutton',
1439
-accesskey=>'Q',
1440
-value=>$lang_text{'cancel'});
1441
$html =~ s/\@\@\@CANCELBUTTON\@\@\@/$temphtml/;
1442
}
1443
1444
$temphtml = submit(-name=>'savebutton',
1445
-accesskey=>'W',
1446
-value=>$lang_text{'save'});
1447
$html =~ s/\@\@\@SAVEBUTTON\@\@\@/$temphtml/;
1448
1449
$temphtml = end_form();
1450
$html =~ s/\@\@\@ENDFORM\@\@\@/$temphtml/g;
1451
1452
httpprint([], [htmlheader(), $html, htmlfooter(2)]);
1453
}
1454
########## END EDITPREFS #########################################
1455
1456
########## SAVEPREFS #############################################
1457
# if any param is not passed from the prefs form,
1458
# this routine will use old value will be used instead,
1459
# so we can use incomplete prefs form
1460
sub saveprefs {
1461
# create dir under ~/.openwebmail/
1462
check_and_create_dotdir(dotpath('/'));
1463
1464
if ($config{'enable_strictforward'} &&
1465
param('forwardaddress') =~ /[&;\`\<\>\(\)\{\}]/) {
1466
openwebmailerror(__FILE__, __LINE__, "$lang_text{'forward'} $lang_text{'email'} $lang_err{'has_illegal_chars'}");
1467
}
1468
1469
my %rcitem_yn=qw(
1470
bgrepeat 1
1471
useminisearchicon 1
1472
confirmmsgmovecopy 1
1473
smartdestination 1
1474
viewnextaftermsgmovecopy 1
1475
autopop3 1
1476
moveoldmsgfrominbox 1
1477
usefixedfont 1
1478
usesmileicon 1
1479
disablejs 1
1480
disableembcode 1
1481
showhtmlastext 1
1482
showimgaslink 1
1483
reparagraphorigmsg 1
1484
backupsentmsg 1
1485
filter_fakedsmtp 1
1486
filter_fakedfrom 1
1487
filter_fakedexecontenttype 1
1488
abook_defaultfilter 1
1489
calendar_showemptyhours 1
1490
calendar_reminderforglobal 1
1491
webdisk_confirmmovecopy 1
1492
webdisk_confirmdel 1
1493
webdisk_confirmcompress 1
1494
uselightbar 1
1495
regexmatch 1
1496
hideinternal 1
1497
);
1498
1499
my (%newprefs, $key, $value);
1500
foreach $key (@openwebmailrcitem) {
1501
$value = param($key);
1502
1503
if ($key eq 'bgurl') {
1504
my $background=param('background');
1505
if ($background eq "USERDEFINE") {
1506
$newprefs{$key}=$value if ($value ne "");
1507
} else {
1508
$newprefs{$key}="$config{'ow_htmlurl'}/images/backgrounds/$background";
1509
}
1510
next;
1511
} elsif ($key eq 'dateformat') {
1512
$newprefs{$key}=$value;
1513
next;
1514
}
1515
1516
$value =~ s/\.\.+//g;
1517
$value =~ s/[=\n\/\`\|\<\>;]//g; # remove dangerous char
1518
if ($key eq 'language') {
1519
foreach my $currlanguage (sort keys %ow::lang::languagenames) {
1520
if ($value eq $currlanguage) {
1521
$newprefs{$key}=$value; last;
1522
}
1523
}
1524
} elsif ($key eq 'sort') {
1525
# since there is already sort param inherited from outside prefs form,
1526
# so the prefs form pass the sort param as msgsort
1527
$newprefs{$key}=param('msgsort')||'date';
1528
} elsif ($key eq 'dictionary') {
1529
foreach my $currdictionary (@{$config{'spellcheck_dictionaries'}}) {
1530
if ($value eq $currdictionary) {
1531
$newprefs{$key}=$value; last;
1532
}
1533
}
1534
} elsif ($key eq 'filter_repeatlimit') {
1535
# if repeatlimit changed, redo filtering may be needed
1536
if ( $value != $prefs{'filter_repeatlimit'} ) {
1537
unlink(dotpath('filter.check'));
1538
}
1539
$newprefs{$key}=$value;
1540
} elsif ( defined($rcitem_yn{$key}) ) {
1541
$value=0 if ($value eq '');
1542
$newprefs{$key}=$value;
1543
} else {
1544
$newprefs{$key}=$value;
1545
}
1546
}
1547
1548
if ( ($newprefs{'filter_fakedsmtp'} && !$prefs{'filter_fakedsmtp'} ) ||
1549
($newprefs{'filter_fakedfrom'} && !$prefs{'filter_fakedfrom'} ) ||
1550
($newprefs{'filter_fakedexecontenttype'} && !$prefs{'filter_fakedexecontenttype'} ) ) {
1551
unlink(dotpath('filter.check'));
1552
}
1553
if ($newprefs{'trashreserveddays'} ne $prefs{'trashreserveddays'} ) {
1554
unlink(dotpath('trash.check'));
1555
}
1556
1557
$value = param('signature') || '';
1558
$value =~ s/\r\n/\n/g;
1559
if (length($value) > 500) { # truncate signature to 500 chars
1560
$value = substr($value, 0, 500);
1561
}
1562
$newprefs{'signature'}=$value;
1563
1564
my $forwardaddress=param('forwardaddress')||'';
1565
my $keeplocalcopy=param('keeplocalcopy')||0;
1566
my $autoreply=param('autoreply')||0;
1567
my $autoreplysubject=param('autoreplysubject')||'';
1568
my $autoreplytext=param('autoreplytext')||'';
1569
$autoreply=0 if (!$config{'enable_autoreply'});
1570
1571
my %userfrom=get_userfrom($logindomain, $loginuser, $user, $userrealname, dotpath('from.book'));
1572
1573
# save .forward file
1574
writedotforward($autoreply, $keeplocalcopy, $forwardaddress, keys %userfrom);
1575
1576
# save .vacation.msg
1577
if ($config{'enable_autoreply'}) {
1578
writedotvacationmsg($autoreply, $autoreplysubject, $autoreplytext, $newprefs{'signature'},
1579
$newprefs{'email'}, $userfrom{$newprefs{'email'}} );
1580
}
1581
1582
# save .signature
1583
my $signaturefile=dotpath('signature');
1584
if ( !-f $signaturefile && -f "$homedir/.signature" ) {
1585
$signaturefile="$homedir/.signature";
1586
}
1587
open (SIGNATURE,">$signaturefile") or
1588
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $signaturefile! ($!)");
1589
print SIGNATURE $newprefs{'signature'};
1590
close (SIGNATURE) or openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_close'} $signaturefile! ($!)");
1591
chown($uuid, (split(/\s+/,$ugid))[0], $signaturefile) if ($signaturefile eq "$homedir/.signature");
1592
1593
# save .openwebmailrc
1594
my $rcfile=dotpath('openwebmailrc');
1595
open (RC, ">$rcfile") or
1596
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $rcfile! ($!)");
1597
foreach my $key (@openwebmailrcitem) {
1598
print RC "$key=$newprefs{$key}\n";
1599
}
1600
close (RC) or openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_close'} $rcfile! ($!)");
1601
1602
%prefs = readprefs();
1603
%style = readstyle($prefs{'style'});
1604
loadlang($prefs{'language'});
1605
1606
my ($html, $temphtml);
1607
$html = applystyle(readtemplate("prefssaved.template"));
1608
1609
if ($prefs_caller eq "cal") {
1610
$temphtml .= startform(-action=>"$config{'ow_cgiurl'}/openwebmail-cal.pl").
1611
ow::tool::hiddens(action=>$prefs{'calendar_defaultview'});
1612
} elsif ($prefs_caller eq "webdisk") {
1613
$temphtml .= startform(-action=>"$config{'ow_cgiurl'}/openwebmail-webdisk.pl").
1614
ow::tool::hiddens(action=>'showdir');
1615
} elsif ($prefs_caller eq "read") {
1616
$temphtml .= startform(-action=>"$config{'ow_cgiurl'}/openwebmail-read.pl").
1617
ow::tool::hiddens(action=>'readmessage');
1618
} else {
1619
$temphtml .= startform(-action=>"$config{'ow_cgiurl'}/openwebmail-main.pl").
1620
ow::tool::hiddens(action=>'listmessages');
1621
}
1622
$temphtml .= ow::tool::hiddens(sessionid=>$thissession,
1623
folder=>$folder,
1624
message_id=>$messageid,
1625
sort=>$prefs{'sort'}, # use new prefs instead of orig $sort
1626
page=>$page);
1627
$html =~ s/\@\@\@STARTSAVEDFORM\@\@\@/$temphtml/;
1628
1629
$temphtml = submit("$lang_text{'continue'}");
1630
$html =~ s/\@\@\@CONTINUEBUTTON\@\@\@/$temphtml/;
1631
1632
$temphtml = end_form();
1633
$html =~ s/\@\@\@ENDFORM\@\@\@/$temphtml/g;
1634
1635
httpprint([], [htmlheader(), $html, htmlfooter(2)]);
1636
}
1637
########## END SAVEPREFS #########################################
1638
1639
########## R/W DOTFORWARD/DOTVACATIONMSG #########################
1640
sub readdotforward {
1641
my $forwardtext;
1642
1643
if (open(FOR, "$homedir/.forward")) {
1644
local $/; undef $/; $forwardtext=<FOR>; # read whole file at once
1645
close(FOR);
1646
}
1647
1648
# get flags and forward list with selfemail and vacationpipe removed
1649
my ($autoreply, $keeplocalcopy, @forwards)=splitforwardtext($forwardtext, 0, 0);
1650
$keeplocalcopy=0 if ($#forwards<0);
1651
return ($autoreply, $keeplocalcopy, @forwards);
1652
}
1653
1654
sub writedotforward {
1655
my ($autoreply, $keeplocalcopy, $forwardtext, @userfrom) = @_;
1656
my @forwards=();
1657
1658
# don't allow forward to self (avoid mail loops!)
1659
# splitforwardtext will remove self emails
1660
($autoreply, $keeplocalcopy, @forwards)=splitforwardtext( $forwardtext, $autoreply, $keeplocalcopy );
1661
1662
# if no other forwards, keeplocalcopy is required
1663
# only if autoreply is on or if this is a virtual user
1664
if ($#forwards<0) {
1665
if ( $autoreply or $config{'auth_module'} eq 'auth_vdomain.pl') {
1666
$keeplocalcopy=1;
1667
} else {
1668
$keeplocalcopy=0
1669
}
1670
}
1671
1672
# nothing enabled, clean .forward
1673
if (!$autoreply && !$keeplocalcopy && $#forwards<0 ) {
1674
unlink("$homedir/.forward");
1675
return 0;
1676
}
1677
1678
if ($autoreply) {
1679
# if this user has multiple fromemail or be mapped from another loginname
1680
# then use -a with vacation.pl to add these aliases for to: and cc: checking
1681
my $aliasparm="";
1682
foreach (sort_emails_by_domainnames($config{'domainnames'}, @userfrom)) {
1683
$aliasparm .= "-a $_ ";
1684
}
1685
$aliasparm .= "-a $loginname " if ($loginname ne $user);
1686
1687
my $vacationuser = $user;
1688
if ($config{'auth_module'} eq 'auth_vdomain.pl') {
1689
$vacationuser = "-p$homedir nobody";
1690
}
1691
if (length("xxx$config{'vacationpipe'} $aliasparm $vacationuser")<250) {
1692
push(@forwards, qq!"| $config{'vacationpipe'} $aliasparm $vacationuser"!);
1693
} else {
1694
push(@forwards, qq!"| $config{'vacationpipe'} -j $vacationuser"!);
1695
}
1696
}
1697
1698
if ($keeplocalcopy) {
1699
if ($config{'auth_module'} eq 'auth_vdomain.pl') {
1700
push(@forwards, vdomain_userspool($user,$homedir));
1701
} else {
1702
push(@forwards, "\\$user");
1703
}
1704
}
1705
1706
open(FOR, ">$homedir/.forward") or return -1;
1707
print FOR join("\n", @forwards), "\n";
1708
close FOR;
1709
chown($uuid, (split(/\s+/,$ugid))[0], "$homedir/.forward");
1710
chmod(0600, "$homedir/.forward");
1711
}
1712
1713
sub readdotvacationmsg {
1714
my ($subject, $text)=("", "");
1715
1716
if (open(MSG, "$homedir/.vacation.msg")) {
1717
my $inheader=1;
1718
while (<MSG>) {
1719
chomp($_);
1720
if ($inheader==0) {
1721
$text.="$_\n";
1722
next;
1723
}
1724
if (/^Subject:\s*(.*)/i) {
1725
$subject=$1;
1726
} elsif (/^[A-Za-z0-9\-]+: /i) {
1727
next;
1728
} else {
1729
$inheader=0;
1730
$text.="$_\n";
1731
}
1732
}
1733
close MSG;
1734
}
1735
1736
$subject = $config{'default_autoreplysubject'} if ($subject eq "");
1737
$subject =~ s/\s/ /g;
1738
$subject =~ s/^\s+//;
1739
$subject =~ s/\s+$//;
1740
1741
# remove signature
1742
my $s=$prefs{'signature'};
1743
$s =~ s/\r\n/\n/g;
1744
my $i=rindex($text, $s);
1745
1746
$text=substr($text, 0, $i) if ($i>0);
1747
1748
$text= $config{'default_autoreplytext'} if ($text eq "");
1749
$text =~ s/\r\n/\n/g;
1750
$text =~ s/^\s+//s;
1751
$text =~ s/\s+$//s;
1752
1753
return($subject, $text);
1754
}
1755
1756
sub writedotvacationmsg {
1757
my ($autoreply, $subject, $text, $signature, $email, $userfrom)=@_;
1758
1759
my $from;
1760
if ($userfrom) {
1761
$from=qq|"$userfrom" <$email>|;
1762
} else {
1763
$from=$email;
1764
}
1765
1766
if ($autoreply) {
1767
local $|=1; # flush all output
1768
if ( fork() == 0 ) { # child
1769
close(STDIN); close(STDOUT); close(STDERR);
1770
ow::suid::drop_ruid_rgid();
1771
# set enviro's for vacation program
1772
$ENV{'USER'}=$user;
1773
$ENV{'LOGNAME'}=$user;
1774
$ENV{'HOME'}=$homedir;
1775
delete $ENV{'GATEWAY_INTERFACE'};
1776
my @cmd;
1777
foreach (split(/\s/, $config{'vacationinit'})) {
1778
/^(.*)$/ && push(@cmd, $1); # untaint all argument
1779
}
1780
exec(@cmd);
1781
exit 0; # should never reach here
1782
}
1783
}
1784
1785
$subject =~ s/\s/ /g;
1786
$subject =~ s/^\s+//;
1787
$subject =~ s/\s+$//;
1788
$subject = $config{'default_autoreplysubject'} if ($subject eq "");
1789
1790
$text =~ s/\r\n/\n/g;
1791
$text =~ s/^\s+//s;
1792
$text =~ s/\s+$//s;
1793
$text = $config{'default_autoreplytext'} if ($text eq "");
1794
1795
if (length($text) > 500) { # truncate to 500 chars
1796
$text = substr($text, 0, 500);
1797
}
1798
1799
open(MSG, ">$homedir/.vacation.msg") or return -2;
1800
print MSG "From: $from\n".
1801
"Subject: $subject\n\n".
1802
"$text\n\n".
1803
$signature; # append signature
1804
close MSG;
1805
chown($uuid, (split(/\s+/,$ugid))[0], "$homedir/.vacation.msg");
1806
}
1807
1808
sub splitforwardtext {
1809
my ($forwardtext, $autoreply, $keeplocalcopy)=@_;
1810
# remove self email and vacation from forward list
1811
# set keeplocalcopy if self email found
1812
# set autoreply if vacation found
1813
my $vacation_bin=(split(/\s+/,$config{'vacationpipe'}))[0];
1814
my @forwards=();
1815
foreach my $name ( split(/[,;\n\r]+/, $forwardtext) ) {
1816
$name=~s/^\s+//; $name=~s/\s+$//;
1817
next if ( $name=~/^$/ );
1818
if ($name=~/$vacation_bin/) { $autoreply=1; }
1819
elsif ( is_selfemail($name) ) { $keeplocalcopy=1; }
1820
else { push(@forwards, $name); }
1821
}
1822
return ($autoreply, $keeplocalcopy, @forwards);
1823
}
1824
1825
sub is_selfemail {
1826
my ($email)=@_;
1827
if ( $email=~/$user\@(.+)/i ) {
1828
foreach ( @{$config{'domainnames'}} ) {
1829
return 1 if (lc($1) eq lc($_));
1830
}
1831
}
1832
return 1 if ($email eq "\\$user" || $email eq $user);
1833
return 1 if ($config{'auth_module'} eq 'auth_vdomain.pl' and $email eq vdomain_userspool($user,$homedir));
1834
return 0;
1835
}
1836
########## END R/W DOTFORWARD/DOTVACATIONMSG #####################
1837
1838
########## EDITPASSWORD ##########################################
1839
sub editpassword {
1840
my ($html, $temphtml);
1841
$html = applystyle(readtemplate("chpwd.template"));
1842
1843
my $chpwd_url="$config{'ow_cgiurl'}/openwebmail-prefs.pl";
1844
if (cookie("openwebmail-ssl")) { # backto SSL
1845
$chpwd_url="https://$ENV{'HTTP_HOST'}$chpwd_url" if ($chpwd_url!~s!^https?://!https://!i);
1846
}
1847
$temphtml = startform(-name=>'passwordform',
1848
-action=>$chpwd_url).
1849
ow::tool::hiddens(action=>'changepassword').
1850
$formparmstr;
1851
$html =~ s/\@\@\@STARTFORM\@\@\@/$temphtml/;
1852
1853
# display virtual or user, but actually not used, chnagepassword grab user from sessionid
1854
$temphtml = textfield(-name=>'loginname',
1855
-default=>$loginname,
1856
-size=>'10',
1857
-disabled=>1,
1858
-override=>'1');
1859
$html =~ s/\@\@\@LOGINNAMEFIELD\@\@\@/$temphtml/;
1860
1861
$temphtml = password_field(-name=>'oldpassword',
1862
-default=>'',
1863
-size=>'10',
1864
-override=>'1');
1865
$html =~ s/\@\@\@OLDPASSWORDFIELD\@\@\@/$temphtml/;
1866
1867
$temphtml = password_field(-name=>'newpassword',
1868
-default=>'',
1869
-size=>'10',
1870
-override=>'1');
1871
$html =~ s/\@\@\@NEWPASSWORDFIELD\@\@\@/$temphtml/;
1872
1873
$temphtml = password_field(-name=>'confirmnewpassword',
1874
-default=>'',
1875
-size=>'10',
1876
-override=>'1');
1877
$html =~ s/\@\@\@CONFIRMNEWPASSWORDFIELD\@\@\@/$temphtml/;
1878
1879
$temphtml = submit(-name=> $lang_text{'changepwd'},
1880
-onClick=>"return changecheck()");
1881
$html =~ s/\@\@\@CHANGEBUTTON\@\@\@/$temphtml/;
1882
1883
$temphtml = end_form();
1884
$html =~ s/\@\@\@ENDFORM\@\@\@/$temphtml/g;
1885
1886
$temphtml = startform(-action=>"$config{'ow_cgiurl'}/openwebmail-prefs.pl") .
1887
ow::tool::hiddens(action=>'editprefs').
1888
$formparmstr.
1889
submit("$lang_text{'cancel'}").
1890
end_form();
1891
$html =~ s/\@\@\@CANCELBUTTON\@\@\@/$temphtml/;
1892
1893
$html =~ s/\@\@\@PASSWDMINLEN\@\@\@/$config{'passwd_minlen'}/g;
1894
1895
httpprint([], [htmlheader(), $html, htmlfooter(2)]);
1896
}
1897
########## END EDITPASSWORD ######################################
1898
1899
########## CHANGEPASSWORD ########################################
1900
sub changepassword {
1901
my $oldpassword=param('oldpassword');
1902
my $newpassword=param('newpassword');
1903
my $confirmnewpassword=param('confirmnewpassword');
1904
1905
my ($html, $temphtml);
1906
if ( length($newpassword) < $config{'passwd_minlen'} ) {
1907
$html = readtemplate("chpwdfailed.template");
1908
$html =~ s/\@\@\@ERRORMSG\@\@\@/$lang_err{'pwd_tooshort'}/;
1909
$html =~ s/\@\@\@PASSWDMINLEN\@\@\@/$config{'passwd_minlen'}/;
1910
} elsif ( $config{'enable_strictpwd'} &&
1911
($newpassword=~/^\d+$/ || $newpassword=~/^[A-Za-z]+$/) ) {
1912
$html = readtemplate("chpwdfailed.template");
1913
$html =~ s/\@\@\@ERRORMSG\@\@\@/$lang_err{'pwd_toosimple'}/;
1914
} elsif ( $newpassword ne $confirmnewpassword ) {
1915
$html = readtemplate("chpwdfailed.template");
1916
$html =~ s/\@\@\@ERRORMSG\@\@\@/$lang_err{'pwd_confirmmismatch'}/;
1917
} else {
1918
my ($origruid, $origeuid)=($<, $>);
1919
my ($errorcode, $errormsg);
1920
if ($config{'auth_withdomain'}) {
1921
($errorcode, $errormsg)=ow::auth::change_userpassword(\%config, "$user\@$domain", $oldpassword, $newpassword);
1922
} else {
1923
($errorcode, $errormsg)=ow::auth::change_userpassword(\%config, $user, $oldpassword, $newpassword);
1924
}
1925
if ($errorcode==0) {
1926
# update authpop3book since it will be used to fetch mail from remote pop3 in this active session
1927
if ($config{'auth_module'} eq 'auth_ldap_vpopmail.pl') {
1928
update_authpop3book(dotpath('authpop3.book'), $domain, $user, $newpassword);
1929
}
1930
writelog("change password");
1931
writehistory("change password");
1932
$html = readtemplate("chpwdok.template");
1933
} else {
1934
writelog("change password error - $config{'auth_module'}, ret $errorcode, $errormsg");
1935
writehistory("change password error - $config{'auth_module'}, ret $errorcode, $errormsg");
1936
my $webmsg='';
1937
if ($errorcode==-1) {
1938
$webmsg=$lang_err{'func_notsupported'};
1939
} elsif ($errorcode==-2) {
1940
$webmsg=$lang_err{'param_fmterr'};
1941
} elsif ($errorcode==-3) {
1942
$webmsg=$lang_err{'auth_syserr'};
1943
} elsif ($errorcode==-4) {
1944
$webmsg=$lang_err{'pwd_incorrect'};
1945
} else {
1946
$webmsg="Unknow error code $errorcode";
1947
}
1948
$html = readtemplate("chpwdfailed.template");
1949
$html =~ s/\@\@\@ERRORMSG\@\@\@/$webmsg/;
1950
}
1951
}
1952
1953
$html = applystyle($html);
1954
1955
my $url="$config{'ow_cgiurl'}/openwebmail-prefs.pl";
1956
if ( !$config{'stay_ssl_afterlogin'} && # leave SSL
1957
($ENV{'HTTPS'}=~/on/i || $ENV{'SERVER_PORT'}==443) ) {
1958
$url="http://$ENV{'HTTP_HOST'}$url" if ($url!~s!^https?://!http://!i);
1959
}
1960
$temphtml = startform(-action=>$url) .
1961
ow::tool::hiddens(action=>'editprefs').
1962
$formparmstr.
1963
submit("$lang_text{'backto'} $lang_text{'userprefs'}").
1964
end_form();
1965
$html =~ s/\@\@\@CONTINUEBUTTON\@\@\@/$temphtml/;
1966
1967
httpprint([], [htmlheader(), $html, htmlfooter(2)]);
1968
}
1969
########## END CHANGEPASSWORD ####################################
1970
1971
########## LOGINHISTORY ##########################################
1972
sub viewhistory {
1973
my ($html, $temphtml);
1974
$html = applystyle(readtemplate("history.template"));
1975
1976
$temphtml = iconlink("backtofolder.gif", "$lang_text{'backto'} $lang_text{'userprefs'}", qq|accesskey="F" href="$config{'ow_cgiurl'}/openwebmail-prefs.pl?action=editprefs&amp;$urlparmstr"|);
1977
$html =~ s/\@\@\@MENUBARLINKS\@\@\@/$temphtml/;
1978
1979
$temphtml="";
1980
1981
my $historyfile=dotpath('history.log');
1982
open (HISTORYLOG, $historyfile);
1983
1984
my $bgcolor = $style{"tablerow_light"};
1985
while (<HISTORYLOG>) {
1986
chomp($_);
1987
$_=~/^(.*?) - \[(\d+)\] \((.*?)\) (.*)$/;
1988
1989
my $record;
1990
my ($timestamp, $pid, $ip, $misc)=($1, $2, $3, $4);
1991
my ($u, $event, $desc, $desc2)=split(/ \- /, $misc, 4);
1992
$desc=ow::htmltext::str2html($desc);
1993
foreach my $field ($timestamp, $ip, $u, $event, $desc) {
1994
if ($event=~/error/i) {
1995
$record.=qq|<td bgcolor=$bgcolor align="center"><font color="#cc0000"><b>$field</font></b></td>\n|;
1996
} elsif ($event=~/warning/i || $desc=~/(?:spam|virus) .* found/i) {
1997
$record.=qq|<td bgcolor=$bgcolor align="center"><font color="#0000cc"><b>$field</font></b></td>\n|;
1998
} else {
1999
$record.=qq|<td bgcolor=$bgcolor align="center">$field</td>\n|;
2000
}
2001
}
2002
$temphtml = '<tr>' . $record . '</tr>' . $temphtml;
2003
2004
if ($bgcolor eq $style{"tablerow_dark"}) {
2005
$bgcolor = $style{"tablerow_light"};
2006
} else {
2007
$bgcolor = $style{"tablerow_dark"};
2008
}
2009
}
2010
close(HISTORYLOG);
2011
$html =~ s/\@\@\@LOGINHISTORY\@\@\@/$temphtml/;
2012
2013
httpprint([], [htmlheader(), $html, htmlfooter(2)]);
2014
}
2015
########## END LOGINHISTORY ######################################
2016
2017
########## EDITFROMS #############################################
2018
sub editfroms {
2019
my ($html, $temphtml);
2020
$html = applystyle(readtemplate("editfroms.template"));
2021
2022
my $frombookfile=dotpath('from.book');
2023
my $frombooksize = ( -s $frombookfile ) || 0;
2024
my $freespace = int($config{'maxbooksize'} - ($frombooksize/1024) + .5);
2025
my %userfrom=get_userfrom($logindomain, $loginuser, $user, $userrealname, $frombookfile);
2026
2027
$html =~ s/\@\@\@FREESPACE\@\@\@/$freespace $lang_sizes{'kb'}/;
2028
2029
$temphtml = iconlink("backtofolder.gif", "$lang_text{'backto'} $lang_text{'userprefs'}", qq|accesskey="F" href="$config{'ow_cgiurl'}/openwebmail-prefs.pl?action=editprefs&amp;$urlparmstr"|);
2030
$html =~ s/\@\@\@MENUBARLINKS\@\@\@/$temphtml/;
2031
2032
$temphtml = startform(-action=>"$config{'ow_cgiurl'}/openwebmail-prefs.pl",
2033
-name=>'newfrom').
2034
ow::tool::hiddens(action=>'addfrom').
2035
$formparmstr;
2036
$html =~ s/\@\@\@STARTFROMFORM\@\@\@/$temphtml/;
2037
2038
if (defined($config{'DEFAULT_realname'})) {
2039
$temphtml = textfield(-name=>'realname',
2040
-default=>$config{'DEFAULT_realname'},
2041
-size=>'20',
2042
-disabled=>'1',
2043
-override=>'1');
2044
} else {
2045
$temphtml = textfield(-name=>'realname',
2046
-default=>'',
2047
-size=>'20',
2048
-override=>'1');
2049
}
2050
$html =~ s/\@\@\@REALNAMEFIELD\@\@\@/$temphtml/;
2051
2052
$temphtml = textfield(-name=>'email',
2053
-default=>'',
2054
-size=>'30',
2055
-override=>'1');
2056
$html =~ s/\@\@\@EMAILFIELD\@\@\@/$temphtml/;
2057
2058
if ($config{'frombook_for_realname_only'}) {
2059
$temphtml = submit(-name=>$lang_text{'modify'},
2060
-class=>"medtext");
2061
} else {
2062
$temphtml = submit(-name=>$lang_text{'addmod'},
2063
-class=>"medtext");
2064
}
2065
$html =~ s/\@\@\@ADDBUTTON\@\@\@/$temphtml/;
2066
2067
$temphtml = end_form();
2068
$html =~ s/\@\@\@ENDFORM\@\@\@/$temphtml/g;
2069
2070
my $bgcolor = $style{"tablerow_dark"};
2071
my ($email, $realname);
2072
2073
$temphtml = '';
2074
foreach $email (sort_emails_by_domainnames($config{'domainnames'}, keys %userfrom)) {
2075
$realname=$userfrom{$email};
2076
2077
my ($r, $e)=($realname, $email);
2078
$r=~s/'/\\'/; $e=~s/'/\\'/; # escape ' for javascript
2079
$temphtml .= qq|<tr>|.
2080
qq|<td bgcolor=$bgcolor>$realname</td>|.
2081
qq|<td bgcolor=$bgcolor><a href="Javascript:Update('$r','$e')">$email</a></td>|.
2082
qq|<td bgcolor=$bgcolor align="center">|.
2083
start_form(-action=>"$config{'ow_cgiurl'}/openwebmail-prefs.pl").
2084
ow::tool::hiddens(action=>'deletefrom',
2085
email=>$email).
2086
$formparmstr .
2087
submit(-name=>$lang_text{'delete'},
2088
-class=>"medtext").
2089
qq|</td></tr>|.
2090
end_form();
2091
2092
if ($bgcolor eq $style{"tablerow_dark"}) {
2093
$bgcolor = $style{"tablerow_light"};
2094
} else {
2095
$bgcolor = $style{"tablerow_dark"};
2096
}
2097
}
2098
$html =~ s/\@\@\@FROMS\@\@\@/$temphtml/;
2099
2100
httpprint([], [htmlheader(), $html, htmlfooter(2)]);
2101
}
2102
########## END EDITFROMS #########################################
2103
2104
########## MODFROM ###############################################
2105
sub modfrom {
2106
my $mode = shift;
2107
my $realname = param('realname') || '';
2108
my $email = param('email') || '';
2109
$realname =~ s/^\s*//; $realname =~ s/\s*$//;
2110
$email =~ s/[\<\>\[\]\\,;:\`\"\s]//g;
2111
2112
my $frombookfile=dotpath('from.book');
2113
2114
if ($email) {
2115
my %userfrom=get_userfrom($logindomain, $loginuser, $user, $userrealname, $frombookfile);
2116
2117
if ($mode eq 'delete') {
2118
delete $userfrom{$email};
2119
} else {
2120
if ( (-s $frombookfile) >= ($config{'maxbooksize'} * 1024) ) {
2121
openwebmailerror(__FILE__, __LINE__, qq|$lang_err{'abook_toobig'} <a href="$config{'ow_cgiurl'}/openwebmail-prefs.pl?action=editfroms&amp;$urlparmstr">$lang_err{'back'}</a>$lang_err{'tryagain'}|);
2122
}
2123
if (!$config{'frombook_for_realname_only'} || defined($userfrom{$email}) ) {
2124
$userfrom{$email} = $realname;
2125
}
2126
}
2127
2128
open (FROMBOOK, ">$frombookfile" ) or
2129
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $frombookfile! ($!)");
2130
foreach $email (sort_emails_by_domainnames($config{'domainnames'}, keys %userfrom)) {
2131
print FROMBOOK "$email\@\@\@$userfrom{$email}\n";
2132
}
2133
close (FROMBOOK) or openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_close'} $frombookfile! ($!)");
2134
}
2135
2136
editfroms();
2137
}
2138
########## END MODFROM ###########################################
2139
2140
########## EDITPOP3 ##############################################
2141
sub editpop3 {
2142
my ($html, $temphtml);
2143
$html = applystyle(readtemplate("editpop3.template"));
2144
2145
my $is_ssl_supported=ow::tool::has_module('IO/Socket/SSL.pm');
2146
2147
my %accounts;
2148
my $pop3bookfile = dotpath('pop3.book');
2149
my $pop3booksize = ( -s $pop3bookfile ) || 0;
2150
my $freespace = int($config{'maxbooksize'} - ($pop3booksize/1024) + .5);
2151
2152
if (readpop3book($pop3bookfile, \%accounts) <0) {
2153
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $pop3bookfile!");
2154
}
2155
2156
$html =~ s/\@\@\@FREESPACE\@\@\@/$freespace $lang_sizes{'kb'}/;
2157
2158
$temphtml = iconlink("backtofolder.gif", "$lang_text{'backto'} $lang_text{'userprefs'}", qq|accesskey="F" href="$config{'ow_cgiurl'}/openwebmail-prefs.pl?action=editprefs&amp;$urlparmstr"|);
2159
$temphtml .= "&nbsp;\n";
2160
$temphtml .= iconlink("pop3.gif", $lang_text{'retr_pop3s'}, qq|accesskey="G" href="$config{'ow_cgiurl'}/openwebmail-main.pl?action=pop3fetches&amp;$urlparmstr"|). qq| \n|;
2161
$html =~ s/\@\@\@MENUBARLINKS\@\@\@/$temphtml/;
2162
2163
$temphtml = startform(-action=>"$config{'ow_cgiurl'}/openwebmail-prefs.pl",
2164
-name=>'newpop3').
2165
ow::tool::hiddens(action=>'addpop3').
2166
$formparmstr;
2167
$html =~ s/\@\@\@STARTPOP3FORM\@\@\@/$temphtml/;
2168
2169
$temphtml = textfield(-name=>'pop3host',
2170
-default=>'',
2171
-size=>'24',
2172
-onChange=>"JavaScript:document.newpop3.pop3passwd.value='';",
2173
-override=>'1');
2174
$html =~ s/\@\@\@HOSTFIELD\@\@\@/$temphtml/;
2175
2176
$temphtml = textfield(-name=>'pop3port',
2177
-default=>$config{'pop3_usessl_by_default'} ? '995' : '110',
2178
-size=>'4',
2179
-onChange=>"JavaScript:document.newpop3.pop3passwd.value='';",
2180
-override=>'1');
2181
$html =~ s/\@\@\@PORTFIELD\@\@\@/$temphtml/;
2182
2183
$temphtml = textfield(-name=>'pop3user',
2184
-default=>'',
2185
-size=>'16',
2186
-onChange=>"JavaScript:document.newpop3.pop3passwd.value='';",
2187
-override=>'1');
2188
$html =~ s/\@\@\@REALNAMEFIELD\@\@\@/$temphtml/;
2189
2190
$temphtml = password_field(-name=>'pop3passwd',
2191
-default=>'',
2192
-size=>'8',
2193
-override=>'1');
2194
$html =~ s/\@\@\@PASSFIELD\@\@\@/$temphtml/;
2195
2196
# if hidden, disable user to change this option
2197
if ($config{'pop3_delmail_hidden'}) {
2198
templateblock_disable($html, 'DELPOP3STR');
2199
$temphtml = ow::tool::hiddens(pop3del=>$config{'pop3_delmail_by_default'});
2200
$html =~ s/\@\@\@DELCHECKBOX\@\@\@/$temphtml/;
2201
} else {
2202
templateblock_enable($html, 'DELPOP3STR');
2203
$temphtml = checkbox(-name=>'pop3del',
2204
-value=>'1',
2205
-checked=>$config{'pop3_delmail_by_default'},
2206
-label=>'');
2207
$html =~ s/\@\@\@DELCHECKBOX\@\@\@/$temphtml/;
2208
}
2209
2210
if ($is_ssl_supported) {
2211
templateblock_enable($html, 'USEPOP3SSL');
2212
$temphtml = checkbox(-name=>'pop3ssl',
2213
-value=>'1',
2214
-checked=>$config{'pop3_usessl_by_default'},
2215
-label=>'',
2216
-onClick=>'ssl();');
2217
$html =~ s/\@\@\@USEPOP3SSLCHECKBOX\@\@\@/$temphtml/;
2218
} else {
2219
templateblock_disable($html, 'USEPOP3SSL');
2220
$temphtml = ow::tool::hiddens(pop3ssl=>'0');
2221
$html =~ s/\@\@\@USEPOP3SSLCHECKBOX\@\@\@/$temphtml/;
2222
}
2223
2224
$temphtml = checkbox(-name=>'enable',
2225
-value=>'1',
2226
-checked=>'checked',
2227
-label=>'');
2228
$html =~ s/\@\@\@ENABLECHECKBOX\@\@\@/$temphtml/;
2229
2230
$temphtml = submit(-name=>$lang_text{'addmod'},
2231
-class=>"medtext");
2232
$html =~ s/\@\@\@ADDBUTTON\@\@\@/$temphtml/;
2233
2234
$temphtml = end_form();
2235
$html =~ s/\@\@\@ENDFORM\@\@\@/$temphtml/g;
2236
2237
$temphtml = '';
2238
my $bgcolor = $style{"tablerow_dark"};
2239
foreach (sort values %accounts) {
2240
my ($pop3host, $pop3port, $pop3ssl, $pop3user, $pop3passwd, $pop3del, $enable) = split(/\@\@\@/, $_);
2241
2242
$temphtml .= qq|<tr>\n|.
2243
qq|<td bgcolor=$bgcolor><a href="Javascript:Update('$pop3host','$pop3port','$pop3ssl','$pop3user','******','$pop3del','$enable')">$pop3host</a></td>\n|.
2244
qq|<td bgcolor=$bgcolor>$pop3port</td>\n|;
2245
2246
$temphtml .= qq|<td align="center" bgcolor=$bgcolor>\n|;
2247
if ($is_ssl_supported) {
2248
if ( $pop3ssl == 1) {
2249
$temphtml .= $lang_text{'yes'};
2250
} else {
2251
$temphtml .= $lang_text{'no'};
2252
}
2253
} else {
2254
$temphtml .= "&nbsp;";
2255
}
2256
$temphtml .= "</td>";
2257
2258
$temphtml .= qq|<td align="center" bgcolor=$bgcolor><a href="$config{'ow_cgiurl'}/openwebmail-main.pl?action=pop3fetch&pop3user=$pop3user&pop3host=$pop3host&pop3port=$pop3port&pop3user=$pop3user&$urlparmstr">$pop3user</a></td>\n|.
2259
qq|<td align="center" bgcolor=$bgcolor>\*\*\*\*\*\*</td>\n|.
2260
qq|<td align="center" bgcolor=$bgcolor>\n|;
2261
2262
if ($config{'pop3_delmail_hidden'}) {
2263
$temphtml .= "&nbsp;";
2264
} else {
2265
if ( $pop3del == 1) {
2266
$temphtml .= $lang_text{'delete'};
2267
} else {
2268
$temphtml .= $lang_text{'reserve'};
2269
}
2270
}
2271
$temphtml .= qq|</td><td align="center" bgcolor=$bgcolor>\n|;
2272
if ( $enable == 1) {
2273
$temphtml .= $lang_text{'enable'};
2274
} else {
2275
$temphtml .= $lang_text{'disable'};
2276
}
2277
$temphtml .= "</td>";
2278
2279
$temphtml .= qq|<td bgcolor=$bgcolor align="center">|.
2280
start_form(-action=>"$config{'ow_cgiurl'}/openwebmail-prefs.pl").
2281
ow::tool::hiddens(action=>'deletepop3',
2282
pop3host=>$pop3host,
2283
pop3port=>$pop3port,
2284
pop3user=>$pop3user).
2285
$formparmstr.
2286
submit(-name=>$lang_text{'delete'},
2287
-class=>"medtext").
2288
qq|</td></tr>|.
2289
end_form();
2290
2291
if ($bgcolor eq $style{"tablerow_dark"}) {
2292
$bgcolor = $style{"tablerow_light"};
2293
} else {
2294
$bgcolor = $style{"tablerow_dark"};
2295
}
2296
}
2297
$html =~ s/\@\@\@ADDRESSES\@\@\@/$temphtml/;
2298
2299
httpprint([], [htmlheader(), $html, htmlfooter(2)]);
2300
}
2301
########## END EDITPOP3 ##########################################
2302
2303
########## MODPOP3 ###############################################
2304
sub modpop3 {
2305
my $mode = shift;
2306
my ($pop3host, $pop3port, $pop3ssl, $pop3user, $pop3passwd, $pop3del, $enable);
2307
$pop3host = param('pop3host') || '';
2308
$pop3port = param('pop3port') || '110';
2309
$pop3ssl = param('pop3ssl') || 0;
2310
$pop3user = param('pop3user') || '';
2311
$pop3passwd = param('pop3passwd') || '';
2312
$pop3del = param('pop3del') || 0;
2313
$enable = param('enable') || 0;
2314
2315
# strip beginning and trailing spaces from hash key
2316
$pop3host =~ s/^\s*//;
2317
$pop3host =~ s/\s*$//;
2318
$pop3host =~ s/[#&=\?]//g;
2319
2320
$pop3port =~ s/^\s*//;
2321
$pop3port =~ s/\s*$//;
2322
2323
$pop3user =~ s/^\s*//;
2324
$pop3user =~ s/\s*$//;
2325
$pop3user =~ s/[#&=\?]//g;
2326
2327
$pop3passwd =~ s/^\s*//;
2328
$pop3passwd =~ s/\s*$//;
2329
2330
my $pop3bookfile = dotpath('pop3.book');
2331
2332
if ( ($pop3host && $pop3user && $pop3passwd)
2333
|| (($mode eq 'delete') && $pop3host && $pop3user) ) {
2334
my %accounts;
2335
2336
if (readpop3book($pop3bookfile, \%accounts) <0) {
2337
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $pop3bookfile!");
2338
}
2339
2340
if ($mode eq 'delete') {
2341
delete $accounts{"$pop3host:$pop3port\@\@\@$pop3user"};
2342
} else {
2343
if ( (-s $pop3bookfile) >= ($config{'maxbooksize'} * 1024) ) {
2344
openwebmailerror(__FILE__, __LINE__, qq|$lang_err{'abook_toobig'} <a href="$config{'ow_cgiurl'}/openwebmail-prefs.pl?action=editpop3&amp;$urlparmstr">$lang_err{'back'}</a> $lang_err{'tryagain'}|);
2345
}
2346
foreach ( @{$config{'pop3_disallowed_servers'}} ) {
2347
if ($pop3host eq $_) {
2348
openwebmailerror(__FILE__, __LINE__, "$lang_err{'disallowed_pop3'} $pop3host");
2349
}
2350
}
2351
$pop3port=110 if ($pop3port!~/^\d+$/);
2352
if ( defined($accounts{"$pop3host:$pop3port\@\@\@$pop3user"}) &&
2353
$pop3passwd eq "******") {
2354
$pop3passwd=(split(/\@\@\@/, $accounts{"$pop3host:$pop3port\@\@\@$pop3user"}))[4];
2355
}
2356
$accounts{"$pop3host:$pop3port\@\@\@$pop3user"}="$pop3host\@\@\@$pop3port\@\@\@$pop3ssl\@\@\@$pop3user\@\@\@$pop3passwd\@\@\@$pop3del\@\@\@$enable";
2357
}
2358
2359
if (writepop3book($pop3bookfile, \%accounts)<0) {
2360
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $pop3bookfile!");
2361
}
2362
2363
# rmove unused pop3 uidl db
2364
if (opendir(POP3DIR, dotpath('pop3'))) {
2365
my @delfiles;
2366
while (defined(my $filename = readdir(POP3DIR))) {
2367
if ( $filename=~/uidl\.(.*)\.(?:db|dir|pag)$/) {
2368
$_=$1; /^(.*)\@(.*):(.*)$/;
2369
($pop3user, $pop3host, $pop3port)=($1, $2, $3);
2370
if (!defined($accounts{"$pop3host:$pop3port\@\@\@$pop3user"})) {
2371
push (@delfiles, ow::tool::untaint(dotpath($filename)));
2372
}
2373
}
2374
}
2375
closedir(POP3DIR);
2376
unlink(@delfiles);
2377
}
2378
}
2379
editpop3();
2380
}
2381
########## END MODPOP3 ###########################################
2382
2383
########## EDITFILTER ############################################
2384
sub editfilter {
2385
my @filterrules=();
2386
my @globalfilterrules=();
2387
2388
my ($html, $temphtml);
2389
$html = applystyle(readtemplate("editfilter.template"));
2390
2391
my $filterbookfile = dotpath('filter.book');
2392
my $filterruledb = dotpath('filter.ruledb');
2393
2394
my $filterbooksize = ( -s $filterbookfile ) || 0;
2395
my $freespace = int($config{'maxbooksize'} - ($filterbooksize/1024) + .5);
2396
$html =~ s/\@\@\@FREESPACE\@\@\@/$freespace $lang_sizes{'kb'}/;
2397
2398
if ($prefs_caller eq "cal") {
2399
$temphtml .= iconlink("backtofolder.gif", "$lang_text{'backto'} $lang_text{'calendar'}", qq|accesskey="B" href="$config{'ow_cgiurl'}/openwebmail-cal.pl?action=$prefs{'calendar_defaultview'}&amp;$urlparmstr"|);
2400
} elsif ($prefs_caller eq "webdisk") {
2401
$temphtml .= iconlink("backtofolder.gif", "$lang_text{'backto'} $lang_text{'webdisk'}", qq|accesskey="B" href="$config{'ow_cgiurl'}/openwebmail-webdisk.pl?action=showdir&amp;$urlparmstr"|);
2402
} elsif ($prefs_caller eq "read") {
2403
$temphtml .= iconlink("backtofolder.gif", "$lang_text{'backto'} ".($lang_folders{$folder}||$folder), qq|accesskey="B" href="$config{'ow_cgiurl'}/openwebmail-read.pl?action=readmessage&amp;$urlparmstr"|);
2404
} else {
2405
$temphtml .= iconlink("backtofolder.gif", "$lang_text{'backto'} ".($lang_folders{$folder}||$folder), qq|accesskey="B" href="$config{'ow_cgiurl'}/openwebmail-main.pl?action=listmessages&amp;$urlparmstr"|);
2406
}
2407
2408
$html =~ s/\@\@\@MENUBARLINKS\@\@\@/$temphtml/;
2409
2410
$temphtml = startform(-action=>"$config{'ow_cgiurl'}/openwebmail-prefs.pl",
2411
-name=>'newfilter').
2412
ow::tool::hiddens(action=>'addfilter').
2413
$formparmstr;
2414
$html =~ s/\@\@\@STARTFILTERFORM\@\@\@/$temphtml/;
2415
2416
$temphtml = end_form();
2417
$html =~ s/\@\@\@ENDFILTERFORM\@\@\@/$temphtml/;
2418
2419
$temphtml = popup_menu(-name=>'priority',
2420
-values=>['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20'],
2421
-default=>'10');
2422
$html =~ s/\@\@\@PRIORITYMENU\@\@\@/$temphtml/;
2423
2424
my %labels = ('from'=>$lang_text{'from'},
2425
'to'=>$lang_text{'to'},
2426
'subject'=>$lang_text{'subject'},
2427
'smtprelay'=>$lang_text{'smtprelay'},
2428
'header'=>$lang_text{'header'},
2429
'textcontent'=>$lang_text{'textcontent'},
2430
'attfilename'=>$lang_text{'attfilename'});
2431
$temphtml = popup_menu(-name=>'ruletype',
2432
-values=>['from', 'to', 'subject', 'smtprelay', 'header', 'textcontent' ,'attfilename'],
2433
-default=>'subject',
2434
-labels=>\%labels);
2435
$html =~ s/\@\@\@RULEMENU\@\@\@/$temphtml/;
2436
2437
my %labels = ('include'=>$lang_text{'include'},
2438
'exclude'=>$lang_text{'exclude'});
2439
$temphtml = popup_menu(-name=>'include',
2440
-values=>['include', 'exclude'],
2441
-labels=>\%labels);
2442
$html =~ s/\@\@\@INCLUDEMENU\@\@\@/$temphtml/;
2443
2444
$temphtml = textfield(-name=>'text',
2445
-default=>'',
2446
-size=>'26',
2447
-accesskey=>'I',
2448
-override=>'1');
2449
$html =~ s/\@\@\@TEXTFIELD\@\@\@/$temphtml/;
2450
2451
my %labels = ('move'=>$lang_text{'move'},
2452
'copy'=>$lang_text{'copy'});
2453
$temphtml = popup_menu(-name=>'op',
2454
-values=>['move', 'copy'],
2455
-labels=>\%labels);
2456
$html =~ s/\@\@\@OPMENU\@\@\@/$temphtml/;
2457
2458
my (@validfolders, $inboxusage, $folderusage);
2459
getfolders(\@validfolders, \$inboxusage, \$folderusage);
2460
foreach (@validfolders, 'DELETE') {
2461
if ( defined($lang_folders{$_}) ) {
2462
$labels{$_} = $lang_folders{$_};
2463
} else {
2464
$labels{$_} = $_;
2465
}
2466
}
2467
$temphtml = popup_menu(-name=>'destination',
2468
-values=>[@validfolders, 'DELETE'],
2469
-default=>'mail-trash',
2470
-labels=>\%labels);
2471
$html =~ s/\@\@\@FOLDERMENU\@\@\@/$temphtml/;
2472
2473
$temphtml = checkbox(-name=>'enable',
2474
-value=>'1',
2475
-checked=>"checked",
2476
-label=>'');
2477
$html =~ s/\@\@\@ENABLECHECKBOX\@\@\@/$temphtml/;
2478
2479
$temphtml = submit(-name=>$lang_text{'addmod'},
2480
-accesskey=>'A',
2481
-class=>"medtext");
2482
$html =~ s/\@\@\@ADDBUTTON\@\@\@/$temphtml/;
2483
2484
my ($_PRIORITY, $_RULETYPE, $_INCLUDE, $_TEXT, $_OP, $_DESTINATION, $_ENABLE, $_REGEX_TEXT)=(0,1,2,3,4,5,6,7);
2485
2486
## get @filterrules ##
2487
if ( -f $filterbookfile ) {
2488
open (FILTER, $filterbookfile) or
2489
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $filterbookfile! ($!)");
2490
while (<FILTER>) {
2491
chomp($_);
2492
if (/^\d+\@\@\@/) { # add valid rule only (Filippo Dattola)
2493
my @rule=split(/\@\@\@/);
2494
push(@filterrules, \@rule);
2495
}
2496
}
2497
close (FILTER) or openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_close'} $filterbookfile! ($!)");
2498
}
2499
@filterrules=sort {
2500
${$a}[$_PRIORITY] <=> ${$b}[$_PRIORITY] or
2501
$op_order{${$a}[$_OP]} <=> $op_order{${$b}[$_OP]} or
2502
$ruletype_order{${$a}[$_RULETYPE]} <=> $ruletype_order{${$b}[$_RULETYPE]} or
2503
$folder_order{${$a}[$_DESTINATION]} <=> $folder_order{${$b}[$_DESTINATION]}
2504
} @filterrules;
2505
2506
if ( $config{'enable_globalfilter'} && -f "$config{'global_filterbook'}" ) {
2507
if ( open (FILTER, "$config{'global_filterbook'}") ) {
2508
while (<FILTER>) {
2509
chomp($_);
2510
if (/^\d+\@\@\@/) { # add valid rule only (Filippo Dattola)
2511
my @rule=split(/\@\@\@/);
2512
push(@globalfilterrules, \@rule);
2513
}
2514
}
2515
close (FILTER);
2516
}
2517
}
2518
@globalfilterrules=sort {
2519
${$a}[$_PRIORITY] <=> ${$b}[$_PRIORITY] or
2520
$op_order{${$a}[$_OP]} <=> $op_order{${$b}[$_OP]} or
2521
$ruletype_order{${$a}[$_RULETYPE]} <=> $ruletype_order{${$b}[$_RULETYPE]} or
2522
$folder_order{${$a}[$_DESTINATION]} <=> $folder_order{${$b}[$_DESTINATION]}
2523
} @globalfilterrules;
2524
2525
$temphtml = '';
2526
my %FILTERRULEDB;
2527
my $bgcolor = $style{"tablerow_dark"};
2528
ow::dbm::open(\%FILTERRULEDB, $filterruledb, LOCK_SH) or
2529
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_locksh'} db $filterruledb");
2530
2531
for (my $i=0; $i<=$#filterrules; $i++) {
2532
my ($priority, $ruletype, $include, $text, $op, $destination, $enable) = @{$filterrules[$i]};
2533
my ($matchcount, $matchdate)=split(":", $FILTERRULEDB{"$ruletype\@\@\@$include\@\@\@$text\@\@\@$destination"});
2534
2535
$temphtml .= "<tr>\n";
2536
if ($matchdate) {
2537
$matchdate=ow::datetime::dateserial2str($matchdate,
2538
$prefs{'timeoffset'}, $prefs{'daylightsaving'},
2539
$prefs{'dateformat'}, $prefs{'hourformat'});
2540
$temphtml .= "<td bgcolor=$bgcolor align=center><a title='$matchdate'>$matchcount</a></font></td>\n";
2541
} else {
2542
$temphtml .= "<td bgcolor=$bgcolor align=center>0</font></td>\n";
2543
}
2544
my $jstext = $text; $jstext=~s/\\/\\\\/g; $jstext=~s/'/\\'/g; $jstext=~s/"/!QUOT!/g;
2545
my $accesskeystr=$i%10+1;
2546
if ($accesskeystr == 10) {
2547
$accesskeystr=qq|accesskey="0"|;
2548
} elsif ($accesskeystr < 10) {
2549
$accesskeystr=qq|accesskey="$accesskeystr"|;
2550
}
2551
$temphtml .= qq|<td bgcolor=$bgcolor align=center>$priority</td>\n|.
2552
qq|<td bgcolor=$bgcolor align=center>$lang_text{$ruletype}</td>\n|.
2553
qq|<td bgcolor=$bgcolor align=center>$lang_text{$include}</td>\n|.
2554
qq|<td bgcolor=$bgcolor align=center><a $accesskeystr href="Javascript:Update('$priority','$ruletype','$include','$jstext','$op','$destination','$enable')">$text</a></td>\n|;
2555
if ($destination eq 'INBOX') {
2556
$temphtml .= "<td bgcolor=$bgcolor align=center>-----</td>\n";
2557
} else {
2558
$temphtml .= "<td bgcolor=$bgcolor align=center>$lang_text{$op}</td>\n";
2559
}
2560
if (defined($lang_folders{$destination})) {
2561
$temphtml .= "<td bgcolor=$bgcolor align=center>$lang_folders{$destination}</td>\n";
2562
} else {
2563
$temphtml .= "<td bgcolor=$bgcolor align=center>$destination</td>\n";
2564
}
2565
if ($enable == 1) {
2566
$temphtml .= "<td bgcolor=$bgcolor align=center>$lang_text{'enable'}</td>\n";
2567
} else {
2568
$temphtml .= "<td bgcolor=$bgcolor align=center>$lang_text{'disable'}</td>\n";
2569
}
2570
$temphtml .= start_form(-action=>"$config{'ow_cgiurl'}/openwebmail-prefs.pl").
2571
qq|<td bgcolor=$bgcolor align=center>|.
2572
ow::tool::hiddens(action=>'deletefilter',
2573
ruletype=>$ruletype,
2574
include=>$include,
2575
text=>$text,
2576
destination=>$destination).
2577
submit(-name=>$lang_text{'delete'},
2578
-class=>"medtext").
2579
$formparmstr.
2580
qq|</td></tr>|.
2581
end_form();
2582
if ($bgcolor eq $style{"tablerow_dark"}) {
2583
$bgcolor = $style{"tablerow_light"};
2584
} else {
2585
$bgcolor = $style{"tablerow_dark"};
2586
}
2587
}
2588
2589
if ($#globalfilterrules >= 0) {
2590
$temphtml .= qq|<tr><td colspan="9">&nbsp;</td></tr>\n|.
2591
qq|<tr><td colspan="9" bgcolor=$style{columnheader}><B>$lang_text{globalfilterrule}</B> ($lang_text{readonly})</td></tr>\n|;
2592
}
2593
$bgcolor = $style{"tablerow_dark"};
2594
2595
for (my $i=0; $i<=$#globalfilterrules; $i++) {
2596
my ($priority, $ruletype, $include, $text, $op, $destination, $enable) = @{$globalfilterrules[$i]};
2597
my ($matchcount, $matchdate)=split(":", $FILTERRULEDB{"$ruletype\@\@\@$include\@\@\@$text\@\@\@$destination"});
2598
2599
$temphtml .= "<tr>\n";
2600
if ($matchdate) {
2601
$matchdate=ow::datetime::dateserial2str($matchdate,
2602
$prefs{'timeoffset'}, $prefs{'daylightsaving'},
2603
$prefs{'dateformat'}, $prefs{'hourformat'});
2604
$temphtml .= "<td bgcolor=$bgcolor align=center><a title='$matchdate'>$matchcount</a></font></td>\n";
2605
} else {
2606
$temphtml .= "<td bgcolor=$bgcolor align=center>0</font></td>\n";
2607
}
2608
my $jstext = $text; $jstext=~s/\\/\\\\/g; $jstext=~s/'/\\'/g; $jstext=~s/"/!QUOT!/g;
2609
my $accesskeystr=$i%10+1;
2610
if ($accesskeystr == 10) {
2611
$accesskeystr=qq|accesskey="0"|;
2612
} elsif ($accesskeystr < 10) {
2613
$accesskeystr=qq|accesskey="$accesskeystr"|;
2614
}
2615
$temphtml .= qq|<td bgcolor=$bgcolor align=center>$priority</td>\n|.
2616
qq|<td bgcolor=$bgcolor align=center>$lang_text{$ruletype}</td>\n|.
2617
qq|<td bgcolor=$bgcolor align=center>$lang_text{$include}</td>\n|.
2618
qq|<td bgcolor=$bgcolor align=center><a $accesskeystr href="Javascript:Update('$priority','$ruletype','$include','$jstext','$op','$destination','$enable')">$text</a></td>\n|.
2619
qq|<td bgcolor=$bgcolor align=center>$lang_text{$op}</td>\n|;
2620
if (defined($lang_folders{$destination})) {
2621
$temphtml .= "<td bgcolor=$bgcolor align=center>$lang_folders{$destination}</td>\n";
2622
} else {
2623
$temphtml .= "<td bgcolor=$bgcolor align=center>$destination</td>\n";
2624
}
2