Changeset 187 for trunk/cgi-bin
- Timestamp:
- 03/04/05 18:12:54 (20 years ago)
- Location:
- trunk/cgi-bin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r186 r187 234 234 eval { 235 235 $msg = "Unable to allocate $cidr as '$disp_alloctypes{$type}'"; 236 if ($type eq 'r r') {236 if ($type eq 'rm') { 237 237 $sth = $dbh->prepare("update freeblocks set routed='y',city='$city'". 238 238 " where cidr='$cidr'"); … … 244 244 # common stuff for end-use, dialup, dynDSL, pools, etc, etc. 245 245 246 # special case - block is a container/"reserve" block - alloctype begins with 'r'247 if ($type =~ /^ r.$/) {248 $sth = $dbh->prepare("update freeblocks set routed=' r' where cidr='$cidr'");246 # special case - block is a container/"reserve" block 247 if ($type =~ /^(.)c$/) { 248 $sth = $dbh->prepare("update freeblocks set routed='$1' where cidr='$cidr'"); 249 249 $sth->execute; 250 250 } else { … … 312 312 313 313 # now we have to do some magic for routing blocks 314 if ($type eq 'r r') {314 if ($type eq 'rm') { 315 315 316 316 # Insert the new freeblocks entries … … 336 336 # Insert the new freeblocks entries 337 337 # Along with some more HairyPerl(TM) in case we're inserting a 338 # subblock ( l.) allocation338 # subblock (.r) allocation 339 339 $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city,routed)". 340 340 " values (?, ?, (select city from routed where cidr >>= '$cidr'),'". 341 (($type =~ /^ l.$/) ? 'r' : 'y')."')");341 (($type =~ /^(.)r$/) ? '$1' : 'y')."')"); 342 342 foreach my $block (@newfreeblocks) { 343 343 $sth->execute("$block", $block->masklen); 344 344 } 345 # special-case for reserve/"container" blocks 346 if ($type =~ /^r.$/) { 345 # Special-case for reserve/"container" blocks - generate 346 # the "extra" freeblocks entry for the container 347 if ($type =~ /^(.)c$/) { 347 348 $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city,routed)". 348 " values ('$cidr',".$cidr->masklen.",'$city',' r')");349 " values ('$cidr',".$cidr->masklen.",'$city','$1')"); 349 350 $sth->execute; 350 351 } … … 500 501 eval { 501 502 502 if ($type eq 'r r') {503 if ($type eq 'rm') { 503 504 $msg = "Unable to remove routing allocation $cidr"; 504 505 $sth = $dbh->prepare("delete from routed where cidr='$cidr'"); … … 531 532 "(select cidr from routed where cidr >>= '$cidr') ". 532 533 " and maskbits<=".$cidr->masklen. 533 " and routed='".(($type =~ /^ l.$/) ? 'r' : 'y').534 " and routed='".(($type =~ /^(.)r$/) ? '$1' : 'y'). 534 535 "' order by maskbits desc"); 535 536 … … 569 570 570 571 # insert "new" freeblocks entry 571 if ($type eq 'r r') {572 if ($type eq 'rm') { 572 573 $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city)". 573 574 " values ('$cidr',".$cidr->masklen.",'<NULL>')"); … … 576 577 " values ('$cidr',".$cidr->masklen. 577 578 ",(select city from routed where cidr >>= '$cidr'),'". 578 (($type =~ /^ l.$/) ? 'r' : 'y')."')");579 (($type =~ /^(.)r$/) ? '$1' : 'y')."')"); 579 580 } 580 581 $sth->execute; -
trunk/cgi-bin/ipdb.psql
r182 r187 125 125 mp Static Pool - Dialup Static dialup pool 43 DIAL-BUS 126 126 wp Static Pool - Wireless Static wireless pool 44 WL-BUS 127 dcDynamic cable block Dynamic cable block 103 CBL-RES128 d yDynamic DSL block Dynamic DSL block 102 DSL-RES129 dnDialup netblock Dialup netblock 101 DIAL-RES130 dwDynamic WiFi block Dynamic WiFi block 104 WL-RES127 ce Dynamic cable block Dynamic cable block 103 CBL-RES 128 de Dynamic DSL block Dynamic DSL block 102 DSL-RES 129 me Dialup netblock Dialup netblock 101 DIAL-RES 130 we Dynamic WiFi block Dynamic WiFi block 104 WL-RES 131 131 mm Master block Master block 999 6750400 132 r rRouting Routed netblock 500 6750400132 rm Routing Routed netblock 500 6750400 133 133 in Internal netblock Internal netblock 990 6750400 134 e eEnd-use netblock End-use netblock 100 6750400134 en End-use netblock End-use netblock 100 6750400 135 135 sd Static Pool - Servers Server pool 40 6750400 136 136 cn Customer netblock Customer netblock 0 … … 140 140 wi Static IP - Wireless Static wireless IP 24 141 141 si Static IP - Server pool Server pool IP 20 6750400 142 wc Reserve for WAN blocks WAN IP blocks 200 6750400 143 wr Internal WAN block Internal WAN block 201 6750400 144 pc Reserve for dynamic-route DSL netblocks Dynamic-route netblocks 202 6750400 145 pr Dynamic-route DSL netblock Dynamic-route DSL 203 142 146 \. -
trunk/cgi-bin/main.cgi
r186 r187 324 324 325 325 while (my @data = $sth->fetchrow_array) { 326 # cidr,custid,type,city,description,notes 327 # Fix up types from pools (which are single-char) 328 # Fixing the database would be... painful. :( 329 ##fixme LEGACY CODE 330 if ($data[2] =~ /^[cdsmw]$/) { 331 $data[2] .= 'i'; 332 } 333 my @row = ( (($data[2] =~ /^l.$/) ? 'Sub ' : ''). 326 # cidr,custid,type,city,description 327 # Prefix subblocks with "Sub " 328 my @row = ( (($data[2] =~ /^.r$/) ? 'Sub ' : ''). 334 329 qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>), 335 330 $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]); … … 599 594 # $data[2] =~ s/\s+//g; 600 595 601 my @row = ( (($data[2] =~ /^l.$/) ? 'Sub ' : ''). 596 # Prefix subblocks with "Sub " 597 my @row = ( (($data[2] =~ /^.r$/) ? 'Sub ' : ''). 602 598 qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>), 603 599 $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]); … … 623 619 qq(<input type=hidden name=action value="delete">\n). 624 620 qq(<input type=hidden name=block value="$master">\n). 625 qq(<input type=hidden name=alloctype value="r r">\n).621 qq(<input type=hidden name=alloctype value="rm">\n). 626 622 qq(<input type=submit value=" Remove this block ">\n). 627 623 qq(</form>\n); … … 642 638 # cidr,routed 643 639 my $cidr = new NetAddr::IP $data[0]; 644 my @row = ((($data[1] eq 'r') ? 'Sub ' : ''). 645 "<a href=\"/ip/cgi-bin/main.cgi?action=assign&block=$cidr\">$cidr</a>", 640 # Include some HairyPerl(TM) to prefix subblocks with "Sub " 641 my @row = ((($data[1] ne 'y' && $data[1] ne 'n') ? 'Sub ' : ''). 642 qq(<a href="/ip/cgi-bin/main.cgi?action=assign&block=$cidr&fbtype=$data[1]">$cidr</a>), 646 643 $cidr->range); 647 644 printRow(\@row, 'color1') if ($count%2 == 0); … … 733 730 $html =~ s|\$\$MASKBITS\$\$|$block->masklen|; 734 731 my $typelist = ''; 735 $sth = $ip_dbh->prepare("select type,listname from alloctypes where listorder < 500 and type not like '_i' order by listorder"); 736 $sth->execute; 737 my @data = $sth->fetchrow_array; 738 $typelist .= "<option value='$data[0]' selected>$data[1]</option>\n"; 739 while (my @data = $sth->fetchrow_array) { 740 $typelist .= "<option value='$data[0]'>$data[1]</option>\n"; 732 733 # This is a little dangerous, as it's *theoretically* possible to 734 # get fbtype='n' (aka a non-routed freeblock). However, should 735 # someone manage to get there, they get what they deserve. 736 if ($webvar{fbtype} ne 'y') { 737 # Snag the type of the block from the database. We have no 738 # convenient way to pass this in from the calling location. :/ 739 $sth = $ip_dbh->prepare("select type from allocations where cidr >>='$block'"); 740 $sth->execute; 741 my @data = $sth->fetchrow_array; 742 $data[0] =~ s/c$/r/; # Munge the type into the correct form 743 $typelist = "$disp_alloctypes{$data[0]}<input type=hidden name=alloctype value=$data[0]>\n"; 744 } else { 745 $typelist .= qq(<select name="alloctype">\n); 746 $sth = $ip_dbh->prepare("select type,listname from alloctypes where listorder < 500 ". 747 "and type not like '_i' order by listorder"); 748 $sth->execute; 749 my @data = $sth->fetchrow_array; 750 $typelist .= "<option value='$data[0]' selected>$data[1]</option>\n"; 751 while (my @data = $sth->fetchrow_array) { 752 $typelist .= "<option value='$data[0]'>$data[1]</option>\n"; 753 } 754 $typelist .= "</select>\n"; 741 755 } 742 756 $html =~ s|\$\$TYPELIST\$\$|$typelist|g; … … 842 856 my $city; 843 857 my $failmsg; 844 if ($webvar{alloctype} eq 'r r') {858 if ($webvar{alloctype} eq 'rm') { 845 859 if ($webvar{allocfrom} ne '-') { 846 860 $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'". … … 856 870 ##fixme 857 871 # This section needs serious Pondering. 858 if ($webvar{alloctype} =~ /^.[pd]$/) { 872 # Pools of all types get assigned to the POP they're "routed from" 873 # This includes WAN blocks and other netblock "containers" 874 if ($webvar{alloctype} =~ /^.[pdc]$/) { 859 875 if (($webvar{city} !~ /^(Sudbury|North Bay)$/) && ($webvar{alloctype} eq 'dp')) { 860 876 printError("You must chose Sudbury or North Bay for DSL pools."); … … 874 890 $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}". 875 891 " and cidr <<= '$webvar{allocfrom}' and routed='". 876 (($webvar{alloctype} =~ /^ l.$/) ? 'r' : 'y')."' order by cidr,maskbits desc";892 (($webvar{alloctype} =~ /^(.)r$/) ? '$1' : 'y')."' order by cidr,maskbits desc"; 877 893 } else { 878 894 $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}". 879 " and routed='".(($webvar{alloctype} =~ /^ l.$/) ? 'r' : 'y').895 " and routed='".(($webvar{alloctype} =~ /^(.)r$/) ? '$1' : 'y'). 880 896 "' order by cidr,maskbits desc"; 881 897 } … … 1012 1028 # Check POP location 1013 1029 my $flag; 1014 if ($webvar{alloctype} eq 'r r') {1030 if ($webvar{alloctype} eq 'rm') { 1015 1031 $flag = 'for a routed netblock'; 1016 1032 foreach (@poplist) { … … 1084 1100 # this has now been Requested, so here goes. 1085 1101 1086 if ($data[2] =~ /^d[nyc]|cn|ee|in$/) { 1102 ##fixme The check here should be built from the database 1103 if ($data[2] =~ /^.[ne]$/) { 1087 1104 # Block that can be changed 1088 1105 my $blockoptions = "<select name=alloctype><option". 1089 (($data[2] eq 'dn') ? ' selected' : '') ." value='dn'>Dialup netblock</option>\n<option". 1090 (($data[2] eq 'dy') ? ' selected' : '') ." value='dy'>Dynamic DSL netblock</option>\n<option". 1091 (($data[2] eq 'dc') ? ' selected' : '') ." value='dc'>Dynamic cable netblock</option>\n<option". 1106 (($data[2] eq 'me') ? ' selected' : '') ." value='me'>Dialup netblock</option>\n<option". 1107 (($data[2] eq 'de') ? ' selected' : '') ." value='de'>Dynamic DSL netblock</option>\n<option". (($data[2] eq 'dc') ? ' selected' : '') ." value='dc'>Dynamic cable netblock</option>\n<option". 1108 (($data[2] eq 'ce') ? ' selected' : '') ." value='ce'>Dynamic cable netblock</option>\n<option". (($data[2] eq 'dc') ? ' selected' : '') ." value='dc'>Dynamic cable netblock</option>\n<option". 1109 (($data[2] eq 'we') ? ' selected' : '') ." value='we'>Dynamic wireless netblock</option>\n<option". (($data[2] eq 'dc') ? ' selected' : '') ." value='dc'>Dynamic cable netblock</option>\n<option". 1092 1110 (($data[2] eq 'cn') ? ' selected' : '') ." value='cn'>Customer netblock</option>\n<option". 1093 (($data[2] eq 'e e') ? ' selected' : '') ." value='ee'>End-use netblock</option>\n<option".1111 (($data[2] eq 'en') ? ' selected' : '') ." value='en'>End-use netblock</option>\n<option". 1094 1112 (($data[2] eq 'in') ? ' selected' : '') ." value='in'>Internal netblock</option>\n". 1095 1113 "</select>\n"; … … 1190 1208 my ($cidr, $custid, $type, $city, $circid, $desc, $notes, $alloctype); 1191 1209 1192 if ($webvar{alloctype} eq 'r r') {1210 if ($webvar{alloctype} eq 'rm') { 1193 1211 $sth = $ip_dbh->prepare("select cidr,city from routed where cidr='$webvar{block}'"); 1194 1212 $sth->execute();
Note:
See TracChangeset
for help on using the changeset viewer.