示例#1
0
$ds = new IPplanDbf() or myError($w, $p, "Could not connect to database");
// get info from base table - do this first as safety check and because
// we need this info later
$result = $ds->GetBaseFromIndex($baseindex);
if (!($row = $result->FetchRow())) {
    myError($w, $p, my_("Subnet cannot be found!"));
}
$maxcnt = $row["subnetsize"];
$baseaddr = $row["baseaddr"];
$netdescrip = $row["descrip"];
$cust = $row["customer"];
// script gets called back from modifyipform script so that user does
// not need to press back button
if ($_POST) {
    if ($grp = $ds->GetBaseGrp($baseindex)) {
        if (in_array($grp, $grps) or $ds->TestCustomerGrp($baseindex, getAuthUsername())) {
            // ---------------- are first x IP addresses of subnet blocked? ---------------
            // ---------------- check that addresses are within subnet      ---------------
            // get lowest number of addresses in subnet that user is not allowed to
            // modify - normally zero. If user belongs to multiple groups, takes lowest value
            $limit = $ds->ds->GetOne("SELECT min(resaddr) AS cnt FROM grp WHERE grp " . $ds->grpSQL($grps));
            foreach ((array) $ip as $iptemp) {
                // cast ip to array
                if ($iptemp - $baseaddr < $limit) {
                    myError($w, $p, sprintf("You may not modify the first %s subnet addresses", $limit));
                }
                if ($iptemp - $baseaddr < 0 or $iptemp - $baseaddr >= $maxcnt) {
                    myError($w, $p, "An address you are attempting to modify is outside of the subnet");
                }
            }
            // ---------------- end check ---------------