Changeset 488 for branches/htmlform/cgi-bin/admin.cgi
- Timestamp:
- 09/23/10 17:23:31 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/htmlform/cgi-bin/admin.cgi
r487 r488 243 243 244 244 } elsif ($webvar{action} eq 'alloctweak') { 245 245 246 fix_allocfrom(); 246 247 showAllocs($webvar{allocfrom}); 248 247 249 } elsif ($webvar{action} eq 'update') { 250 248 251 update(); 249 } elsif ($webvar{action} eq 'assign') {250 # Display a list of possible blocks within the requested block.251 open (HTML, "../admin_alloc.html")252 or croak "Could not open admin_alloc.html :$!";253 my $html = join('', <HTML>);254 $html =~ s/\$\$MASK\$\$/$webvar{masklen}/g;255 $html =~ s/\$\$ALLOCFROM\$\$/$webvar{allocfrom}/g;256 257 my $from = new NetAddr::IP $webvar{allocfrom};258 my @blocklist = $from->split($webvar{masklen});259 my $availblocks;260 foreach (@blocklist) {261 $availblocks .= qq(<tr><td colspan=2 align=center><input type=radio name=block value="$_">$_</td></tr>\n);262 }263 $html =~ s/\$\$BLOCKLIST\$\$/$availblocks/g;264 265 print $html;266 252 267 253 } elsif ($webvar{action} eq 'touch') { … … 547 533 548 534 549 # List free blocks in a /24 for arbitrary manual allocation550 sub showfree($) {551 my $cidr = new NetAddr::IP $_[0];552 print "Showing free blocks in $cidr<br>\n".553 "<table border=1>\n";554 $sth = $ip_dbh->prepare("select * from freeblocks where cidr <<= '$cidr' order by cidr");555 $sth->execute;556 while (my @data = $sth->fetchrow_array) {557 my $temp = new NetAddr::IP $data[0];558 print "<tr><form action=admin.cgi method=POST><input type=hidden name=action value=assign>\n".559 qq(<td>$temp<input type=hidden name=allocfrom value="$temp"></td>\n).560 "<td>".561 (($temp->masklen == 30) ? '<input type=hidden name=masklen value=30>30'562 : "<select name=masklen><option>30</option>\n<option>29</option>\n") .563 (($temp->masklen < 29) ? "<option>28</option>\n" : '') .564 (($temp->masklen < 28) ? "<option>27</option>\n" : '') .565 (($temp->masklen < 27) ? "<option>26</option>\n" : '') .566 (($temp->masklen < 26) ? "<option>25</option>\n" : '') .567 (($temp->masklen < 25) ? "<option>24</option>\n" : '') .568 "</td>".569 qq(<td>$data[2]</td><td><input type=submit value="Allocate from here"></td>).570 "\n</form></tr>\n";571 }572 print "</table>\n";573 }574 575 576 535 # Show allocations to allow editing. 577 536 sub showAllocs {
Note:
See TracChangeset
for help on using the changeset viewer.