User Gallery Alphabetic Tabbing and bridging User Gallery Alphabetic Tabbing and bridging
 

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

User Gallery Alphabetic Tabbing and bridging

Started by jonket, November 09, 2012, 07:12:32 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

jonket

I am getting this error message.  Do not find it anywhere else in the forum.  Please help:

While executing query 'SELECT NULL FROM cpg15x_albums AS p  INNER JOIN cpg15x_pictures AS pics ON pics.aid = p.aid  INNER JOIN `stjarnai_phpbb`.phpbb_users AS u ON p.owner = u.user_id WHERE ( category > 10000 ) AND UPPER(username) LIKE 'B%' GROUP BY category;' in plugins/usergal_alphatabs/codebase.php(364) : eval()'d code on line 31

mySQL error: SELECT command denied to user 'stjar_cpg'@'localhost' for table 'phpbb_users'


It should not be looking for phpbb-users in stjar_cpg. It should be stjarnai_phpbb

Coppermine install: http://stjarna.is/joomla/myndasafn
Coppermine version: cpg1.5.20
Bridging app version: Phpbb3 in CPG 1.5.20


BridgeManager settings:
Bridge app URL:  http://stjarna.is/joomla/spjall     
Relative path to your bridge app's config file:  ../../joomla/spjall/
Cookie name or prefix:  phpbb3_stjarna

Jeff Bailey

Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford

jonket

Thanks, but this did not work.  Just wonder why this  plugin is looking in CPG database, not phpbb3 database.

Jeff Bailey

Oh I miss read this, I thought this was a briding problem. Let me look at the plugin.
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford

Jeff Bailey

It's looking in the correct database `stjarnai_phpbb`.phpbb_users the problem is MySQL user permissions as far as I can tell.

I have no way to test this or even if I have the right idea of what the problem is but

In codebase.php
Find:

        // Get the total number of users with albums
        $sql  = "SELECT NULL ";
        $sql .= "FROM {$CONFIG[\'TABLE_ALBUMS\']} AS p ";
        $sql .= " INNER JOIN {$CONFIG[\'TABLE_PICTURES\']} AS pics ON pics.aid = p.aid ";
        $sql .= " INNER JOIN ".$this->usertable." AS u ON p.owner = u.{$f[\'user_id\']} ";
        $sql .= "WHERE ( category > " . FIRST_USER_CAT . " $forbidden) ";
        if ($l = $getLetter) $sql .= "AND UPPER({$f[\'username\']}) LIKE \'$l%\' ";
        $sql .= "GROUP BY category;";
        $result = cpg_db_query($sql);
        $user_count = mysql_num_rows($result);


replace with:

        // Get the total number of users with albums
        $sql  = "SELECT NULL ";
        $sql .= "FROM {$CONFIG[\'TABLE_ALBUMS\']} AS p ";
        $sql .= " INNER JOIN {$CONFIG[\'TABLE_PICTURES\']} AS pics ON pics.aid = p.aid ";
        $sql .= " INNER JOIN ".$this->usertable." AS u ON p.owner = u.{$this->field[\'user_id\']} ";
        $sql .= "WHERE ( category > " . FIRST_USER_CAT . " $forbidden) ";
        if ($l = $getLetter) $sql .= "AND UPPER({$this->field[\'user_id\']}) LIKE \'$l%\' ";
        $sql .= "GROUP BY category;";
        $result = cpg_db_query($sql);
        $user_count = mysql_num_rows($result);
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford

jonket


Jeff Bailey

Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford

Jeff Bailey

I replied to your email.

Could you run a version check and give me the revision numbers for:

  • udb_base.inc.php
  • functions.inc.php
  • search.inc.php
  • search.php
  • usermgr.php
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford

jonket

I downloaded the files directed to.

They do not have revision numbers in version check.  But they are said to be newer and for cpg 1.5.21

Jeff Bailey

I noticed you hadn't undone the code change from
Quote from: Jeff Bailey on November 09, 2012, 10:59:17 PM
replace with:

        // Get the total number of users with albums
        $sql  = "SELECT NULL ";
        $sql .= "FROM {$CONFIG[\'TABLE_ALBUMS\']} AS p ";
        $sql .= " INNER JOIN {$CONFIG[\'TABLE_PICTURES\']} AS pics ON pics.aid = p.aid ";
        $sql .= " INNER JOIN ".$this->usertable." AS u ON p.owner = u.{$this->field[\'user_id\']} ";
        $sql .= "WHERE ( category > " . FIRST_USER_CAT . " $forbidden) ";
        if ($l = $getLetter) $sql .= "AND UPPER({$this->field[\'user_id\']}) LIKE \'$l%\' ";
        $sql .= "GROUP BY category;";
        $result = cpg_db_query($sql);
        $user_count = mysql_num_rows($result);

you can revert back to the original.
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford

jonket


Jeff Bailey

Well the problem is you have a different mysql user for each table.

$this->can_join_tables becomes false because your db user names are not the same and your cpg db user does not have select permissions on your phpBB table.

I tried writing a workaround for this but I don't know enough about phpBB to create test accounts or enough about how this plugin works. For now I just commented out:

// Get the total number of users with albums
        /*$sql  = "SELECT NULL ";
        $sql .= "FROM {$CONFIG[\'TABLE_ALBUMS\']} AS p ";
        $sql .= " INNER JOIN {$CONFIG[\'TABLE_PICTURES\']} AS pics ON pics.aid = p.aid ";
        $sql .= " INNER JOIN ".$this->usertable." AS u ON p.owner = u.{$f[\'user_id\']} ";
        $sql .= "WHERE ( category > " . FIRST_USER_CAT . " $forbidden) ";
        if ($l = $getLetter) $sql .= "AND UPPER({$f[\'username\']}) LIKE \'$l%\' ";
        $sql .= "GROUP BY category;";
        $result = cpg_db_query($sql);
        $user_count = mysql_num_rows($result);*/


        $users_per_page = $CONFIG[\'thumbcols\'] * $CONFIG[\'thumbrows\'];
        //$totalPages = ceil($user_count / $users_per_page);
        //if ($PAGE > $totalPages) $PAGE = 1;
        $lower_limit = ($PAGE-1) * $users_per_page;


            // This query determines which users we need to collect usernames of - ie just those which have albums with pics
            // and are on the page we are looking at
            $sql  = "SELECT category - 10000 as user_id ";
            $sql .= "FROM {$CONFIG[\'TABLE_ALBUMS\']} AS a ";
            $sql .= "INNER JOIN {$CONFIG[\'TABLE_PICTURES\']} AS p ON p.aid = a.aid ";
            $sql .= "WHERE ((isnull(approved) or approved=\"YES\") ";
            $sql .= "AND category > " . FIRST_USER_CAT . ") $forbidden_with_icon GROUP BY category ";
            //$sql .= "LIMIT $lower_limit, $users_per_page ";

It works for now because you only have one user with a user gallery.

Easiest solution for you would be to grant permissions to your cpg db user for your phpBB tables, then uncomment the above code.
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford

jonket

Well, some hosting providers do not allow same user to different databases.

I just moved the cpg tables to the phpbb3 database.  But i would like to have it in diffferent databases.

I have reverted to the original codebase.php

Jeff Bailey

Maybe something like this will work.

In codebase.php
Find

        // Get the total number of users with albums
        $sql  = "SELECT NULL ";
        $sql .= "FROM {$CONFIG[\'TABLE_ALBUMS\']} AS p ";
        $sql .= " INNER JOIN {$CONFIG[\'TABLE_PICTURES\']} AS pics ON pics.aid = p.aid ";
        $sql .= " INNER JOIN ".$this->usertable." AS u ON p.owner = u.{$f[\'user_id\']} ";
        $sql .= "WHERE ( category > " . FIRST_USER_CAT . " $forbidden) ";
        if ($l = $getLetter) $sql .= "AND UPPER({$f[\'username\']}) LIKE \'$l%\' ";
        $sql .= "GROUP BY category;";
        $result = cpg_db_query($sql);
        $user_count = mysql_num_rows($result);

Replace with

if ($this->can_join_tables){
// Get the total number of users with albums
$sql  = "SELECT NULL ";
$sql .= "FROM {$CONFIG[\'TABLE_ALBUMS\']} AS p ";
$sql .= " INNER JOIN {$CONFIG[\'TABLE_PICTURES\']} AS pics ON pics.aid = p.aid ";
$sql .= " INNER JOIN ".$this->usertable." AS u ON p.owner = u.{$f[\'user_id\']} ";
$sql .= "WHERE ( category > " . FIRST_USER_CAT . " $forbidden) ";
if ($l = $getLetter) $sql .= "AND UPPER({$f[\'username\']}) LIKE \'$l%\' ";
$sql .= "GROUP BY category;";
$result = cpg_db_query($sql);
$user_count = mysql_num_rows($result);
} else {
$sql = "SELECT DISTINCT owner FROM {$CONFIG[\'TABLE_ALBUMS\']}";
$result = cpg_db_query($sql);
$albumowners = mysql_fetch_array($result);
mysql_free_result($result);

$sql = "SELECT user_id FROM {$this->usertable}";
if ($l = $getLetter) $sql .= " WHERE UPPER({$f[\'username\']}) LIKE \'$l%\' ";
$result = cpg_db_query($sql, $this->link_id);
$users = mysql_fetch_array($result);
mysql_free_result($result);

$user_count = 1;
foreach ($users as $user) {
if (in_array($user, $albumowners)) {
$user_count ++;
}
}
}


Untested
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford

jonket

This works now without errors. 

But now I am in trouble with users albums if the users names start with a special Icelandic character.

Jeff Bailey

Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford

jonket


Jeff Bailey

probably needs html_entity_decode() somewhere, I'll look around some tomorrow to see if thats the issue.
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford

ΑndrĂ©

I just had a short look at Jeff's latest mod and your gallery. What I noticed:

1.
$user_count = 1;
probably has to be
$user_count = 0;

2. Browse through the different letters. For every letter the first two albums are dupes, and they appear for several letters.

3. The user name, album and file count seems to be always the same for each user, e.g.
Quote5
5 album(s)
5 file(s)


I haven't looked at the vanilla plugin yet, but I assume issue 2 and 3 doesn't occur there, right?