First Initialization

This commit is contained in:
LudoBoggio
2012-09-02 21:44:37 +02:00
parent 285a78bf73
commit 5a4b5dca1c

30
plugin.php Normal file
View File

@ -0,0 +1,30 @@
<?php
/*
Plugin Name: BlackListIP
Plugin URI: http://yourls.org
Description: Plugin which block blacklisted IPs
Version: 1.0
Author: Ludo
Author URI: http://ludo.boggio.fr
*/
// Hook our custom function into the 'pre_redirect' event
yourls_add_action( 'pre_check_ip_flood', 'Ludo_BlackListIP_Root' );
// For this plugin to work, you need to define $yourls_blacklist_ip
// in the configuration file with entries like this :
// $yourls_blacklist_ip = array ("149.3.136.114","119.180.110.179");
function Ludo_BlackListIP_Root ( $args ) {
global $yourls_blacklist_ip;
$BlackListIP = $args[0];
if (in_array($BlackListIP, $yourls_blacklist_ip)) {
// yourls_die ( "Your IP has been blacklisted.", "Black list",403);
echo "<center>Your IP has been blacklisted.</center>";
die();
}
}
?>