UBB.Dev
Posted By: Slurpee Limiting Users on board at one time? - 03/23/2004 10:06 PM
I don't think this hack has ever been written, and for me it would be very beneficial, because when my board hits about 400 users on at once it completely kills my server.

I don't mind writing this myself, but some direction on where to start would help.

Basically, let's say the board hits the max allowed (400 or whatever), either the closed page comes up for those users over the max, or something like that. Or a different message, just something along those lines.

Any suggestions would be greatly appreciated.
Posted By: Rick Re: Limiting Users on board at one time? - 03/23/2004 11:00 PM
It wouldn't be too hard to limit the number of registered users that are online at a given time, basically 2 places in ubbt.inc.php (the do_login function and also in the authenticate function where it checks if the remember me key is set. In those 2 spots you'd need to do a COUNT of the total # of users already in the w3t_Online table, before actually inserting/updating their session id in the Users table.

However, the main obstable is the fact that guests don't go through any type of login procedure. So there really wouldn't be any way to limit users that don't login. So, you might have a total of 400 users online, and someone tries to login and they'd get the error message while anyone browsing while not being logged in would not. This kinda defeats the purpose.

The other way to accomplish this would be to do a count of the online total on every call to authenticate. The problem with this method is it would just give the errors out to random users, so a user might be logged in and then all of the sudden get an error that says, sorry we're full. Again, this kind of defeats the purpse and would get rather frustrating for the end user. Not to mention the extra query done on every page to see how many users online in total.

These are the primary reasons why this isn't a standard feature. Of course, maybe someone can think of some other way around the issues above
Posted By: Rick Re: Limiting Users on board at one time? - 03/23/2004 11:07 PM
Actually, there is a way to achieve the second option and make it so the error would only appear for non-logged in users or guests. Would still give you an extra query per page, but something you can try to see how it works for you. I'll throw a bit of code together in a bit.
Posted By: Slurpee Re: Limiting Users on board at one time? - 03/23/2004 11:08 PM
Adding another query on every page wouldn't be something I'd want to do anyway yep, that's where most of my problems begin with, all of the queries to the DB. It seems that's the only way however.

I would appreciate if anyone has a work-around, I've been trying to come up with one myself, but now I see the problems with it.
Posted By: Slurpee Re: Limiting Users on board at one time? - 03/23/2004 11:09 PM
[]Scream said:
Actually, there is a way to achieve the second option and make it so the error would only appear for non-logged in users or guests. Would still give you an extra query per page, but something you can try to see how it works for you. I'll throw a bit of code together in a bit. [/]

Cool, thanks a ton scream for taking the time!
Posted By: Rick Re: Limiting Users on board at one time? - 03/23/2004 11:44 PM
Here ya go.
© UBB.Developers