Best event for blocking traffic and double logging

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
Registered User
Posts: 3930
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA

Best event for blocking traffic and double logging

Post by MarkDHamill » Sun Jun 23, 2019 1:33 pm

Working on a filter by country extension and it seems to be working correctly. I have a few issues and concerns.

I am using the core.user_setup_after event for blocking traffic. That's where I check the IP and if it is not associated with allowed countries. I use trigger_error to block traffic:

Code: Select all

			// Not allowed to see board content, so present warning message. Provide a login link if allowed.
			if ($this->config['phpbbservices_filterbycountry_allow_out_of_country_logins'])
				@trigger_error($this->language->lang('ACP_FBC_DENY_ACCESS_LOGIN', $user_ip, $country, $this->phpbb_root_path . "ucp.$this->phpEx?mode=login"), E_USER_WARNING);
				@trigger_error($this->language->lang('ACP_FBC_DENY_ACCESS', $user_ip, $country), E_USER_WARNING);
Is this the best event to use? There are other candidates out there. There is core.user_setup, but language files aren't initialized at this point so I can't show errors in the user's language. There is also core.session_create_after and a number of session variants. Whatever event is used, it has to be one that gets hit with every page.

Since errors can optionally be logged, I have noticed I always get duplicates in the log for the same user at the exact time, and in the statistics table I create if statistics are logged. I don't understand it. You can see the full code here. I don't think it's my code. I think it's something else going on in phpBB. Maybe the trigger_error() function causes an automatic page refresh. I've tried creating a cookie and testing for the presence of a cookie before writing to the log, but that doesn't seem to work. Any ideas?
Get the latest versions of my Digests and Smartfeed extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

Post Reply

Return to “Extension Writers Discussion”