Beispiel #1
0
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);
}
Beispiel #2
0
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);
}