Index: openacs-4/packages/acs-tcl/tcl/request-processor-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/request-processor-procs.tcl,v diff -u -r1.56 -r1.57 --- openacs-4/packages/acs-tcl/tcl/request-processor-procs.tcl 7 Jan 2004 00:16:06 -0000 1.56 +++ openacs-4/packages/acs-tcl/tcl/request-processor-procs.tcl 8 Jan 2004 08:42:53 -0000 1.57 @@ -637,10 +637,7 @@ } # Who's online - # Don't record requests for not-logged in users - if { [ad_conn untrusted_user_id] != 0 } { - whos_online::user_requested_page [ad_conn untrusted_user_id] - } + whos_online::user_requested_page [ad_conn untrusted_user_id] [ad_conn peeraddr] ##### # Index: openacs-4/packages/acs-tcl/tcl/whos-online-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/whos-online-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-tcl/tcl/whos-online-procs.tcl 3 Oct 2003 10:14:30 -0000 1.1 +++ openacs-4/packages/acs-tcl/tcl/whos-online-procs.tcl 8 Jan 2004 08:42:53 -0000 1.2 @@ -8,6 +8,8 @@ @cvs-id $Id$ } +# TODO: Count anonymous users based on their IP, just to have the number + namespace eval whos_online {} @@ -34,7 +36,7 @@ set interval 1 set oldtime [expr [ns_time] - [interval]] - for {set search [array startsearch last_hit]} {[array anymore last_hit $search]} {} { + for { set search [array startsearch last_hit] } { [array anymore last_hit $search] } {} { set user [array nextelement last_hit $search] set time $last_hit($user) if {$time<$oldtime} { @@ -44,7 +46,7 @@ array donesearch last_hit $search - for {set i 0 } { $i < [llength $onliners_out]} {incr i} { + for { set i 0 } { $i < [llength $onliners_out] } { incr i } { set user_id [lindex $onliners_out $i] foreach name { last_hit invsible_users first_hit } { if { [nsv_exists $name $user_id] } { @@ -67,14 +69,18 @@ -default 600] } -ad_proc -private whos_online::user_requested_page { user_id } { +ad_proc -private whos_online::user_requested_page { user_id ip_address } { Records that the user with given id requested a page on the server @author Bjoern Kiesbye } { - nsv_set last_hit $user_id [ns_time] - if { ![nsv_exists first_hit $user_id] } { - nsv_set first_hit $user_id [ns_time] + if { $user_id != 0 } { + nsv_set last_hit $user_id [ns_time] + if { ![nsv_exists first_hit $user_id] } { + nsv_set first_hit $user_id [ns_time] + } + } else { + # TODO: Record the IP address } } @@ -104,6 +110,20 @@ } } +ad_proc -public whos_online::num_users {} { + Get the number of registered users currently online, and not invisible +} { + # We might want to optimize this, but for now, let's just do it this way: + return [llength [whos_online::user_ids]] +} + +ad_proc -public whos_online::num_anonymous {} { + Get the number of anony users currently online, and not invisible +} { + # Not implemented yet: number of anonymous users counted by IP + number of invisible users + return 0 +} + ad_proc -public whos_online::user_ids { {-all:boolean} } { @@ -118,7 +138,7 @@ set onliners [list] set oldtime [expr [ns_time] - [interval]] - for {set search [array startsearch last_hit]} {[array anymore last_hit $search]} {} { + for { set search [array startsearch last_hit] } { [array anymore last_hit $search] } {} { set user_id [array nextelement last_hit $search] if { $last_hit($user_id) > $oldtime } { # User is online