1
martyras
One user login with a username
  • 2004/11/23 18:28

  • martyras

  • Just popping in

  • Posts: 37

  • Since: 2004/11/1


Hi friends,

I would like to ask how I can make XOOPS grand access to only one username at a time? For example when user "userxxx" has logged in, an other user who is trying to login with the same username ("userxxx") won't get access and be notified that another user is already logged in.

Thank you.

2
irmtfan
Re: One user login with a username
  • 2004/11/23 18:48

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


huum
i nearlly sure this possible with check ip of first user login and no other way for it
am i right?
btw i think you want this for prevent sneak preview at your site or something like this

3
Mithrandir
Re: One user login with a username

include/checklogin.php around line 43:
//existing code
$myts =& MyTextsanitizer::getInstance();
$user =& $member_handler->loginUser(addslashes($myts->stripSlashesGPC($uname)), addslashes($myts->stripSlashesGPC($pass)));
if (
false != $user) {
    
//add this to check if user is already logged in
    
if ($user->isOnline()) {
        
redirect_header('index.php'3"User is already logged in");
    }
    
//rest of the existingcode


Note that the who's online block should be set visible for this to work properly.

4
martyras
Re: One user login with a username
  • 2004/11/24 3:58

  • martyras

  • Just popping in

  • Posts: 37

  • Since: 2004/11/1


Quote:

irmtfan wrote:
huum
i nearlly sure this possible with check ip of first user login and no other way for it
am i right?
btw i think you want this for prevent sneak preview at your site or something like this


true.

Quote:

Mithrandir wrote:
include/checklogin.php around line 43:
//existing code
$myts =& MyTextsanitizer::getInstance();
$user =& $member_handler->loginUser(addslashes($myts->stripSlashesGPC($uname)), addslashes($myts->stripSlashesGPC($pass)));
if (
false != $user) {
    
//add this to check if user is already logged in
    
if ($user->isOnline()) {
        
redirect_header('index.php'3"User is already logged in");
    }
    
//rest of the existingcode


Note that the who's online block should be set visible for this to work properly.


Thanks a lot, I will try it and i'll post the result. Can you tell why the who's online block must be set to visible? Does it need to read something from it?

5
Mithrandir
Re: One user login with a username

Quote:
Can you tell why the who's online block must be set to visible? Does it need to read something from it?

the $user->isOnline() method looks up the database table of online users - and that table is only filled with values when the who's online block is shown

6
martyras
Re: One user login with a username
  • 2004/12/7 15:33

  • martyras

  • Just popping in

  • Posts: 37

  • Since: 2004/11/1


Ok, it works but with some minnor gliches.

1) If a user hasn't logged out (for example, closed the browser and go to the website again), XOOPS report him as logged and he can't login again. Is there a way to make XOOPS update the database that the user is logged out when he closes the browser (I assuse it has to do with inactivity time).

2) Is there a way for this modification not to apply for administrators or other specified groups?

Thank you.

7
jpco_122122
Re: One user login with a username

Yes, same thing w/me i found out this one? Can anyone tell us how to fix this one?

8
martyras
Re: One user login with a username
  • 2005/1/8 21:21

  • martyras

  • Just popping in

  • Posts: 37

  • Since: 2004/11/1


First, Happy new year all XOOPS friends!

I have changed the code so the check doesn't apply to admins:

if ($user->isAdmin() == false) { 
        if (
$user->isOnline()) {
            
redirect_header('index.php'3"User is already logged in");
        }
    }


Anyone to help me on how to exclude moderators too?

And another question. It seems that the online block gets the database updates (deletes inactive users) after a large number of user logins. Is there a way to decrease that number?

Thanks.

9
tl
Re: One user login with a username
  • 2005/1/9 0:47

  • tl

  • Friend of XOOPS

  • Posts: 999

  • Since: 2002/6/23


Quote:

Ok, it works but with some minnor gliches.

1) If a user hasn't logged out (for example, closed the browser and go to the website again), XOOPS report him as logged and he can't login again. Is there a way to make XOOPS update the database that the user is logged out when he closes the browser (I assuse it has to do with inactivity time).


If you have enabled WhoisOnline block, the user will have to wait for 5 minutes to re-login. You can tell user this in the error message. The user may have to wait a bit longer if you have a slow traffic site as the garbage collector routine may not be triggered.

If you don't want to enable WhoisOnline, you way want to check this TIP by GIJOE

http://xoops-tips.com/modules/news/article.php?storyid=48

10
zANavAShi
Re: One user login with a username
  • 2005/5/30 13:14

  • zANavAShi

  • Just popping in

  • Posts: 28

  • Since: 2005/5/6 5


Absolutely BRILLIANT!!!

Thanks Mithrandir and martyras, this is exactly what I was looking for for my site.


Login

Who's Online

227 user(s) are online (206 user(s) are browsing Support Forums)


Members: 0


Guests: 227


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Feb 29
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits