diff --git a/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/CGI.pm b/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/CGI.pm
index 416695b44..2325904a7 100644
--- a/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/CGI.pm
+++ b/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/CGI.pm
@@ -10,7 +10,7 @@ our @ISA = qw(CGI);
use Lemonldap::NG::Handler::SharedConf qw(:all);
-our $VERSION = '0.1';
+our $VERSION = '0.11';
sub new {
my $class = shift;
@@ -93,6 +93,10 @@ use Lemonldap::NG::Handler::SharedConf qw(:locationRules);
our @ISA = qw(Lemonldap::NG::Handler::SharedConf);
+sub localInit {
+ 1;
+}
+
sub lmLog {
my ( $self, $mess, $level ) = @_;
$mess =~ s/^.*HASH[^:]*:/__PACKAGE__/e;
diff --git a/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Sessions.pm b/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Sessions.pm
index 92d2fb3ee..18d55258e 100755
--- a/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Sessions.pm
+++ b/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Sessions.pm
@@ -105,7 +105,7 @@ sub new {
my ( $class, $args ) = @_;
my $self = $class->SUPER::new($args)
or _abort( 'Unable to start ' . __PACKAGE__, 'See Apache logs for more' );
- foreach (qw(jqueryUri jquerySimpleTreeUri personnalCss imagePath)) {
+ foreach (qw(jqueryUri jquerySimpleTreeUri personnalCss imagePath protection)) {
$self->{$_} = $args->{$_}; # or print STDERR "Warning, $_ is not set, falling to default value\n";
}
eval "use $globalStorage";
@@ -191,11 +191,11 @@ sub process {
)
{
last if ( ( keys %{ $byUid->{$uid} } ) == 1 );
- print "
$uid";
+ print "- $uid
";
foreach my $ip ( sort keys %{ $byUid->{$uid} } ) {
- print "- $ip
";
+ print "- $ip
";
foreach my $session ( @{ $byUid->{$uid}->{$ip} } ) {
- print "- {id}');\">"
+ print "
- {id}\">{id}');\">"
. localtime( $session->{_utime} )
. "
";
}
@@ -226,7 +226,7 @@ sub process {
$self->start("IP : $req");
$self->window("$req");
foreach my $ip ( sort keys %$byUid ) {
- print "- $ip
";
+ print "- $ip
";
foreach my $uid ( sort keys %{ $byUid->{$ip} } ) {
$self->ajaxNode(
$uid,
@@ -334,6 +334,33 @@ sub process {
}
}
+ # Ajax request to see users by IP
+ elsif ( my $ip = $self->param('uidByIp') ) {
+ my $byUser;
+ print $self->header( -type => 'text/html; charset=utf8' );
+ $globalStorage->get_key_from_all_sessions(
+ $globalStorageOptions,
+ sub {
+ my $entry = shift;
+ my $id = shift;
+ if ( $entry->{ipAddr} eq $ip ) {
+ push @{ $byUser->{ $entry->{uid} } },
+ { id => $id, _utime => $entry->{_utime} };
+ }
+ undef;
+ }
+ );
+ foreach my $user (sort keys %$byUser) {
+ print "- $user
";
+ foreach my $session ( @{ $byUser->{$user} } ) {
+ print "- {id}\">{id}');\">"
+ . localtime( $session->{_utime} )
+ . "
";
+ }
+ print "
";
+ }
+ }
+
# Ajax request to see connexions from a user
elsif ( my $uid = $self->param('uid') ) {
my $byIp;
@@ -351,9 +378,9 @@ sub process {
}
);
foreach my $ip ( sort keys %$byIp ) {
- print "- $ip
";
+ print "- $ip
";
foreach my $session ( @{ $byIp->{$ip} } ) {
- print "- {id}');\">"
+ print "
- {id}\">{id}');\">"
. localtime( $session->{_utime} )
. "
";
}
@@ -387,6 +414,38 @@ sub process {
}
}
+ # Display by IP classes
+ elsif ( $self->param('ipclasses') ) {
+ my $partial = $self->param('p') ? $self->param('p').'.' : '';
+ my $repartial = quotemeta($partial);
+ my ( $byIp, $count );
+ $globalStorage->get_key_from_all_sessions(
+ $globalStorageOptions,
+ sub {
+ my $entry = shift;
+ $entry->{ipAddr} =~ /^$repartial(\d+)/ or return undef;
+ $byIp->{$1}++;
+ $count++;
+ undef;
+ }
+ );
+
+ # Ajax request to list ip subclasses
+ if ( $partial ) {
+ print $self->header( -type => 'text/html; charset=utf8' );
+ }
+
+ # Display by IP subclass
+ else {
+ $self->start("Active sessions ($count)");
+ $self->window("Sessions par réseaux ($count)");
+ }
+ foreach my $ip ( sort {$a<=>$b} keys %$byIp ) {
+ $self->ajaxNode( "$partial$ip", "$partial$ip ($byIp->{$ip})", ($partial!~/^\d+\.\d+\.\d+/?"ipclasses=1&p=$partial$ip":"uidByIp=$partial$ip"));
+ }
+ $self->end() unless($partial);
+ }
+
# Default display
else {
my ( $byUid, $count );
@@ -490,6 +549,7 @@ sub window {
my $root = shift;
print '