Invision Power Services: MediaWiki - Invision Power Services

Jump to content

Web Design and Coding

Our community chat forum areas are for off-topic discussion only. Please do not post topics about IPS or its products and services here. We provide other forum areas for IPS discussion.

Do you need technical support on IPS products or services?

You can obtain support via the client area, or you can try to obtain peer-to-peer support at IPS Resources.

Did you find a bug in one of our products?

If you believe you've found a bug please post it to the bug tracker.

Have a suggestion or feedback?

Use the company feedback forum or appropriate product feedback forum. You can also submit a ticket in your client area if it's a private matter.
  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

MediaWiki Rate Topic: ***** 1 Votes

#1 User is online   Luke Icon

  • Too detail oriented
  • Icon
  • View blog
  • Group: +Active Customers
  • Posts: 5,456
  • Joined: 14-August 04
  • Gender:Male
  • Location:USA

Posted 04 October 2005 - 05:06 PM

I'm currently working on the AuthPlugin.php file in MediaWiki and im trying to use it to authenticate users against an IPB database. Now authenticating is not hard, atleast for me, but does anyone know how to use MediaWiki to connect to a second database and run a couple quries? Here's an example of their code in User.php:

		$dbr =& wfGetDB( DB_SLAVE );
		extract( $dbr->tableNames( 'user', 'user_rights' ) );
		$sql = "SELECT user_name,user_password,user_newpassword,user_email,user_real_name," .
		  "user_options,user_touched,user_token,ur_rights " .
		  "FROM $user LEFT JOIN $user_rights ON user_id=ur_user WHERE user_id={$this->mId}";
		$res = $dbr->query( $sql );
		if ( $res ) {
			$s = $dbr->fetchObject( $res );
		} else {
			$s = false;
		}
		$dbr->freeResult( $res );


Its pretty confusing. And DB_SLAVE, as far as a I can tell, isnt the database name. So I'm really not to sure...
Luke
0

#2 User is offline   Alex Duggan Icon

  • IPS (UK)
  • Icon
  • View blog
  • Group: IPS Staff
  • Posts: 19,444
  • Joined: 13-February 02
  • Location:UK

Posted 04 October 2005 - 05:09 PM

Moving to a more appropriate forum.
Alex Duggan (My Blog)
IPB Conversions Specialist
Invision Power Services, Inc.
0

#3 User is offline   kirkup_xp Icon

  • IPB Full Member
  • PipPipPip
  • View blog
  • Group: Members
  • Posts: 160
  • Joined: 13-January 03

Posted 05 October 2005 - 07:19 AM

I'm no expert, but I found this on one of the vb forums... I believe the VB and IPB login systems are fairly similar.

Quote

Add this snippet to you LocalSettings.php. Insert your vBulletin DB information:
 require_once("AuthPlugin_vBulletin.php");
 
 $wgAuth = new AuthPlugin_vBulletin(<hostname>, <vb_username>, <vb_password>, <vb_dbName);


And then AuthPlugin_vBulletin.php itself:
 <?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...
  *
  * @package MediaWiki
  */
 require_once("includes/AuthPlugin.php");
 
 class AuthPlugin_vBulletin extends AuthPlugin {
 
   // Persistent DB connection
   var $vb_database;
 
   function AuthPlugin_vBulletin($host, $username, $password, $dbname)
   {
	 $this->vb_database = mysql_pconnect($host, $username, $password);
	 mysql_select_db($dbname, $this->vb_database);
   }  
 
 
   /**
	* 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 ) {
	 $username = addslashes($username);
	 $vb_find_user_query = "SELECT usergroupid FROM 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_user_info = mysql_fetch_array($vb_find_result);
	   $usergroupid = $vb_user_info['usergroupid'];
	   // Only registered and admins. Banned and unregistered don't belong here.
	   if($usergroupid == "2" || $usergroupid == "5" || $usergroupid == "6" || $usergroupid == "7")
		 return true;
	 }
	 else
	   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 ) {
	 $username = addslashes($username);
	 $vb_find_user_query = "SELECT password, salt, usergroupid FROM 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_user_info = mysql_fetch_array($vb_find_result);
	   $usergroupid = $vb_user_info['usergroupid'];
	   
	   // Only registered and admins. Banned and unregistered don't belong here.
	   if($usergroupid == "2" || $usergroupid == "5" || $usergroupid == "6" || $usergroupid == "7")
		 if(md5(md5($password) .  $vb_user_info['salt']) == $vb_user_info['password'])
		   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 password, salt FROM 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_user_info = mysql_fetch_array($vb_find_result);
	   $user->mEmail = $vb_user_info['email'];
	 }
	 else {
	   // ERROR?
	 }
   }
 }
 
 
 ?>

Help me get a PSP, and you could get one too!
0

#4 User is offline   ihiustler Icon

  • IPB Full Member
  • PipPipPip
  • View blog
  • Group: Members
  • Posts: 122
  • Joined: 13-June 03

Posted 05 October 2005 - 02:07 PM

Here is the IPB auth plugin.. it needs tweaked to pull the user email though. I cant figure that part out, maybe someone can?

<?php 

# Copyright (C) 2004 Brion Vibber <brion@pobox.com>
# Copyright (C) 2005 Dean Sas <dean@deansas.org>
# http://www.mediawiki.org/
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or 
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# http://www.gnu.org/copyleft/gpl.html

/**
 * Authentication plugin interface. Instantiate a subclass of AuthPlugin
 * and set $this->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...
 *
 * @package MediaWiki
 */
require_once('AuthPlugin.php');
	
class AuthIPB extends AuthPlugin{

	var $ipbDBHost;
	var $ipbDBUsername;
	var $ipbDBPassword;
	var $ipbDBName;
	var $ipbDBTablePrefix;
	
	var $connection;
	var $query;
	var $res;
	var $tmp;

	function AuthIPB(){	
		$this->ipbDBHost = "localhost";
		$this->ipbDBName = "----";
		$this->ipbDBUsername = "----";
		$this->ipbDBPassword= "----";
		$this->ipbDBTablePrefix = "ibf_";
		
	}

	/**
	 * 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 $this->username
	 * @return bool
	 * @access public
	 */
	function userExists( $username ) {
		$connection = mysql_connect($this->ipbDBHost, $this->ipbDBUsername , $this->ipbDBPassword );

		$query = "SELECT name FROM " . $this->ipbDBTablePrefix . "members WHERE name = '".$username . "'";
		mysql_select_db($this->ipbDBName, $connection);
		$res = mysql_query($query, $connection);
		if(mysql_fetch_row($res) == 0)
			return false;
		else
			return true;
	}
	
	/**
	 * 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 $this->username
	 * @param string $this->password
	 * @return bool
	 * @access public
	 */
	function authenticate( $username, $password ) {
		$connection = mysql_connect($this->ipbDBHost, $this->ipbDBUsername , $this->ipbDBPassword );
		mysql_select_db($this->ipbDBName, $connection);
		$query = "SELECT id FROM " . $this->ipbDBTablePrefix . "members WHERE name = '".$username . "'"; 
	
		$res = mysql_query($query, $connection);
		$tmp = mysql_fetch_row($res);
		
		$query = "SELECT converge_pass_hash, converge_pass_salt FROM ". $this->ipbDBTablePrefix."members_converge WHERE converge_id = '".$tmp[0]."' LIMIT 1";

		$res = mysql_query($query, $connection);
		
		
		$resultrow = mysql_fetch_row($res);
		
		$hashedpass =  md5(md5($resultrow[1]).md5($password));
		//start Test Values
		//proof that this is right algorithm
		//first bit is salt, second is password user entered
		//took salt straight from DB and compared result to pass_hash in DB
		/*$test = md5(md5(",\"da>").md5($password));
		echo "<br>TestHash :".$test;
		echo "<br>salt+pass: ". $hashedpass;
		echo "<br>Password: ".md5($password);
		echo "<br>Pass Hash: ".$resultrow[0];
		echo "<br>Pass Salt: ".$resultrow[1];
		echo "<br>User ID: ".$tmp[0];*/
		//end test stuff
				
		if($hashedpass == $resultrow[0]) 
			return true;
		else
			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;
	}

	/**
	 * Update user information in the external authentication database.
	 * Return true if successful.
	 *
	 * @param User $user
	 * @return bool
	 * @access public
	 */
	function updateExternalDB( $user ) {
		# we probably don't want users using MW to change other stuff
		return false;
	}

	/**
	 * Check to see if external accounts can be created.
	 * Return true if external accounts can be created.
	 * @return bool
	 * @access public
	 */
	function canCreateAccounts() {
		return false;
	}

	/**
	 * Add a user to the external authentication database.
	 * Return true if successful.
	 *
	 * @param User $user
	 * @param string $password
	 * @return bool
	 * @access public
	 */
	function addUser( $user, $password ) {
			return false;
	}



}
?>

0

#5 User is online   Luke Icon

  • Too detail oriented
  • Icon
  • View blog
  • Group: +Active Customers
  • Posts: 5,456
  • Joined: 14-August 04
  • Gender:Male
  • Location:USA

Posted 06 October 2005 - 03:58 PM

I've found that method doesnt work because it breaks the wiki's existing connection to the database. What I ended up doing was creating an external encoded auth script :)
Luke
0

#6 User is offline   Ipstenu Icon

  • Advanced Member
  • PipPipPipPip
  • View blog
  • Group: Members
  • Posts: 260
  • Joined: 02-October 03
  • Gender:Female

Posted 07 October 2005 - 04:09 PM

How does it break? I'd like to know before I try it 0:)

I'm speculating you mean that while you can log in, it doesn't keep the connection between user and wiki, but I'm reaching.
0

#7 User is offline   Disko Icon

  • IPB Newbie
  • Pip
  • View blog
  • Group: Members
  • Posts: 5
  • Joined: 03-January 04

Posted 03 February 2006 - 12:43 AM

Sorry to thread-dig, but what is the verdict on this? Does it work? Has anyone got functioning on their site?
0

#8 User is offline   SanderDolphin Icon

  • IPB Newbie
  • Pip
  • View blog
  • Group: Members
  • Posts: 1
  • Joined: 10-July 05

Posted 08 February 2006 - 09:05 PM

View PostDisko, on Feb 3 2006, 12:43 AM, said:

Sorry to thread-dig, but what is the verdict on this? Does it work? Has anyone got functioning on their site?
Yes, Cy got it working on his website (http://www.toontask.com)
0

#9 User is offline   Beefcake Icon

  • IPB Newbie
  • Icon
  • View blog
  • Group: +Active Customers
  • Posts: 26
  • Joined: 23-June 03
  • Location:Midlands, UK

Posted 24 February 2006 - 11:00 AM

Does anybody have any instructions of how to get this working? I have messaged Cy but I guess he is busy at the moment. Would love to be able to integrate my mediawiki into the IPB user/passwords.

:)
0

#10 User is offline   Pⅇter Icon

  • Needs Serious Help
  • PipPipPipPipPipPip
  • View blog
  • Group: Members
  • Posts: 1,509
  • Joined: 25-February 06
  • Location:Belgium

Posted 25 February 2006 - 10:49 PM

the basic things will work if you follow the instructions as they are posted above, but there are a few problems with this script as it is, to name a few: you won't be able to create users on your wiki (only create users on your forum), users with complex passwords won't authenticate, you highly likely will have to login each time as I don't see any direct session support, etc...

the good news is that I've got a solution for all those problems and even add several other features, the bad news is that i don't give it away for free as i'm charging a small fee, but in case you're still interested, you can check out my site here
Posted Image
Add a Wiki to your Forum!
IpbWiki - Full Integration of Invision Power Board with MediaWiki
0

#11 User is offline   Beefcake Icon

  • IPB Newbie
  • Icon
  • View blog
  • Group: +Active Customers
  • Posts: 26
  • Joined: 23-June 03
  • Location:Midlands, UK

Posted 26 February 2006 - 06:16 PM

Thanks that sounds perfect :)
0

#12 User is online   Luke Icon

  • Too detail oriented
  • Icon
  • View blog
  • Group: +Active Customers
  • Posts: 5,456
  • Joined: 14-August 04
  • Gender:Male
  • Location:USA

Posted 27 February 2006 - 05:42 PM

The only problem with your wiki integration is support for 2.1, and its display name feature.
Luke
0

#13 User is offline   Pⅇter Icon

  • Needs Serious Help
  • PipPipPipPipPipPip
  • View blog
  • Group: Members
  • Posts: 1,509
  • Joined: 25-February 06
  • Location:Belgium

Posted 27 February 2006 - 10:16 PM

IpbWiki supports Invision Power Board 2.1.

You're right about the display name though, you have to login with your login name. It wouldn't be logical to allow you to login with your display name as you can't login with your display name on the Ipb2.1 forum either. For instance my login name on this forum is ipbwiki, but I can't login with my display name Peter.
I'll add it to my todo list to show in the wiki header the actual forum "display name" once you're logged in. It's a task with low priority though, as I've got several other features I want to see implemented. :)
Posted Image
Add a Wiki to your Forum!
IpbWiki - Full Integration of Invision Power Board with MediaWiki
0

#14 User is online   Luke Icon

  • Too detail oriented
  • Icon
  • View blog
  • Group: +Active Customers
  • Posts: 5,456
  • Joined: 14-August 04
  • Gender:Male
  • Location:USA

Posted 27 February 2006 - 10:21 PM

Well it wouldnt be hard to switch compatbility, yes. But trust me: Display name is not an easy thing to do, ive tried. It's not a matter of your Display name showing up in the header, its making it display in all of the history of changes, and everything else... And with history of changes, and articles created, the name is cachied directly, not linked via table... Doing it would involve recoding most of the wiki.
Luke
0

#15 User is offline   .Reko Icon

  • Inconsistantly backward; too boring for an avatar.
  • PipPipPipPipPipPip
  • View blog
  • Group: Members
  • Posts: 1,842
  • Joined: 24-July 02

Posted 01 March 2006 - 04:23 PM

You don't have to make a separate MySQL connection to access a different database so long as the user you connected with has permissions on that database.

Specify the table name like database_name.table_name
Interesting things: Interactive fiction | Clusty | My site
0

#16 User is offline   Rensaku Icon

  • IPB Newbie
  • Pip
  • View blog
  • Group: Members
  • Posts: 3
  • Joined: 06-April 07

Posted 06 April 2007 - 10:36 AM

QUOTE(Peter. @ Feb 25 2006, 10:49 PM) <{POST_SNAPBACK}>
the basic things will work if you follow the instructions as they are posted above, but there are a few problems with this script as it is, to name a few: you won't be able to create users on your wiki (only create users on your forum), users with complex passwords won't authenticate, you highly likely will have to login each time as I don't see any direct session support, etc...

the good news is that I've got a solution for all those problems and even add several other features, the bad news is that i don't give it away for free as i'm charging a small fee, but in case you're still interested, you can check out my site here

That's bad news indeed since I tried purchasing, but since you're not making use of Paypal, I can't purchase it since the country I'm at isn't in the list of countries supported by the pay-option that you're using. *sigh*

I'll be trying the steps posted above... Does anyone else have any pointers? It would be much appreciated since I'll be using it on a non-profit community site. Thanks.

[edit]
To describe, I have 2 databases, 1 for IPB and 1 for Mediawiki. The only thing I need is the user integration, including login. Thanks again to those who're willing to shed some light on this task I have.
0

#17 User is offline   Pⅇter Icon

  • Needs Serious Help
  • PipPipPipPipPipPip
  • View blog
  • Group: Members
  • Posts: 1,509
  • Joined: 25-February 06
  • Location:Belgium

Posted 06 April 2007 - 11:22 AM

QUOTE(Rensaku @ Apr 6 2007, 10:36 AM) <{POST_SNAPBACK}>
That's bad news indeed since I tried purchasing, but since you're not making use of Paypal, I can't purchase it since the country I'm at isn't in the list of countries supported by the pay-option that you're using. *sigh*

I do accept PayPal, the payment selection is in order screen 3/3.
Payments can be made through either PayPal or Moneybookers (when you pay through PayPal the order is automatically processed when the payment is complete, Moneybookers orders are manually processed but are usually activated within a few hours).

It could be that I forgot adding a country in my country select box though, which country are you from?
Posted Image
Add a Wiki to your Forum!
IpbWiki - Full Integration of Invision Power Board with MediaWiki
0

#18 User is offline   Rensaku Icon

  • IPB Newbie
  • Pip
  • View blog
  • Group: Members
  • Posts: 3
  • Joined: 06-April 07

Posted 06 April 2007 - 11:29 AM

I must've misread the portion at the bottom. blink.gif

Anyway, the community asked me not to purchase any software anymore since we're not going to earn anything from the site. I'll just try to figure this out.
And, I'm from the Philippines. ^^;
0

#19 User is offline   Pⅇter Icon

  • Needs Serious Help
  • PipPipPipPipPipPip
  • View blog
  • Group: Members
  • Posts: 1,509
  • Joined: 25-February 06
  • Location:Belgium

Posted 06 April 2007 - 11:33 AM

that's alright, anyway your country is listed as "Philippines" maybe I should add a duplicate as "The Philippines" original.gif
Posted Image
Add a Wiki to your Forum!
IpbWiki - Full Integration of Invision Power Board with MediaWiki
0

#20 User is offline   Rensaku Icon

  • IPB Newbie
  • Pip
  • View blog
  • Group: Members
  • Posts: 3
  • Joined: 06-April 07

Posted 06 April 2007 - 11:45 AM

No, it's not that. I already filled up the first page and the second page. The third page, where it stated:

QUOTE
Moneybookers is a similar system as PayPal but it supports more countries (all countries not on the NCCT list) and currencies (Euro, British Pound, Bulgarian Lev, U.S. Dollar, Australian Dollar, Canadian Dollar, Czech Koruna, Danish Krone, Estonian Koruna, Hong Kong Dollar, Hungarian Forint, Israeli Shekel, Japanese Yen, Latvia Lat, Malaysian Ringgit, New Taiwan Dollar, New Zealand Dollar, Norwegian Krone, Polish Zloty, Singapore Dollar, Slovakian Koruna, Slovenian Tollar, South-African rand, South-Korean won, Swedish Krona, Swiss Franc and Thailand Baht.)


didn't have the Philippine Peso there so I assumed you didn't accept payment from here. I wasn't able to read the "Alternative" part. laughing.gif

Anyway, logging out. Have to find a way to make this work. thumbsup.gif
0

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users