<?php
 
require_once('../forum/Settings.php');
require_once('../smf_api.php');
 
$user_info = array();
 
abstract class smfAuthentification
{
    public static function authenticate($username, $password, &$sf_user) 
    {	             
		$member_table = Doctrine::getTable('SmfMembers');
		$users = $member_table->findByDql("memberName = '$username'");
		if ($users[0])
		{
		    $user = $users[0];
		}		
 
		//checking login
		if ($user->passwd == sha1(strtolower($username) . $password) && $user->is_activated)
		{
		    foreach ($user->_data as $key => $value)
		    {
		        $user_info[$key] = $value;
		    }	
 
		    $sf_user->setAuthenticated(true);
		    $sf_user->addCredential('user');
		    if ($user->ID_GROUP == 1)
		    {
		        $sf_user->addCredential('admin');
		        $_SESSION['smf_user_is_admin'] = true;
		    }
		    $sf_user->setAttribute('smf_user', $user);
		    $_SESSION['smf_user_id'] = $user->ID_MEMBER;
 
		    smf_setLoginCookie(3600, $username, $password, false);
		    return true;
		}
		return false;
	}
	public static function log_out(&$sf_user)
	{
	    global $smf_user_info;
	    smf_setLoginCookie(-3600, $sf_user->getAttribute('smf_user')->ID_MEMBER, $sf_user->getAttribute('smf_user')->passwd);
	    $sf_user->setAttribute('smf_user', null);
	    $sf_user->clearCredentials();
	    $sf_user->setAuthenticated(false);
	    return true;
	}   
}

Exemple d'utilisation depuis symfony :

if ($this->request->getParameter('user'))
{
     //trying to login
     if (!smfAuthentification::authenticate($this->request->getParameter('user'), $this->request->getParameter('passwrd'), $this->getUSer()))
     {
         $this->error = 'identifiants incorrects';
     }
 }
 if ($this->request->getParameter('disconnect'))
 {
     smfAuthentification::log_out($this->getUser());
 }

Le fichier SFM API est disponible ici : http://www.simplemachines.org/download/?tools