News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Successfully Fusing 2 SMF Sources to 2 different SQL Databases

Started by Taharok, January 09, 2007, 09:03:58 PM

Previous topic - Next topic

Taharok

It took my eight days to finally figure this out, so the tutorial might not be 100%. My idea was to fuse two different SMF sources in only certain areas using two different SQL DBs. This would end the SMF - SQL Connection Errors. It is more effecient, but causes a lot more bugs and takes up a little more space. Basicly, there is one main SQL Host with one Database. There are two different Prefixes (also considered databases to most people) for each SMF to call upon. I would recommend that you use two different prefixes and not an empty prefix. This tutorial might not be for everyone because there is a lot of editing to do and a lot of risks to your SMF server. Do not attempt this unless you have a backup of your SQL DB (unless you are starting from scratch.)

Here are the chapters we will be covering in this tutorial:

Chapter 1 ~ Getting a webserver to start on (if you already have a webserver, skip to chapter 2.)

Chapter 2 ~ Setting up the primary SQL DB and user using CPanel (again, if this is already finished, skip to chapter 3.)

Chapter 3 ~ Creating the first and primary SMF source (if you already have one, back it up and skip to chapter 4.)

Chapter 4 ~ Creating the secondary SMF source and configuring it for fusion use.

Chapter 5 ~ Getting started and settled-in before the fusion (this includes installing packages and other themes.)

Chapter 6 ~ Choosing the PHP Files to fuse and how to fuse them without screwing up.

Chapter 7 ~ Fusing the the list you saw in Chapter 7.

Chapter 8 ~ Final notes and explanations.

*NOTE* You CANNOT use Fantastico when creating these SMFs. It defeats the entire purpose and will not work, unless you reconfigure the SMF by hand. My method makes it a lot easier.

---------------------------------------------------------------------------------------------------

Chapter 1 ~ Getting a webserver to start on (if you already have a webserver, skip to chapter 2.)

First of all, we will need a webserver to even attempt to make this work. I prefer any webserver with FTP access and a CPanel. I personally use Nationvoice [nofollow] but you could use Netfirms or another webserving company as well.

If you are using nationvoice, then click the 'Signup Now!' button which is clearly shown:



After that, select the free package (unless you want to pay). Then select your sub domain name. After that fill out the form with real information:



Most people do not get the detailed email on it, but that is okay! Try immediatly after you sign up or a day/a few days after the sign up and your webserver should be there. Make sure you are fluent with the CPanel before starting the installation (mainly the MySQL Databases section and PHPMyAdmin.)



To access your CPanel, use this address:

http://[yoursubdomain].nationvoice.com/cpanel

Now you will be able to continue to Chapter 2.

---------------------------------------------------------------------------------------------------

Chapter 2 ~ Setting up the primary SQL DB and user using CPanel (again, if this is already finished, skip to chapter 3.)

Go into the SQL Databases part in your CPanel. Now, click the 'New Database' button shown below:



Now, make the name of the Database the SAME name you use to log onto the CPanel.

Now, we will need to create the SQL User. Click the 'new user' button shown also in the above picture. The name of the user needs to be the same name as the DB name AND needs to have the same password you use to log onto the CPanel.

Finally, if you follow my above steps exactly you should be set for Chapter 3.

---------------------------------------------------------------------------------------------------

Chapter 3 ~ Creating the first and primary SMF source (if you already have one, back it up and skip to chapter 4.)

Now we will be setting up the primary SMF source. You will need to log onto the ftp for this using this address:

ftp://[yoursubdomain].nationvoice.com/

Now log into the FTP (you might have to right click and click 'Login As'):



Now, go into your Public_Http folder and right click and click 'New' -> 'New Folder'. Preferably make the name:


smf


You will need to use the webinstall that you can get by this link:

http://www.simplemachines.org/download/index.php?thanks;filename=webinstall.php

Upload (by copying and pasting) the webinstall.php from wherever you downloaded it from on your computer to your forums folder (the folder you created earlier.) Now, go to this address:

http://[yoursubdomain].nationvoice.com/smf/webinstall.php

You will see this:



Now, fill out your FTP information (leave basicly everything normal except the password because everything is filled in by default, except the password.) You do not have to enter your SMF login information if you do not have any or if you do not desire to.

After you have filled out the correct information, agree to the terms and conditions and then click the 'continue' button. It will not download the full SMF 1.1.1 and the Install.php. You will then be redirected to Install.php. Now, fill it out like this:



If you get a SQL connection problem, that is because you did not use the username and password for the SQL user you made or because you did not enter the correct fields. Hopefully, you get past this part because it is a extremely aggrivating part to manage. Fill out the username and password for your administrative account.



Now, you should come up to this page if it successfully connected to the SQL Database and created the prefix + the tables:



It will have the option to delete the install.php and webinstall.php, DO IT. It is a security issue if those PHP files are not removed from your SMF directory. Finish up the last page similar to the one I provided above.

You should now be all set up for Chapter 4. You can access your forums from this:
http://[yoursubdomain].nationvoice.com/smf/index.php

---------------------------------------------------------------------------------------------------

Chapter 4 ~ Creating the secondary SMF source and configuring it for fusion use.

You will first of all need to create another folder in the 'Public_Http'. The name of it would preferable and probably intelligently the name of your secondary forums. Now upload your webinstall.php into this folder. Go to the new address and set up the webinstall similar to the other SMF:



Now, set up the rest of the forums similar to the pictures I provided above (in Chapter 3) and make sure you deleted install.php and webinstall.php after the forums are set up.

Now log back onto the FTP server (unless you are still on it) and once again go into the 'Public_Http' -> '[yoursecondSMFforums]'. Now, you should see a lot of folders and PHP files (if not, refresh the page.) You will see one called 'Settings.php'. Download (copying and pasting) that to safe and known directory on your computer. You can edit PHP files with Notepad or Wordpad (Wordpad or a PHP Environmental Program prefered.) Now you need to find this:


$db_prefix =


UNDERNEATH that string add this one:


$db_prefix = 'smf_';


Now save that and reupload it to your secondary source folder and replace the old settins.php. You are now prepared for Chapter 5.

---------------------------------------------------------------------------------------------------

Chapter 5 ~ Getting started and settled-in before the fusion (this includes installing packages and other themes.)

Basicly, this chapter is an overview of what we will do in Chapter 6 and some pre-setups before the fusion. Since this is basicly a Beta, it is somewhat 'crude'. What I mean be 'crude', is that certain things need to be done before others otherwise your forums will not run properly.

We will want to make sure all of our packages on these forums are uploaded before we carry out the fusion. I would prefer for you to use the same packages you have used your main SMF forums. This is becuase most of the admin.php is shared between the forums. The reason why you need to upload before the fusion is because it is rare to be able to upload and install packages after the fusion. I have personally gotten it to work on my secondary forums,  but I will add that later in Chapter 9. After your downloads and installations, we can learn a bit more about Chapter 6.

Note: This will not effect your packages on your main SMF forums.

The fusion will consist of simply replacing certain prefix strings with our prefix string so that section of code will load and save into the primary SQL DB Tables. This is the entire base behing my fusion. After you have set up the packages (uploading/downloading and installing), you should be prepared for Chapter 6.

---------------------------------------------------------------------------------------------------

Chapter 6 ~ Choosing the PHP Files to fuse and how to fuse them without screwing up.

This Chapter will have a lot of edits to it. This is what makes this entire tutorial a 'Beta'. I will prepare a list of all the PHP files that you will need to edit for the following fusions (I will add more files to make more fusions):


  • The entire core to the fusion - Load.php, subs.php
  • Fusing all the members - ManageMembers.php, Subs-Members.php
  • Fusing the registrations of users - Register.php, ManageRegistration.php
  • Fusing the Loging in and Out users and the creation and drops of sessions - LogInOut.php
  • Fusing the memberlegend on the Board Index - BoardIndex.php
  • Creating the member profile link of the last post on a certain Board - BoardIndex.php
  • Fusing the statistics on the forums and personalizing it - stats.php
  • Fusing the Membergroup Permissions - ManagePermissions.php
  • Fusing the memberlists - Memberlist.php
  • Fusing the bans on the forums - ManageBans.php
  • Fusing the attachments on the forums - ManageAttachments.php
  • Fusing the personal message index - PersonalMessage.php, MessageIndex.php
  • Fusing Smileys between the SMFs - ManageSmileys.php
  • Fusing the moderation logs on the forums - ModLog.php
  • Fusing Forum news - News.php, ManageNews.php
  • Fusing the Forum Calender - ManageCalender.php, Calender.php
  • Fusing the Forum Errors - ManageErrors.php, Errors.php

We will go through each of these in Chapter 7. Now you will want to save time, download all of these PHP files I provided above into that same directory as Settings.php. You will find all the above PHP files in the folder called 'Sources' which is located in your SMF directory (remember, the PHP files from the second SMF forums.) This will allow easy access with the PHP files when you are creating the fusion. After you are done downloading all of these PHP files, you should be prepared for Chapter 7.

---------------------------------------------------------------------------------------------------

Chapter 7 ~ Fusing the the list you saw in Chapter 7.

I will go as indetail about the fusion PHP files as I can, so bear with me. My instructions will be the easiest you will receive. It is an easy method we wil be using. I call the method: "Ctrl + H":



Simply use this process for all the PHP files unless I ask or to use "Ctrl + F" (find.) Now begins the mini-tutorial through all the PHP files:

==========================

Open up Load.php.

Load.php: Search (using Ctrl  + F) for this:


reloadSettings()


It will say this:


global $modSettings, $db_prefix, $boarddir, $func, $txt, $db_character_set;


Replace the '$db_prefix' with '$db2_prefix'.

Now, replace all of the '$db_prefix' after the 'reloadSettings' with '$db2_prefix' all the way down to 'loadBoard()'.

Now search for this:


loadPermissions()


Now, replace all of the '$db_prefix' after the 'loadPermissions' with '$db2_prefix' all the way down to 'loadTheme($ID_THEME = 0, $initialize = true)'.

Next, search for this:


sessionRead($session_id)


Replace '$db_prefix' with '$db2_prefix' underneath 'sessionRead($session_id)' all the way down to 'cache_put_data($key, $value, $ttl = 120)'.

Now save Load.php.

Open up Subs.php. Search for this:


updateStats($type, $parameter1 = null, $parameter2 = null)


Replace '$db_prefix' with '$db2_prefix' underneath 'updateStats($type, $parameter1 = null, $parameter2 = null)' all the way down to 'updateSettings($changeArray, $update = false)'.

Now save subs.php.

==========================

THE NEXT STEP DOES NOT INCLUDE Subs.php, Load.php, and BoardIndex.php. MAKE SURE THAT YOU DO NOT USE THE FOLLOWING METHOD FOR THOSE PHP FILES.

The next ones are easy. Load.php and Subs.php are the hardest because we do not want everything replaced. Most of the next files will replace each other fully. Open up each of the PHP files that are in the above list and use the Find and Replace I showed you. Have the 'Find What' $db_prefix and the 'replace with' $db2_prefix. Use the 'Replace all'. Do this for each of the PHP files in the list except Subs.php, Load.php, and BoardIndex.php. REMEMBER to save each one after you are done replacing the strings.

==========================

We are almost done. We have configured the two most important fusion files and all of the feature fusion PHP files. Now to add a few more display fusions, we need to modify BoardIndex.php. Search for this:


BoardIndex()


Now you should see this:


global $txt, $scripturl, $db_prefix, $ID_MEMBER, $user_info, $sourcedir;


Change it to this:


global $txt, $scripturl, $db_prefix, $db2_prefix, $ID_MEMBER, $user_info, $sourcedir;


Now, search for this:


LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "


Replace the '$db_prefix' with '$db2_prefix' for this code. Now search for this:


LEFT JOIN {$db2_prefix}members AS mods_mem ON (mods_mem.ID_MEMBER = mods.ID_MEMBER)


Replace the '$db_prefix' with '$db2_prefix' for this code. Now search for this code:


$result = db_query("


Underneath it you will see this:


// Load the users online right now.
$result = db_query("
SELECT
lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP, mg.groupName
FROM {$db_prefix}log_online AS lo
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lo.ID_MEMBER)
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))", __FILE__, __LINE__);

$context['users_online'] = array();
$context['list_users_online'] = array();
$context['online_groups'] = array();
$context['num_guests'] = 0;
$context['num_buddies'] = 0;
$context['num_users_hidden'] = 0;


Change it to this:


// Load the users online right now.
$result = db_query("
SELECT
lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP, mg.groupName
FROM {$db2_prefix}log_online AS lo
LEFT JOIN {$db2_prefix}members AS mem ON (mem.ID_MEMBER = lo.ID_MEMBER)
LEFT JOIN {$db2_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))", __FILE__, __LINE__);

$context['users_online'] = array();
$context['list_users_online'] = array();
$context['online_groups'] = array();
$context['num_guests'] = 0;
$context['num_buddies'] = 0;
$context['num_users_hidden'] = 0;


Save BoardIndex.php and continue to the final step.

==========================

Congratulations, you are very close to finishing the fusion. Now that you have successfully finished the last three steps, you need to upload and replace all of those PHP files. They will be replaced from where you got them from (the Sources folder.) Now you can refresh the page on your second forums. Congratulations, your forums are now joined in certain areas. Continue to Chapter 8 for reported issues and explanations/furture updates and et cetera.

---------------------------------------------------------------------------------------------------

Chapter 8 ~ Final notes and explanations.

Now that you have read and hopefully used my five hour tutorial, you should appreciate the fact that it is possible to fuse and unfuse a database. I may go into unfusing in this tutorial, but I am not sure. This tutorial possibly and most likely will be added to in the furture. This includes more working source lists. Feel free to do fuse whatever you want, but I take no responsibilities for any invalid or corrupt source files. If you follow my tutorial, it work perfectly. If you have suggestions, development comments, or questions on this tutorial, please Private Message me or post about it on this topic.

If you want to see this tutorial in action, look at these two different forums sites that I adminisrtate and have set up:

Raging Coders Forums [nofollow]
Ragesoft RSPS Forums [nofollow]

---------------------------------------------------------------------------------------------------

This tutorial is for learning purposes only. It may only be recopied with permission from Mod Taharok and you must give credits to him.

This tutorial is © 2006-2007 Mod Taharok, Grene Penguin Entertainment, All Rights Reserved.

Taharok

I spend 5 hours working on this and yet no one responds. Why is it that everyone else's topics are more posted in then mine?

vbgamer45

This might not be the best forum for this post. Maybe change the topic title as well.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Taharok

Where exactly would it belong and what would you prefer for the title...?

vbgamer45

Well the title sounds more like a question than a guide I would try the SMF Coding Discussion or the Tips and Tricks forum.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Taharok


The Game

so if I am not mistaken, this tut helps me make a new forum?? SICK!!

The Game

Ok the tut is very nice but I am stuck at that 'aggravating part.' Can you help??  

Advertisement: