source: trunk/cgi-bin/admin.cgi@ 642

Last change on this file since 642 was 642, checked in by Kris Deugau, 10 years ago

/trunk

Commit really old work in admin.cgi adding rDNS

  • allocate block
  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author
File size: 19.1 KB
Line 
1#!/usr/bin/perl
2# ipdb/cgi-bin/admin.cgi
3# Hack interface to make specific changes to IPDB that (for one reason
4# or another) can't be made through the main interface.
5#
6###
7# SVN revision info
8# $Date: 2014-10-17 20:55:34 +0000 (Fri, 17 Oct 2014) $
9# SVN revision $Rev: 642 $
10# Last update by $Author: kdeugau $
11###
12# Copyright (C) 2004-2010 - Kris Deugau
13
14use strict;
15use warnings;
16use CGI::Carp qw(fatalsToBrowser);
17use CGI::Simple;
18use HTML::Template;
19use DBI;
20#use POSIX qw(ceil);
21use NetAddr::IP;
22
23use Sys::Syslog;
24
25# don't remove! required for GNU/FHS-ish install from tarball
26##uselib##
27
28use CustIDCK;
29use MyIPDB;
30
31openlog "IPDB-admin","pid","$IPDB::syslog_facility";
32
33# Collect the username from HTTP auth. If undefined, we're in a test environment.
34my $authuser;
35if (!defined($ENV{'REMOTE_USER'})) {
36 $authuser = '__temptest';
37} else {
38 $authuser = $ENV{'REMOTE_USER'};
39}
40
41syslog "debug", "$authuser active";
42
43# Set up the CGI object...
44my $q = new CGI::Simple;
45# ... and get query-string params as well as POST params if necessary
46$q->parse_query_string;
47
48# Convenience; saves changing all references to %webvar
49##fixme: tweak for handling <select multiple='y' size=3> (list with multiple selection)
50my %webvar = $q->Vars;
51
52# anyone got a better name? :P
53my $thingroot = $ENV{SCRIPT_FILENAME};
54$thingroot =~ s|cgi-bin/admin.cgi||;
55
56# Set up some globals
57$ENV{HTML_TEMPLATE_ROOT} = $thingroot."templates";
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
71if(!defined($webvar{action})) {
72 $webvar{action} = "main"; #shuts up the warnings.
73}
74
75# handle DB error output
76if ($webvar{action} eq 'dberr') {
77 my $page = HTML::Template->new(filename => "admin/dberr.tmpl");
78 $page->param(errmsg => $errstr);
79 print "Content-Type: text/html\n\n".$page->output;
80 exit;
81}
82
83if ($IPDBacl{$authuser} !~ /A/) {
84 my $page = HTML::Template->new(filename => "admin/aclerr.tmpl");
85##fixme: need params for IPDB admin email and name
86 $page->param(ipdbadmin_email => 'ipdbadmin@example.com');
87 $page->param(ipdbadmin_name => 'the IPDB administrator');
88 print "Content-Type: text/html\n\n".$page->output;
89 exit;
90}
91
92my $header = HTML::Template->new(filename => "admin/header.tmpl");
93$header->param(mainpage => 1) if $webvar{action} eq 'main';
94print "Content-type: text/html\n\n".$header->output;
95
96my $page;
97if (-e "$ENV{HTML_TEMPLATE_ROOT}/admin/$webvar{action}.tmpl") {
98 $page = HTML::Template->new(filename => "admin/$webvar{action}.tmpl");
99} else {
100 $page = HTML::Template->new(filename => "admin/dunno.tmpl");
101}
102
103# handle index page
104if ($webvar{action} eq 'main') {
105 my $tlist = getTypeList($ip_dbh, 'a');
106 $tlist->[0]->{sel} = 1;
107 $page->param(typelist => $tlist);
108
109 my $mlist = getMasterList($ip_dbh, 'm');
110 $page->param(masterlist => $mlist);
111}
112
113## Non-default actions.
114
115elsif ($webvar{action} eq 'alloc') {
116
117 my $cidr = new NetAddr::IP $webvar{cidr};
118 if (!$cidr || "$cidr" =~ /^0/) {
119 $page->param(errmsg => "Can't allocate something that's not a netblock/ip");
120 goto ERRJUMP;
121 }
122
123 my $custid = $def_custids{$webvar{alloctype}};
124 if ($custid eq '') {
125 # Crosscheck with billing.
126 my $status = CustIDCK->custid_exist($webvar{custid});
127 if ($CustIDCK::Error) {
128 $page->param(errmsg => "Error verifying customer ID: ".$CustIDCK::ErrMsg);
129 goto ERRJUMP;
130 }
131 if (!$status) {
132 $page->param(errmsg => "Customer ID not valid. Make sure the Customer ID ".
133 "is correct.<br>\nUse STAFF for staff static IPs, and $IPDB::defcustid for any other ".
134 "non-customer assignments.");
135 goto ERRJUMP;
136 }
137 # Type that doesn't have a default custid
138 $custid = $webvar{custid};
139 }
140
141 my $maskbits = $cidr->masklen;
142 my ($fbid, $fb, $fbparent);
143 ($fbid, $fb, $fbparent) = findAllocateFrom($ip_dbh, $maskbits, $webvar{alloctype}, '','',
144 (gimme => "$cidr", allowpriv => 1));
145 $page->param(fbid => $fbid);
146 $page->param(parid => $fbparent);
147 my $rdns = getBlockRDNS($ip_dbh, id => $fbparent, type => ($webvar{alloctype} =~ /^.i$/ ? 'i' : 'b'),
148 user => $authuser);
149 $page->param(rdns => $rdns);
150 if ($webvar{alloctype} =~ /^(.)i$/) {
151 my $iptype = $1;
152 my $ptmp = getBlockData($ip_dbh, $fbparent);
153 if ($ptmp->{type} =~ /^(.)[dp]$/) {
154 my $newiptype = "$1i";
155 if ($ptmp->{type} !~ /^$iptype./) {
156 $page->param(warnmsg => "Warning: Allocating IP as '".$disp_alloctypes{$newiptype}."' instead of '".
157 $disp_alloctypes{$webvar{alloctype}}."' to match pool ".$ptmp->{block}."\n");
158 $webvar{alloctype} = $newiptype;
159 }
160 }
161 if (!$fbid) {
162 $page->param(errmsg => "Can't allocate static IP from outside a pool!!");
163 goto ERRJUMP;
164 }
165 } else {
166 if (!$fbid) {
167 $page->param(errmsg => "Can't allocate from outside a free block!!");
168 goto ERRJUMP;
169 }
170 }
171
172 my $alloc_from = new NetAddr::IP $fb;
173
174 my @cities;
175 foreach my $city (@citylist) {
176 my %row = (city => $city);
177 push @cities, \%row;
178 }
179 $page->param(
180 cidr => $cidr,
181 disptype => $disp_alloctypes{$webvar{alloctype}},
182 type => $webvar{alloctype},
183 alloc_from => $alloc_from,
184 custid => $custid,
185 citylist => \@cities
186 );
187
188} elsif ($webvar{action} eq 'confirm') {
189
190 $page->param(
191 cidr => $webvar{cidr},
192 custid => $webvar{custid},
193 desc => $webvar{desc},
194 disptype => $disp_alloctypes{$webvar{alloctype}}
195 );
196 # Only need to check city here.
197 if ($webvar{city} eq '-') {
198 $page->param(locerr => "Invalid customer location! Go back and select customer's location.");
199 goto ERRJUMP;
200 }
201
202 my ($retcode,$msg) = allocateBlock($ip_dbh, cidr => $webvar{cidr}, fbid => $webvar{fbid},
203 parent => $webvar{parent}, custid => $webvar{custid}, type => $webvar{alloctype}, city => $webvar{city},
204 desc => $webvar{desc}, notes => $webvar{notes}, circid => $webvar{circid},
205 privdata => $webvar{privdata}, nodeid => $webvar{node}, rdns => $webvar{rdns}, user => $authuser);
206
207 if ($retcode eq 'OK') {
208 syslog "notice", "$authuser allocated '$webvar{cidr}' to '$webvar{custid}' as ".
209 "'$webvar{alloctype}'";
210 if ($webvar{alloctype} =~ /^.i$/) {
211 mailNotify($ip_dbh, "a$webvar{alloctype}", "ADDED: $disp_alloctypes{$webvar{alloctype}} allocation",
212 "$disp_alloctypes{$webvar{alloctype}} $webvar{cidr} allocated to customer $webvar{custid}\n".
213 "Description: $webvar{desc}\n\nAllocated by: $authuser\n");
214 }
215 } else {
216 $page->param(errmsg => $msg);
217 syslog "err", "($authuser) Allocation of '$webvar{cidr}' to '$webvar{custid}' as ".
218 "'$webvar{alloctype}' failed: '$msg'";
219 }
220
221} elsif ($webvar{action} eq 'alloctweak') {
222
223 fix_allocfrom();
224 showAllocs($webvar{allocfrom});
225
226} elsif ($webvar{action} eq 'update') {
227
228 update();
229
230} elsif ($webvar{action} eq 'touch') {
231
232 my ($code,$msg) = touchMaster($ip_dbh, $webvar{whichmaster});
233 $page->param(errmsg => $msg) if $code eq 'FAIL';
234
235} elsif ($webvar{action} eq 'listcust') {
236
237 $sth = $ip_dbh->prepare("select custid,name,tech_handle from customers order by custid");
238 $sth->execute;
239 my @custlist;
240 while (my @data = $sth->fetchrow_array) {
241 my %row = (
242 custid => $data[0],
243 custname => $data[1],
244 tech => $data[2]
245 );
246 push @custlist, \%row;
247 }
248 $page->param(custlist => \@custlist);
249
250} elsif ($webvar{action} eq 'edcust') {
251
252 if ($webvar{newcust}) {
253 $sth = $ip_dbh->prepare("INSERT INTO customers (custid) VALUES (?)");
254 $sth->execute($webvar{custid});
255 }
256 $sth = $ip_dbh->prepare("select custid,name,street,city,province,".
257 "country,pocode,phone,tech_handle,abuse_handle,admin_handle,special ".
258 "from customers where custid='$webvar{custid}'");
259 $sth->execute;
260 my ($custid, $name, $street, $city, $prov, $country, $pocode, $phone, $tech, $abuse, $admin, $special) =
261 $sth->fetchrow_array;
262
263 $page->param(
264 custid => $custid,
265 name => $name,
266 street => $street,
267 city => $city,
268 prov => $prov,
269 country => $country,
270 pocode => $pocode,
271 phone => $phone,
272 tech => $tech,
273 abuse => $abuse,
274 admin => $admin,
275 special => $special
276 );
277
278} elsif ($webvar{action} eq 'updcust') {
279
280 $sth = $ip_dbh->prepare("UPDATE customers SET".
281 " name=?, street=?, city=?, province=?, country=?, pocode=?,".
282 " phone=?, tech_handle=?, abuse_handle=?, admin_handle=?, special=?".
283 " WHERE custid=?");
284 $sth->execute($webvar{name}, $webvar{street}, $webvar{city}, $webvar{province},
285 $webvar{country}, $webvar{pocode}, $webvar{phone}, $webvar{tech_handle},
286 $webvar{abuse_handle}, $webvar{admin_handle}, $webvar{special}, $webvar{custid});
287 $page->param(
288 custid => $webvar{custid},
289 name => $webvar{name},
290 street => $webvar{street},
291 city => $webvar{city},
292 prov => $webvar{province},
293 country => $webvar{country},
294 pocode => $webvar{pocode},
295 phone => $webvar{phone},
296 tech => $webvar{tech_handle},
297 abuse => $webvar{abuse_handle},
298 admin => $webvar{admin_handle},
299 special => $webvar{special}
300 );
301
302} elsif ($webvar{action} eq 'showpools') {
303
304 $sth = $ip_dbh->prepare("select pool, count(*) from poolips where available='y' group by pool order by pool");
305 $sth->execute;
306 my @poollist;
307 while (my ($pool,$free) = $sth->fetchrow_array) {
308 my %row = (
309 pool => $pool,
310 free => $free
311 );
312 push @poollist, \%row;
313 }
314 $page->param(poollist => \@poollist);
315
316} elsif ($webvar{action} eq 'tweakpool') {
317
318 showPool($webvar{pool});
319
320} elsif ($webvar{action} eq 'updatepool') {
321
322 $sth = $ip_dbh->prepare("update poolips set custid='$webvar{custid}', ".
323 "city=?, type='$webvar{type}', available='".
324 (($webvar{available} eq 'y') ? 'y' : 'n').
325 "', notes=?, description=? ".
326 "where ip='$webvar{ip}'");
327 $sth->execute($webvar{city},$webvar{notes},$webvar{desc});
328 $page->param(ip => $webvar{ip});
329 if ($sth->err) {
330 $page->param(errmsg => $sth->errstr);
331 syslog "err", "$authuser could not update pool IP $webvar{ip}: ".$sth->errstr;
332 } else {
333 syslog "notice", "$authuser updated pool IP $webvar{ip}";
334 }
335 $sth = $ip_dbh->prepare("select pool from poolips where ip='$webvar{ip}'");
336 $sth->execute;
337 my @data = $sth->fetchrow_array;
338 $page->param(pool => $data[0]);
339
340} elsif ($webvar{action} eq 'showusers') {
341
342 $sth = $ip_dbh->prepare("select username,acl from users order by username");
343 $sth->execute;
344 my @userlist;
345 while (my ($username,$acl) = $sth->fetchrow_array) {
346##fixme: funky things happening with HTML::Template here; shouldn't need the "logic ? iftrue : iffalse" structure
347 my %row = (
348 username => $username,
349 can_add => ($acl =~ /a/ ? 1 : 0),
350 can_change => ($acl =~ /c/ ? 1 : 0),
351 can_del => ($acl =~ /d/ ? 1 : 0),
352 sysnet => ($acl =~ /s/ ? 1 : 0),
353 is_admin => ($acl =~ /A/ ? 1 : 0),
354 acl => $acl
355 );
356 push @userlist, \%row;
357 }
358 $page->param(userlist => \@userlist);
359
360} elsif ($webvar{action} eq 'updacl') {
361
362 $page->param(username => $webvar{username});
363 my $acl = 'b';
364 if ($webvar{admin} eq 'on') {
365 $acl .= "acdsA";
366 } else {
367 $acl .= ($webvar{add} eq 'on' ? 'a' : '').
368 ($webvar{change} eq 'on' ? 'c' : '').
369 ($webvar{del} eq 'on' ? 'd' : '').
370 ($webvar{sysnet} eq 'on' ? 's' : '');
371 }
372 $page->param(acl => $acl);
373
374 $sth = $ip_dbh->prepare("update users set acl='$acl' where username='$webvar{username}'");
375 $sth->execute;
376 $page->param(errmsg => $sth->errstr) if $sth->err;
377
378} elsif ($webvar{action} eq 'newuser') {
379
380 $page->param(username => $webvar{username});
381 my $cr_pass = ($webvar{preenc} ? $webvar{password} :
382 crypt $webvar{password}, join('',('.','/',0..9,'A'..'Z','a'..'z')[rand 64, rand 64]));
383 $sth = $ip_dbh->prepare("insert into users (username,password,acl) values ".
384 "('$webvar{username}','$cr_pass','b')");
385 $sth->execute;
386 $page->param(errmsg => $sth->errstr) if $sth->err;
387
388} elsif ($webvar{action} eq 'deluser') {
389
390 $page->param(username => $webvar{username});
391 $sth = $ip_dbh->prepare("delete from users where username='$webvar{username}'");
392 $sth->execute;
393 $page->param(errmsg => $sth->errstr) if $sth->err;
394
395} elsif ($webvar{action} eq 'emailnotice') {
396
397 $sth = $ip_dbh->prepare("SELECT action,reciplist FROM notify");
398 $sth->execute;
399 my @spamlist;
400 while (my ($notice_code,$reciplist) = $sth->fetchrow_array() ) {
401##fixme: hairy mess, only a few things call mailNotify() anyway, so many possible notices won't work.
402 my $action_out = dispNoticeCode($notice_code);
403 my %row = (
404 action => $action_out,
405 code => $notice_code,
406 recips => $reciplist
407 );
408 push @spamlist, \%row;
409 }
410 $page->param(spamlist => \@spamlist);
411
412 $sth = $ip_dbh->prepare("SELECT type,dispname FROM alloctypes WHERE listorder < 500 ".
413 "ORDER BY listorder");
414 $sth->execute;
415 my $i=0;
416 my @typelist;
417 while (my ($type,$disp) = $sth->fetchrow_array) {
418 my %row = (
419 type => $type,
420 disptype => $disp,
421# ahh, off-by-one counts, how we do love thee... NOT!
422 newrow => ($i+2 > $sth->rows ? 1 : (++$i % 4)),
423 );
424 push @typelist, \%row;
425 }
426 $page->param(typelist => \@typelist);
427
428} elsif ($webvar{action} eq 'addnotice') {
429
430 $webvar{alloctype} = $webvar{special} if $webvar{msgaction} eq 's:';
431 if ($webvar{msgaction} && $webvar{alloctype} && $webvar{reciplist}) {
432 $page->param(cantry => 1);
433 $webvar{reciplist} =~ s/[\r\n]+/,/g;
434 $webvar{msgaction} = "f:$webvar{msgaction}" if $webvar{onfail};
435 $page->param(reciplist => $webvar{reciplist});
436 $page->param(dispnotice => dispNoticeCode($webvar{msgaction}.$webvar{alloctype}));
437 $sth = $ip_dbh->prepare("INSERT INTO notify (action, reciplist) VALUES (?,?)");
438##fixme: automagically merge reciplists iff action already exists
439 $sth->execute($webvar{msgaction}.$webvar{alloctype}, $webvar{reciplist});
440 $page->param(addfailed => $sth->errstr) if $sth->err;
441 }
442
443} elsif ($webvar{action} eq 'delnotice') {
444
445 $page->param(dispnotice => dispNoticeCode($webvar{code}.$webvar{alloctype}));
446 $sth = $ip_dbh->prepare("DELETE FROM notify WHERE action=?");
447 $sth->execute($webvar{code});
448 $page->param(delfailed => $sth->errstr) if $sth->err;
449
450} elsif ($webvar{action} eq 'ednotice') {
451
452 $page->param(dispnotice => dispNoticeCode($webvar{code}));
453 $page->param(code => $webvar{code});
454 $sth = $ip_dbh->prepare("SELECT reciplist FROM notify WHERE action=?");
455 $sth->execute($webvar{code});
456 my ($reciplist) = $sth->fetchrow_array;
457 $reciplist =~ s/,/\n/g;
458 $page->param(reciplist => $reciplist);
459
460} elsif ($webvar{action} eq 'updnotice') {
461
462 $page->param(dispnotice => dispNoticeCode($webvar{code}));
463 $sth = $ip_dbh->prepare("UPDATE notify SET reciplist=? WHERE action=?");
464 $webvar{reciplist} =~ s/[\r\n]+/,/g;
465 $sth->execute($webvar{reciplist}, $webvar{code});
466 $page->param(updfailed => $sth->errstr) if $sth->err;
467
468} elsif ($webvar{action} ne '<NULL>') {
469 $page->param(dunno => $webvar{action});
470}
471
472ERRJUMP: print "Content-type: text/html\n\n".$header->output;
473print $page->output;
474
475##fixme: make me a footer param!
476print qq(<hr><div><a href="$IPDB::webpath/">Back</a> to main interface</div>\n);
477
478# We print the footer here, so we don't have to do it elsewhere.
479my $footer = HTML::Template->new(filename => "footer.tmpl");
480# we're already in the admin tools, no need to provide a bottom link. maybe.
481#$footer->param(adminlink => ($IPDBacl{$authuser} =~ /A/));
482
483print $footer->output;
484
485$ip_dbh->disconnect;
486
487exit;
488
489
490# Hokay. This is a little different. We have a few specific functions here:
491# -> Assign arbitrary subnet from arbitrary free space
492# -> Tweak individual DB fields
493#
494
495
496# Tweak allocfrom into shape.
497sub fix_allocfrom {
498 if ($webvar{allocfrom} =~ /^(\d+\.){2}\d+$/) {
499 # 3-octet class C specified
500 $webvar{allocfrom} .= ".0/24";
501 } elsif ($webvar{allocfrom} =~ /^(\d+\.){3}\d+$/) {
502 # 4-octet IP specified;
503 $webvar{allocfrom} .= "/24";
504 }
505}
506
507
508# Show allocations to allow editing.
509sub showAllocs {
510
511 my $within = new NetAddr::IP $_[0];
512 $page->param(within => $within);
513
514 $sth = $ip_dbh->prepare("select cidr,custid,type,city,description from allocations where cidr <<= '$within' order by cidr");
515 $sth->execute;
516 my @blocklist;
517 while (my ($cidr,$custid,$type,$city,$desc) = $sth->fetchrow_array) {
518 my %row = (
519 cidr => $cidr,
520 custid => $custid,
521 city => $city,
522 desc => $desc,
523 );
524
525##fixme: don't wanna retrieve the whole type list *every time around the outer loop*
526 my $sth2 = $ip_dbh->prepare("select type,listname from alloctypes".
527 " where listorder < 500 and not (type like '_i') order by listorder");
528 $sth2->execute;
529 my @typelist;
530 while (my ($listtype,$dispname) = $sth2->fetchrow_array) {
531 my %subrow = (
532 type => $listtype,
533 dispname => $dispname,
534 selected => ($listtype eq $type)
535 );
536 push @typelist, \%subrow;
537 }
538 $row{typelist} = \@typelist;
539 push @blocklist, \%row;
540 }
541 $page->param(blocklist => \@blocklist);
542} # end showAllocs()
543
544
545# Stuff updates into DB
546sub update {
547 # Relatively simple SQL transaction here. Note that we're deliberately NOT
548 # updating notes/desc here as it's available through the main interface.
549 $sth = $ip_dbh->prepare("update allocations set custid='$webvar{custid}',".
550 "city=?,type='$webvar{alloctype}' where cidr='$webvar{block}'");
551 $sth->execute($webvar{city});
552
553 $page->param(block => $webvar{block});
554 if ($sth->err) {
555 $page->param(updfailed => $sth->errstr);
556 syslog "err", "$authuser could not update block '$webvar{block}': '".$sth->errstr."'";
557 } else {
558 syslog "notice", "$authuser updated $webvar{block}";
559 }
560 # need to get /24 that block is part of
561 my @bits = split /\./, $webvar{block};
562 $bits[3] = "0/24";
563 showAllocs((join ".", @bits));
564} # end update()
565
566
567# showPool()
568# List all IPs in a pool, and allow arbitrary admin changes to each
569# Allow changes to ALL fields
570sub showPool {
571 my $pool = new NetAddr::IP $_[0];
572
573 $sth = $ip_dbh->prepare("select type,listname from alloctypes where type like '_i' order by listorder");
574 $sth->execute;
575 my @typelist;
576 while (my ($type,$dispname) = $sth->fetchrow_array) {
577 my %row = (
578 type => $type,
579 dispname => $dispname
580 );
581 push @typelist, \%row;
582 }
583 $page->param(typelist => \@typelist);
584
585 $sth = $ip_dbh->prepare("SELECT ip,custid,city,type,available,description,notes from poolips".
586 " WHERE pool=? ORDER BY ip");
587 $sth->execute($pool);
588 my @iplist;
589 while (my ($ip,$custid,$city,$type,$avail,$desc,$notes) = $sth->fetchrow_array) {
590 my %row = (
591 ip => $ip,
592 custid => $custid,
593 city => $city,
594 type => $type,
595 avail => $avail,
596 desc => $desc,
597 notes => $notes
598 );
599 push @iplist, \%row;
600 }
601 $page->param(iplist => \@iplist);
602} # end showPool()
603
604
605# interpret the notify codes
606sub dispNoticeCode {
607 my $code = shift;
608 my $action_out = '';
609
610 if ($code =~ /^s:/) {
611 $code =~ s/^s:/Special: /;
612 return $code;
613 }
614 if ($code =~ /^f:(.+)$/) {
615 $code =~ s/^f://;
616 $action_out = "Failure on ";
617 }
618 if (my $target = $code =~ /^n(.+)/) {
619 $action_out .= "New ";
620 if ($1 eq 'ci') { $action_out .= "city"; }
621 elsif ($1 eq 'no') { $action_out .= "node"; }
622 else { $action_out .= '&lt;unknown&gt;'; }
623 } else {
624 my ($action,$target) = ($code =~ /^(.)(.+)$/);
625 if ($action eq 'a') { $action_out .= 'Add '; }
626 elsif ($action eq 'u') { $action_out .= 'Update '; }
627 elsif ($action eq 'd') { $action_out .= 'Delete '; }
628##fixme: what if we get something funky?
629# What about the eleventy-billion odd combinations possible?
630# this should give an idea of the structure tho
631 if ($target eq 'a') { $action_out .= "all"; }
632 elsif ($target eq '.i') {
633 $action_out .= "all static IPs";
634 }
635 else { $action_out .= $disp_alloctypes{$target}; }
636 }
637 return $action_out;
638}
Note: See TracBrowser for help on using the repository browser.