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