3 # Edit options for a class in some section
5 require './cfengine-lib.pl';
8 $conf = $in{'cfd'} ? &get_cfd_config() : &get_config();
9 $sec = $conf->[$in{'idx'}] if ($in{'idx'} ne '');
11 &ui_print_header(undef, $sec ? $text{'edit_create2'} : $text{'edit_create1'}, "",
13 $cls = { 'name' => 'any' };
16 &ui_print_header(undef, $text{'edit_title'}, "", "edit");
17 $cls = $sec->{'cls'}->[$in{'cidx'}];
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";
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";
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";
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'};
45 $type = undef if ($in{'manual'});
46 if ($text{"type_".$type."_".$in{'cfd'}}) {
47 print "<tr> <td colspan=4>",$text{"type_".$type."_".$in{'cfd'}},
50 elsif ($text{"type_".$type}) {
51 print "<tr> <td colspan=4>",$text{"type_".$type},"</td> </tr>\n";
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";
63 foreach $l (@links, { }) {
65 printf "<td><input name=from_$i size=30 value='%s'></td>\n",
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",
74 print "</table></td> </tr>\n";
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";
85 foreach $d (@dirs, { }) {
87 printf "<td><input name=dir_$i size=40 value='%s'></td>\n",
89 printf "<td><input name=mode_$i size=4 value='%s'></td>\n",
91 printf "<td><input name=owner_$i size=13 value='%s'></td>\n",
93 printf "<td><input name=group_$i size=13 value='%s'></td>\n",
98 print "</table></td> </tr>\n";
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";
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";
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";
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";
125 foreach $d (@{$cls->{'defs'}}, { }) {
126 next if ($d->{'name'} eq 'actionsequence');
128 printf "<td><input name=def_$i size=15 value='%s'></td>\n",
130 printf "<td colspan=3><input name=value_$i size=50 value='%s'></td>\n", join(" ", @{$d->{'valuequoted'}});
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;
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;
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;
161 print "<tr> <td colspan=4><hr></td> </tr>\n";
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;
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;
179 print "<tr> <td colspan=4><hr></td> </tr>\n";
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;
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'};
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",
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",
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",
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'}}) {
230 push(@grants, $grant = { 'dir' => $v });
233 push(@{$grant->{'hosts'}}, $v);
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";
242 foreach $g (@grants, { }) {
244 printf "<td><input name=dir_$i size=20 value='%s'></td>\n",
246 printf "<td><input name=hosts_$i size=40 value='%s'></td>\n",
247 join(" ", @{$g->{'hosts'}});
251 print "</table></td></tr>\n";
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";
260 foreach $g (@{$cls->{'defs'}}, { }) {
262 printf "<td><input name=name_$i size=15 value='%s'></td>\n",
264 printf "<td><input name=mems_$i size=45 value='%s'></td>\n",
265 join(" ", @{$g->{'valuequoted'}});
269 print "</table></td></tr>\n";
271 elsif ($type eq "files") {
272 # Allow editing of file permission settings
273 local @files = &parse_directories($cls);
275 foreach $f (@files, $in{'newfiles'} || $in{'new'} ? ( { } ) : ( ) ) {
276 print "<tr> <td colspan=4><hr></td> </tr>\n";
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",
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",
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",
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",
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;
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",
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",
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",
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'};
360 printf "<option value=%s %s> %s\n",
361 $a, $action eq $a ? "selected" : "",
362 $text{"edit_files_$a"};
364 print "<option selected>$action\n"
365 if ($action && &indexof($action, @acts) < 0);
366 print "</select></td> </tr>\n";
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";
374 elsif ($type eq "copy") {
375 # Allow editing of file copy options
376 local @copies = &parse_directories($cls);
378 foreach $f (@copies, $in{'newcopy'} || $in{'new'} ? ( { } ) : ( ) ) {
379 print "<tr> <td colspan=4><hr></td> </tr>\n";
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",
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",
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",
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",
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",
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",
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;
444 local $size = &sname("size", $f);
445 local $smode = $size =~ /^>/ ? 3 : $size =~ /^</ ? 2 :
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'};
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) : "";
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 : "";
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) : "";
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'};
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'};
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'};
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'};
496 printf "<option value=%s %s> %s\n",
497 $a, $action eq $a ? "selected" : "",
498 $text{"edit_copy_$a"};
500 print "<option selected>$action\n"
501 if ($action && &indexof($action, @acts) < 0);
502 print "</select></td> </tr>\n";
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";
510 elsif ($type eq "disable") {
511 # Editing files to disable or delete
512 local @dis = &parse_directories($cls);
514 foreach $f (@dis, $in{'newdis'} || $in{'new'} ? ( { } ) : ( ) ) {
515 print "<tr> <td colspan=4><hr></td> </tr>\n";
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",
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";
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"};
549 print "<option selected>$type\n"
550 if ($type && &indexof($type, @types) < 0);
551 print "</select></td>\n";
553 local $size = &sname("size", $f);
554 local $smode = $size =~ /^>/ ? 3 : $size =~ /^</ ? 2 :
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'};
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) : "";
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 : "";
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) : "";
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";
582 elsif ($type eq "editfiles") {
583 # Allow editing of file-editor script
585 foreach $e (@{$cls->{'lists'}},
586 $in{'newedit'} || $in{'new'} ? ( { } ) : ( ) ) {
587 print "<tr> <td colspan=4><hr></td> </tr>\n";
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",
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";
609 print "</textarea></td> </tr>\n";
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";
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";
624 print "</textarea></td> </tr>\n";
626 elsif ($type eq "processes") {
627 # Show processes to kill
628 local @procs = &parse_processes($cls);
630 foreach $p (@procs, $in{'newproc'} || $in{'new'} ? ( { } ) : ( ) ) {
631 if ($p->{'_options'}) {
632 # Don't edit SetOptionString lines
636 print "<tr> <td colspan=4><hr></td> </tr>\n";
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",
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;
656 print "</select></td>\n";
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";
672 local $mat = &sname("matches", $p);
673 local $smode = $mat =~ /^>/ ? 3 : $mat =~ /^</ ? 2 :
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'};
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) : "";
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 : "";
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) : "";
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",
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",
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",
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";
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";
737 foreach $c (@cmds, { }) {
739 printf "<td><input name=cmd_$i size=40 value='%s'></td>\n",
741 printf "<td><input name=owner_$i size=13 value='%s'></td>\n",
743 printf "<td><input name=group_$i size=13 value='%s'></td>\n",
745 printf"<td><input name=timeout_$i size=6 value='%s'> %s</td>\n",
746 &sname("timeout", $c), "secs";
750 print "</table></td> </tr>\n";
752 elsif ($type eq "tidy") {
753 # Allow editing of directories to tidy up
754 local @dirs = &parse_directories($cls);
756 foreach $d (@dirs, $in{'newtidy'} || $in{'new'} ? ( { } ) : ( ) ) {
757 print "<tr> <td colspan=4><hr></td> </tr>\n";
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",
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",
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;
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";
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;
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";
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";
838 foreach $m (@mnts, { }) {
840 printf "<td><input name=src_$i size=30 value='%s'></td>\n",
842 printf "<td><input name=dest_$i size=30 value='%s'></td>\n",
844 printf "<td><input name=mode_$i size=10 value='%s'></td>\n",
849 print "</table></td></tr>\n";
851 elsif ($type eq "resolve") {
852 # Display nameserver options
854 for($i=0; $i<@{$cls->{'values'}}; $i++) {
855 if ($cls->{'valuequotes'}->[$i]) {
856 push(@other, $cls->{'values'}->[$i]);
859 push(@ns, $cls->{'values'}->[$i]);
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";
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";
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];
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";
883 foreach $r (@reqs, { }) {
885 printf "<td><input name=fs_$i size=40 value='%s'></td> <td>\n",
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;
897 print "</table></td></tr>\n";
900 # Allow editing of class manually
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'}) {
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";
914 print "</textarea></td> </tr>\n";
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";
923 print "</table></td></tr></table>\n";
924 print "<table width=100%><tr>\n";
926 print "<td><input type=submit value='$text{'create'}'></td>\n";
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";
935 print "</tr></table>\n";
939 &ui_print_footer("edit_cfd.cgi", $text{'cfd_return'},
940 "", $text{'index_return'});
943 &ui_print_footer("", $text{'index_return'});
950 for($i=length($_[0]); $i>0; $i--) {
951 local $s = substr($_[0], 0, $i);
952 return $_[1]->{$s} if (defined($_[1]->{$s}));