source: branches/htmlform/cgi-bin/main.cgi@ 507

Last change on this file since 507 was 505, checked in by Kris Deugau, 13 years ago

/branches/htmlform

Clean up final reference to printError(), and remove all references
(commented or otherwise) to CommonWeb.pm. Remove the file itself. See #15.
Tweak block-update template for error handling. See #3.

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