
November 15th, 2002, 10:08 AM
|
|
Junior Member
|
|
Join Date: Nov 2002
Location: Alabama
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Good article
Good article. There is a missing curly brace in the function.
I modified it a little bit so that it prints out a table:
PHP Code:
function getOnlineUsers(){
define("MAX_IDLE_TIME", 5);
$count = 0;
if ( $directory_handle = opendir( session_save_path() ) ) {
while ( false !== ( $file = readdir( $directory_handle ) ) ) {
if($file != '.' && $file != '..'){
// Comment the 'if(...){' and '}' lines if you get a significant amount of traffic
if((time()- fileatime(session_save_path() . '/' . $file)) < MAX_IDLE_TIME * 60) {
$count++;
}
}
}
closedir($directory_handle);
}
//show number of users in an html table
print "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" border=\"0\">\n";
print "<tr><td>";
($count == 1)?(print $count." user online"):(print $count." users online");
print "</td></tr>\n";
print "</table>\n";
return;
}
|