Index: /trunk/cgi-bin/access-pwd-update.pl
===================================================================
--- /trunk/cgi-bin/access-pwd-update.pl	(revision 380)
+++ /trunk/cgi-bin/access-pwd-update.pl	(revision 380)
@@ -0,0 +1,51 @@
+#!/usr/bin/perl
+# Update IPDB users table with user/password data from 5-minute
+# cron'ed push from billing
+###
+# SVN revision info
+# $Date$
+# SVN revision $Rev$
+# Last update by $Author$
+###
+# Copyright (C) 2007 - Kris Deugau
+
+use strict;
+use warnings;
+use DBI;
+use MyIPDB;
+
+my $ip_dbh;
+my $errstr;
+($ip_dbh,$errstr) = connectDB_My;
+if (!$ip_dbh) {
+  die "Database error: $errstr\n";
+}
+initIPDBGlobals($ip_dbh);
+
+my %userhash;
+
+open HTPASS, "</var/www/ipdb.example.com/ip/.htpasswd";
+
+my $sth = $ip_dbh->prepare("select count(*) from users where username=?");
+
+while (<HTPASS>) {
+  chomp;
+  my ($user,$pass) = split /:/;
+  $sth->execute($user);
+  my @data = $sth->fetchrow_array();
+  my $sql;
+  if ($data[0] == 0) {
+    $sql = "insert into users (username,password) values ('$user','$pass')";
+  } else {
+    $sql = "update users set password='$pass' where username='$user'";
+  }
+  my $sth2 = $ip_dbh->prepare($sql);
+  $sth2->execute or print "error executing $sql: ".$DBI::errstr."\n";
+  $userhash{$user} = $pass;
+}
+my @userlist = @{ $ip_dbh->selectall_arrayref("select username from users") };
+$sth = $ip_dbh->prepare("delete from users where username=?");
+foreach my $user (@userlist) {
+  $sth->execute if !$userhash{$user}
+    or print "error deleting $user: ".$DBI::errstr."\n";
+}
Index: /trunk/cgi-bin/extras/db2rwhois.pl
===================================================================
--- /trunk/cgi-bin/extras/db2rwhois.pl	(revision 379)
+++ /trunk/cgi-bin/extras/db2rwhois.pl	(revision 380)
@@ -41,5 +41,4 @@
 my @masterblocks;
 my %netnameprefix;
-my %def_custids;
 
 # Get the list of live directories for potential deletion
@@ -282,11 +281,11 @@
 	"IP-Network: $net\n".
 	"IP-Network-Block: ".$net->range."\n".
-	"Org-Name: $name\n".
-	"Street-Address: $street\n".
-	"City: $city\n".
-	"StateProv: $prov\n".
-	"Postal-Code: $pocode\n".
-	"Country-Code: $country\n".
-	"Tech-Contact: $tech\n".
+	"Org-Name: ".($name ? $name : 'Friendly ISP')."\n".
+	"Street-Address: ".($street ? $street : '123 4th Street')."\n".
+	"City: ".($city ? $city : 'Anytown')."\n".
+	"StateProv: ".($prov ? $prov : 'Ontario')."\n".
+	"Postal-Code: ".($pocode ? $pocode : 'H0H 0H0')."\n".
+	"Country-Code: ".($country ? $country : 'CA')."\n".
+	"Tech-Contact: ".($tech ? $tech : 'ISP-ARIN-HANDLE')."\n".
 	"Created: $ctime\n".
 	"Updated: $mtime\n".
Index: /trunk/cgi-bin/ipdb.psql
===================================================================
--- /trunk/cgi-bin/ipdb.psql	(revision 379)
+++ /trunk/cgi-bin/ipdb.psql	(revision 380)
@@ -158,5 +158,5 @@
 fc	Reserve for fibre	Fibre blocks	203	6750400	ISP
 wr	CORE/WAN block	CORE/WAN block	220	6750400	ISP
-pr	Dynamic-route DSL netblock	Dynamic-route DSL	221		ISP
+pr	Dynamic-route DSL netblock (cust)	Dynamic-route DSL (cust)	221		ISPCUST
 ar	ATM block	ATM block	222		ISP
 fr	Fibre	Fibre	223	ATM-BUS	ISP
Index: /trunk/cgi-bin/main.cgi
===================================================================
--- /trunk/cgi-bin/main.cgi	(revision 379)
+++ /trunk/cgi-bin/main.cgi	(revision 380)
@@ -400,4 +400,8 @@
   $sth->execute();
 
+  # hack hack hack
+  # set up to flag swip=y records if they don't actually have supporting data in the customers table
+  my $custsth = $ip_dbh->prepare("select count(*) from customers where custid=?");
+
   my $count=0;
   while (my @data = $sth->fetchrow_array()) {
@@ -408,9 +412,12 @@
 #    $data[2] =~ s/\s+//g;
 
+    $custsth->execute($data[3]);
+    my ($ncust) = $custsth->fetchrow_array();
+
     # Prefix subblocks with "Sub "
     my @row = ( (($data[2] =~ /^.r$/) ? 'Sub ' : '').
 	qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>),
 	$data[1], $disp_alloctypes{$data[2]}, $data[3], 
-	($data[4] eq 'y' ? 'Yes' : 'No'), $data[5]);
+	($data[4] eq 'y' ? ($ncust == 0 ? 'Yes<small>*</small>' : 'Yes') : 'No'), $data[5]);
     # If the allocation is a pool, allow listing of the IPs in the pool.
     if ($data[2] =~ /^.[pd]$/) {
@@ -841,5 +848,5 @@
       print qq(<div class="center"><div class="heading">The IP $msg has been allocated to customer $webvar{custid}</div>).
 	( ($webvar{alloctype} eq 'di' && $webvar{billinguser}) ?
-		qq(<div><a href="https://billing.example.com/extserv.pl?).
+		qq(<div><a href="https://billing.example.com/radius.pl?).
 		"action=new_radius_user&custid=$webvar{custid}&userid=$webvar{billinguser}".
 		qq(&ipdb=1&ip=$msg">Add this IP to RADIUS user table</a></div>)
@@ -854,5 +861,5 @@
 	"sucessfully added as: $disp_alloctypes{$webvar{alloctype}}</div>".
 	( ($webvar{alloctype} eq 'pr' && $webvar{billinguser}) ?
-		qq(<div><a href="https://billing.example.com/extserv.pl?).
+		qq(<div><a href="https://billing.example.com/radius.pl?).
 		"action=new_radius_user&custid=$webvar{custid}&userid=$webvar{billinguser}".
 		"&route_subnet=".$netblock->addr."&subnet_slash=".$netblock->masklen.
@@ -1120,4 +1127,23 @@
   my $html = join('', <HTML>);
 
+  # Link back to browse-routed or list-pool page on "Update complete" page.
+  my $backlink = "/ip/cgi-bin/main.cgi?action=";
+  my $cblock;	# to contain the CIDR of the container block we're retrieving.
+  my $sql;
+  if (my $pooltype = ($webvar{alloctype} =~ /^(.)i$/) ) {
+    $sql = "select pool from poolips where ip='$webvar{block}'";
+    $backlink .= "listpool&pool=";
+  } else {
+    $sql = "select cidr from routed where cidr >>= '$webvar{block}'";
+    $backlink .= "showrouted&block=";
+  }
+  # I define there to be no errors on this operation...  so we don't need to check for them.
+  $sth = $ip_dbh->prepare($sql);
+  $sth->execute;
+  $sth->bind_columns(\$cblock);
+  $sth->fetch();
+  $sth->finish;
+  $backlink .= $cblock;
+
 my $swiptmp = ($webvar{swip} eq 'on' ? 'Yes' : 'No');
   $html =~ s/\$\$BLOCK\$\$/$webvar{block}/g;
@@ -1134,4 +1160,6 @@
   $webvar{notes} = desanitize($webvar{notes});
   $html =~ s/\$\$NOTES\$\$/$webvar{notes}/g;
+  $html =~ s/\$\$BACKLINK\$\$/$backlink/g;
+  $html =~ s/\$\$BACKBLOCK\$\$/$cblock/g;
 
   if ($IPDBacl{$authuser} =~ /s/) {
Index: /trunk/header.inc
===================================================================
--- /trunk/header.inc	(revision 379)
+++ /trunk/header.inc	(revision 380)
@@ -34,5 +34,5 @@
 </tbody></table>
 
-<table width="100%" border="0" cellspacing="0" cellpadding="0"
+<table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr bgcolor="#000000"><td></td></tr></table>
 <!-- end line and top. -->
Index: /trunk/updated.html
===================================================================
--- /trunk/updated.html	(revision 379)
+++ /trunk/updated.html	(revision 380)
@@ -13,2 +13,6 @@
 </table>
 </div>
+<p>
+<div name="backlink">
+<a href="$$BACKLINK$$">Back to $$BACKBLOCK$$</a>
+</div>
