Page 5 of 10

Re: [BETA] Filter by country - version 1.0.2

Posted: Mon Jun 17, 2019 4:30 pm
by MarkDHamill
These are excellent ideas. Maybe using a function like htmlspecialchars() is all I need when loading the $countries array. If not, using the array approach sounds promising.

Re: [BETA] Filter by country - version 1.0.2

Posted: Mon Jun 17, 2019 4:43 pm
by </Solidjeuh>
Great, already a solution found :D I updated the NL file

Re: [BETA] Filter by country - version 1.0.2

Posted: Mon Jun 17, 2019 5:43 pm
by MarkDHamill
We don't know if these solutions will work. That will take time.

Re: [BETA] Filter by country - version 1.0.2

Posted: Mon Jun 17, 2019 7:30 pm
by EA117
Not something I was already aware of, but it appears to be expected behavior out of DOMDocument::loadHTML when the string source you're loading from isn't a complete document that starts with an identifiable encoding declaration: https://stackoverflow.com/a/8218649

Suggesting that since you know and control that the PHP language file will be in UTF-8 encoding, it might be solved minimally in the existing code by pre-pending the string containing only <option> fields with a document element that declares encoding:

$dom->loadHTML( '<?xml encoding="utf-8" ?>' . $this->language->lang('ACP_FBC_OPTIONS') );

Which of course means that canonknipser's redesign recommendation would also solve the issue, by eliminating "what will DOMDocument::loadHTML do" from the equation entirely.

Re: [BETA] Filter by country - version 1.0.2

Posted: Mon Jun 17, 2019 7:40 pm
by 3Di
MarkDHamill wrote:
Mon Jun 17, 2019 4:30 pm
These are excellent ideas. Maybe using a function like htmlspecialchars() is all I need when loading the $countries array. If not, using the array approach sounds promising.
try (tested with another extension)

Code: Select all

$xml_countries = $dom->getElementsByTagName('option');

$xml_countries = @iconv('UTF-8', 'UTF-8//IGNORE', $xml_countries);

Re: [BETA] Filter by country - version 1.0.2

Posted: Mon Jun 17, 2019 7:41 pm
by </Solidjeuh>
EA117 wrote:
Mon Jun 17, 2019 7:30 pm
$dom->loadHTML( '<?xml encoding="utf-8" ?>' . $this->language->lang('ACP_FBC_OPTIONS') );
I can confirm that this works.
Replacing $dom->loadHTML($this->language->lang('ACP_FBC_OPTIONS')); with $dom->loadHTML( '<?xml encoding="utf-8" ?>' . $this->language->lang('ACP_FBC_OPTIONS') );

Image

Re: [BETA] Filter by country - version 1.0.2

Posted: Tue Jun 18, 2019 1:50 am
by MarkDHamill
Awesome suggestions and testing everyone! I'll incorporate these soon (in the middle of a big job at the moment).

Re: [BETA] Filter by country - version 1.0.2

Posted: Thu Jul 04, 2019 2:18 am
by MarkDHamill
Okay, looking at this again as I have the time after two big upgrade projects.

I think I figured out a way around the dual logging and stat collection issue on a page. Using cookies wasn't working but then I figured a better approach was to use static arrays and keep a running tally of IPs already logged in an array. If the IP is not already in the static array and logging is desired, logging occurs. If statistics are being collected, the IP is tracked in the phpbb_fbc_stats table but only once by using the same approach. This should allow for multi-user access on busy boards where two log entries may occur at the same second from different IPs. Hopefully I can package this up soon for your testing.

Re: [BETA] Filter by country - version 1.0.2

Posted: Thu Jul 04, 2019 9:55 pm
by MarkDHamill
</Solidjeuh>, here are the language changes for version 1.0.3:

In /language/en/common.php:

From:

Code: Select all

	'ACP_FBC_IP_NOT_FOUND_EXPLAIN'		=> 'If a user’s IP addresses isn’t in the database, it’s most likely because it is associated with a virtual private network (VPN) service. Enabling this option will let in users using VPN services, but could also allow entry by spammers.',
To:

Code: Select all

	'ACP_FBC_IP_NOT_FOUND_EXPLAIN'		=> 'If a user’s IP addresses isn’t in the database, it’s likely from a virtual private network (VPN) service. Enabling this option will let in users using VPN services, but could also let in some spammers.',
and from:

Code: Select all

	'ACP_FBC_UNKNOWN'					=> 'Unknown',
to:

Code: Select all

	'ACP_FBC_UNKNOWN'					=> 'VPN (unknown)',

Re: [BETA] Filter by country - version 1.0.2

Posted: Thu Jul 04, 2019 10:43 pm
by </Solidjeuh>
MarkDHamill wrote:
Thu Jul 04, 2019 9:55 pm
</Solidjeuh>, here are the language changes for version 1.0.3:
https://github.com/Solidjeuh/filterbycountry

Re: [BETA] Filter by country - version 1.0.2

Posted: Thu Jul 04, 2019 10:50 pm
by MarkDHamill
Awesome! Thanks!

Re: [BETA] Filter by country - version 1.0.3

Posted: Thu Jul 04, 2019 11:30 pm
by MarkDHamill
Version 1.0.3-beta is released. See the first post for download links.

In this version:
  • Fixed bug that was keeping special characters from being seen in the list of country names. Thanks EA117 for the fix!
  • Fixed bug that was recording in the log and in the statistics duplicate page requests
  • Clarified that when the IP is not found in the MaxMind database, it is most likely because the IP is used by a VPN service. The report shows these statistic as "VPN (unknown)"
  • Updated Dutch language translation, which also includes special characters that were stripped out of country names.
Thanks to all who tested and provided feedback.

Re: [BETA] Filter by country - version 1.0.3

Posted: Fri Jul 05, 2019 12:09 am
by </Solidjeuh>
Okay installed the new version. Seems to work.
Tested a Russian proxy, and the connection was blocked. All good!

Image

Re: [BETA] Filter by country - version 1.0.3

Posted: Fri Jul 05, 2019 1:09 pm
by </Solidjeuh>
Got an error in the forum error log

Code: Select all

Error while creating an image
»Error in [ROOT] /ext/phpbbservices/filterbycountry/core/common.php on line 134: gzopen(./store/phpbbservices/filterbycountry/GeoLite2-Country.tar.gz): failed to open stream: No such file or directory
Image

Re: [BETA] Filter by country - version 1.0.3

Posted: Fri Jul 05, 2019 1:54 pm
by MarkDHamill
I'm guessing it's an issue updating your database. Make sure the permission is the /store and the /store/phpbbservice/filterbycountry folders are 777. You can try just deleting the folder. It should get recreated.