diff options
author | Phil Davis <phil.davis@inf.org> | 2015-05-11 20:34:57 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2015-05-11 20:34:57 +0545 |
commit | 6aaec445e0d1e8a3a0ea7a7571fc17d5ee2eb700 (patch) | |
tree | f2a0133cd964d65449d584d5367a4c2a7395d7e4 /usr/local/www/firewall_shaper_queues.php | |
parent | efd081de20c993d2c5bb991835ca25d5b7b06e3c (diff) | |
download | pfsense-6aaec445e0d1e8a3a0ea7a7571fc17d5ee2eb700.zip pfsense-6aaec445e0d1e8a3a0ea7a7571fc17d5ee2eb700.tar.gz |
Code style firewall shaper
Diffstat (limited to 'usr/local/www/firewall_shaper_queues.php')
-rw-r--r-- | usr/local/www/firewall_shaper_queues.php | 214 |
1 files changed, 114 insertions, 100 deletions
diff --git a/usr/local/www/firewall_shaper_queues.php b/usr/local/www/firewall_shaper_queues.php index c576794..6aa062b 100644 --- a/usr/local/www/firewall_shaper_queues.php +++ b/usr/local/www/firewall_shaper_queues.php @@ -46,7 +46,7 @@ require_once("filter.inc"); require_once("shaper.inc"); require_once("rrd.inc"); -if($_GET['reset'] <> "") { +if ($_GET['reset'] <> "") { mwexec("killall -9 pfctl"); exit; } @@ -55,119 +55,132 @@ $shaperIFlist = get_configured_interface_with_descr(); read_altq_config(); $qlist =& get_unique_queue_list(); -if (!is_array($qlist)) +if (!is_array($qlist)) { $qlist = array(); +} $tree = "<ul class=\"tree\" >"; foreach ($qlist as $queue => $qkey) { $tree .= "<li><a href=\"firewall_shaper_queues.php?queue={$queue}&action=show\" >"; - if (isset($shaperIFlist[$queue])) + if (isset($shaperIFlist[$queue])) { $tree .= $shaperIFlist[$queue] . "</a></li>"; - else + } else { $tree .= $queue . "</a></li>"; + } } $tree .= "</ul>"; if ($_GET) { - if ($_GET['queue']) - $qname = htmlspecialchars(trim($_GET['queue'])); - if ($_GET['interface']) - $interface = htmlspecialchars(trim($_GET['interface'])); - if ($_GET['action']) - $action = htmlspecialchars($_GET['action']); + if ($_GET['queue']) { + $qname = htmlspecialchars(trim($_GET['queue'])); + } + if ($_GET['interface']) { + $interface = htmlspecialchars(trim($_GET['interface'])); + } + if ($_GET['action']) { + $action = htmlspecialchars($_GET['action']); + } switch ($action) { - case "delete": + case "delete": $altq =& $altq_list_queues[$interface]; $qtmp =& $altq->find_queue("", $qname); if ($qtmp) { - $qtmp->delete_queue(); - if (write_config()) + $qtmp->delete_queue(); + if (write_config()) { mark_subsystem_dirty('shaper'); + } } header("Location: firewall_shaper_queues.php"); exit; - break; - case "add": - /* + break; + case "add": + /* * XXX: WARNING: This returns the first it finds. * Maybe the user expects something else?! */ - foreach ($altq_list_queues as $altq) { - $qtmp =& $altq->find_queue("", $qname); - if ($qtmp) { - $copycfg = array(); - $qtmp->copy_queue($interface, $copycfg); - $aq =& $altq_list_queues[$interface]; + foreach ($altq_list_queues as $altq) { + $qtmp =& $altq->find_queue("", $qname); + if ($qtmp) { + $copycfg = array(); + $qtmp->copy_queue($interface, $copycfg); + $aq =& $altq_list_queues[$interface]; if ($qname == $qtmp->GetInterface()) { - $config['shaper']['queue'][] = $copycfg; - } else if ($aq) { - $tmp1 =& $qtmp->find_parentqueue($interface, $qname); - if ($tmp1) - $tmp =& $aq->find_queue($interface, $tmp1->GetQname()); - - if ($tmp) - $link =& get_reference_to_me_in_config($tmp->GetLink()); - else - $link =& get_reference_to_me_in_config($aq->GetLink()); - $link['queue'][] = $copycfg; - } else { - $newroot = array(); - $newroot['name'] = $interface; - $newroot['interface'] = $interface; - $newroot['scheduler'] = $altq->GetScheduler(); - $newroot['queue'] = array(); - $newroot['queue'][] = $copycfg; - $config['shaper']['queue'][] = $newroot; - } - if (write_config()) + $config['shaper']['queue'][] = $copycfg; + } else if ($aq) { + $tmp1 =& $qtmp->find_parentqueue($interface, $qname); + if ($tmp1) { + $tmp =& $aq->find_queue($interface, $tmp1->GetQname()); + } + + if ($tmp) { + $link =& get_reference_to_me_in_config($tmp->GetLink()); + } else { + $link =& get_reference_to_me_in_config($aq->GetLink()); + } + $link['queue'][] = $copycfg; + } else { + $newroot = array(); + $newroot['name'] = $interface; + $newroot['interface'] = $interface; + $newroot['scheduler'] = $altq->GetScheduler(); + $newroot['queue'] = array(); + $newroot['queue'][] = $copycfg; + $config['shaper']['queue'][] = $newroot; + } + if (write_config()) { mark_subsystem_dirty('shaper'); - break; - } - } + } + break; + } + } header("Location: firewall_shaper_queues.php?queue=".$qname."&action=show"); exit; - break; - case "show": - foreach ($config['interfaces'] as $if => $ifdesc) { - $altq = $altq_list_queues[$if]; - if ($altq) { - $qtmp =& $altq->find_queue("", $qname); - if ($qtmp) - $output .= $qtmp->build_shortform(); - else - $output .= build_iface_without_this_queue($if, $qname); - } else { - if (!is_altq_capable($ifdesc['if'])) - continue; - if (!isset($ifdesc['enable']) && $if != "lan" && $if != "wan") - continue; - $output .= build_iface_without_this_queue($if, $qname); - } - } - break; + break; + case "show": + foreach ($config['interfaces'] as $if => $ifdesc) { + $altq = $altq_list_queues[$if]; + if ($altq) { + $qtmp =& $altq->find_queue("", $qname); + if ($qtmp) { + $output .= $qtmp->build_shortform(); + } else { + $output .= build_iface_without_this_queue($if, $qname); + } + } else { + if (!is_altq_capable($ifdesc['if'])) { + continue; + } + if (!isset($ifdesc['enable']) && $if != "lan" && $if != "wan") { + continue; + } + $output .= build_iface_without_this_queue($if, $qname); + } + } + break; } } if ($_POST['apply']) { - write_config(); + write_config(); $retval = 0; - /* Setup pf rules since the user may have changed the optimization value */ + /* Setup pf rules since the user may have changed the optimization value */ $retval = filter_configure(); $savemsg = get_std_save_message($retval); - if (stristr($retval, "error") <> true) - $savemsg = get_std_save_message($retval); - else - $savemsg = $retval; + if (stristr($retval, "error") <> true) { + $savemsg = get_std_save_message($retval); + } else { + $savemsg = $retval; + } - /* reset rrd queues */ - system("rm -f /var/db/rrd/*queuedrops.rrd"); - system("rm -f /var/db/rrd/*queues.rrd"); - enable_rrd_graphing(); + /* reset rrd queues */ + system("rm -f /var/db/rrd/*queuedrops.rrd"); + system("rm -f /var/db/rrd/*queues.rrd"); + enable_rrd_graphing(); - clear_subsystem_dirty('shaper'); + clear_subsystem_dirty('shaper'); } $pgtitle = gettext("Firewall: Shaper: By Queues View"); @@ -189,7 +202,7 @@ include("head.inc"); <?php print_info_box_np(gettext("The traffic shaper configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?><br /></p> <?php endif; ?> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="traffic shaper queues"> - <tr><td> + <tr><td> <?php $tab_array = array(); $tab_array[0] = array(gettext("By Interface"), false, "firewall_shaper.php"); @@ -199,32 +212,33 @@ include("head.inc"); $tab_array[4] = array(gettext("Wizards"), false, "firewall_shaper_wizards.php"); display_top_tabs($tab_array); ?> - </td></tr> - <tr> - <td valign="top"> - <div id="mainarea"> - <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area"> - <tr> - <td width="30%" valign="top" align="left"> - <?php echo $tree; ?> + </td></tr> + <tr> + <td valign="top"> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area"> + <tr> + <td width="30%" valign="top" align="left"> + <?php echo $tree; ?> + </td> + <td width="70%" valign="top" align="center"> + <?php + if ($qname) { + echo "<p class=\"pgtitle\">" . $qname . "</p><br />"; + } + echo "<table align=\"center\" class=\"tabcont\" width=\"80%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\" summary=\"output form\">"; + echo $output; + echo "<tr><td> </td></tr>"; + echo "</table>"; + ?> + </td> + </tr> + </table><!-- table:main area --> + </div><!-- div:main area --> </td> - <td width="70%" valign="top" align="center"> - <?php - if ($qname) - echo "<p class=\"pgtitle\">" . $qname . "</p><br />"; - echo "<table align=\"center\" class=\"tabcont\" width=\"80%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\" summary=\"output form\">"; - echo $output; - echo "<tr><td> </td></tr>"; - echo "</table>"; - ?> - </td></tr> - </table><!-- table:main area --> - - </div><!-- div:main area --> - </td> </tr> </table> - </form> +</form> <?php include("fend.inc"); ?> </body> </html> |