Skip to content

Latest commit

 

History

History
65 lines (47 loc) · 1.95 KB

File metadata and controls

65 lines (47 loc) · 1.95 KB

FilterAccess

Get country code of an IP address and refine users' access

Description

  • Extension reads the country code of a visitor and refine users' access.
  • Version 1.1

Installation

  • Make sure you have MediaWiki 1.29+ installed.
  • Download and place the extension to your /extensions/ folder.
  • Add the following code to your LocalSettings.php:
wfLoadExtension( 'FilterAccess' );
require_once("$IP/extensions/FilterAccess/config/$wgSitename.php");
  • Set correct paths in cron/update_ipdb.sh and create cron job. Once a week should be enough.

Configuration

Create file in /config/ folder named $wgSitename.php and refine access here. If CaptchaSettings extension installed, the $countryFilter variable (true = allow captcha settings by geolocation) can be used here. Example:

#### DON'T ERASE ####
require_once("$IP/extensions/FilterAccess/CountryCode.class.php");
$cc = new CountryCode();
$countryCode = $cc->getLocation();
#################

if($countryCode!="CZ" && $countryCode!="SK") {
	$wgEmailConfirmToEdit = true;
}
$wgGroupPermissions['*']['skipcaptcha'] = false;
$wgGroupPermissions['user']['skipcaptcha'] = false;
$wgGroupPermissions['autoconfirmed']['skipcaptcha'] = true;
$wgGroupPermissions['bot']['skipcaptcha'] = true; // registered bots
$wgGroupPermissions['sysop']['skipcaptcha'] = true;
if( !empty($countryFilter) && isset($_SERVER["REMOTE_ADDR"]) ){
	$wgCaptchaTriggers['addurl'] = false;
	$wgCaptchaTriggers['edit'] = false;
	if($countryCode=="SK") $wgCaptchaTriggers['addurl'] = true;
	elseif($countryCode!="CZ") $wgCaptchaTriggers['edit'] = true;
}
else $wgCaptchaTriggers['edit'] = false;

Release Notes

1.1

Third party code

Authors and license

  • Josef Martiňák
  • MIT License, Copyright (c) 2023 First Faculty of Medicine, Charles University