[3.3][RC] Filter by country - version 1.0.16

A place for Extension Authors to post and receive feedback on Extensions still in development. No Extensions within this forum should be used within a live environment!
Scam Warning
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: Extensions Development rules

IMPORTANT FOR NEEDED EVENTS!!!
If you need an event for your extension please read this for the steps to follow to request the event(s)
User avatar
MarkDHamill
Registered User
Posts: 4282
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [3.3][RC] Filter by country - version 1.0.13

Post by MarkDHamill »

I have noticed in my testing that what can often happen is that two entries in the phpbb_fbc_stats table can occur for the same country a second apart.

I still don't understand why the core.user_setup_after event seems to be called more than once when accessing a page. I tie into the event to prohibit or allow access by country. One workaround it simply to see if there is a similar statistic logged a second earlier and if so not save the statistic. This seems to work but might potentially create an under count of statistics on very highly trafficked boards. For example, it's possible with some sort of denial of service attack coming from a country like Belarus only one page request will get recorded over two seconds when there really were more than that occurring in a very short period of time.

Toward that end I have added a configuration variable where this value can be set in the extension's settings page, defaulting to one second. It is possible that if you have a slow database you might want to up the setting to two or more second. Zero disables it.
Attachments
Screen Shot 2020-07-05 at 11.22.54 AM.png
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. Kindle and paper versions available.
User avatar
RMcGirr83
Former Team Member
Posts: 21614
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: [3.3][RC] Filter by country - version 1.0.13

Post by RMcGirr83 »

Not sure where you're getting that it's called twice. From my testing on my test forum, it's only called once per user.
Appreciate the extensions/mods/support then buy me a beerImage
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
User avatar
MarkDHamill
Registered User
Posts: 4282
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [3.3][RC] Filter by country - version 1.0.13

Post by MarkDHamill »

Thanks for your testing. It seems to happen sporadically when access is allowed, not when it is rejected. But it seems kind of random.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. Kindle and paper versions available.
User avatar
MarkDHamill
Registered User
Posts: 4282
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

[3.3][RC] Filter by country - version 1.0.15

Post by MarkDHamill »

Version 1.0.15 is released. See the first post for download links.

Since the last version was 1.0.13, you might be wondering why this is 1.0.15. I committed 1.0.14 and realized I left out a few things, so I added them.

Changes from version 1.0.13:
  • As requested, you can now see in the statistics those who logged in from a restricted country if that feature is allowed.
  • Users have noticed what appears to be a lot of excess statistics being collected. It appears that the event the extension uses is getting called twice in some circumstances. The work around is to not allow a statistic to be created if it was added "recently". Recently defaults to 1 second. You can change this interval on the settings page. Setting it to 0 disables it.
  • As requested, you can now easily reset the statistics. Look for a button on the statistics page.
  • As in the patch, to avoid a SQL error you can't insert the same country more than once at a time. This happened if the same IP was in multiple HTTP headers.
  • There is a convenient button to blank out the test IP field on the settings page.
  • A bug in the login link was fixed.
  • If you are blocked because your country is unknown, this is noted in the error message.
Overall, this release seems much more consistent and straightforward, so hopefully no errors will be noted. Please test and if no issues I will submit the extension for another review.

A list of all changes from version 1.0.13 is here.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. Kindle and paper versions available.
User avatar
janus_zonstraal
Registered User
Posts: 4857
Joined: Sat Aug 30, 2014 1:30 pm

Re: [3.3][RC] Filter by country - version 1.0.15

Post by janus_zonstraal »

Installed 1.0.15
Only lay-out looks strange to me?
Screenshot_2020-07-06 Filter by country.png
Sorry! My English is bat ;) !!!
bug-i
Registered User
Posts: 132
Joined: Fri Feb 17, 2017 12:45 pm

Re: [3.3][RC] Filter by country - version 1.0.15

Post by bug-i »

ah, I know what boosts the page requests in my stats. I am using the popular mchat-module: https://www.phpbb.com/customise/db/exte ... extension/

Mchat refreshes itself every 5 seconds (standard is 10), nevertheless this means that every 5 (10) seconds every user will generate an new page request, even if the user is "inactive" and just visits the mainpage (where mchat is visible).

Technically - nothings wrong with Filter by country, it does what it is supposed to do, so no urgent need to fix this, but it would be nice to have the option the have "clean" stats without "passive" page refreshes by mchat.

----

additionally with version 15 stats are counted wrong with vpn. I just tested it and my allowed visit with restricted country is counted wrong into Restricted page requests although I can access the forum. This should be fixed.
User avatar
MarkDHamill
Registered User
Posts: 4282
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [3.3][RC] Filter by country - version 1.0.15

Post by MarkDHamill »

janus_zonstraal wrote:
Mon Jul 06, 2020 4:03 pm
Installed 1.0.15
Only lay-out looks strange to me?
Screenshot_2020-07-06 Filter by country.png
Odd my editor didn't pick that up. In /adm/style/acp_filterbycountry_body.html after line 58:

Code: Select all

			<dd><input type="number" id="phpbbservices_filterbycountry_seconds" name="phpbbservices_filterbycountry_seconds" value="{{ FBC_SECONDS }}" min="0" />			</dd>
add below:

Code: Select all

		</dl>
Then purge the cache.
Last edited by MarkDHamill on Mon Jul 06, 2020 4:51 pm, edited 1 time in total.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. Kindle and paper versions available.
User avatar
MarkDHamill
Registered User
Posts: 4282
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [3.3][RC] Filter by country - version 1.0.15

Post by MarkDHamill »

bug-i wrote:
Mon Jul 06, 2020 4:33 pm
additionally with version 15 stats are counted wrong with vpn. I just tested it and my allowed visit with restricted country is counted wrong into Restricted page requests although I can access the forum. This should be fixed.
If the country would otherwise be restricted but "Allow registered users to login from restricted countries" is set to Yes, then if you are already logged in using the IP associated with a restricted country, it will count as an "Allowed page requests from restricted countries" hit on the Statistics page. If you are not logged in and this is set to Yes, you should get a link in the blocked message to the login page, which should work. No other links should work.

Remember multiple IPs are possible because multiple headers are checked. So one IP might be allowed, but another may not be allowed. In this case, access is restricted unless the above is true. Both hits should be recorded.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. Kindle and paper versions available.
bug-i
Registered User
Posts: 132
Joined: Fri Feb 17, 2017 12:45 pm

Re: [3.3][RC] Filter by country - version 1.0.15

Post by bug-i »

nope. Just cleared all stats and used a czech and swiss vpn for testing (and accessed the forum properly). Thats a screenshot what a I see in the stats. I think this is not correct, and the czech and swiss visits should have been counted into "Allowed page requests from restricted countries" and not into "Restricted page requests"
stats2.png
User avatar
janus_zonstraal
Registered User
Posts: 4857
Joined: Sat Aug 30, 2014 1:30 pm

Re: [3.3][RC] Filter by country - version 1.0.15

Post by janus_zonstraal »

Looks better now ;)
Sorry! My English is bat ;) !!!
User avatar
MarkDHamill
Registered User
Posts: 4282
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [3.3][RC] Filter by country - version 1.0.15

Post by MarkDHamill »

bug-i wrote:
Mon Jul 06, 2020 5:39 pm
nope. Just cleared all stats and used a czech and swiss vpn for testing (and accessed the forum properly). Thats a screenshot what a I see in the stats. I think this is not correct, and the czech and swiss visits should have been counted into "Allowed page requests from restricted countries" and not into "Restricted page requests"

stats2.png
What are the IP(s) involved? You can test MaxMind's evaluation of an IP here:

https://www.maxmind.com/en/geoip-demo/
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. Kindle and paper versions available.
bug-i
Registered User
Posts: 132
Joined: Fri Feb 17, 2017 12:45 pm

Re: [3.3][RC] Filter by country - version 1.0.15

Post by bug-i »

MarkDHamill wrote:
Mon Jul 06, 2020 7:23 pm
What are the IP(s) involved? You can test MaxMind's evaluation of an IP here:

https://www.maxmind.com/en/geoip-demo/
this doesnt matter. I used on purpose via vpn a swiss and czech ip which are blocked in my configuartion. As a have selected yes for "Allow registered users to login from restricted countries:" -> I had access to my board and my visits from both countries should have been counted into "allowed page request from restricted countries" not into "restricted page requests".
User avatar
MarkDHamill
Registered User
Posts: 4282
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [3.3][RC] Filter by country - version 1.0.15

Post by MarkDHamill »

bug-i wrote:
Mon Jul 06, 2020 7:35 pm
MarkDHamill wrote:
Mon Jul 06, 2020 7:23 pm
What are the IP(s) involved? You can test MaxMind's evaluation of an IP here:

https://www.maxmind.com/en/geoip-demo/
this doesnt matter. I used on purpose via vpn a swiss and czech ip which are blocked in my configuartion. As a have selected yes for "Allow registered users to login from restricted countries:" -> I had access to my board and my visits from both countries should have been counted into "allowed page request from restricted countries" not into "restricted page requests".
Thank you for reporting the issue. Apparently I didn't think through the logic for when the countries are allowed properly. It needs to reflect the logic for when countries are rejected. So in /event/main_listener.php change line 285 from:

Code: Select all

				$this_request_type = constants::ACP_FBC_REQUEST_RESTRICT;	// Not in one of the selected countries, so reject
to:

Code: Select all

				// If not from one of the selected countries, possibly allow in if they are already logged in
				$this_request_type = ($apply_outside) ? constants::ACP_FBC_REQUEST_OUTSIDE : constants::ACP_FBC_REQUEST_RESTRICT;
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. Kindle and paper versions available.
Tread
Registered User
Posts: 51
Joined: Thu Nov 14, 2019 9:52 pm

Re: [3.3][RC] Filter by country - version 1.0.15

Post by Tread »

Nice ext but way too easy to get around with a vpn maybe try blocking the browser language code for a country or part of a country.

Image
bug-i
Registered User
Posts: 132
Joined: Fri Feb 17, 2017 12:45 pm

Re: [3.3][RC] Filter by country - version 1.0.15

Post by bug-i »

MarkDHamill wrote:
Mon Jul 06, 2020 10:59 pm
Thank you for reporting the issue. Apparently I didn't think through the logic for when the countries are allowed properly. It needs to reflect the logic for when countries are rejected. So in /event/main_listener.php change line 285 from:
Thanks! Now it works! @all: Remember to clear board cache, otherwise changes probably do not have immediate impact.
Post Reply

Return to “Extensions in Development”