Changeset 422


Ignore:
Timestamp:
07/06/10 15:50:22 (14 years ago)
Author:
Kris Deugau
Message:

/trunk

checkpoint, email notice management. See #21.
Completed: display list, edit reciplist

Location:
trunk/cgi-bin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/IPDB.pm

    r420 r422  
    827827  my ($action,$subj,$message) = @_;
    828828
     829##fixme: need to redesign the breakdown/processing for $action for proper handling of all cases
     830
    829831# split action into parts for fiddlement.  nb: there are almost certainly better ways to do this.
    830   my @actionbits = ($action =~ /^(.)(.)(.)$/);
     832  my @actionbits = split //, $action;
    831833
    832834  # want to notify anyone who has specifically requested notify on *this* type ($action as passed),
     
    859861    $mailer->mail("ipdb\@$domain");
    860862    $mailer->to($recip);
    861     $mailer->data("From: \"IP Database\" <ipdb\@$domain>\n",
     863    $mailer->data("From: \"$org_name IP Database\" <ipdb\@$domain>\n",
    862864        "To: $recip\n",
    863865        "Date: ".strftime("%a, %d %b %Y %H:%M:%S %z",localtime)."\n",
  • trunk/cgi-bin/admin.cgi

    r418 r422  
    111111Bump "last updated" timestamp on this master: <select name=whichmaster>$masterlist</select>
    112112<input type=submit value="Update timestamp"> (Sets timestamp to "now")</form>
    113 <a href="admin.cgi?action=listcust">Edit customer data for rWHOIS</a>
     113<a href="admin.cgi?action=listcust">Edit customer data for rWHOIS</a> - data used for
     114blocks with the SWIP box checkmarked.  Links to edit/add data are on this page.
    114115
    115116<hr><a href="admin.cgi?action=showpools">List IP Pools</a> for manual tweaking and updates
     117
    116118<hr><a href="admin.cgi?action=showusers">Manage users</a> (add/remove users;  change
    117 internal access controls - note that this does NOT include IP-based limits)
     119internal access controls - note that this does NOT include IP-based limits)<br>
     120<a href="admin.cgi?action=emailnotice">Manage email notice options</a> (pick which events
     121and allocation types cause notifications;  configure recipient lists for notices)
     122
    118123<hr>Consistency check tools<br>
    119124<a href="consistency-check.pl">General</a>:  Check general netblock consistency.<br>
    120125<a href="freespace.pl">Free space</a>:  List total and aggregate free space.  Does not
    121126include private networks (192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8)
    122 <hr>(r)WHOIS<br>
    123 <a href="list-cust.php">List customer data for WHOIS</a> - data used for blocks with the SWIP box checkmarked.
    124 Links to edit/add data are on this page.
    125127);
    126128} else {
     
    254256        syslog "notice", "$authuser allocated '$webvar{cidr}' to '$webvar{custid}' as ".
    255257                "'$webvar{alloctype}'";
    256         mailNotify($ip_dbh, "$disp_alloctypes{$webvar{alloctype}} allocation",
     258        mailNotify($ip_dbh, "a$webvar{alloctype}",
    257259          "$disp_alloctypes{$webvar{alloctype}} $webvar{cidr} allocated to customer".
    258260          " $webvar{custid}\n".
     
    312314<input type=hidden name=newcust value=1>
    313315<td>CustID:</td><td><input name=custid></td>
    314 <!-- <td>Name:</td><td><input name=name></td></tr>
    315 <tr><td>Street:</td><td><input name=street></td></tr> -->
    316 <!-- <td>Street2:</td><td><input name=street2></td> -->
    317 <!-- <tr><td>City:</td><td><input name=city></td>
    318 <td>Province: (2-letter code)</td><td><input name=province value=ON length=2 size=2></td></tr>
    319 <tr><td>Country: (2-letter code)</td><td><input name=country value=CA length=2 size=2></td>
    320 <td>Postal/ZIP Code:</td><td><input name=pocode></td></tr>
    321 <tr><td>Phone:</td><td><input name=phone></td> -->
    322 <!-- <td>Default rDNS:</td><td><input name=def_rdns></td></tr>
    323 <td>Description:</td><td><input name=description></td> -->
    324 <!-- </tr>
    325 <tr>
    326 <td>ARIN Handles:</td><td>
    327  Tech: <input name=tech_handle value="VH25-ORG-ARIN"><br>
    328  Abuse: <input name=abuse_handle><br>
    329  Admin: <input name=admin_handle><br>
    330 Note:  Only tech is required at the moment.
    331 </td>
    332 <td>"Special":</td><td><textarea name=special rows=4 cols=40></textarea></td>
    333 </tr> -->
    334316<td align=center><input type=submit value="Go to edit page for this custid"></td></tr>
    335317</form></table>
     
    344326  }
    345327  print "</table>\n";
    346 } elsif ($webvar{action} eq 'newcust') {
    347   if ($webvar{custid} eq '') {
    348     print 'No CustID entered.  PTHBT!  (Hit "Back" and fix the problem.)';
    349   } else {
    350     $sth = $ip_dbh->prepare("insert into customers ".
    351         "(custid, name, street, city, province, country, pocode, ".
    352         "phone, tech_handle, abuse_handle, admin_handle) values ".
    353         "('$webvar{custid}', '$webvar{name}', '$webvar{street}', ".
    354         "'$webvar{city}', '$webvar{province}', '$webvar{country}', ".
    355         "'$webvar{pocode}', '$webvar{phone}', '$webvar{techhandle}', ".
    356         "'$webvar{abusehandle}', '$webvar{adminhandle}')");
    357     $sth->execute;
    358     if ($sth->err) {
    359       print "INSERT failed:  ".$sth->errstr."\n";
    360     } else {
    361       print "Success!  Added customer contact data:\n".
    362         qq(<table border=1><tr>
    363 <td>CustID:</td>$webvar{custid}</td><td>Name:</td>$webvar{name}</td></tr>
    364 <tr><td>Street:</td><td>$webvar{street}</td></tr>
    365 <tr><td>City:</td><td>$webvar{city}</td><td>Province:</td><td>$webvar{province}</td></tr>
    366 <tr><td>Country:</td><td>$webvar{country}</td>
    367 <td>Postal/ZIP Code:</td><td>$webvar{pocode}</td></tr>
    368 <tr><td>Phone:</td><td>$webvar{phone}</td>
    369 <!-- <td>Default rDNS:</td><td><input name=def_rdns></td></tr>
    370 <tr><td>Description:</td><td><input name=description></td> -->
    371 <td>ARIN Handles:</td><td>
    372  Tech: $webvar{tech_handle}<br>
    373  Abuse: $webvar{abuse_handle}<br>
    374  Admin: $webvar{admin_handle}<br>
    375 </td></tr></table>
    376 );
    377     } # $sth err check
    378   } # bad custid
    379328} elsif ($webvar{action} eq 'edcust') {
    380329  if ($webvar{newcust}) {
     
    415364<div style="margin-left:5px">
    416365<h3>Explanation for "Special" field:</h3>
    417 This is the field I've mangled into providing a custom WHOIS netname identifier for blocks tagged "SWIP".
     366This is a temporary place to define the WHOIS "net name" for a block.
    418367It may be removed later, more likely migrated elsewhere.
    419368<p>It's formatted like this, one line for each custom net name:
    420369<pre>NetName[CIDR block]: NET-NAME</pre>
    421370Example:
    422 <pre>NetName209.91.133.0/24: CYBERSUDBURY-1</pre>
     371<pre>NetName192.168.236.0/24: MEGAWIDGET-1</pre>
    423372Note:
    424373<ul style="margin-top: 0px;">
     
    572521  print qq(<hr><a href="admin.cgi?action=showusers">Back</a> to user listing\n);
    573522
     523} elsif ($webvar{action} eq 'emailnotice') {
     524  print "<h4>Email notice management:</h4>\nClick the email addresses to edit that list.";
     525  $sth = $ip_dbh->prepare("SELECT action,reciplist FROM notify");
     526  $sth->execute;
     527
     528  print "<table border=1>\n";
     529  while (my ($notice_code,$reciplist) = $sth->fetchrow_array() ) {
     530##fixme: hairy mess, only a few things call mailNotify() anyway, so many possible notices won't work.
     531    my $action_out = dispNoticeCode($notice_code);
     532    print "<tr><td>$action_out</td>".
     533        qq(<td><a href="admin.cgi?action=ednotice&code=$notice_code">$reciplist</a></td>).
     534        qq(<td><a href="admin.cgi?action=delnotice&code=$notice_code">Delete</a></tr>\n);
     535  }
     536  print "</table>\n";
     537} elsif ($webvar{action} eq 'ednotice') {
     538  print "<h4>Editing recipient list for '".dispNoticeCode($webvar{code})."':</h4>\n";
     539##work
     540  $sth = $ip_dbh->prepare("SELECT reciplist FROM notify WHERE action=?");
     541  $sth->execute($webvar{code});
     542  my ($reciplist) = $sth->fetchrow_array;
     543  $reciplist =~ s/,/\n/g;
     544  print qq(<form action=admin.cgi method=POST><input type=hidden name=code value="$webvar{code}">\n).
     545        qq(<input type=hidden name=action value="updnotice"><table border=1><tr><td>).
     546        qq(<textarea cols="40" rows="5" name=reciplist>$reciplist</textarea></td><td><input type=submit value="Update">\n).
     547        "</td></tr></table></form>\n";
     548} elsif ($webvar{action} eq 'updnotice') {
     549  print "<h4>Updating recipient list for '".dispNoticeCode($webvar{code})."':</h4>\n";
     550  $sth = $ip_dbh->prepare("UPDATE notify SET reciplist=? WHERE action=?");
     551  $webvar{reciplist} =~ s/[\r\n]+/,/g;
     552  $sth->execute($webvar{reciplist}, $webvar{code});
     553  if ($sth->err) {
     554    print "Failed:  DB error: ".$sth->errstr."\n";
     555  } else {
     556    print "OK!<br>\n"
     557  }
     558  print qq(<a href="admin.cgi?action=emailnotice">Back to email notice list</a>\n);
    574559} elsif ($webvar{action} ne '<NULL>') {
    575560  print "webvar{action} check failed: Don't know how to $webvar{action}";
     
    724709  print "</form></table>\n";
    725710}
     711
     712
     713# interpret the notify codes
     714sub dispNoticeCode {
     715  my $code = shift;
     716  my $action_out = '';
     717#    my $code = $notice_code;
     718  if ($code =~ /^f:(.+)$/) {
     719    $code =~ s/^f://;
     720    $action_out = "Failure on ";
     721  }
     722  if (my $target = $code =~ /^n(.+)/) {
     723    $action_out .= "New ";
     724    if ($1 eq 'ci') { $action_out .= "city"; }
     725    elsif ($1 eq 'no') { $action_out .= "node"; }
     726    else { $action_out .= '&lt;unknown&gt;'; }
     727  } else {
     728    my ($action,$target) = ($code =~ /^(.)(.+)$/);
     729    if ($action eq 'a')      { $action_out .= 'Add '; }
     730    elsif ($action eq 'u')   { $action_out .= 'Update '; }
     731    elsif ($action eq 'd')   { $action_out .= 'Delete '; }
     732##fixme:  what if we get something funky?
     733    if ($target eq 'a') { $action_out .= "all"; }
     734    else { $action_out .= $disp_alloctypes{$target}; }
     735  }
     736  return $action_out;
     737}
Note: See TracChangeset for help on using the changeset viewer.