This is a class i wrote 6 years ago and uploaded at http://www.phpclasses.org/package/4889-PHP-Keep-track-of-the-current-site-number-of-visitors.html
This class can be used to keeep track of the current site number of current visitors. It uses the IP address of the visitor accessing the site to keep track of the visit in a MySQL database. The class can return the number of visitors still active by default for the last 5 minutes.