News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

SMF and MediaWiki Bridge

Started by rsw686, February 08, 2008, 08:28:51 PM

Previous topic - Next topic

Biology Forums

Check out mine, it works perfectly fine and synchronizes with the username and logins.

http://biology-forums.com/definitions/index.php?title=Biology_Dictionary

Danoth

OK SO!!
After spending about an hour on this looking through various fixes and whatnot, I've got this working fully and seemingly perfectly.

Versions
SMF - 2.0.1
MediaWiki - 1.16.5 (From MediaWiki Download Archive)
This Mod - Fresh download of original from first post

All you need to do is the following:

Find
function AutoAuthenticateSMF(&$user) {

Replace with
function AutoAuthenticateSMF($user) {  (Removes the &)

Find

if (isset($_COOKIE[$smf_settings['cookiename']]))
{
$_COOKIE[$smf_settings['cookiename']] = stripslashes($_COOKIE[$smf_settings['cookiename']]);

// Fix a security hole in PHP 4.3.9 and below...
if (preg_match('~^a:[34]:\{i:0;(i:\d{1,6}|s:[1-8]:"\d{1,8}");i:1;s:(0|40):"([a-fA-F0-9]{40})?";i:2;[id]:\d{1,14};(i:3;i:\d;)?\}$~', $_COOKIE[$smf_settings['cookiename']]) == 1)
{
list ($ID_MEMBER, $password) = @unserialize($_COOKIE[$smf_settings['cookiename']]);
$ID_MEMBER = !empty($ID_MEMBER) && strlen($password) > 0 ? (int) $ID_MEMBER : 0;
}
}


After this, add


else {
// Remove cookies and session
$_COOKIE = array();

if (session_id() != '') {
session_destroy();
}
}


Find


function UserLogoutSMF(&$user) {
smf_sessionSetup();
smf_redirectWrapper('logout_url', 'logout;sesc=' . $_SESSION['rand_code']);


Replace with


function UserLogoutSMF(&$user) {
smf_sessionSetup();
smf_redirectWrapper('logout_url', "logout;{$_SESSION['session_var']}={$_SESSION['session_value']}");


Find


$wgHooks['AutoAuthenticate'][] = 'AutoAuthenticateSMF';


Replace with

$wgHooks['UserLoadFromSession'][] = 'AutoAuthenticateSMF';


And all seems to be working well. I've attatched the modded file for anyone that wants to use it, but I'm no coder, so if this doesnt work for you, sorry I can't help. I'm just posting what worked for me :)

Cheers guys for the help :D

Paracelsus

Quote from: poveyjo on December 03, 2011, 06:20:15 PM
Thanks Shuban...

Ok, I thought so.

Although now I've tried it with a brand new forum installation (1.15) on the same domain, and I get the same problem.
That is, the MW links point to SMF logon, but it doesn't log the user into the wiki also...

I'm using MW1.17 (with semantic mediawiki) and SMF 1.15.

Does anyone have this working with MW 1.17?

I have a test wiki working with SMF 1.1.15... MW 1.18. ;)

You'll have to change line 308 on SMF_Auth from:
$user->setupSession();

to:
wfsetupSession();

... and many extensions will no longer work (if you're updating the wiki).

Paracelsus

For anyone interested...

To fix the problem with characters like á à ã ç and similar, using UTF8, you can do this:

In SMF_Auth.php add:
mysql_query("SET NAMES utf8");
mysql_query("SET CHARACTER_SET utf8");


After the connection to SMF.


Meaning that these lines of code:
/**
* Connect to the database. Use the settings from smf.
*
* {@source}
* @return resource
*/
function connect()
{
global $smf_settings;

// Connect to database.
$this->conn = @mysql_connect($smf_settings['db_server'], $smf_settings['db_user'],
$smf_settings['db_passwd'], true);

// Check if we are connected to the database.
if (!$this->conn)
{
$this->mysqlerror("There was a problem when connecting to the SMF database.<br />\n" .
'Check your host, username, and password settings.');
}

// Select database: this assumes the wiki and smf are in the same database.
$db_selected = @mysql_select_db($smf_settings['db_name'], $this->conn);

// Check if we were able to select the database.
if (!$db_selected)
{
$this->mysqlerror("There was a problem when connecting to the SMF database.<br />\n" .
'The database ' . $smf_settings['db_name'] . ' was not found.');
}
}


Turn out to be like this:
/**
* Connect to the database. Use the settings from smf.
*
* {@source}
* @return resource
*/
function connect()
{
global $smf_settings;

// Connect to database.
$this->conn = @mysql_connect($smf_settings['db_server'], $smf_settings['db_user'],
$smf_settings['db_passwd'], true);

// Check if we are connected to the database.
if (!$this->conn)
{
$this->mysqlerror("There was a problem when connecting to the SMF database.<br />\n" .
'Check your host, username, and password settings.');
}

// Select database: this assumes the wiki and smf are in the same database.
$db_selected = @mysql_select_db($smf_settings['db_name'], $this->conn);

// Check if we were able to select the database.
if (!$db_selected)
{
$this->mysqlerror("There was a problem when connecting to the SMF database.<br />\n" .
'The database ' . $smf_settings['db_name'] . ' was not found.');
}

// Fix for weird characters in usernames
mysql_query("SET NAMES utf8");
mysql_query("SET CHARACTER_SET utf8");
// End

}


It worked for me. ;)

Eliana Tamerin

If nobody has seen it yet, the SMF Team has released their modified version of the SMF-MediaWiki bridge here: http://www.simplemachines.org/community/index.php?topic=461612.0

It's been updated to work flawlessly with SMF 2.0.1 and brings performance increases as well as upgraded user account stability.

The file has been released on github and with a BSD license, so anyone is free to fork it and bring over any improvements they may have developed themselves.
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

Biology Forums

Quote from: Sinistercat on September 12, 2009, 03:25:18 AM
I fixed the issue. In case anyone else has this problem its a simple fix.

Find:
183: function AutoAuthenticateSMF(&$user) {

Replace with:
183: function AutoAuthenticateSMF($user) {

just remove the "&" in front of $user as well as make the nessisary 1.13 > change of "UserLoadFromSession" and it should work fine.

Thanks for the fix, had the same issue :D

Nymphic

Hi !

Is this a version 2.0.2 (or 2.0.x) are in progress ? because the bridge not work and relative path not work too whit a Auth_SMF.php for 2.0

Advertisement: