Example:
Set for five minute timeout
For an example of the info feature visit here
For an example of the database file visit here
This script will display how many active users are viewing the page or multiple pages at any given time in a jpg image. It works by setting a timeout for the user. So, if the script isn't loaded again within the amount of time you set; the user is deemed inactive. You can set the script to work with different active user counters for different pages or set it up as a global one that can be pasted into any page to give you an accurate reading. The database is text file based which means you won't have to do any troubling SQL stuff. However, if you want the script to have multiple counters then it will need to make multiple text files. So if you plan to have a lot it's probably a best idea to dedicate a folder to those database files.
How to use:
Embed it anywhere with a link like this "/active.php?f=example". The "?f=example" part at the end defines what database file you want the script to use. You can remove this feature by following the directions below. Edit the setting below to fit your needs and you're all done! You can put on multiple pages or just one page.
To view your active user database you can just go directly to the flat file but i've implemented a prettier feature that formats the data for easier reading. Just add "?t=info" at the end of your script URL along with the database file you wish to use (if you haven't removed the feature).
For example: "/active.php?t=info&f=example"
I originally had it working without the need for any database file and just using PHP sessions to record the last time you visited but that didn't work out so well because if the user didn't have cookies enabled PHP sessions didn't work and the counter would count them multiple times. So now the script is based off I.P which is even better because it can eliminate people browsing on different browsers or something.
The reason I made this script is not so I could use it on a site of my own. Hell, I don't want people to know how many people are currently viewing my site, that'd be embarrassing. The real reason I made it was to test if I could. I saw a website that was offering this feature and I wanted to see how hard it was to do it myself. I learned a lot about file handling when I made this and actually rewrote the script twice. The script is heavily commented so you PHP novices can easily understand it and edit it themselves. The script is made for expandability it should be pretty easy to edit.
If you have any questions, comments, ideas, or suggestions please shoot me an e-mail and I'd be happy to help.