Well here is the first version I used.
<?php
/* Start the session */
session_start();
/* Define how long the maximum amount of time the session can be inactive. */
define("MAX_IDLE_TIME", 3);
function getOnlineUsers(){
if ( $directory_handle = opendir( session_save_path() ) ) {
$count = 0;
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) ';
?>
And is the version that majik-sheff gave me.
<?php
session_start();//kick off the session
/* Define how long the maximum amount of time the session can be inactive. */
define("MAX_IDLE_TIME", 180); //In seconds this is 3 minutes
function†getOnlineUsers() {
$directory_handle = opendir(session_save_path()) or die("Could not open session path<BR>\n"); //much cleaner way to get in
$count†=†0;††//At least he got this line right
while($file = readdir($directory_handle)) { //Loop through the directory entries
if(!((time()- fileatime(session_save_path() . '/' . $file)†>†MAX_IDLE_TIME) || $file†== '.' || $file == '..')) { //check for ".", "..", and time all at once, putting the most likely match first
$count++; // up the counter
} //closing braces are good
} //ditto
return($count); //functions are usually pointless without a return of some kind
}
?>
Incase you want to see it, here is the include I am trying to use, the page seems to say there are errors in both statements.
<?php
include('getOnlineUsers.php');
echo 'There are ' . getOnlineUsers() . ' currently browsing mzanime.com';
?>