From c60e4f61012753efada5efcc61f9db23fa1c8084 Mon Sep 17 00:00:00 2001 From: Ermal Date: Wed, 18 Aug 2010 21:53:05 +0000 Subject: Also do the wizard optimizations and user-friendliness to the traffic_shaper_wizard_multi_all.xml --- usr/local/www/wizards/traffic_shaper_wizard.inc | 2 + .../wizards/traffic_shaper_wizard_dedicated.inc | 5 +- .../wizards/traffic_shaper_wizard_multi_all.inc | 879 +++++++++++---------- .../wizards/traffic_shaper_wizard_multi_all.xml | 4 +- .../wizards/traffic_shaper_wizard_multi_lan.inc | 1 + 5 files changed, 452 insertions(+), 439 deletions(-) (limited to 'usr/local/www/wizards') diff --git a/usr/local/www/wizards/traffic_shaper_wizard.inc b/usr/local/www/wizards/traffic_shaper_wizard.inc index 61af8bf..47ce591 100644 --- a/usr/local/www/wizards/traffic_shaper_wizard.inc +++ b/usr/local/www/wizards/traffic_shaper_wizard.inc @@ -127,6 +127,7 @@ function step2_stepbeforeformdisplay() { $field['bindstofield'] = "ezshaper->step2->conn{$i}interface"; $fields[] = $field; + $field = array(); $field['displayname'] = "Upload Scheduler"; $field['name'] = "conn{$i}uploadscheduler"; $field['type'] = "select"; @@ -308,6 +309,7 @@ function step3_stepbeforeformdisplay() { $field['type'] = "listtopic"; $voipfields[] = $field; + $field = array(); $field['name'] = "Provider"; $enablefields[] = "Provider"; $field['type'] = "select"; diff --git a/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc b/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc index efd56a7..b264949 100755 --- a/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc +++ b/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc @@ -265,8 +265,8 @@ function step2_stepsubmitphpaction() { } $upbw = $_POST["conn{$i}upload"]; $downbw = $_POST["conn{$i}download"]; - if ($upbw == 0 || $downbw = 0) { - $savemsg = gettext("You cannot specify 0 bandwidth!"); + if ($upbw < 1 || $downbw < 1) { + $savemsg = gettext("You cannot specify bandwidth smaller than 1!"); $stepid--; return; } @@ -332,6 +332,7 @@ function step3_stepbeforeformdisplay() { $field['type'] = "listtopic"; $voipfields[] = $field; + $field = array(); $field['name'] = "Provider"; $enablefields[] = "Provider"; $field['type'] = "select"; diff --git a/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc b/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc index 61c836e..8a2a74b 100755 --- a/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc +++ b/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc @@ -32,284 +32,276 @@ */ function step1_submitphpaction() { - - if (!isset($_POST['numberofconnections'])) { - $message=gettext("You need to specify the number of connections."); - header("Location:wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=0&message={$message}"); - exit; - } - if (intval($_POST['numberofconnections']) > 100 || intval($_POST['numberofconnections']) < 1) { - $message=gettext("The number of connections supported is between 1 and 100."); - header("Location:wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=0&message={$message}"); - exit; - } + global $stepid, $savemsg; + + if (!isset($_POST['numberofconnections'])) { + $savemsg=gettext("You need to specify the number of connections."); + $stepid--; + $stepid--; + return; + } + if (intval($_POST['numberofconnections']) < 1) { + $savemsg=gettext("The number of connections should be greater than 1."); + $stepid--; + return; + } } function step2_stepbeforeformdisplay() { - global $config, $pkg; - - $numberofinterfaces = 0; - $iflist = array(); - $iflisttmp = get_configured_interface_with_descr(); - foreach ($iflisttmp as $if => $ifdesc) { - if (!is_altq_capable(get_real_interface($if))) - continue; - if ($if == "lan") - continue; - $numberofinterfaces++; - $iflist[$if] = $ifdesc; - } - $numberofconnections = intval($config['ezshaper']['step1']['numberofconnections']); - if ($numberofconnections > $numberofinterfaces) { - $message=gettext("You have less interfaces than number of connections!"); - header("Location:wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=0&message={$message}"); - exit; - } - - $numberoflocalinterfaces = intval($config['ezshaper']['step1']['numberoflocalinterfaces']); - if ($numberoflocalinterfaces > $numberofinterfaces) { - $message=gettext("You have less interfaces than number of connections!"); - header("Location:wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=0&message={$message}"); - exit; - } - + global $config, $pkg; + global $stepid, $savemsg; + + $numberofinterfaces = 0; + $iflist = array(); + $iflisttmp = get_configured_interface_with_descr(); + foreach ($iflisttmp as $if => $ifdesc) { + if (!is_altq_capable(get_real_interface($if))) + continue; + $numberofinterfaces++; + $iflist[$if] = $ifdesc; + } + $numberofconnections = intval($config['ezshaper']['step1']['numberofconnections']); + if ($numberofconnections > $numberofinterfaces) { + $savemsg=gettext("You have less interfaces than number of connections!"); + $stepid--; + return; + } - $cfgname = "traffic_shaper_wizard_multi_all.xml"; + $numberoflocalinterfaces = intval($config['ezshaper']['step1']['numberoflocalinterfaces']); + if ($numberoflocalinterfaces > $numberofinterfaces) { + $savemsg=gettext("You have less interfaces than number of connections!"); + $stepid--; + return; + } + $cfgname = "traffic_shaper_wizard_multi_all.xml"; - $fields =& $pkg['step'][1]['fields']['field']; - - /* - unset($config['ezshaper']['step2']); - $config['ezshaper']['step2'] = array(); - write_config(); - */ - $fields = array(); - + $fields =& $pkg['step'][1]['fields']['field']; + + /* + unset($config['ezshaper']['step2']); + $config['ezshaper']['step2'] = array(); + write_config(); + */ + $fields = array(); + + for ($i = 0; $i < $numberoflocalinterfaces; $i++) { $field = array(); - $field['name'] = "Setup LAN schedulers"; + $interface_friendly = $i+1; + $field['name'] = "Setup connection speed and scheduler information for interface LAN #{$interface_friendly}"; $field['type'] = "listtopic"; $fields[] = $field; - for ($i = 0; $i < $numberoflocalinterfaces; $i++) { - $field = array(); - $field['name'] = "local{$i}interface"; - $field['type'] = "select"; -// $field['typehint'] = "Interface of this connection."; - $field['options']['option'] = array(); - foreach ($iflist as $ifname => $ifdescr) { - $opts = array(); - $opts['displayname'] = $ifdescr; - $opts['name'] = $ifname; - $opts['value'] = $ifname; - $field['options']['option'][] = $opts; - } - /* LAN is needed here */ - $opts = array(); - $opts['name'] = "lan"; - $opts['value'] = "lan"; - $field['options']['option'][] = $opts; - - $field['combinefieldsbegin'] = "true"; - $field['bindstofield'] = "ezshaper->step2->local{$i}interface"; - $fields[] = $field; - - $field = array(); - $field['combinefieldsend'] = "true"; - $field['dontdisplayname'] = "true"; - $field['dontcombinecells'] = "true"; - - $field['name'] = "local{$i}downloadscheduler"; - $field['type'] = "select"; - $field['typehint'] = "Queueing discipline to apply on this local interface."; - $field['options']['option'] = array(); - $opts = array(); - $opts['name'] = "HFSC"; - $opts['value'] = "HFSC"; - $field['options']['option'][] = $opts; - $opts = array(); - $opts['name'] = "CBQ"; - $opts['value'] = "CBQ"; - $field['options']['option'][] = $opts; + $field = array(); + $field['displayname'] = "Interface & Scheduler"; + $field['name'] = "local{$i}interface"; + $field['type'] = "select"; + $field['options']['option'] = array(); + foreach ($iflist as $ifname => $ifdescr) { $opts = array(); - $opts['name'] = "PRIQ"; - $opts['value'] = "PRIQ"; - $field['options']['option'][] = $opts; - $field['bindstofield'] = "ezshaper->step2->local{$i}downloadscheduler"; - $fields[] = $field; + $opts['displayname'] = $ifdescr; + $opts['name'] = $ifname; + $opts['value'] = $ifname; + $field['options']['option'][] = $opts; } + $field['combinefieldsbegin'] = "true"; + $field['bindstofield'] = "ezshaper->step2->local{$i}interface"; + $fields[] = $field; $field = array(); - $field['name'] = "Setup connections speeds"; - $field['type'] = "listtopic"; + $field['combinefieldsend'] = "true"; + $field['dontdisplayname'] = "true"; + $field['dontcombinecells'] = "true"; + $field['name'] = "local{$i}downloadscheduler"; + $field['type'] = "select"; + $field['typehint'] = "Queueing discipline to apply on this local interface."; + $field['options']['option'] = array(); + $opts = array(); + $opts['name'] = "HFSC"; + $opts['value'] = "HFSC"; + $field['options']['option'][] = $opts; + $opts = array(); + $opts['name'] = "CBQ"; + $opts['value'] = "CBQ"; + $field['options']['option'][] = $opts; + $opts = array(); + $opts['name'] = "PRIQ"; + $opts['value'] = "PRIQ"; + $field['options']['option'][] = $opts; + $field['bindstofield'] = "ezshaper->step2->local{$i}downloadscheduler"; $fields[] = $field; + } - for ($i = 0; $i < $numberofconnections; $i++) { - - $field = array(); - $interface_friendly = $i+1; - $field['name'] = "Setup connection speed and scheduler information for interface #{$interface_friendly}"; - $field['type'] = "listtopic"; - $fields[] = $field; - - $field = array(); - $field['name'] = "conn{$i}interface"; - $field['type'] = "select"; - $interface_real = $i+1; - $field['typehint'] = "Select interface #{$interface_real} that you would like to shape"; - $field['options']['option'] = array(); - foreach ($iflist as $ifname => $ifdescr) { - $opts = array(); - $opts['displayname'] = $ifdescr; - $opts['name'] = $ifname; - $opts['value'] = $ifname; - $field['options']['option'][] = $opts; - } - $field['bindstofield'] = "ezshaper->step2->conn{$i}interface"; - $fields[] = $field; + for ($i = 0; $i < $numberofconnections; $i++) { + $field = array(); + $interface_friendly = $i+1; + $field['name'] = "Setup connection speed and scheduler information for interface WAN#{$interface_friendly}"; + $field['type'] = "listtopic"; + $fields[] = $field; - $field['name'] = "conn{$i}uploadscheduler"; - $field['type'] = "select"; - $field['typehint'] = "Queueing discipline to apply on the upload of this connection."; - $field['options']['option'] = array(); - $opts = array(); - $opts['name'] = "HFSC"; - $opts['value'] = "HFSC"; - $field['options']['option'][] = $opts; - $opts = array(); - $opts['name'] = "CBQ"; - $opts['value'] = "CBQ"; - $field['options']['option'][] = $opts; - $opts = array(); - $opts['name'] = "PRIQ"; - $opts['value'] = "PRIQ"; - $field['options']['option'][] = $opts; - $field['bindstofield'] = "ezshaper->step2->conn{$i}uploadscheduler"; - $fields[] = $field; - - $field = array(); - $field['name'] = "conn{$i}upload"; - $field['type'] = "input"; - $field['bindstofield'] = "ezshaper->step2->conn{$i}upload"; - $field['combinefieldsbegin'] = "true"; - $fields[] = $field; - - $field = array(); - $field['combinefieldsend'] = "true"; - $field['dontdisplayname'] = "true"; - $field['dontcombinecells'] = "true"; - $field['name'] = "conn{$i}uploadspeed"; - $field['typehint'] = "Upload bandwidth on this connection."; - $field['type'] = "select"; - $field['options']['option'] = array(); - $opts = array(); - $opts['value'] = "Kb"; - $opts['name'] = "Kbit/s"; - $field['options']['option'][] = $opts; - $opts = array(); - $opts['value'] = "Mb"; - $opts['name'] = "Mbit/s"; - $field['options']['option'][] = $opts; - $opts = array(); - $opts['value'] = "Gb"; - $opts['name'] = "Gbit/s"; - $field['options']['option'][] = $opts; - $field['bindstofield'] = "ezshaper->step2->conn{$i}uploadspeed"; - $fields[] = $field; - - $field = array(); - $field['name'] = "conn{$i}download"; - $field['type'] = "input"; - $field['bindstofield'] = "ezshaper->step2->conn{$i}download"; - $field['combinefieldsbegin'] = "true"; - $fields[] = $field; - - $field = array(); - $field['combinefieldsend'] = "true"; - $field['dontdisplayname'] = "true"; - $field['dontcombinecells'] = "true"; - $field['name'] = "conn{$i}downloadspeed"; - $field['typehint'] = "Download bandwidth on this connection."; - $field['type'] = "select"; - $field['options']['option'] = array(); - $opts = array(); - $opts['value'] = "Kb"; - $opts['name'] = "Kbit/s"; - $field['options']['option'][] = $opts; - $opts = array(); - $opts['value'] = "Mb"; - $opts['name'] = "Mbit/s"; - $field['options']['option'][] = $opts; - $opts = array(); - $opts['value'] = "Gb"; - $opts['name'] = "Gbit/s"; - $field['options']['option'][] = $opts; - $field['bindstofield'] = "ezshaper->step2->conn{$i}downloadspeed"; - $fields[] = $field; + $field = array(); + $field['displayname'] = "Interface & Scheduler"; + $field['name'] = "conn{$i}interface"; + $field['type'] = "select"; + $interface_real = $i+1; + $field['options']['option'] = array(); + foreach ($iflist as $ifname => $ifdescr) { + $opts = array(); + $opts['displayname'] = $ifdescr; + $opts['name'] = $ifname; + $opts['value'] = $ifname; + $field['options']['option'][] = $opts; } + $field['bindstofield'] = "ezshaper->step2->conn{$i}interface"; + $field['combinefieldsbegin'] = "true"; + $fields[] = $field; + + $field = array(); + $field['combinefieldsend'] = "true"; + $field['dontdisplayname'] = "true"; + $field['dontcombinecells'] = "true"; + $field['name'] = "conn{$i}uploadscheduler"; + $field['type'] = "select"; + $field['typehint'] = "Queueing discipline to apply on the upload of this connection."; + $field['options']['option'] = array(); + $opts = array(); + $opts['name'] = "HFSC"; + $opts['value'] = "HFSC"; + $field['options']['option'][] = $opts; + $opts = array(); + $opts['name'] = "CBQ"; + $opts['value'] = "CBQ"; + $field['options']['option'][] = $opts; + $opts = array(); + $opts['name'] = "PRIQ"; + $opts['value'] = "PRIQ"; + $field['options']['option'][] = $opts; + $field['bindstofield'] = "ezshaper->step2->conn{$i}uploadscheduler"; + $fields[] = $field; + + $field = array(); + $field['displayname'] = "Upload"; + $field['name'] = "conn{$i}upload"; + $field['type'] = "input"; + $field['bindstofield'] = "ezshaper->step2->conn{$i}upload"; + $field['combinefieldsbegin'] = "true"; + $fields[] = $field; + + $field = array(); + $field['combinefieldsend'] = "true"; + $field['dontdisplayname'] = "true"; + $field['dontcombinecells'] = "true"; + $field['name'] = "conn{$i}uploadspeed"; + $field['typehint'] = "Upload bandwidth on this connection."; + $field['type'] = "select"; + $field['options']['option'] = array(); + $opts = array(); + $opts['value'] = "Kb"; + $opts['name'] = "Kbit/s"; + $field['options']['option'][] = $opts; + $opts = array(); + $opts['value'] = "Mb"; + $opts['name'] = "Mbit/s"; + $field['options']['option'][] = $opts; + $opts = array(); + $opts['value'] = "Gb"; + $opts['name'] = "Gbit/s"; + $field['options']['option'][] = $opts; + $field['bindstofield'] = "ezshaper->step2->conn{$i}uploadspeed"; + $fields[] = $field; + + $field = array(); + $field['displayname'] = "Download"; + $field['name'] = "conn{$i}download"; + $field['type'] = "input"; + $field['bindstofield'] = "ezshaper->step2->conn{$i}download"; + $field['combinefieldsbegin'] = "true"; + $fields[] = $field; + $field = array(); - $field['name'] = "Next"; - $field['type'] = "submit"; + $field['combinefieldsend'] = "true"; + $field['dontdisplayname'] = "true"; + $field['dontcombinecells'] = "true"; + $field['name'] = "conn{$i}downloadspeed"; + $field['typehint'] = "Download bandwidth on this connection."; + $field['type'] = "select"; + $field['options']['option'] = array(); + $opts = array(); + $opts['value'] = "Kb"; + $opts['name'] = "Kbit/s"; + $field['options']['option'][] = $opts; + $opts = array(); + $opts['value'] = "Mb"; + $opts['name'] = "Mbit/s"; + $field['options']['option'][] = $opts; + $opts = array(); + $opts['value'] = "Gb"; + $opts['name'] = "Gbit/s"; + $field['options']['option'][] = $opts; + $field['bindstofield'] = "ezshaper->step2->conn{$i}downloadspeed"; $fields[] = $field; + } + $field = array(); + $field['name'] = "Next"; + $field['type'] = "submit"; + $fields[] = $field; } function step2_stepsubmitphpaction() { global $config; + global $stepid, $savemsg; $sumdownloads = 0; - + /* Input Validation */ $steps = intval($config['ezshaper']['step1']['numberofconnections']); $localint = intval($config['ezshaper']['step1']['numberoflocalinterfaces']); for ($i = 0; $i < $steps; $i++) { - for ($j = $i + 1; $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_multi_all.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_multi_all.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_multi_all.xml&stepid=1&message={$message}"); - exit; - } - $upbw = $_POST["conn{$i}upload"]; - $downbw = $_POST["conn{$i}download"]; - if ($upbw == 0 || $downbw = 0) { - $message = gettext("You cannot specify 0 bandwidth!") -; - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=1&message -={$message}"); - exit; - } - if (intval($upbw) < 128 && $_POST["conn{$i}uploadspeed"] == "Kb" && trim($_POST["conn{$i}scheduler"]) == "CBQ") { - $message=gettext("Uploads smaller than 128Kbit/s is not supported for connection {$i} on CBQ scheduler."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=1&message={$message}"); - exit; - } + for ($j = $i + 1; $j < $steps; $j++) { + if ($_POST["conn{$i}interface"] == $_POST["conn{$j}interface"]) { + $savemsg=gettext("You cannot select the same interface for connections {$i} and {$j}."); + $stepid--; + return; } - for ($j = 0; $j < $localint; $j++) { - if ($_POST["conn{$i}interface"] == $_POST["local{$j}interface"]) { - $message=gettext("You cannot select the same interface for local and outside."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=1&message={$message}"); - exit; - } + if (!is_numeric($_POST["conn{$i}upload"])) { + $savemsg = gettext("Upload bandwidth of connection {$i} is not valid."); + $stepid--; + return; + } + if (!is_numeric($_POST["conn{$i}download"])) { + $savemsg = gettext("Download bandwidth of connection {$i} is not valid."); + $stepid--; + return; + } + $upbw = $_POST["conn{$i}upload"]; + $downbw = $_POST["conn{$i}download"]; + if ($upbw < 1 || $downbw < 1) { + $savemsg = gettext("You cannot specify 0 bandwidth!"); + $stepid--; + return; + } + if (intval($upbw) < 128 && $_POST["conn{$i}uploadspeed"] == "Kb" && trim($_POST["conn{$i}scheduler"]) == "CBQ") { + $savemsg=gettext("Uploads smaller than 128Kbit/s is not supported for connection {$i} on CBQ scheduler."); + $stepid--; + return; } - } + } + for ($j = 0; $j < $localint; $j++) { + if ($_POST["conn{$i}interface"] == $_POST["local{$j}interface"]) { + $savemsg=gettext("You cannot select the same interface for local and outside."); + $stepid--; + return; + } + } + } for ($i = 0; $i < $localint; $i++) { for ($j = $i + 1; $j < $localint; $j++) { - if ($_POST["local{$i}interface"] == $_POST["local{$j}interface"]) { - $message=gettext("You cannot select the same interface twice on local interfaces."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=1&message={$message}"); - exit; - } + if ($_POST["local{$i}interface"] == $_POST["local{$j}interface"]) { + $savemsg=gettext("You cannot select the same interface twice on local interfaces."); + $stepid--; + return; + } } } - /* This is necessary since the wizard expects pecnefined fields. */ unset($config['ezshaper']['step2']); $config['ezshaper']['step2'] = array(); @@ -326,154 +318,175 @@ function step2_stepsubmitphpaction() { $config['ezshaper']['step2']["conn{$i}download"] = $_POST["conn{$i}download"]; $config['ezshaper']['step2']["conn{$i}downloadspeed"] = $_POST["conn{$i}downloadspeed"]; $config['ezshaper']['step2']["conn${i}interface"] = $_POST["conn{$i}interface"]; - } - + } } function step3_stepbeforeformdisplay() { global $config, $pkg; + global $stepid, $savemsg; + + $cfgname = "traffic_shaper_wizard_multi_all.xml"; + + $numberofconnections = intval($config['ezshaper']['step1']['numberofconnections']); + $numberoflocalinterfaces = intval($config['ezshaper']['step1']['numberoflocalinterfaces']); + + $fields =& $pkg['step'][1]['fields']['field']; + + $voipfields =& $pkg['step'][2]['fields']['field']; + + $voipfields = array(); + $enablefields = array(); + + $field = array(); + $field['name'] = "enable"; + $field['type'] = "checkbox"; + $field['typehint'] = "Prioritize Voice over IP traffic."; + $field['bindstofield'] = "ezshaper->step3->enable"; + $field['descritpion'] = "This will raise the priority of VOIP traffic above all other traffic."; + $voipfields[] = $field; + + $field = array(); + $field['name'] = "Next"; + $field['type'] = "submit"; + $voipfields[] = $field; + + $field = array(); + $field['name'] = "VOIP specific settings"; + $field['type'] = "listtopic"; + $voipfields[] = $field; + + $field['name'] = "Provider"; + $enablefields[] = "Provider"; + $field['type'] = "select"; + $field['description'] = "Choose Generic if your provider isn't listed."; + $field['options']['option'] = array(); + $opts = array(); + $opts['name'] = "Generic (lowdelay)"; + $opts['value'] = "Generic"; + $field['options']['option'][] = $opts; + $opts = array(); + $opts['name'] = "VoicePulse"; + $opts['value'] = "VoicePulse"; + $field['options']['option'][] = $opts; + $opts = array(); + $opts['name'] = "Asterisk/Vonage"; + $opts['value'] = "Asterisk"; + $field['options']['option'][] = $opts; + $opts = array(); + $opts['name'] = "PanasonicTDA"; + $opts['value'] = "Panasonic"; + $field['options']['option'][] = $opts; + $field['bindstofield'] = "ezshaper->step3->provider"; + $voipfields[] = $field; + + $field = array(); + $field['name'] = "Address"; + $enablefields[] = "Address"; + $field['type'] = "inputalias"; + $field['description'] = "(Optional) If this is chosen, the provider field will be overridden. This allows you to just provide the IP address of the VOIP adaptor to prioritize. NOTE: You can also use a Firewall Alias in this location."; + $field['message'] = "IP Address field is non-blank and doesn't look like an IP address."; + $field['bindstofield'] = "ezshaper->step3->address"; + $voipfields[] = $field; + + for ($i = 0; $i < $numberofconnections; $i++) { + $field = array(); + $interface_friendly = $i+1; + $field['name'] = "Connection WAN #{$interface_friendly}"; + $field['type'] = "listtopic"; + $voipfields[] = $field; - $cfgname = "traffic_shaper_wizard_multi_all.xml"; + $field = array(); + $field['displayname'] = "Upload"; + $field['name'] = "conn{$i}upload"; + $enablefields[] = "conn{$i}upload"; + $field['type'] = "input"; + $field['bindstofield'] = "ezshaper->step3->conn{$i}upload"; + $field['combinefieldsbegin'] = "true"; + $voipfields[] = $field; - $numberofconnections = intval($config['ezshaper']['step1']['numberofconnections']); - $numberoflocalinterfaces = intval($config['ezshaper']['step1']['numberoflocalinterfaces']); + $field = array(); + $field['combinefieldsend'] = "true"; + $field['dontdisplayname'] = "true"; + $field['dontcombinecells'] = "true"; + $field['name'] = "conn{$i}uploadspeed"; + $enablefields[] = "conn{$i}uploadspeed"; + $field['typehint'] = "Upload bandwidth guarantee for VOIP phone(s) on connection {$i}."; + $field['type'] = "select"; + $field['options']['option'] = array(); + $opts = array(); + $opts['value'] = "Kb"; + $opts['name'] = "Kbit/s"; + $field['options']['option'][] = $opts; + $opts = array(); + $opts['value'] = "Mb"; + $opts['name'] = "Mbit/s"; + $field['options']['option'][] = $opts; + $opts = array(); + $opts['value'] = "Gb"; + $opts['name'] = "Gbit/s"; + $field['options']['option'][] = $opts; + $field['bindstofield'] = "ezshaper->step3->conn{$i}uploadspeed"; + $voipfields[] = $field; + } - $fields =& $pkg['step'][1]['fields']['field']; - - $voipfields =& $pkg['step'][2]['fields']['field']; - - $voipfields = array(); - - $field = array(); - $field['name'] = "enable"; - $field['type'] = "checkbox"; - $field['typehint'] = "Prioritize Voice over IP traffic."; - $field['bindstofield'] = "ezshaper->step3->enable"; - $field['descritpion'] = "This will raise the priority of VOIP traffic above all other traffic."; - $voipfields[] = $field; - - $field = array(); - $field['name'] = "Next"; - $field['type'] = "submit"; - $voipfields[] = $field; - - $field = array(); - $field['name'] = "VOIP specific settings"; - $field['type'] = "listtopic"; - $voipfields[] = $field; - - $field['name'] = "Provider"; - $field['type'] = "select"; - $field['description'] = "Choose Generic if your provider isn't listed."; - $field['options']['option'] = array(); - $opts = array(); - $opts['name'] = "Generic (lowdelay)"; - $opts['value'] = "Generic"; - $field['options']['option'][] = $opts; - $opts = array(); - $opts['name'] = "VoicePulse"; - $opts['value'] = "VoicePulse"; - $field['options']['option'][] = $opts; - $opts = array(); - $opts['name'] = "Asterisk/Vonage"; - $opts['value'] = "Asterisk"; - $field['options']['option'][] = $opts; - $opts = array(); - $opts['name'] = "PanasonicTDA"; - $opts['value'] = "Panasonic"; - $field['options']['option'][] = $opts; - $field['bindstofield'] = "ezshaper->step3->provider"; - $voipfields[] = $field; - - $field = array(); - $field['name'] = "Address"; - $field['type'] = "inputalias"; - $field['description'] = "(Optional) If this is chosen, the provider field will be overridden. This allows you to just provide the IP address of the VOIP adaptor to prioritize. NOTE: You can also use a Firewall Alias in this location."; - $field['message'] = "IP Address field is non-blank and doesn't look like an IP address."; - $field['bindstofield'] = "ezshaper->step3->address"; - $voipfields[] = $field; - - for ($i = 0; $i < $numberofconnections; $i++) { - $field = array(); - $field['name'] = "conn{$i}upload"; - $field['type'] = "input"; - $field['bindstofield'] = "ezshaper->step3->conn{$i}upload"; - $field['combinefieldsbegin'] = "true"; - $voipfields[] = $field; - - $field = array(); - $field['combinefieldsend'] = "true"; - $field['dontdisplayname'] = "true"; - $field['dontcombinecells'] = "true"; - $field['name'] = "conn{$i}uploadspeed"; - $field['typehint'] = "Upload bandwidth guarantee for VOIP phone(s) on connection {$i}."; - $field['type'] = "select"; - $field['options']['option'] = array(); - $opts = array(); - $opts['value'] = "Kb"; - $opts['name'] = "Kbit/s"; - $field['options']['option'][] = $opts; - $opts = array(); - $opts['value'] = "Mb"; - $opts['name'] = "Mbit/s"; - $field['options']['option'][] = $opts; - $opts = array(); - $opts['value'] = "Gb"; - $opts['name'] = "Gbit/s"; - $field['options']['option'][] = $opts; - $field['bindstofield'] = "ezshaper->step3->conn{$i}uploadspeed"; - $voipfields[] = $field; - } + for ($i = 0; $i < $numberoflocalinterfaces; $i++) { + $field = array(); + $interface_friendly = $i+1; + $field['name'] = "Connection LAN #{$interface_friendly}"; + $field['type'] = "listtopic"; + $voipfields[] = $field; - for ($i = 0; $i < $numberoflocalinterfaces; $i++) { - $field = array(); - $field['name'] = "local{$i}download"; - $field['type'] = "input"; - $field['bindstofield'] = "ezshaper->step3->local{$i}download"; - $field['combinefieldsbegin'] = "true"; - $voipfields[] = $field; - - $field = array(); - $field['combinefieldsend'] = "true"; - $field['dontdisplayname'] = "true"; - $field['dontcombinecells'] = "true"; - $field['name'] = "local{$i}downloadspeed"; - $field['typehint'] = "Download bandwidth guarantee for VOIP phone(s) on connections."; - $field['type'] = "select"; - $field['options']['option'] = array(); - $opts = array(); - $opts['value'] = "Kb"; - $opts['name'] = "Kbit/s"; - $field['options']['option'][] = $opts; - $opts = array(); - $opts['value'] = "Mb"; - $opts['name'] = "Mbit/s"; - $field['options']['option'][] = $opts; - $opts = array(); - $opts['value'] = "Gb"; - $opts['name'] = "Gbit/s"; - $field['options']['option'][] = $opts; - $field['bindstofield'] = "ezshaper->step3->local{$i}downloadspeed"; - $voipfields[] = $field; - } + $field = array(); + $field['displayname'] = "Download"; + $field['name'] = "local{$i}download"; + $enablefields[] = "local{$i}download"; + $field['type'] = "input"; + $field['bindstofield'] = "ezshaper->step3->local{$i}download"; + $field['combinefieldsbegin'] = "true"; + $voipfields[] = $field; + + $field = array(); + $field['combinefieldsend'] = "true"; + $field['dontdisplayname'] = "true"; + $field['dontcombinecells'] = "true"; + $field['name'] = "local{$i}downloadspeed"; + $enablefields[] = "local{$i}downloadspeed"; + $field['typehint'] = "Download bandwidth guarantee for VOIP phone(s) on connections."; + $field['type'] = "select"; + $field['options']['option'] = array(); + $opts = array(); + $opts['value'] = "Kb"; + $opts['name'] = "Kbit/s"; + $field['options']['option'][] = $opts; + $opts = array(); + $opts['value'] = "Mb"; + $opts['name'] = "Mbit/s"; + $field['options']['option'][] = $opts; + $opts = array(); + $opts['value'] = "Gb"; + $opts['name'] = "Gbit/s"; + $field['options']['option'][] = $opts; + $field['bindstofield'] = "ezshaper->step3->local{$i}downloadspeed"; + $voipfields[] = $field; + } - $field = array(); - $field['name'] = "Next"; - $field['type'] = "submit"; + $field = array(); + $field['name'] = "Next"; + $field['type'] = "submit"; $voipfields[] = $field; + $voipfields[0]['enablefields'] = implode(",", $enablefields); } function step3_stepsubmitphpaction() { global $config; + global $stepid, $savemsg; if($_POST['address']) { - if(!is_ipaddr($_POST['address'])) { - 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_multi_all.xml&stepid=2&message={$message}"); - exit; - } + if(!is_ipaddroralias($_POST['address'])) { + /* item is not an ip or alias. error out */ + $savemsg=gettext("Address must be a valid IP address or Firewall Alias. Please correct this value to continue."); + $stepid--; + return; } } @@ -481,18 +494,18 @@ function step3_stepsubmitphpaction() { for ($i = 0; $i < $steps; $i++) { if ($_POST["conn{$i}upload"]) { 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_multi_all.xml&stepid=2&message={$message}"); - exit; - } + $savemsg = gettext("Upload bandwidth of connection {$i} is not valid."); + $stepid--; + return; + } $factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}uploadspeed"]); $ifbw = $factor * floatval($config['ezshaper']['step2']["conn{$i}upload"]); $factor = wizard_get_bandwidthtype_scale($_POST["conn{$i}uploadspeed"]); $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_multi_all.xml&stepid=2&message={$message}"); - exit; + $savemsg=gettext("You cannot set the VoIP upload bandwidth on connection {$i} higher than 80% of the connection."); + $stepid--; + return; } } } @@ -501,23 +514,22 @@ function step3_stepsubmitphpaction() { for ($i = 0; $i < $localint; $i++) { if ($_POST["local{$i}download"]) { if (!is_numeric($_POST["local{$i}download"])) { - $message = gettext("Download bandwidth of connection {$i} is not valid."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=2&message={$message}"); - exit; - } + $savemsg = gettext("Download bandwidth of connection {$i} is not valid."); + $stepid--; + return; + } $factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}downloadspeed"]); $ifbw = $factor * floatval($config['ezshaper']['step2']["conn{$i}download"]); $factor = wizard_get_bandwidthtype_scale($_POST["local{$i}downloadspeed"]); $input_bw = $factor * floatval($_POST["local{$i}download"]); if ((0.8 * $ifbw) < $input_bw) { - $message=gettext("You cannot set the VoIP download bandwidth on connection {$i} higher than 80% of the connection."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=2&message={$message}"); - exit; + $savemsg=gettext("You cannot set the VoIP download bandwidth on connection {$i} higher than 80% of the connection."); + $stepid--; + return; } } } - for ($i = 0; $i < $localint; $i++) { $config['ezshaper']['step3']["local{$i}download"] = $_POST["local{$i}download"]; $config['ezshaper']['step3']["local{$i}downloadspeed"] = $_POST["local{$i}downloadspeed"]; @@ -530,60 +542,57 @@ function step3_stepsubmitphpaction() { } function step4_stepsubmitphpaction() { - global $config; - - if ( $_POST['enable'] ) { - if(!$_POST['bandwidth']) { - $message="You need to specify a value for bandwidth!"; - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_all.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_multi_all.xml&stepid=3&message={$message}"); - exit; - } - - if ($_POST['bandwidthspeed'] <> "%") { - $message = gettext("Only percentage bandwidth specification is allowed."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=3&message={$message}"); - exit; - } - $bw = $_POST['bandwidth']; - if($bw > 15 && $bw < 2) { - $message="Values should be between 2% and 15%!"; - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=3&message={$message}"); - exit; - } + global $config; + global $stepid, $savemsg; - if($_POST['address'] <> "" && !is_ipaddr($_POST['address'])) { - 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_multi_all.xml&stepid=3&message={$message}"); - } - } + if ( $_POST['enable'] ) { + if(!$_POST['bandwidth']) { + $savemsg="You need to specify a value for bandwidth!"; + $stepid--; + return; } - + if(!is_numeric($_POST['bandwidth'])) { + $savemsg="The posted value is not a valid bandwidth."; + $stepid--; + return; + } + if ($_POST['bandwidthspeed'] <> "%") { + $savemsg = gettext("Only percentage bandwidth specification is allowed."); + $stepid--; + return; + } + $bw = $_POST['bandwidth']; + if($bw > 15 && $bw < 2) { + $savemsg="Values should be between 2% and 15%!"; + $stepid--; + return; + } + if($_POST['address'] <> "" && !is_ipaddroralias($_POST['address'])) { + /* item is not an ip or alias. error out */ + $savemsg=gettext("Address must be a valid IP address or Firewall Alias. Please correct this value to continue."); + $stepid--; + } + } } function step5_stepsubmitphpaction() { + global $stepid, $savemsg; if ( $_POST['enable'] ) { 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_multi_all.xml&stepid=4&message={$message}"); + $savemsg="Posted value is not a valid bandwidth."; + $stepid--; } if ($_POST['bandwidthspeed'] <> "%") { - $message = gettext("Only percentage bandwidth specification is allowed."); - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=4&message={$message}"); - exit; + $savemsg = gettext("Only percentage bandwidth specification is allowed."); + $stepid--; + return; } $bw = $_POST['bandwidth']; if($bw > 15 && $bw < 2) { - $message="Values should be between 2% and 15%!"; - header("Location: wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=3&message={$message}"); - exit; + $savemsg="Values should be between 2% and 15%!"; + $stepid--; + return; } } } @@ -1051,9 +1060,9 @@ $othersplist = array(); $remainbw = round($remainbw / $upbw * 100, 2); if (intval($remainbw) > 0 && intval($remainbw) > 30) { - $message=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue."); + $savemsg=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue."); header("Location: wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=2&message={$message}"); - exit; + return; } else { $remainbw = 100 - $remainbw; } @@ -1466,9 +1475,9 @@ $othersplist = array(); $remainbw = round($remainbw / $lanbw * 100, 2); if (intval($remainbw) > 0 && intval($remainbw) > 40) { - $message=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue."); + $savemsg=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue."); header("Location: wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=2&message={$message}"); - exit; + return; } else { $remainbw = 100 - $remainbw; } diff --git a/usr/local/www/wizards/traffic_shaper_wizard_multi_all.xml b/usr/local/www/wizards/traffic_shaper_wizard_multi_all.xml index 6bac859..5a9f1a8 100755 --- a/usr/local/www/wizards/traffic_shaper_wizard_multi_all.xml +++ b/usr/local/www/wizards/traffic_shaper_wizard_multi_all.xml @@ -160,7 +160,7 @@ checkbox Penalize IP or Alias This will lower the priority of traffic from this IP or alias. - Address,Bandwidth + Address,Bandwidth,BandwidthSpeed ezshaper->step4->enable @@ -173,7 +173,7 @@ Address - input + inputalias This allows you to just provide the IP address of the computer(s) or Penalize. NOTE: You can also use a Firewall Alias in this location. ezshaper->step4->address IP Address field is non-blank and doesn't look like an IP address. 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 19528c8..c8ec0f1 100644 --- a/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc +++ b/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc @@ -191,6 +191,7 @@ function step2_stepbeforeformdisplay() { $field['bindstofield'] = "ezshaper->step2->conn{$i}interface"; $fields[] = $field; + $field = array(); $field['name'] = "conn{$i}downloadscheduler"; $field['displayname'] = "LAN Scheduler"; $field['type'] = "select"; -- cgit v1.1