Changeset 544 for trunk/cgi-bin/admin.cgi
- Timestamp:
- 11/05/12 16:53:38 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note:
See TracChangeset
for help on using the changeset viewer.