Handle hostnames with upper-case letters
[webmin.git] / cfengine / edit_class.cgi
1 #!/usr/local/bin/perl
2 # edit_class.cgi
3 # Edit options for a class in some section
4
5 require './cfengine-lib.pl';
6 use Config;
7 &ReadParse();
8 $conf = $in{'cfd'} ? &get_cfd_config() : &get_config();
9 $sec = $conf->[$in{'idx'}] if ($in{'idx'} ne '');
10 if ($in{'new'}) {
11         &ui_print_header(undef, $sec ? $text{'edit_create2'} : $text{'edit_create1'}, "",
12                 "edit");
13         $cls = { 'name' => 'any' };
14         }
15 else {
16         &ui_print_header(undef, $text{'edit_title'}, "", "edit");
17         $cls = $sec->{'cls'}->[$in{'cidx'}];
18         }
19
20 print "<form action=save_class.cgi method=post>\n";
21 print "<input type=hidden name=new value='$in{'new'}'>\n";
22 print "<input type=hidden name=idx value='$in{'idx'}'>\n";
23 print "<input type=hidden name=cidx value='$in{'cidx'}'>\n";
24 print "<input type=hidden name=type value='$in{'type'}'>\n";
25 print "<input type=hidden name=cfd value='$in{'cfd'}'>\n";
26
27 print "<table border width=100%>\n";
28 print "<tr $tb> <td><b>$text{'edit_header'}</b></td> </tr>\n";
29 print "<tr $cb> <td><table width=100%>\n";
30
31 $type = $in{'type'} ? $in{'type'} : $sec->{'name'};
32 $t = $text{"section_".$type."_".$in{'cfd'}};
33 $t = $text{"section_".$type} if (!$t);
34 print "<tr> <td><b>$text{'edit_section'}</b></td> <td colspan=3>\n";
35 print $t ? "$t ($type)" : $type,"</td> </tr>\n";
36
37 print "<td><b>$text{'edit_class'}</b></td> <td colspan=3>\n";
38 printf "<input type=radio name=class_def value=1 %s> %s\n",
39         $cls->{'name'} eq 'any' ? 'checked' : '', $text{'edit_all'};
40 printf "<input type=radio name=class_def value=0 %s>\n",
41         $cls->{'name'} eq 'any' ? '' : 'checked';
42 printf "<input name=class size=50 value='%s'></td> </tr>\n",
43         $cls->{'name'} eq 'any' ? '' : $cls->{'name'};
44
45 $type = undef if ($in{'manual'});
46 if ($text{"type_".$type."_".$in{'cfd'}}) {
47         print "<tr> <td colspan=4>",$text{"type_".$type."_".$in{'cfd'}},
48               "</td> </tr>\n";
49         }
50 elsif ($text{"type_".$type}) {
51         print "<tr> <td colspan=4>",$text{"type_".$type},"</td> </tr>\n";
52         }
53 if ($type eq 'links') {
54         # Show links that would be created
55         local @links = &parse_links($cls);
56         print "<tr> <td valign=top><b>$text{'edit_links'}</b></td>\n";
57         print "<td colspan=3><table border width=100%>\n";
58         print "<tr $tb> <td><b>$text{'edit_linkfrom'}</b></td> ",
59               "<td><b>$text{'edit_linktype'}</b></td> ",
60               "<td><b>$text{'edit_linkover'}</b></td> ",
61               "<td><b>$text{'edit_linkto'}</b></td> </tr>\n";
62         $i = 0;
63         foreach $l (@links, { }) {
64                 print "<tr $cb>\n";
65                 printf "<td><input name=from_$i size=30 value='%s'></td>\n",
66                         $l->{'_linkfrom'};
67                 printf "<td><input type=checkbox name=type_$i value=1 %s> %s</td>\n", $l->{'_linktype'} =~ /^\+/ ? "checked" : "", $text{'yes'};
68                 printf "<td><input type=checkbox name=over_$i value=1 %s> %s</td>\n", $l->{'_linktype'} =~ /!$/ ? "checked" : "", $text{'yes'};
69                 printf "<td><input name=to_$i size=30 value='%s'></td>\n",
70                         $l->{'_linkto'};
71                 print "</tr>\n";
72                 $i++;
73                 }
74         print "</table></td> </tr>\n";
75         }
76 elsif ($type eq 'directories') {
77         # Show directories that would be created
78         local @dirs = &parse_directories($cls);
79         print "<tr> <td colspan=4><table border width=100%>\n";
80         print "<tr $tb> <td><b>$text{'edit_dir'}</b></td> ",
81               "<td><b>$text{'edit_dirmode'}</b></td> ",
82               "<td><b>$text{'edit_dirowner'}</b></td> ",
83               "<td><b>$text{'edit_dirgroup'}</b></td> </tr>\n";
84         $i = 0;
85         foreach $d (@dirs, { }) {
86                 print "<tr $cb>\n";
87                 printf "<td><input name=dir_$i size=40 value='%s'></td>\n",
88                         $d->{'_dir'};
89                 printf "<td><input name=mode_$i size=4 value='%s'></td>\n",
90                         &sname("mode", $d);
91                 printf "<td><input name=owner_$i size=13 value='%s'></td>\n",
92                         &sname("owner", $d);
93                 printf "<td><input name=group_$i size=13 value='%s'></td>\n",
94                         &sname("group", $d);
95                 print "</tr>\n";
96                 $i++;
97                 }
98         print "</table></td> </tr>\n";
99         }
100 elsif ($type eq "control" && !$in{'cfd'}) {
101         # Show actionsequence definition
102         local ($as) = &find("actionsequence", $cls->{'defs'});
103         print "<tr> <td valign=top><b>$text{'edit_actionseq'}</b></td>\n";
104         print "<td colspan=3><table cellpadding=0 cellspacing=0>\n";
105         print "<tr> <td valign=top><textarea name=seq rows=10 cols=30>";
106         foreach $v (@{$as->{'valuequoted'}}) {
107                 print &html_escape($v),"\n";
108                 }
109         print "</textarea></td>\n";
110         print "<td><select name=add size=10>\n";
111         foreach $s ($in{'cfd'} ? @known_cfd_sections : @known_sections) {
112                 next if ($s eq "control");
113                 local $t = $text{"section_".$s."_".$in{'cfd'}};
114                 $t = $text{"section_".$s} if (!$t);
115                 printf "<option value=$s>$t ($s)\n";
116                 }
117         print "</select><br>\n";
118         print "<input type=button value='$text{'edit_actionadd'}' onClick='document.forms[0].seq.value += document.forms[0].add.options[document.forms[0].add.selectedIndex].value+\"\\n\"'>\n";
119         print "</td></tr></table> </td> </tr>\n";
120
121         # Show other global definitions
122         print "<tr> <td><b>$text{'edit_controldef'}</b></td> ",
123               "<td colspan=3><b>$text{'edit_controlvalue'}</b></td> </tr>\n";
124         $i = 0;
125         foreach $d (@{$cls->{'defs'}}, { }) {
126                 next if ($d->{'name'} eq 'actionsequence');
127                 print "<tr>\n";
128                 printf "<td><input name=def_$i size=15 value='%s'></td>\n",
129                         $d->{'name'};
130                 printf "<td colspan=3><input name=value_$i size=50 value='%s'></td>\n", join(" ", @{$d->{'valuequoted'}});
131                 print "</tr>\n";
132                 $i++;
133                 }
134         }
135 elsif ($type eq "control" && $in{'cfd'}) {
136         # Show cfd-specific control options
137         local $run = &find_value("cfrunCommand", $cls->{'defs'});
138         print "<tr> <td><b>$text{'edit_controlrun'}</b></td> <td colspan=3>\n";
139         printf "<input type=radio name=run_def value=1 %s> %s\n",
140                 $run ? "" : "checked", $text{'edit_none'};
141         printf "<input type=radio name=run_def value=0 %s>\n",
142                 $run ? "checked" : "";
143         printf "<input name=run size=50 value='%s'></td> </tr>\n", $run;
144
145         local $elapsed = &find_value("IfElapsed", $cls->{'defs'});
146         print "<tr> <td><b>$text{'edit_controlelapsed'}</b></td> <td>\n";
147         printf "<input type=radio name=elapsed_def value=1 %s> %s\n",
148                 defined($elapsed) ? "" : "checked", $text{'default'};
149         printf "<input type=radio name=elapsed_def value=0 %s>\n",
150                 defined($elapsed) ? "checked" : "";
151         printf "<input name=elapsed size=5 value='%s'></td>\n", $elapsed;
152
153         local $max = &find_value("MaxConnections", $cls->{'defs'});
154         print "<td><b>$text{'edit_controlmax'}</b></td> <td>\n";
155         printf "<input type=radio name=max_def value=1 %s> %s\n",
156                 defined($max) ? "" : "checked", $text{'default'};
157         printf "<input type=radio name=max_def value=0 %s>\n",
158                 defined($max) ? "checked" : "";
159         printf "<input name=max size=5 value='%s'></td> </tr>\n", $max;
160
161         print "<tr> <td colspan=4><hr></td> </tr>\n";
162
163         local $auto = &find_value("AutoExecCommand", $cls->{'defs'});
164         print "<tr> <td><b>$text{'edit_controlauto'}</b></td> <td colspan=3>\n";
165         printf "<input type=radio name=auto_def value=1 %s> %s\n",
166                 $auto ? "" : "checked", $text{'edit_none'};
167         printf "<input type=radio name=auto_def value=0 %s>\n",
168                 $auto ? "checked" : "";
169         printf "<input name=auto size=50 value='%s'></td></tr>\n", $auto;
170
171         local $interval = &find_value("AutoExecInterval", $cls->{'defs'});
172         print "<tr> <td><b>$text{'edit_controlinterval'}</b></td> <td>\n";
173         printf "<input type=radio name=interval_def value=1 %s> %s\n",
174                 defined($interval) ? "" : "checked", $text{'default'};
175         printf "<input type=radio name=interval_def value=0 %s>\n",
176                 defined($interval) ? "checked" : "";
177         printf "<input name=interval size=5 value='%s'></td> </tr>\n",$interval;
178
179         print "<tr> <td colspan=4><hr></td> </tr>\n";
180
181         local $dom = &find_value("domain", $cls->{'defs'});
182         print "<tr> <td><b>$text{'edit_controldom'}</b></td> <td>\n";
183         printf "<input type=radio name=dom_def value=1 %s> %s\n",
184                 $dom ? "" : "checked", $text{'edit_none'};
185         printf "<input type=radio name=dom_def value=0 %s>\n",
186                 $dom ? "checked" : "";
187         printf "<input name=dom size=15 value='%s'></td>\n", $dom;
188
189         local $log = &find_value("LogAllConnections", $cls->{'defs'});
190         print "<td><b>$text{'edit_controllog'}</b></td>\n";
191         printf "<td><input type=radio name=log value=1 %s> %s\n",
192                 lc($log) eq "true" ? "checked" : "", $text{'yes'};
193         printf "<input type=radio name=log value=0 %s> %s\n",
194                 lc($log) eq "false" ? "checked" : "", $text{'no'};
195         printf "<input type=radio name=log value=-1 %s> %s</td> </tr>\n",
196                 $log ? "" : "checked", $text{'default'};
197
198         local @allow = &find_value("AllowConnectionsFrom", $cls->{'defs'});
199         print "<tr> <td><b>$text{'edit_controlallow'}</b></td>\n";
200         printf "<td colspan=3><input type=radio name=allow_def value=1 %s> %s ",
201                 @allow ? "" : "checked", $text{'edit_controlall'};
202         printf "<input type=radio name=allow_def value=0 %s>\n",
203                 @allow ? "checked" : "";
204         printf "<input name=allow size=40 value='%s'></td> </tr>\n",
205                 join(" ", @allow);
206
207         local @deny = &find_value("DenyConnectionsFrom", $cls->{'defs'});
208         print "<tr> <td><b>$text{'edit_controldeny'}</b></td>\n";
209         printf "<td colspan=3><input type=radio name=deny_def value=1 %s> %s ",
210                 @deny ? "" : "checked", $text{'edit_controlnone'};
211         printf "<input type=radio name=deny_def value=0 %s>\n",
212                 @deny ? "checked" : "";
213         printf "<input name=deny size=40 value='%s'></td> </tr>\n",
214                 join(" ", @deny);
215
216         local @skip = &find_value("SkipVerify", $cls->{'defs'});
217         print "<tr> <td><b>$text{'edit_controlskip'}</b></td>\n";
218         printf "<td colspan=3><input type=radio name=skip_def value=1 %s> %s ",
219                 @skip ? "" : "checked", $text{'edit_controlnone'};
220         printf "<input type=radio name=skip_def value=0 %s>\n",
221                 @skip ? "checked" : "";
222         printf "<input name=skip size=40 value='%s'></td> </tr>\n",
223                 join(" ", @skip);
224         }
225 elsif ($type eq "grant" || $type eq "admit" || $type eq "deny") {
226         # Allow editing of allowed or denied directories
227         local (@grants, $grant);
228         foreach $v (@{$cls->{'values'}}) {
229                 if ($v =~ /\//) {
230                         push(@grants, $grant = { 'dir' => $v });
231                         }
232                 else {
233                         push(@{$grant->{'hosts'}}, $v);
234                         }
235                 }
236
237         print "<tr> <td valign=top><b>",$text{'edit_'.$type},"</b></td>\n";
238         print "<td colspan=3><table border width=100%>\n";
239         print "<tr $tb> <td><b>$text{'edit_grantdir'}</b></td> ",
240               "<td><b>$text{'edit_granthosts'}</b></td> </tr>\n";
241         $i = 0;
242         foreach $g (@grants, { }) {
243                 print "<tr $cb>\n";
244                 printf "<td><input name=dir_$i size=20 value='%s'></td>\n",
245                         $g->{'dir'};
246                 printf "<td><input name=hosts_$i size=40 value='%s'></td>\n",
247                         join(" ", @{$g->{'hosts'}});
248                 print "</tr>\n";
249                 $i++;
250                 }
251         print "</table></td></tr>\n";
252         }
253 elsif ($type eq "groups" || $type eq "classes") {
254         # Allow editing of group definitions
255         print "<tr> <td valign=top><b>$text{'edit_groups'}</b></td>\n";
256         print "<td colspan=3><table border width=100%>\n";
257         print "<tr $tb> <td><b>$text{'edit_groupname'}</b></td> ",
258               "<td><b>$text{'edit_groupmems'}</b></td> </tr>\n";
259         $i = 0;
260         foreach $g (@{$cls->{'defs'}}, { }) {
261                 print "<tr $cb>\n";
262                 printf "<td><input name=name_$i size=15 value='%s'></td>\n",
263                         $g->{'name'};
264                 printf "<td><input name=mems_$i size=45 value='%s'></td>\n",
265                         join(" ", @{$g->{'valuequoted'}});
266                 print "</tr>\n";
267                 $i++;
268                 }
269         print "</table></td></tr>\n";
270         }
271 elsif ($type eq "files") {
272         # Allow editing of file permission settings
273         local @files = &parse_directories($cls);
274         local $i = 0;
275         foreach $f (@files, $in{'newfiles'} || $in{'new'} ? ( { } ) : ( ) ) {
276                 print "<tr> <td colspan=4><hr></td> </tr>\n";
277
278                 print "<tr> <td><b>$text{'edit_filesdir'}</b></td>\n";
279                 print "<td colspan=3>";
280                 printf "<input type=radio name=dir_def_$i value=1 %s> %s\n",
281                         $f->{'_dir'} ? "" : "checked", $text{'edit_none'};
282                 printf "<input type=radio name=dir_def_$i value=0 %s>\n",
283                         $f->{'_dir'} ? "checked" : "";
284                 printf "<input name=dir_$i size=50 value='%s'></td> </tr>\n",
285                         $f->{'_dir'};
286
287                 local $owner = &sname("owner", $f);
288                 print "<tr> <td><b>$text{'edit_filesowner'}</b></td> <td>\n";
289                 printf "<input type=radio name=owner_def_$i value=1 %s> %s\n",
290                         $owner ? "" : "checked", $text{'edit_nochange'};
291                 printf "<input type=radio name=owner_def_$i value=0 %s>\n",
292                         $owner ? "checked" : "";
293                 printf "<input name=owner_$i size=13 value='%s'></td>\n",
294                         $owner;
295
296                 local $group = &sname("group", $f);
297                 print "<td><b>$text{'edit_filesgroup'}</b></td> <td>\n";
298                 printf "<input type=radio name=group_def_$i value=1 %s> %s\n",
299                         $group ? "" : "checked", $text{'edit_nochange'};
300                 printf "<input type=radio name=group_def_$i value=0 %s>\n",
301                         $group ? "checked" : "";
302                 printf "<input name=group_$i size=13 value='%s'></td> </tr>\n",
303                         $group;
304
305                 local $mode = &sname("mode", $f);
306                 print "<tr> <td><b>$text{'edit_filesmode'}</b></td> <td>\n";
307                 printf "<input type=radio name=mode_def_$i value=1 %s> %s\n",
308                         $mode ? "" : "checked", $text{'edit_nochange'};
309                 printf "<input type=radio name=mode_def_$i value=0 %s>\n",
310                         $mode ? "checked" : "";
311                 printf "<input name=mode_$i size=15 value='%s'></td>\n",
312                         $mode;
313
314                 local $rec = &sname("recurse", $f);
315                 print "<td><b>$text{'edit_filesrec'}</b></td> <td>\n";
316                 printf "<input type=radio name=rec_def_$i value=1 %s> %s\n",
317                         $rec ? "" : "checked", $text{'edit_none'};
318                 printf "<input type=radio name=rec_def_$i value=2 %s> %s\n",
319                         $rec eq 'inf' ? "checked" : "",
320                         $text{'edit_filesinf'};
321                 printf "<input type=radio name=rec_def_$i value=0 %s>\n",
322                         $rec && $rec ne 'inf' ? "checked" : "";
323                 printf "<input name=rec_$i size=6 value='%s'></td> </tr>\n",
324                         $rec eq 'inf' ? '' : $rec;
325
326                 local $include = &sname("include", $f);
327                 print "<tr> <td><b>$text{'edit_filesinclude'}</b></td> <td>\n";
328                 printf "<input type=radio name=include_def_$i value=1 %s> %s\n",
329                         $include ? "" : "checked", $text{'edit_filesall'};
330                 printf "<input type=radio name=include_def_$i value=0 %s>\n",
331                         $include ? "checked" : "";
332                 printf "<input name=include_$i size=15 value='%s'></td>\n",
333                         $include;
334
335                 local $exclude = &sname("exclude", $f);
336                 print "<td><b>$text{'edit_filesexclude'}</b></td> <td>\n";
337                 printf "<input type=radio name=exclude_def_$i value=1 %s> %s\n",
338                         $exclude ? "" : "checked", $text{'edit_filesnone'};
339                 printf "<input type=radio name=exclude_def_$i value=0 %s>\n",
340                         $exclude ? "checked" : "";
341                 printf "<input name=exclude_$i size=13 value='%s'></td></tr>\n",
342                         $exclude;
343
344                 local $acl = &sname("acl", $f);
345                 print "<tr> <td><b>$text{'edit_filesacl'}</b></td> <td>\n";
346                 printf "<input type=radio name=acl_def_$i value=1 %s> %s\n",
347                         $acl ? "" : "checked", $text{'edit_nochange'};
348                 printf "<input type=radio name=acl_def_$i value=0 %s>\n",
349                         $acl ? "checked" : "";
350                 printf "<input name=acl_$i size=15 value='%s'></td>\n",
351                         $acl;
352
353                 local $action = &sname("action", $f);
354                 local @acts = ( "fixall", "fixdirs", "fixplain", "warnall", "warndirs", "warnplain", "touch", "linkchildren", "create", "compress", "alert" );
355                 print "<td><b>$text{'edit_filesact'}</b></td>\n";
356                 print "<td><select name=act_$i>\n";
357                 printf "<option value='' %s> %s\n",
358                         $action ? "" : "selected", $text{'default'};
359                 foreach $a (@acts) {
360                         printf "<option value=%s %s> %s\n",
361                                 $a, $action eq $a ? "selected" : "",
362                                 $text{"edit_files_$a"};
363                         }
364                 print "<option selected>$action\n"
365                         if ($action && &indexof($action, @acts) < 0);
366                 print "</select></td> </tr>\n";
367                 
368                 $i++;
369                 }
370         if (!$in{'newfiles'} && !$in{'new'}) {
371                 print "<tr> <td colspan=4 align=right><hr><a href='edit_class.cgi?$in&newfiles=1'>$text{'edit_filesnew'}</a></td>\n";
372                 }
373         }
374 elsif ($type eq "copy") {
375         # Allow editing of file copy options
376         local @copies = &parse_directories($cls);
377         local $i = 0;
378         foreach $f (@copies, $in{'newcopy'} || $in{'new'} ? ( { } ) : ( ) ) {
379                 print "<tr> <td colspan=4><hr></td> </tr>\n";
380
381                 print "<tr> <td><b>$text{'edit_copydir'}</b></td>\n";
382                 print "<td colspan=3>";
383                 printf "<input type=radio name=dir_def_$i value=1 %s> %s\n",
384                         $f->{'_dir'} ? "" : "checked", $text{'edit_none'};
385                 printf "<input type=radio name=dir_def_$i value=0 %s>\n",
386                         $f->{'_dir'} ? "checked" : "";
387                 printf "<input name=dir_$i size=50 value='%s'></td> </tr>\n",
388                         $f->{'_dir'};
389
390                 print "<tr> <td><b>$text{'edit_copydest'}</b></td>\n";
391                 print "<td colspan=3>";
392                 printf "<input name=dest_$i size=50 value='%s'></td> </tr>\n",
393                         &sname("dest", $f);
394
395                 local $server = &sname("server", $f);
396                 print "<tr> <td><b>$text{'edit_copyserver'}</b></td>\n";
397                 print "<td colspan=3>";
398                 printf "<input type=radio name=server_def_$i value=1 %s> %s\n",
399                         $server ? "" : "checked", $text{'edit_local'};
400                 printf "<input type=radio name=server_def_$i value=0 %s>\n",
401                         $server ? "checked" : "";
402                 printf "<input name=server_$i size=40 value='%s'></td> </tr>\n",
403                         $server;
404
405                 local $owner = &sname("owner", $f);
406                 print "<tr> <td><b>$text{'edit_filesowner'}</b></td> <td>\n";
407                 printf "<input type=radio name=owner_def_$i value=1 %s> %s\n",
408                         $owner ? "" : "checked", $text{'edit_nochange'};
409                 printf "<input type=radio name=owner_def_$i value=0 %s>\n",
410                         $owner ? "checked" : "";
411                 printf "<input name=owner_$i size=13 value='%s'></td>\n",
412                         $owner;
413
414                 local $group = &sname("group", $f);
415                 print "<td><b>$text{'edit_filesgroup'}</b></td> <td>\n";
416                 printf "<input type=radio name=group_def_$i value=1 %s> %s\n",
417                         $group ? "" : "checked", $text{'edit_nochange'};
418                 printf "<input type=radio name=group_def_$i value=0 %s>\n",
419                         $group ? "checked" : "";
420                 printf "<input name=group_$i size=13 value='%s'></td> </tr>\n",
421                         $group;
422
423                 local $mode = &sname("mode", $f);
424                 print "<tr> <td><b>$text{'edit_filesmode'}</b></td> <td>\n";
425                 printf "<input type=radio name=mode_def_$i value=1 %s> %s\n",
426                         $mode ? "" : "checked", $text{'edit_nochange'};
427                 printf "<input type=radio name=mode_def_$i value=0 %s>\n",
428                         $mode ? "checked" : "";
429                 printf "<input name=mode_$i size=15 value='%s'></td>\n",
430                         $mode;
431
432                 local $rec = &sname("recurse", $f);
433                 print "<td><b>$text{'edit_filesrec'}</b></td> <td>\n";
434                 printf "<input type=radio name=rec_def_$i value=1 %s> %s\n",
435                         $rec ? "" : "checked", $text{'edit_none'};
436                 printf "<input type=radio name=rec_def_$i value=2 %s> %s\n",
437                         $rec eq 'inf' ? "checked" : "",
438                         $text{'edit_filesinf'};
439                 printf "<input type=radio name=rec_def_$i value=0 %s>\n",
440                         $rec && $rec ne 'inf' ? "checked" : "";
441                 printf "<input name=rec_$i size=6 value='%s'></td> </tr>\n",
442                         $rec eq 'inf' ? '' : $rec;
443
444                 local $size = &sname("size", $f);
445                 local $smode = $size =~ /^>/ ? 3 : $size =~ /^</ ? 2 :
446                                $size ne '' ? 1 : 0;
447                 print "<tr> <td><b>$text{'edit_copysize'}</b></td>\n";
448                 print "<td colspan=3>\n";
449                 printf "<input type=radio name=size_mode_$i value=0 %s> %s\n",
450                         $smode == 0 ? "checked" : "", $text{'edit_none'};
451
452                 printf "<input type=radio name=size_mode_$i value=2 %s> %s\n",
453                         $smode == 2 ? "checked" : "", $text{'edit_copysize2'};
454                 printf "<input name=size2_$i size=8 value='%s'>\n",
455                         $smode == 2 ? substr($size, 1) : "";
456
457                 printf "<input type=radio name=size_mode_$i value=1 %s> %s\n",
458                         $smode == 1 ? "checked" : "", $text{'edit_copysize1'};
459                 printf "<input name=size1_$i size=8 value='%s'>\n",
460                         $smode == 1 ? $size : "";
461
462                 printf "<input type=radio name=size_mode_$i value=3 %s> %s\n",
463                         $smode == 3 ? "checked" : "", $text{'edit_copysize3'};
464                 printf "<input name=size3_$i size=8 value='%s'>\n",
465                         $smode == 3 ? substr($size, 1) : "";
466
467                 local $backup = &sname("backup", $f);
468                 print "<tr> <td><b>$text{'edit_copybackup'}</b></td> <td>\n";
469                 printf "<input type=radio name=backup_$i value=1 %s> %s\n",
470                         $backup eq "false" ? "" : "checked", $text{'yes'};
471                 printf "<input type=radio name=backup_$i value=0 %s> %s</td>\n",
472                         $backup eq "false" ? "checked" : "", $text{'no'};
473
474                 local $force = &sname("force", $f);
475                 print "<td><b>$text{'edit_copyforce'}</b></td> <td>\n";
476                 printf "<input type=radio name=force_$i value=1 %s> %s\n",
477                         $force eq "true" ? "checked" : "", $text{'yes'};
478                 printf"<input type=radio name=force_$i value=0 %s> %s</td>\n",
479                         $force eq "true" ? "" : "checked", $text{'no'};
480                 print "</tr>\n";
481
482                 local $purge = &sname("purge", $f);
483                 print "<tr> <td><b>$text{'edit_copypurge'}</b></td> <td>\n";
484                 printf "<input type=radio name=purge_$i value=1 %s> %s\n",
485                         $purge eq "true" ? "checked" : "", $text{'yes'};
486                 printf"<input type=radio name=purge_$i value=0 %s> %s</td>\n",
487                         $purge eq "true" ? "" : "checked", $text{'no'};
488
489                 local $action = &sname("action", $f);
490                 local @acts = ( "fix", "silent", "warn" );
491                 print "<td><b>$text{'edit_copyact'}</b></td>\n";
492                 print "<td><select name=act_$i>\n";
493                 printf "<option value='' %s> %s\n",
494                         $action ? "" : "selected", $text{'default'};
495                 foreach $a (@acts) {
496                         printf "<option value=%s %s> %s\n",
497                                 $a, $action eq $a ? "selected" : "",
498                                 $text{"edit_copy_$a"};
499                         }
500                 print "<option selected>$action\n"
501                         if ($action && &indexof($action, @acts) < 0);
502                 print "</select></td> </tr>\n";
503
504                 $i++;
505                 }
506         if (!$in{'newcopy'} && !$in{'new'}) {
507                 print "<tr> <td colspan=4 align=right><hr><a href='edit_class.cgi?$in&newcopy=1'>$text{'edit_copynew'}</a></td>\n";
508                 }
509         }
510 elsif ($type eq "disable") {
511         # Editing files to disable or delete
512         local @dis = &parse_directories($cls);
513         local $i = 0;
514         foreach $f (@dis, $in{'newdis'} || $in{'new'} ? ( { } ) : ( ) ) {
515                 print "<tr> <td colspan=4><hr></td> </tr>\n";
516
517                 print "<tr> <td><b>$text{'edit_disfile'}</b></td>\n";
518                 print "<td colspan=3>";
519                 printf "<input type=radio name=dir_def_$i value=1 %s> %s\n",
520                         $f->{'_dir'} ? "" : "checked", $text{'edit_none'};
521                 printf "<input type=radio name=dir_def_$i value=0 %s>\n",
522                         $f->{'_dir'} ? "checked" : "";
523                 printf "<input name=dir_$i size=50 value='%s'></td> </tr>\n",
524                         $f->{'_dir'};
525
526                 local $rot = &sname("rotate", $f);
527                 print "<tr> <td><b>$text{'edit_disrot'}</b></td>\n";
528                 print "<td colspan=3>\n";
529                 printf "<input type=radio name=rot_mode_$i value=0 %s> %s\n",
530                         $rot eq '' ? "checked" : "", $text{'edit_disrot0'};
531                 printf "<input type=radio name=rot_mode_$i value=1 %s> %s\n",
532                         $rot eq 'empty' || $rot eq 'truncate' ? "checked" : "",
533                         $text{'edit_disrot1'};
534                 printf "<input type=radio name=rot_mode_$i value=2 %s>\n",
535                         $rot =~ /\d/ ? "checked" : "";
536                 print &text('edit_disrot2', sprintf("<input name=rot_$i size=6 value='%s'>", $rot =~ /\d/ ? $rot : undef)),"</td> </tr>\n";
537
538                 local $type = &sname("type", $f);
539                 local @types = ( "plain", "file", "link" );
540                 print "<tr> <td><b>$text{'edit_distype'}</b></td>\n";
541                 print "<td><select name=type_$i>\n";
542                 printf "<option value='' %s> %s\n",
543                         $type ? "" : "selected", $text{'edit_dis_all'};
544                 foreach $t (@types) {
545                         printf "<option value=%s %s> %s\n",
546                                 $t, $type eq $t ? "selected" : "",
547                                 $text{"edit_dis_$t"};
548                         }
549                 print "<option selected>$type\n"
550                         if ($type && &indexof($type, @types) < 0);
551                 print "</select></td>\n";
552
553                 local $size = &sname("size", $f);
554                 local $smode = $size =~ /^>/ ? 3 : $size =~ /^</ ? 2 :
555                                $size ne '' ? 1 : 0;
556                 print "<tr> <td><b>$text{'edit_dissize'}</b></td>\n";
557                 print "<td colspan=3>\n";
558                 printf "<input type=radio name=size_mode_$i value=0 %s> %s\n",
559                         $smode == 0 ? "checked" : "", $text{'edit_none'};
560
561                 printf "<input type=radio name=size_mode_$i value=2 %s> %s\n",
562                         $smode == 2 ? "checked" : "", $text{'edit_copysize2'};
563                 printf "<input name=size2_$i size=8 value='%s'>\n",
564                         $smode == 2 ? substr($size, 1) : "";
565
566                 printf "<input type=radio name=size_mode_$i value=1 %s> %s\n",
567                         $smode == 1 ? "checked" : "", $text{'edit_copysize1'};
568                 printf "<input name=size1_$i size=8 value='%s'>\n",
569                         $smode == 1 ? $size : "";
570
571                 printf "<input type=radio name=size_mode_$i value=3 %s> %s\n",
572                         $smode == 3 ? "checked" : "", $text{'edit_copysize3'};
573                 printf "<input name=size3_$i size=8 value='%s'>\n",
574                         $smode == 3 ? substr($size, 1) : "";
575
576                 $i++;
577                 }
578         if (!$in{'newdis'} && !$in{'new'}) {
579                 print "<tr> <td colspan=4 align=right><hr><a href='edit_class.cgi?$in&newdis=1'>$text{'edit_disnew'}</a></td>\n";
580                 }
581         }
582 elsif ($type eq "editfiles") {
583         # Allow editing of file-editor script
584         local $i = 0;
585         foreach $e (@{$cls->{'lists'}},
586                     $in{'newedit'} || $in{'new'} ? ( { } ) : ( ) ) {
587                 print "<tr> <td colspan=4><hr></td> </tr>\n";
588
589                 local $ef = $e->{'values'}->[0];
590                 print "<tr> <td><b>$text{'edit_editfile'}</b></td>\n";
591                 print "<td colspan=3>";
592                 printf "<input type=radio name=edit_def_$i value=1 %s> %s\n",
593                         $ef ? "" : "checked", $text{'edit_none'};
594                 printf "<input type=radio name=edit_def_$i value=0 %s>\n",
595                         $ef ? "checked" : "";
596                 printf "<input name=edit_$i size=50 value='%s'></td> </tr>\n",
597                         $ef;
598
599                 print "<tr> <td valign=top><b>$text{'edit_editscript'}</b>",
600                       "</td> <td colspan=3>\n";
601                 print "<textarea name=script_$i rows=7 cols=70>";
602                 shift(@{$e->{'values'}});
603                 shift(@{$e->{'valuelines'}});
604                 shift(@{$e->{'valuequotes'}});
605                 foreach $l (&value_lines($e->{'values'}, $e->{'valuelines'},
606                                          $e->{'valuequotes'})) {
607                         print &html_escape($l),"\n";
608                         }
609                 print "</textarea></td> </tr>\n";
610
611                 $i++;
612                 }
613         if (!$in{'newedit'} && !$in{'new'}) {
614                 print "<tr> <td colspan=4 align=right><hr><a href='edit_class.cgi?$in&newedit=1'>$text{'edit_editnew'}</a></td>\n";
615                 }
616         }
617 elsif ($type eq "ignore") {
618         # Display list of ignored files
619         print "<tr> <td valign=top><b>$text{'edit_ignore'}</b></td>\n";
620         print "<td colspan=3><textarea name=ignore rows=8 cols=50>";
621         foreach $v (@{$cls->{'valuequoted'}}) {
622                 print &html_escape($v),"\n";
623                 }
624         print "</textarea></td> </tr>\n";
625         }
626 elsif ($type eq "processes") {
627         # Show processes to kill
628         local @procs = &parse_processes($cls);
629         local $i = 0;
630         foreach $p (@procs, $in{'newproc'} || $in{'new'} ? ( { } ) : ( ) ) {
631                 if ($p->{'_options'}) {
632                         # Don't edit SetOptionString lines
633                         $i++;
634                         next;
635                         }
636                 print "<tr> <td colspan=4><hr></td> </tr>\n";
637
638                 print "<tr> <td><b>$text{'edit_proc'}</b></td>\n";
639                 print "<td colspan=3>";
640                 printf "<input type=radio name=proc_def_$i value=1 %s> %s\n",
641                         $p->{'_match'} ? "" : "checked", $text{'edit_none'};
642                 printf "<input type=radio name=proc_def_$i value=0 %s>\n",
643                         $p->{'_match'} ? "checked" : "";
644                 printf "<input name=proc_$i size=50 value='%s'></td> </tr>\n",
645                         $p->{'_match'};
646
647                 local $sig = &sname("signal", $p);
648                 print "<tr> <td><b>$text{'edit_procsig'}</b></td>\n";
649                 print "<td><select name=sig_$i>\n";
650                 printf "<option value='' %s>%s\n",
651                         $sig ? "" : "selected", $text{'edit_none'};
652                 foreach $s (split(/\s+/, $Config{sig_name})) {
653                         printf "<option value=%s %s> $s\n",
654                                 lc($s), lc($s) eq $sig ? "selected" : "", $s;
655                         }
656                 print "</select></td>\n";
657
658                 local $act = &sname("action", $p);
659                 print "<td><b>$text{'edit_procact'}</b></td>\n";
660                 print "<td><select name=act_$i>\n";
661                 printf "<option value='' %s>%s\n",
662                         !$act || $act eq 'signal' || $act eq 'do' ?
663                                 "selected" : "", $text{"edit_proc_signal"};
664                 printf "<option value=bymatch %s>%s\n",
665                         $act eq "bymatch" ? "selected" : "",
666                         $text{"edit_proc_bymatch"};
667                 printf "<option value=warn %s>%s\n",
668                         $act eq "warn" ? "selected" : "",
669                         $text{"edit_proc_warn"};
670                 print "</select></td> </tr>\n";
671
672                 local $mat = &sname("matches", $p);
673                 local $smode = $mat =~ /^>/ ? 3 : $mat =~ /^</ ? 2 :
674                                $mat ne '' ? 1 : 0;
675                 print "<tr> <td><b>$text{'edit_procmat'}</b></td>\n";
676                 print "<td colspan=3>\n";
677                 printf "<input type=radio name=mat_mode_$i value=0 %s> %s\n",
678                         $smode == 0 ? "checked" : "", $text{'edit_procmat0'};
679
680                 printf "<input type=radio name=mat_mode_$i value=2 %s> %s\n",
681                         $smode == 2 ? "checked" : "", $text{'edit_procmat2'};
682                 printf "<input name=mat2_$i size=8 value='%s'>\n",
683                         $smode == 2 ? substr($mat, 1) : "";
684
685                 printf "<input type=radio name=mat_mode_$i value=1 %s> %s\n",
686                         $smode == 1 ? "checked" : "", $text{'edit_procmat1'};
687                 printf "<input name=mat1_$i size=8 value='%s'>\n",
688                         $smode == 1 ? $mat : "";
689
690                 printf "<input type=radio name=mat_mode_$i value=3 %s> %s\n",
691                         $smode == 3 ? "checked" : "", $text{'edit_procmat3'};
692                 printf "<input name=mat3_$i size=8 value='%s'>\n",
693                         $smode == 3 ? substr($mat, 1) : "";
694
695                 print "<tr> <td><b>$text{'edit_procrestart'}</b></td>\n";
696                 print "<td colspan=3>";
697                 printf "<input type=radio name=restart_def_$i value=1 %s> %s\n",
698                         $p->{'_restart'} ? "" : "checked", $text{'edit_none'};
699                 printf "<input type=radio name=restart_def_$i value=0 %s>\n",
700                         $p->{'_restart'} ? "checked" : "";
701                 printf "<input name=restart_$i size=50 value='%s'></td></tr>\n",
702                         $p->{'_restart'};
703
704                 local $owner = &sname("owner", $p);
705                 print "<tr> <td><b>$text{'edit_procowner'}</b></td> <td>\n";
706                 printf "<input type=radio name=owner_def_$i value=1 %s> %s\n",
707                         $owner ? "" : "checked", "<tt>root</tt>";
708                 printf "<input type=radio name=owner_def_$i value=0 %s>\n",
709                         $owner ? "checked" : "";
710                 printf "<input name=owner_$i size=13 value='%s'></td>\n",
711                         $owner;
712
713                 local $group = &sname("group", $p);
714                 print "<td><b>$text{'edit_procgroup'}</b></td> <td>\n";
715                 printf "<input type=radio name=group_def_$i value=1 %s> %s\n",
716                         $group ? "" : "checked", "<tt>root</tt>";
717                 printf "<input type=radio name=group_def_$i value=0 %s>\n",
718                         $group ? "checked" : "";
719                 printf "<input name=group_$i size=13 value='%s'></td> </tr>\n",
720                         $group;
721
722                 $i++;
723                 }
724         if (!$in{'newproc'} && !$in{'new'}) {
725                 print "<tr> <td colspan=4 align=right><hr><a href='edit_class.cgi?$in&newproc=1'>$text{'edit_procnew'}</a></td>\n";
726                 }
727         }
728 elsif ($type eq "shellcommands") {
729         # Edit list of executed shell commands
730         local @cmds = &parse_directories($cls);
731         print "<tr> <td colspan=4><table border width=100%>\n";
732         print "<tr $tb> <td><b>$text{'edit_cmd'}</b></td> ",
733               "<td><b>$text{'edit_cmdowner'}</b></td> ",
734               "<td><b>$text{'edit_cmdgroup'}</b></td> ",
735               "<td><b>$text{'edit_cmdtimeout'}</b></td> </tr>\n";
736         $i = 0;
737         foreach $c (@cmds, { }) {
738                 print "<tr $cb>\n";
739                 printf "<td><input name=cmd_$i size=40 value='%s'></td>\n",
740                         $c->{'_dir'};
741                 printf "<td><input name=owner_$i size=13 value='%s'></td>\n",
742                         &sname("owner", $c);
743                 printf "<td><input name=group_$i size=13 value='%s'></td>\n",
744                         &sname("group", $c);
745                 printf"<td><input name=timeout_$i size=6 value='%s'> %s</td>\n",
746                         &sname("timeout", $c), "secs";
747                 print "</tr>\n";
748                 $i++;
749                 }
750         print "</table></td> </tr>\n";
751         }
752 elsif ($type eq "tidy") {
753         # Allow editing of directories to tidy up
754         local @dirs = &parse_directories($cls);
755         local $i = 0;
756         foreach $d (@dirs, $in{'newtidy'} || $in{'new'} ? ( { } ) : ( ) ) {
757                 print "<tr> <td colspan=4><hr></td> </tr>\n";
758
759                 print "<tr> <td><b>$text{'edit_tidydir'}</b></td>\n";
760                 print "<td colspan=3>";
761                 printf "<input type=radio name=dir_def_$i value=1 %s> %s\n",
762                         $d->{'_dir'} ? "" : "checked", $text{'edit_none'};
763                 printf "<input type=radio name=dir_def_$i value=0 %s>\n",
764                         $d->{'_dir'} ? "checked" : "";
765                 printf "<input name=dir_$i size=50 value='%s'></td> </tr>\n",
766                         $d->{'_dir'};
767
768                 local $pat = &sname("pattern", $d);
769                 print "<tr> <td><b>$text{'edit_tidypat'}</b></td>\n";
770                 print "<td colspan=3>";
771                 printf "<input type=radio name=pat_def_$i value=1 %s> %s\n",
772                         $pat ? "" : "checked", $text{'edit_filesall'};
773                 printf "<input type=radio name=pat_def_$i value=0 %s>\n",
774                         $pat ? "checked" : "";
775                 printf "<input name=pat_$i size=50 value='%s'></td> </tr>\n",
776                         $pat;
777
778                 local $size = &sname("size", $d);
779                 print "<tr> <td><b>$text{'edit_tidysize'}</b></td>\n";
780                 print "<td colspan=3>";
781                 printf "<input type=radio name=smode_$i value=0 %s> %s\n",
782                         $size eq '' ? "checked" : "", $text{'edit_tidysize0'};
783                 printf "<input type=radio name=smode_$i value=1 %s> %s\n",
784                         $size eq 'empty' ? "checked" : "",
785                         $text{'edit_tidysize1'};
786                 printf "<input type=radio name=smode_$i value=2 %s> %s\n",
787                         $size eq 'empty' || $size eq '' ? "" : "checked",
788                         $text{'edit_tidysize2'};
789                 printf "<input name=size_$i size=6 value='%s'></td> </tr>\n",
790                         $size eq 'empty' ? "" : $size;
791
792                 local $age = &sname("age", $d);
793                 local $type = &sname("type", $d);
794                 print "<tr> <td><b>$text{'edit_tidyage'}</b></td>\n";
795                 print "<td colspan=3>";
796                 printf "<input type=radio name=age_def_$i value=1 %s> %s\n",
797                         $age eq '' ? "checked" : "", $text{'edit_tidyage1'};
798                 printf "<input type=radio name=age_def_$i value=0 %s>\n",
799                         $age eq '' ? "" : "checked";
800                 local $asel = "<select name=type_$i>";
801                 $asel .= sprintf "<option value='' %s>%s\n",
802                                 $type eq 'atime' || !$type ? "selected" : "",
803                                 $text{'edit_tidyatime'};
804                 $asel .= sprintf "<option value=mtime %s>%s\n",
805                     $type eq 'mtime' ? "selected" : "", $text{'edit_tidymtime'};
806                 $asel .= sprintf "<option value=ctime %s>%s\n",
807                     $type eq 'ctime' ? "selected" : "", $text{'edit_tidyctime'};
808                 $asel .= "</select>\n";
809                 local $afield = "<input name=age_$i size=5 value='$age'>\n";
810                 print &text('edit_tidyage0', $asel, $afield),"</td> </tr>\n";
811
812                 local $rec = &sname("recurse", $d);
813                 print "<td><b>$text{'edit_filesrec'}</b></td> <td>\n";
814                 printf "<input type=radio name=rec_def_$i value=1 %s> %s\n",
815                         $rec ? "" : "checked", $text{'edit_none'};
816                 printf "<input type=radio name=rec_def_$i value=2 %s> %s\n",
817                         $rec eq 'inf' ? "checked" : "",
818                         $text{'edit_filesinf'};
819                 printf "<input type=radio name=rec_def_$i value=0 %s>\n",
820                         $rec && $rec ne 'inf' ? "checked" : "";
821                 printf "<input name=rec_$i size=6 value='%s'></td> </tr>\n",
822                         $rec eq 'inf' ? '' : $rec;
823
824                 $i++;
825                 }
826         if (!$in{'newtidy'} && !$in{'new'}) {
827                 print "<tr> <td colspan=4 align=right><hr><a href='edit_class.cgi?$in&newtidy=1'>$text{'edit_tidynew'}</a></td>\n";
828                 }
829         }
830 elsif ($type eq "miscmounts") {
831         # Display filesystems to mount
832         local @mnts = &parse_miscmounts($cls);
833         print "<tr> <td colspan=4><table border width=100%>\n";
834         print "<tr $tb> <td><b>$text{'edit_miscsrc'}</b></td> ",
835               "<td><b>$text{'edit_miscdest'}</b></td> ",
836               "<td><b>$text{'edit_miscmode'}</b></td> </tr>\n";
837         local $i = 0;
838         foreach $m (@mnts, { }) {
839                 print "<tr $cb>\n";
840                 printf "<td><input name=src_$i size=30 value='%s'></td>\n",
841                         $m->{'_src'};
842                 printf "<td><input name=dest_$i size=30 value='%s'></td>\n",
843                         $m->{'_dest'};
844                 printf "<td><input name=mode_$i size=10 value='%s'></td>\n",
845                         &sname("mode", $m);
846                 print "</tr>\n";
847                 $i++;
848                 }
849         print "</table></td></tr>\n";
850         }
851 elsif ($type eq "resolve") {
852         # Display nameserver options
853         local (@ns, @other);
854         for($i=0; $i<@{$cls->{'values'}}; $i++) {
855                 if ($cls->{'valuequotes'}->[$i]) {
856                         push(@other, $cls->{'values'}->[$i]);
857                         }
858                 else {
859                         push(@ns, $cls->{'values'}->[$i]);
860                         }
861                 }
862         print "<tr> <td valign=top><b>$text{'edit_resns'}</b></td>\n";
863         print "<td><textarea name=ns rows=4 cols=20>",
864                 join("\n", @ns),"</textarea></td>\n";
865
866         print "<td valign=top><b>$text{'edit_resother'}</b></td>\n";
867         print "<td><textarea name=other rows=4 cols=20>",
868                 join("\n", @other),"</textarea></td> </tr>\n";
869         }
870 elsif ($type eq "defaultroute") {
871         # Display the default route
872         printf "<tr> <td><b>$text{'edit_route'}</b></td>\n";
873         printf "<td><input name=route size=25 value='%s'></td> </tr>\n",
874                 $cls->{'values'}->[0];
875         }
876 elsif ($type eq "required" || $type eq "disks") {
877         # Display filesystems to check
878         local @reqs = &parse_directories($cls);
879         print "<tr> <td colspan=4><table border>\n";
880         print "<tr $tb> <td><b>$text{'edit_reqfs'}</b></td> ",
881               "<td><b>$text{'edit_reqfree'}</b></td> </tr>\n";
882         local $i = 0;
883         foreach $r (@reqs, { }) {
884                 print "<tr $cb>\n";
885                 printf "<td><input name=fs_$i size=40 value='%s'></td> <td>\n",
886                         $r->{'_dir'};
887                 local $free = &sname("freespace", $r);
888                 printf "<input type=radio name=free_def_$i value=1 %s> %s\n",
889                         $free eq '' ? "checked" : "", $text{'edit_none'};
890                 printf "<input type=radio name=free_def_$i value=0 %s>\n",
891                         $free eq '' ? "" : "checked";
892                 printf "<input name=free_$i size=10 value='%s'></td>\n", $free;
893                 print "</tr>\n";
894                 print "</tr>\n";
895                 $i++;
896                 }
897         print "</table></td></tr>\n";
898         }
899 else {
900         # Allow editing of class manually
901         if (!$in{'new'}) {
902                 $lref = &read_file_lines($cls->{'file'});
903                 local $st = $cls->{'line'};
904                 local $en = $cls->{'eline'};
905                 if ($lref->[$st] =~ /^\s*(\S+)::\s*$/ && $1 eq $cls->{'name'}) {
906                         $st++;
907                         }
908                 print "<tr> <td colspan=4><b>",&text('edit_manualtext2',
909                                 $st, $en, "<tt>$cls->{'file'}</tt>"),"</b>\n";
910                 print "<br><textarea name=manual rows=15 cols=70>\n";
911                 for($i=$st; $i<=$en; $i++) {
912                         print &html_escape($lref->[$i]),"\n";
913                         }
914                 print "</textarea></td> </tr>\n";
915                 }
916         else {
917                 print "<tr> <td colspan=4><b>$text{'edit_manualtext'}</b>\n";
918                 print "<br><textarea name=manual rows=15 cols=70>\n";
919                 print "</textarea></td> </tr>\n";
920                 }
921         }
922
923 print "</table></td></tr></table>\n";
924 print "<table width=100%><tr>\n";
925 if ($in{'new'}) {
926         print "<td><input type=submit value='$text{'create'}'></td>\n";
927         }
928 else {
929         print "<td><input type=submit value='$text{'save'}'></td>\n";
930         print "<td align=middle><input type=submit name=manualmode ",
931               "value='$text{'edit_manual'}'></td>\n" if (!$in{'manual'});
932         print "<td align=right><input type=submit name=delete ",
933               "value='$text{'delete'}'></td>\n";
934         }
935 print "</tr></table>\n";
936 print "</form>\n";
937
938 if ($in{'cfd'}) {
939         &ui_print_footer("edit_cfd.cgi", $text{'cfd_return'},
940                 "", $text{'index_return'});
941         }
942 else {
943         &ui_print_footer("", $text{'index_return'});
944         }
945
946 # sname(name, &hash)
947 sub sname
948 {
949 local $i;
950 for($i=length($_[0]); $i>0; $i--) {
951         local $s = substr($_[0], 0, $i);
952         return $_[1]->{$s} if (defined($_[1]->{$s}));
953         }
954 return undef;
955 }
956