Changeset 187 for trunk/cgi-bin/main.cgi
- Timestamp:
- 03/04/05 18:12:54 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.