Ignore:
Timestamp:
09/16/05 17:21:57 (19 years ago)
Author:
Kris Deugau
Message:

/branches/privdata

Add support for editing/viewing "private"/restricted-access
data field for allocations and static IPs.

New ACL entry: s for systems/networking

SQL tabledefs updated.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/privdata/cgi-bin/main.cgi

    r261 r280  
    904904  # because I'm lazy, we'll try to make the SELECT's bring out identical)ish) data
    905905  if ($webvar{block} =~ /\/32$/) {
    906     $sql = "select ip,custid,type,city,circuitid,description,notes,modifystamp from poolips where ip='$webvar{block}'";
     906    $sql = "select ip,custid,type,city,circuitid,description,notes,modifystamp,privdata from poolips where ip='$webvar{block}'";
    907907  } else {
    908     $sql = "select cidr,custid,type,city,circuitid,description,notes,modifystamp from allocations where cidr='$webvar{block}'"
     908    $sql = "select cidr,custid,type,city,circuitid,description,notes,modifystamp,privdata from allocations where cidr='$webvar{block}'"
    909909  }
    910910
     
    971971  my $i=1;
    972972
     973  # Check to see if we can display sensitive data
     974  my $privdata = '';
     975  if ($IPDBacl{$authuser} =~ /s/) {
     976    $privdata = qq(<tr class="color).($i%2).qq("><td class=heading>Restricted data:</td>).
     977        qq(<td class=regular><textarea rows="3" cols="64" name="privdata" class="regular">).
     978        qq($data[8]</textarea></td></tr>\n);
     979    $i++;
     980  }
     981  $html =~ s/\$\$PRIVDATA\$\$/$privdata/g;
     982
    973983  # More ACL trickery - we can live with forms that don't submit,
    974984  # but we can't leave the extra table rows there, and we *really*
     
    976986  my $updok = '';
    977987  if ($IPDBacl{$authuser} =~ /c/) {
    978     $updok = qq(<tr class="color$i"><td colspan=2><div class="center">).
     988    $updok = qq(<tr class="color).($i%2).qq("><td colspan=2><div class="center">).
    979989        qq(<input type="submit" value=" Update this block " class="regular">).
    980990        "</div></td></tr></form>\n";
     
    986996  if ($IPDBacl{$authuser} =~ /d/) {
    987997    $delok = qq(<form method="POST" action="main.cgi">
    988         <tr class="color$i"><td colspan=2 class="regular"><div class=center>
     998        <tr class="color).($i%2).qq("><td colspan=2 class="regular"><div class=center>
    989999        <input type="hidden" name="action" value="delete">
    9901000        <input type="hidden" name="block" value="$webvar{block}">
     
    10031013# action=update
    10041014sub update {
     1015  if ($IPDBacl{$authuser} !~ /c/) {
     1016    printError("You shouldn't have been able to get here.  Access denied.");
     1017    return;
     1018  }
     1019
     1020  # Check to see if we can update restricted data
     1021  my $privdata = '';
     1022  if ($IPDBacl{$authuser} =~ /s/) {
     1023    $privdata = ",privdata='$webvar{privdata}'";
     1024  }
    10051025
    10061026  # Make sure incoming data is in correct format - custID among other things.
     
    10131033    if (my $pooltype = ($webvar{alloctype} =~ /^(.)i$/) ) {
    10141034      $sql = "update poolips set custid='$webvar{custid}',notes='$webvar{notes}',".
    1015         "circuitid='$webvar{circid}',description='$webvar{desc}',city='$webvar{city}' ".
    1016         "where ip='$webvar{block}'";
     1035        "circuitid='$webvar{circid}',description='$webvar{desc}',city='$webvar{city}'".
     1036        "$privdata where ip='$webvar{block}'";
    10171037    } else {
    10181038      $sql = "update allocations set custid='$webvar{custid}',".
    10191039        "description='$webvar{desc}',notes='$webvar{notes}',city='$webvar{city}',".
    1020         "type='$webvar{alloctype}',circuitid='$webvar{circid}' where cidr='$webvar{block}'";
     1040        "type='$webvar{alloctype}',circuitid='$webvar{circid}'$privdata ".
     1041        "where cidr='$webvar{block}'";
    10211042    }
    10221043    # Log the details of the change.
     
    10541075  $html =~ s/\$\$NOTES\$\$/$webvar{notes}/g;
    10551076
     1077  if ($IPDBacl{$authuser} =~ /s/) {
     1078    $privdata = qq(<tr class="color2"><td valign="top">Restricted data:</td>).
     1079        qq(<td class="regular">).desanitize($webvar{privdata}).qq(</td></tr>\n);
     1080  }
     1081  $html =~ s/\$\$PRIVDATA\$\$/$privdata/g;
     1082
    10561083  print $html;
    10571084
Note: See TracChangeset for help on using the changeset viewer.