From 420b45385af6c8c7c90db1730ff859f792be8f5d Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Mon, 24 Feb 2014 09:10:11 -0300 Subject: Fix whitespace and indent --- etc/inc/shaper.inc | 1654 ++++++++++++++++++++++++++-------------------------- 1 file changed, 827 insertions(+), 827 deletions(-) diff --git a/etc/inc/shaper.inc b/etc/inc/shaper.inc index bbe3da8..32fc3c8 100644 --- a/etc/inc/shaper.inc +++ b/etc/inc/shaper.inc @@ -38,11 +38,11 @@ require_once("notices.inc"); /* * I admit :) this is derived from xmplparse.inc StartElement() */ -function &get_reference_to_me_in_config(&$mypath) +function &get_reference_to_me_in_config(&$mypath) { global $config; - $ptr =& $config['shaper']; + $ptr =& $config['shaper']; foreach ($mypath as $indeks) { $ptr =& $ptr['queue'][$indeks]; } @@ -50,7 +50,7 @@ function &get_reference_to_me_in_config(&$mypath) return $ptr; } -function unset_object_by_reference(&$mypath) +function unset_object_by_reference(&$mypath) { global $config; @@ -61,7 +61,7 @@ function unset_object_by_reference(&$mypath) unset($ptr['queue'][$mypath[$i]]); } -function &get_dn_reference_to_me_in_config(&$mypath) +function &get_dn_reference_to_me_in_config(&$mypath) { global $config; @@ -73,7 +73,7 @@ function &get_dn_reference_to_me_in_config(&$mypath) return $ptr; } -function unset_dn_object_by_reference(&$mypath) +function unset_dn_object_by_reference(&$mypath) { global $config; @@ -84,26 +84,26 @@ function unset_dn_object_by_reference(&$mypath) unset($ptr['queue'][$mypath[$i]]); } -function clean_child_queues($type, $mypath) +function clean_child_queues($type, $mypath) { $ref = &get_reference_to_me_in_config($mypath); switch ($type) { case 'HFSC': - if (isset($ref['borrow'])) unset($ref['borrow']); + if (isset($ref['borrow'])) unset($ref['borrow']); if (isset($ref['hogs'])) unset($ref['hogs']); if (isset($ref['buckets'])) unset($ref['buckets']); break; case 'PRIQ': - if (isset($ref['borrow'])) unset($ref['borrow']); + if (isset($ref['borrow'])) unset($ref['borrow']); if (isset($ref['bandwidth'])) unset($ref['bandwidth']); if (isset($ref['bandwidthtype'])) unset($ref['bandwidthtype']); /* fall through */ case 'FAIRQ': - if (isset($ref['borrow'])) unset($ref['borrow']); + if (isset($ref['borrow'])) unset($ref['borrow']); /* fall through */ case 'CBQ': - if (isset($ref['realtime'])) unset($ref['realtime']); + if (isset($ref['realtime'])) unset($ref['realtime']); if (isset($ref['realtime1'])) unset($ref['realtime1']); if (isset($ref['realtime2'])) unset($ref['realtime2']); if (isset($ref['realtime3'])) unset($ref['realtime3']); @@ -114,66 +114,66 @@ function clean_child_queues($type, $mypath) if (isset($ref['linkshare'])) unset($ref['linkshare']); if (isset($ref['linkshare1'])) unset($ref['linkshare1']); if (isset($ref['linkshare2'])) unset($ref['linkshare2']); - if (isset($ref['linkshare3'])) unset($ref['linkshare3']); + if (isset($ref['linkshare3'])) unset($ref['linkshare3']); if (isset($ref['hogs'])) unset($ref['hogs']); if (isset($ref['buckets'])) unset($ref['buckets']); break; } } -function get_bandwidthtype_scale($type) +function get_bandwidthtype_scale($type) { - switch ($type) { - case "Gb": - $factor = 1024 * 1024 * 1024; - break; - case "Mb": - $factor = 1024 * 1024; - break; - case "Kb": - $factor = 1024; - break; - case "b": - default: - $factor = 1; - break; - } - return intval($factor); + switch ($type) { + case "Gb": + $factor = 1024 * 1024 * 1024; + break; + case "Mb": + $factor = 1024 * 1024; + break; + case "Kb": + $factor = 1024; + break; + case "b": + default: + $factor = 1; + break; + } + return intval($factor); } -function get_hfsc_bandwidth($object, $bw) +function get_hfsc_bandwidth($object, $bw) { $pattern= "/[0-9]+/"; - if (preg_match($pattern, $bw, $match)) - $bw_1 = $match[1]; - else - return 0; - $pattern= "/(b|Kb|Mb|Gb|%)/"; - if (preg_match($pattern, $bw, $match)) { - switch ($match[1]) { - case '%': - $bw_1 = $bw_1 / 100 * get_interface_bandwidth($object); - break; - default: - $bw_1 = $bw_1 * get_bandwidthtype_scale($match[0]); - break; - } + if (preg_match($pattern, $bw, $match)) + $bw_1 = $match[1]; + else + return 0; + $pattern= "/(b|Kb|Mb|Gb|%)/"; + if (preg_match($pattern, $bw, $match)) { + switch ($match[1]) { + case '%': + $bw_1 = $bw_1 / 100 * get_interface_bandwidth($object); + break; + default: + $bw_1 = $bw_1 * get_bandwidthtype_scale($match[0]); + break; + } return floatval($bw_1); - } else - return 0; + } else + return 0; } -function get_interface_bandwidth($object) +function get_interface_bandwidth($object) { global $altq_list_queues; - $int = $object->GetInterface(); - $altq =& $altq_list_queues[$int]; - if ($altq) { - $bw_3 = $altq->GetBandwidth(); - $bw_3 = $bw_3 * get_bandwidthtype_scale($altq->GetBwscale()); + $int = $object->GetInterface(); + $altq =& $altq_list_queues[$int]; + if ($altq) { + $bw_3 = $altq->GetBandwidth(); + $bw_3 = $bw_3 * get_bandwidthtype_scale($altq->GetBwscale()); return floatval($bw_3); - } else + } else return 0; } @@ -181,24 +181,24 @@ function get_interface_bandwidth($object) * This is duplicated here since we cannot include guiconfig.inc. * Including it makes all stuff break. */ -function shaper_do_input_validation($postdata, $reqdfields, $reqdfieldsn, $input_errors) +function shaper_do_input_validation($postdata, $reqdfields, $reqdfieldsn, $input_errors) { - /* check for bad control characters */ - foreach ($postdata as $pn => $pd) { - if (is_string($pd) && preg_match("/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]/", $pd)) { - $input_errors[] = sprintf(gettext("The field '%s' contains invalid characters."), $pn); - } - } - - for ($i = 0; $i < count($reqdfields); $i++) { - if ($postdata[$reqdfields[$i]] == "") { - $input_errors[] = sprintf(gettext("The field '%s' is required."), $reqdfieldsn[$i]); - } - } + /* check for bad control characters */ + foreach ($postdata as $pn => $pd) { + if (is_string($pd) && preg_match("/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]/", $pd)) { + $input_errors[] = sprintf(gettext("The field '%s' contains invalid characters."), $pn); + } + } + + for ($i = 0; $i < count($reqdfields); $i++) { + if ($postdata[$reqdfields[$i]] == "") { + $input_errors[] = sprintf(gettext("The field '%s' is required."), $reqdfieldsn[$i]); + } + } } -function cleanup_queue_from_rules($queue) +function cleanup_queue_from_rules($queue) { global $config; @@ -210,7 +210,7 @@ function cleanup_queue_from_rules($queue) } } -function cleanup_dnqueue_from_rules($queue) +function cleanup_dnqueue_from_rules($queue) { global $config; @@ -256,7 +256,7 @@ class altq_root_queue { } function GetLink() { return $this->link; - } + } function GetEnabled() { return $this->qenabled; } @@ -324,17 +324,17 @@ class altq_root_queue { shaper_do_input_validation($data, $reqdfields, $reqdfieldsn, $input_errors); - if ($data['bandwidth'] && (!is_numeric($data['bandwidth']))) + if ($data['bandwidth'] && (!is_numeric($data['bandwidth']))) $input_errors[] = gettext("Bandwidth must be an integer."); - if ($data['bandwidth'] < 0) + if ($data['bandwidth'] < 0) $input_errors[] = gettext("Bandwidth cannot be negative."); - if ($data['qlimit'] && (!is_numeric($data['qlimit']))) + if ($data['qlimit'] && (!is_numeric($data['qlimit']))) $input_errors[] = gettext("Qlimit must be an integer."); - if ($data['qlimit'] < 0) + if ($data['qlimit'] < 0) $input_errors[] = gettext("Qlimit must be positive."); - if ($data['tbrconfig'] && (!is_numeric($data['tbrconfig']))) + if ($data['tbrconfig'] && (!is_numeric($data['tbrconfig']))) $input_errors[] = gettext("Tbrsize must be an integer."); - if ($data['tbrconfig'] < 0) + if ($data['tbrconfig'] < 0) $input_errors[] = gettext("Tbrsize must be positive."); } @@ -361,7 +361,7 @@ class altq_root_queue { else $this->SetQlimit(""); if (isset($conf['name'])) - $this->SetQname($conf['name']); + $this->SetQname($conf['name']); if (!empty($conf['enabled'])) $this->SetEnabled($conf['enabled']); else @@ -369,14 +369,14 @@ class altq_root_queue { } function copy_queue($interface, &$cflink) { - $cflink['interface'] = $interface; - $cflink['name'] = $interface; - $cflink['scheduler'] = $this->GetScheduler(); - $cflink['bandwidth'] = $this->GetBandwidth(); - $cflink['bandwidthtype'] = $this->GetBwscale(); - $cflink['qlimit'] = $this->GetQlimit(); - $cflink['tbrconfig'] = $this->GetTbrConfig(); - $cflink['enabled'] = $this->GetEnabled(); + $cflink['interface'] = $interface; + $cflink['name'] = $interface; + $cflink['scheduler'] = $this->GetScheduler(); + $cflink['bandwidth'] = $this->GetBandwidth(); + $cflink['bandwidthtype'] = $this->GetBwscale(); + $cflink['qlimit'] = $this->GetQlimit(); + $cflink['tbrconfig'] = $this->GetTbrConfig(); + $cflink['enabled'] = $this->GetEnabled(); if (is_array($this->queues)) { $cflink['queue'] = array(); foreach ($this->queues as $q) { @@ -416,7 +416,7 @@ class altq_root_queue { $q =& new fairq_queue(); break; default: - /* XXX: but should not happen anyway */ + /* XXX: but should not happen anyway */ return; break; } @@ -443,7 +443,7 @@ class altq_root_queue { } $q->SetAvailableBandwidth($myBw); $this->SetAvailableBandwidth($this->GetAvailableBandwidth() - $myBw); - $this->queues[$q->GetQname()] = &$q; + $this->queues[$q->GetQname()] = &$q; ref_on_altq_queue_list($this->GetQname(), $q->GetQname()); if (is_array($queue['queue'])) { foreach ($queue['queue'] as $key1 => $que) { @@ -460,7 +460,7 @@ class altq_root_queue { function &find_queue($interface, $qname) { if ($qname == $this->GetQname()) { return $this; - } + } foreach ($this->queues as $q) { $result =& $q->find_queue("", $qname); if ($result) @@ -471,7 +471,7 @@ class altq_root_queue { function &find_parentqueue($interface, $qname) { if ($qname == $interface) { $result = NULL; - } else if ($this->queues[$qname]) { + } else if ($this->queues[$qname]) { $result = $this; } else if ($this->GetScheduler() <> "PRIQ") { foreach ($this->queues as $q) { @@ -485,7 +485,7 @@ class altq_root_queue { function build_tree() { global $shaperIFlist; - $tree = "
  • GetInterface()."&queue=". $this->GetInterface()."&action=show"; + $tree = "
  • GetInterface()."&queue=". $this->GetInterface()."&action=show"; $tree .= "\">" . $shaperIFlist[$this->GetInterface()] . ""; if (is_array($this->queues)) { $tree .= "