1
rplima2004
Login's System Hack
  • 2005/9/8 11:37

  • rplima2004

  • Just popping in

  • Posts: 70

  • Since: 2004/10/8


Good Morning,

During these days it was questioned me by a customer if it would be possible to limit the system of login of xoops. The limit: not to allow to a loged user already in the site to use this exactly username and password to enter in another session while himself still was loged in.

After very searching, I didn't find no referring to this question in our forums or in the communities, therefore I write this topic in forum of XOOPS Brasil community, which I am part of the group of Support and Contribution. This topic can be seen in this adress.

Based in the answers of this forum, I developed a small hack of the login's system that it decided this problem. And I decided too, to share it with all because it can be of the interest of other xoopers. Thank's to my friends Topet and David for the great tips and to Léu for the translation of this post.

Of course, that’s enough, go hack:

Quote:

//Hack’s Start by rplima
// This hack serves to check if the user already is logged in the site, in case that he is does not allow new login
$query = $xoopsDB->queryF('SELECT * FROM '.$xoopsDB->prefix('online').' WHERE online_uname="'.$uname.'"');
$total = $xoopsDB->getRowsNum($query);
if ($total){
$msg = 'Sorry '.$uname.' But, it wasn’t possible effect your login in the site !! < br />
< p align="left" style="color:red;">
Possibilities:< br />
- You already are logged in the site.< br />
- Somebody logged in the site using your username and password.< br />
- You left the site or close the window of your navigator without click in "logout" link. < br/>
< /p>
Wait some minutes and try again. If the problem persists contact us using the contact form, click in
< a href="'.XOOPS_URL.'/modules/contact/">aqui< /a>.';
redirect_header(XOOPS_URL.'/index.php', 12, $msg);
exit();
}
//Hack’s end


This hack must be placed in the file include/checklogin.php below of line 49 (xoops 2.0.13).
Below you find a stretch of the code until the line 49 to easy localization:

Quote:

$member_handler =& xoops_gethandler('member');
$myts =& MyTextsanitizer::getInstance();
$user =& $member_handler->loginUser($myts->addSlashes($uname), $myts->addSlashes($pass));
if (false != $user) {
if (0 == $user->getVar('level')) {
redirect_header(XOOPS_URL.'/index.php', 5, _US_NOACTTPADM);
exit();
}


Write a new line below “}” and put the hack.

Save file and up again for sever.

I hope that it is useful for you, therefore for me solved a problem and allowed me make more one work using XOOPS.

Greetings for all..


Rodrigo


************************************************************
Para a comunidade XOOPS de Lingua Portuguesa

Bom dia a todos,

Durante esses dias me foi questionado por um cliente se seria possível limitar o sistema de login do xoops, limitar no sentido de não permitir a um usuário já logado no site de usar este mesmo nome de usuário e senha para efetuar outra sessão ao site enquanto o mesmo ainda estivesse logado.

Depois de muito pesquisar, não achei nada referente a essa questão nos fóruns das comunidades que frequento, portanto lancei este tópico no fórum da comunidade XOOPS Brasil, a qual faço parte do grupo de Suporte e Colaboração. Este tópico pode ser visto aqui.

Com base nas respostas deste fórum, desenvolvi um pequeno hack do sistema de login que resolveu este problema, portanto resolvi compartilhá-lo com todos por achar que o mesmo pode ser do interesse de outros usuários xoops. Gostaria de agradecer também aos amigos Topet e David pelas dicas valiosas e ao amigo Leo pela tradução deste post.

Bom, chega de papo, vamos ao hack.

Quote:

//Inicio do hack by rplima
//Este hack serve para checar se o usuário ja está logado no site, caso esteja não permite novo login
$query = $xoopsDB->queryF('SELECT * FROM '.$xoopsDB->prefix('online').' WHERE online_uname="'.$uname.'"');
$total = $xoopsDB->getRowsNum($query);
if ($total){
$msg = 'Desculpe '.$uname.' mas não foi possível efetuar o login no site!! < br />
< p align="left" style="color:red;">
Possíveis causas:< br />
- Você já está logado no site.< br />
- Alguém logou no site utilizando seu nome de usuário e senha.< br />
- Você saiu do site ou fechou a janela do navegador sem clicar no link de logout.< br />
< /p>
Aguarde alguns minutos e tente novamente. Caso o problema persista entre em contato conosco através do formulário de contato clicando
< a href="'.XOOPS_URL.'/modules/contact/">aqui< /a>.';
redirect_header(XOOPS_URL.'/index.php', 12, $msg);
exit();
}
//Fim do hack


Este hack deve ser colocado no arquivo include/checklogin.php logo abaixo da linha 49 (xoops 2.0.13).
Abaixo vc encontra um trecho do código até chegar na linha 49 para facilitar a localização da mesma caso a sua versão não seja a mesma que a minha.

Quote:

$member_handler =& xoops_gethandler('member');
$myts =& MyTextsanitizer::getInstance();
$user =& $member_handler->loginUser($myts->addSlashes($uname), $myts->addSlashes($pass));
if (false != $user) {
if (0 == $user->getVar('level')) {
redirect_header(XOOPS_URL.'/index.php', 5, _US_NOACTTPADM);
exit();
}


Abra uma linha nova logo abaixo do } e coloque o hack aí.

Basta salvar o arquivo e uppar novamente para o servidor.

Espero que seja útil para vocês, pois pra mim solucionou um problema e me permitiu realizar mais um trabalho envolvendo o xoops.

Abraços a todos.


Rodrigo

2
bluenova
Re: Logins System Hack

Very nice, thanks for the tip

Login

Who's Online

211 user(s) are online (147 user(s) are browsing Support Forums)


Members: 0


Guests: 211


more...

Donat-O-Meter

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

Latest GitHub Commits