[MOD] Integrate SMF with your CPG [CPG 1.4.X] [MOD] Integrate SMF with your CPG [CPG 1.4.X]
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

[MOD] Integrate SMF with your CPG [CPG 1.4.X]

Started by just_some_guy, August 19, 2007, 12:48:01 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

just_some_guy



The goal I wanted to achieve when making this mod was to add a forum to my website and not lose all members when doing this. Most of you will say "That's easy just bridge it" Well, the downside of bridging in my case was losing all current members and user groups. Also when bridging your CPG with SMF the forum will become priority and when logging into the gallery you will start of at the forum.

This way, when logging in you use the CPG login as usual and your CPG simply has a link to the forum where the member can then sign in to the forum and post. With this mod any new registers will automatically become members of the forum. All current members will be transferred to the SMF forum and become members. All users will be "saved".

Files that require editing: register.php and your database.

Let's start.

Step 1. Backup all files and the database – This is very important as you will be editing the database and if you make a mistake then you could risk losing all members, I can't stress how important it is to do this.

Step 2. Using a tool like phpmyadmin (this is what used) run the following query on the database. (Assuming that you kept the default table prefixes when installing SMF and CPG) if changed then you will have to edit the code to suit you. If you already have members in this table you will probably need to truncate it.
Query:

insert
  into smf_members
     ( memberName
     , passwd
     , emailAddress
     , realName )
select user_name
     , user_password
     , user_email
     , user_name
from cpg1411_users


This will copy all current users of CPG into SMF

When you transfer the users and your admin account on the SMF gets lost do this:

Open up table: smf_members table and find your admin username. And edit it so your ID_GROUP appears as 1. This is manually making your self an admin,


Step 3. Now we need to make all new registrations members of the SMF too. Open register.php and find:

$sql = "INSERT INTO {$CONFIG['TABLE_USERS']} ".
           "(user_regdate, user_active, user_actkey, user_name, user_password, user_email, user_profile1, user_profile2, user_profile3, user_profile4, user_profile5, user_profile6) ".
           "VALUES (NOW(), '$active', '$act_key', '" . addslashes($user_name) . "', '" . addslashes($encpassword) . "', '" . addslashes($email) . "', '$profile1', '$profile2', '$profile3', '$profile4', '$profile5', '$profile6')";
           
if ($CONFIG['log_mode'])
{
        log_write('New user "'.addslashes($user_name).'" created on '.date("F j, Y, g:i a"),CPG_ACCESS_LOG);
    }
         
    $result = cpg_db_query($sql);


And on the line after  "$result = cpg_db_query($sql);"

Add :

$sql= "INSERT INTO smf_members".
   "(memberName, passwd, emailAddress, realName) ".
   "VALUES ('" . addslashes($user_name) . "', '" . addslashes($encpassword) . "', '" . addslashes($email)."','" . addslashes($user_name) . "')" ;

$result = cpg_db_query($sql);


Obviously if you changed the default prefixes when you installed SMF and CMG then you will need to edit the above to suit you.

You will notice in the smf_members table there are many more columns. From what I have found these can be changed in the profile or automatically as the user uses the forum.

As with bridging the user may not show in the SMF memberlist.

All that's left is to do a test run it. I haven't tested making people moderators etc, but I think this can be done the same way as manually making your self an admin. You will need to find the number that a moderator corresponds with. (Example: Admin = 1 and Member = 0).

This is my first mod, hope you like it and it proves useful. It did for me!

1 known issue: If a user selects to hide their email address it appears as hidden in their profile nut not in their post.

Demo:

Gallery: http://www.mysimtractor.com
Forum: http://www.mysimtractor.com/forum

Thanks, to Sami and the devshed forums for the help.

just_some_guy
Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Joachim Müller


just_some_guy

Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

just_some_guy

Another note: This MOD will only work if you have installed Simple Machines Forum on the same database as your Coppermine Gallery. If you havent, i will try and post instructions on this soon.

Also i have been using this mod for a day now and seems to be working well i have received new members today too and they are also members of the forum.

just_some_guy,
Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

just_some_guy

Can this be a mod then...? It works fine.

I am currently working on a installation script that you run which will make it easier to install.
Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Joachim Müller

Quote from: just_some_guy on August 21, 2007, 04:24:04 PM
Can this be a mod then...?
If someone reviews it and confirms that it works - as I suggested above:
Quote from: GauGau on August 19, 2007, 12:50:32 PM
Can someone please review the suggestion?