Ejemplo n.º 1
0
function checkSubnet() {
    /* Check that the given subnet is not contained into an existing subnet */
    $subnet = $_POST["subnet"];
    $netmask = $_POST["netmask"];
    foreach(getSubnets("") as $dn => $entry) {
        $sub = $entry[1]["cn"][0];
        $mask = $entry[1]["dhcpNetMask"][0];
        if (ipInNetwork($subnet, $sub, $mask, True)) {
            $error = sprintf(_T("The given network address belongs to the already existing DHCP subnet %s / %s."), $sub, $mask);
            setFormError("subnet");
            setFormError("netmask");
            break;
        }
    }
    if (isset($error)) {
        $_POST["subnet"] = "";
        $_POST["netmask"] = "";
    }
    return array(isset($error), $error);
}
Ejemplo n.º 2
0
 if (isset($_POST["dhcpsubnet"])) {
     if ($hasnetaddress & $hasnetmask) {
         $dhcpsubnet = True;
     } else {
         $error .= " " . _T("The network address and the network mask fields must be filled in if you also want to create a DHCP subnet.");
         if (!$hasnetaddress) {
             setFormError("netaddress");
         }
         if (!$hasnetmask) {
             setFormError("netmask");
         }
     }
 }
 /* Check that the given subnet is not contained into an existing subnet */
 if ($dhcpsubnet) {
     foreach (getSubnets("") as $dn => $entry) {
         $subnet = $entry[1]["cn"][0];
         $mask = $entry[1]["dhcpNetMask"][0];
         if (ipInNetwork($netaddress, $subnet, $mask, True)) {
             $error .= " " . sprintf(_T("The given network address belongs to the already existing DHCP subnet %s / %s."), $subnet, $mask);
             break;
         }
     }
 }
 if (!isset($error)) {
     $result = "";
     $servicesNames = getServicesNames();
     if ($dhcpsubnet) {
         addZoneWithSubnet($zonename, $netaddress, $netmask, $reverse, $description, $nameserver, $nameserverip);
         $result .= _T("DHCP subnet and DNS zone successfully added.");
         $result .= "<br />" . _T("The DHCP and DNS services must be restarted.");
Ejemplo n.º 3
0
<?

$filter = $_GET["filter"];
$subnets = array();
$count = array();

foreach(getSubnets($filter) as $dn => $entry) {
    $subnet = $entry[1]["cn"][0];
    $subnets[$subnet] = array();
    $subnets[$subnet]["name"] = $entry[1]["dhcpComments"][0];
    $subnets[$subnet]["netmask"] = $entry[1]["dhcpNetMask"][0];
}

ksort($subnets);
$names = array();
$netmasks = array();
$count = array();
$ranges = array();
foreach($subnets as $subnet => $infos) {
    $count[] = '<span style="font-weight: normal;">(' . getSubnetHostsCount($subnet) . ')</span>';
    $names[] = $infos["name"];
    $netmasks[] = $infos["netmask"];
    $poolsRanges = getPoolsRanges($subnet);
    $rangesStr = "";
    $showedRangesCount = 2;
    $rangesCount = count($poolsRanges);
    for ($i = 0; $i < $rangesCount; $i++){
        list($ipstart, $ipend) = explode(" ", $poolsRanges[$i]);
        $rangesStr .= "$ipstart -> $ipend";
        if ($i < $rangesCount - 1){ 
    	    if ($i == $showedRangesCount - 1)