break; } else { if (!$ipaddr) { insert($w, text(my_("IP address may not be blank"))); break; } else { if (testIP($ipaddr)) { insert($w, text(sprintf(my_("Invalid IP address [ %s ]"), $ipaddr))); break; } else { if (!$size) { insert($w, text(my_("Subnet mask is invalid"))); break; } else { // handle duplicate subnets $result = $ds->GetDuplicateSubnet($base, $size, $cust); if ($row = $result->FetchRow()) { // check if baseaddr and size match EXACTLY if ($row["baseaddr"] != $base or $row["subnetsize"] != $size) { insert($w, text(sprintf(my_("Subnet could not be updated - start address and size do not EXACTLY match existing subnet [ %s ]"), $ipaddr))); break; } insert($w, block("<b>" . sprintf(my_("Row is duplicate - updating with [ %s, %s ]"), $ipaddr, $descrip) . "</b>")); $result =& $ds->ds->Execute("UPDATE base\n SET descrip=" . $ds->ds->qstr($descrip) . ",\n lastmod=" . $ds->ds->DBTimeStamp(time()) . ",\n userid=" . $ds->ds->qstr(getAuthUsername()) . ",\n admingrp=" . $ds->ds->qstr($admingrp) . "\n WHERE customer={$cust} AND\n baseaddr={$base}"); // Changed - Begin [FE] // Start of template support for base [FE] if (!empty($info)) { // Get the last insert_id $baseindex = $ds->ds->GetOne("SELECT baseindex \n FROM base\n WHERE baseaddr={$base} AND customer={$cust}"); // First, try to insert. $result =& $ds->ds->Execute("INSERT INTO baseadd\n (info, baseindex)\n VALUES\n (" . $ds->ds->qstr($info) . ",\n {$baseindex})");
$size = $row["subnetsize"]; $base = $row["baseaddr"]; $baseip = inet_ntoa($row["baseaddr"]); // test if subnet to delete is within bounds foreach ($grps as $value) { if ($extst = $ds->TestBounds($base, $size, $value)) { // got an overlap, allowed to create break; } } // could not find new subnet within any of the defined bounds // so do not create if (!$extst) { myError($w, $p, sprintf(my_("Subnet %s not modified - out of defined authority boundary"), $baseip) . "\n"); } $restemp = $ds->GetDuplicateSubnet($base, $size, $cust); if ($restemp->FetchRow()) { $formerror .= my_("Subnet could not be created - possibly overlaps with an existing subnet on new customers network") . "\n"; } else { $ds->DbfTransactionStart(); // move the subnet to another customer, template will move with as relation // between base and baseadd is baseindex column if ($duplicatesubnet == 0) { $result =& $ds->ds->Execute("UPDATE base\n SET descrip=" . $ds->ds->qstr($descrip) . ",\n admingrp=" . $ds->ds->qstr($grp) . ",\n customer={$cust},\n lastmod=" . $ds->ds->DBTimeStamp(time()) . ",\n userid=" . $ds->ds->qstr($userid) . "\n WHERE baseindex={$baseindex}"); $ds->AuditLog(array("event" => 174, "action" => "move subnet", "user" => getAuthUsername(), "baseaddr" => inet_ntoa($base), "size" => $size, "newcust" => $cust)); } else { // use the first group user belongs to create subnet if ($id = $ds->CreateSubnet($base, $size, $descrip, $cust, 0, $grp)) { if ($duplicatesubnet == 1) { // subnet created, now move info to new subnet // cant use a temp table here as database does not