BanzaiTokyo MODx forums  
  (#1 (permalink)) Old
immortal Offline
Junior Member
 
Posts: 9
Join Date: Aug 2008
Default Integrating with modx0961p2 and vBulletin 3.7.2 - 08-29-2008, 10:09 PM

I'm trying to use it on a website with the latest version of modx (0961p2) and latest vBulletin (3.7.2) and its not working with the given instructions.

Heres what I did:
- Created a modx plugin with the given code and set it to run at login/logout
- Added vBulletin plugin and enabled it and set modxpath to the right path (../modx-0961p2/)
- Put $VBDIR = "../forum/" right after <?php in index.php (thats the only line I added)

The error I get on login:

Fatal error: Call to a member function on a non-object in /home/immortal/public_html/modx-0961p2/manager/includes/document.parser.class.inc.php(745) : eval()'d code on line 11
(which is the "clean_array_gpc" line that sets username and password to TYPE_STR)

Error I get on logout:

Fatal error: Call to a member function on a non-object in /home/immortal/public_html/forum/includes/functions_login.php on line 393
(which is a database query line for deleting from session)

And vBulletin is not being automatically logged in.

I've been trying to debug this myself, but I have limited knowledge of vBulletin API and can't figure out what the incompatibility is. Is this something I'm doing wrong or just a compatibility issue with this version of vBulletin?

Any help would be greatly appreciated!
-Priyesh
   
Reply With Quote
  (#2 (permalink)) Old
resurepus Offline
Administrator
 
resurepus's Avatar
 
Posts: 27
Join Date: May 2008
Location: Toulouse, France
Default 09-04-2008, 05:31 PM

Priyesh, sorry it took us so long to reply - Summer is the time of vacations, you know.
What you describe in this message is not enough to understand where the problem is. If you could give us the access to your website we could take a look and most probably fix the problem. Thanks in advance!
  Send a message via MSN to resurepus Send a message via Skype™ to resurepus 
Reply With Quote
  (#3 (permalink)) Old
immortal Offline
Junior Member
 
Posts: 9
Join Date: Aug 2008
Question 09-05-2008, 04:10 PM

Thanks for the reply, I do appreciate it. Sorry for interrupting your vacation :P I wish I could go on one right now

Heres what DOES work: When a user is registered on vBulletin they are automatically added to ModX. Thats working just fine which is great! But when the user logs into ModX or logs out the plugin code gives errors.

I've been doing some digging and heres what I've found:

OnWebLogin: the error is this
Quote:
Fatal error: Call to a member function on a non-object in /home/immortal/public_html/modx-0961p2/manager/includes/document.parser.class.inc.php(745) : eval()'d code on line 10
And that line is:
Code:
$vbulletin->input->clean_array_gpc('p', array("username" => TYPE_STR, "password" => TYPE_STR));
It seems that its because "input" is not an object because its not defined. "vbulletin" is defined though, thats good but vbulletin->input is not. I tried commenting out that line and it does let me login without error but I am guessing that line is important for the function of the plugin (since the user is not logged into vbulletin).

OnWebLogout: the error is this
Quote:
Fatal error: Call to a member function on a non-object in /home/immortal/public_html/forum/includes/functions_login.php on line 393
And that line is as follows:
Code:
$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "session WHERE sessionhash = '" . $vbulletin->db->escape_string($vbulletin->session->vars['dbsessionhash']) . "'");
So this time, "vbulletin->db" is not defined.

For reference, heres exactly what I have in the plugin:
Code:
$event_name = $modx->Event->name;

if($event_name == 'OnWebLogin') {
	define('SESSION_BYPASS', 1);
	define('THIS_SCRIPT', 'archive');
        global $vbulletin, $db, $VBDIR;
	$CURDIR = getcwd();
	//$modx->Event->_output = $dir1;
	chdir($VBDIR);
        $vbulletin->input->clean_array_gpc('p', array("username" => TYPE_STR, "password" => TYPE_STR));

	if (!empty($vbulletin->GPC['username']) AND !empty($vbulletin->GPC['password']))
	{
		require_once('./includes/functions_login.php');
		$strikes = verify_strike_status($vbulletin->GPC['username'], true);

		if ($strikes === false)
		{ // user has got too many wrong passwords
			$error_message = fetch_error('strikes', $vbulletin->options['bburl'], $vbulletin->session->vars['sessionurl']);
			$do = 'error';
		}
		else if (verify_authentication($vbulletin->GPC['username'], $vbulletin->GPC['password'], '', '', $rememberme, true))
		{
			exec_unstrike_user($vbulletin->GPC['username']);

			$db->query_write("DELETE FROM " . TABLE_PREFIX . "session WHERE sessionhash = '" . $db->escape_string($vbulletin->session->vars['dbsessionhash']) . "'");

			$vbulletin->session->vars = $vbulletin->session->fetch_session($vbulletin->userinfo['userid']);

			/*insert query*/
			$db->query_write("
				INSERT INTO " . TABLE_PREFIX . "session
					(sessionhash, userid, host, idhash, lastactivity, styleid, loggedin, bypass, useragent)
				VALUES
					('" . $db->escape_string($vbulletin->session->vars['sessionhash']) . "', " . $vbulletin->session->vars['userid'] . ", '" . $db->escape_string($vbulletin->session->vars['host']) . "', '" . $db->escape_string($vbulletin->session->vars['idhash']) . "', " . TIMENOW . ", " . $vbulletin->session->vars['styleid'] . ", 1, " . iif ($logintype === 'cplogin', 1, 0) . ", '" . $db->escape_string($vbulletin->session->vars['useragent']) . "')
			");
		}
		else
		{ // wrong username / password
			exec_strike_user($vbulletin->userinfo['username']);
			$error_message = fetch_error('badlogin', $vbulletin->options['bburl'], $vbulletin->session->vars['sessionurl'], $strikes);
			$do = 'error';
		}
	}
	else {
	  $do = 'error';
	}

	chdir($CURDIR);

	if ($do == 'error')
	{
	 $output = "login failed";
	}
	else {
	 $output = "login success";
	}
	$modx->Event->_output = $output;
}
else if ($event_name == 'OnWebLogout') {
	global $vbulletin, $db, $VBDIR;
	$CURDIR = getcwd();
	//$modx->Event->_output = $dir1;
	chdir($VBDIR);
	require_once('./includes/functions_login.php');
	process_logout();
	chdir($CURDIR);
}
Its finding my forum so I know $VBDIR is properly set (I put it under the <php in modX's index.php file). The script has worked as-is for people in the past so either I installed it wrong or its broken for the latest version of vBulletin (3.7.3) or ModX (0961p2)

For further reference, heres what I did to install it:
vBulletin:
- I imported "product-modxvbin.xml" to vBulletin via the admincp
- GZIP/HTML output is turned off
- I edited "modxpath" to point to modx "../modx-0961p2/"
ModX:
- I created a new plugin called "modxVbin"
- Copy/pasted the code in modx_vblogin.php into the plugin
- Set it to go off on WebLogin and Weblogout
- Saved it

Then to test it I used the admincp to create a new vBulletin account. I checked to see if the user exists in modx (it does). So now I am trying to login to the modx website with this user info and getting these errors. But if I manually change the URL to a private page it does let me in because the login to modx is successful. The user is not logged into vBulletin though.

Let me know if you need further info, I am stumped by this. It seems the problem is properly defining vbulletin->input and vbulletin->db but who knows if thats the problem or just a symptom.

Thanks again for your help with this, I really appreciate it.
-Priyesh
   
Reply With Quote
  (#4 (permalink)) Old
resurepus Offline
Administrator
 
resurepus's Avatar
 
Posts: 27
Join Date: May 2008
Location: Toulouse, France
Default 09-10-2008, 07:54 AM

it is really strange, but it looks like modx_index.php was missing from the archieve. I am attaching the full archieve.

So in index.php add the following after $VBDIR:

Code:
$CURDIR = getcwd();
chdir($VBDIR);
require_once($VBDIR . "global.php");
chdir($CURDIR);
Attached Files
File Type: zip ModxVBin.zip (6.1 KB, 23 views)
  Send a message via MSN to resurepus Send a message via Skype™ to resurepus 
Reply With Quote
  (#5 (permalink)) Old
resurepus Offline
Administrator
 
resurepus's Avatar
 
Posts: 27
Join Date: May 2008
Location: Toulouse, France
Default 09-10-2008, 08:02 AM

guys, it looks like the original archive that I uploaded was missing modx_index.php
I am uploading the correct version right now. So for everybody who downloads it from now everything should work fine. I am sorry for any disconvenience it may have caused.
  Send a message via MSN to resurepus Send a message via Skype™ to resurepus 
Reply With Quote
  (#6 (permalink)) Old
immortal Offline
Junior Member
 
Posts: 9
Join Date: Aug 2008
Default 09-10-2008, 02:22 PM

Yes, adding those lines fixes the problem. The login is now integrated! Thanks for the help!

I was going to ditch login on the website altogether.. now I have to put things back the way they were :P

-Priyesh
   
Reply With Quote
  (#7 (permalink)) Old
resurepus Offline
Administrator
 
resurepus's Avatar
 
Posts: 27
Join Date: May 2008
Location: Toulouse, France
Default 09-10-2008, 06:39 PM

Cool, I am very glad to hear that it worked! Let us know what you think of our integration script and what features you would like to see in future releases.
  Send a message via MSN to resurepus Send a message via Skype™ to resurepus 
Reply With Quote
  (#8 (permalink)) Old
immortal Offline
Junior Member
 
Posts: 9
Join Date: Aug 2008
Default 09-11-2008, 05:00 PM

So the forum I am integrating already has a lot of members.. and I am now trying to figure out the best way to add them to ModX and have the passwords synced.

I added them to the Web Users list with the exact same username and email address. And I used a dummy password. But the issue is, the only way I found to "reset" their password is to set it myself through the admincp. If I do it that way, the change shows up in modx and they are synced. But obviously I don't want to set everyone's password myself. They should be able to change it through the User CP and the change should be reflected in ModX. Is there any other way you can think of to do this? Any quick change to the vBulletin plugin that will sync the password when changed through User CP?

Thanks
-Priyesh
   
Reply With Quote
  (#9 (permalink)) Old
resurepus Offline
Administrator
 
resurepus's Avatar
 
Posts: 27
Join Date: May 2008
Location: Toulouse, France
Default 09-15-2008, 07:05 PM

Here's a solution that may help in your situation.

In the "login_process" plugin after 3rd line from bottom (starts with
"setcookie(session_name()...") add following lines:

$row = ($vbulletin->GPC['password'] != '') ?
$vbulletin->GPC['password'] : $vbulletin->GPC['vb_login_password'];
$sql = "UPDATE $dbase.`".$table_prefix."web_users` SET
password='".md5($row).
"' WHERE username = '".$vbulletin->userinfo['username']."'
AND IFNULL(password, '') = ''";
if ($row != '') mysql_query($sql);

This will update empty passwords in MODx to actual in vB when user
logs into vB. Of course, MODx users must exist. If you need script to
upload vB users into MODx, let us know.
  Send a message via MSN to resurepus Send a message via Skype™ to resurepus 
Reply With Quote
  (#10 (permalink)) Old
immortal Offline
Junior Member
 
Posts: 9
Join Date: Aug 2008
Default 09-17-2008, 07:22 PM

I added the lines but the problem is how do I give the user an empty password? It has to be something or ModX doesn't let me create it.

So how would we modify this script so it checks for a specific password and then replaces it?
   
Reply With Quote
Reply

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vBulletin Skin developed by: vBStyles.com