Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-27-2005, 08:51 PM
leitel leitel is offline
 
Join Date: Mar 2003
Location: Costa Rica
Posts: 118
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default MediWiki Integration

I have posted the stub of an article that will outline modifications needed to integrate vB users with MediaWiki. This will result in wiki users being able to login through vB. Please go to: VBulletin/Users_Integration The reason for posting this information there is because this is more of a MediaWiki hack than vB.

If anyone has or is pursuing this, please share your insights there. Thank you!
Reply With Quote
  #2  
Old 07-27-2005, 10:14 PM
ricker ricker is offline
 
Join Date: Jun 2003
Location: Apple Valley, CA
Posts: 108
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by leitel
I have posted the stub of an article that will outline modifications needed to integrate vB users with MediaWiki. This will result in wiki users being able to login through vB. Please go to: VBulletin/Users_Integration The reason for posting this information there is because this is more of a MediaWiki hack than vB.

If anyone has or is pursuing this, please share your insights there. Thank you!
I will be checking this out.
Reply With Quote
  #3  
Old 07-28-2005, 03:53 PM
nogerorob nogerorob is offline
 
Join Date: Jun 2004
Location: Portland, OR
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Holy smoke. This is recent interest for me. How incredibly timely.

Thank you.

rob
Reply With Quote
  #4  
Old 07-29-2005, 07:46 PM
Darax The Good Darax The Good is offline
 
Join Date: Jan 2003
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This would be a reasonable project to put some effort into. I'll contribute what I can. The single intergration thing is interesting and something which I would leverage-but it would need to be complete, and the issues at the bottom of your post show how this could be challenging.

I've been running my wiki for a week now (yeah yeah) and I've had a few bad eggs-one person even blanked around 50 articles before we blocked him and rolled everything back. It only took a few minutes to undo damage that took the attacker more than 30 minutes to create.

What I really want to do is have the 'discussion' tab turn into a vB thread discussing the article. What I'm working on doing in the meantime is making a simple script which will automatically make and/or redirect to the thread in my 'articles' discussion forum. This, I think, will be something that is absolutely necessary for an integration.
Reply With Quote
  #5  
Old 07-31-2005, 04:24 AM
Darax The Good Darax The Good is offline
 
Join Date: Jan 2003
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

btw, I have a media wiki template and some php code that will cause a thread to get autogenerated if it doesn't exist for an article and link to the thread if it does. I can't update the wiki with all the code, unfortuantely because of vB rules...
This is crude-and a bit hacked together. The RSS Bot guys saved me a lot of time.
Code:
<?php


//get started
error_reporting(E_ALL & ~E_NOTICE);
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'WikiThread');
$phrasegroups = array();
$specialtemplates = array();
$actiontemplates = array();
$auto=0;

require_once('./global.php');
require_once('./includes/functions.php');
require_once('./includes/functions_bigthree.php');
require_once('./includes/functions_forumlist.php');
require_once('./includes/functions_newpost.php');


//See if it is an existing thread
$threads = $DB_site->query("
	SELECT * FROM " . TABLE_PREFIX . "thread
	WHERE title = 'Discussion: ".$_REQUEST['t']. "'
	AND forumid='46'	
");
//if it is, go there
while($thread=$DB_site->fetch_array($threads)){

echo($thread['forumid']);
$url = "http://www.hitchhikernet.com/forum/showthread.php?t=".$thread['threadid'];
eval(standard_redirect('',$url));
}
//the thread doesn't exist, better make sure this is a real wiki article
//or haxxors will get you.  You need to put your wiki db info in here.

$title = $_REQUEST['t']; 
if($title == ''){die("No article specified");}
$wdbserver  = 
$wdbusername=
$wdbpassword = 
$wdbdbname = 
$dbconn = mysql_connect($wdbserver,$wdbusername,$wdbpassword);

$dbacc = mysql_select_db($wdbdbname,$dbconn);
if(!$dbacc){
die("Error getting to the db...");
}

$res = mysql_query("
SELECT * FROM cur 
WHERE cur_title = '".$title."'",$dbconn);

if(mysql_num_rows( $res ) < 1){
	die("Invalid Article Requested");
}
//it is a real article, add the 'default thread'
//You need to do a lot of editing here.

$threadtitle = "Discussion: ".$title;
$wikibotpost = "This is an automatically generated introductory discussion post for the article at http://www.hitchhikernet.com/index.php/".$title."";
$wikibotname = "WikiBot";
$wikibotid = 220;
$wikiforumid=46;

$foruminfo = fetch_foruminfo($wikiforumid);
$bbuserinfo = fetch_userinfo($wikibotid);

$post['signature'] = true;
$post['emailupdate'] = 9999;
$post['title'] = $threadtitle;
$post['message'] = $wikibotpost;
$post['poststarttime'] = TIMENOW;
$post['rss_date'] = TIMENOW;
$post['posthash'] = md5($post['poststarttime'] . $bbuserinfo['userid'] . $bbuserinfo['salt']);
build_new_post('thread', $foruminfo, array(), 0, $post, $errors, $wikibotid);

$url = "http://www.hitchhikernet.com/forum/wikithread.php?t=".$title;
eval(standard_redirect('',$url));


?>
and then I made a template on my wiki called fd (forum discussion)

Code:
<h3>
[http://www.hitchhikernet.com/forum/wikithread.php?t={{PAGENAMEE}} comments/discussion]
</h3>
my sig has a link to where this is currently working.
Reply With Quote
  #6  
Old 07-31-2005, 04:30 PM
nogerorob nogerorob is offline
 
Join Date: Jun 2004
Location: Portland, OR
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Darax, would you consider adding this information to the wiki Leitel's started?

r
Reply With Quote
  #7  
Old 08-01-2005, 03:23 AM
Darax The Good Darax The Good is offline
 
Join Date: Jan 2003
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I can't because the first bit of code references vB code at the beginning and end... The best I could do is link back to here.
Reply With Quote
  #8  
Old 08-01-2005, 11:35 AM
leitel leitel is offline
 
Join Date: Mar 2003
Location: Costa Rica
Posts: 118
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Darax, you are welcome to add your comments/code to the article I started. Notice how nogerorob did this.

The focus of this article is Users integration. Your hack addresses thread integration with the discussion tab (if got that right). QUESTION: Should my article be renamed to cover vB integration in general OR should someone start a NEW article perhaps entitled: VBulletin/Thread_Integration?
Reply With Quote
  #9  
Old 08-04-2005, 04:23 PM
leitel leitel is offline
 
Join Date: Mar 2003
Location: Costa Rica
Posts: 118
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am starting to dive into this again. It sure would be helpful to collaborate with any others on this. If you are interested, please reply here or email me. Thanks!
Reply With Quote
  #10  
Old 08-04-2005, 05:05 PM
Kai Backman Kai Backman is offline
 
Join Date: Apr 2005
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm sorry to be late to the thread, but I've actually been running an integrated vBulletin/MediaWiki system for quite some time. I just today got another request from someone wanting to have the code, and realized it might be easier to just post it ..

MediaWiki has a facility for creating Authentication plugins that let you do the integration pretty easily. They were non-documented when I started with the hack, but once you find the correct template everything was smooth sailing. There are a few comments about the code

- People still need to log on to MediaWiki once, after that they are cookied.
- MediaWiki has a smaller namespace for usernames than vBulletin, on a large board you might have clashes. I'm assuming it's not a security problem, but it might be an inconvenience.
- You need to clean up the user properties pages of things like changing names and stuff (they aren't automatically dropped).
- The Wiki will create only those users who actually log on
- The $usergroupid clauses determine who can create an account, you need to change these clauses to suit your own board.

Have fun!

Add this snippet to you LocalSettings.php. Insert your vBulletin DB information:
Code:
require_once("AuthPlugin_vBulletin.php");

$wgAuth = new AuthPlugin_vBulletin(<hostname>, <vb_username>, <vb_password>, <vb_dbName);
And then AuthPlugin_vBulletin.php itself:
Code:
<?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?
    }
  }
}


?>
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:56 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04448 seconds
  • Memory Usage 2,307KB
  • Queries Executed 14 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete