Ignore:
Timestamp:
06/13/17 13:58:57 (8 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Merge /trunk through r749 for 1.4.0

Location:
branches/stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/stable

  • branches/stable/dns.cgi

    r725 r756  
    33##
    44# $Id$
    5 # Copyright 2008-2013 Kris Deugau <kdeugau@deepnet.cx>
     5# Copyright 2008-2016 Kris Deugau <kdeugau@deepnet.cx>
    66#
    77#    This program is free software: you can redistribute it and/or modify
     
    120120$webvar{startwith} =~ s/^(0-9|[a-z]).*/$1/ if $webvar{startwith};
    121121# not much call for chars not allowed in domain names
    122 $webvar{filter} =~ s/[^a-zA-Z0-9_.:\@-]//g if $webvar{filter};
     122$webvar{filter} =~ s/[^a-zA-Z0-9_.:\@%-]//g if $webvar{filter};
    123123## only set 'y' if box is checked, no other values legal
    124124## however, see https://secure.deepnet.cx/trac/dnsadmin/ticket/31
     
    138138# @#$%@%@#% XHTML - & in a URL must be escaped.  >:(
    139139my $uri_self = $ENV{REQUEST_URI};
     140$uri_self = "/dns.cgi" if !$uri_self || $uri_self eq '/';
    140141$uri_self =~ s/\&([a-z])/\&amp\;$1/g;
    141142
     
    455456
    456457  if ($code eq 'OK') {
     458    $webvar{domain} = lc($webvar{domain}) if $dnsdb->{lowercase};
    457459    $dnsdb->mailNotify("New ".($webvar{makeactive} eq 'on' ? 'Active' : 'Inactive')." Domain Created",
    458460        ($webvar{makeactive} eq 'on' ? 'Active' : 'Inactive').qq( domain "$webvar{domain}" added by ).
     
    17951797##fixme:  where should we call this from?
    17961798    $id = $webvar{id};
    1797     if (!check_scope(id => $id, type => 'user')) {
    1798       $page->param(errmsg => "You are not permitted to view log entries for the requested user");
    1799       goto DONELOG;
    1800     }
    1801     $page->param(logfor => 'user '.$dnsdb->userFullName($id));
     1799##fixme:  don't include username on out-of-scope users
     1800    $page->param(logfor => 'user '.($id ? $dnsdb->userFullName($id) : $webvar{fname}));
    18021801  } elsif ($webvar{ltype} && $webvar{ltype} eq 'dom') {
    18031802    $id = $webvar{id};
     
    18211820  }
    18221821  $webvar{ltype} = 'group' if !$webvar{ltype};
    1823   my $lcount = $dnsdb->getLogCount(id => $id, logtype => $webvar{ltype}) or push @debugbits, $dnsdb->errstr;
     1822
     1823  # Done here since we want to allow more arbitrary blobs in the log filter
     1824  if (defined($webvar{logfilter})) {
     1825    $session->param('logfilter', '') if !$session->param('logfilter');
     1826    if ($webvar{logfilter} ne $session->param('logfilter')) {
     1827      $uri_self =~ s/\&amp;offset=[^&]//;
     1828      $offset = 0;
     1829    }
     1830    $session->param('logfilter', $webvar{logfilter})
     1831  }
     1832  my $logfilter = $session->param('logfilter');
     1833  $filter = $logfilter;
     1834  $page->param(logfilter => $logfilter);
     1835
     1836  my $lcount = $dnsdb->getLogCount(id => $id, group => $logingroup, fname => $webvar{fname},
     1837    logtype => $webvar{ltype}, filter => $logfilter);
     1838  if (!$lcount) {
     1839    $page->param(errmsg => $dnsdb->errstr);
     1840    $lcount = 0;
     1841  }
    18241842
    18251843  $page->param(id => $id);
     
    18401858
    18411859  # Set up the column headings with the sort info
    1842   my @cols = ('fname','username','entry','stamp');
    1843   my %colnames = (fname => 'Name', username => 'Username', entry => 'Log Entry', stamp => 'Date/Time');
     1860  my @cols = ('fname','domain','revzone','entry','stamp');
     1861  my %colnames = (fname => 'Name', domain => 'Forward zone', revzone => 'Reverse zone',
     1862      entry => 'Log Entry', stamp => 'Date/Time');
    18441863  fill_colheads($sortby, $sortorder, \@cols, \%colnames);
    18451864
    18461865##fixme:  increase per-page limit or use separate limit for log?  some ops give *lots* of entries...
    1847   my $logentries = $dnsdb->getLogEntries(id => $id, logtype => $webvar{ltype},
    1848         offset => $webvar{offset}, sortby => $sortby, sortorder => $sortorder);
    1849   $page->param(logentries => $logentries);
     1866  my $logentries = $dnsdb->getLogEntries(id => $id, group => $logingroup, fname => $webvar{fname},
     1867        logtype => $webvar{ltype},
     1868        offset => $webvar{offset}, sortby => $sortby, sortorder => $sortorder, filter => $logfilter);
     1869  if (!$logentries) {
     1870    $page->param(errmsg => $dnsdb->errstr);
     1871  } else {
     1872    # undef $logentries is inexplicably puking instead of showing "no entries found",
     1873    # like all the rest of the methods that return a list the same way.  idunno...
     1874    $page->param(logentries => $logentries);
     1875  }
    18501876
    18511877##fixme:
    1852 # - filtering
    1853 # - show reverse zone column?
    18541878# - on log record creation, bundle "parented" log actions (eg, "AXFR record blah for domain foo",
    18551879#   or "Add record bar for new domain baz") into one entry (eg, "AXFR domain foo", "Add domain baz")?
     
    18581882  # scope check fail target
    18591883  DONELOG: ;
     1884
     1885} elsif ($webvar{page} eq 'recsearch') {
     1886
     1887  # we do this for the domain and record list filter/search - it should be extremely rare to
     1888  # need to search on characters outside this set until we get into IDNs
     1889  # note this is a little larger due to template records
     1890  $webvar{searchfor} =~ s/[^a-zA-Z0-9_.:\@%-]//g if $webvar{searchfor};
     1891
     1892  # save the search in the session, same as the "filter" in various other lists...
     1893  if (defined($webvar{searchfor})) {
     1894    if ($session->param('recsearch') && $webvar{searchfor} ne $session->param('recsearch')) {
     1895      $uri_self =~ s/\&amp;offset=[^&]//;
     1896      $offset = 0;
     1897    }
     1898    $session->param(recsearch => $webvar{searchfor});
     1899  }
     1900  my $searchfor = $session->param('recsearch');
     1901
     1902  $sortby = 'host';
     1903  $session->param($webvar{page}.'sortby', $webvar{sortby}) if $webvar{sortby};
     1904  $session->param($webvar{page}.'order', $webvar{order}) if $webvar{order};
     1905  $sortby = $session->param($webvar{page}.'sortby') if $session->param($webvar{page}.'sortby');
     1906  $sortorder = $session->param($webvar{page}.'order') if $session->param($webvar{page}.'order');
     1907
     1908  # some magic to label and linkify the column headers for sorting
     1909  my @cols = ('domain','revzone','host','type','val');
     1910  my %colheads = (domain => "Domain (Group)", revzone => "Reverse zone (Group)", host => "Host",
     1911        type => "Type", val => "IP/value");
     1912  # only users allowed to see location/view data get this column
     1913  if ($permissions{admin} || $permissions{location_view}) {
     1914    $colheads{location} = "Location";
     1915    push @cols, 'location';
     1916  }
     1917  fill_colheads($sortby, $sortorder, \@cols, \%colheads);
     1918
     1919  # pgcount.tmpl
     1920  my $count = $dnsdb->recSearchCount(searchfor => $searchfor, group => $logingroup);
     1921  fill_pgcount($count, "records");
     1922  fill_fpnla($count);
     1923
     1924  # and a bit for fpnla.tmpl
     1925  $page->param(curpage => $webvar{page});
     1926
     1927  $page->param(searchfor => $searchfor);
     1928  my $recset = $dnsdb->recSearch(searchfor => $searchfor, group => $logingroup, offset => $webvar{offset},
     1929    sortby => $sortby, sortorder => $sortorder);
     1930  $page->param(searchresults => $recset);
    18601931
    18611932} # end $webvar{page} dance
Note: See TracChangeset for help on using the changeset viewer.