Changeset 191 for trunk


Ignore:
Timestamp:
12/09/11 16:10:56 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

Minor fix in dns-rpc.cgi to load DB user/pass/etc with loadConfig

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r190 r191  
    487487# Log an action
    488488# Internal sub
    489 # Takes a database handle, domain_id, user_id, group_id, email, name and log entry
     489# Takes a database handle, domain_id, group_id, log entry, and user info hash
     490# User info must contain a user ID OR username+fullname
    490491sub _log {
    491492  my $dbh = shift;
    492493  my ($domain_id,$user_id,$group_id,$username,$name,$entry) = @_;
     494
     495##fixme:  need better way(s?) to snag userinfo for log entries
     496  if (!$user_id) {
     497    $user_id, $fullname) = $dbh->fetchrow_array("SELECT user_id, firstname || ' ' || lastname FROM users".
     498        " WHERE username=?", undef, ($username));
     499  } elsif (!$username) {
     500    $username, $fullname) = $dbh->fetchrow_array("SELECT username, firstname || ' ' || lastname FROM users".
     501        " WHERE user_id=?", undef, ($user_id));
     502  }
     503
     504  $name = $fullname if !$name;
    493505
    494506##fixme:  farm out the actual logging to different subs for file, syslog, internal, etc based on config
     
    546558  local $dbh->{RaiseError} = 1;
    547559
    548 my $stage = 'insert';
    549560  # Wrap all the SQL in a transaction
    550561  eval {
    551562    # insert the domain...
    552563    $dbh->do("INSERT INTO domains (domain,group_id,status) VALUES (?,?,?)", undef, ($domain, $group, $state));
    553 $stage = 'domid';
    554564
    555565    # get the ID...
    556566    ($dom_id) = $dbh->selectrow_array("SELECT domain_id FROM domains WHERE domain=?", undef, ($domain));
    557567
    558 $stage = 'loginsert';
    559568    _log($dbh, $dom_id, $userinfo{id}, $group, $userinfo{name}, $userinfo{fullname},
    560569        "Added ".($state ? 'active' : 'inactive')." domain $domain");
    561570
    562 $stage = 'getdefrec';
    563571    # ... and now we construct the standard records from the default set.  NB:  group should be variable.
    564572    my $sth = $dbh->prepare("SELECT host,type,val,distance,weight,port,ttl FROM default_records WHERE group_id=?");
     
    592600    my $msg = $@;
    593601    eval { $dbh->rollback; };
    594     return ('FAIL',"$msg : $stage");
     602    return ('FAIL',$msg);
    595603  } else {
    596604    return ('OK',$dom_id);
  • trunk/dns-rpc.cgi

    r123 r191  
    1818#package main;
    1919
     20loadConfig();
     21
    2022# need to create a DNSDB object too
    21 my ($dbh,$msg) = DNSDB::connectDB("dnsdb","dnsdb","secret","dnsdbhost");
     23my ($dbh,$msg) = DNSDB::connectDB($DNSDB::config{dbname}, $DNSDB::config{dbuser},
     24        $DNSDB::config{dbpass}, $DNSDB::config{dbhost});
     25
    2226DNSDB::initGlobals($dbh);
    2327
  • trunk/dns.cgi

    r190 r191  
    347347
    348348  if ($code eq 'OK') {
    349     logaction($msg, $session->param("username"), $webvar{group}, "Added domain $webvar{domain}");
     349#    logaction($msg, $session->param("username"), $webvar{group}, "Added domain $webvar{domain}");
    350350    changepage(page => "reclist", id => $msg);
    351351  } else {
  • trunk/dns.sql

    r130 r191  
    184184\.
    185185
     186-- ennnhhh...  do we want to create superusers by default?  may save going back to the DB to manually readd one
    186187CREATE TABLE users (
    187188    user_id serial NOT NULL,
Note: See TracChangeset for help on using the changeset viewer.