3 # Display one server polled by fetchmail
5 require './fetchmail-lib.pl';
7 if ($config{'config_file'}) {
8 $file = $config{'config_file'};
11 &can_edit_user($in{'user'}) || &error($text{'poll_ecannot'});
12 @uinfo = getpwnam($in{'user'});
13 $file = "$uinfo[7]/.fetchmailrc";
14 $uheader = &text('poll_foruser', "<tt>$in{'user'}</tt>");
18 &ui_print_header($uheader, $text{'poll_create'}, "");
21 &ui_print_header($uheader, $text{'poll_edit'}, "");
22 @conf = &parse_config_file($file);
23 $poll = $conf[$in{'idx'}];
26 print "<form action=save_poll.cgi method=post>\n";
27 print "<input type=hidden name=new value='$in{'new'}'>\n";
28 print "<input type=hidden name=idx value='$in{'idx'}'>\n";
29 print "<input type=hidden name=file value='$file'>\n";
30 print "<input type=hidden name=user value='$in{'user'}'>\n";
33 print "<table border width=100%>\n";
34 print "<tr $tb> <td><b>$text{'poll_header'}</b></td> </tr>\n";
35 print "<tr $cb> <td><table width=100%>\n";
37 print "<tr> <td><b>$text{'poll_poll'}</b></td>\n";
38 printf "<td><input name=poll size=30 value='%s'></td>\n",
41 print "<td><b>$text{'poll_skip'}</b></td>\n";
42 printf "<td><input type=radio name=skip value=0 %s> %s\n",
43 $poll->{'skip'} ? '' : 'checked', $text{'yes'};
44 printf "<input type=radio name=skip value=1 %s> %s</td> </tr>\n",
45 $poll->{'skip'} ? 'checked' : '', $text{'no'};
47 print "<tr> <td><b>$text{'poll_via'}</b></td>\n";
48 printf "<td colspan=3><input type=radio name=via_def value=1 %s> %s\n",
49 $poll->{'via'} ? '' : 'checked', $text{'poll_via_def'};
50 printf "<input type=radio name=via_def value=0 %s>\n",
51 $poll->{'via'} ? 'checked' : '';
52 printf "<input name=via size=30 value='%s'></td> </tr>\n",
55 print "<tr> <td><b>$text{'poll_proto'}</b></td>\n";
56 print "<td><select name=proto>\n";
57 printf "<option value='' %s> %s\n",
58 $poll->{'proto'} ? '' : 'selected', $text{'default'};
59 foreach $p ('pop3', 'pop2', 'imap', 'imap-k4', 'imap-gss', 'apop', 'kpop') {
60 printf "<option value=%s %s>%s\n",
61 $p, lc($poll->{'proto'}) eq $p ? 'selected' : '', uc($p);
62 $found++ if (lc($poll->{'proto'}) eq $p);
64 printf "<option value=%s selected>%s\n", $poll->{'proto'}, uc($poll->{'proto'})
65 if (!$found && $poll->{'proto'});
66 print "</select></td>\n";
69 print "<td><b>$text{'poll_port'}</b></td>\n";
70 printf "<td><input type=radio name=port_def value=1 %s> %s\n",
71 $poll->{'port'} ? '' : 'checked', $text{'default'};
72 printf "<input type=radio name=port_def value=0 %s> %s\n",
73 $poll->{'port'} ? 'checked' : '';
74 printf "<input name=port size=8 value='%s'></td> </tr>\n",
77 print "<tr> <td><b>$text{'poll_auth'}</b></td>\n";
78 print "<td><select name=auth>\n";
79 printf "<option value='' %s> %s\n",
80 $poll->{'auth'} ? '' : 'selected', $text{'default'};
81 foreach $p ('password', 'kerberos_v5', 'kerberos_v4', 'gssapi', 'cram-md5', 'otp', 'ntlm', 'ssh') {
82 printf "<option value=%s %s>%s\n",
83 $p, lc($poll->{'auth'}) eq $p ? 'selected' : '', uc($p);
84 $found++ if (lc($poll->{'auth'}) eq $p);
86 printf "<option value=%s selected>%s\n", $poll->{'auth'}, uc($poll->{'auth'})
87 if (!$found && $poll->{'auth'});
88 print "</select></td> </tr>\n";
90 @interface = split(/\//, $poll->{'interface'});
91 print "<tr> <td valign=top><b>$text{'poll_interface'}</b></td><td colspan=3>\n";
92 printf "<input type=radio name=interface_def value=1 %s> %s<br>\n",
93 @interface ? '' : 'checked', $text{'poll_interface_def'};
94 printf "<input type=radio name=interface_def value=0 %s> %s\n",
95 @interface ? 'checked' : '', $text{'poll_interface_ifc'};
96 print "<input name=interface size=8 value='$interface[0]'> ",
97 "$text{'poll_interface_ip'}\n";
98 print "<input name=interface_net size=15 value='$interface[1]'> /\n";
99 print "<input name=interface_mask size=15 value='$interface[2]'></td> </tr>\n";
101 print "</table></td></tr></table>\n";
104 @users = @{$poll->{'users'}};
105 push(@users, undef) if ($in{'new'} || $in{'adduser'});
107 foreach $u (@users) {
108 print "<br><table border width=100%>\n";
109 print "<tr $tb> <td><b>$text{'poll_uheader'}</b></td> </tr>\n";
110 print "<tr $cb> <td><table width=100%>\n";
112 print "<tr> <td><b>$text{'poll_user'}</b></td>\n";
113 printf "<td><input name=user_$i size=15 value='%s'></td>\n",
116 print "<td><b>$text{'poll_pass'}</b></td>\n";
117 print "<td>",&ui_password("pass_$i", $u->{'pass'}, 15),"</td> </tr>\n";
119 print "<tr> <td><b>$text{'poll_is'}</b></td> <td colspan=3>\n";
120 printf "<input name=is_$i size=60 value='%s'></td> </tr>\n",
121 join(" ", @{$u->{'is'}}) || $remote_user;
123 print "<tr> <td><b>$text{'poll_keep'}</b></td> <td colspan=3>\n";
124 printf "<input type=radio name=keep_$i value=1 %s> %s\n",
125 $u->{'keep'} eq '1' ? 'checked' : '', $text{'yes'};
126 printf "<input type=radio name=keep_$i value=0 %s> %s\n",
127 $u->{'keep'} eq '0' ? 'checked' : '', $text{'no'};
128 printf "<input type=radio name=keep_$i value='' %s> %s (%s)\n",
129 $u->{'keep'} eq '' ? 'checked' : '', $text{'default'},
130 $text{'poll_usually'};
131 print "</td> </tr>\n";
133 print "<td><b>$text{'poll_fetchall'}</b></td> <td colspan=3>\n";
134 printf "<input type=radio name=fetchall_$i value=1 %s> %s\n",
135 $u->{'fetchall'} eq '1' ? 'checked' : '', $text{'yes'};
136 printf "<input type=radio name=fetchall_$i value=0 %s> %s\n",
137 $u->{'fetchall'} eq '0' ? 'checked' : '', $text{'no'};
138 printf "<input type=radio name=fetchall_$i value='' %s> %s (%s)\n",
139 $u->{'fetchall'} eq '' ? 'checked' : '', $text{'default'},
140 $text{'poll_usually'};
141 print "</td> </tr>\n";
143 print "<td><b>$text{'poll_ssl'}</b></td> <td colspan=3>\n";
144 printf "<input type=radio name=ssl_$i value=1 %s> %s\n",
145 $u->{'ssl'} eq '1' ? 'checked' : '', $text{'yes'};
146 printf "<input type=radio name=ssl_$i value=0 %s> %s\n",
147 $u->{'ssl'} eq '0' ? 'checked' : '', $text{'no'};
148 printf "<input type=radio name=ssl_$i value='' %s> %s (%s)\n",
149 $u->{'ssl'} eq '' ? 'checked' : '', $text{'default'},
150 $text{'poll_usually'};
151 print "</td> </tr>\n";
153 print "<tr> <td><b>$text{'poll_preconnect'}</b></td>\n";
154 $u->{'preconnect'} =~ s/'/'/g;
155 printf "<td colspan=3><input name=preconnect_$i size=50 value='%s'></td> </tr>\n", $u->{'preconnect'};
157 print "<tr> <td><b>$text{'poll_postconnect'}</b></td>\n";
158 $u->{'postconnect'} =~ s/'/'/g;
159 printf "<td colspan=3><input name=postconnect_$i size=50 value='%s'></td></tr>\n", $u->{'postconnect'};
161 print "</table></td></tr></table>\n";
165 print "<table width=100%><tr>\n";
167 print "<td><input type=submit value='$text{'create'}'></td>\n";
170 print "<td><input type=submit value='$text{'save'}'></td>\n";
171 if (!$in{'adduser'}) {
172 print "<td align=middle><input type=submit name=adduser ",
173 "value='$text{'poll_adduser'}'></td>\n";
175 print "<td align=middle><input type=submit name=check ",
176 "value='$text{'poll_check'}'></td>\n";
177 print "<td align=right><input type=submit name=delete ",
178 "value='$text{'delete'}'></td>\n";
180 print "</tr></table>\n";
182 if (!$fetchmail_config && $config{'view_mode'}) {
183 &ui_print_footer("edit_user.cgi?user=$in{'user'}", $text{'user_return'},
184 "", $text{'index_return'});
187 &ui_print_footer("", $text{'index_return'});