Changeset 911
- Timestamp:
- 08/12/25 15:47:28 (17 hours ago)
- Location:
- branches/secondaryzones
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/secondaryzones/DNSDB.pm
r908 r911 3170 3170 # - an array of "acceptable" groups 3171 3171 # - a flag for forward/reverse zones 3172 # - a flag for primary/secondary zones 3172 3173 # - Optionally accept a "starts with" and/or "contains" filter argument 3173 3174 # Returns an integer count of the resulting zone list. … … 3196 3197 3197 3198 my $sql; 3198 # Not as compact, and fix-me-twice if the common bits get wrong, but much easier to read 3199 if ($args{revrec} eq 'n') { 3200 $sql = "SELECT count(*) FROM domains". 3199 3200 if ($args{secondary} eq 'y') { 3201 # Secondary zones have less distinction between forward/reverse. 3202 # May need to revisit that once viewing records in the zones. 3203 $sql = "SELECT count(*) FROM secondaryzones". 3204 " WHERE group_id IN ($args{curgroup}".($args{childlist} ? ",$args{childlist}" : '').")". 3205 ($args{startwith} ? " AND zone ~* ?" : ''). 3206 ($args{filter} ? " AND zone ~* ?" : ''); 3207 } else { 3208 if ($args{revrec} eq 'n') { 3209 $sql = "SELECT count(*) FROM domains". 3201 3210 " WHERE group_id IN ($args{curgroup}".($args{childlist} ? ",$args{childlist}" : '').")". 3202 3211 ($args{startwith} ? " AND domain ~* ?" : ''). 3203 3212 ($args{filter} ? " AND domain ~* ?" : ''); 3204 } else {3205 $sql = "SELECT count(*) FROM revzones".3213 } else { 3214 $sql = "SELECT count(*) FROM revzones". 3206 3215 " WHERE group_id IN ($args{curgroup}".($args{childlist} ? ",$args{childlist}" : '').")". 3207 3216 ($args{startwith} ? " AND CAST(revnet AS VARCHAR) ~* ?" : ''); 3208 # if ($self->{showrev_arpa} eq 'zone' || $self->{showrev_arpa} eq 'all') {3209 3217 # Just In Case the UI is using formal .arpa notation, and someone enters something reversed, 3210 3218 # we want to match both the formal and natural zone name 3211 3219 $sql .= ($args{filter} ? " AND (CAST(revnet AS VARCHAR) ~* ? OR CAST(revnet AS VARCHAR) ~* ?)" : ''); 3212 3220 push @filterargs, join('[.]',reverse(split(/\[\.\]/,$args{filter}))) if $args{filter}; 3213 # } else { 3214 # $sql .= ($args{filter} ? " AND CAST(revnet AS VARCHAR) ~* ?" : ''); 3215 # } 3221 } 3216 3222 } 3217 3223 my ($count) = $dbh->selectrow_array($sql, undef, @filterargs); … … 3253 3259 3254 3260 my $sql; 3255 # Not as compact, and fix-me-twice if the common bits get wrong, but much easier to read 3256 if ($args{ revrec} eq 'n') {3257 $args{sortby} = ' domain' if !$args{sortby} || !grep /^$args{sortby}$/, ('domain','group','status');3261 3262 if ($args{secondary} eq 'y') { 3263 $args{sortby} = 'zone' if !$args{sortby} || !grep /^$args{sortby}$/, ('zone','primaryserver','group','status'); 3258 3264 $sql = q(SELECT 3265 secondary_id AS zoneid, 3266 zone, 3267 primaryserver, 3268 status, 3269 groups.group_name AS group, 3270 l.description AS location 3271 FROM secondaryzones 3272 LEFT JOIN locations l ON secondaryzones.default_location=l.location 3273 INNER JOIN groups ON secondaryzones.group_id=groups.group_id ). 3274 "WHERE secondaryzones.group_id IN ($args{curgroup}".($args{childlist} ? ",$args{childlist}" : '').")". 3275 ($args{startwith} ? " AND zone ~* ?" : ''). 3276 ($args{filter} ? " AND zone ~* ?" : ''); 3277 } else { 3278 if ($args{revrec} eq 'n') { 3279 $args{sortby} = 'domain' if !$args{sortby} || !grep /^$args{sortby}$/, ('domain','group','status'); 3280 $sql = q(SELECT 3259 3281 domain_id AS zoneid, 3260 3282 domain AS zone, … … 3268 3290 ($args{startwith} ? " AND domain ~* ?" : ''). 3269 3291 ($args{filter} ? " AND domain ~* ?" : ''); 3270 } else {3292 } else { 3271 3293 ##fixme: arguably startwith here is irrelevant. depends on the UI though. 3272 $args{sortby} = 'revnet' if !$args{sortby} || !grep /^$args{sortby}$/, ('revnet','group','status');3273 $sql = q(SELECT3294 $args{sortby} = 'revnet' if !$args{sortby} || !grep /^$args{sortby}$/, ('revnet','group','status'); 3295 $sql = q(SELECT 3274 3296 rdns_id AS zoneid, 3275 3297 revnet AS zone, … … 3282 3304 " WHERE revzones.group_id IN ($args{curgroup}".($args{childlist} ? ",$args{childlist}" : '').")". 3283 3305 ($args{startwith} ? " AND CAST(revnet AS VARCHAR) ~* ?" : ''); 3284 # if ($self->{showrev_arpa} eq 'zone' || $self->{showrev_arpa} eq 'all') {3285 3306 # Just In Case the UI is using formal .arpa notation, and someone enters something reversed, 3286 3307 # we want to match both the formal and natural zone name 3287 3308 $sql .= ($args{filter} ? " AND (CAST(revnet AS VARCHAR) ~* ? OR CAST(revnet AS VARCHAR) ~* ?)" : ''); 3288 3309 push @filterargs, join('[.]',reverse(split(/\[\.\]/,$args{filter}))) if $args{filter}; 3289 # } else { 3290 # $sql .= ($args{filter} ? " AND CAST(revnet AS VARCHAR) ~* ?" : ''); 3291 # } 3310 } 3292 3311 } 3293 3312 # A common tail. -
branches/secondaryzones/dns.cgi
r909 r911 606 606 changepage(page => "revzones"); 607 607 } 608 609 } elsif ($webvar{page} eq 'secondaryzones') { 610 611 # $page->param(domlist => 1); 612 613 # hmm. seeing problems in some possibly-not-so-corner cases. 614 # this currently only handles "domain on", "domain off" 615 if (defined($webvar{zonestatus})) { 616 # security check - does the user have permission to access this entity? 617 my $flag = 0; 618 foreach (@viewablegroups) { 619 $flag = 1 if $dnsdb->isParent($_, 'group', $webvar{id}, 'secondary'); 620 } 621 if ($flag && ($permissions{admin} || $permissions{domain_edit})) { 622 my $stat = $dnsdb->secondaryzoneStatus($webvar{id}, 'n', $webvar{zonestatus}); 623 $page->param(resultmsg => $DNSDB::resultstr); 624 } else { 625 $page->param(errmsg => "You are not permitted to view or change the requested domain"); 626 } 627 $uri_self =~ s/\&zonestatus=[^&]*//g; # clean up URL for stuffing into templates 628 } 629 630 show_msgs(); 631 632 $page->param(curpage => $webvar{page}); 633 634 listsecondaryzones(); 635 608 636 609 637 } elsif ($webvar{page} eq 'reclist') { … … 1967 1995 ##fixme 1968 1996 $page->param(mayrdns => 1); 1997 $page->param(maysecondary => 1); 1969 1998 1970 1999 $page->param(mayloc => ($permissions{admin} || $permissions{location_view})); … … 2359 2388 2360 2389 2390 sub listsecondaryzones { 2391 # ACLs 2392 $page->param(secondary_create => ($permissions{admin} || $permissions{domain_create}) ); 2393 $page->param(secondary_edit => ($permissions{admin} || $permissions{domain_edit}) ); 2394 $page->param(secondary_delete => ($permissions{admin} || $permissions{domain_delete}) ); 2395 2396 my @childgroups; 2397 $dnsdb->getChildren($curgroup, \@childgroups, 'all') if $searchsubs; 2398 my $childlist = join(',',@childgroups); 2399 2400 # my $count = $dnsdb->getSecondaryZoneCount(childlist => $childlist, curgroup => $curgroup, 2401 my $count = $dnsdb->getZoneCount(childlist => $childlist, curgroup => $curgroup, secondary => 'y', 2402 filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef) ); 2403 2404 # fill page count and first-previous-next-last-all bits 2405 fill_pgcount($count, 'secondary zone(s)', $dnsdb->groupName($curgroup)); 2406 fill_fpnla($count); 2407 2408 $sortby = 'zone'; 2409 # sort/order 2410 $session->param($webvar{page}.'sortby', $webvar{sortby}) if $webvar{sortby}; 2411 $session->param($webvar{page}.'order', $webvar{order}) if $webvar{order}; 2412 2413 $sortby = $session->param($webvar{page}.'sortby') if $session->param($webvar{page}.'sortby'); 2414 $sortorder = $session->param($webvar{page}.'order') if $session->param($webvar{page}.'order'); 2415 2416 # set up the headers 2417 my @cols = ('secondary', 'primaryserver', 'status', 'group'); 2418 my %colheads = (secondary => 'Secondary zone', primaryserver => 'Primary server(s)', status => 'Status', group => 'Group'); 2419 fill_colheads($sortby, $sortorder, \@cols, \%colheads); 2420 2421 # hack! hack! pthbttt. have to rethink the status column storage, 2422 # or inactive comes "before" active. *sigh* 2423 $sortorder = ($sortorder eq 'ASC' ? 'DESC' : 'ASC') if $sortby eq 'status'; 2424 2425 # waffle, waffle - keep state on these as well as sortby, sortorder? 2426 ##fixme: put this higher so the count doesn't get munched? 2427 $page->param("start$startwith" => 1) if $startwith && $startwith =~ /^(?:[a-z]|0-9)$/; 2428 2429 $page->param(filter => $filter) if $filter; 2430 $page->param(searchsubs => $searchsubs) if $searchsubs; 2431 2432 $page->param(group => $curgroup); 2433 2434 # my $zonelist = $dnsdb->getSecondaryZoneList(childlist => $childlist, curgroup => $curgroup, 2435 my $zonelist = $dnsdb->getZoneList(childlist => $childlist, curgroup => $curgroup, secondary => 'y', 2436 filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef), 2437 offset => $offset, sortby => $sortby, sortorder => $sortorder 2438 ); 2439 # probably don't need this, keeping for reference for now 2440 # foreach my $rec (@$zonelist) { 2441 # } 2442 $page->param(zonetable => $zonelist); 2443 } # end listsecondaryzones() 2444 2445 2361 2446 sub listgroups { 2362 2447 -
branches/secondaryzones/templates/menu.tmpl
r762 r911 6 6 <a href="<TMPL_VAR NAME=script_self>&page=domlist">Domains</a><br /> 7 7 <TMPL_IF mayrdns><a href="<TMPL_VAR NAME=script_self>&page=revzones">Reverse Zones</a><br /></TMPL_IF> 8 <TMPL_IF maysecondary><a href="<TMPL_VAR NAME=script_self>&page=secondaryzones">Secondary Zones</a><br /></TMPL_IF> 8 9 <a href="<TMPL_VAR NAME=script_self>&page=useradmin">Users</a><br /> 9 10 <a href="<TMPL_VAR NAME=script_self>&page=log">Log</a><br />
Note:
See TracChangeset
for help on using the changeset viewer.