Prevent articles from being copied by @chotamreaderbot and @corsabot bots
Who doesn’t love @chotamreaderbot and @corsabot? The two fantastic bots on Telegram that thanks to the excuse of creating instant views of the articles, thanks to a copy on telegra.ph, allows the web savvy to use it to be able to read blog articles without giving the same blog numbers on visits.
I understand the thought of those who hate all kinds of anti-tracking scripts, but I also understand those who have a blog and want to defend themselves from this practice.
The solution is as simple as it is immediate.
Just insert the following code inside the functions.php file of our theme
// by Francesco for www.selectallfromdual.com
add_action('parse_query','fuck_bot_telegraph');
function fuck_bot_telegraph() {
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
//check ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
//to check ip is pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$json_string = file_get_contents('https://www.selectallfromdual.com/services/chotamreaderbot/getiplist');
$json = json_decode($json_string, true);
if (in_array($ip,$json['ips'])) {
wp_redirect("https://it.wikipedia.org/wiki/Diritto_d'autore");
}
}
that apart from the goliardia of the descriptions used, allows you to redirect the services used by the two bots on other sources that are not our blog, in order to avoid being copied.
How does it work
The function downloads the IPs identified as coming from the two bots via a services, so that it will not even be necessary to update it as we will do it for you.
I hope I have been helpful in writing a useful WordPress plugin.