3 # Display extra header and body test
5 require './spam-lib.pl';
7 &set_config_file_in(\%in);
8 &can_use_check("header");
9 &ui_print_header($header_subtext, $text{'header_title'}, "");
10 $conf = &get_config();
12 print "$text{'header_desc'}<p>\n";
13 &start_form("save_header.cgi", $text{'header_header'},
14 "<a href='edit_simple.cgi?file=".&urlize($in{'file'}).
15 "&title=".&urlize($in{'title'}).
16 "'>$text{'header_switch'}</a>");
18 # Allow user-defined rules?
19 if (!$module_info{'usermin'}) {
20 $allow = &find("allow_user_rules", $conf);
21 print &ui_table_row($text{'header_allow'},
22 &yes_no_field("allow_user_rules", $allow, 0));
26 @header = &find("header", $conf);
27 print &ui_table_row($text{'header_test'},
29 [ $text{'header_tname'}, $text{'header_name'}, $text{'header_op'},
30 $text{'header_pat'}, $text{'header_default'} ],
31 [ map { [ &split_header($_->{'value'}) ] } @header ], [ ], \&header_conv, 2));
35 push(@body, map { [ &split_body($_->{'value'}), 0 ] } &find("body", $conf));
36 push(@body, map { [ &split_body($_->{'value'}), 1 ] } &find("rawbody", $conf));
37 push(@body, map { [ &split_body($_->{'value'}), 2 ] } &find("fullbody", $conf));
38 push(@body, map { [ &split_body($_->{'value'}), 3 ] } &find("full", $conf));
39 print &ui_table_row($text{'header_body'},
41 [ $text{'header_tname'}, $text{'header_mode'}, $text{'header_op'},
42 $text{'header_pat'} ], \@body, [ ], \&body_conv, 2));
46 @uri = &find("uri", $conf);
47 print &ui_table_row($text{'header_uri'},
49 [ $text{'header_tname'}, $text{'header_pat'} ],
50 [ map { $_->{'words'} } @uri ], [ 20, 40 ], undef, 2));
54 @meta = &find("meta", $conf);
55 print &ui_table_row($text{'header_meta'},
57 [ $text{'header_tname'}, $text{'header_bool'} ],
58 [ map { $_->{'value'} =~ /^(\S+)\s*(.*)$/ ? [ $1, $2 ] : [ ] } @meta ],
59 [ 20, 40 ], undef, 2));
63 @score = &find("score", $conf);
64 print &ui_table_row($text{'score_score'},
66 [ $text{'score_name'}, $text{'score_points'} ],
67 [ map { $_->{'words'} } @score ], [ 30, 6 ]));
69 @describe = &find("describe", $conf);
70 print &ui_table_row($text{'score_describe'},
71 &edit_table("describe",
72 [ $text{'score_name'}, $text{'score_descr'} ],
73 [ map { $_->{'value'} =~ /^(\S+)\s*(.*)/ ? [ $1, $2 ] : [ ] }
74 @describe ], [ 30, 40 ]));
76 &end_form(undef, $text{'save'});
77 &ui_print_footer($redirect_url, $text{'index_return'});
79 # header_conv(col, name, size, value, &values)
83 return &ui_textbox($_[1], $_[3], 20);
86 local $h = $_[3] =~ /^exists:(\S+)$/ ? $1 : $_[3] =~ /^eval:/ ? "" : $_[3];
87 return &ui_textbox($_[1], $h, 15);
90 local $v = $_[4]->[1] =~ /^exists:/ ? 'exists' :
91 $_[4]->[1] =~ /^eval:/ ? 'eval' : $_[3];
92 return &ui_select($_[1], $v,
93 [ [ '=~', $text{'header_op0'} ],
94 [ '!~', $text{'header_op1'} ],
95 [ 'exists', $text{'header_op2'} ],
96 [ 'eval', $text{'header_op3'} ] ], 1, 0, $v);
99 return &ui_textbox($_[1], $_[4]->[1] =~ /^eval:(.*)/ ? $1 : $_[3], 20);
102 return &ui_textbox($_[1], $_[3], 15);
106 # body_conv(col, name, size, value, &values)
110 return &ui_textbox($_[1], $_[4]->[0], 20);
113 return &ui_select($_[1], $_[4]->[2],
114 [ [ 0, $text{'header_mode0'} ],
115 [ 1, $text{'header_mode1'} ],
116 [ 2, $text{'header_mode2'} ],
117 [ 3, $text{'header_mode3'} ] ]);
120 return &ui_select($_[1], $_[4]->[1] =~ /^eval:/ ? 1 : 0,
121 [ [ 0, $text{'header_op0'} ],
122 [ 1, $text{'header_op3'} ] ]);
125 return &ui_textbox($_[1], $_[4]->[1] =~ /^eval:(.*)$/ ? $1 : $_[4]->[1],
132 if ($_[0] =~ /^(\S+)\s+(eval:\S+\(.*\))/) {
135 elsif ($_[0] =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\/.*\/\S*)\s*(if-unset:\s*(.*))?/) {
136 return ($1, $2, $3, $4, $6);
145 if ($_[0] =~ /^(\S+)\s+((\/.*\/\S*)|(eval:\S+\(.*\)))/) {