This thread will detail how to have a single login for multiple forums. It makes the following assumptions:
A valid vbulletin license exists for each install
All forums will be on the same server
You already have one forum operational AND that forum uses a BLANK $tableprefix!
One database will contain all the tables
This thread is a follow-up from this discussion over at vbulletin.com. Thanks to Brains for some pointers!
Here are the steps:
Copy your forum directories to a parallel directory (for example copy /www/forums to /www/new_forums)
In /includes/config.php, change $tableprefix (line 91) to a new prefix [for example $tableprefix = 'new_';]
Run the vb install from the new directory (/www/new_forums/install/install.php)
During the install, be sure NOT to empty the tables. If you have any doubt about what this means, stop NOW! If you empty the tables, you will lose all of your existing data from a prior install!
Download the files from these directories to your PC: /new_forums, /new_forums/admincp, /new_forums/archive, /new_forums/includes, /new_forums/modcp, /new_forums/subscriptions
We are now going to make global changes to the files in the folders (and subfolders) above. I used Dreamweaver's "edit-find and replace" function with "find in" set to "Entire Current Local Site". We are basically going to remove the "TABLE_PREFIX" from any code dealing with the user. (Note - if you are comfortable with unix command, you could do these changes from the command line on the server.)
Run the following find and replace operations:
Find [" . TABLE_PREFIX . "user] (find what's inside the brackets). Replace with [?.?user] This should find 562 instances of user, usergroup, userfield, and usertextfield
Find [" . TABLE_PREFIX . "strikes] (find what's inside the brackets). Replace with [?.?strikes] This should find 5 instances of strikes
Find [" . TABLE_PREFIX . "pm] (find what's inside the brackets). Replace with [?.?pm] This should find 61 instances of pm, pmtext, pmtextid, and pmreceipt.
Upload these directories back to the server.
We now need to do a little fine tuning
In /includes/functions.php: on line 1171 remove the table_prefix before $idname.
In /includes/adminfunctions: modify print_choser_row (line 1161)to check for $tableid of user, usergroups
PHP Code:
if ($tableid == "user" OR $tableid == "usergroup") {
$result = $DB_site->query("SELECT title, $tableid FROM "."$tablename$wherecondition ORDER BY title");
} else {
$result = $DB_site->query("SELECT title, $tableid FROM " . TABLE_PREFIX . "$tablename$wherecondition ORDER BY title"); // existing code
}
In /includes/adminfunctions_user.php around line 116 (construct_style_chooser)
PHP Code:
$tableid = $tablename . "id";
if ($tablename == "user" OR $tablename == "usergroupid") {
$result = $DB_site->query("
SELECT title, $tableid FROM "."$tablename WHERE userselect = 1
ORDER BY title
");
} else {
// existing code
$result = $DB_site->query("
SELECT title, $tableid FROM " . TABLE_PREFIX . "$tablename WHERE userselect = 1
ORDER BY title
");
}
Done! Both forums are now accessed by the same user table! PM's are unified across forums as is the user count.
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
Invalid SQL:
SELECT username, userid, birthday
FROM ?.?user
WHERE (birthday LIKE '10-30-%' OR birthday LIKE '10-31-%')
AND usergroupid IN (0, 6, 7, 2, 5)
mysql error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?.?user
WHERE (birthday LIKE '10-30-%' OR birthday LIKE '10-31-%')
AND use' at line 2
mysql error number: 1064
what does this mean?
It looks like maybe you've created a a double-double quote in that sql statement. Something that looks like
Code:
"".""user
I'll try to locate the exact spot where this sql is coded later today but if you can search in for "birthday" in the php files under includes.
Invalid SQL:
SELECT username, userid, birthday
FROM ?.?user
WHERE (birthday LIKE '10-30-%' OR birthday LIKE '10-31-%')
AND usergroupid IN (0, 6, 7, 2, 5)
mysql error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?.?user
WHERE (birthday LIKE '10-30-%' OR birthday LIKE '10-31-%')
AND use' at line 2
mysql error number: 1064
what does this mean?
Can you post what you have in includes/functions_databuild.php from line 840 to 846? It should look like this (assuming you've replaced " . TABLE_PREFIX . " with "."
PHP Code:
$bdays = $DB_site->query("
SELECT username, userid, birthday
FROM "."user
WHERE (birthday LIKE '$todayneggmt-%' OR birthday LIKE '$todayposgmt-%')
AND usergroupid IN ($usergroupids)
$activitycut ");
In /includes/functions.php: on line 1171 remove the table_prefix before $idname.
PHP Code:
if (!$check = $DB_site->query_first("SELECT $selid FROM " . TABLE_PREFIX . "$idname WHERE $idname" . "id=$id"))
this is what it look like after according to your explination
PHP Code:
if (!$check = $DB_site->query_first("SELECT $selid FROM " "$idname WHERE $idname" . "id=$id"))
is that correct?
Correct, you may want to do a "." just to help you find it in the future. To be honest, I don't know for sure what else is used by this query. This may need to be wrapped in an if statement instead. Can anyone else verify if this is only used for user type queries?
Can you post what you have in includes/functions_databuild.php from line 840 to 846? It should look like this (assuming you've replaced " . TABLE_PREFIX . " with "."
PHP Code:
$bdays = $DB_site->query("
SELECT username, userid, birthday
FROM "."user
WHERE (birthday LIKE '$todayneggmt-%' OR birthday LIKE '$todayposgmt-%')
AND usergroupid IN ($usergroupids)
$activitycut ");
What do you have there?
this is what I have from line 840 to 846
PHP Code:
$bdays = $DB_site->query("
SELECT username, userid, birthday
FROM ?.?user
WHERE (birthday LIKE '$todayneggmt-%' OR birthday LIKE '$todayposgmt-%')
AND usergroupid IN ($usergroupids)
$activitycut ");