- Timestamp:
- 11/05/09 15:40:13 (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dns.cgi
r25 r26 53 53 my $group = ($webvar{group} ? $webvar{group} : 1); 54 54 55 # handle login redirect 56 if ($webvar{action} && $webvar{action} eq 'login') { 57 ##fixme: need to actually do a user/pass check 58 changepage(page => "domlist"); 59 } 55 # nrgh, can't handle login here because we don't have a database handle to check the user/pass with yet 60 56 61 57 if ($webvar{action} && $webvar{action} eq 'chgroup') { … … 87 83 # fiddle hardcoded "defaults" as per system/user (?) prefs 88 84 initGlobals($dbh); 85 86 # handle login redirect 87 if ($webvar{action} && $webvar{action} eq 'login') { 88 my $sth = $dbh->prepare("SELECT user_id,group_id,password,firstname,lastname FROM users WHERE username=?"); 89 $sth->execute($webvar{username}); 90 my ($uid,$gid,$pass,$fname,$lname) = $sth->fetchrow_array; 91 $webvar{loginfailed} = 1 if !defined($uid); 92 $webvar{loginfailed} = 1 if $pass ne $webvar{password}; 93 94 # set session bits 95 $session->param('logingroup',$gid); 96 $session->param('curgroup',$gid); 97 98 changepage(page => "domlist") if !defined($webvar{loginfailed}); 99 } 89 100 90 101 ## Default page is a login page … … 104 115 $page->param(sid => $sid); 105 116 106 if ($webvar{page} eq 'domlist' or $webvar{page} eq 'index') { 117 if ($webvar{page} eq 'login') { 118 119 $page->param(loginfailed => 1) if $webvar{loginfailed}; 120 ##fixme: set up session init to actually *check* for session timeout 121 $page->param(timeout => 1) if $webvar{sesstimeout}; 122 123 } elsif ($webvar{page} eq 'domlist' or $webvar{page} eq 'index') { 107 124 108 125 # hmm. seeing problems in some possibly-not-so-corner cases. … … 774 791 775 792 sub listgroups { 776 my $sth = $dbh->prepare("select count(*) from groups"); 793 my @childgroups; 794 getChildren($dbh, $logingroup, \@childgroups, 'all'); 795 my $childlist = join(',',@childgroups); 796 797 my $sql = "SELECT count(*) FROM groups WHERE group_id IN ($logingroup".($childlist ? ",$childlist" : '').")"; 798 my $sth = $dbh->prepare($sql); 799 777 800 $sth->execute; 778 801 my ($count) = ($sth->fetchrow_array); 779 780 802 # fill page count and first-previous-next-last-all bits 781 803 ##fixme - hardcoded group bit … … 785 807 my @grouplist; 786 808 $sth = $dbh->prepare("SELECT g.group_id, g.group_name, g2.group_name, ". 787 "count(distinct(u. email)), count(distinct(d.domain)) ".809 "count(distinct(u.username)), count(distinct(d.domain)) ". 788 810 "FROM groups g ". 789 811 "INNER JOIN groups g2 ON g2.group_id=g.parent_group_id ". 790 812 "LEFT OUTER JOIN users u ON u.group_id=g.group_id ". 791 813 "LEFT OUTER JOIN domains d ON d.group_id=g.group_id ". 814 "WHERE g.group_id IN ($logingroup".($childlist ? ",$childlist" : '').") ". 792 815 "GROUP BY g.group_id, g.group_name, g2.group_name ". 793 816 "ORDER BY g.group_id".($offset eq 'all' ? '' : " LIMIT $perpage OFFSET ".$offset*$perpage)); … … 813 836 my $template_var = shift; 814 837 my $cur = shift || $curgroup; 838 839 my @childgroups; 840 getChildren($dbh, $logingroup, \@childgroups, 'all'); 841 my $childlist = join(',',@childgroups); 842 815 843 # weesa gonna discard parent_group_id for now 816 my $sth = $dbh->prepare("SELECT group_id,parent_group_id,group_name FROM groups ORDER BY group_id"); 844 my $sth = $dbh->prepare("SELECT group_id,parent_group_id,group_name FROM groups ". 845 "WHERE group_id IN ($logingroup".($childlist ? ",$childlist" : '').")". 846 "ORDER BY group_id"); 817 847 $sth->execute; 818 848 my @grouplist; … … 830 860 831 861 } # end fill_grouplist() 862 832 863 833 864 sub list_users { -
trunk/templates/login.tmpl
r2 r26 1 1 <center> 2 2 <table id="login"> 3 <TMPL_IF NAME=loginfailed><tr><td colspan=2 class="errmsg" align="center">Error logging in: Invalid username or password</td></tr></TMPL_IF> 3 4 <tr><td colspan=2 class="title" align="center">Please log in:</td></tr> 4 5 <form method="POST" action="dns.cgi"> 5 6 <input type="hidden" name="action" value="login"> 6 7 <input type="hidden" name="sid" value="<TMPL_VAR NAME=sid>"> 7 <input type="hidden" name="page" value=" domlist">8 <tr><td class="inputlabel"> Email Address:</td><td><input type="text" name="email"></td></tr>8 <input type="hidden" name="page" value="login"> 9 <tr><td class="inputlabel">Username:</td><td><input type="text" name="username"></td></tr> 9 10 <tr><td class="inputlabel">Password:</td><td><input type="password" name="password"></td></tr> 10 11 <tr><td colspan=2 class="tblsubmit" align="right"><input type="submit" value="Login"></td></tr>
Note:
See TracChangeset
for help on using the changeset viewer.