{
    use esmith::NetworksDB;
    use esmith::ConfigDB;

    my $ndb = esmith::NetworksDB->open_ro();

    $localAccess = $ndb->local_access_spec();
    $localAccess =~ s#/255\.255\.255\.255##g;

        my $dbh = esmith::ConfigDB->open() || die "Unable to open configuration dbase.";
        my %sa_conf = $dbh->get('dansguardian')->props;

        while (my ($parameter,$value) = each(%sa_conf)) {
          if (lc($parameter) eq 'localonly') {
           $local = $value;
          }
          if (lc($parameter) eq 'webstats') {
           $enabled = $value;
          }

        }

        $OUT = "";
        if (not (uc($enabled) eq 'YES')) {
         return;
        }
        $OUT .= "# This is the location of the Dansguardian Stats web interface\n";

        $OUT .= "AddHandler cgi-script .pl\n";
        $OUT .= "Alias /dansguardian /usr/local/dansguardian-stats\n";

        $OUT .= "<Directory /usr/local/dansguardian-stats>\n";
	$OUT .= "\tAddType application/x-httpd-php .php\n";
        $OUT .= "\tOptions FollowSymLinks\n";
        $OUT .= "\tOptions +ExecCGI\n";
        $OUT .= "\torder deny,allow\n";
        $OUT .= "\tdeny from all\n";

        if (uc($local) eq 'YES') {
          $OUT .= "\tallow from $localAccess\n";
        } else {
          $OUT .= "\tallow from all\n";
        }

        $OUT .= "</Directory>\n";
}

