Changeset 275 for trunk/DNSDB.pm
- Timestamp:
- 03/15/12 15:34:38 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r274 r275 48 48 &parentID 49 49 &isParent 50 & domStatus &importAXFR50 &zoneStatus &importAXFR 51 51 &export 52 52 &mailNotify … … 70 70 &parentID 71 71 &isParent 72 & domStatus &importAXFR72 &zoneStatus &importAXFR 73 73 &export 74 74 &mailNotify … … 2722 2722 2723 2723 2724 ## DNSDB:: domStatus()2725 # Sets and/or returns a domain's status2726 # Takes a database handle, domain IDand optionally a status argument2727 # Returns undef on errors.2728 sub domStatus {2724 ## DNSDB::zoneStatus() 2725 # Returns and optionally sets a zone's status 2726 # Takes a database handle, domain/revzone ID, forward/reverse flag, and optionally a status argument 2727 # Returns status, or undef on errors. 2728 sub zoneStatus { 2729 2729 my $dbh = shift; 2730 2730 my $id = shift; 2731 my $newstatus = shift; 2731 my $revrec = shift; 2732 my $newstatus = shift || 'mu'; 2732 2733 2733 2734 return undef if $id !~ /^\d+$/; 2734 2735 2735 my $sth;2736 2737 2736 # ooo, fun! let's see what we were passed for status 2738 if ($newstatus) { 2739 $sth = $dbh->prepare("update domains set status=? where domain_id=?"); 2740 # ass-u-me caller knows what's going on in full 2741 if ($newstatus =~ /^[01]$/) { # only two valid for now. 2742 $sth->execute($newstatus,$id); 2743 } elsif ($newstatus =~ /^domo(?:n|ff)$/) { 2744 $sth->execute(($newstatus eq 'domon' ? 1 : 0),$id); 2745 } 2746 } 2747 2748 $sth = $dbh->prepare("select status from domains where domain_id=?"); 2749 $sth->execute($id); 2750 my ($status) = $sth->fetchrow_array; 2737 if ($newstatus ne 'mu') { 2738 $newstatus = 0 if $newstatus eq 'domoff'; 2739 $newstatus = 1 if $newstatus eq 'domon'; 2740 $dbh->do("UPDATE ".($revrec eq 'n' ? 'domains' : 'revzones')." SET status=? WHERE ". 2741 ($revrec eq 'n' ? 'domain_id' : 'rdns_id')."=?", undef, ($newstatus,$id) ); 2742 } 2743 2744 my ($status) = $dbh->selectrow_array("SELECT status FROM ". 2745 ($revrec eq 'n' ? "domains WHERE domain_id=?" : "revzones WHERE rdns_id=?"), 2746 undef, ($id) ); 2751 2747 return $status; 2752 } # end domStatus()2748 } # end zoneStatus() 2753 2749 2754 2750
Note:
See TracChangeset
for help on using the changeset viewer.