Here, how you can display total number of online user in your webpage you want. Just include file name, which I have given file name as online-user.php here. You need to include this file on any php page you want to display total users online.
I have developed this php script to implement on my own webpage.
See this, I have implement this on https://www.ashesh.com.np/nepali-date-converter.php
online-user.php
$file1 = 'online-user-ashesh/ip.txt';
$lines = file($file1);
$line2 = "";
foreach ($lines as $line_num => $line)
{
//echo $line."
";
$fp = strpos($line,'****');
$nam = substr($line,0,$fp);
$sp = strpos($line,'++++');
$val = substr($line,$fp+4,$sp-($fp+4));
$diff = $sd-$val;
if($diff < 900 && $nam != $rip)
{
$count = $count+1;
$line2 = $line2.$line;
//echo $line2;
}
}
$my = $rip."****".$sd."++++\n";
$open1 = fopen($file1, 'w');
fwrite($open1,"$line2");
fwrite($open1,"$my");
fclose($open1);
echo "| "; echo ""; //echo "A | "; echo ""; echo "Total users online $count "; echo " |
And you need to create empty text file called ip.txt as described in online-user.php code.
You can download here too