Changeset 634 for trunk/cgi-bin/IPDB.pm
- Timestamp:
- 10/09/14 12:37:39 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r633 r634 1166 1166 return ('FAIL', 'Missing block to update') if !$args{block}; 1167 1167 1168 # Spaces don't show up well in lots of places. Make sure they don't get into the DB. 1169 $args{custid} =~ s/^\s+//; 1170 $args{custid} =~ s/\s+$//; 1171 1168 1172 # do it all in a transaction 1169 1173 local $dbh->{AutoCommit} = 0; … … 1179 1183 } 1180 1184 1185 my $binfo; 1181 1186 my $updtable = 'allocations'; 1182 my $keyfield = ' cidr';1187 my $keyfield = 'id'; 1183 1188 if ($args{type} =~ /^(.)i$/) { 1184 1189 $updtable = 'poolips'; 1185 $ keyfield = 'ip';1190 $binfo = getBlockData($dbh, $args{block}, 'i'); 1186 1191 } else { 1187 1192 ## fixme: there's got to be a better way... 1193 $binfo = getBlockData($dbh, $args{block}); 1188 1194 if ($args{swip}) { 1189 1195 if ($args{swip} eq 'on' || $args{swip} eq '1' || $args{swip} eq 'y') { … … 1203 1209 return ('FAIL', 'No fields to update') if !@fieldlist; 1204 1210 1205 # push @vallist, $args{block}, $args{rdepth}, $args{vrf}; 1206 push @vallist, $args{block}, $args{rdepth}; 1211 push @vallist, $args{block}; 1207 1212 my $sql = "UPDATE $updtable SET "; 1208 1213 $sql .= join " = ?, ", @fieldlist; 1209 # $sql .= " = ? WHERE $keyfield = ? AND rdepth = ? AND vrf = ?"; 1210 $sql .= " = ? WHERE $keyfield = ? AND rdepth = ? "; 1214 $sql .= " = ? WHERE $keyfield = ?"; 1211 1215 1212 1216 eval { … … 1216 1220 if ($args{node}) { 1217 1221 # done with delete/insert so we don't have to worry about funkyness updating a node ref that isn't there 1218 $dbh->do("DELETE FROM noderef WHERE block = ?", undef, ($args{block}) ); 1219 $dbh->do("INSERT INTO noderef (block,node_id) VALUES (?,?)", undef, ($args{block}, $args{node}) ); 1222 $dbh->do("DELETE FROM noderef WHERE block = ?", undef, ($binfo->{block}) ); 1223 $dbh->do("INSERT INTO noderef (block,node_id) VALUES (?,?)", undef, ($binfo->{block}, $args{node}) ) 1224 if $args{node} ne '--'; 1220 1225 } 1221 1226 … … 1228 1233 } 1229 1234 1230 _rpc('addOrUpdateRevRec', cidr => $args{block}, name => $args{rdns}, rpcuser => $args{user}); 1235 $binfo->{block} =~ s|/32$||; 1236 _rpc('addOrUpdateRevRec', cidr => $binfo->{block}, name => $args{rdns}, rpcuser => $args{user}); 1231 1237 return ('OK','OK'); 1232 1238 } # end updateBlock()
Note:
See TracChangeset
for help on using the changeset viewer.