Changeset 280


Ignore:
Timestamp:
Sep 16, 2005, 5:21:57 PM (17 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.

Location:
branches/privdata
Files:
5 edited

Legend:

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

    r259 r280  
    285285
    286286  print "<hr>Users with access:\n<table border=1>\n";
     287  print "<tr><td></td><td align=center colspan=3>General access</td></tr>\n";
    287288  print "<tr><td>Username</td><td>Add new</td><td>Change</td>".
    288         "<td>Delete</td><td>Admin user</td></tr>\n".
     289        "<td>Delete</td><td>Systems/Networking</td><td>Admin user</td></tr>\n".
    289290        "<form action=admin.cgi method=POST>\n";
    290291  $sth = $ip_dbh->prepare("select username,acl from users order by username");
     
    298299        "></td><td><input type=checkbox name=change".($data[1] =~ /c/ ? ' checked=y' : '').
    299300        "></td><td><input type=checkbox name=del".($data[1] =~ /d/ ? ' checked=y' : '').
     301        "></td><td><input type=checkbox name=sysnet".($data[1] =~ /s/ ? ' checked=y' : '').
    300302        "></td><td><input type=checkbox name=admin".($data[1] =~ /A/ ? ' checked=y' : '').
    301303        qq(></td><td><input type=submit value="Update"></td></form>\n).
     
    310312  my $acl = 'b';
    311313  if ($webvar{admin} eq 'on') {
    312     $acl .= "acdA";
     314    $acl .= "acdsA";
    313315  } else {
    314316    $acl .= ($webvar{add} eq 'on' ? 'a' : '').
    315317        ($webvar{change} eq 'on' ? 'c' : '').
    316         ($webvar{del} eq 'on' ? 'd' : '');
     318        ($webvar{del} eq 'on' ? 'd' : '').
     319        ($webvar{sysnet} eq 'on' ? 's' : '');
    317320  }
    318321  print "New ACL: $acl<br>\n";
  • branches/privdata/cgi-bin/ipdb.psql

    r257 r280  
    7171        "description" character varying(64) DEFAULT '' NOT NULL,
    7272        "circuitid" character varying(128) DEFAULT '' NOT NULL,
     73        "privdata" text DEFAULT '' NOT NULL,
    7374        "newcustid" integer,
    7475        "createstamp" timestamp DEFAULT now(),
     
    9293        "createstamp" timestamp DEFAULT now(),
    9394        "modifystamp" timestamp DEFAULT now(),
     95        "privdata" text DEFAULT '' NOT NULL,
    9496        "newcustid" integer
    9597);
  • 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
  • branches/privdata/editDisplay.html

    r255 r280  
    2222<tr class="color2"><td class="heading" valign="top">Notes:</td><td class="regular">$$NOTES$$</td></tr>
    2323
     24$$PRIVDATA$$
    2425$$UPDOK$$
    2526$$DELOK$$
  • branches/privdata/updated.html

    r74 r280  
    99<tr class="color2"><td valign="top">Description/Name:</td><td>$$DESC$$</td></tr>
    1010<tr class="color1"><td valign="top">Notes:</td><td>$$NOTES$$</td></tr>
     11$$PRIVDATA$$
    1112</table>
    1213</div>
Note: See TracChangeset for help on using the changeset viewer.