OK. I can think of two ways of doing this. Either insert all the information into a single database on every domain acessing the same database. Or have a seperate database for each site and output the number of visitors with a seperate PHP file and pull the number outputted from each page. The first way would be the way I would go but it's a little harder to setup.
// delete old visitors
$timeout = time() - 60 * 5; // 5 minutes
mysql_query("DELETE * FROM sessions WHERE lastvisit < $timeout");
// update user
mysql_query("REPLACE INTO sessions SET lastvisit = '" . time() . "'");
// query users
$thisdomainquery = mysql_query("SELECT COUNT(*) AS totalusers FROM sessions");
$thisdomain = mssql_fetch_array($thisdomainquery);
// will output users on this site
// pull info from other sites
// this will pull the info from the other domains with each new line as an array element
$network = file('http://www.anotherdomain.com/online.php');
$networktotal += $network;
// add the above two lines for all the sites you wish
Last edited by CreativeLogic : 04-19-2005 at 04:25 PM.
I updated the script and actually tested it this time. I decided that it was not a very good way to go about this script. It makes the page lag and if a site is down will make the page hang for a very long time. I will update the code to make it work with one database shortly. If the sites are all on the same server you'll run into no problems. If not you will have to allow the ipaddress of the server to access the database.
You will need to use one database and just link all the sites to the one server. It shouldn't be too rough especially if you have cPanel. It's rather easy to setup in cPanel. I've been rather busy today. I'll see if I can't help you out later tonight and if not tomorrow.
Please don't edit your posts when you solve something, you probably aren't the only person to have whatever problem it was so leaving it could be of use to someone. It is considered good etiquette on help forum to leave your posts in tact.