firewall_rules.php 31.4 KB
Newer Older
Ad Schellevis's avatar
Ad Schellevis committed
1
<?php
2

Ad Schellevis's avatar
Ad Schellevis committed
3
/*
4 5 6 7
    Copyright (C) 2014-2015 Deciso B.V.
    Copyright (C) 2005 Scott Ullrich (sullrich@gmail.com)
    Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
    All rights reserved.
8

9 10
    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are met:
11

12 13
    1. Redistributions of source code must retain the above copyright notice,
       this list of conditions and the following disclaimer.
14

15 16 17
    2. Redistributions in binary form must reproduce the above copyright
       notice, this list of conditions and the following disclaimer in the
       documentation and/or other materials provided with the distribution.
18

19 20 21 22 23 24 25 26 27 28
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    POSSIBILITY OF SUCH DAMAGE.
Ad Schellevis's avatar
Ad Schellevis committed
29 30
*/

31
require_once("guiconfig.inc");
Ad Schellevis's avatar
Ad Schellevis committed
32
require_once("filter.inc");
33
require_once("pfsense-utils.inc");
Ad Schellevis's avatar
Ad Schellevis committed
34 35


36
if (!isset($config['filter']['rule'])) {
37
    $config['filter']['rule'] = array();
38
}
Ad Schellevis's avatar
Ad Schellevis committed
39

40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
$a_filter = &$config['filter']['rule'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (isset($_GET['if'])) {
        $current_if = htmlspecialchars($_GET['if']);
    } else {
        $current_if = "FloatingRules";
    }
    $pconfig = $_POST;
    if (isset($pconfig['id']) && isset($a_filter[$pconfig['id']])) {
        // id found and valid
        $id = $pconfig['id'];
    }
    if (isset($pconfig['apply'])) {
        filter_configure();
        clear_subsystem_dirty('filter');
        $savemsg = sprintf(gettext("The settings have been applied. The firewall rules are now reloading in the background.<br />You can also %s monitor %s the reload progress"),"<a href='status_filter_reload.php'>","</a>");
    } elseif (isset($pconfig['act']) && $pconfig['act'] == 'del' && isset($id)) {
        // delete single item
        if (!empty($a_filter[$id]['associated-rule-id'])) {
            // unlink nat entry
            if (isset($config['nat']['rule'])) {
                $a_nat = &$config['nat']['rule'];
                foreach ($a_nat as &$natent) {
                    if ($natent['associated-rule-id'] == $a_filter[$id]['associated-rule-id']) {
                        $natent['associated-rule-id'] = '';
                    }
                }
            }
        }
        unset($a_filter[$id]);
        if (write_config()) {
            mark_subsystem_dirty('filter');
        }
        header("Location: firewall_rules.php?if=" . htmlspecialchars($current_if));
        exit;
    } elseif (isset($pconfig['act']) && $pconfig['act'] == 'del_x' && isset($pconfig['rule']) && count($pconfig['rule']) > 0) {
        // delete selected rules
        foreach ($pconfig['rule'] as $rulei) {
            // unlink nat entry
            if (isset($config['nat']['rule'])) {
                $a_nat = &$config['nat']['rule'];
                foreach ($a_nat as &$natent) {
                    if ($natent['associated-rule-id'] == $a_filter[$rulei]['associated-rule-id']) {
                        $natent['associated-rule-id'] = '';
                    }
                }
            }
            unset($a_filter[$rulei]);
        }
        if (write_config()) {
            mark_subsystem_dirty('filter');
        }
        header("Location: firewall_rules.php?if=" . htmlspecialchars($current_if));
        exit;
    } elseif ( isset($pconfig['act']) && $pconfig['act'] == 'move' && isset($pconfig['rule']) && count($pconfig['rule']) > 0) {
        // move selected rules
        if (!isset($id)) {
            // if rule not set/found, move to end
98
            $id = count($a_filter);
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
        }
        $a_filter = legacy_move_config_list_items($a_filter, $id,  $pconfig['rule']);
        if (write_config()) {
            mark_subsystem_dirty('filter');
        }
        header("Location: firewall_rules.php?if=" . htmlspecialchars($current_if));
        exit;

    } elseif (isset($pconfig['act']) && $pconfig['act'] == 'toggle' && isset($id)) {
        // toggle item
        if(isset($a_filter[$id]['disabled'])) {
            unset($a_filter[$id]['disabled']);
        } else {
            $a_filter[$id]['disabled'] = true;
        }
        if (write_config()) {
            mark_subsystem_dirty('filter');
        }
        header("Location: firewall_rules.php?if=" . htmlspecialchars($current_if));
        exit;
    }
Ad Schellevis's avatar
Ad Schellevis committed
120 121
}

122 123
if (isset($_GET['if'])) {
    $selected_if = htmlspecialchars($_GET['if']);
Ad Schellevis's avatar
Ad Schellevis committed
124
} else {
125
    $selected_if = "FloatingRules";
Ad Schellevis's avatar
Ad Schellevis committed
126 127 128
}

include("head.inc");
129

Ad Schellevis's avatar
Ad Schellevis committed
130
?>
Ad Schellevis's avatar
Ad Schellevis committed
131
</head>
Ad Schellevis's avatar
Ad Schellevis committed
132
<body>
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
<script type="text/javascript">
$( document ).ready(function() {
  // link delete buttons
  $(".act_delete").click(function(){
    var id = $(this).attr("id").split('_').pop(-1);
    if (id != 'x') {
      // delete single
      BootstrapDialog.show({
        type:BootstrapDialog.TYPE_INFO,
        title: "<?= gettext("Rules");?>",
        message: "<?=gettext("Do you really want to delete this rule?");?>",
        buttons: [{
                  label: "<?= gettext("No");?>",
                  action: function(dialogRef) {
                      dialogRef.close();
                  }}, {
                  label: "<?= gettext("Yes");?>",
                  action: function(dialogRef) {
                    $("#id").val(id);
                    $("#action").val("del");
                    $("#iform").submit()
                }
              }]
    });
    } else {
      // delete selected
      BootstrapDialog.show({
        type:BootstrapDialog.TYPE_INFO,
        title: "<?= gettext("Rules");?>",
        message: "<?=gettext("Do you really want to delete the selected rules?");?>",
        buttons: [{
                  label: "<?= gettext("No");?>",
                  action: function(dialogRef) {
                      dialogRef.close();
                  }}, {
                  label: "<?= gettext("Yes");?>",
                  action: function(dialogRef) {
                    $("#id").val("");
                    $("#action").val("del_x");
                    $("#iform").submit()
                }
              }]
      });
    }
  });

  // link move buttons
  $(".act_move").click(function(){
    var id = $(this).attr("id").split('_').pop(-1);
    $("#id").val(id);
    $("#action").val("move");
    $("#iform").submit();
  });

  // link toggle buttons
  $(".act_toggle").click(function(){
    var id = $(this).attr("id").split('_').pop(-1);
    $("#id").val(id);
    $("#action").val("toggle");
    $("#iform").submit();
  });

});
Ad Schellevis's avatar
Ad Schellevis committed
196
</script>
Ad Schellevis's avatar
Ad Schellevis committed
197

Ad Schellevis's avatar
Ad Schellevis committed
198
<?php include("fbegin.inc"); ?>
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
  <section class="page-content-main">
    <div class="container-fluid">
      <div class="row">
        <?php if (isset($savemsg)) print_info_box($savemsg); ?>
        <?php if (is_subsystem_dirty('filter')): ?><p>
        <?php print_info_box_apply(gettext("The firewall rule configuration has been changed.<br />You must apply the changes in order for them to take effect."));?>
        <?php endif; ?>
        <section class="col-xs-12">
<?php
           // create tabs per interface + floating
           $iflist_tabs = array();
           $iflist_tabs['FloatingRules'] = 'Floating';
           if (isset($config['ifgroups']['ifgroupentry']))
             foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
                 $iflist_tabs[$ifgen['ifname']] = $ifgen['ifname'];

           foreach (get_configured_interface_with_descr() as $ifent => $ifdesc)
               $iflist_tabs[$ifent] = $ifdesc;

           if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == "server")
               $iflist_tabs['l2tp'] = "L2TP VPN";

           if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] == "server")
               $iflist_tabs['pptp'] = "PPTP VPN";

           if (isset($config['pppoes']['pppoe'])) {
             foreach ($config['pppoes']['pppoe'] as $pppoes) {
Ad Schellevis's avatar
Ad Schellevis committed
226
               if (($pppoes['mode'] == 'server')) {
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
                 $iflist_tabs['pppoe'] = "PPPoE Server";
               }
             }
           }

           /* add ipsec interfaces */
           if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])) {
               $iflist_tabs['enc0'] = 'IPsec';
           }

           /* add openvpn/tun interfaces */
           if (isset($config['openvpn']['openvpn-server']) || isset($config['openvpn']['openvpn-client'])) {
             $iflist_tabs['openvpn'] = 'OpenVPN';
           }

          $tab_array = array();
          foreach ($iflist_tabs as $ifent => $ifname) {
            $active = false;
            // mark active if selected or mark floating active when none is selected
            if ($ifent == $selected_if) {
                $active = true;
            }
            $tab_array[] = array($ifname, $active, "firewall_rules.php?if={$ifent}");
          }
          display_top_tabs($tab_array);
?>
253
          <div class="content-box">
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
            <form action="firewall_rules.php?if=<?=$selected_if;?>" method="post" name="iform" id="iform">
              <input type="hidden" id="id" name="id" value="" />
              <input type="hidden" id="action" name="act" value="" />
              <div class="table-responsive" >
                <table class="table table-striped">
                  <thead>
                    <tr>
                      <th>&nbsp;</th>
                      <th>&nbsp;</th>
                      <th><?=gettext("Proto");?></th>
                      <th><?=gettext("Source");?></th>
                      <th class="hidden-xs hidden-sm"><?=gettext("Port");?></th>
                      <th class="hidden-xs hidden-sm"><?=gettext("Destination");?></th>
                      <th class="hidden-xs hidden-sm"><?=gettext("Port");?></th>
                      <th class="hidden-xs hidden-sm"><?=gettext("Gateway");?></th>
                      <th class="hidden-xs hidden-sm"><?=gettext("Schedule");?></th>
                      <th><?=gettext("Description");?></th>
                      <th></th>
                  </tr>
                </thead>
                <tbody>
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
<?php
                // Show floating block IPv6 rule if IPv6 is globally disabled in system settings
                if (!isset($config['system']['ipv6allow']) &&
                        ($selected_if == 'FloatingRules')):
?>
                  <tr valign="top">
                    <td>&nbsp;</td>
                    <td><span class="glyphicon glyphicon-remove text-danger"></span></td>
                    <td>IPv6 *</td>
                    <td>*</td>
                    <td class="hidden-xs hidden-sm">*</td>
                    <td class="hidden-xs hidden-sm">*</td>
                    <td class="hidden-xs hidden-sm">*</td>
                    <td class="hidden-xs hidden-sm">*</td>
                    <td class="hidden-xs hidden-sm">&nbsp;</td>
                    <td><?=gettext("Block all IPv6 traffic");?></td>
                    <td>
                      <a href="system_advanced_network.php" title="<?=gettext("edit rule");?>" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
                    </td>
                  </tr>
<?php
                endif; ?>
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
<?php
                // Show the anti-lockout rule if it's enabled, and we are on LAN with an if count > 1, or WAN with an if count of 1.
                if (!isset($config['system']['webgui']['noantilockout']) &&
                        (((count($config['interfaces']) > 1) && ($selected_if == 'lan'))
                        || ((count($config['interfaces']) == 1) && ($selected_if == 'wan')))):
                        $alports = implode('<br />', filter_get_antilockout_ports(true));
?>
                  <tr valign="top">
                    <td>&nbsp;</td>
                    <td><span class="glyphicon glyphicon-play text-success"></span></td>
                    <td>*</td>
                    <td>*</td>
                    <td class="hidden-xs hidden-sm">*</td>
                    <td class="hidden-xs hidden-sm"><?=htmlspecialchars(convert_friendly_interface_to_friendly_descr($selected_if));?> Address</td>
                    <td class="hidden-xs hidden-sm"><?=$alports;?></td>
                    <td class="hidden-xs hidden-sm">*</td>
                    <td class="hidden-xs hidden-sm">&nbsp;</td>
                    <td><?=gettext("Anti-Lockout Rule");?></td>
                    <td>
                      <a href="system_advanced_admin.php" title="<?=gettext("edit rule");?>" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
                    </td>
                  </tr>
<?php
                endif; ?>
<?php
                if (isset($config['interfaces'][$selected_if]['blockpriv'])): ?>
                  <tr>
                    <td>&nbsp;</td>
325 326 327 328 329 330 331 332
                    <td>
                      <span class="glyphicon glyphicon-remove text-danger"></span>
<?php
                      if (!isset($config['syslog']['nologprivatenets'])):?>
                      <span class="glyphicon glyphicon-info-sign"></span>
<?php
                      endif; ?>
                    </td>
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
                    <td>*</td>
                    <td><?=gettext("RFC 1918 networks");?></td>
                    <td>*</td>
                    <td class="hidden-xs hidden-sm">*</td>
                    <td class="hidden-xs hidden-sm">*</td>
                    <td class="hidden-xs hidden-sm">*</td>
                    <td class="hidden-xs hidden-sm">&nbsp;</td>
                    <td class="hidden-xs hidden-sm"><?=gettext("Block private networks");?></td>
                    <td valign="middle" class="list nowrap">
                        <a href="interfaces.php?if=<?=$selected_if?>#rfc1918" title="<?=gettext("edit rule");?>" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
                    </td>
                  </tr>
<?php
              endif;
              if (isset($config['interfaces'][$selected_if]['blockbogons'])): ?>
                  <tr valign="top" id="frrfc1918">
                    <td>&nbsp;</td>
350 351 352 353 354 355 356 357
                    <td>
                      <span class="glyphicon glyphicon-remove text-danger"></span>
<?php
                      if (!isset($config['syslog']['nologbogons'])):?>
                      <span class="glyphicon glyphicon-info-sign"></span>
<?php
                      endif; ?>
                    </td>
358 359 360 361 362 363
                    <td>*</td>
                    <td><?=gettext("Reserved/not assigned by IANA");?></td>
                    <td class="hidden-xs hidden-sm">*</td>
                    <td class="hidden-xs hidden-sm">*</td>
                    <td class="hidden-xs hidden-sm">*</td>
                    <td class="hidden-xs hidden-sm">*</td>
364
                    <td class="hidden-xs hidden-sm">&nbsp;</td>
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
                    <td><?=gettext("Block bogon networks");?></td>
                    <td>
                      <a href="interfaces.php?if=<?=htmlspecialchars($if)?>#rfc1918" title="<?=gettext("edit rule");?>" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
                    </td>
                  </tr>
<?php
                endif; ?>
<?php
                $interface_has_rules = false;
                foreach ($a_filter as $i => $filterent):
                if ( (isset($filterent['interface']) && $filterent['interface'] == $selected_if) ||
                     (isset($filterent['floating']) && $selected_if == "FloatingRules" )):
                  $interface_has_rules = true;
                  // select icon
                  if (!isset($filterent['type']) && empty($filterent['disabled'])) {
                      // not very nice.... associated NAT rules don't have a type...
                      $iconfn = "glyphicon-play text-success";
                  } else if (!isset($filterent['type']) && !empty($filterent['disabled'])) {
                      $iconfn = "glyphicon-play text-muted";
                  } elseif ($filterent['type'] == "block" && empty($filterent['disabled'])) {
                      $iconfn = "glyphicon-remove text-danger";
                  } elseif ($filterent['type'] == "block" && !empty($filterent['disabled'])) {
                      $iconfn = "glyphicon-remove text-muted";
                  }  elseif ($filterent['type'] == "reject" && empty($filterent['disabled'])) {
                      $iconfn = "glyphicon-remove  text-warning";
                  }  elseif ($filterent['type'] == "reject" && !empty($filterent['disabled'])) {
                      $iconfn = "glyphicon-remove  text-muted";
                  } else if ($filterent['type'] == "match" && empty($filterent['disabled'])) {
                      $iconfn = "glyphicon-ok";
                  } else if ($filterent['type'] == "match" && !empty($filterent['disabled'])) {
                      $iconfn = "glyphicon-ok text-muted";
                  } elseif (empty($filterent['disabled'])) {
                      $iconfn = "glyphicon-play text-success";
                  } else {
                      $iconfn = "glyphicon-play text-muted";
                  }

                  // construct line ipprotocol
                  if (isset($filterent['ipprotocol'])) {
                      switch($filterent['ipprotocol']) {
                          case "inet":
                              $record_ipprotocol = "IPv4 ";
                              break;
                          case "inet6":
                              $record_ipprotocol = "IPv6 ";
                              break;
                          case "inet46":
                              $record_ipprotocol = "IPv4+6 ";
                              break;
                      }
                  } else {
                      $record_ipprotocol = "IPv4 ";
                  }
Ad Schellevis's avatar
Ad Schellevis committed
418

Ad Schellevis's avatar
Ad Schellevis committed
419

420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
?>
                  <tr ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
                    <td>
                      <input type="checkbox" name="rule[]" value="<?=$i;?>"  />
                    </td>
                    <td>
                      <a href="#" class="act_toggle" id="toggle_<?=$i;?>" data-toggle="tooltip" data-placement="left" title="<?=gettext("click to toggle enabled/disabled status");?>">
                        <span class="glyphicon <?=$iconfn;?>"></span>
                      </a>
<?php
                      if (isset($filterent['log'])):?>
                      <span class="glyphicon glyphicon-info-sign <?=!empty($filterent['disabled']) ? "text-muted" :""?>"></span>
<?php
                      endif; ?>
                    </td>
                    <td>
                        <?=$record_ipprotocol;?>
<?php
                        $icmptypes = array(
                          "" => gettext("any"),
                          "echoreq" => gettext("Echo request"),
                          "echorep" => gettext("Echo reply"),
                          "unreach" => gettext("Destination unreachable"),
                          "squench" => gettext("Source quench"),
                          "redir" => gettext("Redirect"),
                          "althost" => gettext("Alternate Host"),
                          "routeradv" => gettext("Router advertisement"),
                          "routersol" => gettext("Router solicitation"),
                          "timex" => gettext("Time exceeded"),
                          "paramprob" => gettext("Invalid IP header"),
                          "timereq" => gettext("Timestamp"),
                          "timerep" => gettext("Timestamp reply"),
                          "inforeq" => gettext("Information request"),
                          "inforep" => gettext("Information reply"),
                          "maskreq" => gettext("Address mask request"),
                          "maskrep" => gettext("Address mask reply")
                        );
                        if (isset($filterent['protocol']) && $filterent['protocol'] == "icmp" && !empty($filterent['icmptype'])):
?>
                        <span data-toggle="tooltip" title="ICMP type: <?=$icmptypes[$filterent['icmptype']];?> ">
                            <?= isset($filterent['protocol']) ? strtoupper($filterent['protocol']) : "*";?>
                        </span>
<?php
                        else:?>
                        <?= isset($filterent['protocol']) ? strtoupper($filterent['protocol']) : "*";?>
<?php
                        endif;?>
                    </td>
                    <td>
                      <?=htmlspecialchars(pprint_address($filterent['source']));?>
<?php                 if (isset($filterent['source']['address']) && is_alias($filterent['source']['address'])): ?>
                      &nbsp;<a href="/firewall_aliases_edit.php?name=<?=htmlspecialchars($filterent['source']['address']);?>"><i class="fa fa-list"></i> </a>
<?php                 endif; ?>
                    </td>
                    <td class="hidden-xs hidden-sm">
                      <?=htmlspecialchars(pprint_port(isset($filterent['source']['port']) ? $filterent['source']['port'] : null)); ?>
<?php                   if (isset($filterent['source']['port']) && is_alias($filterent['source']['port'])): ?>
                        &nbsp;<a href="/firewall_aliases_edit.php?name=<?=htmlspecialchars($filterent['source']['port']);?>"><i class="fa fa-list"></i> </a>
<?php                   endif; ?>
                    </td>
                    <td class="hidden-xs hidden-sm">
                      <?=htmlspecialchars(pprint_address($filterent['destination'])); ?>
<?php                 if (isset($filterent['destination']['address']) && is_alias($filterent['destination']['address'])): ?>
                      &nbsp;<a href="/firewall_aliases_edit.php?name=<?=htmlspecialchars($filterent['destination']['address']);?>"><i class="fa fa-list"></i> </a>
<?php                 endif; ?>
                    </td>
                    <td class="hidden-xs hidden-sm">
                      <?=htmlspecialchars(pprint_port(isset($filterent['destination']['port']) ? $filterent['destination']['port'] : null)); ?>
<?php                 if (isset($filterent['destination']['port']) && is_alias($filterent['destination']['port'])): ?>
                      &nbsp;<a href="/firewall_aliases_edit.php?name=<?=htmlspecialchars($filterent['destination']['port']);?>"><i class="fa fa-list"></i> </a>
<?php                 endif; ?>
                    </td>
                    <td class="hidden-xs hidden-sm">
<?php
                       if (isset($filterent['gateway'])):?>
                      <?=isset($config['interfaces'][$filterent['gateway']]['descr']) ? htmlspecialchars($config['interfaces'][$filterent['gateway']]['descr']) : htmlspecialchars(pprint_port($filterent['gateway'])); ?>
<?php
                      else: ?>
                      *
<?php                 endif; ?>
                    </td>
                    <td class="hidden-xs hidden-sm">
<?php
                       if (!empty($filterent['sched'])):?>
                      <?=htmlspecialchars($filterent['sched']);?>
                      <a href="/firewall_schedule_edit.php?name=<?=htmlspecialchars($filterent['sched']);?>"> <span class="glyphicon glyphicon-calendar"> </span> </a>
<?php
                       endif;?>
                    </td>
                    <td>
                      <?=htmlspecialchars($filterent['descr']);?>
                    </td>
                    <td>
                      <a id="move_<?=$i;?>" name="move_<?=$i;?>_x" data-toggle="tooltip" data-placement="left" title="<?=gettext("move selected rules before this rule");?>" class="act_move btn btn-default btn-xs">
                        <span class="glyphicon glyphicon-arrow-left"></span>
                      </a>
                      <a href="firewall_rules_edit.php?id=<?=$i;?>" data-toggle="tooltip" data-placement="left" title="<?=gettext("edit this rule");?>" class="btn btn-default btn-xs">
                        <span class="glyphicon glyphicon-pencil"></span>
                      </a>
                      <a id="del_<?=$i;?>" title="<?=gettext("delete this rule"); ?>" data-toggle="tooltip"  class="act_delete btn btn-default btn-xs">
                        <span class="glyphicon glyphicon-remove"></span>
                      </a>
                      <a href="firewall_rules_edit.php?dup=<?=$i;?>" class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left" title="<?=gettext("add new rule based on this one");?>">
                        <span class="glyphicon glyphicon-plus"></span>
                      </a>
                    </td>
                  </tr>
<?php
                  endif;
                  endforeach;
                  if (!$interface_has_rules):
?>
                  <tr>
                    <td colspan="11" align="center" valign="middle">
                    <span class="gray">
                <?php if ($selected_if == "FloatingRules"): ?>
                      <?=gettext("No floating rules are currently defined."); ?><br /><br />
                <?php else: ?>
                      <?=gettext("No rules are currently defined for this interface"); ?><br />
                      <?=gettext("All incoming connections on this interface will be blocked until you add pass rules."); ?><br /><br />
                <?php endif; ?>
                      <?=gettext("Click the"); ?>
                      <a href="firewall_rules_edit.php?if=<?=$selected_if;?>"  class="btn btn-default btn-xs">
                        <span class="glyphicon glyphicon-plus"></span>
                      </a>
                      <?=gettext(" button to add a new rule.");?></span>
                    </td>
                  </tr>
              <?php else: ?>
                  <tr>
                    <td colspan="5"></td>
                    <td colspan="5" class="hidden-xs hidden-sm"></td>
                    <td>
                      <a type="submit" id="move_<?=$i;?>" name="move_<?=$i;?>_x" data-toggle="tooltip" data-placement="left" title="<?=gettext("move selected rules to end");?>" class="act_move btn btn-default btn-xs">
                        <span class="glyphicon glyphicon-arrow-left"></span>
                      </a>
                      <a id="del_x" title="<?=gettext("delete selected rules"); ?>" data-toggle="tooltip"  class="act_delete btn btn-default btn-xs">
                        <span class="glyphicon glyphicon-remove"></span>
                      </a>
                      <a href="firewall_rules_edit.php?if=<?=$selected_if;?>" class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left" title="<?=gettext("add new rule");?>">
                        <span class="glyphicon glyphicon-plus"></span>
                      </a>
                    </td>
                  </tr>
              <?php endif; ?>
                </tbody>
                <tfoot>
                  <tr>
                    <td colspan="11">&nbsp;</td>
                  </tr>
                  <tr class="hidden-xs hidden-sm">
                    <td colspan="11">
                      <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="16"><span class="glyphicon glyphicon-play text-success"></span></td>
                          <td width="100"><?=gettext("pass");?></td>
                          <td width="14"></td>
                          <td width="16"><span class="glyphicon glyphicon-ok"></span></td>
                          <td width="100"><?=gettext("match");?></td>
                          <td width="14"></td>
                          <td width="16"><span class="glyphicon glyphicon-remove text-danger"></span></td>
                          <td width="100"><?=gettext("block");?></td>
                          <td width="14"></td>
                          <td width="16"><span class="glyphicon glyphicon-remove text-warning"></span></td>
                          <td width="100"><?=gettext("reject");?></td>
                          <td width="14"></td>
                          <td width="16"><span class="glyphicon glyphicon-info-sign"></span></td>
                          <td width="100"><?=gettext("log");?></td>
                        </tr>
                        <tr>
                          <td><span class="glyphicon glyphicon-play text-muted"></span></td>
                          <td class="nowrap"><?=gettext("pass (disabled)");?></td>
                          <td>&nbsp;</td>
                          <td><span class="glyphicon glyphicon-ok text-muted"></span></td>
                          <td class="nowrap"><?=gettext("match (disabled)");?></td>
                          <td>&nbsp;</td>
                          <td><span class="glyphicon glyphicon-remove text-muted"></span></td>
                          <td class="nowrap"><?=gettext("block (disabled)");?></td>
                          <td>&nbsp;</td>
                          <td><span class="glyphicon glyphicon-remove text-muted"></span></td>
                          <td class="nowrap"><?=gettext("reject (disabled)");?></td>
                          <td>&nbsp;</td>
                          <td width="16"><span class="glyphicon glyphicon-info-sign text-muted"></span></td>
                          <td class="nowrap"><?=gettext("log (disabled)");?></td>
                        </tr>
                      </table>
                    </td>
                  </tr>
                  <tr class="hidden-xs hidden-sm">
                    <td><a><i class="fa fa-list"></i></a></td>
                    <td colspan="10"><?=gettext("Alias (click to view/edit)");?></td>
                  </tr>
                  <tr class="hidden-xs hidden-sm">
                    <td><a><span class="glyphicon glyphicon-calendar"> </span></a></td>
                    <td colspan="10"><?=gettext("Schedule (click to view/edit)");?></td>
                  </tr>
                  <tr class="hidden-xs hidden-sm">
                    <td colspan="11">
                      <strong>
                        <span class="text-danger"><?=gettext("Hint:");?></span>
                      </strong>
                      <br />
                      <?php if ("FloatingRules" != $selected_if): ?>
                      <?=gettext("Rules are evaluated on a first-match basis (i.e. " .
                        "the action of the first rule to match a packet will be executed). " .
                        "This means that if you use block rules, you'll have to pay attention " .
                        "to the rule order. Everything that isn't explicitly passed is blocked " .
                        "by default. ");?>
                      <?php else: ?>
                        <?=gettext("Floating rules are evaluated on a first-match basis (i.e. " .
                        "the action of the first rule to match a packet will be executed) only " .
                        "if the 'quick' option is checked on a rule. Otherwise they will only apply if no " .
                        "other rules match. Pay close attention to the rule order and options " .
                        "chosen. If no rule here matches, the per-interface or default rules are used. ");?>
                      <?php endif; ?>
                    </td>
                  </tr>
                </tfoot>
              </table>
            </div>
          </form>
        </div>
      </section>
    </div>
  </div>
</section>
Ad Schellevis's avatar
Ad Schellevis committed
646

647
<?php include("foot.inc"); ?>