Esempio n. 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");
                }
            }
Esempio n. 2
0
 // can only be one row - does not matter if nothing is
 // found as array search will return false
 $row = $result->FetchRow();
 if (!in_array($row["admingrp"], $grps)) {
     myError($w, $p, my_("You may not split or join a subnet for this customer as you are not a member of the customers admin group"));
 }
 // get info from base table
 $result = $ds->GetBaseFromIndex($baseindex);
 if (!($row = $result->FetchRow())) {
     myError($w, $p, my_("Subnet cannot be found!"));
 }
 $size = $row["subnetsize"];
 $base = $row["baseaddr"];
 $descriptmp = $row["descrip"];
 $baseip = inet_ntoa($row["baseaddr"]);
 $admingrp = $ds->GetBaseGrp($baseindex);
 // test if subnet to delete is within bounds
 foreach ($grps as $value) {
     if ($extst = $ds->TestBounds($base, $size, $value)) {
         // got an overlap, allowed to delete
         break;
     }
 }
 // could not find new subnet within any of the defined bounds
 // so do not delete
 if (!$extst) {
     myError($w, $p, sprintf(my_("Subnet %s not split or joined - out of defined authority boundary"), $baseip) . "\n");
 }
 $ds->DbfTransactionStart();
 // this code is not safe if transactions are not used
 // another user could have added a new subnet that causes an overlap