Wikka with Simple Machines Forum

This modification is now in testing and development. I'm a novice coder so all help appreciated!

This mod uses the SMF API (smf_api.php) available from SMF which is a tool to facilitate clean integration of SMF into other scripts.

  1. Replace the Wikka registration/login system with a bridge to the SMF forum membership system.
  2. Allow registered and logged-in SMF forum users to edit pages in Wikka
  3. Automatically camel-case SMF usernames for use in Wikka

Here's the basics of how it works:

Is user logged in to SMF?
Yes >
Does WikkaUsername exist?
No > User is a guest and can register for the wiki using the registration code (requires registration code mod)
Yes > User logged in to wiki automatically
No >
User is a guest and can't register to edit the Wiki until they are logged in to SMF.

Note: the WikkaUsername is created automatically by taking the SMF username, changing the first letter to uppercase and prefixing with "Wikka", thus making it CamelCase and WikiName friendly.

I also added a new ACL "smf registered users" for which I used the symbol "^". This checks that the user is logged in to SMF but doesn't check whether they have a Wikka account.

TonZijlstra has also created a bridge between Wikka and SMF which works the other way around - i.e. people login to Wikka and this automatically logs them into SMF, see below. (For ease of reading this page I wonder whether these two mods should be seperated onto different pages, as they do slightly different things too).


We could work the other way around as well:
  1. Replace the SMF registration page with a bridge from wikka registration page
  2. Allow registered and logged-in wikka users to use the forum (and none else)

I use a wikkasite where I want to include a SMF forum. So I'd like SMF to use the usernames and pw's from Wikka, and have Wikka log them into the forum when they log into the wiki. (same goes for editing rights in Wordpress weblog admintool)

Possible ways of achieving this:
  1. the two routes as stated above
  2. have Wikka set a cookie for SMF as well, as both rely on cookies for determining logged-in status.

I've hacked together an extremely crude attempt of making the Wikka Login procedure run through SMF.
I am using it in a platform that is a combination of Wikka, SMF and two Wordpress blogs one of which is only accessible for logged on users. The user tables of these 4 modules already contain the same list of users and pw's. As no-one can register on the platform freely, the number of users is limited to around 20, and only the admin creates accounts it is easy to maintain those tables.

Also the only reason I go through the forum here is because setting the cookies for the forum from the wiki was to tedious and it was easier the other way around. I only wanted to give the users the impression of single sign on.

Next step is deleting all cookies that were set on log-out which is easily done from within wikka itself. Changing passwords is another matter, but as I said, in my case not a big problem, given the closed user group of only a few individuals.

I have altered the login script of SMF Loginout.php after where it says

// Bam!  Cookie set.  A session too, just incase.
	setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['ID_MEMBER'], $md5_passwrd);

by adding
// setting cookies for both blogs as well for editing rights and the wiki
// first some variables
$cookiepathwp1= preg_replace('|https?://[^/]+|i', '', $homewp1 . '/' );
$cookiepathwp2= preg_replace('|https?://[^/]+|i', '', $homewp2 . '/' );
$cookiehashwp1 = md5($siteurlwp1);
$cookiehashwp2 = md5($siteurlwp2);

// setting the cookies for two wordpress blogs
setcookie('wordpressuser_'. $cookiehashwp1, $usernamewp, time() + 31536000, $cookiepathwp1);
setcookie('wordpresspass_'. $cookiehashwp1, $passwordwp, time() + 31536000, $cookiepathwp1);
setcookie('wordpressuser_'. $cookiehashwp2, $usernamewp, time() + 31536000, $cookiepathwp2);
setcookie('wordpresspass_'. $cookiehashwp2, $passwordwp, time() + 31536000, $cookiepathwp2);

//variables for the wiki-cookies
$wikipass= md5($_REQUEST['passwrd']);
// setting wikicookies
setcookie($name1, $wikiname, time() + 90 * 24 * 60 * 60, "/");
setcookie($name2, $wikipass, time() + 90 * 24 * 60 * 60, "/");

And a bit further down in the same file I added:

// redirect to wiki if that is where you came from
if (isset($_REQUEST[refer])) 
	   redirectexit('http://yourdomain.com/yourwikipage', false);

before where it says

// Just log you back out if it's in maintenance mode and you AREN'T an admin.

Next I altered usersettings.php in the Wikka actions:


// check password
			if ($existingUser["password"] == md5($_POST["password"]))


// check password
			if ($existingUser["password"] == md5($_POST["password"]))
							 // lets go through the forum
							  $forumurl = "http://yourdomain.com/forum/index.php?action=login2&user=".$_POST['name']."&passwrd=".$_POST['password']."&refer=wiki ";


There are 6 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki