3 # Display a list of all active rules
4 require './itsecur-lib.pl';
6 &can_use_error("rules");
7 &header($text{'rules_title'}, "",
8 undef, undef, undef, undef, &apply_button());
12 # 0-No. 1-Source,2-Destination, 3-Services, 4-Time, 5-Action, 6-Enabled, 7-Comment
13 local @CW=( "5%", "15%", "15%", "20%", "5%", "5%", "5%", "20%");
17 $C_disabled="#FF3333";
18 $C_separator="#ffffcc";
22 @rules = &list_rules();
23 @servs = &list_services();
24 $edit = &can_edit("rules");
25 $times = &supports_time() && &list_times() > 0;
28 print "<a href='edit_rule.cgi?new=1'>$text{'rules_add'}</a>\n";
30 print "<a href='edit_sep.cgi?new=1'>$text{'rules_sadd'}</a>\n";
32 print "<form action=enable_rules.cgi method=post>\n";
34 $cols = $times ? 8 : 7;
35 print "<table border>\n";
37 "<td width=$CW[0]><b>$text{'rule_num'}</b></td> ",
38 "<td width=$CW[1]><b>$text{'rule_source'}</b></td> ",
39 "<td width=$CW[2]><b>$text{'rule_dest'}</b></td> ",
40 "<td width=$CW[3]><b>$text{'rules_service'}</b></td> ",
41 ($times ? "<td><b>$text{'rule_time'}</b></td> " : ""),
42 "<td width=$CW[5]><b>$text{'rule_action'}</b></td> ",
43 "<td width=$CW[6]><b>$text{'rule_enabled'}</b></td> ",
44 ($config{'show_desc'} ? "<td width=$CW[7]><b>$text{'rules_desc'}</b></td> " :
45 "<td width=10><b>$text{'rules_move'}</b></td>"),
49 $Row_Color="bgcolor=\"$C_separator\" ";
50 } elsif (!$r->{'enabled'}){
51 $Row_Color="bgcolor=\"$C_disabled\" ";
52 } elsif ( $r->{'action'} eq "drop" ){
53 $Row_Color="bgcolor=\"$C_drop\" ";
54 } elsif ( $r->{'action'} eq "reject" ){
55 $Row_Color="bgcolor=\"$C_reject\" ";
68 print "<tr $Row_Color $cb>\n";
70 # Actually a separator - just show it's description
71 print "<td colspan=$cols><b><a href='edit_sep.cgi?idx=$r->{'index'}'>$r->{'desc'}</b></a></td>\n";
74 # Show full rule details
77 print "<td width=$CW[0]>";
79 print "<input type=checkbox name=r value=$r->{'index'}> ";
81 print "<a href='edit_rule.cgi?",
82 "idx=$r->{'index'}'>$r->{'num'}</a></td>\n";
83 print "<td width=$CW[1]>",
84 &group_names_link($r->{'source'}, 'rules'),
86 print "<td width=$CW[2]>",
87 &group_names_link($r->{'dest'}, 'rules',
88 &allow_action($r) ? 'dest' : undef),
90 print "<td width=$CW[3]>",&protocol_names($r->{'service'},\@servs),"</td>\n";
92 print "<td>",$r->{'time'} eq '*' ?
93 $text{'rule_anytime'} :
94 $r->{'time'},"</td>\n";
96 print "<td width=$CW[5]>",$text{'rule_'.$r->{'action'}},
97 $r->{'log'} ? " $text{'rules_log'}" : "","</td>\n";
98 print "<td width=$CW[6]>",$r->{'enabled'} ? $text{'yes'} :
99 "<font color=#ff0000>$text{'no'}</font>",
101 if ($config{'show_desc'}) {
102 print "<td width=$CW[7]>",$r->{'desc'} eq "*" ? "<br>"
103 : $r->{'desc'},"</td>\n";
106 if ($r eq $rules[0] || !$edit) {
107 print "<td><img src=images/gap.gif>\n";
110 print "<td><a href='up.cgi?idx=$r->{'index'}'>",
111 "<img src=images/up.gif border=0></a>\n";
113 if ($r eq $rules[$#rules] || !$edit) {
114 print "<img src=images/gap.gif></td>\n";
117 print "<a href='down.cgi?idx=$r->{'index'}'>",
118 "<img src=images/down.gif border=0></a></td>\n";
127 print "<b>$text{'rules_none'}</b><p>\n";
130 print "<a href='edit_rule.cgi?new=1'>$text{'rules_add'}</a>\n";
132 print "<a href='edit_sep.cgi?new=1'>$text{'rules_sadd'}</a>\n";
135 if ($edit && @rules) {
136 print "<input type=submit name=enable value='$text{'rules_enable'}'>\n";
137 print "<input type=submit name=disable value='$text{'rules_disable'}'>\n";
140 print "<input type=submit name=logon value='$text{'rules_logon'}'>\n";
141 print "<input type=submit name=logoff value='$text{'rules_logoff'}'>\n";
143 print "<input type=submit name=delete value='$text{'rules_delete'}'>\n";
148 &footer("", $text{'index_return'});