Global variables from loadUserSettings in smf_2_integrations_hooks file.

Started by CoderLanie, May 17, 2021, 11:23:44 PM

Previous topic - Next topic

CoderLanie

I am getting a hang of this hooking thing. I would like to grab the display, email, and password.

function smf_login_function($memberName, $hash_password, $cookieTime)
{
$firstDisplayName = $memberName;
$firstPassword = $hash_password;

$user_info= loadUserSettings();
$smfemail = $user_info['email'];
$smfpw = $user_info['passwd'];
$displayName = $user_info['name'];

require 'first_login.php';
}


I get Undefined Index errors, (but none of the ones I called.) I'm not sure what I'm missing.


Kindred

Globalize $user_info or use a different name, because user_info is one of the main smf arrays, iirc
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

CoderLanie

I changed the variable name but with the same errors, but, I feel like I don't need to do what I wanted to do. So with that said, for some reason, I'm setting the session in my script but it won't be acknowledged in my main website!

the code in the script is simply $_SESSION['name'] = $passedName

When I created it for my website, it was set just fine but here it won't set.

Kindred

that's because SMF controls the session -- so it overwrites your attempt.



It might help if you told us exactly what the errors are, rather than having us try to guess.....
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

CoderLanie

I figured out what I need to do. Thanks!

CoderLanie

Okay, Maybe I didn't..


This is the code thats in the smf_2_integration file:

function smf_login_function($memberName, $hash_password, $cookieTime)
{
$tmnDisplayName = $memberName;
$tmnPassword = $hash_password;

loadUserSettings();
global $user_info;

require 'tmn_login.php';
}


What I'm trying to do, is set SESSIONS for my application.
What I want to do is use the script thats on my application (since SMF will override any attempt).

These are the variables in my script in my application, not in SMF.
$smf_user_info = $user_info;
$smfuserid = $smf_user_info['id'];
$smfusername = $smf_user_info['username'];
$smfdisplayname = $smf_user_info['name'];
$smfemail = $smf_user_info['email'];


I'm basically going to match all the info and log the user in that way.



I also tried to grab a single sell from the SMF database but it wouldn't work.


What I was thinking of doing after my last "nevermind" post was to put the IP addy in my tables but again, the integrate_login only gets those three variables. I need to make even the IP gloab from loadUserSettings(), which is not working.


These are the errors that come up on my application when I try to log in:

Notice: Undefined index: member_name
Notice: Undefined index: id_member
Notice: Undefined index: passwd
Notice: Undefined index: password_salt
Notice: Undefined index: additional_groups
Notice: Undefined index: id_group



Kindred

well, it would seem that you are not actually passing the $membername in the function call...

I'd expect to see something like this

smf_login_function('SomeMemberName','^*HGGKSYUFD',2400);
(after processing whatever variables you actually use in the function call)

not
smf_login_function();



You can't use this function like this unless you actually HAVE the membername and other variables in "memory" when you call it.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

CoderLanie

$memberName and the hashed password gets passed through that function upon sign in within the smf_2_integration hooks file.

I am simply trying to globalize loadUserSettings so I can access the users information.

do I need to pas the member name or the hashed password into loadUserSettings?

There is zero documentation on loadUserSettings that I've come across. All it does it explain what's in $user_info.

CoderLanie

This is the error that comes up when I try to log in now: The database value you're trying to insert does not exist: current_member

I passeed $memberName into loadUserSettings().

Kindred

try this.... after loadusersettings();


echo '<h2>$USER_INFO</h2>';
echo '<pre>'; print_r($user_info); echo '</pre>';
echo '<hr />';
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

live627

The problem with loadUserSettings() is that it was not really designed to be manually called. It was built specifically for SMF to load the user from the    cookie. It has a hook integrate_verify_user which can be used like this. This won't work for you because you don't have the id.

So you need to fetch member data from the database.



$request = $smcFunc['db_query']('', '
SELECT id_member, id_group, lngfile, is_activated, email_address, additional_groups
FROM {db_prefix}members
WHERE member_name = {string:name}
LIMIT 1',
array(
'name' => $memberName,
)
);


$user_settings = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);[/quote]

CoderLanie

Let me ask another question because I'm very inexperienced with coding (if it wasn't obvious enough).

I need to set a session for my website to log the user in. Is there any way to do this via the SMF?

The user needs to be logged in to keep track of their movements.

My application is a game.

CoderLanie

What are the sessions that get set for SMF?

If I know these, then I can put that session key into a table with the users info when they log in, and then match that session to the table from my website.

So upon login, my table would have
smf_session_id and memberName

and then on my applicatoin, I can retrieve that session ID and match it to the table, get the member name, and then match that to the corresponding info I need for my application.


I simply need to set a session.

live627

The database table is smf_sessions and the handler is in Sessions.php.

CoderLanie

I'm using site ground and did a clean install on SMF several times. The sessions.php file isnt included??

Aleksi "Lex" Kilpinen

Slava
Ukraini!


"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

CoderLanie

This is very strange. The clean install on siteground doesn't have the sessions file that I see.. although I did find it when I installed a downloaded zip of the forum on my local computer..

Advertisement: