Index: trunk/dns.cgi
===================================================================
--- trunk/dns.cgi	(revision 10)
+++ trunk/dns.cgi	(revision 11)
@@ -48,8 +48,6 @@
 # handle login redirect
 if ($webvar{action} && $webvar{action} eq 'login') {
-  # handle user check
-  my $newurl = "http://$ENV{HTTP_HOST}$ENV{REQUEST_URI}?sid=$sid&page=domlist";
-  print "Status: 302\nLocation: $newurl\n\n";
-  exit;
+  ##fixme:  need to actually do a user/pass check
+  changepage(page => "domlist");
 }
 
@@ -98,5 +96,5 @@
   }
 
-  domlist();
+  listdomains();
 
 } elsif ($webvar{page} eq 'reclist') {
@@ -151,4 +149,31 @@
   $page->param(grplist => \@grplist);
 
+} elsif ($webvar{page} eq 'deldom') {
+
+  $page->param(id => $webvar{id});
+  # first pass = confirm y/n (sorta)
+  if (!defined($webvar{del})) {
+    $page->param(del_getconf => 1);
+    $page->param(domain => domainName($dbh,$webvar{id}));
+# print some neato things?
+
+#  } else {
+#    #whether actually deleting or cancelling we redirect to the domain list, default format
+
+  } elsif ($webvar{del} eq 'ok') {
+    my ($code,$msg) = delDomain($dbh, $webvar{id});
+    if ($code ne 'OK') {
+# need to find failure mode
+      $page->param(del_failed => 1);
+      $page->param(errmsg => $msg);
+    } else {
+      # success.  go back to the domain list, do not pass "GO"
+      changepage(page => "domlist");
+    }
+  } else {
+    # cancelled.  whee!
+    changepage(page => "domlist");
+  }
+
 } elsif ($webvar{page} eq 'newrec') {
   print "whee!\n";
@@ -214,32 +239,4 @@
 ##fixme:  group/parent instead of hardcoded 1
     showdomain('y',1);
-  }
-
-} elsif ($webvar{page} eq 'deldom') {
-
-  $page->param(id => $webvar{id});
-  # first pass = confirm y/n (sorta)
-  if (!defined($webvar{del})) {
-    $page->param(del_getconf => 1);
-    $page->param(domain => domainName($dbh,$webvar{id}));
-# print some neato things?
-
-#  } else {
-#    #whether actually deleting or cancelling we redirect to the domain list, default format
-
-  } elsif ($webvar{del} eq 'ok') {
-    my ($code,$msg) = delDomain($dbh, $webvar{id});
-    if ($code ne 'OK') {
-# need to find failure mode
-      $page->param(del_failed => 1);
-      $page->param(errmsg => $msg);
-    } else {
-##work
-      domlist();
-    }
-  } else {
-    # cancelled.  whee!
-    $page->param(del_failed => 0);
-    domlist();
   }
 
@@ -280,4 +277,6 @@
 # hokay, a bit of magic to decide which page we hit.
   if ($code eq 'OK') {
+# redirect to dns.cgi?etc&page=reclist
+    print $q->redirect("");
     $page = HTML::Template->new(filename => "$templatedir/reclist.tmpl");
     showdomain(0,$msg);
@@ -315,4 +314,18 @@
 
 exit 0;
+
+
+sub changepage {
+  my %params = @_;	# think this works the way I want...
+
+  # handle user check
+  my $newurl = "http://$ENV{HTTP_HOST}$ENV{SCRIPT_NAME}?sid=$sid";
+  foreach (keys %params) {
+    $newurl .= "&$_=$params{$_}";
+  }
+
+  print "Status: 302\nLocation: $newurl\n\n";
+  exit;
+} # end changepage
 
 
@@ -441,5 +454,5 @@
 
 
-sub domlist {
+sub listdomains {
   my $sth = $dbh->prepare("select count(*) from domains");
   $sth->execute;
@@ -477,3 +490,3 @@
   }
   $page->param(domtable => \@domlist);
-} # end domlist()
+} # end listdomains()
