Changeset 11 for trunk


Ignore:
Timestamp:
09/10/09 15:27:29 (15 years ago)
Author:
Kris Deugau
Message:

/trunk

Shuffle some segments for logical grouping
Rearrange domain-delete endpoints to redirect to domlist page instead

of including it - still needs template page fixups and other tweaks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns.cgi

    r10 r11  
    4848# handle login redirect
    4949if ($webvar{action} && $webvar{action} eq 'login') {
    50   # handle user check
    51   my $newurl = "http://$ENV{HTTP_HOST}$ENV{REQUEST_URI}?sid=$sid&page=domlist";
    52   print "Status: 302\nLocation: $newurl\n\n";
    53   exit;
     50  ##fixme:  need to actually do a user/pass check
     51  changepage(page => "domlist");
    5452}
    5553
     
    9896  }
    9997
    100   domlist();
     98  listdomains();
    10199
    102100} elsif ($webvar{page} eq 'reclist') {
     
    151149  $page->param(grplist => \@grplist);
    152150
     151} elsif ($webvar{page} eq 'deldom') {
     152
     153  $page->param(id => $webvar{id});
     154  # first pass = confirm y/n (sorta)
     155  if (!defined($webvar{del})) {
     156    $page->param(del_getconf => 1);
     157    $page->param(domain => domainName($dbh,$webvar{id}));
     158# print some neato things?
     159
     160#  } else {
     161#    #whether actually deleting or cancelling we redirect to the domain list, default format
     162
     163  } elsif ($webvar{del} eq 'ok') {
     164    my ($code,$msg) = delDomain($dbh, $webvar{id});
     165    if ($code ne 'OK') {
     166# need to find failure mode
     167      $page->param(del_failed => 1);
     168      $page->param(errmsg => $msg);
     169    } else {
     170      # success.  go back to the domain list, do not pass "GO"
     171      changepage(page => "domlist");
     172    }
     173  } else {
     174    # cancelled.  whee!
     175    changepage(page => "domlist");
     176  }
     177
    153178} elsif ($webvar{page} eq 'newrec') {
    154179  print "whee!\n";
     
    214239##fixme:  group/parent instead of hardcoded 1
    215240    showdomain('y',1);
    216   }
    217 
    218 } elsif ($webvar{page} eq 'deldom') {
    219 
    220   $page->param(id => $webvar{id});
    221   # first pass = confirm y/n (sorta)
    222   if (!defined($webvar{del})) {
    223     $page->param(del_getconf => 1);
    224     $page->param(domain => domainName($dbh,$webvar{id}));
    225 # print some neato things?
    226 
    227 #  } else {
    228 #    #whether actually deleting or cancelling we redirect to the domain list, default format
    229 
    230   } elsif ($webvar{del} eq 'ok') {
    231     my ($code,$msg) = delDomain($dbh, $webvar{id});
    232     if ($code ne 'OK') {
    233 # need to find failure mode
    234       $page->param(del_failed => 1);
    235       $page->param(errmsg => $msg);
    236     } else {
    237 ##work
    238       domlist();
    239     }
    240   } else {
    241     # cancelled.  whee!
    242     $page->param(del_failed => 0);
    243     domlist();
    244241  }
    245242
     
    280277# hokay, a bit of magic to decide which page we hit.
    281278  if ($code eq 'OK') {
     279# redirect to dns.cgi?etc&page=reclist
     280    print $q->redirect("");
    282281    $page = HTML::Template->new(filename => "$templatedir/reclist.tmpl");
    283282    showdomain(0,$msg);
     
    315314
    316315exit 0;
     316
     317
     318sub changepage {
     319  my %params = @_;      # think this works the way I want...
     320
     321  # handle user check
     322  my $newurl = "http://$ENV{HTTP_HOST}$ENV{SCRIPT_NAME}?sid=$sid";
     323  foreach (keys %params) {
     324    $newurl .= "&$_=$params{$_}";
     325  }
     326
     327  print "Status: 302\nLocation: $newurl\n\n";
     328  exit;
     329} # end changepage
    317330
    318331
     
    441454
    442455
    443 sub domlist {
     456sub listdomains {
    444457  my $sth = $dbh->prepare("select count(*) from domains");
    445458  $sth->execute;
     
    477490  }
    478491  $page->param(domtable => \@domlist);
    479 } # end domlist()
     492} # end listdomains()
Note: See TracChangeset for help on using the changeset viewer.