Changeset 192 for branches/stable/cgi-bin/main.cgi
- Timestamp:
- 03/10/05 14:15:19 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/cgi-bin/main.cgi
r185 r192 325 325 326 326 while (my @data = $sth->fetchrow_array) { 327 # cidr,custid,type,city,description,notes 328 # Fix up types from pools (which are single-char) 329 # Fixing the database would be... painful. :( 330 ##fixme LEGACY CODE 331 if ($data[2] =~ /^[cdsmw]$/) { 332 $data[2] .= 'i'; 333 } 334 my @row = (qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>), 327 # cidr,custid,type,city,description 328 # Prefix subblocks with "Sub " 329 my @row = ( (($data[2] =~ /^.r$/) ? 'Sub ' : ''). 330 qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>), 335 331 $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]); 336 332 # Allow listing of pool if desired/required. … … 599 595 # $data[2] =~ s/\s+//g; 600 596 601 my @row = ("<a href=\"/ip/cgi-bin/main.cgi?action=edit&block=$data[0]\">$data[0]</a>", 597 # Prefix subblocks with "Sub " 598 my @row = ( (($data[2] =~ /^.r$/) ? 'Sub ' : ''). 599 qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>), 602 600 $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]); 603 601 # If the allocation is a pool, allow listing of the IPs in the pool. … … 622 620 qq(<input type=hidden name=action value="delete">\n). 623 621 qq(<input type=hidden name=block value="$master">\n). 624 qq(<input type=hidden name=alloctype value="r r">\n).622 qq(<input type=hidden name=alloctype value="rm">\n). 625 623 qq(<input type=submit value=" Remove this block ">\n). 626 624 qq(</form>\n); … … 635 633 # unrouted free blocks, but it's better to let the database do the work if we can. 636 634 $count = 0; 637 $sth = $ip_dbh->prepare("select cidr from freeblocks where routed='y' and cidr <<= '$master' order by cidr"); 635 $sth = $ip_dbh->prepare("select cidr,routed from freeblocks where cidr <<= '$master'". 636 " order by cidr"); 638 637 $sth->execute(); 639 638 while (my @data = $sth->fetchrow_array()) { 640 # cidr, maskbits,city639 # cidr,routed 641 640 my $cidr = new NetAddr::IP $data[0]; 642 my @row = ("<a href=\"/ip/cgi-bin/main.cgi?action=assign&block=$cidr\">$cidr</a>", 641 # Include some HairyPerl(TM) to prefix subblocks with "Sub " 642 my @row = ((($data[1] ne 'y' && $data[1] ne 'n') ? 'Sub ' : ''). 643 qq(<a href="/ip/cgi-bin/main.cgi?action=assign&block=$cidr&fbtype=$data[1]">$cidr</a>), 643 644 $cidr->range); 644 645 printRow(\@row, 'color1') if ($count%2 == 0); … … 730 731 $html =~ s|\$\$MASKBITS\$\$|$block->masklen|; 731 732 my $typelist = ''; 732 $sth = $ip_dbh->prepare("select type,listname from alloctypes where listorder < 500 and type not like '_i' order by listorder"); 733 $sth->execute; 734 my @data = $sth->fetchrow_array; 735 $typelist .= "<option value='$data[0]' selected>$data[1]</option>\n"; 736 while (my @data = $sth->fetchrow_array) { 737 $typelist .= "<option value='$data[0]'>$data[1]</option>\n"; 733 734 # This is a little dangerous, as it's *theoretically* possible to 735 # get fbtype='n' (aka a non-routed freeblock). However, should 736 # someone manage to get there, they get what they deserve. 737 if ($webvar{fbtype} ne 'y') { 738 # Snag the type of the block from the database. We have no 739 # convenient way to pass this in from the calling location. :/ 740 $sth = $ip_dbh->prepare("select type from allocations where cidr >>='$block'"); 741 $sth->execute; 742 my @data = $sth->fetchrow_array; 743 $data[0] =~ s/c$/r/; # Munge the type into the correct form 744 $typelist = "$list_alloctypes{$data[0]}<input type=hidden name=alloctype value=$data[0]>\n"; 745 } else { 746 $typelist .= qq(<select name="alloctype">\n); 747 $sth = $ip_dbh->prepare("select type,listname from alloctypes where listorder < 500 ". 748 "and type not like '_i' and type not like '_r' order by listorder"); 749 $sth->execute; 750 my @data = $sth->fetchrow_array; 751 $typelist .= "<option value='$data[0]' selected>$data[1]</option>\n"; 752 while (my @data = $sth->fetchrow_array) { 753 $typelist .= "<option value='$data[0]'>$data[1]</option>\n"; 754 } 755 $typelist .= "</select>\n"; 738 756 } 739 757 $html =~ s|\$\$TYPELIST\$\$|$typelist|g; … … 839 857 my $city; 840 858 my $failmsg; 841 if ($webvar{alloctype} eq 'r r') {859 if ($webvar{alloctype} eq 'rm') { 842 860 if ($webvar{allocfrom} ne '-') { 843 861 $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'". … … 853 871 ##fixme 854 872 # This section needs serious Pondering. 855 if ($webvar{alloctype} =~ /^.[pd]$/) { 873 # Pools of all types get assigned to the POP they're "routed from" 874 # This includes WAN blocks and other netblock "containers" 875 if ($webvar{alloctype} =~ /^.[pdc]$/) { 856 876 if (($webvar{city} !~ /^(Sudbury|North Bay)$/) && ($webvar{alloctype} eq 'dp')) { 857 877 printError("You must chose Sudbury or North Bay for DSL pools."); … … 870 890 if ($webvar{allocfrom} ne '-') { 871 891 $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}". 872 " and cidr <<= '$webvar{allocfrom}' and routed='y' order by cidr,maskbits desc"; 892 " and cidr <<= '$webvar{allocfrom}' and routed='". 893 (($webvar{alloctype} =~ /^(.)r$/) ? "$1" : 'y')."' order by maskbits desc,cidr"; 873 894 } else { 874 895 $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}". 875 " and routed='y' order by cidr,maskbits desc"; 896 " and routed='".(($webvar{alloctype} =~ /^(.)r$/) ? "$1" : 'y'). 897 "' order by maskbits desc,cidr"; 876 898 } 877 899 } … … 955 977 } else { 956 978 print qq(<div class="center"><div class="heading">The block $webvar{fullcidr} was ). 957 "sucessfully added as type '$webvar{alloctype}' ". 958 "($disp_alloctypes{$webvar{alloctype}})</div></div>"; 979 "sucessfully added as: $disp_alloctypes{$webvar{alloctype}}</div></div>"; 959 980 } 960 981 syslog "notice", "$authuser allocated '$webvar{fullcidr}' to '$webvar{custid}' as ". … … 963 984 syslog "err", "Allocation of '$webvar{fullcidr}' to '$webvar{custid}' as ". 964 985 "'$webvar{alloctype}' by $authuser failed: '$msg'"; 965 printError("Allocation of $webvar{fullcidr} as $disp_alloctypes{$webvar{alloctype}}".986 printError("Allocation of $webvar{fullcidr} as '$disp_alloctypes{$webvar{alloctype}}'". 966 987 " failed:<br>\n$msg\n"); 967 988 } … … 1023 1044 # Check POP location 1024 1045 my $flag; 1025 if ($webvar{alloctype} eq 'r r') {1046 if ($webvar{alloctype} eq 'rm') { 1026 1047 $flag = 'for a routed netblock'; 1027 1048 foreach (@poplist) { … … 1095 1116 # this has now been Requested, so here goes. 1096 1117 1097 if ($data[2] =~ /^d[nyc]|cn|ee|in$/) { 1118 ##fixme The check here should be built from the database 1119 if ($data[2] =~ /^.[ne]$/) { 1098 1120 # Block that can be changed 1099 1121 my $blockoptions = "<select name=alloctype><option". 1100 (($data[2] eq 'dn') ? ' selected' : '') ." value='dn'>Dialup netblock</option>\n<option". 1101 (($data[2] eq 'dy') ? ' selected' : '') ." value='dy'>Dynamic DSL netblock</option>\n<option". 1102 (($data[2] eq 'dc') ? ' selected' : '') ." value='dc'>Dynamic cable netblock</option>\n<option". 1122 (($data[2] eq 'me') ? ' selected' : '') ." value='me'>Dialup netblock</option>\n<option". 1123 (($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". 1124 (($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". 1125 (($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". 1103 1126 (($data[2] eq 'cn') ? ' selected' : '') ." value='cn'>Customer netblock</option>\n<option". 1104 (($data[2] eq 'e e') ? ' selected' : '') ." value='ee'>End-use netblock</option>\n<option".1127 (($data[2] eq 'en') ? ' selected' : '') ." value='en'>End-use netblock</option>\n<option". 1105 1128 (($data[2] eq 'in') ? ' selected' : '') ." value='in'>Internal netblock</option>\n". 1106 1129 "</select>\n"; … … 1199 1222 my ($cidr, $custid, $type, $city, $circid, $desc, $notes, $alloctype); 1200 1223 1201 if ($webvar{alloctype} eq 'r r') {1224 if ($webvar{alloctype} eq 'rm') { 1202 1225 $sth = $ip_dbh->prepare("select cidr,city from routed where cidr='$webvar{block}'"); 1203 1226 $sth->execute(); … … 1223 1246 $desc = "N/A"; 1224 1247 $notes = "N/A"; 1225 } elsif ($webvar{alloctype} =~ /^.i$/) { # done with alloctype= rr1248 } elsif ($webvar{alloctype} =~ /^.i$/) { # done with alloctype=[rm]m 1226 1249 1227 1250 # Unassigning a static IP
Note:
See TracChangeset
for help on using the changeset viewer.