Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r90 r91 28 28 &initPermissions &getPermissions &changePermissions &comparePermissions 29 29 &connectDB &finish 30 &addDomain &delDomain &domainName 30 &addDomain &delDomain &domainName &domainID 31 31 &addGroup &delGroup &getChildren &groupName 32 32 &addUser &updateUser &delUser &userFullName &userStatus &getUserData 33 &getSOA &getRecLine &getDomRecs 33 &getSOA &getRecLine &getDomRecs &getRecCount 34 34 &addRec &updateRec &delRec 35 35 &domStatus &importAXFR … … 43 43 &initPermissions &getPermissions &changePermissions &comparePermissions 44 44 &connectDB &finish 45 &addDomain &delDomain &domainName 45 &addDomain &delDomain &domainName &domainID 46 46 &addGroup &delGroup &getChildren &groupName 47 47 &addUser &updateUser &delUser &userFullName &userStatus &getUserData 48 &getSOA &getRecLine &getDomRecs 48 &getSOA &getRecLine &getDomRecs &getRecCount 49 49 &addRec &updateRec &delRec 50 50 &domStatus &importAXFR … … 367 367 return ('FAIL',"Need database handle") if !$dbh; 368 368 my $domain = shift; 369 return ('FAIL'," Need domain") if !defined($domain);369 return ('FAIL',"Domain must not be blank") if !$domain; 370 370 my $group = shift; 371 371 return ('FAIL',"Need group") if !defined($group); … … 470 470 my $dbh = shift; 471 471 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) ); 475 473 $errstr = $DBI::errstr if !$domname; 476 474 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 481 sub 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() 478 489 479 490 … … 1086 1097 return $ret; 1087 1098 } # 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 1105 sub 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() 1088 1118 1089 1119 … … 1487 1517 } else { 1488 1518 return ('WARN', $warnmsg) if $warnmsg; 1489 return ('OK'," ook");1519 return ('OK',"Imported OK"); 1490 1520 } 1491 1521 -
trunk/dns.cgi
r90 r91 249 249 $page->param(curpage => $webvar{page}); 250 250 251 my $sth = $dbh->prepare("SELECT count(*) FROM ". 252 ($webvar{defrec} eq 'y' ? 'default_' : '')."records ". 253 "WHERE ".($webvar{defrec} eq 'y' ? 'group' : 'domain')."_id=? ". 254 "AND NOT type=$reverse_typemap{SOA}"); 255 $sth->execute($webvar{id}); 256 my ($count) = ($sth->fetchrow_array); 251 my $count = getRecCount($dbh, $webvar{defrec}, $webvar{id}); 257 252 258 253 # $sortby = 'host'; … … 919 914 $page->param(importdoms => $webvar{importdoms}) if $webvar{importdoms}; 920 915 921 ##fixme: check group too? 916 # shut up warning about uninitialized variable 917 $webvar{doit} = '' if !defined($webvar{doit}); 918 922 919 if ($webvar{doit} eq 'y' && !$webvar{ifrom}) { 923 920 $page->param(errmsg => "Need to set host to import from"); 924 921 } elsif ($webvar{doit} eq 'y' && !$webvar{importdoms}) { 925 922 $page->param(errmsg => "Need domains to import"); 926 } els e{923 } elsif ($webvar{doit} eq 'y') { 927 924 my @domlist = split /\s+/, $webvar{importdoms}; 928 925 my @results; 929 my $rnum = 0;930 926 foreach my $domain (@domlist) { 931 927 my %row; 932 928 my ($code,$msg) = importAXFR($dbh, $webvar{ifrom}, $domain, $webvar{group}, 933 929 $webvar{domstatus}, $webvar{rwsoa}, $webvar{rwns}); 934 ##fixme: log935 930 $row{domok} = $msg if $code eq 'OK'; 936 931 if ($code eq 'WARN') { … … 939 934 } 940 935 if ($code eq 'FAIL') { 941 $msg =~ s|\n|<br /> |g;936 $msg =~ s|\n|<br />\n|g; 942 937 $row{domerr} = $msg; 943 938 } 944 # do stuff! DNSDB::importAXFR($webvar{ifrom}, $webvar{rwsoa}, $webvar{rwns}, $domain, <flags>) 939 $msg = "<br />\n".$msg if $msg =~ m|<br />|; 940 logaction(domainID($dbh, $domain), $session->param("username"), $webvar{group}, 941 "AXFR import $domain from $webvar{ifrom} ($code): $msg"); 945 942 $row{domain} = $domain; 946 # $row{row} = $rnum++;947 943 push @results, \%row; 948 944 } … … 1224 1220 sub fill_recdata { 1225 1221 fill_rectypes($webvar{type}); 1222 1223 # le sigh. we may get called with many empty %webvar keys 1224 no warnings qw( uninitialized ); 1226 1225 1227 1226 $page->param(name => $webvar{name}); -
trunk/dns.sql
r89 r91 54 54 \. 55 55 56 -- entry is text due to possible long entries from AXFR - a domain with "many" 57 -- odd records will overflow varchar(200) 56 58 CREATE TABLE log ( 57 59 log_id serial NOT NULL, … … 61 63 email character varying(60), 62 64 name character varying(60), 63 entry character varying(200),65 entry text, 64 66 stamp timestamp with time zone DEFAULT now() 65 67 );
Note:
See TracChangeset
for help on using the changeset viewer.