Changeset 445 for branches/stable/cgi-bin/main.cgi
- Timestamp:
- 07/26/10 17:00:00 (14 years ago)
- Location:
- branches/stable
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable
- Property svn:ignore
-
old new 1 1 local.css 2 *.tar.gz
-
- Property svn:mergeinfo changed
/trunk merged: 415-420,422-443
- Property svn:ignore
-
branches/stable/cgi-bin/main.cgi
r408 r445 1 1 #!/usr/bin/perl 2 2 # ipdb/cgi-bin/main.cgi 3 # Started munging from noc.vianet's old IPDB 04/22/20044 3 ### 5 4 # SVN revision info … … 8 7 # Last update by $Author$ 9 8 ### 9 # Copyright (C) 2004-2010 - Kris Deugau 10 10 11 11 use strict; … … 14 14 use DBI; 15 15 use CommonWeb qw(:ALL); 16 use MyIPDB;17 16 use CustIDCK; 18 17 use POSIX qw(ceil); … … 21 20 use Sys::Syslog; 22 21 23 openlog "IPDB","pid","local2"; 22 # don't remove! required for GNU/FHS-ish install from tarball 23 ##uselib## 24 25 use MyIPDB; 26 27 openlog "IPDB","pid","$IPDB::syslog_facility"; 24 28 25 29 # Collect the username from HTTP auth. If undefined, we're in … … 681 685 if ($webvar{alloctype} =~ /^.i$/) { 682 686 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 }694 687 695 688 # Ewww. But it works. 696 689 $sth = $ip_dbh->prepare("SELECT (SELECT city FROM allocations WHERE cidr=poolips.pool), ". 697 690 "poolips.pool, COUNT(*) FROM poolips,allocations WHERE poolips.available='y' AND ". 698 "poolips.pool=allocations.cidr AND $cityAND poolips.type LIKE '".$base."_' ".691 "poolips.pool=allocations.cidr AND allocations.city='$webvar{pop}' AND poolips.type LIKE '".$base."_' ". 699 692 "GROUP BY pool"); 700 693 $sth->execute; … … 750 743 # This does NOT include cable pools. 751 744 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 }756 745 $city = $webvar{city}; 757 746 $failmsg = "No suitable free block found.<br>\nYou will have to route another". 758 " superblock from one of the<br>\nmaster blocks in Sudburyor chose a smaller".747 " superblock from one of the<br>\nmaster blocks or chose a smaller". 759 748 " block size for the pool."; 760 749 } else { 761 750 $city = $webvar{pop}; 762 751 $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 Sudburyor".752 " superblock to $webvar{pop}<br>\nfrom one of the master blocks or". 764 753 " chose a smaller blocksize."; 765 754 } … … 891 880 qq(&ipdb=1&ip=$msg">Add this IP to RADIUS user table</a></div>) 892 881 : "</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"); 897 885 } else { 898 886 my $netblock = new NetAddr::IP $webvar{fullcidr}; … … 906 894 qq(">Add this netblock to RADIUS user table</a></div>) 907 895 : "</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"); 911 899 } 912 900 syslog "notice", "$authuser allocated '$webvar{fullcidr}' to '$webvar{custid}' as ". … … 958 946 if (!$status) { 959 947 printError("Customer ID not valid. Make sure the Customer ID ". 960 "is correct.<br>\nUse STAFF for staff static IPs, and 6750400for any other ".948 "is correct.<br>\nUse STAFF for staff static IPs, and $IPDB::defcustid for any other ". 961 949 "non-customer assignments."); 962 950 return; 963 951 } 964 #"Please enter a valid customer ID- this must be a 7- or 10-digit number, or STAFF for965 #static IPs for staff.");966 952 } 967 953 # print "<!-- [ In validateInput(). Insert customer ID cross-check here. ] -->\n"; … … 985 971 } else { 986 972 $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'; } 991 975 if ($webvar{pop} =~ /^-$/) { 992 976 $flag = 'to route the block from/through'; … … 1225 1209 # If we get here, the operation succeeded. 1226 1210 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 1213 mailNotify($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'; 1229 1215 open (HTML, "../updated.html") 1230 1216 or croak "Could not open updated.html :$!"; … … 1402 1388 syslog "notice", "$authuser deallocated '$webvar{alloctype}'-type netblock $webvar{block}". 1403 1389 " $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"); 1411 1393 } else { 1412 1394 if ($webvar{alloctype} =~ /^.i$/) {
Note:
See TracChangeset
for help on using the changeset viewer.