.
diff --git a/plugin.php b/plugin.php
index 5f901e0..9b461c9 100644
--- a/plugin.php
+++ b/plugin.php
@@ -1,73 +1,104 @@
.
*/
// No direct call
if( !defined( 'YOURLS_ABSPATH' ) ) die();
// Hook the custom function into the 'pre_check_domain_flood' event
-yourls_add_filter( 'shunt_add_new_link', 'panthro_whitelist_domain_root' );
+yourls_add_filter( 'shunt_add_new_link', 'apelly_blacklist_domain_root' );
// Hook the admin page into the 'plugins_loaded' event
-yourls_add_action( 'plugins_loaded', 'panthro_whitelist_domain_add_page' );
+yourls_add_action( 'plugins_loaded', 'apelly_blacklist_domain_add_page' );
-// Get whitelisted domains from YOURLS options feature and compare with current domain address
-function panthro_whitelist_domain_root ( $bol, $url ) {
+// Get blacklisted domains from YOURLS options feature and compare with current domain address
+function apelly_blacklist_domain_root ( $bol, $url ) {
$parse = parse_url($url);
$domain = str_ireplace('www.', '', parse_url($url, PHP_URL_HOST));
$return = false;
- $domain_list = yourls_get_option ('panthro_whitelist_domain_list');
+ $domain_list = yourls_get_option ('apelly_blacklist_domain_list');
if ( $domain_list ) {
$domain_list_display = unserialize ( $domain_list );
- //if (!in_array($domain, $domain_list_display)) {
- if (strpos($domain_list_display,$domain) === false) {
- $return['status'] = 'fail';
- $return['code'] = 'error:domain-not-allowed';
- $return['message'] = 'This domain is not allowed';
- $return['errorCode'] = '400';
+ if (strpos($domain_list_display,$domain) === true) {
+
+ // Check if a YourlsBlacklistIPs is installed and active
+ if (yourls_is_active_plugin( YOURLS_PLUGINDIR .'/BlackListIP/plugin.php' ) {
+ // fetch the blacklisted IP addresses
+ $IP_List = yourls_get_option ('ludo_blacklist_ip_liste');
+ $IP_List = ( $IP_List ) ? ( unserialize ( $IP_List ) ):((array)NULL);
+
+ // add this IP
+ $IP = yourls_get_IP();
+ $Parsed_IP = ludo_blacklist_ip_Analyze_IP ( $IP ) ;
+ if ( $Parsed_IP != "NULL" ) {
+ $IPList[] = $Parsed_IP ;
+ }
+
+ // Update the blacklist
+ yourls_update_option ( 'ludo_blacklist_ip_liste', serialize ( $IP_List ) );
+ }
+
+ // stop
+ yourls_die( 'Blacklisted domain', 'Forbidden', 403 );
}
}
return $return;
}
// Add admin page
-function panthro_whitelist_domain_add_page () {
- yourls_register_plugin_page( 'panthro_whitelist_domain', 'Whitelist domains', 'panthro_whitelist_domain_do_page' );
+function apelly_blacklist_domain_add_page () {
+ yourls_register_plugin_page( 'apelly_blacklist_domain', 'Blacklist domains', 'apelly_blacklist_domain_do_page' );
}
// Display admin page
-function panthro_whitelist_domain_do_page () {
- if( isset( $_POST['action'] ) && $_POST['action'] == 'whitelist_domain' ) {
- panthro_whitelist_domain_process ();
+function apelly_blacklist_domain_do_page () {
+ if( isset( $_POST['action'] ) && $_POST['action'] == 'blacklist_domain' ) {
+ apelly_blacklist_domain_process ();
} else {
- panthro_whitelist_domain_form ();
+ apelly_blacklist_domain_form ();
}
}
-// Display form to administrate whitelisted domains list
-function panthro_whitelist_domain_form () {
- $nonce = yourls_create_nonce( 'whitelist_domain' ) ;
- $domain_list = yourls_get_option ('panthro_whitelist_domain_list','Enter domain addresses here, one per line');
+// Display form to administrate blacklisted domains list
+function apelly_blacklist_domain_form () {
+ $nonce = yourls_create_nonce( 'blacklist_domain' ) ;
+ $domain_list = yourls_get_option ('apelly_blacklist_domain_list','Enter domain addresses here, one per line');
if ($domain_list != 'Enter domain addresses here, one per line' ){
$domain_list_display = unserialize ( $domain_list );
}else{
$domain_list_display = $domain_list;
}
echo << WhiteList domains
+ BlackList domains