Ignore:
Timestamp:
04/07/06 13:36:54 (18 years ago)
Author:
Kris Deugau
Message:

/trunk

Update SQL tabledefs with defaults on the customers table

(province/country/tech handle)

First iteration of cust data handling for rWHOIS - allow display

of existing data, entry of complete fresh new data.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/admin.cgi

    r320 r329  
    7373  while (my @data = $sth->fetchrow_array) {
    7474    $typelist .= "<option value='$data[0]'>$data[1]</option>\n";
     75  }
     76
     77  my $masterlist = '';
     78  $sth = $ip_dbh->prepare("select cidr,mtime from masterblocks order by cidr");
     79  $sth->execute;
     80  while (my @data = $sth->fetchrow_array) {
     81    $masterlist .= "<option value='$data[0]'>$data[0] ($data[1])</option>\n";
    7582  }
    7683
     
    8996<input type=submit value="Show allocations">
    9097</form>
     98
     99<hr>rWHOIS tools:
     100<form action="admin.cgi" method="POST">
     101<input type=hidden name=action value=touch>
     102Bump "last updated" timestamp on this master: <select name=whichmaster>$masterlist</select>
     103<input type=submit value="Update timestamp"> (Sets timestamp to "now")</form>
     104<a href="admin.cgi?action=listcust">Edit customer data for rWHOIS</a>
     105
    91106<hr><a href="admin.cgi?action=showpools">List IP Pools</a> for manual tweaking and updates
    92107<hr><a href="admin.cgi?action=showusers">Manage users</a> (add/remove users;  change
     
    257272
    258273  print $html;
     274} elsif ($webvar{action} eq 'touch') {
     275  print "Touching master $webvar{whichmaster}\n";
     276} elsif ($webvar{action} eq 'listcust') {
     277  print qq(Add new entry:\n
     278<form action=admin.cgi method=POST>
     279<table border=1><tr>
     280<input type=hidden name=action value=newcust>
     281<td>CustID:</td><td><input name=custid></td>
     282<td>Name:</td><td><input name=name></td></tr>
     283<tr><td>Street:</td><td><input name=street></td></tr>
     284<!-- <td>Street2:</td><td><input name=street2></td> -->
     285<tr><td>City:</td><td><input name=city></td>
     286<td>Province: (2-letter code)</td><td><input name=province value=ON length=2 size=2></td></tr>
     287<tr><td>Country: (2-letter code)</td><td><input name=country value=CA length=2 size=2></td>
     288<td>Postal/ZIP Code:</td><td><input name=pocode></td></tr>
     289<tr><td>Phone:</td><td><input name=phone></td>
     290<!-- <td>Default rDNS:</td><td><input name=def_rdns></td></tr>
     291<td>Description:</td><td><input name=description></td> -->
     292<td>ARIN Handles:</td><td>
     293 Tech: <input name=tech_handle value="VH25-ORG-ARIN"><br>
     294 Abuse: <input name=abuse_handle><br>
     295 Admin: <input name=admin_handle><br>
     296Note:  Only tech is required at the moment.
     297</td></tr>
     298<tr><td colspan=4 align=center><input type=submit value="Add"></td></tr>
     299</form></table>
     300);
     301  print "<p>Edit existing customer contact data:\n".
     302        "<table border=1>\n<tr><td>CustID</td><td>Name</td><td>Tech handle</td></tr>\n";
     303  $sth = $ip_dbh->prepare("select custid,name,tech_handle from customers order by custid");
     304  $sth->execute;
     305  while (my @data = $sth->fetchrow_array) {
     306    print "<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td></tr>\n";
     307  }
     308} elsif ($webvar{action} eq 'newcust') {
     309  if ($webvar{custid} eq '') {
     310    print 'No CustID entered.  PTHBT!  (Hit "Back" and fix the problem.)';
     311  } else {
     312print "<table border=1>\n";
     313foreach my $key (keys %webvar) {
     314  print "<tr><td>$key</td><td>$webvar{$key}</td><tr>\n";
     315}
     316print "</table>\n";
     317    $sth = $ip_dbh->prepare("insert into customers ".
     318        "(custid, name, street, city, province, country, pocode, ".
     319        "phone, tech_handle, abuse_handle, admin_handle) values ".
     320        "('$webvar{custid}', '$webvar{name}', '$webvar{street}', ".
     321        "'$webvar{city}', '$webvar{province}', '$webvar{country}', ".
     322        "'$webvar{pocode}', '$webvar{phone}', '$webvar{techhandle}', ".
     323        "'$webvar{abusehandle}', '$webvar{adminhandle}')");
     324    $sth->execute;
     325    if ($sth->err) {
     326      print "INSERT failed:  ".$sth->errstr."\n";
     327    } else {
     328      print "Success!  Added customer contact data:\n".
     329        qq(<table border=1><tr>
     330<td>CustID:</td>$webvar{custid}</td><td>Name:</td>$webvar{name}</td></tr>
     331<tr><td>Street:</td><td>$webvar{street}</td></tr>
     332<tr><td>City:</td><td>$webvar{city}</td><td>Province:</td><td>$webvar{province}</td></tr>
     333<tr><td>Country:</td><td>$webvar{country}</td>
     334<td>Postal/ZIP Code:</td><td>$webvar{pocode}</td></tr>
     335<tr><td>Phone:</td><td>$webvar{phone}</td>
     336<!-- <td>Default rDNS:</td><td><input name=def_rdns></td></tr>
     337<tr><td>Description:</td><td><input name=description></td> -->
     338<td>ARIN Handles:</td><td>
     339 Tech: $webvar{tech_handle}<br>
     340 Abuse: $webvar{abuse_handle}<br>
     341 Admin: $webvar{admin_handle}<br>
     342</td></tr></table>
     343);
     344    } # $sth err check
     345  } # bad custid
     346} elsif ($webvar{action} eq 'updcust') {
     347  print "Updated $webvar{custid}\n";
    259348} elsif ($webvar{action} eq 'showpools') {
    260349  print "IP Pools currently allocated:\n".
Note: See TracChangeset for help on using the changeset viewer.