From 406b5165dbb9161cef2972cfe359d741b89a07bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=C3=A7i?= Date: Fri, 7 Mar 2008 17:46:41 +0000 Subject: Make the multi LAN wizard actually work. When the other wizard are finished it will be expossed to the GUI. --- .../wizards/traffic_shaper_wizard_multi_lan.inc | 88 ++++++++++------------ .../wizards/traffic_shaper_wizard_multi_lan.xml | 21 +++--- 2 files changed, 50 insertions(+), 59 deletions(-) (limited to 'usr/local/www/wizards') diff --git a/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc b/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc index bf4c835..66181bd 100644 --- a/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc +++ b/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc @@ -35,12 +35,12 @@ function step1_submitphpaction() { if (!isset($_POST['numberofconnections'])) { $message=gettext("You need to specify the number of local interfaces connected."); - header("Location:wizard.php?xml=traffic_shaper_wizard.xml&stepid=0&message={$message}"); + header("Location:wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=0&message={$message}"); exit; } if (intval($_POST['numberofconnections']) > 100 || intval($_POST['numberofconnections']) < 1) { $message=gettext("The number of local interfaces supported is between 1 and 100."); - header("Location:wizard.php?xml=traffic_shaper_wizard.xml&stepid=0&message={$message}"); + header("Location:wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=0&message={$message}"); exit; } } @@ -55,7 +55,7 @@ function step2_stepbeforeformdisplay() { continue; if (!isset($ifdesc['enable']) && $if != "lan" && $if != "wan") continue; - if ($if == "lan") + if ($if == "wan") continue; $numberofinterfaces++; $iflist[] = $if; @@ -63,7 +63,7 @@ function step2_stepbeforeformdisplay() { $numberofconnections = intval($config['ezshaper']['step1']['numberofconnections']); if ($numberofconnections > $numberofinterfaces) { $message=gettext("You do not have {$numberofconnections} of local interfaces!"); - header("Location:wizard.php?xml=traffic_shaper_wizard.xml&stepid=0&message={$message}"); + header("Location:wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=0&message={$message}"); exit; } @@ -81,7 +81,7 @@ function step2_stepbeforeformdisplay() { $field['type'] = "listtopic"; $fields[] = $field; $field = array(); - $field['name'] = "uploaddscheduler"; + $field['name'] = "uploadscheduler"; $field['type'] = "select"; $field['typehint'] = "Queueing discipline to apply on the upload of this connection."; $field['options']['option'] = array(); @@ -221,40 +221,30 @@ function step2_stepsubmitphpaction() { for ($j = $j; $j < $steps; $j++) { if ($_POST["conn{$i}interface"] == $_POST["conn{$j}interface"]) { $message=gettext("You cannot select the same interface for connections {$i} and {$j}."); - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=1&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=1&message={$message}"); exit; } - if (!is_numeric($_POST["conn{$i}upload"])) { - $message = gettext("Upload bandwidth of connection {$i} is not valid."); - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=1&message={$message}"); - exit; - } - if (!is_numeric($_POST["conn{$i}download"])) { - $message = gettext("Download bandwidth of connection {$i} is not valid."); - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=1&message={$message}"); - exit; - } - $upbw = floatval($_POST["conn{$i}upload"]); - $downbw = floatval($_POST["conn{$i}download"]); - if ($upbw == 0 || $downbw = 0) { - $message = gettext("You cannot specify 0 bandwidth!") -; - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=1&message -={$message}"); + } + } + if (!is_numeric($_POST["connupload"])) { + $message = gettext("Upload bandwidth of connection is not valid."); + header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=1&message={$message}"); exit; } - if ($upbw < 128 && $_POST["conn{$i}uploadspeed"] == "Kb" && trim($_POST["conn{$i}scheduler"]) == "CBQ") { - $message=gettext("We do not support Bandwidths smaller than 128Kbit/s for CBQ scheduler."); - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=1&message={$message}"); - exit; - } - if ($downbw < 128 && $_POST["conn{$i}downloadspeed"] == "Kb" && trim($_POST["downloadscheduler"]) == "CBQ") { - $message=gettext("We do not support Bandwidths smaller than 128Kbit/s for CBQ scheduler."); - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=1&message={$message}"); - exit; + if (!is_numeric($_POST["conndownload"])) { + $message = gettext("Download bandwidth of connection is not valid."); + header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=1&message={$message}"); + exit; } - } - } + $upbw = floatval($_POST["connupload"]); + $downbw = floatval($_POST["conndownload"]); + if ($upbw == 0 || $downbw = 0) { + $message = gettext("You cannot specify 0 bandwidth!"); + header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=1&message={$message}"); + + exit; + } + /* This is necessary since the wizard expects predefined fields. */ unset($config['ezshaper']['step2']); @@ -283,7 +273,7 @@ function step3_stepsubmitphpaction() { if(!is_alias($_POST['address'])) { /* item is not an ip or alias. error out */ $message=gettext("Address must be a valid IP address or Firewall Alias. Please correct this value to continue."); - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=2&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=2&message={$message}"); exit; } } @@ -294,7 +284,7 @@ function step3_stepsubmitphpaction() { if ($_POST["connupload"]) { if (!is_numeric($_POST["connupload"])) { $message = gettext("Upload bandwidth of connection {$i} is not valid."); - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=2&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=2&message={$message}"); exit; } $factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}uploadspeed"]); @@ -303,7 +293,7 @@ function step3_stepsubmitphpaction() { $input_bw = $factor * floatval($_POST["conn{$i}upload"]); if ((0.8 * $ifbw) < $input_bw) { $message=gettext("You cannot set the VoIP upload bandwidth on connection {$i} higher than 80% of the connection."); - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=2&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=2&message={$message}"); exit; } } @@ -317,24 +307,24 @@ function step4_stepsubmitphpaction() { if ( $_POST['enable'] ) { if(!$_POST['bandwidth']) { $message="You need to specify a value for bandwidth!"; - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=3&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=3&message={$message}"); exit; } if(!is_numeric($_POST['bandwidth'])) { $message="The posted value is not a valid bandwidth."; - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=3&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=3&message={$message}"); exit; } /* if (wizard_get_bwunit($_POST['bandwidth']) <> "%") { $message = gettext("Only percentage bandwidth specification is allowed."); - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=3&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=3&message={$message}"); exit; } $bw = wizard_get_bw($_POST['bandwidth']); if($bw > 15 && $bw < 2) { $message="Values should be between 2% and 15%!"; - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=3&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=3&message={$message}"); exit; } */ @@ -343,7 +333,7 @@ function step4_stepsubmitphpaction() { if(!is_alias($_POST['address'])) { /* item is not an ip or alias. error out */ $message=gettext("Address must be a valid IP address or Firewall Alias. Please correct this value to continue."); - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=3&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=3&message={$message}"); } } } @@ -356,19 +346,19 @@ function step5_stepsubmitphpaction() { if (isset($_POST['bandwidth']) && $_POST['bandwidth'] <> "") { if(!is_numeric($_POST['bandwidth'])) { $message="Posted value is not a valid bandwidth."; - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=4&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=4&message={$message}"); } /* if (wizard_get_bwunit($_POST['bandwidth']) <> "%") { $message = gettext("Only percentage bandwidth specification is allowed."); - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=4&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=4&message={$message}"); exit; } $bw = wizard_get_bw($_POST['bandwidth']); if($bw > 15 && $bw < 2) { $message="Values should be between 2% and 15%!"; - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=3&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=3&message={$message}"); exit; } */ @@ -821,7 +811,7 @@ $othersplist = array(); $remainbw = round($remainbw / $upbw * 100, 2); if ($remainbw > 0 && $remainbw > 30) { $message=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue."); - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=2&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=2&message={$message}"); exit; } else { $remainbw = 100 - $remainbw; @@ -1129,6 +1119,8 @@ $othersplist = array(); $otherpriority = false; $remainbw = 0; + $factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["connuploadspeed"]); + $ifbw = $factor * floatval($config['ezshaper']['step2']["connupload"]); if ($config['ezshaper']['step3']['enable']) { $voip = true; @@ -1171,10 +1163,10 @@ $othersplist = array(); } else { $otherpriority = false; } - $remainbw = round($remainbw / $lanbw * 100, 2); + $remainbw = round($remainbw / $ifbw * 100, 2); if ($remainbw > 0 && $remainbw > 30) { $message=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue."); - header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=2&message={$message}"); + header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=2&message={$message}"); exit; } else { $remainbw = 100 - $remainbw; diff --git a/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.xml b/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.xml index cc28bbb..73424ba 100644 --- a/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.xml +++ b/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.xml @@ -2,7 +2,7 @@ /* $Id$ */ - traffic_shaper_wizard.xml + traffic_shaper_wizard_multi_lan.xml part of pfSense (http://www.pfsense.org/) Copyright (C) 2005 Bill Marquette - bill.marquette@gmail.com. @@ -51,7 +51,7 @@ step1_submitphpaction(); - /usr/local/www/wizards/traffic_shaper_wizard.inc + /usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc 2 @@ -60,7 +60,7 @@ step2_stepbeforeformdisplay(); step2_stepsubmitphpaction(); - /usr/local/www/wizards/traffic_shaper_wizard.inc + /usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc Next @@ -196,9 +196,8 @@ submit - step3_stepbeforeformdisplay(); step3_stepsubmitphpaction(); - /usr/local/www/wizards/traffic_shaper_wizard.inc + /usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc 4 @@ -276,7 +275,7 @@ step4_stepsubmitphpaction(); - /usr/local/www/wizards/traffic_shaper_wizard.inc + /usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc 5 @@ -483,7 +482,7 @@ step5_stepsubmitphpaction(); - /usr/local/www/wizards/traffic_shaper_wizard.inc + /usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc 6 @@ -645,7 +644,7 @@ submit - /usr/local/www/wizards/traffic_shaper_wizard.inc + /usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc 7 @@ -1239,7 +1238,7 @@ submit - /usr/local/www/wizards/traffic_shaper_wizard.inc + /usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc 8 @@ -1256,7 +1255,7 @@ step8_stepsubmitphpaction(); - /usr/local/www/wizards/traffic_shaper_wizard.inc + /usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc 9 @@ -1267,7 +1266,7 @@ submit - /usr/local/www/wizards/traffic_shaper_wizard.inc + /usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc step9_stepsubmitphpaction(); -- cgit v1.1