4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: Lucifix on October 05, 2009, 05:31:08 PM
-
Does anyone have idea how to set that users will be automatically logged in when they active their account?
-
In register.php
Find:
$activationkey = trim($HTTP_GET_VARS['activationkey']);
$sql = "SELECT ".get_user_table_field("", "user_name").get_user_table_field(", ", "user_email").get_user_table_field(", ", "user_activationkey")."
FROM ".USERS_TABLE."
WHERE ".get_user_table_field("", "user_activationkey")." = '$activationkey'";
Replace with:
$activationkey = trim($HTTP_GET_VARS['activationkey']);
//Start Auto-login After Activation
$sql = "SELECT ".get_user_table_field("", "user_name").get_user_table_field(", ", "user_password").get_user_table_field(", ", "user_email").get_user_table_field(", ", "user_activationkey")."
FROM ".USERS_TABLE."
WHERE ".get_user_table_field("", "user_activationkey")." = '$activationkey'";
//End Auto-login After Activation
Find:
$site_email->set_body("activation_success", $config['language_dir']);
$site_email->send_email();
}
After Add:
//Start Auto-login After Activation
if ($site_sess->login($row['user_name'], $row['user_password'], 1, 1, 1)) {
redirect("index.php");
}
//End Auto-login After Activation
In includes / sessions.php
Find:
function login($user_name = "", $user_password = "", $auto_login = 0, $set_auto_login = 1) {
Replace With:
function login($user_name = "", $user_password = "", $auto_login = 0, $set_auto_login = 1, $activate= 0) {
Find:
$user_password = md5($user_password);
Replace with:
//Start Auto-login After Activation
$user_password = ($activate == 0) ? md5($user_password) : $user_password;
//End Auto-login After Activation
-
And in case gallery doesn't have activation, in register.php find:
$msg = $lang['register_success_none'];
insert below:
//Start Auto-login After Activation
if ($site_sess->login($user_name, $user_password, 1, 1, 1))
{
$msg .= '<meta http-equiv="refresh" content="10;url='.$site_sess->url(ROOT_PATH."index.php").'">';
}
//End Auto-login After Activation
It should redirect to index page after 10 seconds.
-
Thx guys!
One thing... how safe is to modify this? I mean if I register with public computer and browser save your url with activation link. Will other user be able to log in if he enters that url even if I log off that computer?
-
Yes, that's a good point.
if you replace
$sql = "SELECT ".get_user_table_field("", "user_name").get_user_table_field(", ", "user_email").get_user_table_field(", ", "user_activationkey")."
FROM ".USERS_TABLE."
WHERE ".get_user_table_field("", "user_activationkey")." = '$activationkey'";
$row = $site_db->query_firstrow($sql);
if (!$row) {
$msg = $lang['invalid_activationkey'];
}
with:
$sql = "SELECT ".get_user_table_field("", "user_name").get_user_table_field(", ", "user_email").get_user_table_field(", ", "user_activationkey").get_user_table_field(", ", "user_level")."
FROM ".USERS_TABLE."
WHERE ".get_user_table_field("", "user_activationkey")." = '$activationkey'";
$row = $site_db->query_firstrow($sql);
if (!$row) {
$msg = $lang['invalid_activationkey'];
}
elseif ($row['user_level'] != USER_AWAITING)
{
redirect("index.php");
}
Then only first visit via activation link will log you in, all others will simply redirect to home page. And also, replace
$site_sess->login($user_name, $user_password, 1, 1, 1)
with:
$site_sess->login($user_name, $user_password, 0, 1, 1)
it will log you in without "auto login"
-
Thanks for helping me, but I think this isn't working.
Even only with impss's code it doesn't :( This one is working ;)
Can someone else please try it, maybe there is something wrong with my modificated 4images?
v@no, where should I change this:
$site_sess->login($user_name, $user_password, 0, 1, 1)
Edited:
I think this is the right one:
//Start Auto-login After Activation
$sql = "SELECT ".get_user_table_field("", "user_name").get_user_table_field(", ", "user_password").get_user_table_field(", ", "user_email").get_user_table_field(", ", "user_activationkey").get_user_table_field(", ", "user_level")."
FROM ".USERS_TABLE."
WHERE ".get_user_table_field("", "user_activationkey")." = '$activationkey'";
//End Auto-login After Activation
if ($site_sess->login($row['user_name'], $row['user_password'], 0, 1, 1)) {
Correct?
-
v@no, where should I change this:
$site_sess->login($user_name, $user_password, 0, 1, 1)
in the code you just added.
But, I didn't realize imps' code a little different, in their code you'll need replace
if ($site_sess->login($row['user_name'], $row['user_password'], 1, 1, 1)) {
with
if ($site_sess->login($row['user_name'], $row['user_password'], 0, 1, 1)) {
to remove auto login
-
Yup it's working just fine :) Thx!
Maybe someone should post this in topic Mods & Plugins (Releases & Support)