Customizing SMF > Portals, Bridges, and Integrations

New tools to help integrating SMF with something else

<< < (17/31) > >>

kristen_tg:
Thank you for the quick reply, Andre. I haven't had a chance to look at $cookiename yet (been squeezing the forum into my existing template)

I do have another question though  ::)

SMF and my app are nicely sharing the same session. However, when I go to the forum itself, the session data my application requires disappears from the session. Backing out of the forums restores the 2 bits of data. Any ideas on what method or function is causing those two bits of data to be unset? There's a whole host of data I need to grab from my application to properly populate the template. The board is in fact loading the proper include file that handles this, but for some reason just those 2 pieces of information are getting dumped out of the session.

Nevermind. Got it all working beautifully. Thank you so much for the API.

stefann:
Thanks for the API Andre, it's made my integration a whole lot less painful than expected!


However, as I am using SMF as only part of a two tier authentication system, I would like to be able to have my external integration call SMF's password reset functionality directly -- what's the best way to achieve this?


Thanks

Andre N:
Hi,
You can see how SMF is doing it in Sources/Reminder.php around line 245 (assuming 2.0)

--- Code: ---// Randomly generate a new password, with only alpha numeric characters that is a max length of 10 chars.
require_once($sourcedir . '/Subs-Members.php');
$password = generateValidationCode();

require_once($sourcedir . '/Subs-Post.php');
$replacements = array(
'REALNAME' => $row['real_name'],
'REMINDLINK' => $scripturl . '?action=reminder;sa=setpassword;u=' . $row['id_member'] . ';code=' . $password,
'IP' => $user_info['ip'],
'MEMBERNAME' => $row['member_name'],
'OPENID' => $row['openid_uri'],
);

$emaildata = loadEmailTemplate('forgot_' . $context['account_type'], $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']);
$context['description'] = $txt['reminder_' . (!empty($row['openid_uri']) ? 'openid_' : '') . 'sent'];

// If they were using OpenID simply email them their OpenID identity.
sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, null, false, 0);
if (empty($row['openid_uri']))
// Set the password in the database.
updateMemberData($row['id_member'], array('validation_code' => substr(md5($password), 0, 10)));

--- End code ---

I'd try it like that, setting all the variables first

Ardenstone:
Thanks for posting this!  I'm new to SMF and so been giving smf_2_integration_hooks.php a shot; seems like it will save a lot of steps.

What I'd like to do is that, when a user first signs up for the forum, write their username to a custom table in the same database.  The following code works fine (it writes the username to the database or throws the error if the username already exists) except that on a successful write to my table, the user just gets a blank screen and is sitting at index.php?action=register2.  Do I need to return a specific value out of this function or something?  Since it stops at this step the user obviously never gets entered into SMF itself which is doubly problematic. :)

Also: has the username been cleansed at this point or is it still the raw username that the user set?  I'm hoping SMF has already taken care of the security aspects, but if not I need to add that here, too.


--- Code: ---function smf_register_function($regOptions, $theme_vars)
{
global $smcFunc;
$dc = 'tnt_';
$query = "SELECT userID from $dc" . "USERS WHERE UPPER(userName) = UPPER('" . $regOptions['username'] . "')";
$result = $smcFunc['db_query']('',"$query");
$row = $smcFunc['db_fetch_assoc']($result);
if (isset($row['userID'])) {
exit("Username is already taken.");
}
$query = "INSERT INTO $dc" . "USERS (userID, userName) SELECT MAX(userID) + 1, '" . $regOptions['username'] . "' FROM $dc" . "USERS";
$result = $smcFunc['db_query']('',"$query");
$smcFunc['db_free_result']($result);

exit();
}

--- End code ---

Thank you,
   Chris

Andre N:
Hi Chris,

It looks like you get a blank screen because of the exit() function. Try removing the second one.
The script will be called just before the data is inserted into the database so it should be cleaned up. You can check this in /Sources/Register.php  in the Register2() function around line 511, which is the point the integration hook is called

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version