News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

need bridge?

Started by Ataraxicstorm, September 22, 2009, 06:02:08 AM

Previous topic - Next topic

Ataraxicstorm

Just wondering if someone could highlight the steps needed to do the following...

I have a cms setup for my own website with member details.

When a member logs in, I need to pass the username and unencrypted password ( different encryption ) to smf, check if the member is in the smf database, then either create them or log them in.

Also create them in smf when register on my site.

Its a site ive coded myself so none of the bridges out there would work, need to do one myself somehow.

[edit]

Update, after reading around I decided it would be easier to use sha1 on my site aswell... so ive switched it over ( probably annoying all the members who now have to reset their passwords lol ). The smf_members is now synced with my members, on registration reset passwords and change passwords. So now all I have to do is have it login and out of smf in the background. How would I do that?

Ataraxicstorm

#1
ok im still stuck...

I have the user id, password and salt grabbed from the smf database

try using
require_once('../forum/Sources/Subs-Auth.php');
setLoginCookie(8000000, $id, sha1($pass.$salt));


And it just says " Hacking Attempt "

What am I doing wrong?

Ataraxicstorm

90% there...

I have the code
if(isset($_REQUEST['action']))
              {
              if($_REQUEST['action']=='externallogin')
                {
                // make the login happen:
                echo custom_integrate_verify_user();
                // now make the login actually show up!
                echo '<script>document.location.href="'.$url.'";</script>';
                }
              }


in index.php

This works but you have to goto action=externallogin

How can I get it to check if member is logged in, and log them in if they arnt, no matter what page they are on

Ataraxicstorm

#3
maybe not the best way, but I figured it out :P

For the sake of others tearing their hair out trying to do this, heres my code ( for SMF 1.1.10 )

Bear in mind that both smf and my database members are synced at registration, change or reset password... this is required to make this work.

For example, in the registration process I insert the new member into the smf database with this code
( $name is username, $pass is unencrypted password, $id is the userid in my database, just to make sure the smf user id matches )

$salt = rand(10000,99999);
$pass1 = sha1(strtolower($name) . $pass);
mysql_query("INSERT INTO smf_members
(ID_Member, memberName, passwd, emailAddress, realName, passwordSalt)
VALUES('$id','$name', '$pass1','$email','$name','$salt' ) ")
or die(mysql_error());


I also changed the smf database so there are default values for ID_GROUP... so no need to include that in the above code

in verifylogin.php ( root of forum)

<?php

function custom_integrate_verify_user() {

// ** grab username from main site here, store as $username **

// get password 
   
$result mysql_query("SELECT passwd FROM smf_members WHERE memberName = '$username' LIMIT 1")
or die(
mysql_error());
$saltarray mysql_fetch_array($result);
$smflogin[1] = $saltarray['passwd'];

// get password salt
   
$result mysql_query("SELECT passwordSalt FROM smf_members WHERE memberName = '$username' LIMIT 1")
or die(
mysql_error());
$saltarray mysql_fetch_array($result);
$smflogin[2] = $saltarray['passwordSalt'];

// get password salt
   
$result mysql_query("SELECT ID_MEMBER FROM smf_members WHERE memberName = '$username' LIMIT 1")
or die(
mysql_error());
$saltarray mysql_fetch_array($result);
$smflogin[3] = $saltarray['ID_MEMBER'];
   if(
$username)
                  {
  require_once(
'../forum/Sources/Subs-Auth.php');  // ** change url **
  
setLoginCookie(8000000$smflogin[3], sha1($smflogin[1].$smflogin[2]));
}



}
?>


Then in index.php I added
require_once('verifylogin.php');
after
// Load the settings...
require_once(dirname(__FILE__) . '/Settings.php');


And then added
if(isset($_REQUEST['action']))
              {
              if($_REQUEST['action']=='externallogin')
                {
                // make the login happen:
                echo custom_integrate_verify_user();
                // now make the login actually show up!
                echo '<script>document.location.href="** URL TO FORUM **";</script>';
                }
              }


after
// What function shall we execute? (done like this for memory's sake.)
call_user_func(smf_main());


Thats enough if you send a user to action=externallogin but to do it anyway I added
// ** grab username from main site here, store as $username **
if ($context['user']['is_guest'] && $username!="") {

                echo '<script>document.location.href="?action=externallogin";</script>';
               
              }


in index.template

That last part redirects them to ?action=externallogin if they are logged into my site but not the forum

Most of this code is borrowed from http://www.simplemachines.org/community/index.php?topic=311025.120

Brummern

I need bridge to
Sombody who can help me with a bridge to websitebaker 2.8. Iam using Simple machine 1.1.10
Please one good forum and one good cms tool should be in one
PLEASE help me

:) :) :)

Advertisement: