Ignore:
Timestamp:
07/26/10 17:00:00 (14 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Bring /branches/stable up to date with /trunk. See #13.

Location:
branches/stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/stable

    • Property svn:ignore
      •  

        old new  
        11local.css
         2*.tar.gz
    • Property svn:mergeinfo changed
      /trunkmerged: 415-420,​422-443
  • branches/stable/cgi-bin/main.cgi

    r408 r445  
    11#!/usr/bin/perl
    22# ipdb/cgi-bin/main.cgi
    3 # Started munging from noc.vianet's old IPDB 04/22/2004
    43###
    54# SVN revision info
     
    87# Last update by $Author$
    98###
     9# Copyright (C) 2004-2010 - Kris Deugau
    1010
    1111use strict;             
     
    1414use DBI;
    1515use CommonWeb qw(:ALL);
    16 use MyIPDB;
    1716use CustIDCK;
    1817use POSIX qw(ceil);
     
    2120use Sys::Syslog;
    2221
    23 openlog "IPDB","pid","local2";
     22# don't remove!  required for GNU/FHS-ish install from tarball
     23##uselib##
     24
     25use MyIPDB;
     26
     27openlog "IPDB","pid","$IPDB::syslog_facility";
    2428
    2529# Collect the username from HTTP auth.  If undefined, we're in
     
    681685  if ($webvar{alloctype} =~ /^.i$/) {
    682686    my ($base,undef) = split //, $webvar{alloctype};    # split into individual chars
    683     my ($sql,$city);
    684     # Check for pools in Subury, North Bay, or Toronto if DSL or server pool.
    685     # Anywhere else is invalid and shouldn't be in the db in the first place.
    686     # ... aside from #^%#$%#@#^%^^!!!! legacy data.  GRRR.
    687     # Note that we want to retain the requested city to relate to customer info.
    688     if ($base =~ /^[ds]$/) {
    689       $city = "(allocations.city='Sudbury' or allocations.city='North Bay' or ".
    690         "allocations.city='Toronto')";
    691     } else {
    692       $city = "allocations.city='$webvar{pop}'";
    693     }
    694687
    695688# Ewww.  But it works.
    696689    $sth = $ip_dbh->prepare("SELECT (SELECT city FROM allocations WHERE cidr=poolips.pool), ".
    697690        "poolips.pool, COUNT(*) FROM poolips,allocations WHERE poolips.available='y' AND ".
    698         "poolips.pool=allocations.cidr AND $city AND poolips.type LIKE '".$base."_' ".
     691        "poolips.pool=allocations.cidr AND allocations.city='$webvar{pop}' AND poolips.type LIKE '".$base."_' ".
    699692        "GROUP BY pool");
    700693    $sth->execute;
     
    750743        # This does NOT include cable pools.
    751744        if ($webvar{alloctype} =~ /^.[pc]$/) {
    752           if (($webvar{city} !~ /^(Sudbury|North Bay|Toronto)$/) && ($webvar{alloctype} eq 'dp')) {
    753             printError("You must chose Sudbury, North Bay, or Toronto for DSL pools.");
    754             return;
    755           }
    756745          $city = $webvar{city};
    757746          $failmsg = "No suitable free block found.<br>\nYou will have to route another".
    758             " superblock from one of the<br>\nmaster blocks in Sudbury or chose a smaller".
     747            " superblock from one of the<br>\nmaster blocks or chose a smaller".
    759748            " block size for the pool.";
    760749        } else {
    761750          $city = $webvar{pop};
    762751          $failmsg = "No suitable free block found.<br>\nYou will have to route another".
    763             " superblock to $webvar{pop}<br>\nfrom one of the master blocks in Sudbury or".
     752            " superblock to $webvar{pop}<br>\nfrom one of the master blocks or".
    764753            " chose a smaller blocksize.";
    765754        }
     
    891880                qq(&ipdb=1&ip=$msg">Add this IP to RADIUS user table</a></div>)
    892881        : "</div>");
    893       # Notify tech@example.com
    894 #      mailNotify('tech@example.com',"ADDED: $disp_alloctypes{$webvar{alloctype}} allocation",
    895 #       "$disp_alloctypes{$webvar{alloctype}} $msg allocated to customer $webvar{custid}\n".
    896 #       "Description: $webvar{desc}\n\nAllocated by: $authuser\n");
     882      mailNotify($ip_dbh, "a$webvar{alloctype}", "ADDED: $disp_alloctypes{$webvar{alloctype}} allocation",
     883        "$disp_alloctypes{$webvar{alloctype}} $msg allocated to customer $webvar{custid}\n".
     884        "Description: $webvar{desc}\n\nAllocated by: $authuser\n");
    897885    } else {
    898886      my $netblock = new NetAddr::IP $webvar{fullcidr};
     
    906894                qq(">Add this netblock to RADIUS user table</a></div>)
    907895        : "</div>");
    908 #      mailNotify('nocmgr@example.com',"ADDED: $disp_alloctypes{$webvar{alloctype}} allocation",
    909 #       "$disp_alloctypes{$webvar{alloctype}} $webvar{fullcidr} allocated to customer $webvar{custid}\n".
    910 #       "Description: $webvar{desc}\n\nAllocated by: $authuser\n");
     896      mailNotify($ip_dbh, "a$webvar{alloctype}", "ADDED: $disp_alloctypes{$webvar{alloctype}} allocation",
     897        "$disp_alloctypes{$webvar{alloctype}} $webvar{fullcidr} allocated to customer $webvar{custid}\n".
     898        "Description: $webvar{desc}\n\nAllocated by: $authuser\n");
    911899    }
    912900    syslog "notice", "$authuser allocated '$webvar{fullcidr}' to '$webvar{custid}' as ".
     
    958946      if (!$status) {
    959947        printError("Customer ID not valid.  Make sure the Customer ID ".
    960           "is correct.<br>\nUse STAFF for staff static IPs, and 6750400 for any other ".
     948          "is correct.<br>\nUse STAFF for staff static IPs, and $IPDB::defcustid for any other ".
    961949          "non-customer assignments.");
    962950        return;
    963951      }
    964 #"Please enter a valid customer ID- this must be a 7- or 10-digit number, or STAFF for
    965 #static IPs for staff.");
    966952    }
    967953#    print "<!-- [ In validateInput().  Insert customer ID cross-check here. ] -->\n";
     
    985971  } else {
    986972    $flag = 'n';
    987     if ($webvar{alloctype} =~ /[wp][cr]|[ds][pi]/) {
    988       # Set this forcibly rather than messing around elsewhere.  Yes, this *is* a hack.  PTHBTT!!
    989       $webvar{pop} = 'Sudbury';
    990     }
     973##fixme:  hook to force-set POP or city on certain alloctypes
     974# if ($webvar{alloctype =~ /foo,bar,bz/ { $webvar{pop} = 'blah'; }
    991975    if ($webvar{pop} =~ /^-$/) {
    992976      $flag = 'to route the block from/through';
     
    12251209  # If we get here, the operation succeeded.
    12261210  syslog "notice", "$authuser updated $webvar{block}";
    1227 #mailNotify('nocmgr@example.com',"SWIPed: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",
    1228 #       "$webvar{block} had SWIP status changed to \"Yes\" by $authuser");
     1211##fixme:  need to wedge something in to allow "update:field" notifications
     1212## hmm.  how to tell what changed?  O_o
     1213mailNotify($ip_dbh, 's:swi', "SWIPed: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",
     1214        "$webvar{block} had SWIP status changed to \"Yes\" by $authuser") if $webvar{swip} eq 'on';
    12291215  open (HTML, "../updated.html")
    12301216        or croak "Could not open updated.html :$!";
     
    14021388    syslog "notice", "$authuser deallocated '$webvar{alloctype}'-type netblock $webvar{block}".
    14031389        " $custid, $city, desc='$description'";
    1404     # Notify tech@ when a block/IP is deallocated
    1405 #    mailNotify('tech@example.com',"REMOVED: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",
    1406 #       "$disp_alloctypes{$webvar{alloctype}} $webvar{block} deallocated by $authuser\n".
    1407 #       "CustID: $custid\nCity: $city\nDescription: $description\n");
    1408 #    mailNotify('nocmgr@example.com',"REMOVED: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",
    1409 #       "$disp_alloctypes{$webvar{alloctype}} $webvar{block} deallocated by $authuser\n".
    1410 #       "CustID: $custid\nCity: $city\nDescription: $description\n");
     1390    mailNotify($ip_dbh, 'da', "REMOVED: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",
     1391        "$disp_alloctypes{$webvar{alloctype}} $webvar{block} deallocated by $authuser\n".
     1392        "CustID: $custid\nCity: $city\nDescription: $description\n");
    14111393  } else {
    14121394    if ($webvar{alloctype} =~ /^.i$/) {
Note: See TracChangeset for help on using the changeset viewer.