Changeset 544
- Timestamp:
- 11/05/12 16:53:38 (12 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r541 r544 549 549 ##fixme: chain cities to align roughly with a full layer-2 node graph 550 550 $city = $pop if $type !~ /^.[pc]$/; 551 if ($type ne 'rm' ) {551 if ($type ne 'rm' && $city) { 552 552 $sql .= " AND city = ?"; 553 553 push @vallist, $city; 554 } 555 # Allow specifying an arbitrary full block, instead of a master 556 if ($optargs{gimme}) { 557 $sql .= " AND cidr >>= ?"; 558 push @vallist, $optargs{gimme}; 554 559 } 555 560 # if a specific master was requested, allow the requestor to self->shoot(foot) -
trunk/cgi-bin/admin.cgi
r543 r544 121 121 } 122 122 123 $sth = $ip_dbh->prepare("select def_custid from alloctypes where type='$webvar{alloctype}'"); 124 $sth->execute; 125 my @data = $sth->fetchrow_array; 126 my $custid = $data[0]; 123 my $custid = $def_custids{$webvar{alloctype}}; 127 124 if ($custid eq '') { 128 125 if ($webvar{custid} !~ /^(?:\d{10}|\d{7}|STAFF)(?:-\d\d?)?$/) { … … 146 143 } 147 144 148 my @data; 145 my $maskbits = $cidr->masklen; 146 my $fbtmp = findAllocateFrom($ip_dbh, $maskbits, $webvar{alloctype}, '','', 147 (gimme => "$cidr", allowpriv => 1)); 148 149 149 if ($webvar{alloctype} eq 'rm') { 150 $sth = $ip_dbh->prepare("select cidr from freeblocks where cidr >>='$cidr' and routed='n'"); 151 $sth->execute; 152 @data = $sth->fetchrow_array; 153 # User deserves errors if user can't be bothered to find the free block first. 154 if (!$data[0]) { 150 if (!$fbtmp) { 155 151 $page->param(errmsg => "Can't allocate from outside a free block!!"); 156 152 goto ERRJUMP; 157 153 } 158 154 } elsif ($webvar{alloctype} =~ /^(.)i$/) { 159 $sth = $ip_dbh->prepare("select cidr from allocations where cidr >>='$cidr' and (type like '_d' or type like '_p')"); 160 $sth->execute; 161 @data = $sth->fetchrow_array; 162 # User deserves errors if user can't be bothered to find the pool and a free IP first. 163 if (!$data[0]) { 155 my $iptype = $1; 156 my $ptmp = ipParent($ip_dbh, "$cidr"); 157 if ($ptmp->{type} =~ /^(.)[dp]$/) { 158 my $newiptype = "$1i"; 159 $fbtmp = $ptmp->{cidr}; 160 if ($ptmp->{type} !~ /^$iptype./) { 161 $page->param(warnmsg => "Warning: Allocating IP as '".$disp_alloctypes{$newiptype}."' instead of '". 162 $disp_alloctypes{$webvar{alloctype}}."' to match pool $fbtmp\n"); 163 $webvar{alloctype} = $newiptype; 164 } 165 } 166 if (!$fbtmp) { 164 167 $page->param(errmsg => "Can't allocate static IP from outside a pool!!"); 165 168 goto ERRJUMP; 166 169 } 167 170 } else { 168 $sth = $ip_dbh->prepare("select cidr from freeblocks where cidr >>='$cidr' and not (routed='n')"); 169 $sth->execute; 170 @data = $sth->fetchrow_array; 171 # User deserves errors if user can't be bothered to find the free block first. 172 if (!$data[0]) { 171 if (!$fbtmp) { 173 172 $page->param(errmsg => "Can't allocate from outside a routed block!!"); 174 173 goto ERRJUMP; … … 176 175 } 177 176 178 my $alloc_from = new NetAddr::IP $data[0]; 179 $sth->finish; 177 my $alloc_from = new NetAddr::IP $fbtmp; 180 178 181 179 my @cities; -
trunk/ipdb.css
r517 r544 109 109 } 110 110 111 .warnmsg { 112 border: solid 2px #FFFF00; 113 color: #333300; 114 background-color: #e0e0e0; 115 text-align: center; 116 padding: 5px; 117 width: 70%; 118 } 119 120 111 121 hr.w60 { 112 122 width: 60%; -
trunk/templates/admin/alloc.tmpl
r517 r544 2 2 <TMPL_VAR NAME=errmsg> 3 3 <TMPL_ELSE> 4 <TMPL_IF warnmsg><div class="warnmsg"><TMPL_VAR NAME=warnmsg></div></TMPL_IF> 4 5 <form method="POST" action="admin.cgi"> 5 6 <fieldset><legend class="noshow"> </legend>
Note:
See TracChangeset
for help on using the changeset viewer.