source: trunk/cgi-bin/main.cgi@ 520

Last change on this file since 520 was 519, checked in by Kris Deugau, 12 years ago

/trunk

Move SQL for node search page into IPDB.pm. See #34.
Also tweak some handling for the lingering global statement handle
variable, since it may be undefined instead of a statement handle.

  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author
File size: 39.9 KB
Line 
1#!/usr/bin/perl
2# ipdb/cgi-bin/main.cgi
3###
4# SVN revision info
5# $Date: 2012-10-19 20:15:59 +0000 (Fri, 19 Oct 2012) $
6# SVN revision $Rev: 519 $
7# Last update by $Author: kdeugau $
8###
9# Copyright (C) 2004-2010 - Kris Deugau
10
11use strict;
12use warnings;
13use CGI::Carp qw(fatalsToBrowser);
14use CGI::Simple;
15use HTML::Template;
16use DBI;
17use POSIX qw(ceil);
18use NetAddr::IP;
19
20use Sys::Syslog;
21
22# don't remove! required for GNU/FHS-ish install from tarball
23##uselib##
24
25use CustIDCK;
26use MyIPDB;
27
28openlog "IPDB","pid","$IPDB::syslog_facility";
29
30## Environment. Collect some things, process some things, set some things...
31
32# Collect the username from HTTP auth. If undefined, we're in
33# a test environment, or called without a username.
34my $authuser;
35if (!defined($ENV{'REMOTE_USER'})) {
36 $authuser = '__temptest';
37} else {
38 $authuser = $ENV{'REMOTE_USER'};
39}
40
41# anyone got a better name? :P
42my $thingroot = $ENV{SCRIPT_FILENAME};
43$thingroot =~ s|cgi-bin/main.cgi||;
44
45syslog "debug", "$authuser active, $ENV{'REMOTE_ADDR'}";
46
47##fixme there *must* be a better order to do things in so this can go back where it was
48# CGI fiddling done here so we can declare %webvar so we can alter $webvar{action}
49# to show the right page on DB errors.
50# Set up the CGI object...
51my $q = new CGI::Simple;
52# ... and get query-string params as well as POST params if necessary
53$q->parse_query_string;
54
55# Convenience; saves changing all references to %webvar
56##fixme: tweak for handling <select multiple='y' size=3> (list with multiple selection)
57my %webvar = $q->Vars;
58
59# Why not a global DB handle? (And a global statement handle, as well...)
60# Use the connectDB function, otherwise we end up confusing ourselves
61my $ip_dbh;
62my $sth;
63my $errstr;
64($ip_dbh,$errstr) = connectDB_My;
65if (!$ip_dbh) {
66 $webvar{action} = "dberr";
67} else {
68 initIPDBGlobals($ip_dbh);
69}
70
71# Set up some globals
72$ENV{HTML_TEMPLATE_ROOT} = $thingroot."templates";
73
74my $header = HTML::Template->new(filename => "header.tmpl");
75my $footer = HTML::Template->new(filename => "footer.tmpl");
76
77$header->param(version => $IPDB::VERSION);
78$header->param(addperm => $IPDBacl{$authuser} =~ /a/);
79$header->param(webpath => $IPDB::webpath);
80print "Content-type: text/html\n\n", $header->output;
81
82
83#main()
84my $aclerr;
85
86if(!defined($webvar{action})) {
87 $webvar{action} = "index"; #shuts up the warnings.
88}
89
90my $page;
91if (-e "$ENV{HTML_TEMPLATE_ROOT}/$webvar{action}.tmpl") {
92 $page = HTML::Template->new(filename => "$webvar{action}.tmpl");
93} else {
94 $page = HTML::Template->new(filename => "dunno.tmpl");
95}
96
97if($webvar{action} eq 'index') {
98 showSummary();
99} elsif ($webvar{action} eq 'addmaster') {
100 if ($IPDBacl{$authuser} !~ /a/) {
101 $aclerr = 'addmaster';
102 }
103} elsif ($webvar{action} eq 'newmaster') {
104
105 if ($IPDBacl{$authuser} !~ /a/) {
106 $aclerr = 'addmaster';
107 } else {
108 my $cidr = new NetAddr::IP $webvar{cidr};
109 $page->param(cidr => "$cidr");
110
111 my ($code,$msg) = addMaster($ip_dbh, $webvar{cidr});
112
113 if ($code eq 'FAIL') {
114 syslog "err", "Could not add master block '$webvar{cidr}' to database: '$msg'";
115 $page->param(err => $msg);
116 } else {
117 syslog "info", "$authuser added master block $webvar{cidr}";
118 }
119
120 } # ACL check
121
122} # end add new master
123
124elsif($webvar{action} eq 'showmaster') {
125 showMaster();
126}
127elsif($webvar{action} eq 'showrouted') {
128 showRBlock();
129}
130elsif($webvar{action} eq 'listpool') {
131 listPool();
132}
133
134# Not modified or added; just shuffled
135elsif($webvar{action} eq 'assign') {
136 assignBlock();
137}
138elsif($webvar{action} eq 'confirm') {
139 confirmAssign();
140}
141elsif($webvar{action} eq 'insert') {
142 insertAssign();
143}
144elsif($webvar{action} eq 'edit') {
145 edit();
146}
147elsif($webvar{action} eq 'update') {
148 update();
149}
150elsif($webvar{action} eq 'delete') {
151 remove();
152}
153elsif($webvar{action} eq 'finaldelete') {
154 finalDelete();
155}
156elsif ($webvar{action} eq 'nodesearch') {
157 my $nodelist = getNodeList($ip_dbh);
158 $page->param(nodelist => $nodelist);
159}
160
161# DB failure. Can't do much here, really.
162elsif ($webvar{action} eq 'dberr') {
163 $page->param(errmsg => $errstr);
164}
165
166# Default is an error. It shouldn't be possible to get here unless you're
167# randomly feeding in values for webvar{action}.
168else {
169 my $rnd = rand 500;
170 my $boing = sprintf("%.2f", rand 500);
171 my @excuses = (
172 "Aether cloudy. Ask again later about $webvar{action}.",
173 "The gods are unhappy with your sacrificial $webvar{action}.",
174 "Because one of $webvar{action}'s legs are both the same",
175 "<b>wibble</b><br>Can't $webvar{action}, the grue will get me!<br>Can't $webvar{action}, the grue will get me!",
176 "Hey, man, you've had your free $webvar{action}. Next one's gonna... <i>cost</i>....",
177 "I ain't done $webvar{action}",
178 "Oooo, look! A flying $webvar{action}!",
179 "$webvar{action} too evil, avoiding.",
180 "Rocks fall, $webvar{action} dies.",
181 "Bit bucket must be emptied before I can $webvar{action}..."
182 );
183 $page->param(dunno => $excuses[$rnd/50.0]);
184}
185## Finally! Done with that NASTY "case" emulation!
186
187
188# Switch to a different template if we've tripped on an ACL error.
189# Note that this should only be exercised in development, when
190# deeplinked, or when being attacked; normal ACL handling should
191# remove the links a user is not allowed to click on.
192if ($aclerr) {
193 $page = HTML::Template->new(filename => "aclerror.tmpl");
194 $page->param(ipdbfunc => $aclmsg{$aclerr});
195}
196
197$sth->finish if $sth;
198# Clean up IPDB globals, DB handle, etc.
199finish($ip_dbh);
200
201## Do all our printing here so we can generate errors and stick them into the slots in the templates.
202
203# can't do this yet, too many blowups
204#print "Content-type: text/html\n\n", $header->output;
205$page->param(webpath => $IPDB::webpath);
206print $page->output;
207
208# include the admin tools link in the output?
209$footer->param(adminlink => ($IPDBacl{$authuser} =~ /A/));
210$footer->param(webpath => $IPDB::webpath);
211print $footer->output;
212
213# Just in case something waaaayyy down isn't in place
214# properly... we exit explicitly.
215exit 0;
216
217
218# Initial display: Show master blocks with total allocated subnets, total free subnets
219sub showSummary {
220 my %allocated;
221 my %free;
222 my %routed;
223 my %bigfree;
224
225 # Count the allocations.
226 $sth = $ip_dbh->prepare("select count(*) from allocations where cidr <<= ?");
227 foreach my $master (@masterblocks) {
228 $sth->execute("$master");
229 $sth->bind_columns(\$allocated{"$master"});
230 $sth->fetch();
231 }
232
233 # Count routed blocks
234 $sth = $ip_dbh->prepare("select count(*) from routed where cidr <<= ?");
235 foreach my $master (@masterblocks) {
236 $sth->execute("$master");
237 $sth->bind_columns(\$routed{"$master"});
238 $sth->fetch();
239 }
240
241 # Count the free blocks.
242 $sth = $ip_dbh->prepare("select count(*) from freeblocks where cidr <<= ? and ".
243 "(routed='y' or routed='n')");
244 foreach my $master (@masterblocks) {
245 $sth->execute("$master");
246 $sth->bind_columns(\$free{"$master"});
247 $sth->fetch();
248 }
249
250 # Find the largest free block in each master
251 $sth = $ip_dbh->prepare("select maskbits from freeblocks where cidr <<= ? and ".
252 "(routed='y' or routed='n') order by maskbits limit 1");
253 foreach my $master (@masterblocks) {
254 $sth->execute("$master");
255 $sth->bind_columns(\$bigfree{"$master"});
256 $sth->fetch();
257 }
258
259 # Assemble the data to stuff into the template.
260 my @masterlist;
261 my $rowclass=0;
262 foreach my $master (@masterblocks) {
263 my %row = (
264 rowclass => $rowclass++ % 2,
265 master => "$master",
266 routed => $routed{"$master"},
267 allocated => $allocated{"$master"},
268 free => $free{"$master"},
269 bigfree => ( ($bigfree{"$master"} eq '') ? ("&lt;NONE&gt;") : ("/".$bigfree{"$master"}) )
270 );
271 push (@masterlist, \%row);
272 }
273 $page->param(masterlist => \@masterlist);
274
275 $page->param(addmaster => ($IPDBacl{$authuser} =~ /a/) );
276
277} # showSummary
278
279
280# Display detail on master
281# Alrighty then! We're showing routed blocks within a single master this time.
282# We should be able to steal code from showSummary(), and if I'm really smart
283# I'll figger a way to munge the two together. (Once I've done that, everything
284# else should follow. YMMV.)
285sub showMaster {
286
287 $page->param(master => $webvar{block});
288
289 my %allocated;
290 my %free;
291 my %cities;
292 my %bigfree;
293
294 my $master = new NetAddr::IP $webvar{block};
295 my @localmasters;
296
297 # Fetch only the blocks relevant to this master
298 $sth = $ip_dbh->prepare("select cidr,city from routed where cidr <<= '$master' order by cidr");
299 $sth->execute();
300
301 my $i=0;
302 while (my @data = $sth->fetchrow_array()) {
303 my $cidr = new NetAddr::IP $data[0];
304 $localmasters[$i++] = $cidr;
305 $free{"$cidr"} = 0;
306 $allocated{"$cidr"} = 0;
307 $bigfree{"$cidr"} = 128;
308 # Retain the routing destination
309 $cities{"$cidr"} = $data[1];
310 }
311
312 # Check if there were actually any blocks routed from this master
313 if ($i > 0) {
314
315 # Count the allocations
316 $sth = $ip_dbh->prepare("select count(*) from allocations where cidr <<= ?");
317 foreach my $master (@localmasters) {
318 $sth->execute("$master");
319 $sth->bind_columns(\$allocated{"$master"});
320 $sth->fetch();
321 }
322
323 # Count the free blocks.
324 $sth = $ip_dbh->prepare("select count(*) from freeblocks where cidr <<= ? and ".
325 "(routed='y' or routed='n')");
326 foreach my $master (@localmasters) {
327 $sth->execute("$master");
328 $sth->bind_columns(\$free{"$master"});
329 $sth->fetch();
330 }
331
332 # Get the size of the largest free block
333 $sth = $ip_dbh->prepare("select maskbits from freeblocks where cidr <<= ? and ".
334 "(routed='y' or routed='n') order by maskbits limit 1");
335 foreach my $master (@localmasters) {
336 $sth->execute("$master");
337 $sth->bind_columns(\$bigfree{"$master"});
338 $sth->fetch();
339 }
340
341 my @routed;
342 my $rowclass = 0;
343 foreach my $master (@localmasters) {
344 my %row = (
345 rowclass => $rowclass++ % 2,
346 block => "$master",
347 city => $cities{"$master"},
348 nsubs => $allocated{"$master"},
349 nfree => $free{"$master"},
350 lfree => ( ($bigfree{"$master"} eq 128) ? ("&lt;NONE&gt;") : ("/".$bigfree{"$master"}) )
351 );
352 push @routed, \%row;
353 }
354 $page->param(routedlist => \@routed);
355
356 } # end check for existence of routed blocks in master
357
358 $page->param(delmaster => ($IPDBacl{$authuser} =~ /d/));
359
360 # Snag the free blocks.
361 my $count = 0;
362 $sth = $ip_dbh->prepare("select cidr from freeblocks where cidr <<='$master' and ".
363 "routed='n' order by cidr");
364 $sth->execute();
365 my @unrouted;
366 my $rowclass = 0;
367 while (my @data = $sth->fetchrow_array()) {
368 my $cidr = new NetAddr::IP $data[0];
369 my %row = (
370 rowclass => $rowclass++ % 2,
371 fblock => "$cidr",
372 frange => $cidr->range
373 );
374 push @unrouted, \%row;
375 }
376 $page->param(unrouted => \@unrouted);
377
378} # showMaster
379
380
381# Display details of a routed block
382# Alrighty then! We're showing allocations within a routed block this time.
383# We should be able to steal code from showSummary() and showMaster(), and if
384# I'm really smart I'll figger a way to munge all three together. (Once I've
385# done that, everything else should follow. YMMV.
386# This time, we check the database before spewing, because we may
387# not have anything useful to spew.
388sub showRBlock {
389
390 my $master = new NetAddr::IP $webvar{block};
391
392 $sth = $ip_dbh->prepare("select city from routed where cidr='$master'");
393 $sth->execute;
394 my ($rcity) = $sth->fetchrow_array;
395
396 $page->param(master => "$master");
397 $page->param(rcity => $rcity);
398
399 # Snag the allocations for this block
400 $sth = $ip_dbh->prepare("select cidr,city,type,custid,swip,description".
401 " from allocations where cidr <<= '$master' order by cidr");
402 $sth->execute();
403
404 # hack hack hack
405 # set up to flag swip=y records if they don't actually have supporting data in the customers table
406 my $custsth = $ip_dbh->prepare("select count(*) from customers where custid=?");
407
408 my $rowclass = 0;
409 my @blocklist;
410 while (my ($cidr,$city,$type,$custid,$swip,$desc) = $sth->fetchrow_array()) {
411 $custsth->execute($custid);
412 my ($ncust) = $custsth->fetchrow_array();
413
414 my %row = (
415 rowclass => $rowclass++ % 2,
416 block => $cidr,
417 city => $city,
418 type => $disp_alloctypes{$type},
419 custid => $custid,
420 swip => ($swip eq 'y' ? ($ncust == 0 ? 'Yes<small>*</small>' : 'Yes') : 'No'),
421 desc => $desc
422 );
423 $row{subblock} = ($type =~ /^.r$/); # hmf. wonder why these won't work in the hash declaration...
424 $row{listpool} = ($type =~ /^.[pd]$/);
425 push (@blocklist, \%row);
426 }
427 $page->param(blocklist => \@blocklist);
428
429 $page->param(delrouted => $IPDBacl{$authuser} =~ /d/);
430
431 # Snag the free blocks. We don't really *need* to be pedantic about avoiding
432 # unrouted free blocks, but it's better to let the database do the work if we can.
433 $rowclass = 0;
434 my @unassigned;
435 $sth = $ip_dbh->prepare("select cidr,routed from freeblocks where cidr <<= '$master'".
436 " order by cidr");
437 $sth->execute();
438 while (my ($cidr_db,$routed) = $sth->fetchrow_array()) {
439 my $cidr = new NetAddr::IP $cidr_db;
440
441 my %row = (
442 rowclass => $rowclass++ % 2,
443 subblock => ($routed ne 'y' && $routed ne 'n'),
444 fblock => $cidr_db,
445 fbtype => $routed,
446 frange => $cidr->range,
447 );
448 push @unassigned, \%row;
449 }
450 $page->param(unassigned => \@unassigned);
451
452} # showRBlock
453
454
455# List the IPs used in a pool
456sub listPool {
457
458 my $cidr = new NetAddr::IP $webvar{pool};
459
460 $page->param(block => $webvar{pool});
461 $page->param(netip => $cidr->addr);
462 $cidr++;
463 $page->param(gate => $cidr->addr);
464 $cidr--; $cidr--;
465 $page->param(bcast => $cidr->addr);
466 $page->param(mask => $cidr->mask);
467
468 # Snag pool info for heading
469 $sth = $ip_dbh->prepare("select type,city from allocations where cidr=?");
470 $sth->execute($webvar{pool});
471 my ($pooltype, $poolcity) = $sth->fetchrow_array;
472
473 $page->param(disptype => $disp_alloctypes{$pooltype});
474 $page->param(city => $poolcity);
475
476 # Only display net/gw/bcast if it's a "real" netblock and not a PPP(oE) lunacy
477 $page->param(realblock => $pooltype =~ /^.d$/);
478
479# probably have to add an "edit IP allocation" link here somewhere.
480
481 $sth = $ip_dbh->prepare("select ip,custid,available,description,type".
482 " from poolips where pool='$webvar{pool}' order by ip");
483 $sth->execute;
484 my @poolips;
485 my $rowclass = 0;
486 while (my ($ip,$custid,$available,$desc,$type) = $sth->fetchrow_array) {
487 my %row = (
488 rowclass => $rowclass++ % 2,
489 ip => $ip,
490 custid => $custid,
491 available => $available,
492 desc => $desc,
493 maydel => $IPDBacl{$authuser} =~ /d/,
494 delme => $available eq 'n'
495 );
496 push @poolips, \%row;
497 }
498 $page->param(poolips => \@poolips);
499
500} # end listPool
501
502
503# Show "Add new allocation" page. Note that the actual page may
504# be one of two templates, and the lists come from the database.
505sub assignBlock {
506
507 if ($IPDBacl{$authuser} !~ /a/) {
508 $aclerr = 'addblock';
509 return;
510 }
511
512 # hack pthbttt eww
513 $webvar{block} = '' if !$webvar{block};
514
515# hmm. TMPL_IF block and TMPL_ELSE block on these instead?
516 $page->param(rowa => 'row'.($webvar{block} eq '' ? 1 : 0));
517 $page->param(rowb => 'row'.($webvar{block} eq '' ? 0 : 1));
518 $page->param(block => $webvar{block}); # fb-assign flag, if block is set, we're in fb-assign
519 $page->param(iscontained => ($webvar{fbtype} && $webvar{fbtype} ne 'y'));
520
521 # New special case- block to assign is specified
522 if ($webvar{block} ne '') {
523 my $block = new NetAddr::IP $webvar{block};
524
525 # Handle contained freeblock allocation.
526 # This is a little dangerous, as it's *theoretically* possible to
527 # get fbtype='n' (aka a non-routed freeblock). However, should
528 # someone manage to get there, they get what they deserve.
529 if ($webvar{fbtype} ne 'y') {
530 # Snag the type of the container block from the database.
531 $sth = $ip_dbh->prepare("select type from allocations where cidr >>='$block'");
532 $sth->execute;
533 my @data = $sth->fetchrow_array;
534 $data[0] =~ s/c$/r/; # Munge the type into the correct form
535 $page->param(fbdisptype => $list_alloctypes{$data[0]});
536 $page->param(type => $data[0]);
537 } else {
538 $sth = $ip_dbh->prepare("select type,listname from alloctypes where listorder < 500 ".
539 "and type not like '_i' and type not like '_r' order by listorder");
540 $sth->execute;
541 my @typelist;
542 my $selflag = 0;
543 while (my @data = $sth->fetchrow_array) {
544 my %row = (tval => $data[0],
545 type => $data[1],
546 sel => ($selflag == 0 ? ' selected' : '')
547 );
548 push (@typelist, \%row);
549 $selflag++;
550 }
551 $page->param(typelist => \@typelist);
552 }
553 } else {
554 my @masterlist;
555 foreach my $master (@masterblocks) {
556 my %row = (master => "$master");
557 push (@masterlist, \%row);
558 }
559 $page->param(masterlist => \@masterlist);
560
561 my @pops;
562 foreach my $pop (@poplist) {
563 my %row = (pop => $pop);
564 push (@pops, \%row);
565 }
566 $page->param(pops => \@pops);
567
568 # could arguably include routing (500) in the list, but ATM it doesn't
569 # make sense, and in any case that shouldn't be structurally possible here.
570 $sth = $ip_dbh->prepare("select type,listname from alloctypes where listorder <= 500 order by listorder");
571 $sth->execute;
572 my @typelist;
573 my $selflag = 0;
574 while (my @data = $sth->fetchrow_array) {
575 my %row = (tval => $data[0],
576 type => $data[1],
577 sel => ($selflag == 0 ? ' selected' : '')
578 );
579 push (@typelist, \%row);
580 $selflag++;
581 }
582 $page->param(typelist => \@typelist);
583 }
584
585 my @cities;
586 foreach my $city (@citylist) {
587 my %row = (city => $city);
588 push (@cities, \%row);
589 }
590 $page->param(citylist => \@cities);
591
592## node hack
593 $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id");
594 $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";
595 my @nodes;
596 while (my ($nid,$nname) = $sth->fetchrow_array()) {
597 my %row = (nid => $nid, nname => $nname);
598 push (@nodes, \%row);
599 }
600 $page->param(nodelist => \@nodes);
601## end node hack
602
603 $page->param(privdata => $IPDBacl{$authuser} =~ /s/);
604
605} # assignBlock
606
607
608# Take info on requested IP assignment and see what we can provide.
609sub confirmAssign {
610 if ($IPDBacl{$authuser} !~ /a/) {
611 $aclerr = 'addblock';
612 return;
613 }
614
615 my $cidr;
616 my $alloc_from;
617
618 # Going to manually validate some items.
619 # custid and city are automagic.
620 return if !validateInput();
621
622# Several different cases here.
623# Static IP vs netblock
624# + Different flavours of static IP
625# + Different flavours of netblock
626
627 if ($webvar{alloctype} =~ /^.i$/) {
628 my ($base,undef) = split //, $webvar{alloctype}; # split into individual chars
629
630# Ewww. But it works.
631 $sth = $ip_dbh->prepare("SELECT (SELECT city FROM allocations WHERE cidr=poolips.pool), ".
632 "poolips.pool, COUNT(*) FROM poolips,allocations WHERE poolips.available='y' AND ".
633 "poolips.pool=allocations.cidr AND allocations.city='$webvar{pop}' AND poolips.type LIKE '".$base."_' ".
634 "GROUP BY pool");
635 $sth->execute;
636 my $optionlist;
637
638 my @poollist;
639 while (my ($poolcit,$poolblock,$poolfree) = $sth->fetchrow_array) {
640 # city,pool cidr,free IP count
641 if ($poolfree > 0) {
642 my %row = (poolcit => $poolcit, poolblock => $poolblock, poolfree => $poolfree);
643 push (@poollist, \%row);
644 }
645 }
646 $page->param(staticip => 1);
647 $page->param(poollist => \@poollist);
648 $cidr = "Single static IP";
649##fixme: need to handle "no available pools"
650
651 } else { # end show pool options
652
653 if ($webvar{fbassign} eq 'y') {
654 $cidr = new NetAddr::IP $webvar{block};
655 $webvar{maskbits} = $cidr->masklen;
656 } else { # done with direct freeblocks assignment
657
658 if (!$webvar{maskbits}) {
659 $page->param(err => "Please specify a CIDR mask length.");
660 return;
661 }
662 my $sql;
663 my $city;
664 my $failmsg;
665 my $extracond = '';
666 if ($webvar{allocfrom} eq '-') {
667 $extracond = ($webvar{allowpriv} eq 'on' ? '' :
668 " and not (cidr <<= '192.168.0.0/16'".
669 " or cidr <<= '10.0.0.0/8'".
670 " or cidr <<= '172.16.0.0/12')");
671 }
672 my $sortorder;
673 if ($webvar{alloctype} eq 'rm') {
674 if ($webvar{allocfrom} ne '-') {
675 $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'".
676 " and cidr <<= '$webvar{allocfrom}'";
677 $sortorder = "maskbits desc";
678 } else {
679 $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'";
680 $sortorder = "maskbits desc";
681 }
682 $failmsg = "No suitable free block found.<br>\nWe do not have a free".
683 " routeable block of that size.<br>\nYou will have to either route".
684 " a set of smaller netblocks or a single smaller netblock.";
685 } else {
686##fixme
687# This section needs serious Pondering.
688 # Pools of most types get assigned to the POP they're "routed from"
689 # This includes WAN blocks and other netblock "containers"
690 # This does NOT include cable pools.
691 if ($webvar{alloctype} =~ /^.[pc]$/) {
692 $city = $webvar{city};
693 $failmsg = "No suitable free block found.<br>\nYou will have to route another".
694 " superblock from one of the<br>\nmaster blocks or chose a smaller".
695 " block size for the pool.";
696 } else {
697 if (!$webvar{pop}) {
698 $page->param(err => 'Please select a POP to route the block from/through.');
699 return;
700 }
701 $city = $webvar{pop};
702 $failmsg = "No suitable free block found.<br>\nYou will have to route another".
703 " superblock to $webvar{pop}<br>\nfrom one of the master blocks or".
704 " chose a smaller blocksize.";
705 }
706 if (defined $webvar{allocfrom} && $webvar{allocfrom} ne '-') {
707 $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
708 " and cidr <<= '$webvar{allocfrom}' and routed='".
709 (($webvar{alloctype} =~ /^(.)r$/) ? "$1" : 'y')."'";
710 $sortorder = "maskbits desc,cidr";
711 } else {
712 $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
713 " and routed='".(($webvar{alloctype} =~ /^(.)r$/) ? "$1" : 'y')."'";
714 $sortorder = "maskbits desc,cidr";
715 }
716 }
717 $sql = $sql.$extracond." order by ".$sortorder;
718 $sth = $ip_dbh->prepare($sql);
719 $sth->execute;
720 my @data = $sth->fetchrow_array();
721 if ($data[0] eq "") {
722 $page->param(err => $failmsg);
723 return;
724 }
725 $cidr = new NetAddr::IP $data[0];
726 } # check for freeblocks assignment or IPDB-controlled assignment
727
728 $alloc_from = "$cidr";
729
730 # If the block to be allocated is smaller than the one we found,
731 # figure out the "real" block to be allocated.
732 if ($cidr->masklen() ne $webvar{maskbits}) {
733 my $maskbits = $cidr->masklen();
734 my @subblocks;
735 while ($maskbits++ < $webvar{maskbits}) {
736 @subblocks = $cidr->split($maskbits);
737 }
738 $cidr = $subblocks[0];
739 }
740 } # if ($webvar{alloctype} =~ /^.i$/)
741
742## node hack
743 if ($webvar{node} && $webvar{node} ne '-') {
744 $sth = $ip_dbh->prepare("SELECT node_name FROM nodes WHERE node_id=?");
745 $sth->execute($webvar{node});
746 my ($nodename) = $sth->fetchrow_array();
747 $page->param(nodename => $nodename);
748 $page->param(nodeid => $webvar{node});
749 }
750## end node hack
751
752 # Stick in the allocation data
753 $page->param(alloc_type => $webvar{alloctype});
754 $page->param(typefull => $q->escapeHTML($disp_alloctypes{$webvar{alloctype}}));
755 $page->param(alloc_from => $alloc_from);
756 $page->param(cidr => $cidr);
757 $page->param(city => $q->escapeHTML($webvar{city}));
758 $page->param(custid => $webvar{custid});
759 $page->param(circid => $q->escapeHTML($webvar{circid}));
760 $page->param(desc => $q->escapeHTML($webvar{desc}));
761
762##fixme: find a way to have the displayed copy have <br> substitutions
763# for newlines, and the <input> value have either encoded or bare newlines.
764# Also applies to privdata.
765 $page->param(notes => $q->escapeHTML($webvar{notes},'y'));
766
767 # Check to see if user is allowed to do anything with sensitive data
768 my $privdata = '';
769 $page->param(privdata => $q->escapeHTML($webvar{privdata},'y'))
770 if $IPDBacl{$authuser} =~ /s/;
771
772 # Yay! This now has it's very own little home.
773 $page->param(billinguser => $webvar{userid})
774 if $webvar{userid};
775
776##fixme: this is only needed iff confirm.tmpl and
777# confirmRemove.tmpl are merged (quite possible, just
778# a little tedious)
779 $page->param(action => "insert");
780
781} # end confirmAssign
782
783
784# Do the work of actually inserting a block in the database.
785sub insertAssign {
786 if ($IPDBacl{$authuser} !~ /a/) {
787 $aclerr = 'addblock';
788 return;
789 }
790 # Some things are done more than once.
791 return if !validateInput();
792
793 if (!defined($webvar{privdata})) {
794 $webvar{privdata} = '';
795 }
796 # $code is "success" vs "failure", $msg contains OK for a
797 # successful netblock allocation, the IP allocated for static
798 # IP, or the error message if an error occurred.
799
800 my ($code,$msg) = allocateBlock($ip_dbh, $webvar{fullcidr}, $webvar{alloc_from},
801 $webvar{custid}, $webvar{alloctype}, $webvar{city}, $webvar{desc}, $webvar{notes},
802 $webvar{circid}, $webvar{privdata}, $webvar{node});
803
804 if ($code eq 'OK') {
805 if ($webvar{alloctype} =~ /^.i$/) {
806 $msg =~ s|/32||;
807 $page->param(staticip => $msg);
808 $page->param(custid => $webvar{custid});
809 $page->param(billinguser => $webvar{billinguser});
810 mailNotify($ip_dbh, "a$webvar{alloctype}", "ADDED: $disp_alloctypes{$webvar{alloctype}} allocation",
811 "$disp_alloctypes{$webvar{alloctype}} $msg allocated to customer $webvar{custid}\n".
812 "Description: $webvar{desc}\n\nAllocated by: $authuser\n");
813 } else {
814 my $netblock = new NetAddr::IP $webvar{fullcidr};
815 $page->param(fullcidr => $webvar{fullcidr});
816 $page->param(alloctype => $disp_alloctypes{$webvar{alloctype}});
817 $page->param(custid => $webvar{custid});
818 if ($webvar{alloctype} eq 'pr' && $webvar{billinguser}) {
819 $page->param(billinguser => $webvar{billinguser});
820 $page->param(custid => $webvar{custid});
821 $page->param(netaddr => $netblock->addr);
822 $page->param(masklen => $netblock->masklen);
823 }
824 mailNotify($ip_dbh, "a$webvar{alloctype}", "ADDED: $disp_alloctypes{$webvar{alloctype}} allocation",
825 "$disp_alloctypes{$webvar{alloctype}} $webvar{fullcidr} allocated to customer $webvar{custid}\n".
826 "Description: $webvar{desc}\n\nAllocated by: $authuser\n");
827 }
828 syslog "notice", "$authuser allocated '$webvar{fullcidr}' to '$webvar{custid}' as ".
829 "'$webvar{alloctype}' ($msg)";
830 } else {
831 syslog "err", "Allocation of '$webvar{fullcidr}' to '$webvar{custid}' as ".
832 "'$webvar{alloctype}' by $authuser failed: '$msg'";
833 $page->param(err => "Allocation of $webvar{fullcidr} as '$disp_alloctypes{$webvar{alloctype}}'".
834 " failed:<br>\n$msg\n");
835 }
836
837} # end insertAssign()
838
839
840# Does some basic checks on common input data to make sure nothing
841# *really* weird gets in to the database through this script.
842# Does NOT do complete input validation!!!
843sub validateInput {
844 if ($webvar{city} eq '-') {
845 $page->param(err => 'Please choose a city');
846 return;
847 }
848
849 # Alloctype check.
850 chomp $webvar{alloctype};
851 if (!grep /$webvar{alloctype}/, keys %disp_alloctypes) {
852 # Danger! Danger! alloctype should ALWAYS be set by a dropdown. Anyone
853 # managing to call things in such a way as to cause this deserves a cryptic error.
854 $page->param(err => 'Invalid alloctype');
855 return;
856 }
857
858 # CustID check
859 # We have different handling for customer allocations and "internal" or "our" allocations
860 if ($def_custids{$webvar{alloctype}} eq '') {
861 if (!$webvar{custid}) {
862 $page->param(err => 'Please enter a customer ID.');
863 return;
864 }
865 if ($webvar{custid} !~ /^(?:\d{10}|\d{7}|STAFF)(?:-\d\d?)?$/) {
866 # Force uppercase for now...
867 $webvar{custid} =~ tr/a-z/A-Z/;
868 # Crosscheck with billing.
869 my $status = CustIDCK->custid_exist($webvar{custid});
870 if ($CustIDCK::Error) {
871 $page->param(err => "Error verifying customer ID: ".$CustIDCK::ErrMsg);
872 return;
873 }
874 if (!$status) {
875 $page->param(err => "Customer ID not valid. Make sure the Customer ID ".
876 "is correct.<br>\nUse STAFF for staff static IPs, and $IPDB::defcustid for any other ".
877 "non-customer assignments.");
878 return;
879 }
880 }
881# print "<!-- [ In validateInput(). Insert customer ID cross-check here. ] -->\n";
882 } else {
883 # New! Improved! And now Loaded From The Database!!
884 if ((!$webvar{custid}) || ($webvar{custid} ne 'STAFF')) {
885 $webvar{custid} = $def_custids{$webvar{alloctype}};
886 }
887 }
888
889 # Check POP location
890 my $flag;
891 if ($webvar{alloctype} eq 'rm') {
892 $flag = 'for a routed netblock';
893 foreach (@poplist) {
894 if (/^$webvar{city}$/) {
895 $flag = 'n';
896 last;
897 }
898 }
899 } else {
900 $flag = 'n';
901##fixme: hook to force-set POP or city on certain alloctypes
902# if ($webvar{alloctype =~ /foo,bar,bz/ { $webvar{pop} = 'blah'; }
903 if ($webvar{pop} =~ /^-$/) {
904 $flag = 'to route the block from/through';
905 }
906 }
907
908 # if the alloctype has a restricted city/POP list as determined above,
909 # and the reqested city/POP does not match that list, complain
910 if ($flag ne 'n') {
911 $page->param(err => "Please choose a valid POP location $flag. Valid ".
912 "POP locations are currently:<br>\n".join (" - ", @poplist));
913 return;
914 }
915
916 return 'OK';
917} # end validateInput
918
919
920# Displays details of a specific allocation in a form
921# Allows update/delete
922# action=edit
923sub edit {
924
925 my $sql;
926
927 # Two cases: block is a netblock, or block is a static IP from a pool
928 # because I'm lazy, we'll try to make the SELECT's bring out identical)ish) data
929##fixme: allow "SWIP" (publication to rWHOIS) of static IP data
930 if ($webvar{block} =~ /\/32$/) {
931 $sql = "select ip,custid,type,city,circuitid,description,notes,modifystamp,privdata from poolips where ip='$webvar{block}'";
932 } else {
933 $sql = "select cidr,custid,type,city,circuitid,description,notes,modifystamp,privdata,swip from allocations where cidr='$webvar{block}'"
934 }
935
936 # gotta snag block info from db
937 $sth = $ip_dbh->prepare($sql);
938 $sth->execute;
939 my @data = $sth->fetchrow_array;
940
941 # Clean up extra whitespace on alloc type
942 $data[2] =~ s/\s//;
943
944 # We can't let the city be changed here; this block is a part of
945 # a larger routed allocation and therefore by definition can't be moved.
946 # block and city are static.
947##fixme
948# Needs thinking. Have to allow changes to city to correct errors, no?
949# Also have areas where a routed block at a POP serves "many" cities/towns/named crossroads
950
951# @data: cidr,custid,type,city,circuitid,description,notes,modifystamp,privdata,swip
952
953 $page->param(block => $webvar{block});
954
955 $page->param(custid => $data[1]);
956 $page->param(city => $data[3]);
957 $page->param(circid => $data[4]);
958 $page->param(desc => $data[5]);
959 $page->param(notes => $data[6]);
960
961##fixme The check here should be built from the database
962# Need to expand to support pool types too
963 if ($data[2] =~ /^.[ne]$/ && $IPDBacl{$authuser} =~ /c/) {
964 $page->param(changetype => 1);
965 $page->param(alloctype => [
966 { selme => ($data[2] eq 'me'), type => "me", disptype => "Dialup netblock" },
967 { selme => ($data[2] eq 'de'), type => "de", disptype => "Dynamic DSL netblock" },
968 { selme => ($data[2] eq 'ce'), type => "ce", disptype => "Dynamic cable netblock" },
969 { selme => ($data[2] eq 'we'), type => "we", disptype => "Dynamic wireless netblock" },
970 { selme => ($data[2] eq 'cn'), type => "cn", disptype => "Customer netblock" },
971 { selme => ($data[2] eq 'en'), type => "en", disptype => "End-use netblock" },
972 { selme => ($data[2] eq 'in'), type => "in", disptype => "Internal netblock" },
973 ]
974 );
975 } else {
976 $page->param(disptype => $disp_alloctypes{$data[2]});
977 $page->param(type => $data[2]);
978 }
979
980## node hack
981 $sth = $ip_dbh->prepare("SELECT nodes.node_id,node_name FROM nodes INNER JOIN noderef".
982 " ON nodes.node_id=noderef.node_id WHERE noderef.block='$webvar{block}'");
983 $sth->execute;
984 my ($nodeid,$nodename) = $sth->fetchrow_array();
985 $page->param(havenodeid => $nodeid);
986
987 if ($data[2] eq 'fr' || $data[2] eq 'bi') {
988 $page->param(typesupportsnodes => 1);
989 $page->param(nodename => $nodename);
990
991##fixme: this whole hack needs cleanup and generalization for all alloctypes
992##fixme: arguably a bug that presence of a nodeid implies it can be changed..
993# but except for manual database changes, only the two types fr and bi can
994# (currently) have a nodeid set in the first place.
995 if ($IPDBacl{$authuser} =~ /c/) {
996 $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id");
997 $sth->execute;
998 my @nodelist;
999 while (my ($nid,$nname) = $sth->fetchrow_array()) {
1000 my %row = (
1001 selme => ($nodeid == $nid),
1002 nodeid => $nid,
1003 nodename => $nname,
1004 );
1005 push (@nodelist, \%row);
1006 }
1007 $page->param(nodelist => \@nodelist);
1008 }
1009 }
1010## end node hack
1011
1012 my ($lastmod,undef) = split /\s+/, $data[7];
1013 $page->param(lastmod => $lastmod);
1014
1015 # not happy with the upside-down logic, but...
1016 $page->param(swipable => $data[2] !~ /.i/);
1017 $page->param(swip => $data[10] ne 'n');
1018
1019 # Check to see if we can display sensitive data
1020 $page->param(nocling => $IPDBacl{$authuser} =~ /s/);
1021 $page->param(privdata => $data[8]);
1022
1023 # ACL trickery - these two template booleans control the presence of all form/input tags
1024 $page->param(maychange => $IPDBacl{$authuser} =~ /c/);
1025 $page->param(maydel => $IPDBacl{$authuser} =~ /d/);
1026
1027} # edit()
1028
1029
1030# Stuff new info about a block into the db
1031# action=update
1032sub update {
1033 if ($IPDBacl{$authuser} !~ /c/) {
1034 $aclerr = 'updateblock';
1035 return;
1036 }
1037
1038 # Check to see if we can update restricted data
1039 my $privdata = '';
1040 if ($IPDBacl{$authuser} =~ /s/) {
1041 $privdata = ",privdata='$webvar{privdata}'";
1042 }
1043
1044 # Make sure incoming data is in correct format - custID among other things.
1045 return if !validateInput;
1046
1047 # SQL transaction wrapper
1048 eval {
1049 # Relatively simple SQL transaction here.
1050 my $sql;
1051 if (my $pooltype = ($webvar{alloctype} =~ /^(.)i$/) ) {
1052 $sql = "UPDATE poolips SET custid='$webvar{custid}',".
1053 "city=?,description=?,notes=?,".
1054 "circuitid='$webvar{circid}',".
1055 "$privdata where ip='$webvar{block}'";
1056 } else {
1057 $sql = "UPDATE allocations SET custid='$webvar{custid}',".
1058 "city=?,description=?,notes=?,".
1059 "circuitid='$webvar{circid}'$privdata,".
1060 "type='$webvar{alloctype}',".
1061 "swip='".($webvar{swip} eq 'on' ? 'y' : 'n')."' ".
1062 "where cidr='$webvar{block}'";
1063 }
1064 # Log the details of the change.
1065 syslog "debug", $sql;
1066 $sth = $ip_dbh->prepare($sql);
1067 $sth->execute($webvar{city}, $webvar{desc}, $webvar{notes});
1068## node hack
1069 if ($webvar{node}) {
1070 # done with delete/insert so we don't have to worry about funkyness updating a node ref that isn't there
1071 $ip_dbh->do("DELETE FROM noderef WHERE block='$webvar{block}'");
1072 $sth = $ip_dbh->prepare("INSERT INTO noderef (block,node_id) VALUES (?,?)");
1073 $sth->execute($webvar{block},$webvar{node});
1074 }
1075## end node hack
1076 $ip_dbh->commit;
1077 };
1078 if ($@) {
1079 my $msg = $@;
1080 eval { $ip_dbh->rollback; };
1081 syslog "err", "$authuser could not update block/IP '$webvar{block}': '$msg'";
1082 $page->param(err => "Could not update block/IP $webvar{block}: $msg");
1083 return;
1084 }
1085
1086 # If we get here, the operation succeeded.
1087 syslog "notice", "$authuser updated $webvar{block}";
1088##fixme: need to wedge something in to allow "update:field" notifications
1089## hmm. how to tell what changed? O_o
1090mailNotify($ip_dbh, 's:swi', "SWIPed: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",
1091 "$webvar{block} had SWIP status changed to \"Yes\" by $authuser") if $webvar{swip} eq 'on';
1092
1093## node hack
1094 if ($webvar{node} && $webvar{node} ne '-') {
1095 $sth = $ip_dbh->prepare("SELECT node_name FROM nodes WHERE node_id=?");
1096 $sth->execute($webvar{node});
1097 my ($nodename) = $sth->fetchrow_array();
1098 $page->param(nodename => $nodename);
1099 }
1100## end node hack
1101
1102 # Link back to browse-routed or list-pool page on "Update complete" page.
1103 my $cblock; # to contain the CIDR of the container block we're retrieving.
1104 my $sql;
1105 if (my $pooltype = ($webvar{alloctype} =~ /^(.)i$/) ) {
1106 $page->param(backpool => 1);
1107 $sql = "select pool from poolips where ip='$webvar{block}'";
1108 } else {
1109 $sql = "select cidr from routed where cidr >>= '$webvar{block}'";
1110 }
1111 # I define there to be no errors on this operation... so we don't need to check for them.
1112 $sth = $ip_dbh->prepare($sql);
1113 $sth->execute;
1114 $sth->bind_columns(\$cblock);
1115 $sth->fetch();
1116 $sth->finish;
1117 $page->param(backblock => $cblock);
1118
1119 $page->param(cidr => $webvar{block});
1120 $page->param(city => $webvar{city});
1121 $page->param(disptype => $disp_alloctypes{$webvar{alloctype}});
1122 $page->param(custid => $webvar{custid});
1123 $page->param(swip => $webvar{swip} eq 'on' ? 'Yes' : 'No');
1124 $page->param(circid => $q->escapeHTML($webvar{circid}));
1125 $page->param(desc => $q->escapeHTML($webvar{desc}));
1126 $page->param(notes => $q->escapeHTML($webvar{notes}));
1127 $webvar{privdata} = ($webvar{privdata} ? $q->escapeHTML($webvar{privdata}) : "&nbsp;");
1128 $page->param(privdata => $webvar{privdata})
1129 if $IPDBacl{$authuser} =~ /s/;
1130
1131} # update()
1132
1133
1134# Delete an allocation.
1135sub remove {
1136 if ($IPDBacl{$authuser} !~ /d/) {
1137 $aclerr = 'delblock';
1138 return;
1139 }
1140
1141 # Serves'em right for getting here...
1142 if (!defined($webvar{block})) {
1143 $page->param(err => "Can't delete a block that doesn't exist");
1144 return;
1145 }
1146
1147 my ($cidr, $custid, $type, $city, $circid, $desc, $notes, $alloctype, $privdata);
1148
1149 if ($webvar{alloctype} eq 'rm') {
1150 $sth = $ip_dbh->prepare("select cidr,city from routed where cidr='$webvar{block}'");
1151 $sth->execute();
1152
1153# This feels... extreme.
1154 croak $sth->errstr() if($sth->errstr());
1155
1156 $sth->bind_columns(\$cidr,\$city);
1157 $sth->execute();
1158 $sth->fetch || croak $sth->errstr();
1159 $custid = "N/A";
1160 $alloctype = $webvar{alloctype};
1161 $circid = "N/A";
1162 $desc = "N/A";
1163 $notes = "N/A";
1164 $privdata = "N/A";
1165
1166 } elsif ($webvar{alloctype} eq 'mm') {
1167
1168 $cidr = $webvar{block};
1169 $city = "N/A";
1170 $custid = "N/A";
1171 $alloctype = $webvar{alloctype};
1172 $circid = "N/A";
1173 $desc = "N/A";
1174 $notes = "N/A";
1175 $privdata = "N/A";
1176
1177 } elsif ($webvar{alloctype} =~ /^.i$/) { # done with alloctype=[rm]m
1178
1179 # Unassigning a static IP
1180 my $sth = $ip_dbh->prepare("select ip,custid,city,type,notes,circuitid,privdata".
1181 " from poolips where ip='$webvar{block}'");
1182 $sth->execute();
1183# croak $sth->errstr() if($sth->errstr());
1184
1185 $sth->bind_columns(\$cidr, \$custid, \$city, \$alloctype, \$notes, \$circid,
1186 \$privdata);
1187 $sth->fetch() || croak $sth->errstr;
1188
1189 } else { # done with alloctype=~ /^.i$/
1190
1191 my $sth = $ip_dbh->prepare("select cidr,custid,type,city,circuitid,description,notes,privdata".
1192 " from allocations where cidr='$webvar{block}'");
1193 $sth->execute();
1194# croak $sth->errstr() if($sth->errstr());
1195
1196 $sth->bind_columns(\$cidr, \$custid, \$alloctype, \$city, \$circid, \$desc,
1197 \$notes, \$privdata);
1198 $sth->fetch() || carp $sth->errstr;
1199 } # end cases for different alloctypes
1200
1201 $page->param(block => $cidr);
1202 $page->param(disptype => $disp_alloctypes{$alloctype});
1203 $page->param(type => $alloctype);
1204 $page->param(city => $city);
1205 $page->param(custid => $custid);
1206 $page->param(circid => $circid);
1207 $page->param(desc => $desc);
1208 $page->param(notes => $notes);
1209 $privdata = '&nbsp;' if $privdata eq '';
1210 $page->param(privdata => $privdata) if $IPDBacl{$authuser} =~ /s/;
1211 $page->param(delpool => $alloctype =~ /^.[pd]$/);
1212
1213} # end remove()
1214
1215
1216# Delete an allocation. Return it to the freeblocks table; munge
1217# data as necessary to keep as few records as possible in freeblocks
1218# to prevent weirdness when allocating blocks later.
1219# Remove IPs from pool listing if necessary
1220sub finalDelete {
1221 if ($IPDBacl{$authuser} !~ /d/) {
1222 $aclerr = 'delblock';
1223 return;
1224 }
1225
1226 # need to retrieve block data before deleting so we can notify on that
1227 my ($cidr,$custid,$type,$city,$description) = getBlockData($ip_dbh, $webvar{block});
1228
1229 my ($code,$msg) = deleteBlock($ip_dbh, $webvar{block}, $webvar{alloctype});
1230
1231 $page->param(block => $webvar{block});
1232 if ($code eq 'OK') {
1233 syslog "notice", "$authuser deallocated '$webvar{alloctype}'-type netblock $webvar{block}".
1234 " $custid, $city, desc='$description'";
1235 mailNotify($ip_dbh, 'da', "REMOVED: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",
1236 "$disp_alloctypes{$webvar{alloctype}} $webvar{block} deallocated by $authuser\n".
1237 "CustID: $custid\nCity: $city\nDescription: $description\n");
1238 } else {
1239 $page->param(failmsg => $msg);
1240 if ($webvar{alloctype} =~ /^.i$/) {
1241 syslog "err", "$authuser could not deallocate static IP '$webvar{block}': '$msg'";
1242 } else {
1243 syslog "err", "$authuser could not deallocate netblock '$webvar{block}': '$msg'";
1244 $page->param(netblock => 1);
1245 }
1246 }
1247
1248} # finalDelete
Note: See TracBrowser for help on using the repository browser.