simple login with smf_api.php

Started by peeeeeter, February 05, 2007, 05:48:46 AM

Previous topic - Next topic

peeeeeter

I'm struggling to auto login a user to SMF when they login to my custom system.

After I had a conflict name with a function used in SSI.php, I switched to using smf_api.php.

I had issues with the smf_setLoginCookie, which I believe is because it creates the password part of the serialized cookie without using the password salt.

I was able to write the correct cookie manually, but have now found that I need to set session data as well.

So, maybe I am missing something, but I would LOVE an example of how to login in a user with raw data using smf_api.php.

Here's the code I have been testing with (c3ef06c27831d60a3de94c4f74861665e72348cf is the password from the database, 3ed1 is the password salt:
<? include_once("smf_api.php");
               $value = serialize(array('26',  sha1('c3ef06c27831d60a3de94c4f74861665e72348cf' . '3ed1'), time()+3600,'0'));
               setcookie("SMFCookie566", $value, time()+3600, '/');
               smf_authenticateUser();
               smf_loadSession();
               smf_logOnline();
               $cookie_array = @unserialize(stripslashes($_COOKIE[$smf_settings['cookiename']]));
               // $cookie_array = @unserialize(stripslashes($value));
               print_r($cookie_array);
               print_r($_SESSION);
?>

Here's the output, after I delete all cookies and run the above script:
Array
(
   
  • => 26
        [1] => 2f4bf15461f694f54742db2710e7dc1c7ca9ca9a
        [2] => 1170676078
        [3] => 0
    )
    Array
    (
        [rand_code] => 44c60ede23da3e075f90234b9849aabe
        [ban] => Array
            (
                [last_checked] => 1170672482
                [ID_MEMBER] => 0
                [ip] => 71.208.22.221
                [ip2] => 71.208.22.221
                [email] =>
            )

        [log_time] => 1170672478
        [timeOnlineUpdated] => 1170672220
        [old_url] => hxxp:mydomain.com/support/forums/ [nonactive]
        [USER_AGENT] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1
    )

    Again, this duplicates the cookie that is set when logging in normally, but I believe it's not logging in as I need to set session data as well.

    I'd love a simple example of a manual data login using smf_api.php, or any hints or ideas on how to accomplish what I need.

    Thanks,

    Peter Janett

vbgamer45

SMF API has not been updated to SMF 1.1.1  I would look into either intergration or ssi
Community Suite for SMF - Grow your forum with SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com - Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Ensiferous

There was a beta release of the smf_api file, do a search for it, you'll need to fix a few bugs in it though.
My Latest Blog Post: Debugging Nginx Errors

vb


Advertisement: