Web Hosting Forum | Lunarpages
News: April 3, 2008 - New Contest! - Win 5 Years of Hosting and $1,000!
June 30, 2008 - Submit Your Site for the July 08 Site of the Month Award!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 05, 2008, 01:49:56 PM


Login with username, password and session length


Pages: [1] 2   Go Down
  Print  
Author Topic: [HOW TO] Integrate Coppermine into SMF  (Read 11184 times)
Dominic
Trekkie
**
Offline Offline

Posts: 14



WWW
« on: October 14, 2005, 09:32:12 AM »

First, It is a long post, and i hope Forum Moderators will move it into the How-To's section.
Second, please excuse any bad typing/sentences, english is a second language to me.

Since it took me a lot of time to look for the right infos on how to integrate Coppermine Into SMF,
I decided i'd share it, so other people might avoid the process of looking at 8 different places Very Happy

It's not that hard to integrate, even if it does not look like it.

I don't take credit for it, i added my 2 cents to  this Post and  this One on SMF Forums. But i will add some informations that are particular to LP's setup.

This is for SMF 1.0.5 and Coppermine 1.3.5

Lets Begin
 Applause

First, Install SMF from Fantastico.
Make sure it runs correctly as Standalone,
and change the cookie name to something other than the default(in the admin panel/server params of SMF), This is to prevent other SMF site you are browsing to clear the cookie if the all use the default.
I'll take it you installed SMF into folder /smf


Second Step: Installing and Integrating Coppermine into SMF
Do not install Coppermine from Fantastico, or it will create it's own MySQL DataBase! And this integration requires Both Coppermine And SMF to share the same DB[/i]

To start, you'll need to download Coppermine on your computer.

Once downloaded, rename the unzipped coppermine folder named
cpg135
to
gallery or anything you'd like, (remember the name you will give it)
then follow these instructions to properly integrate Coppermine with your SMF forum.

In /include/init.inc.php, find:
Code:
// define('UDB_INTEGRATION', 'smf');

Replace with:
Code:
define('UDB_INTEGRATION', 'smf');

In /bridge/smf.inc.php, find:
Code:
$path = '../smf';

Replace /smf with the directory you have your SMF forum installed in, without the public_html

Once all necessary changes have been made, upload Coppermine to its own directory (examples: /public_html/gallery). 

Since SMF is installed via fantastico, you'll need to "steal" the SMF MySql database informations from the settings.php file in the forum root folder to put in the Coppermine setup:

Ftp to your Lunarpages Account, go in /public_html/smf/ (replace /smf with the folder name of the forum.
Open the file settings.php and look for the following:
Code:
########## Database Info ##########
$db_server = 'localhost';
$db_name = 'Something_smf1';
$db_user = 'Something_smf1';
$db_passwd = 'some password';

Note those, you will need them soon.

Now,from you web Browser run Coppermine's install.php.
(h**p://yoursite.com/gallery/install.php).
When asked about the database settings, Make sure you install Coppermine on the same database as that of your SMF forum. (use what you noted from the above 4 lines) Once installed, your new Coppermine gallery will be up and ready for use sharing the users and groups with your SMF forum Smile.

Creating the Navigation button for SMF to link to the Gallery
Create yourself a Gallery button, name it gallery.gif, place it into the proper theme folder you are using in SMF. ex:
/SMF/Themes/default/images/english/
if you are using the default theme or
/SMF/Themes/ThemeName/images/english
for a custom theme.
There is a SMF button Generator here

Now you have 2 options, either Open the Gallery in a new Window, or have it display inside the forum body, choose the one that best suits you..
If you decide to have the gallery open in a new browser window, do the following:

Edit the SMF index.template.php file on the theme you are using with BBedit(MAC) or Notepad(PC)
look for the following lines:(at the end)

Code:
// Otherwise, they might want to [logout]...
else {
echo '<a href="', $scripturl, '?action=logout;sesc=', $context['session_id'],
    '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url']
    . '/' . $context['user']['language'] . '/logout.gif" alt="' . $txt[108]
    . '" style="margin: 2px 0;" border="0" />' : $txt[108]),'</a>';

insert the following code between the else{ and echo '<a href="', $scripturl, '?action=logout;(...)

(change the "../gallery" on the  first line to match the name of the coppermine folder)

Code:
   echo '<a href="../gallery" >',
    ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url']
    . '/' . $context['user']['language'] . '/gallery.gif" alt="Photo Gallery" style="margin: 2px 0;"
    border="0" />' : "Photo Gallery"),'</a>', $context['menu_separator'];

Placing the code there will make the Gallery button display only when users are logged in into the forum, at the end of the button row, just before the logout button.
If you did add the above code, skip the following section

If you want to make coppermine display into the forum page itself do the following:
1. open /smf/index.php
2. find this line:

Code:
'boardrecount' => array('Admin.php', 'AdminBoardRecount'),
and after that code add this code:
Code:
'coppermine' => array('Coppermine.php', 'Coppermine'),

3. create a file called Coppermine.php with your text-only editor such as NotePad (PC) or BBEdit (Mac) and add this code inside it:
Code:
<?php
if (!defined('SMF'))
die('Hacking attempt...');

function 
Coppermine() {
// This is gonna be needed...
loadTemplate('Coppermine');
}
?>
4. save this file inside /smf/Sources

5. create a file called Coppermine.template.php with your text-only editor such as NotePad (PC) or BBEdit (Mac) and add this code inside it:
Code:
<?php

function template_main()
{
     global $context$settings$options$txt$scripturl;

        echo '
        <script language="JavaScript" type="text/javascript"><!--
                function checkAll(onOff)
                {
                        for (var i = 0; i < document.searchform.elements.length; i++)
                        {
                                if (document.searchform.elements[i].name.substr(0, 3) == "brd")
                                        document.searchform.elements[i].checked = onOff;
                        }
                }
        // --></script>
        <form action="'
$scripturl'?action=search2" method="post" name="searchform" id="searchform">
                <table width="80%" border="0" cellspacing="0" cellpadding="3" align="center">
                        <tr>
                                <td>'
theme_linktree(), '</td>
                        </tr>
                </table>

                <table width="100%"  border="0" cellspacing="0" cellpadding="4" align="center" class="tborder">
                        <tr class="titlebg">
                                <td>Coppermine Photo Gallery</td>
                        </tr><tr>
                                <td class="windowbg">'
;

                                        // load coppermine
        echo '<iframe width="100%" height="450"
src="http://YourSite.com/gallery"></iframe>'
;

        echo '
                                </td>
                        </tr>
                </table>
        </form>'
;
}

?>

Note the address in the above code, change this to reflect your Coppermine folder name and make sure to leave out the www so as to keep compatability with firefox and IE

The original help i found adds /index.php at the end of the URL, don't put it there, since it will disable the automatic user login from the forum and makes the gallery display as unregistered user.

6. save this file inside /smf/Themes/default/

7. in that same folder open /smf/Themes/default/index.template.php (or /smf/Themes/ThemeName/index.template.php) and at the end of the file find this bit of code:
The original post have you look for the calendar section to add the code, i'm changing it in order to have the Gallery button display only when the user is Logged-in
Code:
// Otherwise, they might want to [logout]...
else {
echo '<a href="', $scripturl, '?action=logout;sesc=', $context['session_id'],
    '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url']
    . '/' . $context['user']['language'] . '/logout.gif" alt="' . $txt[108]
    . '" style="margin: 2px 0;" border="0" />' : $txt[108]),'</a>';

insert the following code between the else{ and echo '<a href="', $scripturl, '?action=logout;(...)
Code:
//begin gallery code
                echo '
                                <a href="', $scripturl, '?action=coppermine"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/gallery.gif" alt="' . "Gallery" . '" style="margin: 2px 0;" border="0" /></a>', $context['menu_separator'];
//end gallery code

Now, Preventing navigation Errors
This step has to be done depending on what type of display you choosed above!
In order to prevent coppermine Logout errors and the forum displaying in a loop insde the iframe if integrated into the forum display, we have to edit the Coppermine theme file you are using.

if If you have the Photo gallery open in a blank page, do the following;
Open the coppermine theme.php file you are using (ex:/gallery/theme/classic/theme.php
and replace everything that is between the
<!-- BEGIN logout -->
<!-- END logout -->

to have it look like this:
Code:
<!-- BEGIN logout -->
                                               <a href="../forum/index.php">Back to forum</a> |
<!-- END logout -->
So this will close the Coppermine page and send the user back to the forum index, using the cookie to remember the login and password of the user.

If you did include the Gallery Into the iframe of the forum ,Do the following:
It's better to disable the profile and logout buttons of coppermine so as the register button(since registration is handled by the forum...
to do so, Open the coppermine theme.php file you are using (ex:/gallery/theme/classic/theme.php
and clear the lines between the register, login and logout tags, so that it looks like this:
Code:
define('THEME_HAS_RATING_GRAPHICS', 1);
// HTML template for main menu
$template_main_menu1 = <<<EOT
                                                |
<!-- BEGIN my_gallery -->
                                                <a href="{MY_GAL_TGT}" title="{MY_GAL_TITLE}">{MY_GAL_LNK}</a> |
<!-- END my_gallery -->
<!-- BEGIN allow_memberlist -->
                                                <a href="{MEMBERLIST_TGT}" title="{MEMBERLIST_TITLE}">{MEMBERLIST_LNK}</a> |
<!-- END allow_memberlist -->
<!-- BEGIN my_profile -->
                                         
<!-- END my_profile -->
<!-- BEGIN faq -->
                        <a href="{FAQ_TGT}" title="{FAQ_TITLE}">{FAQ_LNK}</a> |
<!-- END faq -->
<!-- BEGIN enter_admin_mode -->
                                                <a href="{ADM_MODE_TGT}" title="{ADM_MODE_TITLE}">{ADM_MODE_LNK}</a> |
<!-- END enter_admin_mode -->
<!-- BEGIN leave_admin_mode -->
                                                <a href="{USR_MODE_TGT}" title="{USR_MODE_TITLE}">{USR_MODE_LNK}</a> |
<!-- END leave_admin_mode -->
<!-- BEGIN upload_pic -->
                                                <a href="{UPL_PIC_TGT}" title="{UPL_PIC_TITLE}">{UPL_PIC_LNK}</a> |
<!-- END upload_pic -->
<!-- BEGIN register -->
                                               
<!-- END register -->
<!-- BEGIN login -->
                                             
<!-- END login -->

<!-- BEGIN logout -->
                                             
<!-- END logout -->
EOT;

And that's it! Thumbs Up

Below are some optionals steps you can do, for functionality:
1-If you want to prevent unregistered users to see the Gallery by typing direct url like h**p://yoursite.com/gallery, simply add the following code to the file /gallery/index.php

Look for
Code:
require('include/init.inc.php');

And add this on a new line after the semicolon
Code:
//Prevent Unregistered users
if (USER_ID){

} else {
{
  $redirect = $redirect . "../forum/index.php";
      header("Location: $redirect");

  exit();
}}
//end Prevent Unregistered users
This will forward all non-logged/unregistered users to the login/subscribe page of SMF

2-You could also give the possibility to your users to open the gallery in a new window even if integrated into the forum, easy way is to edit the coppermine.template.php file and adding a href in the title bar of the forum section, still protected by forum logins...
Changing
Code:
<table width="100%"  border="0" cellspacing="0" cellpadding="4" align="center" class="tborder">
                        <tr class="titlebg">
                                <td>Coppermine Photo Gallery</td>
                        </tr><tr>
                                <td class="windowbg">';
to
Code:
<table width="100%"  border="0" cellspacing="0" cellpadding="4" align="center" class="tborder">
                        <tr class="titlebg">
                                <td>Coppermine Photo Gallery  Open the photo gallery on a new page by clicking <a href="http://yoursite.com/gallery"target="_blank">here</a></td>
                        </tr><tr>
                                <td class="windowbg">';


I hope this helps, and that you will like the integration possibilty as much as I do

Dominic
Logged
Monica
Pong! (the videogame) Master
*****
Offline Offline

Posts: 28


r0xx0rs your s0xx0rs


« Reply #1 on: October 18, 2005, 07:54:49 AM »

Thanks for posting this Dominic  Thumbs Up
Logged

.•º¨٭¨º•{ Monica }•º¨٭¨º•.

Superman - "Self-help books? You don't seem the type."

Randal Savage - "I read whatever I can...Anyways, I've got issues, what with me destroying the world and all."
TranzNDance
Princess of Naboo
Berserker Poster
*****
Offline Offline

Posts: 11966



WWW
« Reply #2 on: October 18, 2005, 08:10:43 AM »

Was this posted in the coppermine board, too? If not, it should. Smile

(There is one for cpg 1.4 but not 1.3)
« Last Edit: October 18, 2005, 08:16:08 AM by TranzNDance » Logged

Grr..!! Luff Ya Grr..!! Luff Ya Grr..!! Luff Ya
Dominic
Trekkie
**
Offline Offline

Posts: 14



WWW
« Reply #3 on: October 18, 2005, 08:51:04 AM »

Was this posted in the coppermine board, too? If not, it should. Smile

(There is one for cpg 1.4 but not 1.3)

It is Now!
 Applause

Dom
Logged
TranzNDance
Princess of Naboo
Berserker Poster
*****
Offline Offline

Posts: 11966



WWW
« Reply #4 on: October 18, 2005, 09:36:24 AM »

Thanks! Thumbs Up
Logged

Grr..!! Luff Ya Grr..!! Luff Ya Grr..!! Luff Ya
dodgebill
Trekkie
**
Offline Offline

Posts: 15


« Reply #5 on: November 02, 2005, 06:47:19 PM »

I'm trying this but having trouble. I get an error message as soon as I install coppermine. http://www.offroadexchange.com/gallery/

I double and triple checked everything. It's all good. Any ideas? I have been having some problems with SMF on some users. They get a 500 error but not always.

Bill Cooke
Logged
Nibbler
21st century digital boy
Master Jedi
*****
Offline Offline

Posts: 1184



WWW
« Reply #6 on: November 02, 2005, 07:11:14 PM »

You need to make a slight change to the bridge file for SMF 1.1

http://coppermine-gallery.net/forum/index.php?topic=22015.msg100774#msg100774
Logged

Missing since 1983

dodgebill
Trekkie
**
Offline Offline

Posts: 15


« Reply #7 on: November 02, 2005, 10:23:07 PM »

That did it. I swear Nibbler, you are my gaurdian angel or something. I'll try not to get in any more trouble for a few days. You must be tired from fixing all my problems.

Thanks again

Bill Cooke
Logged
racer_ex
Space Explorer
***
Offline Offline

Posts: 7


« Reply #8 on: December 16, 2005, 01:53:40 PM »

Cool website DodgeBill. Any other examples of this MOD at work?
Logged
ultraming
Trekkie
**
Offline Offline

Posts: 14


« Reply #9 on: January 05, 2006, 11:41:24 AM »

Is it applicable to CPG 1.4.3? 
I cannot find
// define('UDB_INTEGRATION', 'smf');
in the init.inc.php file.

Thanks.
Logged
TranzNDance
Princess of Naboo
Berserker Poster
*****
Offline Offline

Posts: 11966



WWW
« Reply #10 on: January 05, 2006, 01:16:18 PM »

There is another method for 1.4x http://coppermine-gallery.net/forum/index.php?topic=25877.0
Logged

Grr..!! Luff Ya Grr..!! Luff Ya Grr..!! Luff Ya
tonyd812003
Newbie
*
Offline Offline

Posts: 1


« Reply #11 on: January 14, 2006, 09:15:29 PM »

Great tutorial!

I have a few problems after bridging through..

If I login to SMF as admin, I cannot see any admin links in CPG, so I can't administer the gallery.

If I login as a regular member, I can't create any galleries, becase the only links listed are:
(these are the only links displayed if I login as admin (throhgh SMF) as well..

  • Album list ::
  • Last uploads ::
  • Last comments ::
  • Most viewed ::
  • Top rated ::
  • My Favorites ::
  • Search

Any ideas on how to fix this??
Thanks a million,
Terry
Logged
Dominic
Trekkie
**
Offline Offline

Posts: 14



WWW
« Reply #12 on: January 16, 2006, 10:31:59 AM »

That is strange, you don'd see the switch to admin panel under the "@", just besides the Upload an image?

wich version of Coppermine you use?
Logged
Dominic
Trekkie
**
Offline Offline

Posts: 14



WWW
« Reply #13 on: February 07, 2006, 08:28:07 AM »

Just to let you Know,

If you installed and Bridged Smf 1.0.5 and coppermine 1.3.5 as said in the howto above, you will be able to update your forum to smf 1.0.6 using the packages manager of the forum, and update coppermint to version 1.4.3, and then use the bridge manager..

you will not lose any pictures, but the permissions table of the photo gallery have to be redone, all the rest keeps working.

so, Update to SMF 1.0.6 via Package manager in the Admin section of your forum,
then follow These instructions to update Coppermine 1.3.X to 1.4.3
and finally, read This to re-activate the bridge bbetween both updated versions.

Enjoy Applause

Dom
Logged
Dominic
Trekkie
**
Offline Offline

Posts: 14



WWW
« Reply #14 on: February 17, 2006, 08:32:01 AM »

In order to see if a user is currently in the gallery while looking into the who's online section of SMF do the following:

in /gallery/bridge/smf.inc.php
find:
Code:
$pwseed = SMF_PASSWD_SEED;
make sure the section under it looks like this:
Code:
session_start();

        reloadSettings();
        LoadUserSettings();
        $_GET['action'] = 'coppermine'; writeLog();

then in /forum/themes/default/languages/who.english.php
add the following around line #37
Code:
$txt['whoall_coppermine'] = 'Browsing the Photo Gallery';

and there you go  Applause

Dom
Logged
Pages: [1] 2   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM