From fce824608bfde0b239e141bb387f98f461c433f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=C3=A7i?= Date: Thu, 21 Feb 2008 18:22:00 +0000 Subject: [PATCH] * Fix some bugs when deleteing queues * Remove Manuel from firewall_shaper.php copyright this has nothing to do with him * Apply fixes to show the actions taken on queues directly(you needed a refresh to display those), though we pay some penalty for this now --- etc/inc/shaper.inc | 20 ++++----- usr/local/www/firewall_shaper.php | 68 +++++++++++++------------------ 2 files changed, 39 insertions(+), 49 deletions(-) diff --git a/etc/inc/shaper.inc b/etc/inc/shaper.inc index bf53963bdf..7c9904a4bb 100644 --- a/etc/inc/shaper.inc +++ b/etc/inc/shaper.inc @@ -437,10 +437,10 @@ class altq_root_queue { } function delete_queue() { - foreach ($this->queues as $q) - $q->delete_queue(); - + foreach ($this->queues as $q) { $this->SetAvailableBandwidth($this->GetAvailableBandwidth() + $q->GetAvailableBandwidth()); + $q->delete_queue(); + } unset_object_by_reference($this->GetLink()); } @@ -1239,10 +1239,10 @@ class hfsc_queue extends priq_queue { altq_set_default_queue($this->GetInterface(), "false"); cleanup_queue_from_rules($this->GetQname()); $parent =& $this->GetParent(); - foreach ($this->subqueues as $q) - $q->delete_queue(); + foreach ($this->subqueues as $q) { $this->SetAvailableBandwidth($this->GetAvailableBandwidth() + $q->GetAvailableBandwidth()); - + $q->delete_queue(); + } unset_object_by_reference($this->GetLink()); } @@ -1786,11 +1786,11 @@ class cbq_queue extends priq_queue { if ($this->GetDefault()) altq_set_default_queue($this->GetInterface(), "false"); cleanup_queue_from_rules($this->GetQname()); - foreach ($this->subqueues as $q) - $q->delete_queue(); + foreach ($this->subqueues as $q) { $this->SetAvailableBandwidth($this->GetAvailableBandwidth() + $q->GetAvailableBandwidth()); - $parent =& $this->GetParent(); - unset_object_by_reference($this->subqueues[$qname]->GetLink()); + $q->delete_queue(); + } + unset_object_by_reference($this->GetLink()); } function validate_input($data, &$input_errors) { diff --git a/usr/local/www/firewall_shaper.php b/usr/local/www/firewall_shaper.php index acf9bced64..eee915d011 100755 --- a/usr/local/www/firewall_shaper.php +++ b/usr/local/www/firewall_shaper.php @@ -6,10 +6,6 @@ Copyright (C) 2008 Ermal Luçi All rights reserved. - Originally part of m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2004 Manuel Kasper . - All rights reserved. - Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -34,22 +30,9 @@ require("guiconfig.inc"); -$pgtitle = array("Firewall","Traffic Shape"); - -if (!is_array($config['shaper']['queue'])) { - $config['shaper']['queue'] = array(); -} +$pgtitle = array("Firewall","Traffic Shaper"); read_altq_config(); -$tree = ""; - /* * The whole logic in these code maybe can be specified. * If you find a better way contact me :). @@ -76,19 +59,6 @@ if ($interface) { $altq = $altq_list_queues[$interface]; if ($altq) { $queue =& $altq->find_queue($interface, $qname); - if ($queue) { - if ($queue->GetEnabled()) - $can_enable = true; - else - $can_enable = false; - if ($queue->CanHaveChilds() && $can_enable) { - if ($queue->GetDefault() <> "") - $can_add = false; - else - $can_add = true; - } else - $can_add = false; - } } else $addnewaltq = true; } @@ -239,10 +209,8 @@ if ($_GET) { write_config(); touch($d_shaperconfdirty_path); $can_enable = true; - if ($queue->GetDefault() <> "") - $can_add = false; - else - $can_add = true; + $can_add = true; + read_altq_config(); } $output_form .= $altq->build_form(); @@ -256,8 +224,9 @@ if ($_GET) { array_pop($tmppath); $tmp->wconfig(); $can_enable = true; + read_altq_config(); if ($tmp->CanHaveChilds() && $can_enable) { - if ($queue->GetDefault() <> "") + if ($tmp->GetDefault() <> "") $can_add = false; else $can_add = true; @@ -267,7 +236,7 @@ if ($_GET) { touch($d_shaperconfdirty_path); $can_enable = true; if ($altq->GetScheduler() != "PRIQ") /* XXX */ - if ($queue->GetDefault() <> "") + if ($tmp->GetDefault() <> "") $can_add = false; else $can_add = true; @@ -311,6 +280,7 @@ if ($_GET) { write_config(); touch($d_shaperconfdirty_path); $dontshow = false; + read_altq_config(); } $output_form .= $queue->build_form(); } else { @@ -321,9 +291,29 @@ if ($_GET) { $output_form .= "

" . $default_shaper_msg."

"; $dontshow = true; } - - +if ($queue) { + if ($queue->GetEnabled()) + $can_enable = true; + else + $can_enable = false; + if ($queue->CanHaveChilds() && $can_enable) { + if ($queue->GetDefault() <> "") + $can_add = false; + else + $can_add = true; + } else + $can_add = false; +} + +$tree = ""; if (!$dontshow || $newqueue) {