TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Could someone help me write this script? (http://www.talkphp.com/absolute-beginners/46-could-someone-help-me-write-script.html)

AndyM3 04-18-2005 10:37 PM

..........
 
Fixed - ignore.

CreativeLogic 04-18-2005 10:41 PM

Can you have access to a database for all the domains?

AndyM3 04-19-2005 01:02 AM

Fixed - ignore.

CreativeLogic 04-19-2005 01:07 AM

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.

AndyM3 04-19-2005 01:12 AM

Fixed - ignore.

CreativeLogic 04-19-2005 01:16 AM

Yes they would. Just #2 would have more queries.

CreativeLogic 04-19-2005 01:16 AM

Hold on and I'll try to write something up real quick.

CreativeLogic 04-19-2005 01:24 AM

This is untested but it should work.
online.php
Code:

// 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
echo $thisdomain['totalusers'];

// 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[0];

// add the above two lines for all the sites you wish


AndyM3 04-19-2005 01:37 AM

Fixed - ignore.

CreativeLogic 04-19-2005 03:46 PM

You will need to create a database. According to my script above you will need to name the database table sessions. Then you have to have a row in that table named lastvisit.

By the way I left something out of there. One of the most important parts. I'll change it in a little bit.

CreativeLogic 04-19-2005 04:42 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.

AndyM3 04-19-2005 10:24 PM

Fixed - ignore.

CreativeLogic 04-19-2005 10:58 PM

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.

AndyM3 04-19-2005 11:09 PM

Fixed - ignore.

AndyM3 05-08-2005 03:44 AM

Fixed - ignore.

KingOfTheSouth 12-20-2008 02:55 AM

lol wgt do you keep posting fixed-ignore?

Village Idiot 12-20-2008 04:48 AM

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.


All times are GMT. The time now is 02:46 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0