Display total online users in web page

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

    Example for how to include online-user.php in web page.

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

Ashesh

सयौ थुङ्गा फूलका हामी एउटै माला नेपाली, Welcome to my webpage. I'm from the Himalayan Country of Nepal. Well talking about me, I like mostly Web programming and Designing and furthermore I like Philosophical literature, Photography, Social networking. And I am Romantic and Sentimental person to some extent. Read more...