Changeset 24 for branches/stable/cgi-bin/main.cgi
- Timestamp:
- 10/26/04 11:26:11 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/cgi-bin/main.cgi
r17 r24 694 694 my $cidr = new NetAddr::IP $data[0]; 695 695 if ($master->contains($cidr)) { 696 my @row = ("$cidr", $cidr->range); 696 my @row = ("<a href=\"/ip/cgi-bin/main.cgi?action=assign&block=$cidr\">$cidr</a>", 697 $cidr->range); 697 698 printRow(\@row, 'color1') if ($count%2 == 0); 698 699 printRow(\@row, 'color2') if ($count%2 != 0); … … 766 767 printHeader(''); 767 768 768 open HTML, "../assign.html" 769 my $html; 770 771 # New special case- block to assign is specified 772 if ($webvar{block} ne '') { 773 open HTML, "../fb-assign.html" 774 or croak "Could not open fb-assign.html: $!"; 775 $html = join('',<HTML>); 776 close HTML; 777 my $block = new NetAddr::IP $webvar{block}; 778 $html =~ s|\$\$BLOCK\$\$|$block|g; 779 $html =~ s|\$\$MASKBITS\$\$|$block->masklen|; 780 } else { 781 open HTML, "../assign.html" 769 782 or croak "Could not open assign.html: $!"; 770 my $html = join('',<HTML>); 771 close(HTML); 783 $html = join('',<HTML>); 784 close HTML; 785 } 772 786 773 787 print $html; … … 830 844 831 845 } else { # end show pool options 832 if (!$webvar{maskbits}) { 833 printAndExit("Please specify a CIDR mask length."); 834 } 835 my $sql; 836 my $city; 837 my $failmsg; 838 if ($webvar{alloctype} eq 'rr') { 839 $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'". 840 " order by maskbits desc"; 841 $failmsg = "No suitable free block found.<br>\nWe do not have a free". 842 " routeable block of that size.<br>\nYou will have to either route". 843 " a set of smaller netblocks or a single smaller netblock."; 844 } else { 845 if ($webvar{alloctype} =~ /^[sd]p$/) { 846 if (($webvar{city} !~ /^(Sudbury|North Bay)$/) && ($webvar{alloctype} eq 'dp')) { 847 printAndExit("You must chose Sudbury or North Bay for DSL pools."); } 848 if ($webvar{alloctype} eq 'sp') { $city = "Sudbury"; } else { $city = $webvar{city}; } 849 $failmsg = "No suitable free block found.<br>\nYou will have to route another". 850 " superblock <br>\nfrom one of the master blocks in Sudbury or chose a smaller". 851 " block size for the pool."; 846 847 if ($webvar{fbassign} eq 'y') { 848 $cidr = new NetAddr::IP $webvar{block}; 849 $webvar{maskbits} = $cidr->masklen; 850 } else { # done with direct freeblocks assignment 851 852 if (!$webvar{maskbits}) { 853 printAndExit("Please specify a CIDR mask length."); 854 } 855 my $sql; 856 my $city; 857 my $failmsg; 858 if ($webvar{alloctype} eq 'rr') { 859 $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'". 860 " order by maskbits desc"; 861 $failmsg = "No suitable free block found.<br>\nWe do not have a free". 862 " routeable block of that size.<br>\nYou will have to either route". 863 " a set of smaller netblocks or a single smaller netblock."; 852 864 } else { 853 $city = $webvar{pop}; 854 $failmsg = "No suitable free block found.<br>\nYou will have to route another". 855 " superblock to $webvar{city}<br>\nfrom one of the master blocks in Sudbury or". 856 " chose a smaller blocksize."; 857 } 858 $sql = "select * from freeblocks where city='$city' and maskbits<=$webvar{maskbits}". 859 " and routed='y' order by cidr,maskbits desc"; 860 } 861 $sth = $ip_dbh->prepare($sql); 862 $sth->execute; 863 my @data = $sth->fetchrow_array(); 864 if ($data[0] eq "") { 865 printAndExit($failmsg); 866 } 867 868 $cidr = new NetAddr::IP $data[0]; 865 if ($webvar{alloctype} =~ /^[sd]p$/) { 866 if (($webvar{city} !~ /^(Sudbury|North Bay)$/) && ($webvar{alloctype} eq 'dp')) { 867 printAndExit("You must chose Sudbury or North Bay for DSL pools."); } 868 if ($webvar{alloctype} eq 'sp') { $city = "Sudbury"; } else { $city = $webvar{city}; } 869 $failmsg = "No suitable free block found.<br>\nYou will have to route another". 870 " superblock <br>\nfrom one of the master blocks in Sudbury or chose a smaller". 871 " block size for the pool."; 872 } else { 873 $city = $webvar{pop}; 874 $failmsg = "No suitable free block found.<br>\nYou will have to route another". 875 " superblock to $webvar{city}<br>\nfrom one of the master blocks in Sudbury or". 876 " chose a smaller blocksize."; 877 } 878 $sql = "select * from freeblocks where city='$city' and maskbits<=$webvar{maskbits}". 879 " and routed='y' order by cidr,maskbits desc"; 880 } 881 $sth = $ip_dbh->prepare($sql); 882 $sth->execute; 883 my @data = $sth->fetchrow_array(); 884 if ($data[0] eq "") { 885 printAndExit($failmsg); 886 } 887 $cidr = new NetAddr::IP $data[0]; 888 } # check for freeblocks assignment or IPDB-controlled assignment 889 869 890 $alloc_from = qq($cidr<input type=hidden name=alloc_from value="$cidr">); 870 891 … … 1120 1141 printAndExit("Please enter a customer ID."); 1121 1142 } 1122 if ($webvar{custid} !~ /^(?:\d{10}|\d{7}|STAFF) $/) {1143 if ($webvar{custid} !~ /^(?:\d{10}|\d{7}|STAFF)(?:-\d\d?)?$/) { 1123 1144 printAndExit("Please enter a valid customer ID- this must be a 7- or 10-digit number, or STAFF for static IPs for staff."); 1124 1145 } … … 1221 1242 } else { 1222 1243 $sql = "update allocations set custid='$webvar{custid}',". 1223 "description='$webvar{desc}',notes='$webvar{notes}' ".1244 "description='$webvar{desc}',notes='$webvar{notes}',city='$webvar{city}' ". 1224 1245 "where cidr='$webvar{block}'"; 1225 1246 } … … 1489 1510 } 1490 1511 print "<div class=heading align=center>Success! $webvar{block} deleted.</div>\n"; 1491 syslog "notice", "$authuser deallocated netblock $webvar{block}";1512 syslog "notice", "$authuser deallocated '$webvar{alloctype}'-type netblock $webvar{block}"; 1492 1513 1493 1514 } # end alloctype != netblock
Note:
See TracChangeset
for help on using the changeset viewer.