I figured it out last night and it is working for me now. I had one thing set wrong in my gallery2.php file. Looking through this thread over and overhelped me a lot even after I had already looked and looked through it man times a day until I had it right. Here is how you set it up.
install vbulletin to:
domain.com/forum/
install gallery to:
domain.com/gallery/
open up a text editor and insert this code:
PHP Code:
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'gallery'); // change this depending on your filename
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(
);
// get special data templates from the datastore
$specialtemplates = array(
);
// pre-cache templates used by all actions
$globaltemplates = array(
'gallery2',
);
// pre-cache templates used by specific actions
$actiontemplates = array(
);
// ######################### REQUIRE BACK-END ############################
require_once('/kunden/homepages/16/d95423082/htdocs/hswaves2008/forum/global.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
$navbits = array();
$navbits[$parent] = 'Gallery';
error_reporting(E_ALL );
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
// #######################################################################
// ###################### Begin G2 INTEGRATION CODE ######################
// #######################################################################
$data = runGallery();
$data['title'] = (isset($data['title']) && !empty($data['title'])) ? $data['title'] : 'Gallery';
function runGallery() {
global $vbulletin, $userinfo;
require_once('/kunden/homepages/16/d95423082/htdocs/hswaves2008/gallery/embed.php');
$data = array();
// If it's an anonymous user, set the g2 activeUser to null
$uid = $vbulletin->userinfo['userid'] = 0 ? '' : $vbulletin->userinfo['userid'];
// initiate G2
// You need to edit the following 4 lines to suit your VB3 & G2 installations
// This is set up for an install that looks like:
// public_html/VB/<vb files>
// public_html/gallery2/<gallery2 files>
// and also setup for a VB3 template name of 'gallery2'. If you have any
// differences, make those changes here!
// You might need to change 'loginRedirect' if you have your VB3 setup to
// where index.php is not the root page of VB3... Like if you've changed it
// to forums.php or something of the like.
$ret = GalleryEmbed::init(array('embedUri' => 'gallery2.php',
'g2Uri' => '/gallery/',
'loginRedirect' => 'index.php',
'activeUserId' => $uid));
if ($ret)
{
if ($ret->getErrorCode() & ERROR_MISSING_OBJECT)
{
// Check if there's no G2 user mapped to the activeUserId
$ret = GalleryEmbed::isExternalIdMapped($uid, 'GalleryUser');
if ($ret && ($ret->getErrorCode() & ERROR_MISSING_OBJECT))
{
// User not mapped, create G2 user now
// Get Arguments for the new user:
$args['fullname'] = $vbulletin->userinfo['username'];
$args['username'] = $vbulletin->userinfo['username'];
$args['hashedpassword'] = $vbulletin->userinfo['password'];
$args['hashmethod'] = 'md5';
$args['email'] = $vbulletin->userinfo['email'];
$args['language'] = $vbulletin->userinfo['lang_code'];
$args['creationtimestamp'] = $vbulletin->userinfo['joindate'];
$retcreate = GalleryEmbed :: createUser($uid, $args);
if ($retcreate)
{
echo '<HR>line: '.__LINE__.', Failed to create G2 user with extId ['.$uid.']. Here is the error message from G2: <br />'.$retcreate->getAsHtml();
return false;
}
$ret = GalleryEmbed::checkActiveUser($uid);
if ($ret) {
print $ret->getAsHtml();
return false;
}
}
else
{
echo '<HR>line: '.__LINE__.', G2 did not return a success status. Here is the error message from G2: <br />'.$ret->getAsHtml();
return false;
}
}
else
{
echo '<HR>line: '.__LINE__.', G2 did not return a success status. Here is the error message from G2: <br />'.$ret->getAsHtml();
return false;
}
}
// user interface: disable sidebar in G2 and get it as separate HTML to put it into a block
// GalleryCapabilities::set('showSidebar', false);
// handle the G2 request
$g2moddata = GalleryEmbed::handleRequest();
// show error message if isDone is not defined
if (!isset($g2moddata['isDone'])) {
$data['bodyHtml'] = 'isDone is not defined, something very bad must have happened.';
return $data;
}
// die if it was a binary data (image) request
if ($g2moddata['isDone']) {
exit; /* uploads module does this too */
}
// put the body html from G2 into the xaraya template
$data['bodyHtml'] = isset($g2moddata['bodyHtml']) ? $g2moddata['bodyHtml'] : '';
// get the page title, javascript and css links from the <head> html from G2
$title = ''; $javascript = array(); $css = array();
if (isset($g2moddata['headHtml'])) {
list($data['title'], $css, $javascript) = GalleryEmbed::parseHead($g2moddata['headHtml']);
$data['headHtml'] = $g2moddata['headHtml'];
}
/* Add G2 javascript */
if (!empty($javascript)) {
foreach ($javascript as $script) {
$data['javascript'] .= "\n".$script;
}
}
/* Add G2 css */
if (!empty($css)) {
foreach ($css as $style) {
$data['css'] .= "\n".$style;
}
}
// sidebar block
if (isset($g2moddata['sidebarHtml']) && !empty($g2moddata['sidebarHtml'])) {
$data['sidebarHtml'] = $g2moddata['sidebarHtml'];
}
return $data;
}
// #######################################################################
// ####################### End G2 integration code #######################
// #######################################################################
eval('print_output("' . fetch_template('gallery2') . '");');
?>
This is my code, so you can feel free to copy it and save it as gallery2.php. There are two absolute paths that need to be altered toward the top. If you do a search for hswaves2008, you will find those paths. Put your absolute paths in there. One is for global.php and the other for embed.php. The other part of the code is already set for this type of setup so no need to edit the last part like the initial post of this thread tells you, I have already done it for you.
Save this file and upload to:
domain.com/forum/gallery2.php
Create the new template like Step 4 of the initial post instructs you to do.
That is all. Now you can use the gallery2.php file as the link to your gallery. You will need to edit the css file in gallery to match the colors of your vbulletin or vice-versa.
What this code does is integrate the gallery and the forums when anyone visits that file. When they register for your vbulletin forum, it
WILL NOT create a gallery user
yet. The user must first visit the gallery2.php file in order for a user account to be created in gallery. As I understand, there are two different db's. One for vbulletin and one for gallery. The password for the gallery will not be the same as the vbulletin forum for the user due to the fact that vbulletin wants to add SALT(password) to the password. When a user visits the gallery2.php file for the second time it will look to see if the user is registered in vbulletin and if so, will look in the gallery db for a user account that matches,and if so then all will be gravy. If you have any further questions, let me know. Im not good at this stuff but if you follow my instructions, it will work now that I have it all figured out.
It just sucks that someone like me has to be support for this for the fact that Im not really good at this stuff and am new to all this coding. Im a first timer to vbulletin, even if I have installed quite a few things in the past. I really would like to know what I am talking about when I help someone. What kind of code do I need to know to tweak this stuff. PHP? If I got a book on PHP, would that help me?