Changeset 71 for branches


Ignore:
Timestamp:
11/15/04 12:42:35 (20 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Backport email notification for static IP assignments from /trunk
r66, r68, r69, and r70

Location:
branches/stable/cgi-bin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/cgi-bin/IPDB.pm

    r26 r71  
    11# ipdb/cgi-bin/IPDB.pm
    2 # Contains DB-related functions for IPDB
     2# Contains functions for IPDB - database access, subnet mangling, block allocation, etc
    33###
    44# SVN revision info
     
    77# Last update by $Author$
    88###
    9 
    10 # Split from CommonWeb.pm 08/13/2004 kdeugau@vianet
     9# Copyright (C) 2004 - Kris Deugau
    1110
    1211package IPDB;
     
    1514use warnings;
    1615use Exporter;
     16use Net::SMTP;
     17use POSIX;
    1718use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
    1819
    1920$VERSION        = 1.0;
    2021@ISA            = qw(Exporter);
    21 @EXPORT_OK      = qw(&connectDB &checkDBSanity);
     22@EXPORT_OK      = qw(&connectDB &checkDBSanity &allocateBlock &mailNotify);
    2223
    2324@EXPORT         = (); # Export nothing by default.
    24 %EXPORT_TAGS    = ( ALL => [qw( &connectDB &checkDBSanity )]
     25%EXPORT_TAGS    = ( ALL => [qw( &connectDB &checkDBSanity &allocateBlock &mailNotify)]
    2526                  );
     27
    2628
    2729# Creates connection to IPDB.
     
    6668} # end checkDBSanity
    6769
     70
     71# allocateBlock()
     72# Does all of the magic of actually allocating a netblock
     73sub allocateBlock($) {
     74}
     75
     76
     77# mailNotify()
     78# Sends notification mail to recipients regarding an IPDB operation
     79sub mailNotify ($$$) {
     80  my ($recip,$subj,$message) = @_;
     81  my $mailer = Net::SMTP->new("smtp.example.com", Hello => "ipdb.example.com");
     82
     83  $mailer->mail('ipdb@example.com');
     84  $mailer->to($recip);
     85  $mailer->data("From: \"IP Database\" <ipdb\@example.com>\n",
     86        "Date: ".strftime("%a, %d %b %Y %H:%M:%S %z",localtime)."\n",
     87        "Subject: {IPDB} $subj\n",
     88        "X-Mailer: IPDB Notify v".sprintf("%.1d",$IPDB::VERSION)."\n",
     89        "Organization: Example Corp\n",
     90        "\n$message\n");
     91  $mailer->quit;
     92}
     93
    6894# Indicates module loaded OK.  Required by Perl.
    69951;
  • branches/stable/cgi-bin/main.cgi

    r64 r71  
    4747
    4848my %full_alloc_types = (
    49         "ci","Cable pool IP",
    50         "di","DSL pool IP",
     49        "ci","Static cable IP",
     50        "di","Static DSL IP",
    5151        "si","Server pool IP",
    5252        "mi","Static dialup IP",
     
    987987    print qq(<div class="center"><div class="heading">The IP $cidr has been allocated to customer $webvar{custid}</div></div>);
    988988    syslog "notice", "$authuser allocated $cidr to $webvar{custid}";
     989# Notify tech@example.com
     990    mailNotify('tech@example.com','$full_alloc_types{$webvar{alloctype}} allocation',
     991        "$full_alloc_types{$webvar{alloctype}} $cidr allocated to customer $webvar{custid}");
    989992
    990993  } else { # end IP-from-pool allocation
Note: See TracChangeset for help on using the changeset viewer.