Changeset 320
- Timestamp:
- 04/04/06 18:25:28 (19 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/assign.html
r284 r320 29 29 </td> 30 30 </tr><tr class="color2"> 31 <td>Route/allocate from this master: </td><td>$$MASTERLIST$$</td> 31 <td>Route/allocate from this master: </td><td>$$MASTERLIST$$ 32 Allow automatic allocation from private IP ranges:<input type=checkbox name=allowpriv> 33 </td> 32 34 </tr><tr class="color1"> 33 35 <td>Circuit ID: </td><td><input name=circid size=40></td> -
trunk/cgi-bin/IPDB.pm
r284 r320 7 7 # Last update by $Author$ 8 8 ### 9 # Copyright (C) 2004 ,2005- Kris Deugau9 # Copyright (C) 2004-2006 - Kris Deugau 10 10 11 11 package IPDB; -
trunk/cgi-bin/MyIPDB.pm
r142 r320 8 8 # Last update by $Author$ 9 9 ### 10 # Copyright (C) 2004 ,2005- Kris Deugau10 # Copyright (C) 2004-2006 - Kris Deugau 11 11 12 12 use IPDB 2.0 qw(:ALL); -
trunk/cgi-bin/admin.cgi
r295 r320 10 10 # Last update by $Author$ 11 11 ### 12 # Copyright (C) 2004 ,2005- Kris Deugau12 # Copyright (C) 2004-2006 - Kris Deugau 13 13 14 14 use strict; … … 92 92 <hr><a href="admin.cgi?action=showusers">Manage users</a> (add/remove users; change 93 93 internal access controls - note that this does NOT include IP-based limits) 94 <hr>Consistency check tools<br> 95 <a href="consistency-check.pl">General</a>: Check general netblock consistency.<br> 96 <a href="freespace.pl">Free space</a>: List total and aggregate free space. Does not 97 include private networks (192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8) 94 98 ); 95 99 } else { … … 295 299 print "Notes:<br>\n". 296 300 "<li>Admin users automatically get all other priviledges.\n". 301 "<li>Everyone has basic read access.\n". 297 302 "<hr>Add new user:<form action=admin.cgi method=POST>\n". 298 303 "Username: <input name=username><br>\n". -
trunk/cgi-bin/freespace.pl
r146 r320 8 8 # Last update by $Author$ 9 9 ### 10 # Copyright (C) 2004 ,2005- Kris Deugau10 # Copyright (C) 2004-2006 - Kris Deugau 11 11 12 12 use DBI; … … 20 20 $tnumfree = $bigrfree = $bigufree = 0; 21 21 22 $sql = 'select * from freeblocks where '; 22 23 # General counts first 23 24 if ($ARGV[0]) { 24 $sth = $dbh->prepare("select * from freeblocks where maskbits >= $ARGV[0] order by maskbits desc"); 25 } else { 26 $sth = $dbh->prepare("select * from freeblocks order by maskbits desc"); 25 $sql .= 'maskbits >= $ARGV[0] and '; 27 26 } 27 $sql .= "not (cidr <<= '192.168.0.0/16') ". 28 "and not (cidr <<= '172.16.0.0/12') ". 29 "and not (cidr <<= '10.0.0.0/8') "; 30 $sql .= "order by maskbits desc"; 31 32 $sth = $dbh->prepare($sql); 28 33 $sth->execute; 29 34 while (@data = $sth->fetchrow_array) { … … 33 38 } 34 39 40 print "Free block counts:\n"; 35 41 foreach $size (sort {$a cmp $b} keys %numfree) { 36 42 print "/$size: $numfree{$size}\n"; … … 44 50 } 45 51 52 print "Aggregate free space:\n"; 46 53 foreach $size (sort {$a cmp $b} keys %numfree) { 47 54 print "/$size: $numfree{$size}\n"; -
trunk/cgi-bin/main.cgi
r314 r320 103 103 104 104 if ($@) { 105 carp "Transaction aborted because $@"; 105 my $msg = $@; 106 carp "Transaction aborted because $msg"; 106 107 eval { $ip_dbh->rollback; }; 107 syslog "err", "Could not add master block '$webvar{cidr}' to database: '$ @'";108 printError("Could not add master block $webvar{cidr} to database: $ @");108 syslog "err", "Could not add master block '$webvar{cidr}' to database: '$msg'"; 109 printError("Could not add master block $webvar{cidr} to database: $msg"); 109 110 } else { 110 111 print "<div type=heading align=center>Success!</div>\n"; … … 414 415 qq($master ($data[0]):</div></center><br>\n); 415 416 416 startTable('CIDR allocation','Customer Location','Type','CustID',' Description/Name');417 startTable('CIDR allocation','Customer Location','Type','CustID','SWIPed?','Description/Name'); 417 418 418 419 # Snag the allocations for this block 419 $sth = $ip_dbh->prepare("select cidr,city,type,custid, description".420 $sth = $ip_dbh->prepare("select cidr,city,type,custid,swip,description". 420 421 " from allocations where cidr <<= '$master' order by cidr"); 421 422 $sth->execute(); … … 423 424 my $count=0; 424 425 while (my @data = $sth->fetchrow_array()) { 425 # cidr,city,type,custid, description, as per the SELECT426 # cidr,city,type,custid,swip,description, as per the SELECT 426 427 my $cidr = new NetAddr::IP $data[0]; 427 428 … … 432 433 my @row = ( (($data[2] =~ /^.r$/) ? 'Sub ' : ''). 433 434 qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>), 434 $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]); 435 $data[1], $disp_alloctypes{$data[2]}, $data[3], 436 ($data[4] eq 'y' ? 'Yes' : 'No'), $data[5]); 435 437 # If the allocation is a pool, allow listing of the IPs in the pool. 436 438 if ($data[2] =~ /^.[pd]$/) { … … 710 712 my $city; 711 713 my $failmsg; 714 my $extracond = ''; 715 if ($webvar{allocfrom} eq '-') { 716 $extracond = ($webvar{allowpriv} eq 'on' ? '' : 717 " and not (cidr <<= '192.168.0.0/16'". 718 " or cidr <<= '10.0.0.0/8'". 719 " or cidr <<= '172.16.0.0/12')"); 720 } 721 my $sortorder; 712 722 if ($webvar{alloctype} eq 'rm') { 713 723 if ($webvar{allocfrom} ne '-') { 714 724 $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'". 715 " and cidr <<= '$webvar{allocfrom}' order by maskbits desc"; 725 " and cidr <<= '$webvar{allocfrom}'"; 726 $sortorder = "maskbits desc"; 716 727 } else { 717 $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'" .718 " order bymaskbits desc";728 $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'"; 729 $sortorder = "maskbits desc"; 719 730 } 720 731 $failmsg = "No suitable free block found.<br>\nWe do not have a free". … … 745 756 $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}". 746 757 " and cidr <<= '$webvar{allocfrom}' and routed='". 747 (($webvar{alloctype} =~ /^(.)r$/) ? "$1" : 'y')."' order by maskbits desc,cidr"; 758 (($webvar{alloctype} =~ /^(.)r$/) ? "$1" : 'y')."'"; 759 $sortorder = "maskbits desc,cidr"; 748 760 } else { 749 761 $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}". 750 " and routed='".(($webvar{alloctype} =~ /^(.)r$/) ? "$1" : 'y'). 751 "' order bymaskbits desc,cidr";762 " and routed='".(($webvar{alloctype} =~ /^(.)r$/) ? "$1" : 'y')."'"; 763 $sortorder = "maskbits desc,cidr"; 752 764 } 753 765 } 766 $sql = $sql.$extracond." order by ".$sortorder; 754 767 $sth = $ip_dbh->prepare($sql); 755 768 $sth->execute; … … 914 927 } else { 915 928 # New! Improved! And now Loaded From The Database!! 916 $webvar{custid} = $def_custids{$webvar{alloctype}}; 929 if ((!$webvar{custid}) || ($webvar{custid} ne 'STAFF')) { 930 $webvar{custid} = $def_custids{$webvar{alloctype}}; 931 } 917 932 } 918 933 … … 929 944 } else { 930 945 $flag = 'n'; 931 if ($webvar{alloctype} =~ /[wp][cr]| [ds][pi]/) {946 if ($webvar{alloctype} =~ /[wp][cr]|d[pi]/) { 932 947 # Set this forcibly rather than messing around elsewhere. Yes, this *is* a hack. PTHBTT!! 933 $webvar{pop} = 'Sudbury';934 }935 if ($webvar{pop} =~ /^-$/) {948 # Match CORE/WAN types (wc, wr, pc, pr), DSL pool and IP (dp, di). 949 $webvar{pop} = "Sudbury"; 950 } elsif ($webvar{pop} =~ /^-$/) { 936 951 $flag = 'to route the block from/through'; 937 952 } … … 957 972 # because I'm lazy, we'll try to make the SELECT's bring out identical)ish) data 958 973 if ($webvar{block} =~ /\/32$/) { 959 $sql = "select ip,custid,type,city,circuitid,description,notes,modifystamp,privdata from poolips where ip='$webvar{block}'";974 $sql = "select ip,custid,type,city,circuitid,description,notes,modifystamp,privdata,oldcustid from poolips where ip='$webvar{block}'"; 960 975 } else { 961 $sql = "select cidr,custid,type,city,circuitid,description,notes,modifystamp,privdata from allocations where cidr='$webvar{block}'"976 $sql = "select cidr,custid,type,city,circuitid,description,notes,modifystamp,privdata,oldcustid,swip from allocations where cidr='$webvar{block}'" 962 977 } 963 978 … … 1006 1021 $html =~ s/\$\$TYPESELECT\$\$/$disp_alloctypes{$data[2]}<input type=hidden name=alloctype value="$data[2]">/g; 1007 1022 } 1023 $html =~ s/\$\$OLDCUSTID\$\$/$data[9]/g; 1008 1024 $html =~ s/\$\$CITY\$\$/<input type=text name=city value="$data[3]">/g; 1009 1025 $html =~ s/\$\$CIRCID\$\$/<input type="text" name="circid" value="$data[4]" maxlength=64 size=64 class="regular">/g; … … 1012 1028 } else { 1013 1029 $html =~ s/\$\$CUSTID\$\$/$data[1]/g; 1030 $html =~ s/\$\$OLDCUSTID\$\$/$data[9]/g; 1014 1031 $html =~ s/\$\$TYPESELECT\$\$/$disp_alloctypes{$data[2]}/g; 1015 1032 $html =~ s/\$\$CITY\$\$/$data[3]/g; … … 1020 1037 my ($lastmod,undef) = split /\s+/, $data[7]; 1021 1038 $html =~ s/\$\$LASTMOD\$\$/$lastmod/g; 1039 1040 ## Hack time! SWIP isn't going to stay, so I'm not going to integrate it with ACLs. 1041 if ($data[2] =~ /.i/) { 1042 $html =~ s/\$\$SWIP\$\$/N\/A/; 1043 } else { 1044 my $tmp = (($data[10] eq 'n') ? '<input type=checkbox name=swip>' : 1045 '<input type=checkbox name=swip checked=yes>'); 1046 $html =~ s/\$\$SWIP\$\$/$tmp/; 1047 } 1022 1048 1023 1049 # Allows us to "correctly" colour backgrounds in table … … 1091 1117 $sql = "update allocations set custid='$webvar{custid}',". 1092 1118 "description='$webvar{desc}',notes='$webvar{notes}',city='$webvar{city}',". 1093 "type='$webvar{alloctype}',circuitid='$webvar{circid}'$privdata ". 1119 "type='$webvar{alloctype}',circuitid='$webvar{circid}'$privdata,". 1120 "swip='".($webvar{swip} eq 'on' ? 'y' : 'n')."' ". 1094 1121 "where cidr='$webvar{block}'"; 1095 1122 } … … 1115 1142 my $html = join('', <HTML>); 1116 1143 1144 my $swiptmp = ($webvar{swip} eq 'on' ? 'Yes' : 'No'); 1117 1145 $html =~ s/\$\$BLOCK\$\$/$webvar{block}/g; 1118 1146 $webvar{city} = desanitize($webvar{city}); … … 1121 1149 $html =~ s/\$\$TYPEFULL\$\$/$disp_alloctypes{$webvar{alloctype}}/g; 1122 1150 $html =~ s/\$\$CUSTID\$\$/$webvar{custid}/g; 1151 $html =~ s/\$\$SWIP\$\$/$swiptmp/g; 1123 1152 $webvar{circid} = desanitize($webvar{circid}); 1124 1153 $html =~ s/\$\$CIRCID\$\$/$webvar{circid}/g; -
trunk/cgi-bin/search.cgi
r289 r320 9 9 # Last update by $Author$ 10 10 ### 11 # Copyright 2005 Kris Deugau <kdeugau@deepnet.cx>11 # Copyright 2005,2006 Kris Deugau 12 12 13 13 use strict; … … 106 106 # First chunk of SQL. Filter on custid, description, and notes as necessary. 107 107 my $sql = "(select $cols from searchme where $webvar{custexclude} custid ilike '%$webvar{custid}%')". 108 " $sqlconcat $webvar{custexclude} oldcustid ilike '%$webvar{custid}%')". 108 109 " $sqlconcat (select $cols from searchme where $webvar{descexclude} description ilike '%$webvar{desc}%')". 109 110 " $sqlconcat (select $cols from searchme where $webvar{notesexclude} notes ilike '%$webvar{notes}%')"; … … 283 284 # Query for a customer ID. Note that we can't restrict to "numeric-only" 284 285 # as we have non-numeric custIDs in the legacy data. :/ 285 $sql = "select * from searchme where custid ilike '%$query%' ";286 $sql = "select * from searchme where custid ilike '%$query%' or oldcustid ilike '%$query%'"; 286 287 my $count = countRows($sql); 287 288 $sql .= " order by cidr limit $RESULTS_PER_PAGE offset $offset"; -
trunk/editDisplay.html
r284 r320 13 13 14 14 <tr class="color2"><td class=heading>CustID:</td><td class="regular">$$CUSTID$$</td></tr> 15 <tr class="color2"><td class=heading>Old CustID:</td><td class="regular">$$OLDCUSTID$$</td></tr> 16 17 <tr class="color2"><td class=heading>SWIPed?:</td><td class=regular>$$SWIP$$</td></tr> 15 18 16 19 <tr class="color1"><td class=heading>Last modified:</td><td class=regular>$$LASTMOD$$</td></tr> -
trunk/updated.html
r284 r320 6 6 <tr class="color1"><td>Type:</td><td>$$TYPEFULL$$</td></tr> 7 7 <tr class="color2"><td>Customer ID:</td><td>$$CUSTID$$</td></tr> 8 <tr class="color2"><td>SWIPed?:</td><td>$$SWIP$$</td></tr> 8 9 <tr class="color1"><td>Circuit ID:</td><td>$$CIRCID$$</td></tr> 9 10 <tr class="color2"><td valign="top">Description/Name:</td><td>$$DESC$$</td></tr>
Note:
See TracChangeset
for help on using the changeset viewer.