Changeset 947


Ignore:
Timestamp:
07/31/24 16:09:57 (7 weeks ago)
Author:
Kris Deugau
Message:

/trunk

Commit add of userid field that had been left waving in the breeze
Normalize and update copyright block in IPDB.pm and main.cgi

Location:
trunk/cgi-bin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/IPDB.pm

    • Property svn:keywords changed from Date Rev Author to Date Rev Author Id
    r945 r947  
    11# ipdb/cgi-bin/IPDB.pm
    22# Contains functions for IPDB - database access, subnet mangling, block allocation, etc
    3 ###
    4 # SVN revision info
    5 # $Date$
    6 # SVN revision $Rev$
    7 # Last update by $Author$
    8 ###
    9 # Copyright (C) 2004-2016 - Kris Deugau
     3##
     4# $Id$
     5# Copyright (C) 2004-2018,2022-2024 - Kris Deugau <kdeugau@deepnet.cx>
     6#
     7#    This program is free software: you can redistribute it and/or modify
     8#    it under the terms of the GNU General Public License as published by
     9#    the Free Software Foundation, either version 3 of the License, or
     10#    (at your option) any later version.
     11#
     12#    This program is distributed in the hope that it will be useful,
     13#    but WITHOUT ANY WARRANTY; without even the implied warranty of
     14#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15#    GNU General Public License for more details.
     16#
     17#    You should have received a copy of the GNU General Public License
     18#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
     19##
    1020
    1121package IPDB;
     
    353363      INSERT INTO allocations (
    354364              cidr,type,city, description, notes, circuitid, createstamp, modifystamp,
    355               privdata, custid, vrf, vlan, rdns, parent_id, master_id
     365              privdata, custid, vrf, vlan, rdns, parent_id, master_id, userid
    356366          )
    357367      SELECT
    358368              ip, ? AS type, city, description, notes, circuitid, createstamp, modifystamp,
    359               privdata, custid, vrf, vlan, rdns, ? AS parent_id, master_id
     369              privdata, custid, vrf, vlan, rdns, ? AS parent_id, master_id, userid
    360370          FROM poolips
    361371          WHERE parent_id = ? AND available = 'n'
     
    15961606  $args{vlan} = '' if !$args{vlan};
    15971607  $args{rdns} = '' if !$args{rdns};
     1608# customer accounts may have multiple allocations;  tag the specific billing user for the allocation
     1609  $args{billinguserid} = 0 if !$args{billinguserid};
    15981610
    15991611  # munge the reverse name to include the default domain if there are no dots.  Don't append if
     
    16871699      # finally assign the IP
    16881700      $dbh->do("UPDATE poolips SET custid = ?, city = ?, available='n', description = ?, notes = ?, vlan = ?, ".
    1689         "circuitid = ?, privdata = ?, rdns = ?, backup_id = ? ".
     1701        "circuitid = ?, privdata = ?, rdns = ?, backup_id = ?, userid = ? ".
    16901702        "WHERE ip = ? AND parent_id = ?", undef,
    16911703                ($args{custid}, $args{city}, $args{desc}, $args{notes}, $args{vlan},
    1692                 $args{circid}, $args{privdata}, $args{rdns}, $backupid,
     1704                $args{circid}, $args{privdata}, $args{rdns}, $backupid, $args{billinguserid},
    16931705                $args{cidr}, $args{parent}) );
    16941706
     
    17481760        # Insert the allocations entry
    17491761        $dbh->do("INSERT INTO allocations ".
    1750                 "(cidr,parent_id,master_id,vrf,vlan,custid,type,city,description,notes,circuitid,privdata,rdns,backup_id)".
    1751                 " VALUES (?,?,?,(SELECT vrf FROM allocations WHERE id=?),?,?,?,?,?,?,?,?,?,?)", undef,
     1762                "(cidr,parent_id,master_id,vrf,vlan,custid,type,city,description,notes,circuitid,privdata,rdns,backup_id,userid)".
     1763                " VALUES (?,?,?,(SELECT vrf FROM allocations WHERE id=?),?,?,?,?,?,?,?,?,?,?,?)", undef,
    17521764                ($args{cidr}, $fbparent, $fbmaster, $fbmaster, $args{vlan}, $args{custid}, $args{type}, $args{city},
    1753                 $args{desc}, $args{notes}, $args{circid}, $args{privdata}, $args{rdns}, $backupid) );
     1765                $args{desc}, $args{notes}, $args{circid}, $args{privdata}, $args{rdns}, $backupid, $args{billinguserid}) );
    17541766        my ($bid) = $dbh->selectrow_array("SELECT currval('allocations_id_seq')");
    17551767
     
    18241836        # Insert the allocations entry
    18251837        $dbh->do("INSERT INTO allocations ".
    1826                 "(cidr,parent_id,master_id,vrf,vlan,custid,type,city,description,notes,circuitid,privdata,rdns)".
    1827                 " VALUES (?,?,?,(SELECT vrf FROM allocations WHERE id=?),?,?,?,?,?,?,?,?,?)", undef,
     1838                "(cidr,parent_id,master_id,vrf,vlan,custid,type,city,description,notes,circuitid,privdata,rdns,userid)".
     1839                " VALUES (?,?,?,(SELECT vrf FROM allocations WHERE id=?),?,?,?,?,?,?,?,?,?,?)", undef,
    18281840                ($args{cidr}, $fbparent, $fbmaster, $fbmaster, $args{vlan}, $args{custid}, $args{type}, $args{city},
    1829                 $args{desc}, $args{notes}, $args{circid}, $args{privdata}, $args{rdns}) );
     1841                $args{desc}, $args{notes}, $args{circid}, $args{privdata}, $args{rdns}, $args{billinguserid}) );
    18301842        my ($bid) = $dbh->selectrow_array("SELECT currval('allocations_id_seq')");
    18311843
     
    22762288    # direct in SQL, something like
    22772289    # "INSERT INTO foo (f1,f2,f3) VALUES (newf1,(SELECT oldf2,oldf3 FROM foo WHERE baz))"
    2278     my @fieldlist = qw(type city description notes circuitid privdata custid swip vrf vlan rdns parent_id master_id);
     2290    my @fieldlist = qw(type city description notes circuitid privdata custid swip vrf vlan rdns parent_id master_id userid);
    22792291    my $fields_sql = join(',', @fieldlist);
    22802292    my @vals;
     
    33723384  # Note city, vrf, parent_id and master_id removed due to JOIN uncertainty for block allocations
    33733385  my $commonfields = q(a.custid, a.type, a.circuitid, a.description, a.notes, a.modifystamp AS lastmod,
    3374         a.privdata, a.vlan, a.rdns);
     3386        a.privdata, a.vlan, a.rdns, a.userid);
    33753387  my $bkfields = q(b.backup_id AS hasbk, b.bkbrand, b.bkmodel, b.bktype, b.bkport, b.bksrc,
    33763388        b.bkuser, b.bkvpass, b.bkepass, b.bkip);
  • trunk/cgi-bin/main.cgi

    • Property svn:keywords changed from Date Rev Author to Date Rev Author Id
    r944 r947  
    33##
    44# $Id$
    5 # Copyright (C) 2004-2018,2022 - Kris Deugau <kdeugau@deepnet.cx>
     5# Copyright (C) 2004-2018,2022-2024 - Kris Deugau <kdeugau@deepnet.cx>
    66#
    77#    This program is free software: you can redistribute it and/or modify
     
    907907        vlan            => $webvar{vlan},
    908908        user            => $authuser,
     909        billinguserid   => $webvar{billinguser},
    909910        );
    910911
Note: See TracChangeset for help on using the changeset viewer.