diff options
author | gnhb <gnoahb@gmail.com> | 2010-05-11 15:41:01 +0700 |
---|---|---|
committer | gnhb <gnoahb@gmail.com> | 2010-05-11 15:41:01 +0700 |
commit | 0810c115f42151234545be2560feea97f4c3efec (patch) | |
tree | 40280d93d877870f7de37fea8c4c64eec6b6f08c /usr/local/www | |
parent | 766bd6d083d1ad15d5a285901eb172181c7eb216 (diff) | |
download | pfsense-0810c115f42151234545be2560feea97f4c3efec.zip pfsense-0810c115f42151234545be2560feea97f4c3efec.tar.gz |
Fix up final bits of PPPoE Periodic reset and disable setting of bandwidths for mlppp links for now.
Diffstat (limited to 'usr/local/www')
-rw-r--r-- | usr/local/www/interfaces_ppps_edit.php | 79 | ||||
-rw-r--r-- | usr/local/www/javascript/interfaces_ppps_edit/ppps_edit.js | 47 |
2 files changed, 72 insertions, 54 deletions
diff --git a/usr/local/www/interfaces_ppps_edit.php b/usr/local/www/interfaces_ppps_edit.php index 91da56d..bacded9 100644 --- a/usr/local/www/interfaces_ppps_edit.php +++ b/usr/local/www/interfaces_ppps_edit.php @@ -49,19 +49,12 @@ define("CRON_WEEKLY_PATTERN", "0 0 * * 0"); define("CRON_DAILY_PATTERN", "0 0 * * *"); define("CRON_HOURLY_PATTERN", "0 * * * *"); -if (!is_array($config['ppps']['ppp'])) - $config['ppps']['ppp'] = array(); - -$a_ppps = &$config['ppps']['ppp']; - -$portlist = get_interface_list(); - -function getMPDCRONSettings() { +function getMPDCRONSettings($ptpid_) { global $config; if (is_array($config['cron']['item'])) { for ($i = 0; $i < count($config['cron']['item']); $i++) { $item = $config['cron']['item'][$i]; - if (strpos($item['command'], CRON_PPPOE_CMD_FILE.$_POST['ptpid']) !== false) { + if (strpos($item['command'], CRON_PPPOE_CMD_FILE.$ptpid_) !== false) { return array("ID" => $i, "ITEM" => $item); } } @@ -69,15 +62,12 @@ function getMPDCRONSettings() { return NULL; } -function getMPDResetTimeFromConfig() { - $itemhash = getMPDCRONSettings(); - $cronitem = $itemhash['ITEM']; - if (isset($cronitem)) { - return "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}"; - } else { - return NULL; - } -} +if (!is_array($config['ppps']['ppp'])) + $config['ppps']['ppp'] = array(); + +$a_ppps = &$config['ppps']['ppp']; + +$portlist = get_interface_list(); $id = $_GET['id']; if (isset($_POST['id'])) @@ -134,8 +124,14 @@ if (isset($id) && $a_ppps[$id]) { if (isset($a_ppps[$id]['pppoe-reset-type'])) { $pconfig['pppoe-reset-type'] = $a_ppps[$id]['pppoe-reset-type']; - - $resetTime = getMPDResetTimeFromConfig(); + $itemhash = getMPDCRONSettings($a_ppps[$id]['ptpid']); + $cronitem = $itemhash['ITEM']; + if (isset($cronitem)) { + $resetTime = "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}"; + } else { + $resetTime = NULL; + } + if ($a_ppps[$id]['pppoe-reset-type'] == "custom") { $resetTime_a = split(" ", $resetTime); $pconfig['pppoe_pr_custom'] = true; @@ -351,15 +347,36 @@ if ($_POST) { $ppp['protocomp'] = $_POST['protocomp'] ? true : false; $ppp['vjcomp'] = $_POST['vjcomp'] ? true : false; $ppp['tcpmssfix'] = $_POST['tcpmssfix'] ? true : false; - if (isset($_POST['bandwidth']) && count($_POST['bandwidth'])) + + while(count($_POST['bandwidth'])){ + if($_POST['bandwidth'][count($_POST['bandwidth'])-1] == "") + array_pop(&$_POST['bandwidth']); + else + break; + } + if (!empty($_POST['bandwidth']) && count($_POST['bandwidth'])) $ppp['bandwidth'] = implode(',', $_POST['bandwidth']); else unset($ppp['bandwidth']); - if (isset($_POST['mtu']) && count($_POST['mtu'])) + + while(count($_POST['mtu'])){ + if($_POST['mtu'][count($_POST['mtu'])-1] == "") + array_pop(&$_POST['mtu']); + else + break; + } + if (!empty($_POST['mtu']) && count($_POST['mtu'])) $ppp['mtu'] = implode(',', $_POST['mtu']); else unset($ppp['mtu']); - if (isset($_POST['mru']) && count($_POST['mru'])) + + while(count($_POST['mru'])){ + if($_POST['mru'][count($_POST['mru'])-1] == "") + array_pop(&$_POST['mru']); + else + break; + } + if (!empty($_POST['mru']) && count($_POST['mru'])) $ppp['mru'] = implode(',', $_POST['mru']); else unset($ppp['mru']); @@ -395,7 +412,7 @@ function handle_pppoe_reset() { if (!is_array($config['cron']['item'])) $config['cron']['item'] = array(); - $itemhash = getMPDCRONSettings(); + $itemhash = getMPDCRONSettings($_POST['ptpid']); $item = $itemhash['ITEM']; /* reset cron items if necessary and return*/ @@ -472,7 +489,7 @@ $closehead = false; $pgtitle = array("Interfaces","PPPs","Edit"); include("head.inc"); -$types = array("select" => "Select", "ppp" => "PPP", "pppoe" => "PPPoE", "pptp" => "PPTP", "l2tp" => "L2TP"/*, "tcp" => "TCP", "udp" => "UDP"*/ ); +$types = array("select" => "Select", "ppp" => "PPP", "pppoe" => "PPPoE", "pptp" => "PPTP"/*, "l2tp" => "L2TP", "tcp" => "TCP", "udp" => "UDP"*/ ); ?> <script type="text/javascript" > @@ -505,10 +522,10 @@ $types = array("select" => "Select", "ppp" => "PPP", "pppoe" => "PPPoE", "pptp" <tr name="interface" id="interface" > <td width="22%" valign="top" class="vncellreq"><?= gettext("Link interface(s)"); ?></td> <td width="78%" class="vtable"> - <select valign="top" name="interfaces[]" multiple="true" class="formselect" size="4" onChange="show_hide_linkfields();"> + <select valign="top" name="interfaces[]" multiple="true" class="formselect" size="4" <! onChange="show_hide_linkfields(this.options);" -->> <option></option> </select> - <a href='#' onClick='javascript:clear_selected("interfaces[]");'><?= gettext("Click here"); ?></a> <?= gettext("to clear selection(s)."); ?> + <br/><span class="vexpl"><?= gettext("Interfaces or ports participating in the multilink connection."); ?></span> <span style="display:none" id="prefil_ppp"> <p/><?= gettext("Click a link to fill in defaults for these carriers:"); ?> @@ -548,6 +565,8 @@ $types = array("select" => "Select", "ppp" => "PPP", "pppoe" => "PPPoE", "pptp" echo ",|"; } echo $port_count; + if($serport_count > $port_count) + $port_count=$serport_count; ?></td> </tr> <tr> @@ -681,7 +700,9 @@ $types = array("select" => "Select", "ppp" => "PPP", "pppoe" => "PPPoE", "pptp" <td align="left" valign="top"> <p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;"> <select valign="top" id="reset_type" name="pppoe-reset-type" class="formselect" onChange="show_reset_settings(this.value);"> - <option value = ""><?= gettext("Disabled"); ?></option><option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected"; ?>><?= gettext("Custom"); ?></option><option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected"; ?>><?= gettext("Pre-set"); ?></option> + <option value = ""><?= gettext("Disabled"); ?></option> + <option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected"; ?>><?= gettext("Custom"); ?></option> + <option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected"; ?>><?= gettext("Pre-Set"); ?></option> </select> <?= gettext("Select a reset timing type"); ?> </p> <?php if ($pconfig['pppoe_pr_custom']): ?> @@ -816,7 +837,7 @@ $types = array("select" => "Select", "ppp" => "PPP", "pppoe" => "PPPoE", "pptp" <td width="22%" valign="top" id="bandwidth<?=$i;?>" class="vncell"> Bandwidth</td> <td width="78%" class="vtable"> <br/><input name="bandwidth[]" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['bandwidth'][$i]);?>"> - <br/> <span class="vexpl">Set Bandwidth for each link ONLY when links have different bandwidths.</span> + <br/> <span class="vexpl">Set Bandwidth for each link ONLY for MLPPP connections and ONLY when links have different bandwidths.</span> </td> </tr> <tr> diff --git a/usr/local/www/javascript/interfaces_ppps_edit/ppps_edit.js b/usr/local/www/javascript/interfaces_ppps_edit/ppps_edit.js index 52bff7d..75ad1aa 100644 --- a/usr/local/www/javascript/interfaces_ppps_edit/ppps_edit.js +++ b/usr/local/www/javascript/interfaces_ppps_edit/ppps_edit.js @@ -1,19 +1,19 @@ function update_select_list(new_options, select_list){ var option_array = new_options.split("|"); - select_list.options.length = 0; + select_list.length = 0; for(var j=0; j < option_array.length-1; j++){ var option = option_array[j].split(","); var selected = Boolean(parseInt(option[2])); - select_list.options[j] = new Option(option[0], option[1], false, selected); - var linklabel = "linklabel" + j.toString(); - var label_text = $(linklabel).innerHTML; - $(linklabel).innerHTML = label_text + " (" + option[1] + ")"; + select_list[j] = new Option(option[0], option[1], false, selected); + var label = "linklabel" + j.toString(); + //var label_text = $(label).innerHTML; + $(label).innerHTML = "Link Parameters (" + option[1] + ")"; //for testing and debugging //select_list.options[option_array.length-1+j] = new Option(option[2].toString() +" "+ selected.toString()); //select_list.options[option_array.length-1+j] = new Option("Link Label: " + linklabel + " Label Text:" + label_text); } - show_hide_linkfields(); + //show_hide_linkfields(select_list); } function clear_selected(list_name){ @@ -23,27 +23,31 @@ function clear_selected(list_name){ } } -function show_hide_linkfields(){ - var select_list = document.iform["interfaces[]"].options; - for(var j=0; j < select_list.length; j++){ - var linklabel = "link" + j.toString(); - if (select_list[j].selected){ - $(linklabel).show(); - continue; - } - $(linklabel).hide(); +function show_hide_linkfields(options){ + var select_count = 0; + for(var j=0; j < options.length; j++){ + if (options[j].selected) + select_count++; + } + for(var j=0; j < options.length; j++){ + var label = "link" + j.toString(); + if (options[j].selected && select_count > 1){ + $(label).show(); + continue; } + $(label).hide(); + } } function updateType(t){ var serialports = $('serialports').innerHTML; var ports = $('ports').innerHTML; - var select_list = document.iform["interfaces[]"]; + var select_list = document.iform["interfaces[]"].options; switch(t) { case "select": { $('ppp','pppoe','pptp','ipfields','prefil_ppp').invoke('hide'); - select_list.options.length = 0; + select_list.length = 0; select_list.options[0] = new Option("Select Link Type First",""); break; } @@ -66,19 +70,12 @@ function updateType(t){ break; } default: - select_list.options.length = 0; + select_list.length = 0; break; } $(t).show(); } -function show_more_settings(checkbox_obj,element_id) { - if (checkbox_obj.checked) - $(element_id).show(); - else - $(element_id).hide(); -} - function show_reset_settings(reset_type) { if (reset_type == 'preset') { Effect.Appear('pppoepresetwrap', { duration: 0.0 }); |