From 0aa3929ba86ea8198abcf03bd5fe64d32b110cfb Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Tue, 23 Apr 2013 12:05:23 -0300 Subject: Fix indent and whitespaces --- usr/local/www/wizards/traffic_shaper_wizard.inc | 302 ++++++++++++------------ 1 file changed, 151 insertions(+), 151 deletions(-) diff --git a/usr/local/www/wizards/traffic_shaper_wizard.inc b/usr/local/www/wizards/traffic_shaper_wizard.inc index 71bcea0..cf7bf1b 100644 --- a/usr/local/www/wizards/traffic_shaper_wizard.inc +++ b/usr/local/www/wizards/traffic_shaper_wizard.inc @@ -1,33 +1,33 @@ SetInterface($config['ezshaper']['step2']["conn{$i}interface"]); $interfacelist[] = $config['ezshaper']['step2']["conn{$i}interface"]; $altq->SetScheduler($config['ezshaper']['step2']["conn{$i}uploadscheduler"]); @@ -631,13 +631,13 @@ function apply_all_choosen_items() { $otherpriority = false; $remainbw = 0; $upfactor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}uploadspeed"]); - $upbw = floatval($config['ezshaper']['step2']["conn{$i}upload"]) * $upfactor; + $upbw = floatval($config['ezshaper']['step2']["conn{$i}upload"]) * $upfactor; if ($config['ezshaper']['step3']['enable']) { $voip = true; $voipbw = floatval($config['ezshaper']['step3']["conn{$i}upload"]); $voipbwunit = $config['ezshaper']['step3']["conn{$i}uploadspeed"]; - if ($voipbwunit == "%") + if ($voipbwunit == "%") $factor = $upbw/100; else $factor = wizard_get_bandwidthtype_scale($voipbwunit); @@ -681,12 +681,12 @@ function apply_all_choosen_items() { } else { $games = false; } - + if ($config['ezshaper']['step7']['enable']) { $otherpriority = true; } else { $otherpriority = false; - } + } $remainbw = round($remainbw / $upbw * 100, 2); if ($remainbw > 0 && $remainbw > 30) { @@ -700,9 +700,9 @@ function apply_all_choosen_items() { if ($sched == "PRIQ") $q =& new priq_queue(); else if ($sched == "CBQ") - $q =& new cbq_queue(); + $q =& new cbq_queue(); else if ($sched == "HFSC") - $q =& new hfsc_queue(); + $q =& new hfsc_queue(); $tmpcf = array(); $tmpcf['name'] = "qACK"; $tmpcf['priority'] = 6; @@ -712,12 +712,12 @@ function apply_all_choosen_items() { $tmpcf['borrow'] = "on"; $tmpcf['bandwidth'] = $remainbw * 0.2; $tmpcf['bandwidthtype'] = "%"; - } + } else if ($sched == "HFSC") { $lkbw = 0.20 * $remainbw; $tmpcf['linkshare3'] = "{$lkbw}%"; $tmpcf['linkshare'] = "on"; - $tmpcf['bandwidth'] = $lkbw; + $tmpcf['bandwidth'] = $lkbw; $tmpcf['bandwidthtype'] = "%"; } array_push($tmppath, "qACK"); @@ -781,9 +781,9 @@ function apply_all_choosen_items() { $tmpcf['upperlimit'] = "on"; $tmpcf['upperlimit3'] = "{$p2pcatchbw}{$p2pcatchbwunit}"; $tmpcf['bandwidth'] = $p2pcatchbw; - $tmpcf['bandwidthtype'] = $p2pcatchbwunit; + $tmpcf['bandwidthtype'] = $p2pcatchbwunit; } - $tmpcf['default'] = "on"; + $tmpcf['default'] = "on"; $tmpcf['qlimit'] = 500; } else { if ($sched == "CBQ") { @@ -793,10 +793,10 @@ function apply_all_choosen_items() { } else if ($sched == "HFSC") { $tmpbw = $remainbw * 0.05; /* 5% bandwidth */ $tmpcf['linkshare'] = "on"; - $tmpcf['linkshare3'] = "{$tmpbw}%"; - $tmpcf['upperlimit'] = "on"; - $tmpcf['upperlimit3'] = "{$tmpbw}%"; - $tmpcf['bandwidth'] = $tmpbw; + $tmpcf['linkshare3'] = "{$tmpbw}%"; + $tmpcf['upperlimit'] = "on"; + $tmpcf['upperlimit3'] = "{$tmpbw}%"; + $tmpcf['bandwidth'] = $tmpbw; $tmpcf['bandwidthtype'] = "%"; } } @@ -807,7 +807,7 @@ function apply_all_choosen_items() { //var_dump($input_errors); $qtmp->wconfig(); } - + if ($voip) { if ($sched == "PRIQ") $q =& new priq_queue(); @@ -847,7 +847,7 @@ function apply_all_choosen_items() { //var_dump($input_errors); $qtmp->wconfig(); } - + if ($games) { if ($sched == "PRIQ") $q =& new priq_queue(); @@ -865,9 +865,9 @@ function apply_all_choosen_items() { $tmpcf['bandwidth'] = $remainbw * 0.2; /* 20% bandwidth */ $tmpcf['bandwidthtype'] = "%"; } else if ($sched == "HFSC") { - $gamesbw = $remainbw * 0.2; /* 20% bandwidth */ + $gamesbw = $remainbw * 0.2; /* 20% bandwidth */ $tmpcf['linkshare'] = "on"; - $tmpcf['linkshare3'] = "{$gamesbw}%"; + $tmpcf['linkshare3'] = "{$gamesbw}%"; $tmpcf['bandwidth'] = "{$gamesbw}"; $tmpcf['bandwidthtype'] = "%"; } @@ -878,7 +878,7 @@ function apply_all_choosen_items() { //var_dump($input_errors); $qtmp->wconfig(); } - + if ($otherpriority) { if ($sched == "PRIQ") $q =& new priq_queue(); @@ -908,7 +908,7 @@ function apply_all_choosen_items() { //echo "qHigh
"; //var_dump($input_errors); $qtmp->wconfig(); - + if ($sched == "PRIQ") $q =& new priq_queue(); @@ -937,7 +937,7 @@ function apply_all_choosen_items() { $lsbw = $remainbw * 0.05; $tmpcf['linkshare3'] = "{$lsbw}%"; /* 5% bandwidth */ $tmpcf['bandwidth'] = $lsbw; - $tmpcf['bandwidthtype'] = "%"; + $tmpcf['bandwidthtype'] = "%"; } $tmpcf['linkshare'] = "on"; } @@ -986,7 +986,7 @@ function apply_all_choosen_items() { $voipbw = $config['ezshaper']['step3']["download"]; $voipbwunit = $config['ezshaper']['step3']["downloadspeed"]; if ($sched != "HFSC") { - if ($voipbwunit == "%") + if ($voipbwunit == "%") $factor = $lanbw/100; else $factor = wizard_get_bandwidthtype_scale($voipbwunit); @@ -1078,40 +1078,40 @@ function apply_all_choosen_items() { if ($sched != "PRIQ") { if ($sched == "CBQ") $q =& new cbq_queue(); - else if ($sched == "HFSC") - $q =& new hfsc_queue(); - $tmpcf = array(); - $tmpcf['name'] = "qInternet"; - //$tmpcf['priority'] = 6; - $tmpcf['ecn'] = "on"; - $tmpcf['enabled'] = "on"; - If ($sched == "CBQ") { - $tmpcf['bandwidth'] = $lanbw/1000; - $tmpcf['bandwidthtype'] = "Kb"; - } - else if ($sched == "HFSC") { - $tmpcf['linkshare3'] = $lanbw/1000 ."Kb"; - $tmpcf['upperlimit'] = "on"; - $tmpcf['upperlimit3'] = $lanbw/1000 ."Kb"; - $tmpcf['linkshare'] = "on"; - $tmpcf['bandwidth'] = $lanbw/1000; - $tmpcf['bandwidthtype'] = "Kb"; - } - array_push($tmppath, "qInternet"); - $qtmp =& $altq->add_queue($q, &$tmpcf, &$tmppath, $input_errors); - //array_pop($tmppath); - //echo "qInternet
"; - //var_dump($input_errors); - $qtmp->wconfig(); - $altq =& $qtmp; + else if ($sched == "HFSC") + $q =& new hfsc_queue(); + $tmpcf = array(); + $tmpcf['name'] = "qInternet"; + //$tmpcf['priority'] = 6; + $tmpcf['ecn'] = "on"; + $tmpcf['enabled'] = "on"; + If ($sched == "CBQ") { + $tmpcf['bandwidth'] = $lanbw/1000; + $tmpcf['bandwidthtype'] = "Kb"; + } + else if ($sched == "HFSC") { + $tmpcf['linkshare3'] = $lanbw/1000 ."Kb"; + $tmpcf['upperlimit'] = "on"; + $tmpcf['upperlimit3'] = $lanbw/1000 ."Kb"; + $tmpcf['linkshare'] = "on"; + $tmpcf['bandwidth'] = $lanbw/1000; + $tmpcf['bandwidthtype'] = "Kb"; + } + array_push($tmppath, "qInternet"); + $qtmp =& $altq->add_queue($q, &$tmpcf, &$tmppath, $input_errors); + //array_pop($tmppath); + //echo "qInternet
"; + //var_dump($input_errors); + $qtmp->wconfig(); + $altq =& $qtmp; } if ($sched == "PRIQ") $q =& new priq_queue(); else if ($sched == "CBQ") - $q =& new cbq_queue(); + $q =& new cbq_queue(); else if ($sched == "HFSC") - $q =& new hfsc_queue(); + $q =& new hfsc_queue(); $tmpcf = array(); $tmpcf['name'] = "qACK"; $tmpcf['priority'] = 6; @@ -1125,7 +1125,7 @@ function apply_all_choosen_items() { $lkbw = 0.20 * $remainbw; $tmpcf['linkshare3'] = "{$lkbw}%"; $tmpcf['linkshare'] = "on"; - $tmpcf['bandwidth'] = $lkbw; + $tmpcf['bandwidth'] = $lkbw; $tmpcf['bandwidthtype'] = "%"; } array_push($tmppath, "qACK"); @@ -1160,7 +1160,7 @@ function apply_all_choosen_items() { $tmpcf['bandwidth'] = $p2pcatchbw; $tmpcf['bandwidthtype'] = $p2pcatchbwunit; } - $tmpcf['default'] = "on"; + $tmpcf['default'] = "on"; } else { if ($sched == "CBQ") { $tmpcf['borrow'] = "on"; @@ -1169,10 +1169,10 @@ function apply_all_choosen_items() { } else if ($sched == "HFSC") { $tmpbw = $remainbw * 0.05; /* 5% bandwidth */ $tmpcf['linkshare'] = "on"; - $tmpcf['linkshare3'] = "{$tmpbw}%"; - $tmpcf['upperlimit'] = "on"; - $tmpcf['upperlimit3'] = "{$tmpbw}%"; - $tmpcf['bandwidth'] = $tmpbw; + $tmpcf['linkshare3'] = "{$tmpbw}%"; + $tmpcf['upperlimit'] = "on"; + $tmpcf['upperlimit3'] = "{$tmpbw}%"; + $tmpcf['bandwidth'] = $tmpbw; $tmpcf['bandwidthtype'] = "%"; } } @@ -1241,9 +1241,9 @@ function apply_all_choosen_items() { $tmpcf['bandwidth'] = $remainbw * 0.2; /* 20% bandwidth */ $tmpcf['bandwidthtype'] = "%"; } else if ($sched == "HFSC") { - $gamesbw = $remainbw * 0.2; /* 20% bandwidth */ + $gamesbw = $remainbw * 0.2; /* 20% bandwidth */ $tmpcf['linkshare'] = "on"; - $tmpcf['linkshare3'] = "{$gamesbw}%"; + $tmpcf['linkshare3'] = "{$gamesbw}%"; $tmpcf['bandwidth'] = "{$gamesbw}"; $tmpcf['bandwidthtype'] = "%"; } @@ -1284,7 +1284,7 @@ function apply_all_choosen_items() { //echo "qHigh
"; //var_dump($input_errors); $qtmp->wconfig(); - + if ($sched == "PRIQ") $q =& new priq_queue(); else if ($sched == "CBQ") @@ -1312,7 +1312,7 @@ function apply_all_choosen_items() { $lsbw = $remainbw * 0.05; $tmpcf['linkshare3'] = "{$lsbw}%"; /* 5% bandwidth */ $tmpcf['bandwidth'] = $lsbw; - $tmpcf['bandwidthtype'] = "%"; + $tmpcf['bandwidthtype'] = "%"; } $tmpcf['linkshare'] = "on"; } @@ -1328,7 +1328,7 @@ function apply_all_choosen_items() { /* End LAN bandwidth ------------------------------------------------------------------------------------- */ if (!is_array($config['filter']['rule'])) - $config['filter']['rule'] = array(); + $config['filter']['rule'] = array(); if (empty($interfacelist)) $interfacelist = ""; @@ -1336,24 +1336,24 @@ function apply_all_choosen_items() { $interfacelist = implode(",", $interfacelist); /* Rules */ - if ($penalty) { - if( is_ipaddr($config['ezshaper']['step4']['address']) || is_alias($config['ezshaper']['step4']['address'])) { - $rule = array(); - $rule['type'] = "match"; - $rule['interface'] = $interfacelist; - $rule['descr'] = gettext("Penalty Box"); - $rule['source']['any'] = TRUE; - $rule['defaultqueue'] = "qOthersLow"; - $rule['source']['address'] = $config['ezshaper']['step4']['address']; - $rule['destination']['any'] = TRUE; - $rule['floating'] = "yes"; - $rule['wizard'] = "yes"; - $rule['enabled'] = "on"; - $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); - $config['filter']['rule'][] = $rule; - - } - } + if ($penalty) { + if( is_ipaddr($config['ezshaper']['step4']['address']) || is_alias($config['ezshaper']['step4']['address'])) { + $rule = array(); + $rule['type'] = "match"; + $rule['interface'] = $interfacelist; + $rule['descr'] = gettext("Penalty Box"); + $rule['source']['any'] = TRUE; + $rule['defaultqueue'] = "qOthersLow"; + $rule['source']['address'] = $config['ezshaper']['step4']['address']; + $rule['destination']['any'] = TRUE; + $rule['floating'] = "yes"; + $rule['wizard'] = "yes"; + $rule['enabled'] = "on"; + $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); + $config['filter']['rule'][] = $rule; + + } + } /* If user specifies an IP, we don't bother with providers */ if ($voip) { @@ -1389,7 +1389,7 @@ function apply_all_choosen_items() { } elseif( $config['ezshaper']['step3']['provider'] == "Generic" ) { /* create VOIP rules */ $rule = array(); - $rule['type'] = "match"; + $rule['type'] = "match"; $rule['interface'] = $interfacelist; $rule['descr'] = "DiffServ/Lowdelay/Upload"; $rule['protocol'] = "udp"; @@ -1402,7 +1402,7 @@ function apply_all_choosen_items() { $rule['enabled'] = "on"; $rule['created'] = make_config_revision_entry(null, gettext("Traffic Shaper Wizard")); $config['filter']['rule'][] = $rule; - + } else { /* loop through voiplist[] */ foreach ($voiplist[$config['ezshaper']['step3']['provider']] as $voip) { @@ -1423,7 +1423,7 @@ function apply_all_choosen_items() { $config['filter']['rule'][] = $rule; } } - } + } /* loop through p2plist[] */ if ($p2p) { @@ -1435,7 +1435,7 @@ function apply_all_choosen_items() { $rule['type'] = "match"; $rule['interface'] = $interfacelist; $rule['defaultqueue'] = 'qP2P'; - $rule['source']['any'] = TRUE; + $rule['source']['any'] = TRUE; $rule['destination']['any'] = TRUE; $rule['descr'] = "m_P2P {$p2pclient[0]} outbound"; $rule['floating'] = "yes"; @@ -1448,7 +1448,7 @@ function apply_all_choosen_items() { } } } - + /* loop through gamesplist[] */ if ($games) { foreach($config['ezshaper']['step6'] as $key => $val) { @@ -1475,7 +1475,7 @@ function apply_all_choosen_items() { } } } - + /* loop through othersplist[] */ if ($otherpriority) { foreach($config['ezshaper']['step7'] as $key => $val) { @@ -1495,7 +1495,7 @@ function apply_all_choosen_items() { case "L": $rule['defaultqueue'] = 'qOthersLow'; /* posted value H or L */ if ($otherclient[1] == "tcp") - $rule['ackqueue'] = 'qACK'; + $rule['ackqueue'] = 'qACK'; $loop = 0; break; case "D": @@ -1517,7 +1517,7 @@ function apply_all_choosen_items() { $rule['wizard'] = "yes"; $rule['enabled'] = "on"; $rule['descr'] = "m_Other {$otherclient[0]} outbound"; - + if($otherclient[2] or $otherclient[3]) { $rule['destination']['port'] = $otherclient[2]."-".$otherclient[3]; } @@ -1533,22 +1533,22 @@ function apply_all_choosen_items() { } function wizard_get_bandwidthtype_scale($type = "b") { - 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); } ?> -- cgit v1.1