Hey guys,
I've recently upgraded my network of sites up to the vB3.6 branch, getting ready to re-release the sites and I've run into a problem that I could use some assistance with.
I have a premium account with Sigma Chat and I am trying to edit their chat_auth.php file to allow integration with my user database. I will include the entire chat_auth.php file (which resides in the forum root directory).
From the Sigma Chat help resources;
Quote:
The AAS (remote access system) allows you to perform username/password verification from your own web site. This is performed by hosting a script on your own website (using CGI, PHP, ASP, or similar) that accepts two parameters; a username, and a password; and returns a simple zero (denying access) or 1 (to accept access).
|
Here's an example of a remote call -
HTML Code:
http://www.mywebsite/verify.pl?username=JAVAMAN&password=FOXTROT&ip=01.029.95.25
Here's the chat_auth.php file;
PHP Code:
<?php
/*======================================================================*\
|| #################################################################### ||
|| # SigmaChat Authentication module for vBulletin 3 # ||
|| # ---------------------------------------------------------------- # ||
|| # Version: 1.1 # ||
|| # Author: Oleg Krogius (olegk@cgshock.com) # ||
|| #################################################################### ||
\*======================================================================*/
/*
In order to install this all you need to do is drop this in the root folder
of your vBulletin 3 installation. :)
Important note: you may need to customize your banned usergroup ID.
You can find it on line 59 of this script, which reads:
" if ( $bbuserinfo['usergroupid'] == 45 ) "
Just change the number 8 to another one, if needed.
*/
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('SESSION_BYPASS', 1);
define('LOCATION_BYPASS', 1);
define('THIS_SCRIPT', 'chat_auth');
// ################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array();
$specialtemplates = array();
$globaltemplates = array();
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once('./includes/functions_legacy.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
globalize($_GET, array('username' => STR,'password' => STR));
if ($username == '')
{
die('0');
}
// get userid for given username
if ($bbuserinfo = $DB_site->query_first('SELECT userid, usergroupid, membergroupids, username, password, salt FROM ' . TABLE_PREFIX . 'user
WHERE username = "' . addslashes(htmlspecialchars_uni($username)) . '"'))
{
if ($bbuserinfo['password'] != md5(md5($password) . $bbuserinfo['salt']))
{
//bad password
die('0');
}
else
{
//is user activated?
if ( $bbuserinfo['usergroupid'] == 3 || $bbuserinfo['usergroupid'] == 4 )
{
die('0');
}
//is user banned?
if ( $bbuserinfo['usergroupid'] == 8 )
{
die('0');
}
//is the user an admin / super mod?
if ( $bbuserinfo['usergroupid'] == 5 || $bbuserinfo['usergroupid'] == 6 )
{
die('2');
}
//user is regular user
die('1');
}
}
else
{
//bad username
die('0');
}
?>
The following error is reported when running the above script;
Quote:
Fatal error: Call to a member function on a non-object in /home/final/public_html/420/chat_auth.php on line 52
|
Again, im trying to adapt this to work with vB3.6x. The script works fine with vB 3.5x.
Any insight would be greatly apprecaited!
Thanks!
Max
I have completed the necessary changes to the sigma chat integration script to make it work with vB3.6. The main change was with the way the data was being called. The old script was using a deprecated db function from vB. I updated that and had to include the functinos_legacy.php files to allow for globalize() to initialize.
Here's the final script. Just drop this in your vB root directory and in your Sigma Chat account settings point to this script for vB user authentication.
PHP Code:
<?php
/*======================================================================*\
|| #################################################################### ||
|| # SigmaChat Authentication module for vBulletin 3 # ||
|| # ---------------------------------------------------------------- # ||
|| # Version: 1.1 # ||
|| # Author: Oleg Krogius (olegk@cgshock.com) # ||
|| 07-20-7 - updated script to work with vB3.6 by Maximux1 & vB.org
|| #################################################################### ||
\*======================================================================*/
/*
In order to install this all you need to do is drop this in the root folder
of your vBulletin 3 installation. :)
Important note: you may need to customize your banned usergroup ID.
You can find it on line 59 of this script, which reads:
" if ( $bbuserinfo['usergroupid'] == 45 ) "
Just change the number 8 to another one, if needed.
*/
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('SESSION_BYPASS', 1);
define('LOCATION_BYPASS', 1);
define('THIS_SCRIPT', 'chat_auth');
// ################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array();
$specialtemplates = array();
$globaltemplates = array();
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once('./includes/functions_legacy.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
globalize($_GET, array('username' => STR,'password' => STR));
if ($username == '')
{
die('0');
}
// get userid for given username
$bbuserinfo = $db->query_first("SELECT userid, usergroupid, membergroupids, username, password, salt FROM " . TABLE_PREFIX . "user WHERE username = '$username'");
if ($bbuserinfo['password'] != md5(md5($password) . $bbuserinfo['salt']))
{
//bad password
die('0');
}
else
{
//is user activated?
if ( $bbuserinfo['usergroupid'] == 3 || $bbuserinfo['usergroupid'] == 4 )
{
die('0');
}
//is user banned?
if ( $bbuserinfo['usergroupid'] == 8 )
{
die('0');
}
//is the user an admin / super mod?
if ( $bbuserinfo['usergroupid'] == 5 || $bbuserinfo['usergroupid'] == 6 )
{
die('2');
}
//user is regular user
die('1');
}
?>