ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE. Software > DC Member Programs and Projects

GDPR Blocking (PHP Edition)

<< < (3/4) > >>

Specifically, in case he was being too obtuse, this in the code.

--- Code: PHP ---Prerequisites:  * PHP  * GeoIP as described here:

Though I wouldn't disagree that a bit of obtuseness was perhaps warranted in this case.

In fact, the PHP manual is more descriptive than I could be, especially with its comments section.

The Code Queryer:
There is an expensive web service that makes your website GDPR-compliant by adding a JavaScript that redirects visitors from the EU to an error page.

This is my attempt to provide a simple and free PHP script for those who want to achieve the same result on server side.

--- Code: PHP ---<?php/*  Copyright © 2018 tux. <[email protected]>  This work is free. You can redistribute it and/or modify it under the  terms of the Do What The Fuck You Want To Public License, Version 2,  as published by Sam Hocevar. See for more details.   GDPR SHIELD [PHP draft v1]   Prerequisites:  * PHP  * GeoIP as described here:   Usage:  <?php require("gdprshield.php"); ?>  <!doctype html>  <html>    ...  </html>*/$disallowed_countries = ["BE", "BG", "CZ", "DK", "DE", "EE", "IE", "EL", "ES", "FR", "HR", "IT", "CY", "LV", "LT", "LU", "HU", "MT", "NL", "AT", "PL", "PT", "RO", "SI", "SK", "FI", "SE", "UK"];$ip = $_SERVER["REMOTE_ADDR"];if (in_array(geoip_country_code_by_name($ip), $disallowed_countries)) {    die("Your country does not want you to be here.");     /*      The above code displays a plain error text.      If you prefer to redirect to a full-featured HTML page,      you could delete it and use a Location header instead:    */    header("Location: GDPR_blocked.php", true, 451);}?>
Enjoy. And feel free to extend/fix/implement it as you wish.
-Tuxman (May 04, 2018, 05:27 AM)
--- End quote ---

According to this link:

You need c library installed. Not sure how to install that on my cPanel. I was looking for something with php alone.

GeoLite2 is what you likely could use.

You could create a subdomain using cPanel and divert users from the GDPR countries to that subdomain where you make a simple page that explains why they are not allowed access. That gives you still an overview of how many visitors from GDPR countries wanted to visit your site and these visitors have an inkling of why access was denied and (hopefully) create so much outcry that politicians gladly take action to cut GDPR short before the internet becomes (too) divided. 

(hopefully) create so much outcry that politicians gladly take action to cut GDPR short before the internet becomes (too) divided. 
-Shades (April 06, 2019, 06:13 PM)
--- End quote ---


I mean


... wait, you were serious?


[0] Message Index

[#] Next page

[*] Previous page

Go to full version