Ignore:
Timestamp:
05/13/10 13:17:04 (15 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Merge extra pieces of admin.cgi from /trunk. See #13.

File:
1 edited

Legend:

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

    r391 r411  
    7474  while (my @data = $sth->fetchrow_array) {
    7575    $typelist .= "<option value='$data[0]'>$data[1]</option>\n";
     76  }
     77
     78  my $masterlist = '';
     79  $sth = $ip_dbh->prepare("select cidr,mtime from masterblocks order by cidr");
     80  $sth->execute;
     81  while (my @data = $sth->fetchrow_array) {
     82    $masterlist .= "<option value='$data[0]'>$data[0] ($data[1])</option>\n";
    7683  }
    7784
     
    9097<input type=submit value="Show allocations">
    9198</form>
     99
     100<hr>rWHOIS tools:
     101<form action="admin.cgi" method="POST">
     102<input type=hidden name=action value=touch>
     103Bump "last updated" timestamp on this master: <select name=whichmaster>$masterlist</select>
     104<input type=submit value="Update timestamp"> (Sets timestamp to "now")</form>
     105<a href="admin.cgi?action=listcust">Edit customer data for rWHOIS</a>
     106
    92107<hr><a href="admin.cgi?action=showpools">List IP Pools</a> for manual tweaking and updates
    93108<hr><a href="admin.cgi?action=showusers">Manage users</a> (add/remove users;  change
     
    276291
    277292  print $html;
     293} elsif ($webvar{action} eq 'touch') {
     294  print "Touching master $webvar{whichmaster}\n";
     295  $sth = $ip_dbh->prepare("update masterblocks set mtime=now() where cidr='$webvar{whichmaster}'");
     296  $sth->execute;
     297  if ($sth->err) {
     298    print "<p>Error updating modified timestamp on master $webvar{whichmaster}: ".$sth->errstr."\n";
     299  }
     300} elsif ($webvar{action} eq 'listcust') {
     301  print qq(Add new entry:\n
     302<form action=admin.cgi method=POST>
     303<table border=1><tr>
     304<input type=hidden name=action value=newcust>
     305<td>CustID:</td><td><input name=custid></td>
     306<td>Name:</td><td><input name=name></td></tr>
     307<tr><td>Street:</td><td><input name=street></td></tr>
     308<!-- <td>Street2:</td><td><input name=street2></td> -->
     309<tr><td>City:</td><td><input name=city></td>
     310<td>Province: (2-letter code)</td><td><input name=province value=ON length=2 size=2></td></tr>
     311<tr><td>Country: (2-letter code)</td><td><input name=country value=CA length=2 size=2></td>
     312<td>Postal/ZIP Code:</td><td><input name=pocode></td></tr>
     313<tr><td>Phone:</td><td><input name=phone></td>
     314<!-- <td>Default rDNS:</td><td><input name=def_rdns></td></tr>
     315<td>Description:</td><td><input name=description></td> -->
     316<td>ARIN Handles:</td><td>
     317 Tech: <input name=tech_handle value="VH25-ORG-ARIN"><br>
     318 Abuse: <input name=abuse_handle><br>
     319 Admin: <input name=admin_handle><br>
     320Note:  Only tech is required at the moment.
     321</td></tr>
     322<tr><td colspan=4 align=center><input type=submit value="Add"></td></tr>
     323</form></table>
     324);
     325  print "<p>Click CustID to edit existing customer contact data:\n".
     326        "<table border=1>\n<tr><td>CustID</td><td>Name</td><td>Tech handle</td></tr>\n";
     327  $sth = $ip_dbh->prepare("select custid,name,tech_handle from customers order by custid");
     328  $sth->execute;
     329  while (my @data = $sth->fetchrow_array) {
     330    print qq(<tr><td><a href="admin.cgi?action=edcust&custid=$data[0]">$data[0]</td>).
     331        "<td>$data[1]</td><td>$data[2]</td></tr>\n";
     332  }
     333  print "</table>\n";
     334} elsif ($webvar{action} eq 'newcust') {
     335  if ($webvar{custid} eq '') {
     336    print 'No CustID entered.  PTHBT!  (Hit "Back" and fix the problem.)';
     337  } else {
     338    $sth = $ip_dbh->prepare("insert into customers ".
     339        "(custid, name, street, city, province, country, pocode, ".
     340        "phone, tech_handle, abuse_handle, admin_handle) values ".
     341        "('$webvar{custid}', '$webvar{name}', '$webvar{street}', ".
     342        "'$webvar{city}', '$webvar{province}', '$webvar{country}', ".
     343        "'$webvar{pocode}', '$webvar{phone}', '$webvar{techhandle}', ".
     344        "'$webvar{abusehandle}', '$webvar{adminhandle}')");
     345    $sth->execute;
     346    if ($sth->err) {
     347      print "INSERT failed:  ".$sth->errstr."\n";
     348    } else {
     349      print "Success!  Added customer contact data:\n".
     350        qq(<table border=1><tr>
     351<td>CustID:</td>$webvar{custid}</td><td>Name:</td>$webvar{name}</td></tr>
     352<tr><td>Street:</td><td>$webvar{street}</td></tr>
     353<tr><td>City:</td><td>$webvar{city}</td><td>Province:</td><td>$webvar{province}</td></tr>
     354<tr><td>Country:</td><td>$webvar{country}</td>
     355<td>Postal/ZIP Code:</td><td>$webvar{pocode}</td></tr>
     356<tr><td>Phone:</td><td>$webvar{phone}</td>
     357<!-- <td>Default rDNS:</td><td><input name=def_rdns></td></tr>
     358<tr><td>Description:</td><td><input name=description></td> -->
     359<td>ARIN Handles:</td><td>
     360 Tech: $webvar{tech_handle}<br>
     361 Abuse: $webvar{abuse_handle}<br>
     362 Admin: $webvar{admin_handle}<br>
     363</td></tr></table>
     364);
     365    } # $sth err check
     366  } # bad custid
     367} elsif ($webvar{action} eq 'edcust') {
     368  $sth = $ip_dbh->prepare("select custid,name,street,city,province,".
     369        "country,pocode,phone,tech_handle,abuse_handle,admin_handle ".
     370        "from customers where custid='$webvar{custid}'");
     371  $sth->execute;
     372  my ($custid, $name, $street, $city, $prov, $country, $pocode, $phone, $tech, $abuse, $admin) =
     373        $sth->fetchrow_array;
     374  print qq(<form action=admin.cgi method=POST>
     375<table border=1><tr>
     376<input type=hidden name=action value=updcust>
     377<td>CustID:</td><td>$custid<input type=hidden name=custid value=$custid></td>
     378<td>Name:</td><td><input name=name value="$name"></td></tr>
     379<tr><td>Street:</td><td><input name=street value="$street"></td></tr>
     380<!-- <td>Street2:</td><td><input name=street2></td> -->
     381<tr><td>City:</td><td><input name=city value="$city"></td>
     382<td>Province: (2-letter code)</td><td><input name=province value="$prov" length=2 size=2></td></tr>
     383<tr><td>Country: (2-letter code)</td><td><input name=country value="$country" length=2 size=2></td>
     384<td>Postal/ZIP Code:</td><td><input name=pocode value="$pocode"></td></tr>
     385<tr><td>Phone:</td><td><input name=phone value="$pocode"></td>
     386<!-- <td>Default rDNS:</td><td><input name=def_rdns></td></tr>
     387<td>Description:</td><td><input name=description></td> -->
     388<td>ARIN Handles:</td><td>
     389 Tech: <input name=tech_handle value="$tech"><br>
     390 Abuse: <input name=abuse_handle value="$abuse"><br>
     391 Admin: <input name=admin_handle value="$admin"><br>
     392Note:  Only tech is required at the moment.
     393</td></tr>
     394<tr><td colspan=4 align=center><input type=submit value="Update"></td></tr>
     395</form></table>
     396);
     397
     398} elsif ($webvar{action} eq 'updcust') {
     399  print "Updated $webvar{custid}\n";
    278400} elsif ($webvar{action} eq 'showpools') {
    279401  print "IP Pools currently allocated:\n".
     
    542664  print "</form></table>\n";
    543665}
    544 
Note: See TracChangeset for help on using the changeset viewer.