Beispiel #1
0
         $input_errors[] = gettext("Secret and confirmation must match");
     }
     if ($_POST['radiussecret'] != $_POST['radiussecret_confirm']) {
         $input_errors[] = gettext("Secret and confirmation must match");
     }
     if (!is_numericint($_POST['n_l2tp_units']) || $_POST['n_l2tp_units'] > 255) {
         $input_errors[] = gettext("Number of L2TP users must be between 1 and 255");
     }
     /* if this is an AJAX caller then handle via JSON */
     if (isAjax() && is_array($input_errors)) {
         input_errors2Ajax($input_errors);
         exit;
     }
     if (!$input_errors) {
         $_POST['remoteip'] = $pconfig['remoteip'] = gen_subnet($_POST['remoteip'], $_POST['l2tp_subnet']);
         if (is_inrange_v4($_POST['localip'], $_POST['remoteip'], ip_after($_POST['remoteip'], $_POST['n_l2tp_units'] - 1))) {
             $input_errors[] = gettext("The specified server address lies in the remote subnet.");
         }
         if ($_POST['localip'] == get_interface_ip("lan")) {
             $input_errors[] = gettext("The specified server address is equal to the LAN interface address.");
         }
     }
 }
 /* if this is an AJAX caller then handle via JSON */
 if (isAjax() && is_array($input_errors)) {
     input_errors2Ajax($input_errors);
     exit;
 }
 if (!$input_errors) {
     $l2tpcfg['remoteip'] = $_POST['remoteip'];
     $l2tpcfg['localip'] = $_POST['localip'];
     $input_errors[] = gettext("A valid remote start address must be specified.");
 }
 if ($_POST['radiusserver'] && !is_ipaddr($_POST['radiusserver'])) {
     $input_errors[] = gettext("A valid RADIUS server address must be specified.");
 }
 if (!is_numericint($_POST['n_pppoe_units']) || $_POST['n_pppoe_units'] > 255) {
     $input_errors[] = gettext("Number of PPPoE users must be between 1 and 255");
 }
 if (!is_numericint($_POST['n_pppoe_maxlogin']) || $_POST['n_pppoe_maxlogin'] > 255) {
     $input_errors[] = gettext("User Max Logins must be between 1 and 255");
 }
 if (!is_numericint($_POST['pppoe_subnet']) || $_POST['pppoe_subnet'] > 32) {
     $input_errors[] = gettext("Subnet mask must be an interger between 0 and 32");
 }
 $_POST['remoteip'] = $pconfig['remoteip'] = gen_subnet($_POST['remoteip'], $_POST['pppoe_subnet']);
 if (is_inrange_v4($_POST['localip'], $_POST['remoteip'], ip_after($_POST['remoteip'], $_POST['pppoe_subnet'] - 1))) {
     $input_errors[] = gettext("The specified server address lies in the remote subnet.");
 }
 if ($_POST['localip'] == get_interface_ip($_POST['interface'])) {
     $input_errors[] = gettext("The specified server address is equal to an interface ip address.");
 }
 for ($x = 0; $x < 4999; $x++) {
     if ($_POST["username{$x}"]) {
         if (empty($_POST["password{$x}"])) {
             $input_errors[] = sprintf(gettext("No password specified for username %s"), $_POST["username{$x}"]);
         }
         if ($_POST["ip{$x}"] != "" && !is_ipaddr($_POST["ip{$x}"])) {
             $input_errors[] = sprintf(gettext("Incorrect ip address specified for username %s"), $_POST["username{$x}"]);
         }
     }
 }
$form = new Form();
$section = new Form_Section('General Options');
if (!is_numeric($pool) && !($act == "newpool")) {
    $section->addInput(new Form_Checkbox('enable', 'Enable', sprintf(gettext("Enable DHCP server on %s interface"), htmlspecialchars($iflist[$if])), $pconfig['enable']));
} else {
    print_info_box(gettext('Editing pool-specific options. To return to the Interface, click its tab above.'), 'info', false);
}
$section->addInput(new Form_Checkbox('denyunknown', 'Deny unknown clients', 'Only the clients defined below will get DHCP leases from this server.', $pconfig['denyunknown']));
$section->addInput(new Form_Checkbox('nonak', 'Ignore denied clients', 'Denied clients will be ignored rather than rejected.', $pconfig['nonak']))->setHelp("This option is not compatible with failover and cannot be enabled when a Failover Peer IP address is configured.");
if (is_numeric($pool) || $act == "newpool") {
    $section->addInput(new Form_Input('descr', 'Pool Description', 'text', $pconfig['descr']));
}
$section->addInput(new Form_StaticText('Subnet', gen_subnet($ifcfgip, $ifcfgsn)));
$section->addInput(new Form_StaticText('Subnet mask', gen_subnet_mask($ifcfgsn)));
// Compose a string to display the required address ranges
$rangestr = ip_after($subnet_start) . ' - ' . ip_before($subnet_end);
if (is_numeric($pool) || $act == "newpool") {
    $rangestr .= '<br />' . gettext('In-use DHCP Pool Ranges:');
    if (is_array($config['dhcpd'][$if]['range'])) {
        $rangestr .= '<br />' . $config['dhcpd'][$if]['range']['from'] . ' - ' . $config['dhcpd'][$if]['range']['to'];
    }
    foreach ($a_pools as $p) {
        if (is_array($p['range'])) {
            $rangestr .= '<br />' . $p['range']['from'] . ' - ' . $p['range']['to'];
        }
    }
}
$section->addInput(new Form_StaticText('Available range', $rangestr));
if ($is_olsr_enabled) {
    $section->addInput(new Form_Select('netmask', 'Subnet mask', $pconfig['netmask'], array_combine(range(32, 1, -1), range(32, 1, -1))));
}