= time() - 86400)// check timestamp past time less than 24 hrs
{
$new_file[] = $line; // push line new array
}
if(strpos( $users[2], 'user') ===false )// get array of bots
{
$bots[] = $users[2];
}
if(strpos( $users[2], 'user') !==false )// get array of all users
{
$all[] = $users[0];
//$non_bot++;
}
if(strpos( $users[2], 'mobileuser') !==false )// get array of mobile users only
{
$mobile[] = $users[0];
//$non_bot++;
}
//compare time and delete lines
//minutes 86400 24hrs 3600 1 hour expiration = 3 hours
$i++;
}
//write filtered lines back to file
file_put_contents($file_name, $new_file, LOCK_EX);
//count page hits
$hits = $i;
//check for bots
$bot_cnt = count((array) $bots);// count bots array
if($bot_cnt > 0){// if more than 0
$bot = array_unique($bots);// array unique it
$bot = implode(" ", $bot); // implode to string variable
}
if(empty($bot)){// if empty didsplay none
$bot = " none";
}
//now many unique users online
//var_dump($all);
//array_shift($all);
$mobile_cnt = count((array) $mobile);// count mobile
if($mobile_cnt > 0){// more than 0
$mobile = array_unique($mobile);// array unique
$mobile = count((array) $mobile);// recount
}else{
$mobile =$mobile_cnt;// else display count is 0
}
$all_cnt = count((array) $all);// ditto as above
if($all_cnt > 0){
$all = array_unique($all);
$online = count((array) $all);
}else{
$online =$all_cnt;
}
//var_dump($all);
//display results
echo "Page views today $hits
";
echo "Users online today $online
";
echo "Mobile Users today $mobile
";
echo "Bots today: $bot ";
?>