PDA

View Full Version : Integrate or bridge with MediaWiki


HolisticEarth
14 Apr 2006, 05:29
Do you want to use vBulletin's user database with your MediaWiki? You might like this.

I have taken Kai Backman (http://www.vbulletin.org/forum/member.php?u=81733)'s MediaWiki (http://www.vbulletin.org/forum/showpost.php?p=749311&postcount=10) authentication plugin idea, fixed coding errors, and expanded greatly on it.

Working on:
vBulletin 3.5.4 and MediaWiki 1.6.3

Features:

Allows you to run MediaWiki with your vBulletin user database
Disallows users with invalid username characters
Disallows users who are not part of specified usergroups
Sets users to sysop status in MediaWiki if they are part of a specified admin usergroup
Removes users from sysop status in MediaWiki if they no longer are a part of a specified admin usergroup
For same-database setups, allows easy installation


Possible Future Features:
These are possible features for inclusion in the how-to in the future. They have not been investigated for their feasibility, but are here to let you know they have been requested and I am thinking about them. If you know how to add the features, please let us know.

No-login required (automatic) integration
Option: User profile field points to, or has option to link to vBulletin profile
To register, link the user to vBulletin's registration script on the login pages


How to:

Install Reynaldovb (http://www.vbulletin.org/forum/member.php?u=71852)'s Restrict usernames to alphanumeric and underscore (http://www.vbulletin.org/forum/showthread.php?t=106877) plugin, and disallow both spaces and underscores
Optional: On boards that already have existing users, somehow have their usernames changed so that they are only alphanumeric. This is required if you wish your users to be able to login and edit the wiki using their vBulletin username. The reason you have to do this is because MediaWiki has some Restrictions (http://meta.wikimedia.org/wiki/Help:Page_name#Restrictions) on what can go in a page title, and as usernames have to be passed as page titles, they also have to adhere to the same restrictions. If you do not change the usernames, I have included a check to not allow users to login if their username contains non-alphanumeric characters.
Open your wiki/LocalSettings.php file
Insert the following code at the end of the file, before the ?>:
# vBulletin integration script
require_once("AuthPlugin_vBulletin.php");
// if vBulletin and MediaWiki are not installed on the same database
// change these values to reflect your vBulletin database information
$wgAuth = new AuthPlugin_vBulletin($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, "vb_");
If you are running vBulletin and MediaWiki in the same database, then it already uses the connection information.
If you are not running vBulletin and MediaWiki in the same database, please change the strings to reflect your vBulletin database information.
In either case, the last value is whatever your vBulletin table prefix is.
Insert this code below the require_once( "includes/DefaultSettings.php" ); at the top of the LocalSettings.php file:
# Disabling new user registrations
$wgWhitelistAccount = array ( "sysop" => 1, "developer" => 1 );
# Disabling anonymous edits
$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['read'] = false;
$wgGroupPermissions['*']['edit'] = false;
$wgWhitelistRead = array ("Special:Userlogin");
This prevents people from registering new accounts on the wiki, requiring people to register on vBulletin. It also prevents anonymous edits. This code may only work on MediaWiki 1.5.x and above, but I am unsure.
Download the AuthPlugin_vBulletin.php file and put it in your main wiki directory, ie: /wiki/AuthPlugin_vBulletin.php


Please let me know if this was helpful, or if you can expand on this code.

pipin
14 Apr 2006, 09:00
Thanx HolisticEarth,

maybe you should add $wgCapitalLinks = false; too, so the usernames will be exactly the same and not changed at the first letter.

machtzu
15 Apr 2006, 00:21
Probably one of the best little snippets of code here! Well done HolisticEarth, its awesome! :banana:

Jon_Simmonds
16 Apr 2006, 14:22
Ive been using the original method for a while, ill take a look at the code and see if I can merge it in to mine(done so many edits since then, which ive not made notes on..)

Also if you like to use subdomains on yoru sites, ill find the code so you can have something like http://wiki.site.com/PAGETITLE (eg http://wiki.exceem.co.uk/Help:Contents)

HolisticEarth
16 Apr 2006, 16:18
Ive been using the original method for a while, ill take a look at the code and see if I can merge it in to mine(done so many edits since then, which ive not made notes on..)

Also if you like to use subdomains on yoru sites, ill find the code so you can have something like http://wiki.site.com/PAGETITLE (eg http://wiki.exceem.co.uk/Help:Contents)
The article on making a really short url for MediaWiki is here:
http://meta.wikimedia.org/wiki/Using_a_very_short_URL

However I am not a hardcore techie to konw which (if any) of the methods listed are foolproof. I have heard now and again that some of those methods do not work perfectly, as in they will not display URLs that contain periods properly.

Also, the script I came up should work great with the other script... the only difference is the extra function call in your LocalSettings.php file for your vB table prefix. If you simply add that information to the LocalSettings.php, then all you need to do is replace the original file with my file and you will be good to go, no worse than before, but have more functionality.

rockaffe
17 Apr 2006, 09:30
I've followed the instructions but it don't work...
When i open my wiki page it remain to an error page.

http://tutorialweb.org/wiki/

here is the link.

Bye!

HolisticEarth
17 Apr 2006, 14:45
I've followed the instructions but it don't work...
When i open my wiki page it remain to an error page.

http://tutorialweb.org/wiki/
Did you try logging in using your vb information?

You might want to try changing
$wgGroupPermissions['*']['read'] = false;
to
$wgGroupPermissions['*']['read'] = true;
if you want anonymous users to be able to read the wiki.

rockaffe
17 Apr 2006, 16:13
I'll be happy if I can use my info to login but in the wiki page no login box appear, and if I click on "login" it remain on the same page.

However when I visit that page, I'm already logged in on my vbulletin.

HolisticEarth
18 Apr 2006, 03:09
I'll be happy if I can use my info to login but in the wiki page no login box appear, and if I click on "login" it remain on the same page.

However when I visit that page, I'm already logged in on my vbulletin.
I can't provide technical support for it. You dont have to login to the forums, you just have to have an account there. Then you have to login with that same information on the wiki, and your login information must have only alpha-numeric characters.

Zachery
18 Apr 2006, 03:18
Intresting, say I already have a wiki setup and working, how will this work then?

HolisticEarth
18 Apr 2006, 13:36
Intresting, say I already have a wiki setup and working, how will this work then?
It wont erase anything from the database. It is like other plugins - you just install it and it starts using the vb database for login info. There might be conflicts if users have the same info but different passwords, or if another user has a different username that exists for someone else, but I dont know ... i started this from a fresh wiki. A sure way to fix it would be to erase all the users but wikisysop and start with a fresh users db.

Brent H
20 Apr 2006, 01:26
Thanks for this, installed and working.

TheFinney
24 Apr 2006, 23:42
Hi, I'm not that great at PHP. For the changing of the values, do I replace everything after the $, or after the $wgDBserver, or something else?

Thanks!

Cyburbia
26 Apr 2006, 23:23
Thanks for making this!

I'd use it if it weren't for the "no alphanumeric characters" restriction. It would be terrific id there was a way around it.

HolisticEarth
27 Apr 2006, 13:45
Thanks for making this!

I'd use it if it weren't for the "no alphanumeric characters" restriction. It would be terrific id there was a way around it.
Yeah, I have a forum with a moderate amount of people (~3000), and there are many non-alphanumeric characters as well.

I like your website btw, I found a bit of information on it for a paper or two I have done at University.

Hi, I'm not that great at PHP. For the changing of the values, do I replace everything after the $, or after the $wgDBserver, or something else?

Thanks!
For the values, and php in general, $something is a variable, and if it is a string, you can thing of it as "somevalue". So if you were to hard-code something like the server name, you would replace $servername with "servername".

ndahiya
06 May 2006, 15:25
# Rehash of sammyman's and my posts in the old thread::


You might get the following error (looks like only with PHP 4.3.11):
Fatal error: Call to a member function on a non-object in /home/user/public_html/manuals/includes/SpecialUserlogin.php on line 314

Workaround: In includes/SpecialUserlogin.php, find:
$u =& $this->initUser( $u );
Replace this to this:
$u = $this->initUser( $u );



Excessive Database Pings


Open your wiki/LocalSettings.php file
Insert the following code at the end of the file, before the ?>:
# vBulletin integration script
require_once("AuthPlugin_vBulletin.php");
// if vBulletin and MediaWiki are not installed on the same database
// change these values to reflect your vBulletin database information
$wgAuth = new AuthPlugin_vBulletin($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, "vb_");
If you are running vBulletin and MediaWiki in the same database, then it already uses the connection information.
If you are not running vBulletin and MediaWiki in the same database, please change the strings to reflect your vBulletin database information.
In either case, the last value is whatever your vBulletin table prefix is.

This works perfectly fine, but for one problem.... Inserting the code in LocalSettings.php creates a "session" to mysql every time someone accesses *any* page in the wiki... (you can see this by putting in the wrong password). On my server, this caused too many sessions being created in mysql, and resulted in the intermittent access problems (as the db was unavailable)!!


The way around this is (Thogh a less elegant solution, and one you have to reapply every time your upgrade mediawiki) to insert the same code near the begining of "includes/User.php"

This takes care of the excess pinging problem, as the vb database is accessed only when a user tries to login.

BizzehDee
22 May 2006, 00:33
hey,
i used this to try to integrate my mediawiki 1.6.x install with my vb3.5.x install. i did exactly, and only, what the tutorial said... none of the users on the board are able to use their login that they registered with vbulletin, on mediawiki.. is there something im missing?

Da Drgon
23 May 2006, 04:29
I'm getting the same problem... running MW 1.6.5 and vb 3.5.4 here.... I followed the instructions but instead of denying anonymous read access, I left it enabled... I also inserted the $wgAuth code in includes/user.php instead of localsettings.php after reading ndahiya's post

I'm getting this error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/xxxxxx/public_html/wiki/AuthPlugin_vBulletin.php on line 90

FYI, my site is run off a shared host, so all my database name starts with my host login name then an underscore then the actual database name (ie: joeuser_wiki)

does this have something to do with MW not being able to access the vb_ tables? if so how do I specify directly where to find the tables in the code snippet? or is it just more coding errors?

thisgeek
30 May 2006, 19:40
I'm getting the same problem... running MW 1.6.5 and vb 3.5.4 here.... I followed the instructions but instead of denying anonymous read access, I left it enabled... I also inserted the $wgAuth code in includes/user.php instead of localsettings.php after reading ndahiya's post

I'm getting this error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/xxxxxx/public_html/wiki/AuthPlugin_vBulletin.php on line 90


I'm getting the same issue with MW 1.6.6 and vb 3.5.4. I also inserted the code in includes/User.php. It doesn't work even if I do it as originally directed.

I'm running PHP 5 and MySQL 5.

EDIT: I'm a complete tosser. I just realised I had the database connection info completely wrong. *sigh* That's what you get for trying to do stuff like this when you're tired.

So..... It's working :)

Da Drgon
05 Jun 2006, 10:16
thanks for replying and getting me to rethink of what I've exactly done.... so I'm an idiot and I also had the connection info wrong.... it's working now on MW 1.6.6!

sub_ubi
06 Jun 2006, 20:10
HolisticEarth,

To overcome the username issue, did you look in to the possibility of

Making any links to a user's page link to their user page on vBulletin. Theoretically, this would allow people to keep their usernames intact, while not interfering with the MediaWiki namespace.

from

http://meta.wikimedia.org/wiki/VBulletin/Users_Integration

If so, what did you think about it?

Cyburbia
11 Jun 2006, 05:25
I'm going to bump and ask the same thing.

HolisticEarth
13 Jun 2006, 03:33
Here I thought summer would come and I would have time to fiddle with things :/.

I have not tried it atm ... has anyone else tried merging the two more fully to use the vB sessions instead?

yessir
25 Jun 2006, 16:30
I'm not much of a coder but I can certainly test over the summer.

My forum is located in the web root, and I want to also toss my wiki into the web root. Does anyone see a problem with this?

Ideally the wiki is the landing page at www.mydomain. com. Or would I be better off dropping the wiki into a /wiki directory, or moving the forums (urgh) to /forum?

Also, has anyone tried this with vBSEO installed? Any potential .htaccess hacks required?

Thanks in advance.

offline
28 Jun 2006, 02:45
I installed this but none of my users can login. Is there a log file or something telling me why this might not be working?

Thanks!

thumbsucker
30 Jun 2006, 14:50
This is off topic but I tried to install Wiki and got this error.

Anyone know what's wrong?

include all of the lines below when reporting installation problems.

PHP 4.3.11 installed
PHP server API is apache2handler; ok, using pretty URLs (index.php/Page_Title)
Have XML / Latin1-UTF-8 conversion support.
PHP's memory_limit is 32M. If this is too low, installation may fail!
Have zlib support; enabling output compression.
Neither Turck MMCache nor eAccelerator are installed, can't use object caching functions
GNU diff3 not found.
Found GD graphics library built-in, image thumbnailing will be enabled if you enable uploads.
Installation directory: /var/www/vhosts/mysite/httpdocs/mediawiki
Script URI path: /mediawiki
Environment checked. You can install MediaWiki.
Warning: $wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.
Generating configuration file...

Database type: mysql
Parse error: parse error, unexpected $, expecting '}' in /var/www/vhosts/mysite/httpdocs/mediawiki/includes/Database.php on line 459

mickmel
02 Jul 2006, 13:15
Will this work with vB 3.6.x and MW 1.6.7?

Deimos
05 Jul 2006, 12:43
I'm getting the same problem

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/xxx/public_html/wiki/AuthPlugin_vBulletin.php on line 90

I've double checked the login details for the database, all are ok

thumbsucker
06 Jul 2006, 01:38
Is support for this alive?

I filled in my DB info in the mediawiki config file but no one from vbulletincan login.

HolisticEarth
06 Jul 2006, 06:44
I don't want to sound negative, but I dont have the time to support this ... it was a How-To because I dont have the time to make it a perfect add-on / hack / etc., and the old How-To was non-existant.

For vB 3.5.4 and MW 1.6.7, and my original installation method, my installation still works logging in and logging out. I'll try putting it in user.php instead of LocalSettings.php tomorrow and let you know how it works out...

jeffj
07 Jul 2006, 16:57
has anyone tried to get mediawiki running inside of menu driven framework?

I had a masthead and menu bar (javascript) and a left nav bar with serves up banner ads and I want to maintain this look and feel to my site and add a wiki, but I am pulling my hair out trying to get this code into monobook.php

have anyone done this?

yessir
27 Jul 2006, 14:10
Thanks Holisitic Earth. You've given us a starting point!

Anyone care to comment on Mediawiki and vBull in the same directory?

Renmiri
06 Aug 2006, 01:04
Wow, you are an angel!!!

I had the user databases integrated with phpBB and now that I moved to vB the Wiki does not allow any new user :(

Thanks, this will help a lot!!!

:)

ElfMage
07 Aug 2006, 08:07
Hello everybody, I too have been looking for a way to integrate MediaWiki with vBulletin.

However, in my case, I decided to write my own plugin, as I had certain requirements that were not met by existing solutions.

Anyways, if you would like to give my extension a try go here: http://www.luxurywiki.com/wiki/Luxury_vBulletin

ElfMage.

yessir
07 Aug 2006, 12:56
ElfMage, when your plugin has a little more development behind it, I will test for sure. It looks very, very promising. Thanks!

lightwave
08 Aug 2006, 06:52
What happens if a user has username that is not alphanumeric or underscore.

Does it produce an error? Or they simply just can't log in but the others with correct username can?

ElfMage
08 Aug 2006, 07:04
What happens if a user has username that is not alphanumeric or underscore.

Does it produce an error? Or they simply just can't log in but the others with correct username can?

That's one of the current limitations. I haven't tested the scenario you describe, but it should behave as you describe.

Users with special characters will be able to login into vB, but not MediaWiki. Regular users will be logged in/out from both.

However, I think that this is fairly easy to correct. Let me give it some more thought.

ElfMage, when your plugin has a little more development behind it, I will test for sure. It looks very, very promising. Thanks!

Thanks yessir. I am developing this extension for my site, but I thought I'd share it with the community..

ElfMage.

thenetbox
13 Aug 2006, 18:40
Hi,

Does any one know if this is working with VB 3.6? Thank you

yessir
13 Aug 2006, 18:48
LuxuryWiki is being developed for 3.6

thenetbox
13 Aug 2006, 19:15
oh cool :) thank you

HolisticEarth
14 Aug 2006, 14:44
Hi,

Does any one know if this is working with VB 3.6? Thank you
I will be upgrading my vB very soon, so I will make sure it works

ElfMage
15 Aug 2006, 03:34
Initially I started on 3.5.x, but I upgraded as soon as 3.6 came out.

3.6 broke my vRewrite implementation (wiki-vB plugin doesn't need vRewrite, it can work with or without SEO), but I am sure that by now this has been discussed elsewhere, and/or a fix has been provided.

Other than that it was 100% compatible. I will provide a public build in the next couple of days.

dsl55dsl
18 Aug 2006, 21:40
I am using Wiki and vB integration and works great I was wondering if it would be possible to have the AuthPlugin_vBulletin.php to check the vB database under User Table under the 'membergroupids' for the value 29 and only at that moment to give access to Wiki.

I dont want all my vB users to have access to Wiki.

Thanks alot,

G.

ndahiya
20 Aug 2006, 15:05
in AuthPlugin_vBulletin find

// Only registered and admins. Banned and unregistered don't belong here.
if($usergroupid == "2" || $usergroupid == "5" || $usergroupid == "6" || $usergroupid == "7")


and change the if condition to include or exclude the groups you want. :)

dsl55dsl
21 Aug 2006, 14:33
Actually I dont really care about the usergroupid, What am I looking for is membergroupid that is a value of x.

ElfMage
21 Aug 2006, 15:01
Try the following changes:

First, let's change the allowed user groups to only 29.

Change the following code in the constructor:
$this->allowed_usergroups = Array(2, 5, 6, 7);
to
$this->allowed_usergroups = Array(29);

And then, change the following code in the function userExists
if (in_array($vb_userinfo['usergroupid'], $this->allowed_usergroups)) {
to the following:
$vb_usergroups = explode(",", $vb_userinfo['membergroupids']); // make an array of membergroupids
$vb_usergroups[] = $vb_userinfo['usergroupid']; // add the primary usergroup to the array
foreach ( $vb_usergroups as $vb_groupiter )
if (in_array( $vb_groupiter, $this->allowed_usergroups))
return TRUE;


This last piece of code checks the user's 'primary' group id as well as any other member group the user may belong to (membergroupids).

Notice that I haven't run this code, so it may not work, or it may have some small syntax errors ... :-)

dsl55dsl
21 Aug 2006, 15:37
I am getting the following error:

Parse error: parse error, unexpected T_RETURN, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /hsphere/local/home/mrshides/ww2.free-collective.us/wiki/AuthPlugin_vBulletin.php on line 73

this is how my AuthPlugin_vBulletin.php looks like:

<?php
/**
* Authentication plugin interface. Instantiate a subclass of AuthPlugin
* and set $wgAuth to it to authenticate against some external tool.
*
* The default behavior is not to do anything, and use the local user
* database for all authentication. A subclass can require that all
* accounts authenticate externally, or use it only as a fallback; also
* you can transparently create internal wiki accounts the first time
* someone logs in who can be authenticated externally.
*
* This interface is new, and might change a bit before 1.4.0 final is
* done...
*
* AuthPlugin extension by Daniel Gravenor c/o HolisticEarth.org
* AuthPlugin original by Kai Backman
*
* @package MediaWiki
*/
require_once("includes/AuthPlugin.php");

class AuthPlugin_vBulletin extends AuthPlugin {

// Create a persistent DB connection
var $vb_database;

function AuthPlugin_vBulletin($host, $username, $password, $dbname, $prefix) {
$this->vb_database = mysql_pconnect($host, $username, $password);
mysql_select_db($dbname, $this->vb_database);
$this->vb_prefix = $prefix;
// set the usergroups for those who can edit the wiki
$this->allowed_usergroups = Array(29);
// set the usergroups for the administrators
$this->admin_usergroups = Array(6, 9);
$this->user_rights = Array("sysop");
// search pattern to only accept alphanumeric or underscore characters in usernames
// if they have illegal characters, their name cannot exist, period
$this->searchpattern = "/[^a-zA-Z0-9]+/";
}


/**
* Check whether there exists a user account with the given name.
* The name will be normalized to MediaWiki's requirements, so
* you might need to munge it (for instance, for lowercase initial
* letters).
*
* @param string $username
* @return bool
* @access public
*/
function userExists( $username ) {
// if no illegal characters are found in their username, then check to see if they exist
if (!preg_match($this->searchpattern, $username)) {
$username = addslashes($username);
$vb_find_user_query = "SELECT usergroupid FROM " . $this->vb_prefix . "user WHERE LOWER(username)=LOWER('" . $username . "')";
$vb_find_result = mysql_query($vb_find_user_query, $this->vb_database);
// make sure that there is only one person with the username
if (mysql_num_rows($vb_find_result) == 1) {
$vb_userinfo = mysql_fetch_assoc($vb_find_result);
mysql_free_result($vb_find_result);
// Only registered and admins. Banned and unregistered don't belong here.
$vb_usergroups = explode(",", $vb_userinfo['membergroupids']); // make an array of membergroupids
$vb_usergroups[] = $vb_userinfo['usergroupid']; // add the primary usergroup to the array
foreach ( $vb_usergroups as $vb_groupiter )
if (in_array( $vb_groupiter, $this->allowed_usergroups))
return TRUE;
}
}
}
// if no one is registered with that username, or there are more than 1 entries
// or they have illegal characters return FALSE (they do not exist)
return FALSE;
}

/**
* Check if a username+password pair is a valid login.
* The name will be normalized to MediaWiki's requirements, so
* you might need to munge it (for instance, for lowercase initial
* letters).
*
* @param string $username
* @param string $password
* @return bool
* @access public
*/
function authenticate( $username, $password ) {
// if their name does not contain any illegal characters, let them try to login
if (!preg_match($this->searchpattern, $username)) {
$username = addslashes($username);
$vb_find_user_query = "SELECT password, salt, usergroupid FROM " . $this->vb_prefix . "user WHERE LOWER(username)=LOWER('" . $username . "')";
$vb_find_result = mysql_query($vb_find_user_query, $this->vb_database);
if (mysql_num_rows($vb_find_result) == 1) {
$vb_userinfo = mysql_fetch_assoc($vb_find_result);
mysql_free_result($vb_find_result);
// Only registered and admins. Banned and unregistered don't belong here.
if (in_array($vb_userinfo['usergroupid'], $this->allowed_usergroups)) {
if(md5(md5($password) . $vb_userinfo['salt']) == $vb_userinfo['password']) return true;
}
}
}
return false;
}

/**
* When a user logs in, optionally fill in preferences and such.
* For instance, you might pull the email address or real name from the
* external user database.
*
* The User object is passed by reference so it can be modified; don't
* forget the & on your function declaration.
*
* @param User $user
* @access public
*/
function updateUser( &$user ) {
# Override this and do something
$vb_find_user_query = "SELECT usergroupid, membergroupids FROM " . $this->vb_prefix . "user WHERE LOWER(username)=LOWER('" . addslashes($user->mName) . "')";
$vb_find_result = mysql_query($vb_find_user_query, $this->vb_database) or die("Could not find username");
if(mysql_num_rows($vb_find_result) == 1) {
$vb_userinfo = mysql_fetch_assoc($vb_find_result);
mysql_free_result($vb_find_result);
// go through the users member groups to see if one of them is administrative
$user_membergroups = explode(",", $vb_userinfo['membergroupids']);
$admin_secondary = FALSE;
for ($x = 0; $x < count($user_membergroups); $x++) {
if (in_array($user_membergroups[$x], $this->admin_usergroups)) $admin_secondary = TRUE;
}

if (in_array($vb_userinfo['usergroupid'], $this->admin_usergroups) || $admin_secondary === TRUE) {
// if a user is not a sysop, make them a sysop
if (!in_array("sysop", $user->getEffectiveGroups())) {
$user->addGroup('sysop');
return TRUE;
}
}
// if the user is not an administrator, but they were, and they are still a sysop, remove their sysop status
if (!in_array($vb_userinfo['usergroupid'], $this->admin_usergroups) && $admin_secondary === FALSE) {
if (in_array("sysop", $user->getEffectiveGroups())) {
$user->removeGroup('sysop');
return TRUE;
}
}
}
return FALSE;
}

/**
* Return true if the wiki should create a new local account automatically
* when asked to login a user who doesn't exist locally but does in the
* external auth database.
*
* If you don't automatically create accounts, you must still create
* accounts in some way. It's not possible to authenticate without
* a local account.
*
* This is just a question, and shouldn't perform any actions.
*
* @return bool
* @access public
*/
function autoCreate() {
return true;
}

/**
* Return true to prevent logins that don't authenticate here from being
* checked against the local database's password fields.
*
* This is just a question, and shouldn't perform any actions.
*
* @return bool
* @access public
*/
function strict() {
return true;
}

/**
* When creating a user account, optionally fill in preferences and such.
* For instance, you might pull the email address or real name from the
* external user database.
*
* The User object is passed by reference so it can be modified; don't
* forget the & on your function declaration.
*
* @param User $user
* @access public
*/
function initUser( &$user ) {
$vb_find_user_query = "SELECT email, usergroupid FROM " . $this->vb_prefix . "user WHERE LOWER(username)=LOWER('" . addslashes($user->mName) . "')";
$vb_find_result = mysql_query($vb_find_user_query, $this->vb_database);
if(mysql_num_rows($vb_find_result) == 1) {
$vb_userinfo = mysql_fetch_assoc($vb_find_result);
mysql_free_result($vb_find_result);
$user->mEmail = $vb_userinfo['email'];
$user->mEmailAuthenticated = wfTimestampNow();
}
}
}
?>


Any help would be AWESOME.

ElfMage
21 Aug 2006, 16:27
In the function userExists, I left one '{' out (or didn't tell you to remove the extra '}'.. <g>)

Change this:
if (in_array( $vb_groupiter, $this->allowed_usergroups))

To this:
if (in_array( $vb_groupiter, $this->allowed_usergroups)) {

dsl55dsl
21 Aug 2006, 16:37
I dont get an error anymore really. I get:

Login error:Incorrect password entered. Please try again

I noticed that my membergroupids are the following: 6,25,26,29,30

Could that cause a problem?

ElfMage
21 Aug 2006, 17:43
I forgot to notice that the same filter is present in the function 'authenticate'. This is why you are getting the 'wrong password' error.

Make the same change to that function, there is a similar line there.

dsl55dsl
21 Aug 2006, 17:53
Still getting the same error.

Login error:Incorrect password entered. Please try again

This is what the AuthPlugin_Vbulletin.php file looks like:

<?php
/**
* Authentication plugin interface. Instantiate a subclass of AuthPlugin
* and set $wgAuth to it to authenticate against some external tool.
*
* The default behavior is not to do anything, and use the local user
* database for all authentication. A subclass can require that all
* accounts authenticate externally, or use it only as a fallback; also
* you can transparently create internal wiki accounts the first time
* someone logs in who can be authenticated externally.
*
* This interface is new, and might change a bit before 1.4.0 final is
* done...
*
* AuthPlugin extension by Daniel Gravenor c/o HolisticEarth.org
* AuthPlugin original by Kai Backman
*
* @package MediaWiki
*/
require_once("includes/AuthPlugin.php");

class AuthPlugin_vBulletin extends AuthPlugin {

// Create a persistent DB connection
var $vb_database;

function AuthPlugin_vBulletin($host, $username, $password, $dbname, $prefix) {
$this->vb_database = mysql_pconnect($host, $username, $password);
mysql_select_db($dbname, $this->vb_database);
$this->vb_prefix = $prefix;
// set the usergroups for those who can edit the wiki
$this->allowed_usergroups = Array(29);
// set the usergroups for the administrators
$this->admin_usergroups = Array(6, 9);
$this->user_rights = Array("sysop");
// search pattern to only accept alphanumeric or underscore characters in usernames
// if they have illegal characters, their name cannot exist, period
$this->searchpattern = "/[^a-zA-Z0-9]+/";
}


/**
* Check whether there exists a user account with the given name.
* The name will be normalized to MediaWiki's requirements, so
* you might need to munge it (for instance, for lowercase initial
* letters).
*
* @param string $username
* @return bool
* @access public
*/
function userExists( $username ) {
// if no illegal characters are found in their username, then check to see if they exist
if (!preg_match($this->searchpattern, $username)) {
$username = addslashes($username);
$vb_find_user_query = "SELECT usergroupid FROM " . $this->vb_prefix . "user WHERE LOWER(username)=LOWER('" . $username . "')";
$vb_find_result = mysql_query($vb_find_user_query, $this->vb_database);
// make sure that there is only one person with the username
if (mysql_num_rows($vb_find_result) == 1) {
$vb_userinfo = mysql_fetch_assoc($vb_find_result);
mysql_free_result($vb_find_result);
// Only registered and admins. Banned and unregistered don't belong here.
$vb_usergroups = explode(",", $vb_userinfo['membergroupids']); // make an array of membergroupids
$vb_usergroups[] = $vb_userinfo['usergroupid']; // add the primary usergroup to the array
foreach ( $vb_usergroups as $vb_groupiter )
if (in_array( $vb_groupiter, $this->allowed_usergroups)) {
return TRUE;
}
}
}
// if no one is registered with that username, or there are more than 1 entries
// or they have illegal characters return FALSE (they do not exist)
return FALSE;
}

/**
* Check if a username+password pair is a valid login.
* The name will be normalized to MediaWiki's requirements, so
* you might need to munge it (for instance, for lowercase initial
* letters).
*
* @param string $username
* @param string $password
* @return bool
* @access public
*/
function authenticate( $username, $password ) {
// if their name does not contain any illegal characters, let them try to login
if (!preg_match($this->searchpattern, $username)) {
$username = addslashes($username);
$vb_find_user_query = "SELECT password, salt, usergroupid FROM " . $this->vb_prefix . "user WHERE LOWER(username)=LOWER('" . $username . "')";
$vb_find_result = mysql_query($vb_find_user_query, $this->vb_database);
if (mysql_num_rows($vb_find_result) == 1) {
$vb_userinfo = mysql_fetch_assoc($vb_find_result);
mysql_free_result($vb_find_result);
// Only registered and admins. Banned and unregistered don't belong here.
$vb_usergroups = explode(",", $vb_userinfo['membergroupids']); // make an array of membergroupids
$vb_usergroups[] = $vb_userinfo['usergroupid']; // add the primary usergroup to the array
foreach ( $vb_usergroups as $vb_groupiter )
if (in_array( $vb_groupiter, $this->allowed_usergroups)) {
return TRUE;
if(md5(md5($password) . $vb_userinfo['salt']) == $vb_userinfo['password']) return true;
}
}
}
return false;
}

/**
* When a user logs in, optionally fill in preferences and such.
* For instance, you might pull the email address or real name from the
* external user database.
*
* The User object is passed by reference so it can be modified; don't
* forget the & on your function declaration.
*
* @param User $user
* @access public
*/
function updateUser( &$user ) {
# Override this and do something
$vb_find_user_query = "SELECT usergroupid, membergroupids FROM " . $this->vb_prefix . "user WHERE LOWER(username)=LOWER('" . addslashes($user->mName) . "')";
$vb_find_result = mysql_query($vb_find_user_query, $this->vb_database) or die("Could not find username");
if(mysql_num_rows($vb_find_result) == 1) {
$vb_userinfo = mysql_fetch_assoc($vb_find_result);
mysql_free_result($vb_find_result);
// go through the users member groups to see if one of them is administrative
$user_membergroups = explode(",", $vb_userinfo['membergroupids']);
$admin_secondary = FALSE;
for ($x = 0; $x < count($user_membergroups); $x++) {
if (in_array($user_membergroups[$x], $this->admin_usergroups)) $admin_secondary = TRUE;
}

if (in_array($vb_userinfo['usergroupid'], $this->admin_usergroups) || $admin_secondary === TRUE) {
// if a user is not a sysop, make them a sysop
if (!in_array("sysop", $user->getEffectiveGroups())) {
$user->addGroup('sysop');
return TRUE;
}
}
// if the user is not an administrator, but they were, and they are still a sysop, remove their sysop status
if (!in_array($vb_userinfo['usergroupid'], $this->admin_usergroups) && $admin_secondary === FALSE) {
if (in_array("sysop", $user->getEffectiveGroups())) {
$user->removeGroup('sysop');
return TRUE;
}
}
}
return FALSE;
}

/**
* Return true if the wiki should create a new local account automatically
* when asked to login a user who doesn't exist locally but does in the
* external auth database.
*
* If you don't automatically create accounts, you must still create
* accounts in some way. It's not possible to authenticate without
* a local account.
*
* This is just a question, and shouldn't perform any actions.
*
* @return bool
* @access public
*/
function autoCreate() {
return true;
}

/**
* Return true to prevent logins that don't authenticate here from being
* checked against the local database's password fields.
*
* This is just a question, and shouldn't perform any actions.
*
* @return bool
* @access public
*/
function strict() {
return true;
}

/**
* When creating a user account, optionally fill in preferences and such.
* For instance, you might pull the email address or real name from the
* external user database.
*
* The User object is passed by reference so it can be modified; don't
* forget the & on your function declaration.
*
* @param User $user
* @access public
*/
function initUser( &$user ) {
$vb_find_user_query = "SELECT email, usergroupid FROM " . $this->vb_prefix . "user WHERE LOWER(username)=LOWER('" . addslashes($user->mName) . "')";
$vb_find_result = mysql_query($vb_find_user_query, $this->vb_database);
if(mysql_num_rows($vb_find_result) == 1) {
$vb_userinfo = mysql_fetch_assoc($vb_find_result);
mysql_free_result($vb_find_result);
$user->mEmail = $vb_userinfo['email'];
$user->mEmailAuthenticated = wfTimestampNow();
}
}
}
?>

ElfMage
22 Aug 2006, 03:40
:-) If I had dedicated some time to test the changes I was suggesting, we would have had it working by now... If this time it doesn't work, I will take the time to test it before my next post... <g>

Now, realize that this AuthPlugin_vBulletin was not written by me, and as such, the original author may not like/agree with my suggestions...

In the original code, the function authenticate checks for the allowed_usergroups. I personally think that this is not needed, since 'userExists' is always called before 'authenticate'.

Try changing the function 'authenticate' for the following code. Let me know if it doesn't work, and I will try it on my test server.


function authenticate( $username, $password ) {
// if their name does not contain any illegal characters, let them try to login
if (!preg_match($this->searchpattern, $username)) {
$username = addslashes($username);
$vb_find_user_query = "SELECT password, salt, usergroupid FROM " . $this->vb_prefix . "user WHERE LOWER(username)=LOWER('" . $username . "')";
$vb_find_result = mysql_query($vb_find_user_query, $this->vb_database);
if (mysql_num_rows($vb_find_result) == 1) {
$vb_userinfo = mysql_fetch_assoc($vb_find_result);
mysql_free_result($vb_find_result);
// check password
if(md5(md5($password) . $vb_userinfo['salt']) == $vb_userinfo['password']) return true;
}
}
return false;
}

Rowen
14 Sep 2006, 18:59
Does anyone know how this project is coming along?

vBulletin 3.6.1 is now out, last I heard, this was for 3.5.4

I would be willing to donate to help progression of this plugin.

yessir
14 Sep 2006, 19:03
The Luxury Wiki bridge is for 3.6 and Mediawiki 1.7.x

HolisticEarth
15 Sep 2006, 15:41
Does anyone know how this project is coming along?

vBulletin 3.6.1 is now out, last I heard, this was for 3.5.4

I would be willing to donate to help progression of this plugin.
The plugin is still working good in its original format, for both 1.7.x and 3.6.0:
http://holisticearth.org/wiki/

3.6.1 must have just come out ... I will give my forum an upgrade asap to make sure it still works.

Clayton
20 Oct 2006, 08:45
some nice design styling done with wiki and your forums

:up:

mfarmerhi
03 Dec 2006, 04:50
Gah...!

3.5.7 board. For security I recently changed the DB username and password... The integration is no longer working.

I'm getting "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/totalli/public_html/wiki/AuthPlugin_vBulletin.php on line 73" and "The password you entered is incorrect (or missing). Please try again" errors upon trying to log in.

Ideas?

Hensa
03 Mar 2007, 18:33
Does this solution allow users to login to MW and vBulletin on the same domain with a single login? I want MW to be separate from, rather than integrated into, vBulletin, but with a single login.

ElfMage
04 Mar 2007, 00:31
Yes, vbWiki Standard will allow you to do that.

snoopy5
13 Sep 2007, 18:16
does this work with vb 3.68 also?

blue_asterisk
17 Apr 2008, 21:41
I can confirm that I got this working on vb3.6.7 with mediawiki 1.11svn
http://www.mediawiki.org/wiki/Extension:VBulletin/Users_Integration

Mancia
15 May 2008, 22:06
Anyone got this working for vBulletin 3.7?

or any other integration between mediawiki and vB 3.7?

Elenna
16 May 2008, 20:01
Update: This seems to work well with vBulletin 3.7 and MW 1.12.

Has anyone found a way to have it automatically log the user in?

pelicanparts
20 May 2008, 10:29
It seems that the later versions of MediaWiki no longer require no spaces in the usernames? So, the restriction in this extension is no longer required (apparently). Hence, I replaced this line:

$this->searchpattern = "/[^a-zA-Z0-9]+/";

with this line:

$this->searchpattern = "/[\#\<\>\[\]\|\{\}/";

So far so good. I will be now working on some additional features, like the auto-logon from vB.

-Wayne

Smitty
21 May 2008, 07:09
Thanks, pelicanparts. I have the 'Pro' version ElfMage was selling. As far as I can tell, ElfMage has 'left the premises' so to speak. Maybe I'll be able to apply some of your information to the Pro version so your information is appreciated very much!

pelicanparts
21 May 2008, 07:40
I'm working on it tonight - I've got it able to read the vB cookies, and it should work for autologon - it's just a matter of getting the details just right. I'll post my code here when I'm done.

-Wayne

Elenna
29 May 2008, 22:19
Hi Wayne!

Were you able to make any headway on what you're working on? I would sincerely love to have it automatically log my members in again.

pelicanparts
30 May 2008, 06:15
Yes, I was, and it is currently working. I will post it soon...

-Wayne

--------------- Added 1212124788 at 1212124788 ---------------

Add to end of LocalSettings.php. Change 123456789 to your vB license number. Change pelicanparts.com to your domain.

Make sure that in cookie settings in vBulletin's admin control panel, you set the cookie domain to be your domain, not blank. In my case I set it to be pelicanparts.com


# vBulletin integration script
require_once("D:/Wiki/extensions/AuthPlugin_vBulletin/AuthPlugin_vBulletin.php");
$wgCookieDomain = "pelicanparts.com";
define('COOKIE_SALT', '123456789'); ### VB LICENSE NUMBER, FROM LINE 37 OF FUNCTIONS
$wgAuth = new Auth_remoteuser();
$wgShowExceptionDetails = true;


--------------- Added 1212125151 at 1212125151 ---------------

Here's the code, still rough and with test messages printing.

Replace VBULLETINDATABASE with the name of your vb database
Replace MYSQLLOGIN with your mysql logon name
Replace MYSQLPASSWORD with your mysql password name

That does it, this does work on my site right now, I think the only thing I'm missing is sending people to vb for account creation...

-Wayne


<?php
ini_set('display_errors', '1');
error_reporting(E_ALL);
/**
* Authentication plugin interface. Instantiate a subclass of AuthPlugin
* and set $wgAuth to it to authenticate against some external tool.
*
* The default behavior is not to do anything, and use the local user
* database for all authentication. A subclass can require that all
* accounts authenticate externally, or use it only as a fallback; also
* you can transparently create internal wiki accounts the first time
* someone logs in who can be authenticated externally.
*
* This interface is new, and might change a bit before 1.4.0 final is
* done...
*
* AuthPlugin extension by Daniel Gravenor c/o HolisticEarth.org
* AuthPlugin original by Kai Backman
*
* @package MediaWiki
*/
require_once("includes/AuthPlugin.php");

$wgHooks['UserLogout'][] = 'fnMyVBLOGOUTHook';

class Auth_remoteuser extends AuthPlugin {

//WAYNE'S STUFF FROM http://www.raskas.be/blog/2006/11/17/mediawiki-remote-user-authentication/
function Auth_remoteuser() {
global $wgExtensionFunctions;
if (!isset($wgExtensionFunctions)) {
$wgExtensionFunctions = array();
} else if (!is_array($wgExtensionFunctions)) {
$wgExtensionFunctions = array( $wgExtensionFunctions );
}
//print "TEST: REMOTE HOOK2\n";
array_push($wgExtensionFunctions, 'Auth_remote_user_hook');
//print "DONE2\n";
return;
}

// Create a persistent DB connection
var $vb_database;

function AuthPlugin_vBulletin($host, $username, $password, $dbname, $prefix) {
global $wgCookiePrefix;
global $exp;
global $wgCookiePath;
global $wgCookieDomain;
global $wgCookieSecure;

global $wgUser;
global $wgRequest;
global $_REQUEST;

$this->vb_database = mysql_pconnect($host, $username, $password);
mysql_select_db($dbname, $this->vb_database);
$this->vb_prefix = $prefix;
// set the usergroups for those who can edit the wiki
$this->allowed_usergroups = Array(2, 5, 6, 7);
// set the usergroups for the administrators
$this->admin_usergroups = Array(6, 9);
$this->user_rights = Array("sysop");
// search pattern to only accept alphanumeric or underscore characters in usernames
// if they have illegal characters, their name cannot exist, period
$this->searchpattern = "/[\#\<\>\[\]\|\{\}/";

//print_r($_COOKIE);

//print "Content-type: text/html\n\n";
//print "bbsessionhash:" . $_COOKIE["bbsessionhash"] . "<br>\n";
//print "bblastvisit:" . $_COOKIE["bblastvisit"] . "<br>\n";
//print "bblastactivity:" . $_COOKIE["bblastactivity"] . "<br>\n";
//print "bbuserid:" . $_COOKIE["bbuserid"] . "<br>\n";
//print "bbpassword:" . $_COOKIE["bbpassword"] . "<br>\n";
}


/**
* Check whether there exists a user account with the given name.
* The name will be normalized to MediaWiki's requirements, so
* you might need to munge it (for instance, for lowercase initial
* letters).
*
* @param string $username
* @return bool
* @access public
*/
function userExists( $username ) {
print "Content-type: text/html TEST1\n\n";
// if no illegal characters are found in their username, then check to see if they exist
if (!preg_match($this->searchpattern, $username)) {
$username = addslashes($username);
$vb_find_user_query = "SELECT usergroupid FROM " . $this->vb_prefix . "user WHERE LOWER(username)=LOWER('" . $username . "')";
$vb_find_result = mysql_query($vb_find_user_query, $this->vb_database);
// make sure that there is only one person with the username
if (mysql_num_rows($vb_find_result) == 1) {
$vb_userinfo = mysql_fetch_assoc($vb_find_result);
mysql_free_result($vb_find_result);
// Only registered and admins. Banned and unregistered don't belong here.
if (in_array($vb_userinfo['usergroupid'], $this->allowed_usergroups)) {
return TRUE;
}
}
}
// if no one is registered with that username, or there are more than 1 entries
// or they have illegal characters return FALSE (they do not exist)
return FALSE;
}

/**
* Check if a username+password pair is a valid login.
* The name will be normalized to MediaWiki's requirements, so
* you might need to munge it (for instance, for lowercase initial
* letters).
*
* @param string $username
* @param string $password
* @return bool
* @access public
*/
function authenticate( $username, $password ) {
$searchpattern = "/[\#\<\>\[\]\|\{\}]/";
$dbh = mysql_pconnect("localhost", "MYSQL-LOGON", "MYSQL-PASSWORD");
mysql_select_db("VBULLETINDBNAME", $dbh);

print "Content-type: text/html TEST2\n\n";
// if their name does not contain any illegal characters, let them try to login
if (!preg_match($searchpattern, $username)) {
print "TEST2A\n";
$username = addslashes($username);
$vb_find_user_query = "SELECT password, salt, usergroupid FROM VBULLETINDATABASE.user WHERE LOWER(username)=LOWER('" . $username . "')";
$vb_find_result = mysql_query($vb_find_user_query, $dbh);
if (mysql_num_rows($vb_find_result) == 1) {
print "FOUND!\n";
$vb_userinfo = mysql_fetch_assoc($vb_find_result);
mysql_free_result($vb_find_result);
// Only registered and admins. Banned and unregistered don't belong here.
$valid_usergroup_array = array(2, 5, 6, 7);
print "TEST2B\n";
if (in_array($vb_userinfo['usergroupid'], $valid_usergroup_array)) {
if(md5(md5($password) . $vb_userinfo['salt']) == $vb_userinfo['password'])
{
print "AUTH TRUE: NOW WE NEED TO UPDATE VBULLETIN WITH THE LOGIN INFORMATION? OR NOT?\n";
return true;
}
}
}
}
return false;
}

/**
* When a user logs in, optionally fill in preferences and such.
* For instance, you might pull the email address or real name from the
* external user database.
*
* The User object is passed by reference so it can be modified; don't
* forget the & on your function declaration.
*
* @param User $user
* @access public
*/
function updateUser( &$user ) {
print "Content-type: text/html TEST3\n\n";
# Override this and do something
$dbh = mysql_pconnect("localhost", "MYSQL-LOGON", "MYSQL-PASSWORD");
mysql_select_db("VBULLETINDATABASE", $dbh);

$vb_find_user_query = "SELECT usergroupid, membergroupids FROM VBULLETINDATABASE.user WHERE LOWER(username)=LOWER('" . addslashes($user->mName) . "')";
$vb_find_result = mysql_query($vb_find_user_query, $dbh) or print("Could not find username");
if(mysql_num_rows($vb_find_result) == 1) {
$vb_userinfo = mysql_fetch_assoc($vb_find_result);
mysql_free_result($vb_find_result);
// go through the users member groups to see if one of them is administrative
$user_membergroups = explode(",", $vb_userinfo['membergroupids']);
$admin_secondary = FALSE;
for ($x = 0; $x < count($user_membergroups); $x++) {
if (in_array($user_membergroups[$x], $this->admin_usergroups)) $admin_secondary = TRUE;
}

if (in_array($vb_userinfo['usergroupid'], $this->admin_usergroups) || $admin_secondary === TRUE) {
// if a user is not a sysop, make them a sysop
if (!in_array("sysop", $user->getEffectiveGroups())) {
$user->addGroup('sysop');
return TRUE;
}
}
// if the user is not an administrator, but they were, and they are still a sysop, remove their sysop status
if (!in_array($vb_userinfo['usergroupid'], $this->admin_usergroups) && $admin_secondary === FALSE) {
if (in_array("sysop", $user->getEffectiveGroups())) {
$user->removeGroup('sysop');
return TRUE;
}
}
}
return FALSE;
}

/**
* Return true if the wiki should create a new local account automatically
* when asked to login a user who doesn't exist locally but does in the
* external auth database.
*
* If you don't automatically create accounts, you must still create
* accounts in some way. It's not possible to authenticate without
* a local account.
*
* This is just a question, and shouldn't perform any actions.
*
* @return bool
* @access public
*/
function autoCreate() {
return true;
}

/**
* Return true to prevent logins that don't authenticate here from being
* checked against the local database's password fields.
*
* This is just a question, and shouldn't perform any actions.
*
* @return bool
* @access public
*/
function strict() {
return true;
}

/**
* When creating a user account, optionally fill in preferences and such.
* For instance, you might pull the email address or real name from the
* external user database.
*
* The User object is passed by reference so it can be modified; don't
* forget the & on your function declaration.
*
* @param User $user
* @access public
*/
function initUser( &$user ) {
print "Content-type: text/html TEST4\n\n";
$vb_find_user_query = "SELECT email, usergroupid FROM " . $this->vb_prefix . "user WHERE LOWER(username)=LOWER('" . addslashes($user->mName) . "')";
$vb_find_result = mysql_query($vb_find_user_query, $this->vb_database);
if(mysql_num_rows($vb_find_result) == 1) {
$vb_userinfo = mysql_fetch_assoc($vb_find_result);
mysql_free_result($vb_find_result);
$user->mEmail = $vb_userinfo['email'];
$user->mEmailAuthenticated = wfTimestampNow();
}
}



} // END CLASS

function Auth_remote_user_hook() {
global $wgUser;
global $wgRequest;
global $_REQUEST;

global $wgCookiePrefix;
global $exp;
global $wgCookiePath;
global $wgCookieDomain;
global $wgCookieSecure;

//print_r($_COOKIE);

//print "REMOTE HOOK77";
// For a few special pages, don't do anything.
$title = $wgRequest->getVal('title') ;
if ($title == 'Special:Userlogout' || $title == 'Special:Userlogin') {
//print "TEST101\n";
return;
}

// Do nothing if session is valid
$wgUser = User::newFromSession();
if ($wgUser->isLoggedIn()) {
//print "TEST102\n";
return; // User is already logged in and not anonymous.
}
//print "TEST: WGUSER\n" . $_COOKIE["bbsessionhash"];

$test = new Auth_remoteuser();
$wgAuth = $test->AuthPlugin_vBulletin("localhost", "MYSQL-LOGON", "MYSQL-PASSWORD", "VBULLETINDATABASE", "VBULLETINDATABASE.");

if ($_COOKIE["bbsessionhash"] != "")
{
//print "TEST: IS INT, CONNECT TO DB\n";
$dbh = mysql_pconnect("localhost", "MYSQL-LOGON", "MYSQL-PASSWORD");
mysql_select_db("VBULLETINDATABASE", $dbh);

$vb_find_user_query = "SELECT password, salt, usergroupid, username FROM VBULLETINDATABASE.user WHERE userid IN (select userid from session where sessionhash = '" . $_COOKIE["bbsessionhash"] . "');";
$vb_find_result = mysql_query($vb_find_user_query, $dbh);
//print "SQL: $vb_find_user_query\n";
if (mysql_num_rows($vb_find_result) == 1) {
//print "FOUND";
$vb_userinfo = mysql_fetch_assoc($vb_find_result);
mysql_free_result($vb_find_result);
// Only registered and admins. Banned and unregistered don't belong here.
//print "USERNAME: " . $vb_userinfo['username'] ."\n";
setcookie( $wgCookiePrefix.'wikidbUserName', $vb_userinfo['username'], $exp, $wgCookiePath, $wgCookieDomain, $wgCookieSecure );
// NEED TO FIX THIS TO BE CONSISTENT
$valid_usergroup_array = array(2, 5, 6, 7);
if (in_array($vb_userinfo['usergroupid'], $valid_usergroup_array))
{
//print "TEST33\n";
//if(md5($vb_userinfo['password'] . COOKIE_SALT) == $_COOKIE["bbpassword"])
// {
//print "LOGGED INTO vB, NOW LOG INTO WIKI";\
// THIS ROUTINE IS CALLED, AND THEN THE PAGE IS REFRESHED
$username = $vb_userinfo['username'];
$u = User::newFromName( $username );
if (is_null($u))
{
# Invalid username or some other error -- force login, just return
//print "INVALID";
return;
}
$wgUser = $u;
if ($u->getId() != 0)
{
$_REQUEST['wpName'] = $username;
# also return, but user is know. set Cookies, et al
$wgUser->setCookies();
$wgUser->saveSettings();
//print "TEST103\n";
return;
#include 'includes/SpecialUserlogin.php';
#$form = new LoginForm( $wgRequest );
#$form->initUser( $wgUser );
#$wgUser->saveSettings();
#return true;
}
//print "TEST77:" . md5(md5($_COOKIE["bbpassword"])) ;
//print "<br>PWD: " . md5($vb_userinfo['password'] . COOKIE_SALT) ."<br> TEST44:" . $_COOKIE["bbpassword"] . "\n";
// }
}
}
}

// Ok, now we need to create a user.
//print "Location: http://forums.pelicanparts.com/newreply.php?do=newreply&noquote=1&p=3801901\n\n";
return;

// $loginForm = new LoginForm($params);
// $result = $loginForm->authenticateUserData();
// if ($result != LoginForm::SUCCESS) {
// error_log('Unexpected REMOTE_USER authentication failure.');
// return;
// }

}

function fnMyVBLOGOUTHook(&$user)
{
global $wgCookiePrefix;
global $exp;
global $wgCookiePath;
global $wgCookieDomain;
global $wgCookieSecure;

//print "LOGOUT HOOK";

setcookie('bbsessionhash', '', $exp, $wgCookiePath, $wgCookieDomain, $wgCookieSecure );
setcookie('bblastvisit', '', $exp, $wgCookiePath, $wgCookieDomain, $wgCookieSecure );
setcookie('bblastactivity', '', $exp, $wgCookiePath, $wgCookieDomain, $wgCookieSecure );
setcookie('bbuserid', '', $exp, $wgCookiePath, $wgCookieDomain, $wgCookieSecure );
setcookie('bbpassword', '', $exp, $wgCookiePath, $wgCookieDomain, $wgCookieSecure );
return true;
}



#class AuthPlugin_vBulletin extends AuthPlugin {



?>

Elenna
30 May 2008, 15:25
Thank you, Wayne!

I get the following error:
Notice: Undefined index: bbsessionhash in /(path)/wiki/AuthPlugin_vBulletin.php on line 290

Also, would it be possible to make variables for the database name, sql username, and password, instead of manually putting them in each connection string? I'm not asking you to do it, I'm curious if it's possible - if it is, then I can work on that :)

pelicanparts
30 May 2008, 23:44
Turn off error reporting by deleting or commenting out lines 2 and 3. That's just a warning message, nothing serious there.

-Wayne

Elenna
31 May 2008, 03:34
Thanks, I'll try that :)

SuperGLS
26 Jun 2008, 23:38
Wayne,

Thanks for the additional work on this for 3.7.

I have had a forum for a long time and just set up a wiki (MW 1.12). In order to get this integration working do I have to follow the instructions from the first post, then make the changes you have suggested, or just make the changes that you have put forth? Thanks in advance.

SuperGLS
30 Jun 2008, 20:19
Anyone have any thoughts on this?

Elenna, have you gotten yours to work?

Arkidas
01 Jul 2008, 00:21
I bought vBWiki Pro, disliked it and got a refund. I am now wondering if this may be better for me. Does anyone have a demo of this?

Smitty
01 Jul 2008, 03:17
I bought vBWiki Pro, disliked it and got a refund. I am now wondering if this may be better for me. Does anyone have a demo of this?I use the Pro version. I'm only running MediaWiki 1.11.0 but it works fine for me with vB 3.7.2. I haven't really looked to see what Mediawiki 1.12 will really do for me because my wiki is rarely used.

What didn't you like about the Pro version?

Is there a significant advantage in upgrading to Mediawiki 1.12?

Arkidas
01 Jul 2008, 15:09
I'm just wondering if this tutorial works better than vbwiki pro. I didn't like that there was no support and it doesn't work 100% with vB 3.7.2.

Smitty
01 Jul 2008, 22:28
I'm just wondering if this tutorial works better than vbwiki pro. I didn't like that there was no support and it doesn't work 100% with vB 3.7.2. This is sorta off topic, but... What problems are you having with the pro version on 3.7.2?

Goomzee
02 Jul 2008, 11:46
I also have same question is this work with 3.7.2

Arkidas
02 Jul 2008, 13:39
This is sorta off topic, but... What problems are you having with the pro version on 3.7.2?

It doesn't work with the current version of MediaWiki, I'd like spaced usernames to work.

I'm wondering, is it possible to disable areas in mediawiki that could confuse members ( e.g. 'discussion' ) ?

epaillac
02 Jul 2008, 16:48
# Rehash of sammyman's and my posts in the old thread::


You might get the following error (looks like only with PHP 4.3.11):


Workaround: In includes/SpecialUserlogin.php, find:
$u =& $this->initUser( $u );
Replace this to this:
$u = $this->initUser( $u );



Excessive Database Pings



This works perfectly fine, but for one problem.... Inserting the code in LocalSettings.php creates a "session" to mysql every time someone accesses *any* page in the wiki... (you can see this by putting in the wrong password). On my server, this caused too many sessions being created in mysql, and resulted in the intermittent access problems (as the db was unavailable)!!


The way around this is (Thogh a less elegant solution, and one you have to reapply every time your upgrade mediawiki) to insert the same code near the begining of "includes/User.php"

This takes care of the excess pinging problem, as the vb database is accessed only when a user tries to login.


Well, concerning the "Excessive Database Pings" I can't make the modification work.
I've removed :
require_once("AuthPlugin_vBulletin.php");
$wgAuth = new AuthPlugin_vBulletin($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, "vb_");
in the LocalSettings.php

and put this (not in the class) at the beginning of those 2 files : User.php and SpecialUserLogin.php and... my bridge doesn't work anymore. Any ideas on how to debug this ?

I'm using MW12 and vB 3.7.2

Thanks,

Charles.

Elenna
03 Jul 2008, 14:38
Anyone have any thoughts on this?

Elenna, have you gotten yours to work?

Yes, this works just fine. I am running vB 3.7.2 and MW 1.12.0.

The only thing that I would like to do, is to have it automatically log them in, instead of having them re-login (perhaps use the same cookie as vB?).

Arkidas
03 Jul 2008, 16:18
Can you show me a demo?

SuperGLS
04 Jul 2008, 03:19
Yes, this works just fine. I am running vB 3.7.2 and MW 1.12.0.

The only thing that I would like to do, is to have it automatically log them in, instead of having them re-login (perhaps use the same cookie as vB?).

Can you make a quick post that goes through exactly the steps you went through to get it set up?On my many attempts the other day I couldn't get it to work. It would be much appreciated.

Can you show me a demo?

Please!

Elenna
04 Jul 2008, 07:57
I followed the instructions starting at post 68 of this thread, and adjusted as instructed in the following posts.

Not sure how a demo would be beneficial. Basically it looks at your vB table for authentication, so you log in to MW with your vBulletin credentials.

Arkidas
04 Jul 2008, 13:13
So it's just like vbWikiPro except we can use the most recent MedaWiki and it isn't inside the vBulletin wrapper?

steven s
05 Jul 2008, 23:06
Can someone recap how to make this work with vB 3.7 and v1.12?

Are there now two files that need to be uploaded?
What edits are needed for localsettings?



Perhaps a new article needs to be written?

Elenna
05 Jul 2008, 23:39
So it's just like vbWikiPro except we can use the most recent MedaWiki and it isn't inside the vBulletin wrapper?

Yeppers! And folks will need to log-in separately, as this won't log them in automatically.

steven s
05 Jul 2008, 23:53
Yeppers! And folks will need to log-in separately, as this won't log them in automatically.
I seem to recall reading that users would need to log in just once using their vB username/password.

Arkidas
06 Jul 2008, 23:19
I think someone posted a code here so they log in automatically.

thestaton
07 Jul 2008, 16:18
I got it working... However, when I login using my admin credentials from the forum I'm getting these sql errors.

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/forum/public_html/wiki/AuthPlugin_vBulletin.php on line 179

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/forum/public_html/wiki/AuthPlugin_vBulletin.php on line 182

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/forum/public_html/wiki/AuthPlugin_vBulletin.php on line 190

GoodOmens
06 Aug 2008, 18:30
Anyone have a good way to use vbulletin templates for MediaWiki?

I have a idea of including the wrapper inside the MediaWiki template but MW templates are so poorly written its tough to figure out.

Tails0600
09 Aug 2008, 01:51
Question:

How do I edit: "$wgAuth = new AuthPlugin_vBulletin($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, "vb_"); " if vB is in the forums directory with user admin and password password?

I'm getting stuck with this!

--------------- Added 1218320827 at 1218320827 ---------------

Can somebody please help?

Kadar
06 Sep 2008, 01:16
Question:

How do I edit: "$wgAuth = new AuthPlugin_vBulletin($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, "vb_"); " if vB is in the forums directory with user admin and password password?

I'm getting stuck with this!

--------------- Added 1218320827 at 1218320827 ---------------

Can somebody please help?

"$wgAuth = new AuthPlugin_vBulletin($wgDBserver, $admin, $password, $wgDBname, "vb_"); "

hydn
07 Sep 2008, 22:52
I 3rd that request

chriske
28 Oct 2009, 22:58
## Database settings
$wgDBtype = "mysql";
$wgDBserver = "localhost";
$wgDBname = "username";
$wgDBuser = "database";
$wgDBpassword = "password";

You supply your own info instead of the above info like this:

"$wgAuth = new AuthPlugin_vBulletin("localhost", "username", "password", "databasename", "vb_"); "

jkt557
13 Feb 2011, 19:38
Is it possible to assign a Bureaucrats status to members of a vB usergroup?