示例#1
0
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 {
    $section->addInput(new Form_StaticText(null, '<div class="alert alert-info"> Editing Pool-Specific Options. To return to the Interface, click its tab above. </div>'));
}
$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']));
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
$range_from = ip2long(gen_subnetv4($ifcfgip, $ifcfgsn));
$range_from++;
$range_to = ip2long(gen_subnetv4_max($ifcfgip, $ifcfgsn));
$range_to--;
$rangestr = long2ip32($range_from) . ' - ' . long2ip32($range_to);
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) {
示例#2
0
 }
 /* make sure it's not within the dynamic subnet */
 if ($_POST['ipaddr']) {
     $dynsubnet_start = ip2ulong($config['dhcpd'][$if]['range']['from']);
     $dynsubnet_end = ip2ulong($config['dhcpd'][$if]['range']['to']);
     if (ip2ulong($_POST['ipaddr']) >= $dynsubnet_start && ip2ulong($_POST['ipaddr']) <= $dynsubnet_end) {
         $input_errors[] = sprintf(gettext("The IP address must not be within the DHCP range for this interface."));
     }
     foreach ($a_pools as $pidx => $p) {
         if (is_inrange_v4($_POST['ipaddr'], $p['range']['from'], $p['range']['to'])) {
             $input_errors[] = gettext("The IP address must not be within the range configured on a DHCP pool for this interface.");
             break;
         }
     }
     $lansubnet_start = ip2ulong(gen_subnetv4($ifcfgip, $ifcfgsn));
     $lansubnet_end = ip2ulong(gen_subnetv4_max($ifcfgip, $ifcfgsn));
     $ipaddr_int = ip2ulong($_POST['ipaddr']);
     if ($ipaddr_int < $lansubnet_start || $ipaddr_int > $lansubnet_end) {
         $input_errors[] = sprintf(gettext("The IP address must lie in the %s subnet."), $ifcfgdescr);
     }
     if ($ipaddr_int == $lansubnet_start) {
         $input_errors[] = sprintf(gettext("The IP address cannot be the %s network address."), $ifcfgdescr);
     }
     if ($ipaddr_int == $lansubnet_end) {
         $input_errors[] = sprintf(gettext("The IP address cannot be the %s broadcast address."), $ifcfgdescr);
     }
 }
 if ($_POST['gateway'] && !is_ipaddrv4($_POST['gateway'])) {
     $input_errors[] = gettext("A valid IP address must be specified for the gateway.");
 }
 if ($_POST['wins1'] && !is_ipaddrv4($_POST['wins1']) || $_POST['wins2'] && !is_ipaddrv4($_POST['wins2'])) {
         break;
     }
 }
 /* make sure it's not within the dynamic subnet */
 if ($_POST['ipaddr']) {
     if (is_inrange_v4($_POST['ipaddr'], $config['dhcpd'][$if]['range']['from'], $config['dhcpd'][$if]['range']['to'])) {
         $input_errors[] = sprintf(gettext("The IP address must not be within the DHCP range for this interface."));
     }
     foreach ($a_pools as $pidx => $p) {
         if (is_inrange_v4($_POST['ipaddr'], $p['range']['from'], $p['range']['to'])) {
             $input_errors[] = gettext("The IP address must not be within the range configured on a DHCP pool for this interface.");
             break;
         }
     }
     $lansubnet_start = gen_subnetv4($ifcfgip, $ifcfgsn);
     $lansubnet_end = gen_subnetv4_max($ifcfgip, $ifcfgsn);
     if (!is_inrange_v4($_POST['ipaddr'], $lansubnet_start, $lansubnet_end)) {
         $input_errors[] = sprintf(gettext("The IP address must lie in the %s subnet."), $ifcfgdescr);
     }
     if ($_POST['ipaddr'] == $lansubnet_start) {
         $input_errors[] = sprintf(gettext("The IP address cannot be the %s network address."), $ifcfgdescr);
     }
     if ($_POST['ipaddr'] == $lansubnet_end) {
         $input_errors[] = sprintf(gettext("The IP address cannot be the %s broadcast address."), $ifcfgdescr);
     }
 }
 if ($_POST['gateway'] && !is_ipaddrv4($_POST['gateway'])) {
     $input_errors[] = gettext("A valid IP address must be specified for the gateway.");
 }
 if ($_POST['wins1'] && !is_ipaddrv4($_POST['wins1']) || $_POST['wins2'] && !is_ipaddrv4($_POST['wins2'])) {
     $input_errors[] = gettext("A valid IP address must be specified for the primary/secondary WINS servers.");