Support Forum Project Downloads FAQ Documentation About Demo Tutorials Blog Plugins
July 05, 2009, 01:57:12 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Maintenance release cpg1.4.25 - upgrade recommended
The Coppermine development team is releasing an update for Coppermine in order to fix an issue with http uploads that could occur in particular versions of PHP.The fix is not security-critical, so if your gallery is running fine with cpg1.4.23 or cpg1.4.24 you don't need to upgrade. If you are running an older version than cpg1.4.23, you must update to this latest version as soon as possible because of the security impact (the past few maintenance releases before cpg1.4.24 all were security-related).
[more]
   Home   Help Search Board rules Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Auto Album creation with cpg1.4 and SMF1.1.4  (Read 4928 times)
0 Members and 1 Guest are viewing this topic.
Hot Rides Topic starter
Coppermine frequent poster
***
Gender: Male
Posts: 105

I am


WWW
« on: April 17, 2008, 11:08:40 pm »

I had been searching on how to do this and found easy answers for a standalone but nothing for a bridge.
Everyone here said it was a SMF problem. Everyone there said it was a CPM problem. Well it turns out it was a CPM problem and after a lot of help from a SMF user and some good luck by me I found the answer.

So for anyone running a bridge CPM and SMF looking to have an album automaticlly created for your users so they dont have to manually create one before uploading pics (because we all know the easier it is for them, the more likely they are to stay), heres the answer.

in bridge/smf10.ini.php find;
Code:
        // overriding authenticate() as we can let SMF do this all for us.
        function authenticate()
scrol down to just above;
Code:
$this->session_update();

And add;
Code:
if($user_settings['ID_MEMBER'] != 0)
{
$sql = "SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = " . (10000 + $user_settings['ID_MEMBER']);
$result = cpg_db_query($sql);
if(mysql_num_rows($result) == 0)
{
$sql = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (title, category) VALUES ('My album', " .(10000 + $user_settings['ID_MEMBER']) . ")";
cpg_db_query($sql);
}
mysql_free_result($result);
}

This will automatically create an album for each user named 'My Album' Unless the already have an album created.  And the album can not be deleted until the user creates another album because it will recreate the album if another does not exist every time they access the gallery.

I am not a great coder, I will be of limited help if this does not work for you. I just wanted to share this with everyone has it has helped me.
Logged
Debugger
Coppermine newbie

Posts: 1


« Reply #1 on: June 21, 2008, 02:19:15 pm »

For PhpBB
you must patch phpbb2018.inc.php file

after
Code:
function phpbb2018_udb(){
...
}

add code like this
Code:
function authenticate()
        {
                global $USER_DATA, $CONFIG;

                if (!($auth = $this->session_extraction()) && !($auth = $this->cookie_extraction())) {
                        $this->load_guest_data();
                } else {
                        list ($id, $cookie_pass) = $auth;
                        $f = $this->field;

                        if (isset($this->usergroupstable)){
                                $sql = "SELECT u.{$f['user_id']} AS id, u.{$f['username']} AS username, u.{$f['password']} AS password, ug.{$f['usertbl_group_id']} AS group_id ".
                                           "FROM {$this->usertable} AS u, {$this->usergroupstable} AS ug ".
                                           "WHERE u.{$f['user_id']}=ug.{$f['user_id']} AND u.{$f['user_id']}='$id'";
                        } else {
                                $sql = "SELECT u.{$f['user_id']} AS id, u.{$f['username']} AS username, u.{$f['password']} AS password, u.{$f['usertbl_group_id']}+100 AS group_id ".
                                           "FROM {$this->usertable} AS u INNER JOIN {$this->groupstable} AS g ON u.{$f['usertbl_group_id']}=g.{$f['grouptbl_group_id']} ".
                                           "WHERE u.{$f['user_id']}='$id'";
                        }

                        $result = cpg_db_query($sql, $this->link_id);

                        if (mysql_num_rows($result)){
                                $row = mysql_fetch_assoc($result);
                                mysql_free_result($result);

                                $db_pass = $this->udb_hash_db($row['password']);
                                if ($db_pass === $cookie_pass) {
                                        $this->load_user_data($row);
                                } else {
                                        $this->load_guest_data();
                                }
                        } else {
                                $this->load_guest_data();
                        }
                }

                $user_group_set = '(' . implode(',', $USER_DATA['groups']) . ')';

        $USER_DATA = array_merge($USER_DATA, $this->get_user_data($USER_DATA['groups'][0], $USER_DATA['groups'], $this->guestgroup));

                if ($this->use_post_based_groups){
                        $USER_DATA['has_admin_access'] = (in_array($USER_DATA['groups'][0] - 100,$this->admingroups)) ? 1 : 0;
                } else {
                        $USER_DATA['has_admin_access'] = ($USER_DATA['groups'][0] == 1) ? 1 : 0;
                }

                $USER_DATA['can_see_all_albums'] = $USER_DATA['has_admin_access'];

                // avoids a template error
                if (!$USER_DATA['user_id']) $USER_DATA['can_create_albums'] = 0;

                // For error checking
                $CONFIG['TABLE_USERS'] = '**ERROR**';


                define('USER_ID', $USER_DATA['user_id']);
        define('USER_NAME', addslashes($USER_DATA['user_name']));
        define('USER_GROUP', $USER_DATA['group_name']);
        define('USER_GROUP_SET', $user_group_set);
        define('USER_IS_ADMIN', $USER_DATA['has_admin_access']);
        define('USER_CAN_SEND_ECARDS', (int)$USER_DATA['can_send_ecards']);
        define('USER_CAN_RATE_PICTURES', (int)$USER_DATA['can_rate_pictures']);
        define('USER_CAN_POST_COMMENTS', (int)$USER_DATA['can_post_comments']);
        define('USER_CAN_UPLOAD_PICTURES', (int)$USER_DATA['can_upload_pictures']);
        define('USER_CAN_CREATE_ALBUMS', (int)$USER_DATA['can_create_albums']);
        define('USER_UPLOAD_FORM', (int)$USER_DATA['upload_form_config']);
        define('CUSTOMIZE_UPLOAD_FORM', (int)$USER_DATA['custom_user_upload']);
        define('NUM_FILE_BOXES', (int)$USER_DATA['num_file_upload']);
        define('NUM_URI_BOXES', (int)$USER_DATA['num_URI_upload']);

        //Autocreating albums
        if($USER_DATA['user_id'] != 0)
        {
                $cid = 10000 + $USER_DATA['user_id'];
                $sql = "SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = " . $cid;
                $result = cpg_db_query($sql);
                if(mysql_num_rows($result) == 0)
                {
                        $sql = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (category, title, uploads, pos) VALUES ('$cid', 'My Album', 'NO',  '1')";
                        cpg_db_query($sql);
                }
                mysql_free_result($result);
        }
                $this->session_update();
        }
Logged
Hot Rides Topic starter
Coppermine frequent poster
***
Gender: Male
Posts: 105

I am


WWW
« Reply #2 on: June 27, 2008, 06:46:16 pm »

thanks for adding to it!! Grin
Logged
pvisser
Coppermine newbie

Posts: 9


« Reply #3 on: June 30, 2008, 02:09:03 pm »

I Try to do it but i haven an FATAL ERROR: and i white page.
See my codin now.
Code:
// overriding authenticate() as we can let SMF do this all for us.
        function authenticate()
        {
                global $USER_DATA, $user_settings;

                if (!$user_settings){
                        $this->load_guest_data();
                } else {

                        $row = array(
                                'id' => $user_settings['ID_MEMBER'],
                                'username' => $user_settings['memberName'],
                                'group_id' => $user_settings['ID_GROUP']
                        );

                        $this->load_user_data($row);
                }

                $user_group_set = '(' . implode(',', $USER_DATA['groups']) . ')';

$USER_DATA = array_merge($USER_DATA, $this->get_user_data($USER_DATA['groups'][0], $USER_DATA['groups'], $this->guestgroup));

                 $USER_DATA['can_see_all_albums'] = $USER_DATA['has_admin_access'] = array_intersect($USER_DATA['groups'],$this->admingroups) ? 1 : 0;

                // avoids a template error
                if (!$USER_DATA['user_id']) $USER_DATA['can_create_albums'] = 0;

// For error checking
                $CONFIG['TABLE_USERS'] = '**ERROR**';

                define('USER_ID', $USER_DATA['user_id']);
define('USER_NAME', addslashes($USER_DATA['user_name']));
define('USER_GROUP', $USER_DATA['group_name']);
define('USER_GROUP_SET', $user_group_set);
define('USER_IS_ADMIN', $USER_DATA['has_admin_access']);
define('USER_CAN_SEND_ECARDS', (int)$USER_DATA['can_send_ecards']);
define('USER_CAN_RATE_PICTURES', (int)$USER_DATA['can_rate_pictures']);
define('USER_CAN_POST_COMMENTS', (int)$USER_DATA['can_post_comments']);
define('USER_CAN_UPLOAD_PICTURES', (int)$USER_DATA['can_upload_pictures']);
define('USER_CAN_CREATE_ALBUMS', (int)$USER_DATA['can_create_albums']);
define('USER_UPLOAD_FORM', (int)$USER_DATA['upload_form_config']);
define('CUSTOMIZE_UPLOAD_FORM', (int)$USER_DATA['custom_user_upload']);
define('NUM_FILE_BOXES', (int)$USER_DATA['num_file_upload']);
define('NUM_URI_BOXES', (int)$USER_DATA['num_URI_upload']);

//!!!!!!!!!!!!!!!!!!!!!!!--------------Here is your pasted coding..
                if($user_settings['ID_MEMBER'] != 0)
{
$sql = "SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = " . (10000 + $user_settings['ID_MEMBER']);
$result = cpg_db_query($sql);
if(mysql_num_rows($result) == 0)
{
$sql = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (title, category) VALUES ('My album', " .(10000 + $user_settings['ID_MEMBER']) . ")";
cpg_db_query($sql);
}
mysql_free_result($result);
}
    // !!!!!!!!!!!!!!!!!!!!!!----------------Here end your mod



$this->session_update();


Please advice.
Logged
pvisser
Coppermine newbie

Posts: 9


« Reply #4 on: July 03, 2008, 05:18:33 pm »

no one? Huh
Logged
Nibbler
Dev Team member
Coppermine addict
****
Gender: Male
United Kingdom United Kingdom

Posts: 19041



WWW
« Reply #5 on: July 03, 2008, 05:30:15 pm »

Enable debug mode in config and post the mysql error message you get when you replicate the error.
Logged

Deny everything.
pvisser
Coppermine newbie

Posts: 9


« Reply #6 on: July 03, 2008, 06:22:39 pm »

Thanks, The Message is


While executing query "SELECT aid FROM  WHERE category = 10001" on 0

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 'WHERE category = 10001' at line 1

Can you advice me or help me? Thanks
Greetings Patrick Visser
Logged
Nibbler
Dev Team member
Coppermine addict
****
Gender: Male
United Kingdom United Kingdom

Posts: 19041



WWW
« Reply #7 on: July 03, 2008, 07:02:04 pm »

Find

Code:
global $USER_DATA, $user_settings;

change to

Code:
global $USER_DATA, $user_settings, $CONFIG;
Logged

Deny everything.
pvisser
Coppermine newbie

Posts: 9


« Reply #8 on: July 03, 2008, 07:10:44 pm »

O Nope. Same i Think. This is the message:

While executing query "SELECT aid FROM  WHERE category = 10001" on 0

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 'WHERE category = 10001' at line 1
Logged
Nibbler
Dev Team member
Coppermine addict
****
Gender: Male
United Kingdom United Kingdom

Posts: 19041



WWW
« Reply #9 on: July 03, 2008, 07:30:16 pm »

Strange. Hardcode your table names instead then.

Change

Code:
{$CONFIG['TABLE_ALBUMS']}

to

Code:
cpg_albums

or whatever prefix your chose during installation. Read the debug output if you don't know what you chose.
Logged

Deny everything.
pvisser
Coppermine newbie

Posts: 9


« Reply #10 on: July 04, 2008, 08:28:16 am »

Thanks Nibbler, The cpg_albums part did the trick. Now its working.  Is it also possible to automatic enter an album discription ad the same time? If so kan you please advice my hou te do this. Thanks for the help.
Logged
Nibbler
Dev Team member
Coppermine addict
****
Gender: Male
United Kingdom United Kingdom

Posts: 19041



WWW
« Reply #11 on: July 04, 2008, 11:13:33 am »

Yeah, you can just add it in.

Code:
$sql = "INSERT INTO cpg_albums (title, category, description) VALUES ('My album', " .(10000 + $user_settings['ID_MEMBER']) . ", 'Your description here')";
Logged

Deny everything.
pvisser
Coppermine newbie

Posts: 9


« Reply #12 on: July 05, 2008, 08:16:02 am »

I'm so thankfull, I try this part and let you know. Grin
Logged
dannypritchett01
Coppermine newbie

Posts: 7


« Reply #13 on: August 02, 2008, 07:09:47 am »

For PhpBB
you must patch phpbb2018.inc.php file

after
Code:
function phpbb2018_udb(){
...
}

add code like this
Code:
function authenticate()
        {
                global $USER_DATA, $CONFIG;

                if (!($auth = $this->session_extraction()) && !($auth = $this->cookie_extraction())) {
                        $this->load_guest_data();
                } else {
                        list ($id, $cookie_pass) = $auth;
                        $f = $this->field;

                        if (isset($this->usergroupstable)){
                                $sql = "SELECT u.{$f['user_id']} AS id, u.{$f['username']} AS username, u.{$f['password']} AS password, ug.{$f['usertbl_group_id']} AS group_id ".
                                           "FROM {$this->usertable} AS u, {$this->usergroupstable} AS ug ".
                                           "WHERE u.{$f['user_id']}=ug.{$f['user_id']} AND u.{$f['user_id']}='$id'";
                        } else {
                                $sql = "SELECT u.{$f['user_id']} AS id, u.{$f['username']} AS username, u.{$f['password']} AS password, u.{$f['usertbl_group_id']}+100 AS group_id ".
                                           "FROM {$this->usertable} AS u INNER JOIN {$this->groupstable} AS g ON u.{$f['usertbl_group_id']}=g.{$f['grouptbl_group_id']} ".
                                           "WHERE u.{$f['user_id']}='$id'";
                        }

                        $result = cpg_db_query($sql, $this->link_id);

                        if (mysql_num_rows($result)){
                                $row = mysql_fetch_assoc($result);
                                mysql_free_result($result);

                                $db_pass = $this->udb_hash_db($row['password']);
                                if ($db_pass === $cookie_pass) {
                                        $this->load_user_data($row);
                                } else {
                                        $this->load_guest_data();
                                }
                        } else {
                                $this->load_guest_data();
                        }
                }

                $user_group_set = '(' . implode(',', $USER_DATA['groups']) . ')';

        $USER_DATA = array_merge($USER_DATA, $this->get_user_data($USER_DATA['groups'][0], $USER_DATA['groups'], $this->guestgroup));

                if ($this->use_post_based_groups){
                        $USER_DATA['has_admin_access'] = (in_array($USER_DATA['groups'][0] - 100,$this->admingroups)) ? 1 : 0;
                } else {
                        $USER_DATA['has_admin_access'] = ($USER_DATA['groups'][0] == 1) ? 1 : 0;
                }

                $USER_DATA['can_see_all_albums'] = $USER_DATA['has_admin_access'];

                // avoids a template error
                if (!$USER_DATA['user_id']) $USER_DATA['can_create_albums'] = 0;

                // For error checking
                $CONFIG['TABLE_USERS'] = '**ERROR**';


                define('USER_ID', $USER_DATA['user_id']);
        define('USER_NAME', addslashes($USER_DATA['user_name']));
        define('USER_GROUP', $USER_DATA['group_name']);
        define('USER_GROUP_SET', $user_group_set);
        define('USER_IS_ADMIN', $USER_DATA['has_admin_access']);
        define('USER_CAN_SEND_ECARDS', (int)$USER_DATA['can_send_ecards']);
        define('USER_CAN_RATE_PICTURES', (int)$USER_DATA['can_rate_pictures']);
        define('USER_CAN_POST_COMMENTS', (int)$USER_DATA['can_post_comments']);
        define('USER_CAN_UPLOAD_PICTURES', (int)$USER_DATA['can_upload_pictures']);
        define('USER_CAN_CREATE_ALBUMS', (int)$USER_DATA['can_create_albums']);
        define('USER_UPLOAD_FORM', (int)$USER_DATA['upload_form_config']);
        define('CUSTOMIZE_UPLOAD_FORM', (int)$USER_DATA['custom_user_upload']);
        define('NUM_FILE_BOXES', (int)$USER_DATA['num_file_upload']);
        define('NUM_URI_BOXES', (int)$USER_DATA['num_URI_upload']);

        //Autocreating albums
        if($USER_DATA['user_id'] != 0)
        {
                $cid = 10000 + $USER_DATA['user_id'];
                $sql = "SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = " . $cid;
                $result = cpg_db_query($sql);
                if(mysql_num_rows($result) == 0)
                {
                        $sql = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (category, title, uploads, pos) VALUES ('$cid', 'My Album', 'NO',  '1')";
                        cpg_db_query($sql);
                }
                mysql_free_result($result);
        }
                $this->session_update();
        }


Will this code work for phpbb3 as well?
Logged
Joachim Müller
Administrator
Coppermine addict
*****
Gender: Male
Germany Germany

Posts: 43477


aka "GauGau"


WWW
« Reply #14 on: August 02, 2008, 01:41:45 pm »

Almost certainly not. Spare parts for a Volkswagen hardly ever fit into a Porsche or vice versa.
Logged

Don't contact me over PM or email unless I asked you to. Instead: post on the proper board. All unrequested messages will be ignored!
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.149 seconds with 20 queries.