Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r51 r55 67 67 our %reverse_typemap; 68 68 69 69 70 ## 70 71 ## Initialization and cleanup subs 71 72 ## 73 72 74 73 75 ## DNSDB::connectDB() … … 154 156 } 155 157 } # end initGlobals 158 159 160 ## DNSDB::_log() 161 # Log an action 162 # Internal sub 163 # Takes a database handle, <foo>, <bar> 164 sub _log { 165 } # end _log 156 166 157 167 … … 489 499 my $sth = $dbh->prepare("INSERT INTO users (group_id,username,password,firstname,lastname,phone,type,status) ". 490 500 "VALUES (?,?,?,?,?,?,?,?)"); 491 $sth->execute($group,$username, $pass,$fname,$lname,$phone,$type,$state);501 $sth->execute($group,$username,unix_md5_crypt($pass),$fname,$lname,$phone,$type,$state); 492 502 493 503 # get the ID... … … 510 520 } 511 521 } # end addUser 522 523 524 ## DNSDB::checkUser() 525 # Check user/pass combo on login 526 sub checkUser { 527 my $dbh = shift; 528 my $user = shift; 529 my $pass = shift; 530 531 my $sth = $dbh->prepare("SELECT user_id,group_id,password,firstname,lastname FROM users WHERE username=?"); 532 $sth->execute($user); 533 my ($uid,$gid,$pass,$fname,$lname) = $sth->fetchrow_array; 534 my $loginfailed = 1 if !defined($uid); 535 536 if ($pass =~ m|^\$1\$([A-Za-z0-9/.]+)\$|) { 537 $loginfailed = 1 if $pass ne unix_md5_crypt($pass,$1); 538 } else { 539 $loginfailed = 1 if $pass ne $pass; 540 } 541 542 # nnnngggg 543 return ($uid, $gid); 544 } # end checkUser 512 545 513 546 -
trunk/dns.cgi
r54 r55 275 275 276 276 if ($code eq 'OK') { 277 ##fixme: need more magic to get proper group - if domain was fiddled 278 # from search-subgroups listing, may not be "current" group 279 logaction($webvar{parentid}, $session->param("username"), $webvar{group}, 280 "Added '$typemap{$webvar{type}} $webvar{name} $webvar{address}', TTL $webvar{ttl}"); 277 281 changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}); 278 282 } else { … … 315 319 316 320 if ($code eq 'OK') { 321 ##fixme: need more magic to get proper group - if domain was fiddled 322 # from search-subgroups listing, may not be "current" group 323 logaction($webvar{parentid}, $session->param("username"), $webvar{group}, 324 "Updated '$typemap{$webvar{type}} $webvar{name} $webvar{address}', TTL $webvar{ttl}"); 317 325 changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}); 318 326 } else { … … 358 366 359 367 if ($code eq 'OK') { 368 ##fixme: need more magic to get proper group - if domain was fiddled 369 # from search-subgroups listing, may not be "current" group 370 logaction($webvar{parentid}, $session->param("username"), $webvar{group}, 371 "Added '$typemap{$webvar{type}} $webvar{name} $webvar{address}', TTL $webvar{ttl}"); 360 372 showdomain($webvar{defrec},$webvar{parentid}); 361 373 # NB: should **really** redirect here, in case of reload. >_< eyowch. … … 429 441 fillsoa($webvar{defrec},$webvar{id}); 430 442 } else { 443 logaction(0, $session->param("username"), $webvar{group}, 444 "Updated SOA (ns $webvar{prins}, contact $webvar{contact}, refresh $webvar{refresh},". 445 " retry $webvar{retry}, expire $webvar{expire}, minTTL $webvar{minttl}, TTL $webvar{ttl}"); 431 446 changepage(page => "reclist", id => $webvar{id}, defrec => $webvar{defrec}); 432 447 $page->param(update_failed => 0); … … 436 451 437 452 } elsif ($webvar{page} eq 'adddomain') { 438 # Need some magic here. 439 440 ##fixme: Group should be variable 453 441 454 my ($code,$msg) = addDomain($dbh,$webvar{domain},$webvar{group},($webvar{makeactive} eq 'on' ? 1 : 0)); 442 455 443 # hokay, a bit of magic to decide which page we hit.444 456 if ($code eq 'OK') { 445 # redirect to dns.cgi?etc&page=reclist 457 logaction($msg, $session->param("username"), $webvar{group}, "Added domain $webvar{domain}"); 446 458 changepage(page => "reclist", id => $msg); 447 # $page = HTML::Template->new(filename => "$templatedir/reclist.tmpl");448 # showdomain(0,$msg);449 459 } else { 450 460 # oooh, yeah, this is supposed to be a redirect. er, maybe. whee. … … 467 477 # not gonna provide the 4th param: template-or-clone flag, just yet 468 478 my ($code,$msg) = addGroup($dbh, $webvar{newgroup}, $webvar{pargroup}); 469 changepage(page => "grpman") if $code eq 'OK'; 479 if $code eq 'OK' { 480 logaction(0, $session->param("username"), $webvar{pargroup}, "Added group $webvar{newgroup}"); 481 changepage(page => "grpman"); 482 } 470 483 $page->param(add_failed => 1); 471 484 $page->param(errmsg => $msg); … … 500 513 listgroups(); 501 514 } else { 515 ##fixem: need more magic to correctly determine the group this action happens in 516 logaction(0, $session->param("username"), $webvar{curgroup}, "Deleted group $webvar{id}"); 502 517 # success. go back to the domain list, do not pass "GO" 503 518 changepage(page => "grpman"); … … 539 554 # hokay, a bit of magic to decide which page we hit. 540 555 if ($code eq 'OK') { 556 logaction(0, $session->param("username"), $webvar{group}, 557 "Added user $webvar{uname} ($webvar{fname} $webvar{lname})"); 541 558 changepage(page => "useradmin"); 542 559 } else { … … 1260 1277 } 1261 1278 $page->param(usertable => \@userlist); 1262 } 1279 } # end list_users() 1280 1263 1281 1264 1282 # Generate all of the glop necessary to add or not the appropriate marker/flag for … … 1293 1311 1294 1312 } # end fill_colheads() 1313 1314 1315 sub logaction { 1316 my ($domid,$username,$groupid,$entry); 1317 1318 my $sth = dbh->prepare("SELECT user_id, firstname || ' ' || lastname FROM users WHERE username=?"); 1319 $sth->execute($username); 1320 my ($user_id, $fullname) = $sth->fetchrow_array; 1321 1322 $sth = $dbh->prepare("INSERT INTO log (domain_id,user_id,group_id,email,name,entry) ". 1323 "VALUES (?,?,?,?,?,?)"); 1324 $sth->execute($domid,$userid,$groupid,$username,$fullname,$entry); 1325 1326 } # end logaction()
Note:
See TracChangeset
for help on using the changeset viewer.