Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: 1 [2]   Go Down

Author Topic: Unknown Coward  (Read 11146 times)

0 Members and 1 Guest are viewing this topic.

klewless

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 107
Re: Unknown Coward
« Reply #20 on: July 15, 2016, 02:53:04 am »

Working, sort-of, thank you.

All 9 pages of Home/Member Galleries are now full, rather than there being some blank pages at the end. Unfortunately, the active members and former members are mixed upL some of the active users' album cover thumbs are replaced by those empty film cans. The pictures are still inside fortunately, and so are the comments and other file information associated with the images, for everyone -- former members or members.

I will try to see if I missed a bracket or something in the copy-pasting.

 :-\ :-\ :-\
Logged

klewless

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 107
Re: Unknown Coward
« Reply #21 on: July 15, 2016, 03:49:45 am »

Another odd thing is that "all" the results are showing up on each page of Home>Member Galleries: the same "film cans" , in the same order.
 :-\
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15760
Re: Unknown Coward
« Reply #22 on: July 15, 2016, 06:50:42 am »

I'll perform some tests on your gallery as soon as possible.
Logged

klewless

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 107
Re: Unknown Coward
« Reply #23 on: July 17, 2016, 04:04:58 pm »

Still here  :)

I have left the new code in place for now so you can see   ???  :



Thanks again,
L.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15760
Re: Unknown Coward
« Reply #24 on: July 18, 2016, 02:08:00 pm »

My last code change was created with totally wrong assumptions. I just updated the code on your website and it seems to work as expected as far as I can tell. I've reverted the first modification and instead I applied this mod.

Open index.php, find
Code: [Select]
    if (!$rowset) {
        msg_box($lang_list_users['user_list'], $lang_list_users['no_user_gal'], '', '', 'info');
        return;
    }

    $user_per_page = $CONFIG['thumbcols'] * $CONFIG['thumbrows'];
    $totalPages    = ceil($user_count / $user_per_page);
and replace with
Code: [Select]
    if (!$user_count) {
        msg_box($lang_list_users['user_list'], $lang_list_users['no_user_gal'], '', '', 'info');
        return;
    }

    $user_per_page = $CONFIG['thumbcols'] * $CONFIG['thumbrows'];
    $totalPages    = ceil($user_count / $user_per_page);

    $users_this_page = count($rowset);
    if ($user_count > $users_this_page && $users_this_page < $user_per_page) {
        $sql  = "SELECT {$cpg_udb->field['user_id']} AS user_id FROM {$cpg_udb->usertable}";
        $result = cpg_db_query($sql);
        while ($row = cpg_db_fetch_assoc($result)) {
            $user_ids_existing[] = $row['user_id'];
        }
        cpg_db_free_result($result);

        $sql  = "SELECT category "
                . "FROM {$CONFIG['TABLE_ALBUMS']} AS p "
                . "INNER JOIN {$CONFIG['TABLE_PICTURES']} AS pics ON pics.aid = p.aid "
                . "WHERE ( category > " . FIRST_USER_CAT . " $FORBIDDEN_SET) "
                . "GROUP BY category";
        $result = cpg_db_query($sql);
        while ($row = cpg_db_fetch_assoc($result)) {
            $user_ids_all[] = $row['category'] - FIRST_USER_CAT;
        }
        cpg_db_free_result($result);

        $users_missing = array_diff($user_ids_all, $user_ids_existing);

        $users_w_albums = count(array_intersect($user_ids_all, $user_ids_existing));

        $offset = max(0, ($PAGE - 1) * $user_per_page - $users_w_albums);

        $user_ids = array_slice($users_missing, $offset, $user_per_page - $users_this_page);

        foreach ($user_ids as $user_id) {
            $user_categories[] = $user_id + FIRST_USER_CAT;
        }
        $result = cpg_db_query("
            SELECT p.owner_id, p.aid, COUNT(*) AS pic_count FROM {$CONFIG['TABLE_PICTURES']} AS p
            INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a
            ON a.aid = p.aid
            WHERE a.category IN (".implode(',', $user_categories).")
            GROUP BY p.aid
        ");
        while ($row = cpg_db_fetch_assoc($result)) {
            $user_category_data[$row['owner_id']]['alb_count']++;
            $user_category_data[$row['owner_id']]['pic_count'] += $row['pic_count'];
        }
        foreach ($user_ids as $user_id) {
            $rowset[] = array(
                'user_id' => $user_id,
                'user_name' => 'Former user '.$user_id,
                'alb_count' => $user_category_data[$user_id]['alb_count'],
                'pic_count' => $user_category_data[$user_id]['pic_count'],
            );
        }
    }
Logged

klewless

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 107
Re: Unknown Coward
« Reply #25 on: July 19, 2016, 06:11:25 am »

I am happy to confirm it works well. Just one problem, the Former Members galleries are showing up as film cans (when you are looking at an album list page), however all the pictures and their comments are intact.

Perhaps I can go in there and assign a picture to each of these albums.

Thanks VERY much!
 :) :) :) :) :) :) :) :)
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15760
Re: Unknown Coward
« Reply #26 on: July 19, 2016, 10:48:50 am »

Perhaps I can go in there and assign a picture to each of these albums.

Please don't! They're still set in the database, but I haven't added that part to the code, as it had no priority since now. I'll work further on the code and let you know when it's ready.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15760
Re: Unknown Coward
« Reply #27 on: July 19, 2016, 11:03:40 am »

Updated code:
Code: [Select]
    if (!$user_count) {
        msg_box($lang_list_users['user_list'], $lang_list_users['no_user_gal'], '', '', 'info');
        return;
    }

    $user_per_page = $CONFIG['thumbcols'] * $CONFIG['thumbrows'];
    $totalPages    = ceil($user_count / $user_per_page);

    $users_this_page = count($rowset);
    if ($user_count > $users_this_page && $users_this_page < $user_per_page) {
        $sql  = "SELECT {$cpg_udb->field['user_id']} AS user_id FROM {$cpg_udb->usertable}";
        $result = cpg_db_query($sql);
        while ($row = cpg_db_fetch_assoc($result)) {
            $user_ids_existing[] = $row['user_id'];
        }
        cpg_db_free_result($result);

        $sql  = "SELECT category "
                . "FROM {$CONFIG['TABLE_ALBUMS']} AS p "
                . "INNER JOIN {$CONFIG['TABLE_PICTURES']} AS pics ON pics.aid = p.aid "
                . "WHERE ( category > " . FIRST_USER_CAT . " $FORBIDDEN_SET) "
                . "GROUP BY category";
        $result = cpg_db_query($sql);
        while ($row = cpg_db_fetch_assoc($result)) {
            $user_ids_all[] = $row['category'] - FIRST_USER_CAT;
        }
        cpg_db_free_result($result);

        $users_missing = array_diff($user_ids_all, $user_ids_existing);

        $users_w_albums = count(array_intersect($user_ids_all, $user_ids_existing));

        $offset = max(0, ($PAGE - 1) * $user_per_page - $users_w_albums);

        $user_ids = array_slice($users_missing, $offset, $user_per_page - $users_this_page);

        foreach ($user_ids as $user_id) {
            $user_categories[] = $user_id + FIRST_USER_CAT;
        }
        $result = cpg_db_query("
            SELECT p.owner_id, p.aid, COUNT(*) AS pic_count, MAX(pid) AS thumb_pid, MAX(galleryicon) AS gallery_pid
            FROM {$CONFIG['TABLE_PICTURES']} AS p
            INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a
            ON a.aid = p.aid
            WHERE a.category IN (".implode(',', $user_categories).")
            GROUP BY p.aid
        ");
        while ($row = cpg_db_fetch_assoc($result)) {
            $user_category_data[$row['owner_id']]['alb_count']++;
            $user_category_data[$row['owner_id']]['pic_count'] += $row['pic_count'];
            $user_category_data[$row['owner_id']]['thumb_pid'] = $row['thumb_pid'];
            $user_category_data[$row['owner_id']]['gallery_pid'] = $row['gallery_pid'];
        }
        foreach ($user_ids as $user_id) {
            $rowset[] = array(
                'user_id' => $user_id,
                'user_name' => 'Former user '.$user_id,
                'alb_count' => $user_category_data[$user_id]['alb_count'],
                'pic_count' => $user_category_data[$user_id]['pic_count'],
                'thumb_pid' => $user_category_data[$user_id]['thumb_pid'],
                'gallery_pid' => $user_category_data[$user_id]['gallery_pid'],
            );
        }
    }

I've already applied it to your gallery, and it seems to work for most user categories. Some have still the trash can icon, but I haven't checked in detail yet why this happens. Maybe you find something obvious.
Logged

klewless

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 107
Re: Unknown Coward
« Reply #28 on: July 19, 2016, 01:26:57 pm »

I checked those folders with the cans, they have't got any pictures. I guess I just missed a few, some cans also among the sub-albums.


THANK YOU!!!!
Perfect now. Awesome! 
 :) :) :)
Logged
Pages: 1 [2]   Go Up
 

Page created in 0.019 seconds with 19 queries.