forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 email => Topic started by: maddogprod on August 04, 2016, 03:41:20 pm

Title: Emails being sent to old admin
Post by: maddogprod on August 04, 2016, 03:41:20 pm
This is kind of baffling. An old admin who was changed to "Registered" rather than "Admin" still gets email notifications. I'm checked, changed him back and forth several times, and he's not Category 1 (Admin). Why is he still getting those and what can I do to stop it?

THANKS
Title: Re: Emails being sent to old admin
Post by: gmc on August 06, 2016, 03:25:59 pm
Perhaps the simple answer? Check your gallery config under General Settings...
3rd entry is Gallery administrator email...
As the doc says:
Quote
This email address must not be confused with the email address that correlates to the email address of the gallery administrator's user account. Those email addresses can be identical, but they don't necessarilly have to.
Title: Re: Emails being sent to old admin
Post by: maddogprod on August 06, 2016, 05:10:57 pm
That's not it. Nor is the general email in that space (photos@) being forwarded.

The emails go to each of the three admins PLUS this person who used to be an admin but isn't anymore.
Title: Re: Emails being sent to old admin
Post by: Αndré on August 12, 2016, 02:39:19 pm
gets email notifications

Which kind of notifications? Please post some examples. Additionally, check if the former admin isn't assigned to the admin group as secondary/additional group.
Title: Re: Emails being sent to old admin
Post by: maddogprod on August 17, 2016, 07:18:50 pm
He gets "A new user with the username "xyz" has registered in your gallery." He might also be getting them when they upload a photo, I'm not certain.

He's Registered only. Not an admin. How could he be assigned to a secondary group? See the attachment
Title: Re: Emails being sent to old admin
Post by: Αndré on August 22, 2016, 08:11:10 pm
He gets "A new user with the username "xyz" has registered in your gallery."

This is how get the admin email addresses for such emails:
Code: (register.php) [Select]
        if (UDB_INTEGRATION == 'coppermine') {
            // get default language in which to inform the admins
            $result = cpg_db_query("SELECT user_id, user_email, user_language FROM {$CONFIG['TABLE_USERS']} WHERE user_group = 1");
            while ( ($row = mysql_fetch_assoc($result)) ) {
                if (!empty($row['user_email'])) {
                    $admins[$row['user_id']] = array('email' => $row['user_email'], 'lang' => $row['user_language']);
                }
            }
        } else {
            //@todo: is it possible to get the language from bridged installs?
            $admins[] = array('email' => $CONFIG['gallery_admin_email'], 'lang' => 'english');
        }

As it seems your gallery is unbridged, that user must be in user_group "1", though Coppermine says something different. I'd like to have a closer look at this issue. I'd need access to the MySQL database of your Coppermine gallery. If you agree, I'll send you my contact information.
Title: Re: Emails being sent to old admin
Post by: maddogprod on August 22, 2016, 10:00:15 pm
I can do that if you want. I've attached a db screenshot. The user in question is highlighted in YELLOW. He's definitely user_group 2!
Title: Re: Emails being sent to old admin
Post by: Αndré on August 22, 2016, 11:40:16 pm
Weird. Is there maybe an email forwarder for some of the current admins, which redirects to the old admin email address?

Next step would be to debug the content of $admins. Please add
Code: [Select]
print_r($admins);die(); below the above mentioned code, register a new test user and have a look at the output after submitting the form.
Title: Re: Emails being sent to old admin
Post by: maddogprod on August 22, 2016, 11:53:08 pm
No forwarders. I checked and double checked since that was the obvious thing.

Should the new test user be a regular user or an admin? Tons of new users have been added since this person and they don't get the notices.
Title: Re: Emails being sent to old admin
Post by: Αndré on August 23, 2016, 12:06:38 am
It doesn't matter, as we only want to see the content of the array of admins which has been prepared.
Title: Re: Emails being sent to old admin
Post by: maddogprod on August 23, 2016, 12:25:12 am
Here's what I get. Maildrop99 is the one that shouldn't be there.

Code: [Select]
Array ( [2] => Array ( [email] => maildrop99@gmail.com [lang] => english ) [8] => Array ( [email] => jamesgcampbellsf@gmail.com [lang] => english ) )
And I just searched the db....as you'd expect there's only one instance of this email address being used and he's the one that was changed to group 2.

I've looked through the settings and haven't found it, but is there someplace I might have missed where he could be specified to receive this along with the other admin?
Title: Re: Emails being sent to old admin
Post by: Αndré on August 23, 2016, 12:36:51 am
Maybe there's some kind of SQL query cache enabled in your MySQL server, I don't know. We could adjust the query to exclude user_id 2,but that would just be a workaround.
Title: Re: Emails being sent to old admin
Post by: maddogprod on August 23, 2016, 12:49:40 am
I'd say the cache could be possible but this has been happening for a couple of years, believe it or not. He keeps getting upset because he's still getting them when he shouldn't and I tell him to set up email filters.

I just looked through all the settings again. I also searched the entire db and there's only one instance of that email address, and that's his user info.

W...T...F!?

I'd delete him and re-add him except he has lots of photos in there and I don't want them to be disconnected from him.

Title: Re: Emails being sent to old admin
Post by: gmc on August 23, 2016, 03:24:37 am
OK... so let's eliminate the database...
Using a tool like PHPMyAdmin, issue the following SQL using your correct table prefix of course in place of cpg_:
Code: [Select]
SELECT user_id, user_group, user_email, user_language FROM cpg_users WHERE user_group = 1(I added user_group to the SELECT CPG issues just to see it in output... Of course expect to see only '1' there based on WHERE clause.

If that returns his email...

From the screen shot - looks like the array should have contained users 1 and 8... instead the array showed 2 and 8.
Title: Re: Emails being sent to old admin
Post by: maddogprod on August 23, 2016, 03:30:15 am
Attached is what it returned, which is correct. These are the three admins. he's not in the list....
Title: Re: Emails being sent to old admin
Post by: gmc on August 23, 2016, 03:35:33 am
To quote you... W...T...F!?  lol...

CPG isn't just going to dream up his email...
Any mods made to CPG code?  Could the email have been hardcoded someplace in past?
I don't see a link to your gallery - so can't see the release you are running...
Title: Re: Emails being sent to old admin
Post by: maddogprod on August 23, 2016, 04:10:31 am
I don't think there are any mods....I set it up originally a few years ago as an annual photo contest.

The gallery is here: http://belvederecommunityfoundation.com/photocontest/index.php?cat=7

It's version 1.5.20. Old, yes....

There are no Installed Plugins

thanks for sticking with me on this....I'm baffled.
Title: Re: Emails being sent to old admin
Post by: Αndré on August 23, 2016, 07:00:01 am
Please upgrade to the latest Coppermine version (currently cpg1.5.42) and try again. If it still doesn't work, we'll apply a workaround.
Title: Re: Emails being sent to old admin
Post by: maddogprod on August 23, 2016, 05:22:32 pm
I was going to do that but my concern is the photo contest is live now (it's only a couple of months each year) and I'm nervous about updating problems while it's live. Is this a pretty safe update to make? I'm pretty sure the only changed files are in the template.

Thoughts?

THANKS
Title: Re: Emails being sent to old admin
Post by: Αndré on August 23, 2016, 05:33:37 pm
Create a copy of your gallery (files and database) and test the update on a local web server (e.g. XAMPP). You could also run the SQL queries and check the result on your local server before and after the upgrade to the latest Coppermine version.
Title: Re: Emails being sent to old admin
Post by: maddogprod on August 24, 2016, 07:26:25 pm
I think it was successful!

Upgraded with no problem. I didn't realize they were maintenance releases which of course are usually simple.

When I add the code to register.php I get:

Code: [Select]
Array ( [1] => Array ( [email] => md@maddogproductions.com [lang] => english ) [8] => Array ( [email] => jamesgcampbellsf@gmail.com [lang] => english ) [305] => Array ( [email] => SWrightRyan@gmail.com [lang] => english ) )
When I do the MySQL query it's the same (see attachment).

No sign of the old Admin's "maildrop99@" email address!

GOOD WORK!

Any clue what was overwritten that cleaned it up? Just curious.

And THANKS A MILLION for working through this with me. The old Admin will be very happy....
Title: Re: Emails being sent to old admin
Post by: Αndré on August 24, 2016, 08:51:55 pm
There are no changes from cpg1.5.20 to cpg1.5.42 regarding the admin detection in register.php, it's exactly the same code. Glad that it works now.
Title: Re: Emails being sent to old admin
Post by: gmc on August 24, 2016, 10:58:00 pm
Only thing I can think of was a modification to the old source... If you still have it - compare old/new register.php as André said there were no changes in that area at least...

When I do an upgrade of an unknown gallery - I download a clean copy of the version in use - and compare to what is running to see if there are any changes.  Most of the time works well... sometimes something changed carriage returns and makes it ugly... but helps me determine if there were any customizations.  WinMerge is an example of a tool to do that with.