[RC] Filter by country - version 1.0.7

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!
Ideas Centre
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)
Post Reply
User avatar
</Solidjeuh>
Registered User
Posts: 1703
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [RC] Filter by country - version 1.0.4

Post by </Solidjeuh> » Mon Jul 29, 2019 2:23 pm

I wonder why I see no flags ... ? (latest version)
I just noticed this, never saw them in any other previous versions also

Image

User avatar
MarkDHamill
Registered User
Posts: 3876
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [RC] Filter by country - version 1.0.4

Post by MarkDHamill » Mon Jul 29, 2019 2:30 pm

Flags are a new feature. You can try purging the cache to see if they show up but if you follow the standard procedure for enabling extensions (first disabling them, removing the files and uploading new ones) it shouldn't matter. You can also look at the HTML markup. The markup should look like this:

Code: Select all

		<tbody>
					<tr>
				<td headers="country"><img src="./../ext/phpbbservices/filterbycountry/flags/BE.png" alt="Belgium" title="Belgium"> <span>Belgium</span></td><td headers="allowed" class="center">514</td><td headers="restricted" class="center">28</td>
			</tr>
					<tr>
				<td headers="country"><img src="./../ext/phpbbservices/filterbycountry/flags/US.png" alt="United States" title="United States"> <span>United States</span></td><td headers="allowed" class="center">16</td><td headers="restricted" class="center">91</td>
			</tr>
					<tr>
				<td headers="country"><span>VPN (unknown)</span></td><td headers="allowed" class="center">547</td><td headers="restricted" class="center">0</td>
			</tr>
		</tbody>
Get the latest versions of my Digests and Smartfeed extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
</Solidjeuh>
Registered User
Posts: 1703
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [RC] Filter by country - version 1.0.4

Post by </Solidjeuh> » Mon Jul 29, 2019 2:32 pm

MarkDHamill wrote:
Mon Jul 29, 2019 2:30 pm
Flags are a new feature. You can try purging the cache to see if they show up but if you follow the standard procedure for enabling extensions (first disabling them, removing the files and uploading new ones) it shouldn't matter. You can also look at the HTML markup. The markup should look like this:

Code: Select all

		<tbody>
					<tr>
				<td headers="country"><img src="./../ext/phpbbservices/filterbycountry/flags/BE.png" alt="Belgium" title="Belgium"> <span>Belgium</span></td><td headers="allowed" class="center">514</td><td headers="restricted" class="center">28</td>
			</tr>
					<tr>
				<td headers="country"><img src="./../ext/phpbbservices/filterbycountry/flags/US.png" alt="United States" title="United States"> <span>United States</span></td><td headers="allowed" class="center">16</td><td headers="restricted" class="center">91</td>
			</tr>
					<tr>
				<td headers="country"><span>VPN (unknown)</span></td><td headers="allowed" class="center">547</td><td headers="restricted" class="center">0</td>
			</tr>
		</tbody>
I disabled the ext and deleted data, deleted all old files and uploaded new ones. but still no flags. This is the source code:

Code: Select all

<td headers="country"><span>België</span></td><td headers="allowed" class="center">338</td><td headers="restricted" class="center">0</td>
</tr>
<tr>
<td headers="country"><span>China</span></td><td headers="allowed" class="center">0</td><td headers="restricted" class="center">3</td>
</tr>
<tr>
<td headers="country"><span>Duitsland</span></td><td headers="allowed" class="center">37</td><td headers="restricted" class="center">0</td>
</tr>
<tr>
<td headers="country"><span>Frankrijk</span></td><td headers="allowed" class="center">398</td><td headers="restricted" class="center">0</td>
</tr>
<tr>
<td headers="country"><span>Ierland</span></td><td headers="allowed" class="center">2</td><td headers="restricted" class="center">0</td>
</tr>
<tr>
<td headers="country"><span>Nederland</span></td><td headers="allowed" class="center">846</td><td headers="restricted" class="center">0</td>
</tr>
<tr>
<td headers="country"><span>Oekraïne</span></td><td headers="allowed" class="center">3</td><td headers="restricted" class="center">0</td>
</tr>
<tr>
<td headers="country"><span>Russische Federatie</span></td><td headers="allowed" class="center">0</td><td headers="restricted" class="center">15</td>
</tr>
<tr>
<td headers="country"><span>Verenigde Staten</span></td><td headers="allowed" class="center">196</td><td headers="restricted" class="center">0</td>

User avatar
MarkDHamill
Registered User
Posts: 3876
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [RC] Filter by country - version 1.0.4

Post by MarkDHamill » Mon Jul 29, 2019 2:48 pm

This is odd. I checked GitHub (the master and branch) and my archive and the changes are in all of them. Here's an example on the GitHub master.

Code: Select all

				<td headers="country">{% if country.S_SHOW_FLAG %}{{ country.FLAG }} {% endif %}<span>{{ country.TEXT }}</span></td><td headers="allowed" class="center">{{ country.ALLOWED }}</td><td headers="restricted" class="center">{{ country.RESTRICTED }}</td>
My best guess is that the file_exists function is failing:

https://github.com/MarkDHamill/filterby ... r.php#L375

Code: Select all

							'S_SHOW_FLAG'	=> (file_exists('./../ext/phpbbservices/filterbycountry/flags/' . $row['country_code'] . '.png')) ? true : false,
The flags should be in the extension's flags folder.
Get the latest versions of my Digests and Smartfeed extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
MarkDHamill
Registered User
Posts: 3876
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [RC] Filter by country - version 1.0.4

Post by MarkDHamill » Mon Jul 29, 2019 2:52 pm

Must be a case problem. Try lowercasing it. It works for me, but my configuration of PHP must be more forgiving:

Code: Select all

							'S_SHOW_FLAG'	=> (file_exists('./../ext/phpbbservices/filterbycountry/flags/' . strtolower($row['country_code']) . '.png')) ? true : false,
Get the latest versions of my Digests and Smartfeed extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
</Solidjeuh>
Registered User
Posts: 1703
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [RC] Filter by country - version 1.0.4

Post by </Solidjeuh> » Mon Jul 29, 2019 2:53 pm

MarkDHamill wrote:
Mon Jul 29, 2019 2:48 pm
This is odd. I checked GitHub (the master and branch) and my archive and the changes are in all of them. Here's an example on the GitHub master.

Code: Select all

				<td headers="country">{% if country.S_SHOW_FLAG %}{{ country.FLAG }} {% endif %}<span>{{ country.TEXT }}</span></td><td headers="allowed" class="center">{{ country.ALLOWED }}</td><td headers="restricted" class="center">{{ country.RESTRICTED }}</td>
My best guess is that the file_exists function is failing:

https://github.com/MarkDHamill/filterby ... r.php#L375

Code: Select all

							'S_SHOW_FLAG'	=> (file_exists('./../ext/phpbbservices/filterbycountry/flags/' . $row['country_code'] . '.png')) ? true : false,
The flags should be in the extension's flags folder.
Correct, this code is working:

Code: Select all

							'S_SHOW_FLAG'	=> ('./../ext/phpbbservices/filterbycountry/flags/' . $row['country_code'] . '.png')
But the flags are giving a wrong URL.
/ext/phpbbservices/filterbycountry/flags/CN.png (image not found)
It should be:
/ext/phpbbservices/filterbycountry/flags/cn.png (Note the capital letters)

Code: Select all

'S_SHOW_FLAG'	=> (file_exists('./../ext/phpbbservices/filterbycountry/flags/' . strtolower($row['country_code']) . '.png')) ? true : false,
Give the same result, image not found (uppercase)

User avatar
MarkDHamill
Registered User
Posts: 3876
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [RC] Filter by country - version 1.0.4

Post by MarkDHamill » Mon Jul 29, 2019 3:09 pm

This is still very strange. I presume the flags directory exists and all the files are inside of it.

You can try replacing file_exists() with is_readable(). I suppose it's possible the file exists but cannot be read.
Get the latest versions of my Digests and Smartfeed extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
</Solidjeuh>
Registered User
Posts: 1703
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [RC] Filter by country - version 1.0.4

Post by </Solidjeuh> » Mon Jul 29, 2019 3:11 pm

MarkDHamill wrote:
Mon Jul 29, 2019 3:09 pm
This is still very strange. I presume the flags directory exists and all the files are inside of it.

You can try replacing file_exists() with is_readable(). I suppose it's possible the file exists but cannot be read.
Also not working.
Yes, the images are present: https://www.solidjeuh.be/ext/phpbbservices/filterbycountry/flags/be.png
but the code is just giving this: https://www.solidjeuh.be/ext/phpbbservices/filterbycountry/flags/BE.png

User avatar
MarkDHamill
Registered User
Posts: 3876
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [RC] Filter by country - version 1.0.4

Post by MarkDHamill » Mon Jul 29, 2019 3:14 pm

I don't think your table is multi-byte, but it can't hurt to try mb_strtolower() instead of strtolower().
Get the latest versions of my Digests and Smartfeed extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
</Solidjeuh>
Registered User
Posts: 1703
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [RC] Filter by country - version 1.0.4

Post by </Solidjeuh> » Mon Jul 29, 2019 3:17 pm

MarkDHamill wrote:
Mon Jul 29, 2019 3:14 pm
I don't think your table is multi-byte, but it can't hurt to try mb_strtolower() instead of strtolower().
Nope same result... I think it's just easier that I rename all images :lol:

User avatar
MarkDHamill
Registered User
Posts: 3876
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [RC] Filter by country - version 1.0.4

Post by MarkDHamill » Mon Jul 29, 2019 3:23 pm

Try replacing the block of code starting after line 369 in /controller/acp_controller.php as follows:

Code: Select all

						$filename = strtolower($row['country_code']) . 'png';
						echo $filename . '<br>';
						$this->template->assign_block_vars('countries', array(
							'FLAG'			=> '<img src="./../ext/phpbbservices/filterbycountry/flags/' . $filename. '" alt="' . $countries[$row['country_code']]. '" title="' . $countries[$row['country_code']]. '">',
							'TEXT'        	=> $countries[$row['country_code']],
							'ALLOWED'		=> $allowed_count,
							'RESTRICTED'	=> $not_allowed_count,
							'S_SHOW_FLAG'	=> (file_exists('./../ext/phpbbservices/filterbycountry/flags/' . $filename)) ? true : false,
						));
This will throw up some debug code but will help show where the problem lies.
Get the latest versions of my Digests and Smartfeed extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
</Solidjeuh>
Registered User
Posts: 1703
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [RC] Filter by country - version 1.0.4

Post by </Solidjeuh> » Mon Jul 29, 2019 3:31 pm

I now see this at the top

Code: Select all

bepng
cnpng
depng
frpng
hnpng
iepng
nlpng
uapng
rupng
czpng
gbpng
uspng

User avatar
MarkDHamill
Registered User
Posts: 3876
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [RC] Filter by country - version 1.0.4

Post by MarkDHamill » Mon Jul 29, 2019 3:33 pm

Oopsie. Let's make line 370:

Code: Select all

						$filename = strtolower($row['country_code']) . '.png';
Get the latest versions of my Digests and Smartfeed extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
</Solidjeuh>
Registered User
Posts: 1703
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [RC] Filter by country - version 1.0.4

Post by </Solidjeuh> » Mon Jul 29, 2019 3:39 pm

MarkDHamill wrote:
Mon Jul 29, 2019 3:33 pm
Oopsie. Let's make line 370:

Code: Select all

						$filename = strtolower($row['country_code']) . '.png';
Line 370 is: $this->template->assign_block_vars('countries', array(

User avatar
MarkDHamill
Registered User
Posts: 3876
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [RC] Filter by country - version 1.0.4

Post by MarkDHamill » Mon Jul 29, 2019 3:42 pm

Our line numbers are different.

Replace the two lines above:

Code: Select all

						$this->template->assign_block_vars('countries', array(
with:

Code: Select all

						$filename = strtolower($row['country_code']) . '.png';
						echo $filename . '<br>';
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 “Extensions in Development”