•  » Beta testing
  •  » Public Beta: Bot Protection Plugin for Piwigo

#1 2025-06-01 17:36:26

Schneider-Fotografie
Member
Berlin
2023-04-16
151

Public Beta: Bot Protection Plugin for Piwigo

Hello


I am happy to announce the public beta of my new plugin Bot Protection for Piwigo. This plugin is designed for anyone who wants to protect their gallery from unwanted bots and direct access attempts.

What does the plugin do?

Blocks known bots and malicious user agents
Access attempts from a customizable list of known crawlers and bad bots are automatically blocked.

Protects against direct access
Requests without a valid HTTP referer can optionally be blocked. This makes it harder for automated tools to directly access image URLs or API endpoints.

Logs blocked access attempts
Every blocked request is logged with timestamp, IP address, and user agent. Logs are viewable in the admin area.

Easy admin interface
All settings, the bot list, and access logs are accessible from the plugin menu in the admin panel.

Works on shared hosting
No special server configuration or additional software required – it runs entirely on PHP and within the Piwigo framework.

Goals of the beta

Feedback on the reliability of the protection

Suggestions for improving the interface and settings

Reports on compatibility with other plugins and themes

If you want to make your gallery more secure, feel free to try out the plugin and share your experiences in this forum thread.

Download (Beta version): Bot Protection
Feedback welcome here:

Thanks for your support,
Olaf


-Schneider-Photography- Gallery
----------------------------------
BYB | Block You Bots
„Stay human. I block the rest.“

Offline

 

#2 2025-06-03 16:54:08

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
14059

Re: Public Beta: Bot Protection Plugin for Piwigo

Hi Olaf,

Very interesting. Bots have been a real pain for years. On Piwigo.com, where we host thousands of Piwigo installations, I would say bots are making between 80 to 95% of the incoming HTTP requests. That's crazy. For many of them, I have no idea what they're doing here. Just scanning all the web pages they can with no goal :-/

I haven't analyzed your code yet but I have several questions/remarks/recommandations:

1) why don't you host your code on Github? It would be so much easier for us to follow the commits, have an issue tracker, let piwigo.org generate the zip archive...

2) do not use a "data" directory within the plugin directory. Use $conf['data_location'].'bot_protection' instead. It's mandatory for Piwigo installations using the multisite features (like piwigo.com). See examples of use in [extension by mistic100] Batch Downloader or [extension by plg] Prepaid Credits

Offline

 

#3 2025-06-04 05:49:05

Schneider-Fotografie
Member
Berlin
2023-04-16
151

Re: Public Beta: Bot Protection Plugin for Piwigo

Hi Plg,

Thanks a lot for your feedback — and yes, you're absolutely right: the bot situation is insane. Seeing 80–95% bot traffic on Piwigo.com just confirms how widespread and damaging this issue is. That’s exactly why I started developing this plugin — to give admins more control and insight without needing server-level tools.

Regarding your questions:

GitHub hosting: You're absolutely right. I've been developing locally so far, but I completely agree that GitHub is the better place for collaboration, issue tracking, and transparency. I’ll prepare the repository and move development there shortly. I’ll also ensure the plugin is compatible with the automatic zip generation on piwigo.org.

Use of $conf['data_location']: Yes, good point — and I’ve already updated the plugin accordingly. All data files (logs, blocklists, stats etc.) are now stored in PWG_LOCAL_DIR . $conf['data_location'].'bot_protection/' to ensure compatibility with multisite setups like Piwigo.com. I’ll double-check that all references are updated consistently throughout the code.

Thanks again for your remarks — they’re much appreciated. Once the GitHub repo is live, I’ll share the link.

Best regards
Olaf


Bot Protection Plugin – Dokumentation

Last edited by Schneider-Fotografie (2025-06-04 06:22:14)


-Schneider-Photography- Gallery
----------------------------------
BYB | Block You Bots
„Stay human. I block the rest.“

Offline

 

#4 2025-06-04 07:22:54

Katryne
Member
Provence, France
2016-12-03
580

Re: Public Beta: Bot Protection Plugin for Piwigo

Olaf, I'm interested in this plugin, but I'll wait for the final version. I spend too much time managing the robots that overload the servers of my shared hosting. On my little site, I had up to 70,000 visitors/day at the end of 2024, I managed to normalize the flow to 200 or 300, although in February I still had peaks of 20,000 or 30,000. The 70,000 peak was due to the Apache version being upgraded to 2.4 and htaccess no longer stopping anything. So I asked ChatGPT to convert my .htaccess to the new syntax. There are many online converters, but I kept it simple and it worked.
I have 3 types of online sites: one for genealogy, one for classified articles and the Piwigo. Each of them has a little something extra to combat invading robots: the texts site has an htaccess editor from the admin, with no need to access ftp. The genealogy site has a bot trap that detects rapid visits and bans the IPs concerned directly in the htaccess. In principle, I use practically the same htaccess on all my sites, because I copy the content from one to another.
Thanks for your devlopment, I look forward to it.


https://album.chauvigne.info/ v.16.4  PHP: 8.2.29
Système d'exploitation: Linux - Hébergeur 1&1-Ionos - MySQL: 5.7.42
Bibliothèque graphique: External ImageMagick 6.9.11-60

Offline

 

#5 2025-06-04 10:50:23

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
14059

Re: Public Beta: Bot Protection Plugin for Piwigo

Unfortunately, you have removed the plugin from piwigo.org/ext :-/

Offline

 

#6 2025-06-04 20:32:21

Schneider-Fotografie
Member
Berlin
2023-04-16
151

Re: Public Beta: Bot Protection Plugin for Piwigo

Hello

Bot Protection 1.0.0 – Available now!
Bot Protection helps you control and limit unwanted bots while allowing useful crawlers like Googlebot or Bingbot. Keep your server responsive and protect your content from aggressive indexing.

Features
- Block access from known bad bots (e.g. SemrushBot, AhrefsBot, MJ12bot)
- Allow and set limits for good bots (e.g. Googlebot, Bingbot)
- Custom whitelist and blocklist management
- Referrer & cookie check to detect real visitors
- Daily visitor statistics with chart
- Detailed log and statistics for blocked bots
- IP blocking support
- Fully integrated admin interface with tabbed layout

Compatibility
- Tested with Piwigo 15.5.0
- Compatible with PHP 8.3.21
- Works on shared hosting
- No external libraries required

Installation
- Upload the plugin to your /plugins/ directory
- Activate it in the Piwigo admin panel
- Go to [Plugins » Bot Protection] to configure settings

I look forward to your feedback!

Best regards from Berlin

Olaf

Bot Protection 1.0.0 – Now Available!

Last edited by Schneider-Fotografie (2025-06-04 20:37:43)


-Schneider-Photography- Gallery
----------------------------------
BYB | Block You Bots
„Stay human. I block the rest.“

Offline

 

#7 2025-06-04 22:47:02

Katryne
Member
Provence, France
2016-12-03
580

Re: Public Beta: Bot Protection Plugin for Piwigo

Hello Olaf. Installed it easily on test site. Did not change any setting. But I was forbiden to access the site, being an unconnected ordinary visitor and clicking on a link to the home page. Message says : Direct access not allowed.

With the browser Vivaldi where I never connect, I can access to the site if I enter the URL letter by letter, but not if I copy and paste the url or if I click on the url registered elsewhere, in a mail, on a forum or in my saved links.

Is this an expected result? See : https://blackland.legtux.org/


https://album.chauvigne.info/ v.16.4  PHP: 8.2.29
Système d'exploitation: Linux - Hébergeur 1&1-Ionos - MySQL: 5.7.42
Bibliothèque graphique: External ImageMagick 6.9.11-60

Offline

 

#8 2025-06-05 00:02:46

Schneider-Fotografie
Member
Berlin
2023-04-16
151

Re: Public Beta: Bot Protection Plugin for Piwigo

Code:

Fatal error: Uncaught mysqli_sql_exception: Data too long for column 'IP' at row 1 in /var/www/legtux.org/users/blackland/www/include/dblayer/functions_mysqli.inc.php:132 Stack trace: #0 /var/www/legtux.org/users/blackland/www/include/dblayer/functions_mysqli.inc.php(132): mysqli->query() #1 /var/www/legtux.org/users/blackland/www/plugins/AntiAspi/main.inc.php(127): pwg_query() #2 /var/www/legtux.org/users/blackland/www/include/functions_plugins.inc.php(264): antiaspi() #3 /var/www/legtux.org/users/blackland/www/include/section_init.inc.php(705): trigger_notify() #4 /var/www/legtux.org/users/blackland/www/index.php(12): include('...') #5 {main} thrown in /var/www/legtux.org/users/blackland/www/include/dblayer/functions_mysqli.inc.php on line 132

Plugin AntiAspi:

Hello Katryne

What does this mean?
The plugin AntiAspi is trying to store an IP address in the database, but the column defined for it is too short to hold the value.

Likely Cause:
Many plugins or database setups define the IP column as VARCHAR(15), which is only enough to store IPv4 addresses (like 192.168.0.1). However, if a visitor uses an IPv6 address (like 2001:0db8:85a3:0000:0000:8a2e:0370:7334), that address won't fit, and MySQL throws a “Data too long” error.

How to Fix:
Identify the table where the plugin logs the IP address (for example, something like piwigo_antiaspi_log).

Update the IP column in that table using this SQL command:

Code:

ALTER TABLE piwigo_antiaspi_log MODIFY COLUMN IP VARCHAR(45);

-Schneider-Photography- Gallery
----------------------------------
BYB | Block You Bots
„Stay human. I block the rest.“

Offline

 

#9 2025-06-05 00:16:20

Katryne
Member
Provence, France
2016-12-03
580

Re: Public Beta: Bot Protection Plugin for Piwigo

Thanks Olaf. It's too late for me to go exploring the data base, to make the field longer.
So I disabled the anti-aspi plugin, but I still have this "Direct access not allowed." as a visitor though I can reach the home page with a refreshing of the page.
I will look better tomorrow.


https://album.chauvigne.info/ v.16.4  PHP: 8.2.29
Système d'exploitation: Linux - Hébergeur 1&1-Ionos - MySQL: 5.7.42
Bibliothèque graphique: External ImageMagick 6.9.11-60

Offline

 

#10 2025-06-05 06:53:11

Schneider-Fotografie
Member
Berlin
2023-04-16
151

Re: Public Beta: Bot Protection Plugin for Piwigo

Hi Piwigo team,

I just noticed that my plugins smileys_votes, bot_protection, and like_dislike have disappeared from the extensions directory, and my account no longer shows any entries.

I didn’t receive any message or explanation, so this came as quite a surprise. Could you please let me know why the plugins were removed? Was there a problem or a report from someone?

I’d really like to understand what happened and – if needed – I’m happy to make adjustments or fix any issues.

Thanks in advance for your reply!

Best regards,
Olaf


-Schneider-Photography- Gallery
----------------------------------
BYB | Block You Bots
„Stay human. I block the rest.“

Offline

 

#11 2025-06-05 10:33:22

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
14059

Re: Public Beta: Bot Protection Plugin for Piwigo

Hi Olaf,

Yes, a hacker has deleted some extensions. We have restored but there is one zip we can't restore and it's yours. Can you publish again a revision 1.0.0 with this text :

This plugin protects your Piwigo gallery from unwanted bots and crawlers.
It blocks common bad bots, lets you whitelist trusted bots like Googlebot and Bingbot,
and provides detailed logs and statistics.

Features:
- Block SemrushBot, AhrefsBot, MJ12bot, DotBot, and more
- Allow Googlebot, Googlebot-Image, Bingbot etc. with daily limits
- IP blocking and referer/cookie checks
- Detailed statistics (bot log, whitelist, visitor stats)
- GDPR compliant (no plain IP storage)

Offline

 

#12 2025-06-05 10:35:55

Katryne
Member
Provence, France
2016-12-03
580

Re: Public Beta: Bot Protection Plugin for Piwigo

Direct access via bookmark links was blocked by the checkbox on the plugin's 1st configuration tab: Block access without referer or cookies (or something like that, I can't get the configuration page back into English).
If I uncheck it, will the plugin continue to block robots?


https://album.chauvigne.info/ v.16.4  PHP: 8.2.29
Système d'exploitation: Linux - Hébergeur 1&1-Ionos - MySQL: 5.7.42
Bibliothèque graphique: External ImageMagick 6.9.11-60

Offline

 

#13 2025-06-05 10:41:32

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
14059

Re: Public Beta: Bot Protection Plugin for Piwigo

Schneider-Fotografie wrote:

I didn’t receive any message or explanation, so this came as quite a surprise. Could you please let me know why the plugins were removed? Was there a problem or a report from someone?

Absolutely not. You're a collateral damage :-/ We're fixing the permission issue and we're adding some checks to prevent this hack to happen in the future.

We're happy to have backups, even if your last revision was not among them. By the way, if you had your code on Github, I could have republished it.

Offline

 

#14 2025-06-05 10:53:47

Schneider-Fotografie
Member
Berlin
2023-04-16
151

Re: Public Beta: Bot Protection Plugin for Piwigo

Hi PLG,

Thanks for your reply – it’s good to know that the issue was caused by a hacker and not something I did wrong. Of course, it’s not a good situation, and it's quite serious that extensions could be deleted like that. I hope you've been able to secure things on your side since then.

Too bad my ZIP couldn’t be recovered, but no problem – I’ll re-upload the 1.0.0 revision as you suggested.

Do you have any more details about the incident?
For example:

- When did it happen?
- How did the attacker get access?
- Were only ZIPs deleted or were other files affected too?
- And what steps have been taken to prevent something like this in the future?

Depending on how the attack was carried out, I might also consider making some adjustments to my plugin to make sure there are no security issues on my side either.

Best regards,
Olaf


-Schneider-Photography- Gallery
----------------------------------
BYB | Block You Bots
„Stay human. I block the rest.“

Offline

 

#15 2025-06-05 11:46:22

Schneider-Fotografie
Member
Berlin
2023-04-16
151

Re: Public Beta: Bot Protection Plugin for Piwigo

The Bot Protection plugin – version 1.0.0 is back online.
It will soon be published on GitHub as well, so you can view and follow the source code openly.

Best regards,
Olaf


-Schneider-Photography- Gallery
----------------------------------
BYB | Block You Bots
„Stay human. I block the rest.“

Offline

 
  •  » Beta testing
  •  » Public Beta: Bot Protection Plugin for Piwigo

Board footer

Powered by FluxBB