Scripts
2BanOrNot2Ban
Dit script blokkeert toegang tot je website voor bepaalde gebruikers via een whitelist of blacklist. Dit doet hij door te kijken wat je IP adres is, of hij in de lijst staat en zo ja, of je dan wel of niet toegang moet krijgen. Ook te downloaden via mirrors beschikbaar op de mirrors. Vragen en / of opmerkingen? Laat het me weten!
2banornot2ban
[b]index.php[/b]
<?php
$var_2banornot2ban_validation = 1;
include('data/script.php');
?>
[b]data/script.php[/b]
<?php
// VALIDATION
// A little security pre-caution
// This will prevent people from directly accessing pages that should be included
// If direct access would be granted, the page would be full of errors
if ((!isset($var_2banornot2ban_validation)) or ($var_2banornot2ban_validation !== 1))
{
die('Direct access to this page is not allowed...');
}
/* ---------- BEGINNING OF THE GLOBAL CONFIGURATION ---------- */
// This is where we will set up the script
// SCRIPT FUNCTION
// The first function defines whether we are using a whitelist or a blacklist
// 1) Whitelist: Only the IP's in the list may pass
// 2) Blacklist: The IP's in the list may not pass
$var_2banornot2ban_function = 2;
// Default: $var_2banornot2ban_function = 2;
// ADMINISTRATOR E-MAIL
// Please fill in the admin's e-mail address below
$var_2banornot2ban_admin = '[email protected]';
// Default: $var_2banornot2ban_admin = '[email protected]';
// DATA FOLDER
// The next variable contains the path to the 'data' folder of this script
// You can use both an absolute or relative path, your call
// If your website uses lots of (sub)folders, you could include your domain name
// Do not start with a slash, but do end with one!
// Use '..' to go up one folder
// If you wish to use our (remote) files in stead of your own local ones, use this value:
// $var_2banornot2ban_folder = 'http://80.61.36.70/2banornot2ban/data/';
// Do keep in mind that this might slow down the loading of your pages
$var_2banornot2ban_folder = 'data/';
// Default: $var_2banornot2ban_folder = 'data/';
// LIST FILE
// Change this value if you prefer to rename the name of the 'list' file
// You may also give it any extension, so you could name it, for example: 'black.list'
// This file should, however, be placed in the 'data' folder
$var_2banornot2ban_file = 'list';
// Default: $var_2banornot2ban_file = 'list';
// LOCKED FILE
// When a user is refused access to the page, the 'locked' page is displayed
// You may edit the 'locked' file just as you wish to, and you can change its name here
// Just as the 'list' file, the file should remain in the 'data' folder
$var_2banornot2ban_locked = 'locked.php';
// Default: $var_2banornot2ban_locked = 'locked.php';
/* ---------- ENDING OF THE GLOBAL CONFIGURATION ---------- */
// Warning: Do not edit anything from this point unless you know what you are doing!
// Load the IP addresses in the 'list' file into an array
$var_2banornot2ban_list = file($var_2banornot2ban_folder.$var_2banornot2ban_file);
// Save the guest's IP address to a variable for faster processing later on
$var_2banornot2ban_ip = $_SERVER['REMOTE_ADDR'];
// Remove any hidden and unwanted symbols in the IP array
foreach($var_2banornot2ban_list as $key => $value)
{
$var_2banornot2ban_list[$key] = trim($value);
}
// If the function of this script is to use a whitelist...
if ($var_2banornot2ban_function == 1)
{
if (!in_array($var_2banornot2ban_ip, $var_2banornot2ban_list))
{
include($var_2banornot2ban_folder.$var_2banornot2ban_locked);
die();
}
}
// If the function of this script is to use a blacklist...
if ($var_2banornot2ban_function == 2)
{
if (in_array($var_2banornot2ban_ip, $var_2banornot2ban_list))
{
include($var_2banornot2ban_folder.$var_2banornot2ban_locked);
die();
}
}
?>
[b]data/blocked.php[/b]
<?php
// VALIDATION
// A little security pre-caution
// This will prevent people from directly accessing pages that should be included
// If direct access would be granted, the page would be full of errors
if ((!isset($var_2banornot2ban_validation)) or ($var_2banornot2ban_validation !== 1))
{
die('Direct access to this page is not allowed...');
}
echo 'You passed!';
?>
[b]data/list[/b]
123.345.567.789
Reacties
0