- Timestamp:
- 11/06/09 18:02:00 (15 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dns.cgi
r29 r30 17 17 use CGI::Session; 18 18 use Crypt::PasswdMD5; 19 use Net::DNS; 19 20 use DBI; 20 21 … … 86 87 87 88 # handle login redirect 88 if ($webvar{action} && $webvar{action} eq 'login') { 89 my $sth = $dbh->prepare("SELECT user_id,group_id,password,firstname,lastname FROM users WHERE username=?"); 90 $sth->execute($webvar{username}); 91 my ($uid,$gid,$pass,$fname,$lname) = $sth->fetchrow_array; 92 $webvar{loginfailed} = 1 if !defined($uid); 93 94 if ($pass =~ m|^\$1\$([A-Za-z0-9/.]+)\$|) { 95 $webvar{loginfailed} = 1 if $pass ne unix_md5_crypt($webvar{password},$1); 96 } else { 97 $webvar{loginfailed} = 1 if $pass ne $webvar{password}; 98 } 99 100 # set session bits 101 $session->param('logingroup',$gid); 102 $session->param('curgroup',$gid); 103 104 changepage(page => "domlist") if !defined($webvar{loginfailed}); 89 if ($webvar{action}) { 90 if ($webvar{action} eq 'login') { 91 my $sth = $dbh->prepare("SELECT user_id,group_id,password,firstname,lastname FROM users WHERE username=?"); 92 $sth->execute($webvar{username}); 93 my ($uid,$gid,$pass,$fname,$lname) = $sth->fetchrow_array; 94 $webvar{loginfailed} = 1 if !defined($uid); 95 96 if ($pass =~ m|^\$1\$([A-Za-z0-9/.]+)\$|) { 97 $webvar{loginfailed} = 1 if $pass ne unix_md5_crypt($webvar{password},$1); 98 } else { 99 $webvar{loginfailed} = 1 if $pass ne $webvar{password}; 100 } 101 102 # set session bits 103 $session->param('logingroup',$gid); 104 $session->param('curgroup',$gid); 105 $session->param('username',$webvar{username}); 106 107 changepage(page => "domlist") if !defined($webvar{loginfailed}); 108 } elsif ($webvar{action} eq 'logout') { 109 # delete the session 110 $session->delete(); 111 $session->flush(); 112 113 my $newurl = "http://$ENV{HTTP_HOST}$ENV{SCRIPT_NAME}"; 114 $newurl =~ s|/[^/]+$|/|; 115 print "Status: 302\nLocation: $newurl\n\n"; 116 exit; 117 118 } 105 119 } 106 120 … … 513 527 } 514 528 529 } elsif ($webvar{page} eq 'dnsq') { 530 531 $page->param(qfor => $webvar{qfor}) if $webvar{qfor}; 532 fill_rectypes($webvar{type} ? $webvar{type} : ''); 533 $page->param(trace => $webvar{trace}) if $webvar{trace}; 534 $page->param(resolver => $webvar{resolver}) if $webvar{resolver}; 535 536 if ($webvar{qfor}) { 537 my $resolv = Net::DNS::Resolver->new; 538 my $query = $resolv->query($webvar{qfor}, $typemap{$webvar{type}}); 539 if ($query) { 540 541 $page->param(showresults => 1); 542 543 my @answer; 544 foreach my $rr ($query->answer) { 545 # next unless $rr->type eq "A" or $rr->type eq 'NS'; 546 my %row; 547 my ($host,$ttl,$class,$type,$data) = 548 ($rr->string =~ /^([0-9a-zA-Z_.-]+)\s+(\d+)\s+([A-Za-z]+)\s+([A-Za-z]+)\s+(.+)$/); 549 $row{host} = $host; 550 $row{ftype} = $type; 551 $row{rdata} = $data; 552 push @answer, \%row; 553 } 554 $page->param(answer => \@answer); 555 556 my @additional; 557 foreach my $rr ($query->additional) { 558 # next unless $rr->type eq "A" or $rr->type eq 'NS'; 559 my %row; 560 my ($host,$ttl,$class,$type,$data) = 561 ($rr->string =~ /^([0-9a-zA-Z_.-]+)\s+(\d+)\s+([A-Za-z]+)\s+([A-Za-z]+)\s+(.+)$/); 562 $row{host} = $host; 563 $row{ftype} = $type; 564 $row{rdata} = $data; 565 push @additional, \%row; 566 } 567 $page->param(additional => \@additional); 568 569 my @authority; 570 foreach my $rr ($query->authority) { 571 # next unless $rr->type eq "A" or $rr->type eq 'NS'; 572 my %row; 573 my ($host,$ttl,$class,$type,$data) = 574 ($rr->string =~ /^([0-9a-zA-Z_.-]+)\s+(\d+)\s+([A-Za-z]+)\s+([A-Za-z]+)\s+(.+)$/); 575 $row{host} = $host; 576 $row{ftype} = $type; 577 $row{rdata} = $data; 578 push @authority, \%row; 579 } 580 $page->param(authority => \@authority); 581 582 $page->param(usedresolver => $resolv->answerfrom); 583 $page->param(frtype => $typemap{$webvar{type}}); 584 585 } else { 586 $page->param(errmsg => $resolv->errorstring); 587 } 588 } 589 ## done DNS query 590 515 591 } 516 592 … … 521 597 ##common bits 522 598 if ($webvar{page} ne 'login') { 599 $page->param(username => $session->param("username")); 600 523 601 $page->param(group => $curgroup); 524 602 $page->param(groupname => groupName($dbh,$curgroup)); … … 591 669 $newurl .= "&$_=$params{$_}"; 592 670 } 671 672 # Just In Case 673 $session->flush(); 593 674 594 675 print "Status: 302\nLocation: $newurl\n\n"; -
trunk/images
-
Property svn:ignore
set to
*.png
*.gif
*.jpg
*.bak
-
Property svn:ignore
set to
-
trunk/templates/domlist.tmpl
r22 r30 52 52 53 53 </td> 54 </tr> 54 55 </table> -
trunk/templates/menu.tmpl
r24 r30 1 1 <td class="menu"> 2 <TMPL_VAR NAME=username> logged in<br /> 3 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&action=logout">Log out</a> 4 <hr> 2 5 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=domlist">Domains</a><br /> 3 6 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=useradmin">Users</a><br />
Note:
See TracChangeset
for help on using the changeset viewer.