diff options
Diffstat (limited to 'etc/inc/shaper.inc')
-rw-r--r-- | etc/inc/shaper.inc | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/etc/inc/shaper.inc b/etc/inc/shaper.inc index 36bf462..fbb1200 100644 --- a/etc/inc/shaper.inc +++ b/etc/inc/shaper.inc @@ -2790,6 +2790,8 @@ class dummynet_class { return $this->link; } function GetMask() { + if (!isset($this->mask["type"])) + $this->mask["type"] = "none"; return $this->mask; } function SetMask($mask) { @@ -2856,7 +2858,21 @@ class dummynet_class { $this->plr = $plr; } - function build_javascript() { return; } /* Do not remove */ + function build_javascript() { + $javascript .= "<script type=\"text/javascript\"> \n"; + $javascript .= "//<![CDATA[\n"; + $javascript .= "function enable_maskbits(enable_over) { \n"; + $javascript .= "var e = document.getElementById(\"mask\"); \n"; + $javascript .= "if ((e.options[e.selectedIndex].text == \"none\") || enable_over) { \n"; + $javascript .= "document.iform.maskbits.disabled = 1;\n"; + $javascript .= "document.iform.maskbits.value = \"\";\n"; + $javascript .= "} else \n"; + $javascript .= "document.iform.maskbits.disabled = 0;\n"; + $javascript .= "} \n"; + $javascript .= "//]]>\n"; + $javascript .= "</script>"; + return $javascript; + } function validate_input($data, &$input_errors) { $reqdfields[] = "bandwidth"; @@ -2880,7 +2896,7 @@ class dummynet_class { $input_errors[] = gettext("Queue names must be alphanumeric and _ or - only."); if (!empty($data['name']) && !preg_match("/^[a-zA-Z0-9_-]+$/", $data['name'])) $input_errors[] = gettext("Queue names must be alphanumeric and _ or - only."); - if (isset($data['maskbits']) && ($data['maskbits'] <> "")) { + if (isset($data['maskbits']) && ($data['maskbits'] <> "")) { if ((!is_numeric($data['maskbits'])) || ($data['maskbits'] <= 0) || ($data['maskbits'] > 32)) $input_errors[] = gettext("Bit mask must be blank or numeric value between 1 and 32."); } @@ -3039,7 +3055,7 @@ class dnpipe_class extends dummynet_class { $maskbits = $q['maskbits']; else $maskbits = ""; - $this->SetMask(array("type" => $masktype, "bits" => $maskbits)); + $this->SetMask(array("type" => $masktype, "bits" => $maskbits)); if (isset($q['buckets']) && $q['buckets'] <> "") $this->SetBuckets($q['buckets']); else @@ -3162,6 +3178,8 @@ class dnpipe_class extends dummynet_class { function build_javascript() { global $g, $config; + $javasr = parent::build_javascript(); + //build list of schedules $schedules = "<option value='none'>none</option>"; if (is_array($config['schedules']) && is_array($config['schedules']['schedule'])) { @@ -3174,7 +3192,7 @@ class dnpipe_class extends dummynet_class { foreach (array("Kb" => "Kbit/s", "Mb" => "Mbit/s", "Gb" => "Gbit/s", "b" => "Bit/s") as $bwidx => $bw) $bwopt .= "<option value='{$bwidx}'>{$bw}</option>"; - $javasr = <<<EOD + $javasr .= <<<EOD <script type='text/javascript'> //<![CDATA[ var addBwRowTo = (function() { @@ -3293,7 +3311,7 @@ EOD; $form .= "</td></tr>"; $form .= "<tr><td valign=\"middle\" class=\"vncellreq\">" . gettext("Mask") . "</td>"; $form .= "<td class=\"vncellreq\">"; - $form .= "<select name=\"mask\" class=\"formselect\">"; + $form .= "<select name=\"mask\" id=\"mask\" class=\"formselect\" onchange=\"enable_maskbits();\" >"; $form .= "<option value=\"none\""; $mask = $this->GetMask(); if ($mask['type'] == "none") @@ -3315,9 +3333,12 @@ EOD; . "respectively. This makes it possible to easily specify bandwidth \n" . "limits per host.") . "</span><br />"; $form .= "255.255.255.255/ <input type=\"text\" class=\"formfld unknown\" size=\"2\" id=\"maskbits\" name=\"maskbits\" value=\""; - $mask = $this->GetMask(); + if ($mask['type'] <> "none") $form .= $mask['bits']; - $form .= "\" />"; + $form .= "\""; + if ($mask['type'] == "none") + $form .= " disabled"; + $form .= " />"; $form .= " mask bits (1-32)<br/>"; $form .= "<span class=\"vexpl\">" . gettext("If 'source' or 'destination' slots is chosen, \n" . "leaving the mask bits blank will create one pipe per host. Otherwise specify \n" @@ -3476,7 +3497,6 @@ class dnqueue_class extends dummynet_class { $this->SetQlimit($q['qlimit']); else $this->SetQlimit(""); - $mask = array(); if (isset($q['mask']) && $q['mask'] <> "") $masktype = $q['mask']; else @@ -3485,7 +3505,7 @@ class dnqueue_class extends dummynet_class { $maskbits = $q['maskbits']; else $maskbits = ""; - $this->SetMask(array("type" => $masktype, "bits" => $maskbits)); + $this->SetMask(array("type" => $masktype, "bits" => $maskbits)); if (isset($q['weight']) && $q['weight'] <> "") $this->SetWeight($q['weight']); else @@ -3544,6 +3564,11 @@ class dnqueue_class extends dummynet_class { return $pfq_rule; } + function build_javascript() { + return parent::build_javascript(); + } + + function build_form() { $form = "<tr><td valign=\"middle\" class=\"vncellreq\"><br/>"; $form .= gettext("Enable/Disable"); @@ -3566,7 +3591,7 @@ class dnqueue_class extends dummynet_class { $form .= "</td></tr>"; $form .= "<tr><td valign=\"middle\" class=\"vncellreq\">" . gettext("Mask") . "</td>"; $form .= "<td class=\"vncellreq\">"; - $form .= "<select name=\"mask\" class=\"formselect\">"; + $form .= "<select name=\"mask\" id=\"mask\" class=\"formselect\" onchange=\"enable_maskbits();\" >"; $form .= "<option value=\"none\""; $mask = $this->GetMask(); if ($mask['type'] == "none") @@ -3588,9 +3613,12 @@ class dnqueue_class extends dummynet_class { . "respectively. This makes it possible to easily specify bandwidth \n" . "limits per host.") . "</span><br/>"; $form .= "255.255.255.255/ <input type=\"text\" class=\"formfld unknown\" size=\"2\" id=\"maskbits\" name=\"maskbits\" value=\""; - $mask = $this->GetMask(); + if ($mask['type'] <> "none") $form .= $mask['bits']; - $form .= "\" />"; + $form .= "\""; + if ($mask['type'] == "none") + $form .= " disabled"; + $form .= " />"; $form .= " mask bits (1-32)<br/>"; $form .= "<span class=\"vexpl\">" . gettext("If 'source' or 'destination' slots is chosen, \n" . "leaving the mask bits blank will create one pipe per host. Otherwise specify \n" |