Exemple #1
0
$section->addInput(new Form_Input('apn', 'Access Point Name', 'text', $pconfig['apn']));
function build_port_list()
{
    $list = array("" => "None");
    $portlist = glob("/dev/cua*");
    $modems = glob("/dev/modem*");
    $portlist = array_merge($portlist, $modems);
    foreach ($portlist as $port) {
        if (preg_match("/\\.(lock|init)\$/", $port)) {
            continue;
        }
        $list[trim($port)] = $port;
    }
    return $list;
}
$section->addInput(new Form_Select('port', "Modem port", $pconfig['port'], build_port_list()));
$section->addInput(new Form_Button('btnadvppp', 'Advanced PPP', isset($pconfig['pppid']) ? 'interfaces_ppps_edit.php?id=' . htmlspecialchars($pconfig['pppid']) : 'interfaces_ppps_edit.php'))->setHelp('Create a new PPP configuration');
$form->add($section);
// PPPoE configuration
$section = new Form_Section('PPPoE Configuration');
$section->addClass('pppoe');
$section->addInput(new Form_Input('pppoe_username', 'Username', 'text', $pconfig['pppoe_username']));
$section->addInput(new Form_Input('pppoe_password', 'Password', 'password', $pconfig['pppoe_password']));
$section->addInput(new Form_Input('provider', 'Service name', 'text', $pconfig['provider']))->setHelp('This field can usually be left empty');
$section->addInput(new Form_Checkbox('pppoe_dialondemand', 'Dial on demand', 'Enable Dial-On-Demand mode ', $pconfig['pppoe_dialondemand'], 'enable'));
$section->addInput(new Form_Input('pppoe_idletimeout', 'Idle timeout', 'number', $pconfig['pppoe_idletimeout'], [min => 0]))->setHelp('If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. ' . 'An idle timeout of zero disables this feature.');
$section->addInput(new Form_Select('pppoe-reset-type', 'Periodic reset', $pconfig['pppoe-reset-type'], ['' => 'Disabled', 'custom' => 'Custom', 'preset' => 'Pre-set']))->setHelp('Select a reset timing type');
$group = new Form_Group('Custom reset');
$group->addClass('pppoecustom');
$group->add(new Form_Input('pppoe_resethour', null, 'number', $pconfig['pppoe_resethour'], [min => 0, max => 23]))->setHelp('Hour (0-23)');
$group->add(new Form_Input('pppoe_resetminute', null, 'number', $pconfig['pppoe_resetminute'], [min => 0, max => 59]))->setHelp('Minutes (0-59)');
$section->addInput(new Form_Select('ptp', 'PTP Ports', $edgelist['selected'], $edgelist['list'], true))->setHelp('Set the interface as a point-to-point link. This is required for straight transitions to forwarding and should be enabled on a direct link to another RSTP-capable switch.');
$edgelist = build_port_list($pconfig['autoptp']);
$section->addInput(new Form_Select('autoptp', 'Auto PTP Ports', $edgelist['selected'], $edgelist['list'], true))->setHelp('Automatically detect the point-to-point status on interface by checking the full duplex link status. This is the default for interfaces added to the bridge.' . '%sThe interfaces selected here will be removed from default autoedge status. %s', ['<strong>', '</strong>']);
$edgelist = build_port_list($pconfig['static']);
$section->addInput(new Form_Select('static', 'Sticky Ports', $edgelist['selected'], $edgelist['list'], true))->setHelp('Mark an interface as a "sticky" interface. Dynamically learned address entries are treated as static once entered into the cache. ' . 'Sticky entries are never aged out of the cache or replaced, even if the address is seen on a different interface.');
$edgelist = build_port_list($pconfig['private']);
$section->addInput(new Form_Select('private', 'Private Ports', $edgelist['selected'], $edgelist['list'], true))->setHelp('Mark an interface as a "private" interface. A private interface does not forward any traffic to any other port that is also a private interface. ');
//	STP section
// ToDo: - Should disable spanning tree section when not checked
$section->addInput(new Form_Checkbox('enablestp', 'Enable RSTP/STP', null, $pconfig['enablestp']));
// Show the spanning tree section
$form->add($section);
$section = new Form_Section('RSTP/STP');
$section->addClass('adnlopts');
$section->addInput(new Form_Select('proto', 'Protocol', $pconfig['proto'], array('rstp' => 'RSTP', 'stp' => 'STP')))->setHelp('Protocol used for spanning tree.');
$edgelist = build_port_list($pconfig['stp']);
$section->addInput(new Form_Select('stp', 'STP Interfaces', $edgelist['selected'], $edgelist['list'], true))->setHelp('Enable Spanning Tree Protocol on interface. The if_bridge(4) driver has support for the IEEE 802.1D Spanning Tree Protocol (STP). ' . 'STP is used to detect and remove loops in a network topology.');
$section->addInput(new Form_Input('maxage', 'Valid time', 'number', $pconfig['maxage'], ['placeholder' => 20, 'min' => 6, 'max' => 40]))->setHelp('Set the time that a Spanning Tree Protocol configuration is valid. The default is 20 seconds. The minimum is 6 seconds and the maximum is 40 seconds.');
$section->addInput(new Form_Input('fwdelay', 'Forward time', 'number', $pconfig['fwdelay'], ['placeholder' => 15, 'min' => 4, 'max' => 30]))->setHelp('Set the time that must pass before an interface begins forwarding packets when Spanning Tree is enabled. The default is 15 seconds. The minimum is 4 seconds and the maximum is 30 seconds. ');
$section->addInput(new Form_Input('hellotime', 'Hello time', 'number', $pconfig['hellotime'], ['placeholder' => 2, 'min' => 1, 'max' => 2, 'step' => '0.1']))->setHelp('Set the time in seconds between broadcasting of Spanning Tree Protocol configuration messages. The hello time may only be changed when operating in legacy STP mode. ' . 'The default is 2 seconds. The minimum is 1 second and the maximum is 2 seconds.');
$section->addInput(new Form_Input('priority', 'Priority', 'number', $pconfig['priority'], ['placeholder' => 32768, 'min' => 0, 'max' => 61440]))->setHelp('Set the bridge priority for Spanning Tree. The default is 32768. The minimum is 0 and the maximum is 61440. ');
$section->addInput(new Form_Input('holdcnt', 'Hold Count', 'number', $pconfig['holdcnt'], ['placeholder' => 6, 'min' => 1, 'max' => 10]))->setHelp('Set the transmit hold count for Spanning Tree. This is the number of packets transmitted before being rate limited. The default is 6. The minimum is 1 and the maximum is 10.');
foreach ($ifacelist as $ifn => $ifdescr) {
    $section->addInput(new Form_Input($ifn, $ifdescr . ' Priority', 'number', $pconfig['ifpriority'][$ifn], ['placeholder' => 128, 'min' => 0, 'max' => 240, 'step' => 16]))->setHelp('Set the Spanning Tree priority of interface to value. The default is 128. The minimum is 0 and the maximum is 240. Increments of 16.');
}
$i = 0;
foreach ($ifacelist as $ifn => $ifdescr) {
    $section->addInput(new Form_Input($ifn . 0, $ifdescr . ' Path cost', 'number', $pconfig['ifpathcost'][$ifn], ['placeholder' => 0, 'min' => 1, 'max' => 200000000]))->setHelp('Set the Spanning Tree path cost of interface to value. The default is calculated from the link speed. ' . 'To change a previously selected path cost back to automatic, set the cost to 0. The minimum is 1 and the maximum is 200000000.');
    $i++;
}
$section->addInput(new Form_Input('bridgeif', null, 'hidden', $pconfig['bridgeif']));