function checkPools(&$poolsRanges) { /* Check that the given pool range is valid */ $subnet = $_POST["subnet"]; $netmask = $_POST["netmask"]; if (isset($_POST["hassubnetpools"])) { foreach ($_POST as $key => $value) { if (preg_match('/^subnetpool_[0-9]*$/', $key)) { list($ipStart, $ipEnd) = preg_split("/\\s+/", $value); if (isset($ipStart) && isset($ipEnd)) { if (!(ipLowerThan($ipStart, $ipEnd) && ipInNetwork($ipStart, $subnet, $netmask) && ipInNetwork($ipEnd, $subnet, $netmask))) { $error .= sprintf(_T("The specified dynamic pool IP range from %s to %s is not valid."), $ipStart, $ipEnd); setFormError("subnetpools"); } $poolsRanges[] = $ipStart . " " . $ipEnd; } } } } return array(isset($error), $error); }
function checkPools() { /* Check that the given pool range is valid */ $subnet = $_POST["subnet"]; $netmask = $_POST["netmask"]; $pools = $_POST["subnetpools"]; $hasPools = isset($_POST["hassubnetpools"]); if ($hasPools) { for ($i = 0; $i < count($pools); $i++) { list($ipStart, $ipEnd) = split(" ", $pools[$i]); if (isset($ipStart) && isset($ipEnd)) { if (!(ipLowerThan($ipStart, $ipEnd) && ipInNetwork($ipStart, $subnet, $netmask) && ipInNetwork($ipEnd, $subnet, $netmask))){ $error .= sprintf(_T("The specified dynamic pool IP range from %s to %s is not valid."), $ipStart, $ipEnd); if ($i < count($pools) -1) $error .= "<br>"; } } else { $error.= sprintf(_T("No IP range specified for %d dynamic pool."), $i + 1); if ($i < count($pools) -1) $error .= "<br>"; } } } return array(isset($error), $error); }
} list($tmp, $lines[$ipaddress]["macaddress"]) = explode(" ", strtoupper($entry[1]["dhcpHWAddress"][0])); $lines[$ipaddress]["type"] = _T("Static", "network"); if ($filter) { /* Don't display a host if filtered */ if (stripos($hostname, $filter) === False && strpos(long2ip($ipaddress), $filter) === False && stripos($lines[$ipaddress]["macaddress"], $filter) === False && stripos($lines[$ipaddress]["type"], $filter) === False) { unset($lines[$ipaddress]); } } } /* Get current DHCP leases info to display dynamically assigned IP addresses */ $leases = getDhcpLeases(); if ($leases) { foreach ($leases as $ipaddress => $infos) { if ($infos["state"] == "active") { if (ipInNetwork($ipaddress, $subnet, $netmask)) { /* Only display lease of the current subnet */ $address = ip2long($ipaddress); $lines[$address]["type"] = _T("Dynamic", "network"); $lines[$address]["macaddress"] = strtoupper($infos["hardware"]); $lines[$address]["hostname"] = $infos["hostname"]; if ($filter) { /* Don't display a host if filtered */ if (stripos($lines[$address]["hostname"], $filter) === False && strpos(long2ip($address), $filter) === False && stripos($lines[$address]["macaddress"], $filter) === False && stripos($lines[$address]["type"], $filter) === False) { unset($lines[$address]); } } } } } }
} 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."); $services = array($servicesNames[0] => "DNS", $servicesNames[1] => "DHCP"); } else { addZone($zonename, $netaddress, $netmask, $reverse, $description, $nameserver, $nameserverip);