<?php
Ob_start ();
Session_Start ();
$num = 0;
$dirpt = "Online";
$reftime = 1;
if (Is_dir ($dirpt) && $dir = Opendir ($dirpt)) {
while (($file = Readdir ($dir))!== false) {
if (strcmp ($file, "..") ==0 | | strcmp ($file, ".") ==0) {
Continue
}
$D _[date ("y-m-d h:i:s", Filemtime ($dirpt.) /". $file))]= $file;
$num + +;
Unset ($cum);
}
Closedir ($dir);
$filename = session_id ();
$fp = fopen ($dirpt.) /". $filename," w ");
Fputs ($FP, "");
Fclose ($FP);
$ntime = Date ("y-m-d h:i:s", Mktime (Date ("H"), Date ("I") -1,0,date ("M"), Date ("D"), Date ("Y"));
$D _[$ntime]= "-";
Krsort ($D _);
$onlinenumber = 0;
while (1) {
$vkey =key ($D _);
$onlinenumber + +;
if (strcmp ($ntime, $vkey) ==0) {
Break
}else{
Array_shift ($D _);
}
}
Array_shift ($D _);
Reset ($D _);
while (count ($D _) >0) {
$ckey =key ($D _);
Unlink ($dirpt. " /". $D _[$ckey]);
if (!next ($D _)) {
Break
}
}
}else{
@chmod ("..", 0777);
@mkdir ($dirpt, 0777);
}
$online = $onlinenumber-1;
$retime =60* $reftime;
echo "Current online <strong><font color=red> $online </font></strong> people <meta Http-equiv=refresh Content=\ "{$retime},url=\" > ";
Ob_end_flush ();
?>
<!--
"Using file attributes combined with session for online population statistics"
Author: sports98
Date of preparation: 2003-3-19
-->