PDA

View Full Version : multiple site controller


robert_2004
10-31-2006, 10:00 PM
This mod will allow you to combine multiple sites that you own and master, into the one set of files and database - easier to maintain, to update, to administer, and to master.

Even though this page is fairly long - there is a lot of info to set it up, but it's bloody easy to install, and easy to work with once installed.

What you can do:
- auto detect which site they have come to, and setup the right usergroup and style.
- run different styles on different sites.
- allow/deny different usergroups to different forums and version of site
- multiple forums with permissions set to individual sites
- multiple calendars with permissions set to individual sites

What you can't do:
- allow users to choose their own style (**coming soon**)
- can't run some plugins on some domains, and not on the others - all plugins must/will be active across the whole board.
- can't work if you have subdomains (at this point) - i dunno, it may - i just have 1 line which auto places 'www' on your domain.
- it is lacking an upgrade system to bring two forums together. I built this from the start - meaning my testing server was my original site, then i started a second test site, and started adding people to it - THERE IS NO MERGE SCRIPT *YET*. although, you might be able to use the vB to merge - CAN SOMEONE PLEASE VERIFIY / COMMENT ON THIS. (i.e. if you have 3000users/25,000posts in your main, and you want to bring 5000users/45,000posts from your 2nd site to combine them, we don't have anything on offer to reset the ID numbers, etc. possible the imPEX thinggy will resort all of that for you.)



----------
Important - My Current Setup:

i'm running vb 3.5 with vBa's CMPS.
i have it set up:
/public_html/index.php (cmps index)
/public_html/domains.php (this current mod)
/public_html/forum/ (all the forums' files)


USERGROUPS
With the usergroups - you are going to have to add the short_http into the start of the usergroup name - so please take this into account (as the system searches the short_http to grab the usergroup for the person viewing, to put them into that usergroup).

i set it up to not use the original 'registered users', but rather, each site has it's own 'registered users' usergroup.
The admin, super mod, banner member - i.e anything you want/think can work across ALL the sites can stay as one, the rest of the sites should have their own usergroups:

Please make sure that the custom usergroups are defined as below:
The number after the http_site (1st,2nd, etc) MUST correspond to the corresponding default vB usergroup id!

1.1st 1 - Unregistered / Not Logged In
1.1st 2 - Registered Users
1.1st 3 - Users Awaiting Email Confirmation
1.1st 5 - Super Moderators
1.1st 7 - Moderators
2.2nd 1 - Unregistered / Not Logged In
2.2nd 2 - Registered Users
2.2nd 3 - Users Awaiting Email Confirmation
2.2nd5 - Super Moderators
2.2nd 7 - Moderators

the first number: i put in just to order the domains (as i don't use '1st' and '2nd' on my testmachine - i use NORTH and WEST - but west was the first site, so i wanted it to be displayed first on the list)
the second number: '1st' and '2nd' are the http_site - the short hand name for each site - if you are running two computer games sites, one counter strike and the other world of warcraft, then 'CS' and 'WOW' are suitable.
the third number: corresponds to the original usergroup id with the same name.


---------


Example:
none at this point.

hacks and addons:
- adding events to multple calendars at once (coming soon)
- calendar custom fields working on multiple calendars
------------------------



[Temp area - installation steps]
cpanel -> add parked domains
mysql database change
domains.php
global.php
register.php
class_dm_user.php
functions.php
create styles
add plugin - domains.php
add plugin - force style

-------------------
FIRSTLY, backup YOUR database!!!

[Step 1 - Park your Domains ]
go into your cPanel or Plesk, or your hosting control system, and park your domains to your account - this will make all your domains, myFirstDomain.com and mySecondDomain.com all display the front page of your first initial site.


[Step 2 - mySQL Changes ]
none that i can remember / find at this point.


[Step 3 - /public_html/domains.php ]
create this file and insert the following:

<?php

###### multiple site controller #########
################################
// https://vborg.vbsupport.ru/showthread.php?p=1108615#post1108615

/* THIS FILE IS THE DOMAIN CHECKER FOR EACH FILE AND PAGE
THAT IS SHOWN ON THE SITE.

IT WILL HELP SECURITY RISKS, AS IF A LINK CANNOT BE
MADE BETWEEN THE CURRENT HTTP_HOST, AND AN IF()
STATEMENT IN THIS FILE, IT WILL OUTPUT AN ERROR.
THIS ABOVE STATEMENT MAY CAUSE PROBLEMS IF YOU HAVE
SISTER-SITES, TRYING TO ACCESS
FILES AND/OR DATABASE

IF ANOTHER SITE IS ADDED TO THE FAMILY, YOU WILL NEED
TO CREATE THE IF() STATEMENT HERE TO ALLOW IT TO DISPLAY
CORRECTLY.

THIS FILE NEEDS TO BE CALLED VIA A PLUGIN
AND AS IN INCLUDED() ON EVERY NON-FORUM PAGE

TO CHANGE DOMAIN'S STYLE = adminCP ->Plugins -> Force Style for each Domain

*/

$http_host = $_SERVER['HTTP_HOST'];
session_start();

// The Following will remove any problems by causing all your sites to begin with 'www'.
// Place WWW in front of all domains
if( strpos($_SERVER['HTTP_HOST'], 'www.') === false ) {
header("Location: http://www.$http_host$_SERVER[REQUEST_URI]");
}


if( preg_match('/MyFirstDomain.com/i', $http_host) ) { ##### My First Domain #####
// You can create any variables you want here:
$_SESSION['short_http'] = "1st"; // this is used in URL
$_SESSION['short_print'] = "1st"; // this is used for folder structure
$_SESSION['http_host'] = "MyFirstDomain.com";
$_SESSION['site_title'] = "My First Domain!!";
$_SESSION['site_home_title'] = "First Domain Forum and Home";
}



elseif( preg_match('/MySecondDomain.com/i', $http_host) ) { ##### My Second Domain #####
$_SESSION['short_http'] = "2nd";
$_SESSION['short_print'] = "2nd";
$_SESSION['http_host'] = "MySecondDomain.com";
$_SESSION['site_title'] = "My Second Domain!!!";
$_SESSION['site_home_title'] = "Second Domain Forum and Home";
}


/*
included an else clause here just to capture the unlikely
event that http_host is not passed. This can happen
with 1.0 useragents.
*/
else
{
header("upgradebrowser.html");
}



if (!function_exists(findCustomGroup)) {
function findCustomGroup($cid){
global $vbulletin;
$customIds = $vbulletin->db->query_read("SELECT usergroupid, title FROM " . TABLE_PREFIX . "usergroup");
while ($customId = $vbulletin->db->fetch_array($customIds)){
if (strpos($customId['title'],$cid)){
$cId = $customId['usergroupid'];
}
}
return $cId;
}
}
if (!function_exists(findAwaitingGroups)) {
function findAwaitingGroups(){
global $vbulletin;
$avug_array = array();
$avIds = $vbulletin->db->query_read(" SELECT usergroupid, title FROM " . TABLE_PREFIX . "usergroup");
while ($avId = $vbulletin->db->fetch_array($avIds)){
if (strpos($avId['title'],"Awaiting Email Confirmation")){
array_push($avug_array,$avId['usergroupid']);
}
}
return $avug_array;
}
}
?>



[Step 4 - global.php]

find [line 115]
$vbphrase = init_language();

// set a default username
if ($vbulletin->userinfo['username'] == '')
{
$vbulletin->userinfo['username'] = $vbphrase['unregistered'];
}
below this, add

// multiple site controller by Robert_2004
// https://vborg.vbsupport.ru/showthread.php?p=1108615#post1108615

require_once('../domains.php');

//let's set the appropriate site and forum titles as determined by the domains.php file.
//also used in providing the correct info in the appropriate emails (eg, activateaccount, welcomemail etc)
$vbulletin->options['hometitle'] = $_SESSION['site_home_title'];
$vbulletin->options['bbtitle'] = $_SESSION['site_title'];
$vbulletin->options['bburl'] = "http://www.".$_SESSION['http_host']."/forum";
$vbulletin->options['homeurl'] = "http://www.".$_SESSION['http_host'];
$vbulletin->options['http_host'] = $_SESSION['http_host'];

// set a default username
if ($vbulletin->userinfo['username'] == '')
{

//set the appropriate custom unregistered usergroup for all the guest accounts
$vbulletin->userinfo['username'] = $vbphrase['unregistered'];
$customUserGroup = $_SESSION['short_print']." ".$vbulletin->userinfo['usergroupid'];
$ncid = findCustomGroup($customUserGroup);
if (!empty($ncid)){
//print_r($vbulletin->userinfo);
//do not tamper with usergroupid just yet but rather utilise a
//customusergroupid field which will be used to set the appropriate
//forum permissions a little later on (function cache_permissions()).
$vbulletin->userinfo['usergroupid'] = $ncid;
}
}


[Step 5 - register.php]
find [line 265]

// Set specified options
if (!empty($vbulletin->GPC['options']))
{
foreach ($vbulletin->GPC['options'] AS $optionname => $onoff)
{
$userdata->set_bitfield('options', $optionname, $onoff);
}
}
add, below:

// multiple site controller by Robert_2004
// https://vborg.vbsupport.ru/showthread.php?p=1108615#post1108615
require_once('../domains.php');

find [line 285]

else
{
$newusergroupid = 2;
}
below, add:
// multiple site controller by Robert_2004
// https://vborg.vbsupport.ru/showthread.php?p=1108615#post1108615
//determine the correct unregistered custom usergroup
$customUserGroup = $_SESSION['short_print']." ".$newusergroupid;
$ncid = findCustomGroup($customUserGroup);
$newusergroupid = $ncid;
find:
// sort out emails and usergroups
if ($vbulletin->options['verifyemail'])
{
$activateid = build_user_activation_id($userid, (($vbulletin->options['moderatenewmembers'] OR $vbulletin->GPC['coppauser']) ? 4 : 2), 0);

eval(fetch_email_phrases('activateaccount'));

vbmail($email, $subject, $message, true);

} replace with
// sort out emails and usergroups
if ($vbulletin->options['verifyemail'])
{
// multiple site controller by Robert_2004
// https://vborg.vbsupport.ru/showthread.php?p=1108615#post1108615
//with custom registered usergroups it's no longer sufficient to simply pass 4 or 2 to
//the build_user_activation_id() so let's be more dynamic.
//$activateid = build_user_activation_id($userid, (($vbulletin->options['moderatenewmembers'] OR $vbulletin->GPC['coppauser']) ? 4 : 2 ), 0);
//determine the appropriate registered usergroup to pass to build_user_activation_id()
$customRGroup = $_SESSION['short_print']." 2";
$rcid = findCustomGroup($customRGroup);
$activateid = build_user_activation_id($userid, (($vbulletin->options['moderatenewmembers'] OR $vbulletin->GPC['coppauser']) ? 4 : $rcid ), 0);

eval(fetch_email_phrases('activateaccount'));

vbmail($email, $subject, $message, true);

}
find:
($hook = vBulletinHook::fetch_hook('register_activate_start ')) ? eval($hook) : false;

if ($userinfo['usergroupid'] == 3) replace with
($hook = vBulletinHook::fetch_hook('register_activate_start ')) ? eval($hook) : false;

// multiple site controller by Robert_2004
// https://vborg.vbsupport.ru/showthread.php?p=1108615#post1108615
$customUserGroup = $_SESSION['short_print']." ".$newusergroupid;
$ncid = findCustomGroup($customUserGroup);
//grab all the relevant usergroupids for the various "Awaiting Validation" groups
$awug_array = findAwaitingGroups();
//if ($userinfo['usergroupid'] == 3 )
if ($userinfo['usergroupid'] == 3 || in_array($ncid,$awug_array))
find
$users = $db->query_read("
SELECT user.userid, user.usergroupid, username, email, activationid, languageid
FROM " . TABLE_PREFIX . "user AS user
LEFT JOIN " . TABLE_PREFIX . "useractivation AS useractivation ON(user.userid = useractivation.userid AND type = 0)
WHERE email = '" . $db->escape_string($vbulletin->GPC['email']) . "'"
); below, add:

// multiple site controller by Robert_2004
// https://vborg.vbsupport.ru/showthread.php?p=1108615#post1108615
$customUserGroup = $_SESSION['short_print']." ".$newusergroupid;
$ncid = findCustomGroup($customUserGroup);


find
while ($user = $db->fetch_array($users))
{
if ($user['usergroupid'] == 3)
{ // only do it if the user is in the correct usergroup
// make random number
if (empty($user['activationid']))
{ //none exists so create one
$user['activationid'] = build_user_activation_id($user['userid'], 2, 0);
}
else
{
$user['activationid'] = vbrand(0, 100000000);
replace with
while ($user = $db->fetch_array($users))
{
// multiple site controller by Robert_2004
// https://vborg.vbsupport.ru/showthread.php?p=1108615#post1108615
//if ($user['usergroupid'] == 3)
$awug_array = findAwaitingGroups();
if ($user['usergroupid'] == 3 || in_array($ncid,$awug_array))

{ // only do it if the user is in the correct usergroup
// make random number
if (empty($user['activationid']))
{ //none exists so create one
// multiple site controller by Robert_2004
// https://vborg.vbsupport.ru/showthread.php?p=1108615#post1108615
//$user['activationid'] = build_user_activation_id($user['userid'], 2, 0);
if ($user['usergroupid'] == 3){
$ncid = $user['usergroupid'];
}
$user['activationid'] = build_user_activation_id($user['userid'], $ncid, 0);

}
else
{
$user['activationid'] = vbrand(0, 100000000);

find
$userinfo = verify_id('user', $vbulletin->GPC['u'], 1, 1);

if ($userinfo['usergroupid'] == 3) replace with
$userinfo = verify_id('user', $vbulletin->GPC['u'], 1, 1);

// multiple site controller by Robert_2004
// https://vborg.vbsupport.ru/showthread.php?p=1108615#post1108615
$customUserGroup = $_SESSION['short_print']." ".$newusergroupid;
$ncid = findCustomGroup($customUserGroup);
//if ($userinfo['usergroupid'] == 3)
$awug_array = findAwaitingGroups();
if ($userinfo['usergroupid'] == 3 || in_array($ncid,$awug_array))

find
$userinfo = verify_id('user', $vbulletin->GPC['u'], 1, 1);

if ($userinfo['usergroupid'] == 3) replace with
$userinfo = verify_id('user', $vbulletin->GPC['u'], 1, 1);
// multiple site controller by Robert_2004
// https://vborg.vbsupport.ru/showthread.php?p=1108615#post1108615
$customUserGroup = $_SESSION['short_print']." ".$newusergroupid;
$ncid = findCustomGroup($customUserGroup);
//if ($userinfo['usergroupid'] == 3)
$awug_array = findAwaitingGroups();
if ($userinfo['usergroupid'] == 3 || in_array($ncid,$awug_array))




[Step 6 - class_dm_user.php]
find
'usergroupid' => array(TYPE_UINT, REQ_YES, VF_METHOD), below, add
// multiple site controller by Robert_2004
// https://vborg.vbsupport.ru/showthread.php?p=1108615#post1108615
'customusergroupid' =>array(TYPE_UINT, REQ_NO),


[Step 7 - functions.php]
find:
$intperms = array();
$_PERMQUERY = array();

// set the usergroupid of the user's primary usergroup
$USERGROUPID = $user['usergroupid'];
replace with:
$intperms = array();
$_PERMQUERY = array();
// multiple site controller by Robert_2004
// https://vborg.vbsupport.ru/showthread.php?p=1108615#post1108615
// if a user belongs to a custom Unregistered group then assign the custom usergroup id to foruminfo
// so that when they browse the forums we can restrict them accordingly.
if (isset($user['customusergroupid'])){
$USERGROUPID = $user['customusergroupid'];
}
else {
$USERGROUPID = $user['usergroupid'];
}
// set the usergroupid of the user's primary usergroup
//$USERGROUPID = $user['usergroupid'];

[Step 8 - styles]
either create child styles or import your styles
you'll figure out the best way to set them up ;)

[step 9 - add plugins]
adminCP -> plugins -> add new plugin

product - vbulletin
hook location - global_start
title - Domains or anything you want
plugin php code - // PUT A DESCRIPTION HERE
include('/home/{hosting_username}/public_html/domains.php'); (ACTIVATE PLUGIN)

NEXT PLUGIN:
product - vbulletin
hook location - style_fetch
title - Force Style for each Domain
code
if( preg_match('/MyFirstDomain.com/i', $http_host) )
{
$styleid = x; // set this
}
elseif( preg_match('/MySecondDomain.com/i', $http_host) )
{
$styleid = x;
}
(ACTIVATE PLUGIN)


>>>>>>>> AND YOU ARE DONE!

Set all your forums - thee are permissions to set for forums, usergroups, CMPS pages, etc
- remember, all heirarchy works on forums, and usergroups



- now for you to help.
Firstly, CLICK INSTALL >>>>>>>>>>>>>>>>>>>>>>>>>>
- If someone can turn this into a plugin, please go ahead
- if someone can see something to fix - please write it
- if you can help with updating/improving some code - please do it
- this mod is open for anyone and everyone, if you want to do something with it and release it - you are more than welcome to - PM ME so i can put a link & description to your version (i.e if you make a lite version, or a to in a different direction with this mod).
- if you want any features or updates, please write so on this forum - if it's good enough for me, i'll get it done - otherwise we'll see.

Ziki
11-01-2006, 10:12 AM
Can you explain me this I don't really get it.

SkyCatcher
11-01-2006, 10:37 AM
I'm assuming he means we can run multiple instances of vb on a machine and have all those forums share the same database.

Hornstar
11-01-2006, 10:47 AM
This was sounding to good to be true.....

MaestroX
11-01-2006, 11:46 AM
This sounds interesting...

Shazz
11-01-2006, 12:15 PM
Um, this will be removed untill its done -.-

robert_2004
11-01-2006, 12:32 PM
a couple of people have been wanting this, so it will go up over the next few days - please subscribe or bookmark this thread - believe me - it will be worth your time!
a large portion of you are running 2-3 vbulletin sites, and believe me, it's easier to take care of them when they are all under the one server -> hosting account -> files & database :)

robert_2004
11-01-2006, 12:34 PM
Um, this will be removed untill its done -.-

well i can't just post it all up at once - i'm not that smart ^__^ - and if i don't get it up like this, it will never go up - cause i work 16 hour days :(

Shazz
11-01-2006, 12:38 PM
well i can't just post it all up at once - i'm not that smart ^__^ - and if i don't get it up like this, it will never go up - cause i work 16 hour days :(
You should then release it when its ready..

VaaKo
11-01-2006, 12:39 PM
Can you upgrade it to 3.6.x?

C.Birch
11-01-2006, 07:49 PM
does this not break vb's terms of use?

SuperFly
11-02-2006, 03:02 AM
No, it does not create more sites under one license, but if you have multiple licenses with diffrent sites on parts of server, it lets you manage them all in 1.

robert_2004
11-02-2006, 01:53 PM
okay, all the details have been uploaded.
Please test on your localhost/testserver first, otherwise BACKUP YOUR FILES AND DATABASE!!!

jstep
11-12-2006, 02:17 AM
a great hack...just having a bit of trouble installing

I think i did everything

could it be that my first domain is not hte main domain on cpanel, so I had to use a redirect instead?

robert_2004
11-16-2006, 04:14 AM
quite possible - fool around with the domains file

Datenpapst
11-17-2006, 10:04 AM
how far is this hack? Will there be a xml product plugin and will it also work for 3.6.

Any Demo here?

jstep
11-21-2006, 07:04 PM
im hoping for an xml product plugin, but I think robert said he could not do this, and was looking for someone else to do it

C Braithwaite
02-06-2007, 08:34 AM
If i understand the way this works properly, and the vbulletin license, you need to have 1 license per domain (or separate set of content), don't you?

woodysfj40
02-11-2007, 08:46 PM
correct...I keep hoping vB will do a multi-forum setup down the road as an official release...purchasing multi-licenses or a "group" license of sorts.

jahshaka
03-18-2007, 08:40 AM
whats the status of this? i would love to use it but am running vb3.6!!!

ochlocracy
05-23-2007, 10:56 PM
I like the idea, and it's something I'm looking for. I'm just not sure it will do what I want.

I run two forums for motorcycles and I created the 2nd forum off the 1st one so it has all the same forum topics.

I would like to merge the two forums into one, but still show 5 diffrent forums depending on what domain they are on. Would this be possible with this mod?

ie

widget.com has 5 forums dedicated to widgets
gadgets.com has it's 5 forums dedicated to gadgets

and the two domains share the offtopic section

robert_2004
06-05-2007, 10:45 PM
ochlocracy, yes. you would place all the forums into the one area (like normal). then set up the two different sets of usergroups, 2 usergroups for unregistered (one for each site), 2 usergroups for registered, 2 usergroups for moderators, etc.
Then you would set the permissions on each usergroup to view only certain forums.
You then set the supermod and admin to view all the forums, or what ever suits your needs.

One thing - just test the installation on a test server to begin with.
you will need to import the forums and members from one site to the other - and this is really the only thing you need to test to make sure it works. This also means all the thread ids would be given new ids due to the ids already being taken by the other forum.
check to see if the impex will effectively do this for you, otherwise we'll need to create a custom export & import script.

robert_2004
06-05-2007, 10:52 PM
also, some news regarding this script:

all members of this site that have installed this script, please check the last 5% of your member database, either 50 members or members which have registered over the past 2 months.
Check how many are full members, and how many haven't finalised and are still awaiting authorisation.
- is the 'awaiting authorisation' number abnormally high?
- should more people (based on record before installing this hack) be confirming their membership??

i've been noticing this problem with mine - seems people are receiving the confirmation email, but when they click it, it takes them to (my) site and says 'confirmed!'. but it doesn't actually change their membership in the database.
I've had a look through the code, but can't figure out why this bug is occuring.

a) it's only happening to between 30-60% of my new members since installing this script
b) it's a hit and miss. first time i tested was fine, second time it happened.

the problem is located in the register.php page, most likely.

Once this problem is fixed - we'll release an update. if anyone has any thoughts, i'd love to hear them.

Floris
01-09-2008, 09:04 PM
Is there an update on this product, say, a 3.6 plugin / product version?

Alfa1
01-14-2008, 07:41 AM
Very interesting!

robert_2004
01-14-2008, 02:15 PM
i gave up on my site due to lack of hirable programmers.
we're getting back into it this year with a programmer i've been hoping to work with for the past few months - hopefully he will be good, and the site will come back online.
when it does, we'll be moving to vb3.6 and then we'll create an update.

Alfa1
01-14-2008, 11:03 PM
That may be good news then. Check out vb 3.7.

Karri
03-05-2008, 06:41 PM
any news on an update for this?

tazzarkin
03-11-2008, 05:19 PM
did you work on this yet?
--------------
i gave up on my site due to lack of hirable programmers.
we're getting back into it this year with a programmer i've been hoping to work with for the past few months - hopefully he will be good, and the site will come back online.
when it does, we'll be moving to vb3.6 and then we'll create an update.

superthang
03-13-2008, 08:51 PM
updates for 3.7?

shortbus1662
06-11-2008, 08:26 PM
would love to get an update on this.

tazzarkin
06-12-2008, 03:33 PM
it's actually already out there in one form or another. i can't remember the location, but it is there somewhere.

robert_2004
06-21-2008, 11:41 AM
hi guys,
An update to this script will be coming shortly - maybe a month or so.
it should work on vb3.7 - i'll be testing this out - again, within a month.

the next update will try to be as much of a product as possible.
Please help me by posting on the mod site your comments and criticism about the current version.
if you stopped using it - please tell me why.
if you want some extra features - please post it on this page.