Changeset 91 for trunk/DNSDB.pm


Ignore:
Timestamp:
04/13/11 16:00:10 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

SQL tabledef update:

  • Tweak log table definition to cope with looooong entries (mainly from AXFR warnings)

DNSDB.pm:

  • Add domainID and getRecCount subs in DNSDB
  • Return more user-friendly error on attempting to add a domain with no name
  • Nitpick-tweak DB calls and SQL formatting in domainName()
  • Replace placeholderish OK message in importAXFR()

dns.cgi:

  • Trim some more direct SQL out in reclist
  • Uninitialized-variable cleanup in AXFR import
  • Add logging to AXFR import
  • Don't complain about uninitialized variables in record-display
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r90 r91  
    2828        &initPermissions &getPermissions &changePermissions &comparePermissions
    2929        &connectDB &finish
    30         &addDomain &delDomain &domainName
     30        &addDomain &delDomain &domainName &domainID
    3131        &addGroup &delGroup &getChildren &groupName
    3232        &addUser &updateUser &delUser &userFullName &userStatus &getUserData
    33         &getSOA &getRecLine &getDomRecs
     33        &getSOA &getRecLine &getDomRecs &getRecCount
    3434        &addRec &updateRec &delRec
    3535        &domStatus &importAXFR
     
    4343                &initPermissions &getPermissions &changePermissions &comparePermissions
    4444                &connectDB &finish
    45                 &addDomain &delDomain &domainName
     45                &addDomain &delDomain &domainName &domainID
    4646                &addGroup &delGroup &getChildren &groupName
    4747                &addUser &updateUser &delUser &userFullName &userStatus &getUserData
    48                 &getSOA &getRecLine &getDomRecs
     48                &getSOA &getRecLine &getDomRecs &getRecCount
    4949                &addRec &updateRec &delRec
    5050                &domStatus &importAXFR
     
    367367  return ('FAIL',"Need database handle") if !$dbh;
    368368  my $domain = shift;
    369   return ('FAIL',"Need domain") if !defined($domain);
     369  return ('FAIL',"Domain must not be blank") if !$domain;
    370370  my $group = shift;
    371371  return ('FAIL',"Need group") if !defined($group);
     
    470470  my $dbh = shift;
    471471  my $domid = shift;
    472   my $sth = $dbh->prepare("select domain from domains where domain_id=?");
    473   $sth->execute($domid);
    474   my ($domname) = $sth->fetchrow_array();
     472  my ($domname) = $dbh->selectrow_array("SELECT domain FROM domains WHERE domain_id=?", undef, ($domid) );
    475473  $errstr = $DBI::errstr if !$domname;
    476474  return $domname if $domname;
    477 } # end domainName
     475} # end domainName()
     476
     477
     478## DNSDB::domainID()
     479# Takes a database handle and domain name
     480# Returns the domain ID number
     481sub domainID {
     482  $errstr = '';
     483  my $dbh = shift;
     484  my $domain = shift;
     485  my ($domid) = $dbh->selectrow_array("SELECT domain_id FROM domains WHERE domain=?", undef, ($domain) );
     486  $errstr = $DBI::errstr if !$domid;
     487  return $domid if $domid;
     488} # end domainID()
    478489
    479490
     
    10861097  return $ret;
    10871098} # end getDomRecs()
     1099
     1100
     1101## DNSDB::getRecCount()
     1102# Return count of non-SOA records in domain (or default records in a group)
     1103# Takes a database handle, default/live flag and group/domain ID
     1104# Returns the count
     1105sub getRecCount {
     1106  my $dbh = shift;
     1107  my $defrec = shift;
     1108  my $id = shift;
     1109
     1110  my ($count) = $dbh->selectrow_array("SELECT count(*) FROM ".
     1111        ($defrec eq 'y' ? 'default_' : '')."records ".
     1112        "WHERE ".($defrec eq 'y' ? 'group' : 'domain')."_id=? ".
     1113        "AND NOT type=$reverse_typemap{SOA}", undef, ($id) );
     1114
     1115  return $count;
     1116
     1117} # end getRecCount()
    10881118
    10891119
     
    14871517  } else {
    14881518    return ('WARN', $warnmsg) if $warnmsg;
    1489     return ('OK',"ook");
     1519    return ('OK',"Imported OK");
    14901520  }
    14911521
Note: See TracChangeset for help on using the changeset viewer.