Changeset 634 for trunk/cgi-bin
- Timestamp:
- 10/09/14 12:37:39 (10 years ago)
- Location:
- trunk/cgi-bin
- Files:
-
- 2 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() -
trunk/cgi-bin/main.cgi
r633 r634 651 651 652 652 # snag block info from db 653 my $blockinfo = getBlockData($ip_dbh, $webvar{block}, $webvar{rdepth}); 653 my $blockinfo = getBlockData($ip_dbh, $webvar{id}, $webvar{basetype}); 654 $page->param(id => $webvar{id}); 655 $page->param(basetype => $webvar{basetype}); 654 656 655 657 # Clean up extra whitespace on alloc type. Mainly a legacy-data cleanup. … … 657 659 658 660 # Get rDNS info; duplicates a bit of getBlockData but also does the RPC call if possible 659 $blockinfo->{rdns} = getBlockRDNS($ip_dbh, $webvar{block}, $webvar{rdepth}, user => $authuser);660 661 $page->param(block => $webvar{block});661 $blockinfo->{rdns} = getBlockRDNS($ip_dbh, id => $webvar{id}, type => $blockinfo->{type}, user => $authuser); 662 663 $page->param(block => $blockinfo->{block}); 662 664 $page->param(rdns => $blockinfo->{rdns}); 663 $page->param(rdepth => $blockinfo->{rdepth});664 665 665 666 $page->param(custid => $blockinfo->{custid}); … … 689 690 690 691 ## node hack 691 my ($nodeid,$nodename) = getNodeInfo($ip_dbh, $webvar{block}); 692 $page->param(havenodeid => $nodeid); 693 694 if ($blockinfo->{type} eq 'fr' || $blockinfo->{type} eq 'bi') { 695 $page->param(typesupportsnodes => 1); 696 $page->param(nodename => $nodename); 692 my ($nodeid,$nodename) = getNodeInfo($ip_dbh, $blockinfo->{block}); 693 # $page->param(havenodeid => $nodeid); 694 $page->param(nodename => $nodename); 697 695 698 696 ##fixme: this whole hack needs cleanup and generalization for all alloctypes 699 697 ##fixme: arguably a bug that presence of a nodeid implies it can be changed.. 700 # but except for manual database changes, only the two types fr and bi can 701 # (currently) have a nodeid set in the first place. 702 if ($IPDBacl{$authuser} =~ /c/) { 703 my $nlist = getNodeList($ip_dbh); 698 if ($IPDBacl{$authuser} =~ /c/) { 699 my $nlist = getNodeList($ip_dbh); 700 if ($nodeid) { 704 701 foreach (@{$nlist}) { 705 702 $$_{selme} = ($$_{node_id} == $nodeid); 706 703 } 707 $page->param(nodelist => $nlist);708 }704 } 705 $page->param(nodelist => $nlist); 709 706 } 710 707 ## end node hack … … 750 747 type => $webvar{alloctype}, 751 748 swip => $webvar{swip}, 752 rdepth => $webvar{rdepth},753 749 rdns => $webvar{rdns}, 754 750 user => $authuser, … … 783 779 784 780 # Link back to browse-routed or list-pool page on "Update complete" page. 785 my $cblock = getBlockData($ip_dbh, $webvar{block}, $webvar{rdepth}); 786 if (my $pooltype = ($webvar{alloctype} =~ /^(.)i$/) ) { 787 $page->param(backpool => 1); 788 $page->param(backblock => $cblock->{pool}); 789 } else { 790 $page->param(backblock => $cblock->{parent}); 791 } 792 $page->param(backdepth => ($webvar{rdepth})); 781 my $binfo = getBlockData($ip_dbh, $webvar{block}, $webvar{basetype}); 782 my $pblock = getBlockData($ip_dbh, $binfo->{parent_id}); 783 $page->param(backid => $binfo->{parent_id}); 784 $page->param(backblock => $pblock->{block}); 785 $page->param(backpool => ($webvar{basetype} eq 'i')); 793 786 794 787 # Do some HTML fiddling here instead of using ESCAPE=HTML in the template, … … 799 792 $webvar{privdata} =~ s/\n/<br>\n/; 800 793 801 $page->param(cidr => $ webvar{block});794 $page->param(cidr => $binfo->{block}); 802 795 $page->param(rdns => $webvar{rdns}); 803 796 $page->param(city => $webvar{city});
Note:
See TracChangeset
for help on using the changeset viewer.