[2.0.21] prevent reply notifications to unauthorized users

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

Rating:

Excellent!
13
93%
Very Good
0
No votes
Good
0
No votes
Fair
0
No votes
Poor
1
7%
 
Total votes: 14

NightriderXP
Registered User
Posts: 1418
Joined: Sat Oct 09, 2004 8:17 am
Location: Florida, US
Contact:

Post by NightriderXP »

asinshesq wrote: Thanks, Eric. And once again, I encourage everyone who is using the older version - even if it is working fine - to switch to this new version so as not to load down your board. (Each version of the mod is only a single FIND and REPLACE so it is really easy to upgrade from the old version!)

I'm a few versions behind. You wouldn't have any update scripts from 1.0.2 to 1.0.5 would you? By not loading down the board, do you mean that earlier versions might be slowing things down a bit???

:?:
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

NightriderXP wrote: ...I'm a few versions behind. You wouldn't have any update scripts from 1.0.2 to 1.0.5 would you? By not loading down the board, do you mean that earlier versions might be slowing things down a bit???...

More than a bit...the slowdown can be very very noticeable, even on medium size boards. You really really should make this change.

As for an upgrade path: the entire mod is only a single find and replace so I never did any upgrade scripts. I'm not at my server now so I can't access the older versions, but if you look at the old script you used for 1.0.2 and the new one for 1.0.5 I doubt you will have any problem figuring out which single block of 1.0.2 code should be repaced by the new 1.0.5 code. Let me know if you're not sure and I'll pm you an upgrade instruction later today.
NightriderXP
Registered User
Posts: 1418
Joined: Sat Oct 09, 2004 8:17 am
Location: Florida, US
Contact:

Post by NightriderXP »

Thanks Alan. I noticed after I posted that the change was extremely minor so I went ahead and replaced the old query with the new. It does seem to help after an initial test. Thanks again...

:lol:
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

Oops, I got your messge too late and I went ahead and put together a simple upgrade path.

You say after an initial test it seems to help. Here's what I found: when I tested this on a board with about 140 users, the original query took almost 20 seconds (each and every time a reply notification gets sent to users!!) while the new query is basically instantaneous...the speed up is dramatic, so people really should upgrade to 1.0.5.

Anyway, here are the upgrade instructions for anyone else who might need them:

Code: Select all

upgrade from version 1.0.2, 1.0.3 or 1.0.4 of this mod to version 1.0.5 of this mod:

# 
#-----[ OPEN ]------------------------------------------ 
# 
includes/functions_post.php

# 
#-----[ FIND ]------------------------------------------ 
# 
// start mod prevent_reply_notification_emails_from_being_emailed_to_unauthorized_users...replaced the original
// $sql definition with the one that appears below
blah blah blah about 20 lines of code here
// end mod prevent_reply_notification_emails_from_being_emailed_to_unauthorized_users

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
// start mod prevent_reply_notification_emails_from_being_emailed_to_unauthorized_users...replaced the original
// $sql definition with the one that appears below
			$sql = "SELECT DISTINCT u.user_id, u.user_email, u.user_lang 
				FROM " . TOPICS_WATCH_TABLE . " tw
				INNER JOIN " . USERS_TABLE . " u ON tw.user_id = u.user_id
				INNER JOIN " . USER_GROUP_TABLE . " ug ON tw.user_id = ug.user_id
				LEFT OUTER JOIN " . AUTH_ACCESS_TABLE . " aa ON ug.group_id = aa.group_id,
				" . FORUMS_TABLE . " f
				WHERE tw.topic_id = $topic_id 
				AND tw.user_id NOT IN (" . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . ") 
				AND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . " 
				AND f.forum_id = $forum_id
				AND u.user_active = 1
				AND
				(
					( aa.forum_id = $forum_id AND aa.auth_read = 1 )
					OR f.auth_read <= " . AUTH_REG . " 
					OR (u.user_level = " . MOD . " AND f.auth_read = " . AUTH_MOD . ")
					OR u.user_level = " . ADMIN . "
				)";
// end mod prevent_reply_notification_emails_from_being_emailed_to_unauthorized_users

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM

If you are using the alternative version of this mod for boards that have David Hermann's forum notification mod installed, there are three changes rather than one to make. Here they are:

Code: Select all

upgrade from 1.0.3 or 1.0.4 to 1.0.5 of the alternative version for boards with David Hermann's forum notification mod installed:

# 
#-----[ OPEN ]------------------------------------------ 
# 
includes/functions_post.php

# 
#-----[ FIND ]------------------------------------------ 
# 
// start mod prevent_reply_notification_emails_from_being_emailed_to_unauthorized_users...replaced the original
// $sql definition with the one that appears below
blah blah blah about 20 lines of code here
// end mod prevent_reply_notification_emails_from_being_emailed_to_unauthorized_users

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
// start mod prevent_reply_notification_emails_from_being_emailed_to_unauthorized_users...replaced the original
// $sql definition with the one that appears below
			$sql = "SELECT DISTINCT u.user_id, u.user_email, u.user_lang 
				FROM " . TOPICS_WATCH_TABLE . " tw
				INNER JOIN " . USERS_TABLE . " u ON tw.user_id = u.user_id
				INNER JOIN " . USER_GROUP_TABLE . " ug ON tw.user_id = ug.user_id
				LEFT OUTER JOIN " . AUTH_ACCESS_TABLE . " aa ON ug.group_id = aa.group_id,
				" . FORUMS_TABLE . " f
				WHERE tw.topic_id = $topic_id 
				AND tw.user_id NOT IN (" . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . ") 
				AND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . " 
				AND f.forum_id = $forum_id
				AND u.user_active = 1
				AND
				(
					( aa.forum_id = $forum_id AND aa.auth_read = 1 )
					OR f.auth_read <= " . AUTH_REG . " 
					OR (u.user_level = " . MOD . " AND f.auth_read = " . AUTH_MOD . ")
					OR u.user_level = " . ADMIN . "
				)";
// end mod prevent_reply_notification_emails_from_being_emailed_to_unauthorized_users

# 
#-----[ FIND ]------------------------------------------ 
# 
// start mod prevent_reply_notification_emails_from_being_emailed_to_unauthorized_users...replaced the original
// $sql definition with the one that appears below
blah blah blah about 20 lines of code here
// end mod prevent_reply_notification_emails_from_being_emailed_to_unauthorized_users

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
// start of reply forum notification
// start mod prevent_reply_notification_emails_from_being_emailed_to_unauthorized_users...replaced the original
// $sql definition with the one that appears below
			$sql = "SELECT DISTINCT u.user_id, u.user_email, u.user_lang, f.forum_name 
				FROM " . FORUMS_WATCH_TABLE . " fw
				INNER JOIN " . USERS_TABLE . " u ON fw.user_id = u.user_id
				INNER JOIN " . USER_GROUP_TABLE . " ug ON fw.user_id = ug.user_id
				LEFT OUTER JOIN " . AUTH_ACCESS_TABLE . " aa ON ug.group_id = aa.group_id,
				" . FORUMS_TABLE . " f
				WHERE fw.forum_id = $forum_id
				AND fw.user_id NOT IN (" . $already_mailed . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . ") 
				AND f.forum_id = $forum_id
				AND f.forum_notify = 1
				AND u.user_active = 1
				AND
				(
					( aa.forum_id = $forum_id AND aa.auth_read = 1 )
					OR f.auth_read <= " . AUTH_REG . " 
					OR (u.user_level = " . MOD . " AND f.auth_read = " . AUTH_MOD . ")
					OR u.user_level = " . ADMIN . "
				)";
// end mod prevent_reply_notification_emails_from_being_emailed_to_unauthorized_users

# 
#-----[ FIND ]------------------------------------------ 
# 
// start mod prevent_reply_notification_emails_from_being_emailed_to_unauthorized_users...replaced the original
// $sql definition with the one that appears below
blah blah blah about 20 lines of code here
// end mod prevent_reply_notification_emails_from_being_emailed_to_unauthorized_users

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
// start mod prevent_reply_notification_emails_from_being_emailed_to_unauthorized_users...replaced the original
// $sql definition with the one that appears below
			$sql = "SELECT DISTINCT u.user_id, u.username, u.user_email, u.user_lang, f.forum_name 
				FROM " . FORUMS_WATCH_TABLE . " fw
				INNER JOIN " . USERS_TABLE . " u ON fw.user_id = u.user_id
				INNER JOIN " . USER_GROUP_TABLE . " ug ON fw.user_id = ug.user_id
				LEFT OUTER JOIN " . AUTH_ACCESS_TABLE . " aa ON ug.group_id = aa.group_id,
				" . FORUMS_TABLE . " f
				WHERE fw.forum_id = $forum_id 
				AND fw.user_id NOT IN (" . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . ") 
				AND f.forum_id = $forum_id
				AND f.forum_notify = 1
				AND u.user_active = 1
				AND
				(
					( aa.forum_id = $forum_id AND aa.auth_read = 1 )
					OR f.auth_read <= " . AUTH_REG . " 
					OR (u.user_level = " . MOD . " AND f.auth_read = " . AUTH_MOD . ")
					OR u.user_level = " . ADMIN . "
				)";
// end mod prevent_reply_notification_emails_from_being_emailed_to_unauthorized_users

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

Just for fun, I ran the older version query through mysql on my current board (with 209 users) and that took 38 seconds. The new version query is instantaneous. People really need to do this upgrade.
NightriderXP
Registered User
Posts: 1418
Joined: Sat Oct 09, 2004 8:17 am
Location: Florida, US
Contact:

Post by NightriderXP »

I agree. Even on my small forum, there is a signigicant performance improvement after applying this update. It is worth the small amount of effort it took to modify the code...

:lol:
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

NightriderXP wrote: I agree. Even on my small forum, there is a signigicant performance improvement after applying this update. It is worth the small amount of effort it took to modify the code...

:lol:


Right, and the time delay increases geometrically rather than just linearly as you increase the size of the board (150 users took 20 seconds while 209 users took 38 seconds). Punchline: if you use this mod please make sure you are running the latest version.

And Nightrider, with only one FIND and REPLACE WITH command in the entire mod, maybe you and I can depart from our usual rule and not insist people use EM ;)
NightriderXP
Registered User
Posts: 1418
Joined: Sat Oct 09, 2004 8:17 am
Location: Florida, US
Contact:

Post by NightriderXP »

asinshesq wrote: And Nightrider, with only one FIND and REPLACE WITH command in the entire mod, maybe you and I can depart from our usual rule and not insist people use EM ;)

Actually I still believe that ALL MODs and updates should be installed using EM. Right now, I have no history of this update being applied to my board. Since I have hundreds of MODs installed on my board and since many of them are constantly being updated, it is nice to use the EM History to determine if I am up to date with the MODs...

There is a new MOD called Advanced Version Check 2.0.0 that all developers can get involved with. It will track the versions of all MODs that have been coordinated with it and tell you when there is an update. It will even provide links to the update. Developers need to work with Fountain of Apples to coordinate their MODs and updates with them so that it will make maintaining these MODs a lot easier in the future...

MOD Authors Guide for Creating an AVC Version Checker

:lol:
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

NightriderXP wrote: ...Actually I still believe that ALL MODs and updates should be installed using EM....

It's like throwing red meat to a lion... ;)
...There is a new MOD called Advanced Version Check 2.0.0 that all developers can get involved with. It will track the versions of all MODs that have been coordinated with it and tell you when there is an update. It will even provide links to the update. Developers need to work with Fountain of Apples to coordinate their MODs and updates with them so that it will make maintaining these MODs a lot easier in the future...

MOD Authors Guide for Creating an AVC Version Checker ...


That's very cool...I didn't know anything about that. I guess I'll check that out and stick my mods into the hopper there.
NightriderXP
Registered User
Posts: 1418
Joined: Sat Oct 09, 2004 8:17 am
Location: Florida, US
Contact:

Post by NightriderXP »

I think it's pretty neat too. I think I've already annoyed FoA since I have requested that his Update scripts be just as EM friendly as his regular MOD scripts. I think he will get over it eventually though...

:lol:
Shanana
Registered User
Posts: 368
Joined: Sat Aug 28, 2004 4:03 am
Location: USA [from London, England]

Post by Shanana »

Does this work with .19?
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

Shanana wrote: Does this work with .19?

Yes.
Kote Nuki
Registered User
Posts: 255
Joined: Thu Oct 31, 2002 6:04 pm
Location: Birmingham, AL
Contact:

Excellent

Post by Kote Nuki »

Excellent MOD asinshesq. Two thumbs up. :mrgreen:
Just me, Kote Nuki
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Re: Excellent

Post by asinshesq »

Kote Nuki wrote: Excellent MOD asinshesq. Two thumbs up. :mrgreen:


Thanks. As I mentioned earlier, it seems pretty strange that this wasn't built into original phpbb. I gather they fixed it for olympus...
User avatar
webmacster87
Former Team Member
Posts: 3758
Joined: Fri Jun 11, 2004 2:30 am
Location: San Mateo, CA
Name: Douglas Bell
Contact:

Post by webmacster87 »

MOD Updated to version 1.0.5a
See first post for Download Link
Post Reply

Return to “[2.0.x] MOD Database Releases”