Changeset 195 for trunk/DNSDB.pm


Ignore:
Timestamp:
12/12/11 17:52:55 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

More log behaviour tweaking

  • fix broken detail-logging of MX/SRV records on record add
  • add flag to control failure logging
  • fix broken user fullname grabber in _log

Tweak config loading with a few new options

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r193 r195  
    9898
    9999# Prepopulate a basic config.  Note some of these *will* cause errors if left unset.
     100# note:  add appropriate stanzas in loadConfig to parse these
    100101our %config = (
    101102                # Database connection info
     
    107108                # Email notice settings
    108109                mailhost        => 'smtp.example.com',
    109                 mailsender      => 'dnsdb@example.com',
     110                mailnotify      => 'dnsdb@example.com', # to
     111                mailsender      => 'dnsdb@example.com', # from
    110112                mailname        => 'DNS Administration',
     113                orgname         => 'Example Corp',
     114                domain          => 'example.com',
    111115
    112116                # Template directory
     
    116120
    117121                # Session params
    118                 timeout         => '3600'       # 1 hour default
     122                timeout         => '3600',      # 1 hour default
     123
     124                # Other miscellanea
     125                log_failures    => 1,   # log all evarthing by default
    119126        );
    120127
     
    150157        "Error opening site config file $siteconfig";
    151158      return;
     159    }
     160  }
     161
     162  # Munge log_failures.
     163  if ($config{log_failures} ne '1' && $config{log_failures} ne '0') {
     164    # true/false, on/off, yes/no all valid.
     165    if ($config{log_failures} =~ /^(?:true|false|on|off|yes|no)$/) {
     166      if ($config{log_failures} =~ /(?:true|on|yes)/) {
     167        $config{log_failures} = 1;
     168      } else {
     169        $config{log_failures} = 0;
     170      }
     171    } else {
     172      $errstr = "Bad log_failures setting $config{log_failures}";
     173      $config{log_failures} = 1;
     174      # Bad setting shouldn't be fatal.
     175      # return 2;
    152176    }
    153177  }
     
    190214      # Mail settings
    191215      $config{mailhost}         = $1 if /^mailhost\s*=\s*([a-z0-9_.-]+)/i;
     216      $config{mailnotify}       = $1 if /^mailnotify\s*=\s*([a-z0-9_.@-]+)/i;
    192217      $config{mailsender}       = $1 if /^mailsender\s*=\s*([a-z0-9_.@-]+)/i;
    193218      $config{mailname}         = $1 if /^mailname\s*=\s*([a-z0-9\s_.-]+)/i;
     219      $config{orgname}          = $1 if /^orgname\s*=\s*([a-z0-9\s_.,'-]+)/i;
     220      $config{domain}           = $1 if /^domain\s*=\s*([a-z0-9_.-]+)/i;
    194221      # session - note this is fed directly to CGI::Session
    195222      $config{timeout}  = $1 if /^[tT][iI][mM][eE][oO][uU][tT]\s*=\s*(\d+[smhdwMy]?)/;
     223      # log failed actions
     224      $config{log_failures}     = $1 if /^log_failures\s*=\s*([a-z01]+)/i;
    196225    }
    197226    close CFG;
     
    496525##fixme:  need better way(s?) to snag userinfo for log entries.  don't want to have
    497526# to pass around yet *another* constant (already passing $dbh, shouldn't need to)
     527  my $fullname;
    498528  if (!$user_id) {
    499     $user_id, $fullname) = $dbh->fetchrow_array("SELECT user_id, firstname || ' ' || lastname FROM users".
     529    ($user_id, $fullname) = $dbh->selectrow_array("SELECT user_id, firstname || ' ' || lastname FROM users".
    500530        " WHERE username=?", undef, ($username));
    501531  } elsif (!$username) {
    502     $username, $fullname) = $dbh->fetchrow_array("SELECT username, firstname || ' ' || lastname FROM users".
     532    ($username, $fullname) = $dbh->selectrow_array("SELECT username, firstname || ' ' || lastname FROM users".
     533        " WHERE user_id=?", undef, ($user_id));
     534  } else {
     535    ($fullname) = $dbh->selectrow_array("SELECT firstname || ' ' || lastname FROM users".
    503536        " WHERE user_id=?", undef, ($user_id));
    504537  }
Note: See TracChangeset for help on using the changeset viewer.