[Netpass-devel] NetPass/www/htdocs/Admin audit.mhtml,1.7,1.8 autohandler,1.17,1.18 chpwd.mhtml,1.3,1
Brought to you by:
jeffmurphy
From: jeff m. <jef...@us...> - 2005-08-31 20:09:30
|
Update of /cvsroot/netpass/NetPass/www/htdocs/Admin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15191/www/htdocs/Admin Modified Files: audit.mhtml autohandler chpwd.mhtml greset.mhtml index.mhtml Log Message: bug fixes, see CHANGES file, see message on netpass-users before deploying these changes Index: index.mhtml =================================================================== RCS file: /cvsroot/netpass/NetPass/www/htdocs/Admin/index.mhtml,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- index.mhtml 3 Aug 2005 02:44:39 -0000 1.12 +++ index.mhtml 31 Aug 2005 20:09:17 -0000 1.13 @@ -5,8 +5,6 @@ # Available under the "Artistic License" # http://www.gnu.org/licenses/license-list.html#ArtisticLicense </%doc> - - <script><!-- setWhereAmI('Home'); --></script> Index: autohandler =================================================================== RCS file: /cvsroot/netpass/NetPass/www/htdocs/Admin/autohandler,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- autohandler 3 Aug 2005 02:44:39 -0000 1.17 +++ autohandler 31 Aug 2005 20:09:17 -0000 1.18 @@ -8,7 +8,44 @@ <%args> $printable => 0; </%args> +<%filter> + s/(href=\")([^\"]+)\"/add_session_id($1,$2)/eg; + s/(action=\")([^\"]+)\"/add_session_id($1,$2)/eg; + my $_SID = $m->session->{_session_id}; + s/\<\/form\>/\<input type=hidden name='npsess' value='$_SID'\>\<\/form\>/i; +</%filter> <%perl> + # this is used by the above filter + sub add_session_id { + my $lt = shift; + my $url = shift; + my $SID = $m->session->{_session_id}; + return $lt.$url.'"' if $url =~ m{^\w+://}; # Don't alter external URLs + if ( $url !~ /npsess=/ ) { + if ($url =~ /\?/) { + $url =~ s/\?/?npsess=$SID&/; + } else { + $url .= "?npsess=".$SID; + } + } + + return $lt.$url.'"'; + } + + # this is used by /Admin/Login for redirects + sub add_session_id2 { + my $url = shift; + return $url if $url =~ m{^\w+://}; # Don't alter external URLs + if ($url =~ /\?/) { + $url =~ s/\?/?npsess=$m->session->{_session_id}&/; + } else { + $url .= "?npsess=".$m->session->{_session_id}; + } + + return $url; + } + + use Sys::Hostname; my $serverType = "PRODUCTION"; if (hostname =~ /-d.cit.buffalo.edu$/) { Index: chpwd.mhtml =================================================================== RCS file: /cvsroot/netpass/NetPass/www/htdocs/Admin/chpwd.mhtml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- chpwd.mhtml 3 May 2005 16:13:30 -0000 1.3 +++ chpwd.mhtml 31 Aug 2005 20:09:17 -0000 1.4 @@ -92,7 +92,8 @@ <tr><td class='left'>New (Confirm) Password:</td> <td class='right'><input name='new2' type='password'></td></tr> <tr><td colspan=2><center><input type='submit' name='submit' value='Change Password'></center></td></tr> -</table></form> +</table> +</form> % } else { Sorry. You don't have permission to use this form. % } Index: audit.mhtml =================================================================== RCS file: /cvsroot/netpass/NetPass/www/htdocs/Admin/audit.mhtml,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- audit.mhtml 24 Apr 2005 03:42:03 -0000 1.7 +++ audit.mhtml 31 Aug 2005 20:09:17 -0000 1.8 @@ -163,7 +163,7 @@ my ($results, $count, $result_set, $next_link, $prev_link) = getAudits($np->db->{'dbh'},$ip,$mac,$uid,$sev,$type,$message,$start); -if($count<0) { +if ($count < 0) { print $q->p( {-class => 'error'}, "Sorry, there was an error while processing your request!"); } @@ -190,20 +190,25 @@ $q->th("Message") )); -while (my $row = $results->fetchrow_hashref() ) { - push( @rows, $q->TR( {-class=> $row->{severity} }, - $q->td({-align=>'center'}, $row->{dt}) . - $q->td({-align=>'center'}, $row->{username}) . - $q->td({-align=>'center'}, $row->{ipAddress}) . - $q->td({-align=>'center'}, NetPass::padMac($row->{macAddress})) . - #$q->td({-align=>'center'}, $row->{severity}) . - #$q->td({-align=>'center'}, $row->{location}) . - $q->td({-align=>'center'}, $row->{message}) +foreach my $row ( sort { $a->[0] <=> $b->[0] } @$results ) { + # 0 dt + # 1 username + # 2 ipAddress + # 3 macAddress + # 4 severity + # 5 location + # 6 message + push( @rows, $q->TR( {-class=> $row->[4] }, + $q->td({-align=>'center'}, $row->[0]) . + $q->td({-align=>'center'}, $row->[1]) . + $q->td({-align=>'center'}, $row->[2]) . + $q->td({-align=>'center'}, NetPass::padMac($row->[3])) . + #$q->td({-align=>'center'}, $row->[4]) . + #$q->td({-align=>'center'}, $row->[5]) . + $q->td({-align=>'center'}, $row->[6]) )); } -$results->finish(); - print $q->table({-width=>'80%'}, @rows); print $q->p(); @@ -220,6 +225,24 @@ my $message = shift; my $start = shift; + # since we dont store the audit table in NDB, we need + # to fetch and merge results from the other NP servers. + + my %hosts = ( &hostname => 1 ); + my $allnw = $np->cfg->getNetworks(); + if (ref($allnw) eq "ARRAY") { + foreach my $nw (@$allnw) { + if ( $np->cfg->ha($nw) ) { + my $svrs = $np->cfg->ha_servers($nw); + if (ref($svrs) eq "ARRAY") { + foreach my $sn (@$svrs) { + $hosts{$sn} = 1; + } + } + } + } + } + $start = 0 if(!($start =~ /\d+/) || $start<0); my $limit = 250; @@ -267,32 +290,49 @@ #print $query; #print join(',', @params); - my $sth = $dbh->prepare($query); + my $lres = $dbh->selectall_arrayref($query); - if(!defined($sth)) { - return ("prepare failed: ". $dbh->errstr, -1); - } - - if( !$sth->execute(@params) ) { - return ("execute failed: ". $dbh->errstr, -1); + if(!defined($lres)) { + return ("failed to retrieve local results: ". $dbh->errstr, -1); } - my $count = $sth->rows; + my $count = $#{$lres}; my $link = "audit.mhtml?ip=$ip&mac=$mac&uid=$uid&type=$type&message=$message&search=Search&start="; my $prev_link = $link . ($start-$limit); my $next_link = ''; my $result_set = ""; - if($count==$limit) { + + if($count == $limit) { $result_set = "$start to " . ($start+$limit); $next_link = $link . ($start+$limit); } else { $result_set = "$start to " . ($start+$count); $next_link = ''; } - return ($sth, $count, $result_set, $next_link, $prev_link); + my @results = @$lres; + +print "others<P>"; + foreach my $npserv (keys %hosts) { +print "others=$npserv<P>"; + my $rdbh = DBI->connect('dbi:mysql:database=netpass;host='.$npserv, + $np->cfg->dbUsername, $np->cfg->dbPassword); + if ($rdbh) { + my $rres = $rdbh->selectall_arrayref($query); + if (ref($rres) eq "ARRAY") { + push @results, @$rres; + } else { + print $q->p({-class => 'error'}, "There was a problem retrieving the results from $npserv"); + } + $rdbh->disconnect; + } else { + print $q->p({-class => 'error'}, "Failed to connect to database on $npserv"); + } + } + + return (\@results, $count, $result_set, $next_link, $prev_link); } </%perl> Index: greset.mhtml =================================================================== RCS file: /cvsroot/netpass/NetPass/www/htdocs/Admin/greset.mhtml,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- greset.mhtml 22 Aug 2005 19:26:08 -0000 1.6 +++ greset.mhtml 31 Aug 2005 20:09:17 -0000 1.7 @@ -68,6 +68,7 @@ print $q->start_form(-name => 'form', -method => "POST"); </%perl> + <h2>Global Reset</h2> <FONT CLASS='error'>WARNING:</FONT>The following will cause <B>all managed ports</B> to be reset to the state you choose.<BR> @@ -128,7 +129,7 @@ border-color:#8b0000;", ); print "</TD>"; -print "</TR></TABLE>"; +print "</TR></TABLE></form>"; </%perl> |