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]   Go Down

Author Topic: search by username is missing  (Read 408 times)

0 Members and 1 Guest are viewing this topic.

angelsfire

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
search by username is missing
« on: January 09, 2023, 12:03:17 am »

my gallery version: Coppermine Photo Gallery 1.6.09 (stable)
https://www.thefantasiesattic.net/attic/cpg/index.php

I have not needed to search by name in such a long time that I did not notice it missing. But as you can see from the image it is not listed anymore. Now I did get it to show up but the rest of the files that needed the code changed just made it not search and I got an error.

Code: [Select]

1. Open search.php

FIND:

$customs
$ip

and above, ADD:


                                        <tr>
                                                <td><input type="checkbox" name="owner_name" id="owner_name" class="checkbox" /><label for="owner_name" class="clickable_option">Owner name</label></td>
                                                <td>&nbsp;</td>
                                        </tr>




adding the above code made it appear in the list but no more the following is the rest of the code that was all for version 1.5.48 (I loved that version). I have not updated any farther since it took someone coming in to  make it behave (mainly a hosting issue it much later came out).

Code: [Select]
2. Open thumbnails.php

FIND

$allowed = array('title', 'caption', 'keywords', 'filename', 'pic_raw_ip', 'pic_hdr_ip', 'user1', 'user2', 'user3', 'user4', 'type');

REPLACE WITH
$allowed = array('title', 'caption', 'keywords', 'filename', 'pic_raw_ip', 'pic_hdr_ip', 'user1', 'user2', 'user3', 'user4', 'type', 'owner_name');


3. Open include/search.inc.php

FIND

$allowed = array('title', 'caption', 'keywords', 'filename', 'pic_raw_ip', 'pic_hdr_ip', 'user1', 'user2', 'user3', 'user4');


ADD BELOW

global $cpg_udb;
// Use actual column name for search by owner name
if ($USER['search']['params']['owner_name']) {
    $USER['search']['params'][$cpg_udb->field['username']] = true;
    $allowed[] = $cpg_udb->field['username'];
}


FIND

            $query = "SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} AS p
                WHERE $sql
                AND ($sort_order)";

REPLACE

            $query = "SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} AS p
                LEFT JOIN {$cpg_udb->usertable} AS u ON p.owner_id = u.{$cpg_udb->field['user_id']}
                WHERE $sql
                AND ($sort_order)";


FIND

            $query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p WHERE " . $sql;

            $temp = str_replace('SELECT *', 'SELECT COUNT(*)', $query);

REPLACE

            $query = "SELECT p.*, u.{$cpg_udb->field['username']} AS owner_name FROM {$CONFIG['TABLE_PICTURES']} AS p
            LEFT JOIN {$cpg_udb->usertable} AS u ON p.owner_id = u.{$cpg_udb->field['user_id']}
            WHERE " . $sql;

            $temp = str_replace("SELECT p.*, u.{$cpg_udb->field['username']} AS owner_name", 'SELECT COUNT(*)', $query);



Can someone please give me the proper code to allow the username to show and be searched for?  It is bridged but will not let me return to bridging to reset the password or anything else since the upgrade. If an admin password is needed then let me know.
Logged

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1527
  • aka 'i-imagine'
    • Home Page
Re: search by username is missing
« Reply #1 on: January 09, 2023, 03:26:28 am »

Try an update to Coppermine 1.6.2 and run Check Versions (versioncheck.php) after completing the update.

What you are looking for is working out of the box for me on 1.6.2.

Dark_Angel

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: search by username is missing
« Reply #2 on: January 09, 2023, 05:48:50 am »

I have avoided updating further than the version I had since it was so hard to update the gallery to it. I will see if I can do it withut killing my gallery.
Logged

Dark_Angel

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: search by username is missing
« Reply #3 on: January 09, 2023, 05:59:53 am »

I forgot to mention that my PHP version is 7.1 and the version you said to update to updates for v8.1+ will that mess things up?
Logged

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1527
  • aka 'i-imagine'
    • Home Page
Re: search by username is missing
« Reply #4 on: January 09, 2023, 11:55:12 pm »

I have avoided updating further than the version I had since it was so hard to update the gallery to it. I will see if I can do it withut killing my gallery.

Follow the instructions (links above), make your backups first, and take your time.

I forgot to mention that my PHP version is 7.1 and the version you said to update to updates for v8.1+ will that mess things up?
No, it will not.

Dark_Angel

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: search by username is missing
« Reply #5 on: January 10, 2023, 02:29:36 am »

will try and see what it does and let you know, am getting ready for surgery on Friday so it may be a bit. Thanks
Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 19 queries.