4images Forum & Community
4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: knacknuss on August 02, 2006, 11:10:10 PM
-
Hi all
I'm planning to provide pictures to only a certain audience, which means, users can't register themselves, they are getting a username and a password. To prevent abuse - people giving theire username and password to their friends - i would like to make sure, that only one user with a certain username can login at the time...if someone else tries to login with the same username at the same time he'll get an error message.
How can I do that?
Thanks for your help :)
BTW I'm using version 1.7.2
-
Here is very basic way accomplish what you are asking. This will not allow visitors login with the same name from different IPs, and it only will work while first logged in member's session is still active. Also, you probably should disallow auto login feature.
In includes/sessions.php find: if ($row[$user_table_fields['user_password']] == $user_password) {
Insert below: $sql = "SELECT session_user_id
FROM ".SESSIONS_TABLE."
WHERE session_user_id = $user_id AND session_ip <> '".$this->session_ip."'";
if ($site_db->query_firstrow($sql))
{
global $loginerror;
$loginerror = 1;
return false;
}
In login.php find: $error = $lang['invalid_login'];
Insert above: if (isset($loginerror))
$error = "Somebody already logged in with this username";
else
(tested on v1.7.3)
-
Hi V@no
First of all I would like to appologies for my late reply :(
I have added the code and it just works perfect :) Thanks a lot!
The next thing I would like to to, is adding a field to the user tabel to be able to set a expiry date for a user account, which makes it impossible to login once the account has expired...
I hope i'll manage to add the things needed to the database and the admin area, but I guess I might need some help with the login...:)
Thanks again and have a great weekend :)