Changeset 545 for trunk/cgi-bin/IPDB.pm
- Timestamp:
- 11/07/12 17:20:58 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r544 r545 671 671 # and available='y' order by ip limit 1); 672 672 673 $sth = $dbh->prepare("select ip from poolips where pool='$alloc_from'". 674 " and available='y' order by ip"); 675 $sth->execute; 676 677 my @data = $sth->fetchrow_array; 678 $cidr = $data[0]; # $cidr is already declared when we get here! 679 680 $sth = $dbh->prepare("update poolips set custid=?,city=?,". 681 "available='n',description=?,notes=?,circuitid=?,privdata=?". 682 " where ip=?"); 683 $sth->execute($custid, $city, $desc, $notes, $circid, $privdata, "$cidr"); 673 if ($cidr) { 674 my ($isavail) = $dbh->selectrow_array("SELECT available FROM poolips WHERE ip=?", undef, ($cidr) ); 675 if ($isavail eq 'n') { 676 die "IP already allocated. Deallocate and reallocate, or update the entry\n"; 677 } 678 if (!$isavail) { 679 die "IP is not in an IP pool.\n"; 680 } 681 } else { 682 ($cidr) = $dbh->selectrow_array("SELECT ip FROM poolips WHERE pool=? AND available='y' ORDER BY ip", 683 undef, ($alloc_from) ); 684 } 685 $dbh->do("UPDATE poolips SET custid=?,city=?,available='n',description=?,notes=?,circuitid=?,privdata=? ". 686 "WHERE ip=?", undef, ($custid, $city, $desc, $notes, $circid, $privdata, $cidr) ); 687 684 688 # node hack 685 689 if ($nodeid && $nodeid ne '') { … … 688 692 } 689 693 # end node hack 694 690 695 $dbh->commit; 691 696 }; 692 697 if ($@) { 693 $msg .= ": '".$sth->errstr."'";698 $msg .= ": $@"; 694 699 eval { $dbh->rollback; }; 695 700 return ('FAIL',$msg);
Note:
See TracChangeset
for help on using the changeset viewer.