- Timestamp:
- 10/07/11 14:43:59 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r132 r135 1211 1211 my $direction = shift || 'ASC'; 1212 1212 1213 my $filter = shift || ''; 1214 # keep the nasties down, since we can't ?-sub this bit. :/ 1215 # note this is chars allowed in DNS hostnames 1216 $filter =~ s/[^a-zA-Z0-9_.:-]//g; 1217 1213 1218 $type = 'y' if $type eq 'def'; 1214 1219 … … 1223 1228 } 1224 1229 $sql .= " AND NOT r.type=$reverse_typemap{SOA}"; 1230 $sql .= " AND host ILIKE '%$filter%'" if $filter; 1225 1231 # use alphaorder column for "correct" ordering of sort-by-type instead of DNS RR type number 1226 1232 $sql .= " ORDER BY ".($order eq 'type' ? 't.alphaorder' : "r.$order")." $direction"; … … 1242 1248 ## DNSDB::getRecCount() 1243 1249 # Return count of non-SOA records in domain (or default records in a group) 1244 # Takes a database handle, default/live flag and group/domain ID1250 # Takes a database handle, default/live flag, group/domain ID, and optional filtering modifier 1245 1251 # Returns the count 1246 1252 sub getRecCount { … … 1248 1254 my $defrec = shift; 1249 1255 my $id = shift; 1256 my $filter = shift || ''; 1257 1258 # keep the nasties down, since we can't ?-sub this bit. :/ 1259 # note this is chars allowed in DNS hostnames 1260 $filter =~ s/[^a-zA-Z0-9_.:-]//g; 1250 1261 1251 1262 my ($count) = $dbh->selectrow_array("SELECT count(*) FROM ". 1252 1263 ($defrec eq 'y' ? 'default_' : '')."records ". 1253 1264 "WHERE ".($defrec eq 'y' ? 'group' : 'domain')."_id=? ". 1254 "AND NOT type=$reverse_typemap{SOA}", undef, ($id) ); 1265 "AND NOT type=$reverse_typemap{SOA}". 1266 ($filter ? " AND host ILIKE '%$filter%'" : ''), 1267 undef, ($id) ); 1255 1268 1256 1269 return $count;
Note:
See TracChangeset
for help on using the changeset viewer.