Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r190 r191 487 487 # Log an action 488 488 # 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 490 491 sub _log { 491 492 my $dbh = shift; 492 493 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; 493 505 494 506 ##fixme: farm out the actual logging to different subs for file, syslog, internal, etc based on config … … 546 558 local $dbh->{RaiseError} = 1; 547 559 548 my $stage = 'insert';549 560 # Wrap all the SQL in a transaction 550 561 eval { 551 562 # insert the domain... 552 563 $dbh->do("INSERT INTO domains (domain,group_id,status) VALUES (?,?,?)", undef, ($domain, $group, $state)); 553 $stage = 'domid';554 564 555 565 # get the ID... 556 566 ($dom_id) = $dbh->selectrow_array("SELECT domain_id FROM domains WHERE domain=?", undef, ($domain)); 557 567 558 $stage = 'loginsert';559 568 _log($dbh, $dom_id, $userinfo{id}, $group, $userinfo{name}, $userinfo{fullname}, 560 569 "Added ".($state ? 'active' : 'inactive')." domain $domain"); 561 570 562 $stage = 'getdefrec';563 571 # ... and now we construct the standard records from the default set. NB: group should be variable. 564 572 my $sth = $dbh->prepare("SELECT host,type,val,distance,weight,port,ttl FROM default_records WHERE group_id=?"); … … 592 600 my $msg = $@; 593 601 eval { $dbh->rollback; }; 594 return ('FAIL', "$msg : $stage");602 return ('FAIL',$msg); 595 603 } else { 596 604 return ('OK',$dom_id); -
trunk/dns-rpc.cgi
r123 r191 18 18 #package main; 19 19 20 loadConfig(); 21 20 22 # need to create a DNSDB object too 21 my ($dbh,$msg) = DNSDB::connectDB("dnsdb","dnsdb","secret","dnsdbhost"); 23 my ($dbh,$msg) = DNSDB::connectDB($DNSDB::config{dbname}, $DNSDB::config{dbuser}, 24 $DNSDB::config{dbpass}, $DNSDB::config{dbhost}); 25 22 26 DNSDB::initGlobals($dbh); 23 27 -
trunk/dns.cgi
r190 r191 347 347 348 348 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}"); 350 350 changepage(page => "reclist", id => $msg); 351 351 } else { -
trunk/dns.sql
r130 r191 184 184 \. 185 185 186 -- ennnhhh... do we want to create superusers by default? may save going back to the DB to manually readd one 186 187 CREATE TABLE users ( 187 188 user_id serial NOT NULL,
Note:
See TracChangeset
for help on using the changeset viewer.