Ignore:
Timestamp:
11/07/12 17:20:58 (11 years ago)
Author:
Kris Deugau
Message:

/trunk

Tweak allocateBlock() to usefully handle passing an IP as an
override on the automatic IP-chooser.
Convert allocation of a pool IP in admin.cgi to use updated
allocateBlock(). See #34.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/admin.cgi

    r544 r545  
    203203    $page->param(locerr => "Invalid customer location!  Go back and select customer's location.");
    204204    goto ERRJUMP;
    205   } else {
    206     if ($webvar{alloctype} =~ /^.i$/) {
    207       $sth = $ip_dbh->prepare("update poolips set available='n', custid='$webvar{custid}', ".
    208         "city='$webvar{city}', description='$webvar{desc}', notes='$webvar{notes}' ".
    209         "where ip='$webvar{cidr}'");
    210       $sth->execute;
    211       if ($sth->err) {
    212         $page->param(errmsg => $sth->errstr);
    213         syslog "err", "($authuser) Allocation of '$webvar{cidr}' to '$webvar{custid}' as ".
    214                 "'$webvar{alloctype}' failed: '".$sth->errstr."'";
    215       } else {
    216         syslog "notice", "$authuser allocated '$webvar{cidr}' to '$webvar{custid}' as ".
    217                 "'$webvar{alloctype}'";
    218         mailNotify($ip_dbh, "a$webvar{alloctype}", "ADDED: $disp_alloctypes{$webvar{alloctype}} allocation",
    219           "$disp_alloctypes{$webvar{alloctype}} $webvar{cidr} allocated to customer $webvar{custid}\n".
    220           "Description: $webvar{desc}\n\nAllocated by: $authuser\n");
    221       }
    222     } else {
    223       my ($retcode,$msg) = allocateBlock($ip_dbh, $webvar{cidr}, $webvar{alloc_from},
     205  }
     206
     207  my ($retcode,$msg) = allocateBlock($ip_dbh, $webvar{cidr}, $webvar{alloc_from},
    224208        $webvar{custid}, $webvar{alloctype}, $webvar{city}, $webvar{desc}, $webvar{notes},
    225209        $webvar{circid});
    226       if ($retcode eq 'OK') {
    227         syslog "notice", "$authuser allocated '$webvar{cidr}' to '$webvar{custid}' as ".
    228                 "'$webvar{alloctype}'";
    229       } else {
    230         $page->param(errmsg => $msg);
    231         syslog "err", "($authuser) Allocation of '$webvar{cidr}' to '$webvar{custid}' as ".
    232                 "'$webvar{alloctype}' failed: '$msg'";
    233       }
    234     } # static IP vs netblock
    235 
    236   } # done city check
     210  if ($retcode eq 'OK') {
     211    syslog "notice", "$authuser allocated '$webvar{cidr}' to '$webvar{custid}' as ".
     212        "'$webvar{alloctype}'";
     213    if ($webvar{alloctype} =~ /^.i$/) {
     214      mailNotify($ip_dbh, "a$webvar{alloctype}", "ADDED: $disp_alloctypes{$webvar{alloctype}} allocation",
     215        "$disp_alloctypes{$webvar{alloctype}} $webvar{cidr} allocated to customer $webvar{custid}\n".
     216        "Description: $webvar{desc}\n\nAllocated by: $authuser\n");
     217    }
     218  } else {
     219    $page->param(errmsg => $msg);
     220    syslog "err", "($authuser) Allocation of '$webvar{cidr}' to '$webvar{custid}' as ".
     221        "'$webvar{alloctype}' failed: '$msg'";
     222  }
    237223
    238224} elsif ($webvar{action} eq 'alloctweak') {
Note: See TracChangeset for help on using the changeset viewer.