Corrections for WP Coding Standard
All PHP classes have been reworked to match the WP coding standard. This includes mostly code styling, but also the use of wp_ functions instead of PHP builtins.
This commit is contained in:
parent
d769c6789c
commit
4890dbaeeb
@ -10,7 +10,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Quit.
|
// Quit.
|
||||||
defined( 'ABSPATH' ) OR exit;
|
defined( 'ABSPATH' ) or exit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Statify Blacklist admin configuration.
|
* Statify Blacklist admin configuration.
|
||||||
@ -72,14 +72,14 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
|||||||
add_submenu_page(
|
add_submenu_page(
|
||||||
'settings.php', $title, $title, 'manage_network_plugins', 'statify-blacklist-settings', array(
|
'settings.php', $title, $title, 'manage_network_plugins', 'statify-blacklist-settings', array(
|
||||||
'StatifyBlacklist_Admin',
|
'StatifyBlacklist_Admin',
|
||||||
'settings_page'
|
'settings_page',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
add_submenu_page(
|
add_submenu_page(
|
||||||
'options-general.php', $title, $title, 'manage_options', 'statify-blacklist', array(
|
'options-general.php', $title, $title, 'manage_options', 'statify-blacklist', array(
|
||||||
'StatifyBlacklist_Admin',
|
'StatifyBlacklist_Admin',
|
||||||
'settings_page'
|
'settings_page',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
|||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function settings_page() {
|
public static function settings_page() {
|
||||||
include STATIFYBLACKLIST_DIR . '/views/settings_page.php';
|
include STATIFYBLACKLIST_DIR . '/views/settings-page.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,10 +104,9 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
|||||||
* @param string $file The filename.
|
* @param string $file The filename.
|
||||||
*
|
*
|
||||||
* @return array Merged links.
|
* @return array Merged links.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static function plugin_meta_link( $links, $file ) {
|
public static function plugin_meta_link( $links, $file ) {
|
||||||
if ( $file === STATIFYBLACKLIST_BASE ) {
|
if ( STATIFYBLACKLIST_BASE === $file ) {
|
||||||
$links[] = '<a href="https://github.com/stklcode/statify-blacklist">GitHub</a>';
|
$links[] = '<a href="https://github.com/stklcode/statify-blacklist">GitHub</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,16 +118,15 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
|||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*
|
*
|
||||||
* @param array $links Registered links
|
* @param array $links Registered links.
|
||||||
* @param string $file The filename
|
* @param string $file The filename.
|
||||||
*
|
*
|
||||||
* @return array Merged links.
|
* @return array Merged links.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static function plugin_actions_links( $links, $file ) {
|
public static function plugin_actions_links( $links, $file ) {
|
||||||
$base = self::$multisite ? network_admin_url( 'settings.php' ) : admin_url( 'options-general.php' );
|
$base = self::$multisite ? network_admin_url( 'settings.php' ) : admin_url( 'options-general.php' );
|
||||||
|
|
||||||
if ( $file === STATIFYBLACKLIST_BASE && current_user_can( 'manage_options' ) ) {
|
if ( STATIFYBLACKLIST_BASE === $file && current_user_can( 'manage_options' ) ) {
|
||||||
array_unshift(
|
array_unshift(
|
||||||
$links,
|
$links,
|
||||||
sprintf( '<a href="%s">%s</a>', esc_attr( add_query_arg( 'page', 'statify-blacklist', $base ) ), __( 'Settings' ) )
|
sprintf( '<a href="%s">%s</a>', esc_attr( add_query_arg( 'page', 'statify-blacklist', $base ) ), __( 'Settings' ) )
|
||||||
@ -148,7 +146,7 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
|||||||
public static function cleanup_database() {
|
public static function cleanup_database() {
|
||||||
// Check user permissions.
|
// Check user permissions.
|
||||||
if ( ! current_user_can( 'manage_options' ) && ! ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
|
if ( ! current_user_can( 'manage_options' ) && ! ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
|
||||||
die( __( 'Are you sure you want to do this?' ) );
|
die( esc_html__( 'Are you sure you want to do this?' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
|
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
|
||||||
@ -159,11 +157,10 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
|||||||
$cleanTrg = true;
|
$cleanTrg = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( $cleanRef ) {
|
if ( $cleanRef ) {
|
||||||
if ( isset( self::$_options['referer']['regexp'] ) && self::$_options['referer']['regexp'] > 0 ) {
|
if ( isset( self::$_options['referer']['regexp'] ) && self::$_options['referer']['regexp'] > 0 ) {
|
||||||
// Merge given regular expressions into one.
|
// Merge given regular expressions into one.
|
||||||
$refererRegexp = implode( "|", array_keys( self::$_options['referer']['blacklist'] ) );
|
$refererRegexp = implode( '|', array_keys( self::$_options['referer']['blacklist'] ) );
|
||||||
} else {
|
} else {
|
||||||
// Sanitize URLs.
|
// Sanitize URLs.
|
||||||
$referer = self::sanitizeURLs( self::$_options['referer']['blacklist'] );
|
$referer = self::sanitizeURLs( self::$_options['referer']['blacklist'] );
|
||||||
@ -176,14 +173,13 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
|||||||
if ( $cleanTrg ) {
|
if ( $cleanTrg ) {
|
||||||
if ( isset( self::$_options['target']['regexp'] ) && self::$_options['target']['regexp'] > 0 ) {
|
if ( isset( self::$_options['target']['regexp'] ) && self::$_options['target']['regexp'] > 0 ) {
|
||||||
// Merge given regular expressions into one.
|
// Merge given regular expressions into one.
|
||||||
$targetRegexp = implode( "|", array_keys( self::$_options['target']['blacklist'] ) );
|
$targetRegexp = implode( '|', array_keys( self::$_options['target']['blacklist'] ) );
|
||||||
} else {
|
} else {
|
||||||
// Build filter regexp.
|
// Build filter regexp.
|
||||||
$targetRegexp = str_replace( '.', '\.', implode( '|', array_flip( self::$_options['target']['blacklist'] ) ) );
|
$targetRegexp = str_replace( '.', '\.', implode( '|', array_flip( self::$_options['target']['blacklist'] ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( ! empty( $refererRegexp ) || ! empty( $targetRegexp ) ) {
|
if ( ! empty( $refererRegexp ) || ! empty( $targetRegexp ) ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
@ -192,8 +188,8 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
|||||||
$wpdb->query(
|
$wpdb->query(
|
||||||
$wpdb->prepare(
|
$wpdb->prepare(
|
||||||
"DELETE FROM `$wpdb->statify` WHERE "
|
"DELETE FROM `$wpdb->statify` WHERE "
|
||||||
. ( ( 1 === self::$_options['referer']['regexp'] ) ? " BINARY " : "" )
|
. ( ( 1 === self::$_options['referer']['regexp'] ) ? ' BINARY ' : '' )
|
||||||
. "referrer REGEXP %s", $refererRegexp
|
. 'referrer REGEXP %s', $refererRegexp
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -201,8 +197,8 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
|||||||
$wpdb->query(
|
$wpdb->query(
|
||||||
$wpdb->prepare(
|
$wpdb->prepare(
|
||||||
"DELETE FROM `$wpdb->statify` WHERE "
|
"DELETE FROM `$wpdb->statify` WHERE "
|
||||||
. ( ( 1 === self::$_options['target']['regexp'] ) ? " BINARY " : "" )
|
. ( ( 1 === self::$_options['target']['regexp'] ) ? ' BINARY ' : '' )
|
||||||
. "target REGEXP %s", $targetRegexp
|
. 'target REGEXP %s', $targetRegexp
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -224,7 +220,6 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
|||||||
* @param array $urls given array of URLs.
|
* @param array $urls given array of URLs.
|
||||||
*
|
*
|
||||||
* @return array sanitized array.
|
* @return array sanitized array.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private static function sanitizeURLs( $urls ) {
|
private static function sanitizeURLs( $urls ) {
|
||||||
return array_flip(
|
return array_flip(
|
||||||
@ -247,20 +242,17 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
|||||||
* @param array $ips given array of URLs.
|
* @param array $ips given array of URLs.
|
||||||
*
|
*
|
||||||
* @return array sanitized array.
|
* @return array sanitized array.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private static function sanitizeIPs( $ips ) {
|
private static function sanitizeIPs( $ips ) {
|
||||||
return array_filter(
|
return array_filter(
|
||||||
$ips, function ( $ip ) {
|
$ips, function ( $ip ) {
|
||||||
return preg_match(
|
return preg_match(
|
||||||
'/^((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])' .
|
'/^((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])(\/([0-9]|[1-2][0-9]|3[0-2]))?$/', $ip
|
||||||
'(\/([0-9]|[1-2][0-9]|3[0-2]))?$/', $ip
|
|
||||||
) ||
|
) ||
|
||||||
preg_match(
|
preg_match(
|
||||||
'/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))' .
|
'/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))(\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?$/', $ip
|
||||||
'(\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?$/', $ip
|
);
|
||||||
);
|
}
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,7 +10,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Quit.
|
// Quit.
|
||||||
defined( 'ABSPATH' ) OR exit;
|
defined( 'ABSPATH' ) or exit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Statify Blacklist system configuration.
|
* Statify Blacklist system configuration.
|
||||||
@ -32,7 +32,7 @@ class StatifyBlacklist_System extends StatifyBlacklist {
|
|||||||
if ( function_exists( 'get_sites' ) ) {
|
if ( function_exists( 'get_sites' ) ) {
|
||||||
$sites = get_sites();
|
$sites = get_sites();
|
||||||
} elseif ( function_exists( 'wp_get_sites' ) ) {
|
} elseif ( function_exists( 'wp_get_sites' ) ) {
|
||||||
$sites = wp_get_sites(); // legacy support for WP < 4.6.
|
$sites = wp_get_sites(); // Legacy support for WP < 4.6.
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ class StatifyBlacklist_System extends StatifyBlacklist {
|
|||||||
switch_to_blog( $site['blog_id'] );
|
switch_to_blog( $site['blog_id'] );
|
||||||
add_option(
|
add_option(
|
||||||
'statify-blacklist',
|
'statify-blacklist',
|
||||||
self::defaultOptions()
|
self::default_options()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ class StatifyBlacklist_System extends StatifyBlacklist {
|
|||||||
} else {
|
} else {
|
||||||
add_option(
|
add_option(
|
||||||
'statify-blacklist',
|
'statify-blacklist',
|
||||||
self::defaultOptions()
|
self::default_options()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ class StatifyBlacklist_System extends StatifyBlacklist {
|
|||||||
if ( function_exists( 'get_sites' ) ) {
|
if ( function_exists( 'get_sites' ) ) {
|
||||||
$sites = get_sites();
|
$sites = get_sites();
|
||||||
} elseif ( function_exists( 'wp_get_sites' ) ) {
|
} elseif ( function_exists( 'wp_get_sites' ) ) {
|
||||||
$sites = wp_get_sites(); // legacy support for WP < 4.6.
|
$sites = wp_get_sites(); // Legacy support for WP < 4.6.
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -111,19 +111,19 @@ class StatifyBlacklist_System extends StatifyBlacklist {
|
|||||||
'active' => self::$_options['active_referer'],
|
'active' => self::$_options['active_referer'],
|
||||||
'cron' => self::$_options['cron_referer'],
|
'cron' => self::$_options['cron_referer'],
|
||||||
'regexp' => self::$_options['referer_regexp'],
|
'regexp' => self::$_options['referer_regexp'],
|
||||||
'blacklist' => self::$_options['referer']
|
'blacklist' => self::$_options['referer'],
|
||||||
),
|
),
|
||||||
'target' => array(
|
'target' => array(
|
||||||
'active' => 0,
|
'active' => 0,
|
||||||
'cron' => 0,
|
'cron' => 0,
|
||||||
'regexp' => 0,
|
'regexp' => 0,
|
||||||
'blacklist' => array()
|
'blacklist' => array(),
|
||||||
),
|
),
|
||||||
'ip' => array(
|
'ip' => array(
|
||||||
'active' => 0,
|
'active' => 0,
|
||||||
'blacklist' => array()
|
'blacklist' => array(),
|
||||||
),
|
),
|
||||||
'version' => 1.4
|
'version' => 1.4,
|
||||||
);
|
);
|
||||||
if ( is_multisite() && array_key_exists( STATIFYBLACKLIST_BASE, (array) get_site_option( 'active_sitewide_plugins' ) ) ) {
|
if ( is_multisite() && array_key_exists( STATIFYBLACKLIST_BASE, (array) get_site_option( 'active_sitewide_plugins' ) ) ) {
|
||||||
update_site_option( 'statify-blacklist', $options );
|
update_site_option( 'statify-blacklist', $options );
|
||||||
@ -136,7 +136,7 @@ class StatifyBlacklist_System extends StatifyBlacklist {
|
|||||||
// Version older than current major release.
|
// Version older than current major release.
|
||||||
if ( self::VERSION_MAIN > self::$_options['version'] ) {
|
if ( self::VERSION_MAIN > self::$_options['version'] ) {
|
||||||
// Merge default options with current config, assuming only additive changes.
|
// Merge default options with current config, assuming only additive changes.
|
||||||
$options = array_merge_recursive( self::defaultOptions(), self::$_options );
|
$options = array_merge_recursive( self::default_options(), self::$_options );
|
||||||
$options['version'] = self::VERSION_MAIN;
|
$options['version'] = self::VERSION_MAIN;
|
||||||
if ( ( is_multisite() && array_key_exists( STATIFYBLACKLIST_BASE, (array) get_site_option( 'active_sitewide_plugins' ) ) ) ) {
|
if ( ( is_multisite() && array_key_exists( STATIFYBLACKLIST_BASE, (array) get_site_option( 'active_sitewide_plugins' ) ) ) ) {
|
||||||
update_site_option( 'statify-blacklist', $options );
|
update_site_option( 'statify-blacklist', $options );
|
@ -9,7 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Quit.
|
// Quit.
|
||||||
defined( 'ABSPATH' ) OR exit;
|
defined( 'ABSPATH' ) or exit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Statify Blacklist.
|
* Statify Blacklist.
|
||||||
@ -58,7 +58,7 @@ class StatifyBlacklist {
|
|||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
// Skip on autosave or AJAX.
|
// Skip on autosave or AJAX.
|
||||||
if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) OR ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) or ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,9 +87,11 @@ class StatifyBlacklist {
|
|||||||
add_action( 'network_admin_menu', array( 'StatifyBlacklist_Admin', '_add_menu_page' ) );
|
add_action( 'network_admin_menu', array( 'StatifyBlacklist_Admin', '_add_menu_page' ) );
|
||||||
add_filter(
|
add_filter(
|
||||||
'network_admin_plugin_action_links', array(
|
'network_admin_plugin_action_links', array(
|
||||||
'StatifyBlacklist_Admin',
|
'StatifyBlacklist_Admin',
|
||||||
'plugin_actions_links'
|
'plugin_actions_links',
|
||||||
), 10, 2
|
),
|
||||||
|
10,
|
||||||
|
2
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
add_action( 'admin_menu', array( 'StatifyBlacklist_Admin', '_add_menu_page' ) );
|
add_action( 'admin_menu', array( 'StatifyBlacklist_Admin', '_add_menu_page' ) );
|
||||||
@ -112,12 +114,11 @@ class StatifyBlacklist {
|
|||||||
* @since 1.2.1 update_options($options = null) Parameter with default value introduced.
|
* @since 1.2.1 update_options($options = null) Parameter with default value introduced.
|
||||||
*
|
*
|
||||||
* @param array $options Optional. New options to save.
|
* @param array $options Optional. New options to save.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static function update_options( $options = null ) {
|
public static function update_options( $options = null ) {
|
||||||
self::$_options = wp_parse_args(
|
self::$_options = wp_parse_args(
|
||||||
get_option( 'statify-blacklist' ),
|
get_option( 'statify-blacklist' ),
|
||||||
self::defaultOptions()
|
self::default_options()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,25 +129,25 @@ class StatifyBlacklist {
|
|||||||
*
|
*
|
||||||
* @return array The options array.
|
* @return array The options array.
|
||||||
*/
|
*/
|
||||||
protected static function defaultOptions() {
|
protected static function default_options() {
|
||||||
return array(
|
return array(
|
||||||
'referer' => array(
|
'referer' => array(
|
||||||
'active' => 0,
|
'active' => 0,
|
||||||
'cron' => 0,
|
'cron' => 0,
|
||||||
'regexp' => 0,
|
'regexp' => 0,
|
||||||
'blacklist' => array()
|
'blacklist' => array(),
|
||||||
),
|
),
|
||||||
'target' => array(
|
'target' => array(
|
||||||
'active' => 0,
|
'active' => 0,
|
||||||
'cron' => 0,
|
'cron' => 0,
|
||||||
'regexp' => 0,
|
'regexp' => 0,
|
||||||
'blacklist' => array()
|
'blacklist' => array(),
|
||||||
),
|
),
|
||||||
'ip' => array(
|
'ip' => array(
|
||||||
'active' => 0,
|
'active' => 0,
|
||||||
'blacklist' => array()
|
'blacklist' => array(),
|
||||||
),
|
),
|
||||||
'version' => self::VERSION_MAIN
|
'version' => self::VERSION_MAIN,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,62 +164,68 @@ class StatifyBlacklist {
|
|||||||
// Regular Expression filtering since 1.3.0.
|
// Regular Expression filtering since 1.3.0.
|
||||||
if ( isset( self::$_options['referer']['regexp'] ) && self::$_options['referer']['regexp'] > 0 ) {
|
if ( isset( self::$_options['referer']['regexp'] ) && self::$_options['referer']['regexp'] > 0 ) {
|
||||||
// Get full referer string.
|
// Get full referer string.
|
||||||
$referer = ( isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '' );
|
$referer = wp_get_raw_referer();
|
||||||
|
if ( ! $referer ) {
|
||||||
|
$referer = '';
|
||||||
|
}
|
||||||
// Merge given regular expressions into one.
|
// Merge given regular expressions into one.
|
||||||
$regexp = '/' . implode( "|", array_keys( self::$_options['referer']['blacklist'] ) ) . '/';
|
$regexp = '/' . implode( '|', array_keys( self::$_options['referer']['blacklist'] ) ) . '/';
|
||||||
if ( 2 === self::$_options['referer']['regexp'] ) {
|
if ( 2 === self::$_options['referer']['regexp'] ) {
|
||||||
$regexp .= 'i';
|
$regexp .= 'i';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check blacklist (return NULL to continue filtering).
|
// Check blacklist (return NULL to continue filtering).
|
||||||
|
|
||||||
return ( 1 === preg_match( $regexp, $referer ) ) ? true : null;
|
return ( 1 === preg_match( $regexp, $referer ) ) ? true : null;
|
||||||
} else {
|
} else {
|
||||||
// Extract relevant domain parts.
|
// Extract relevant domain parts.
|
||||||
$referer = strtolower( ( isset( $_SERVER['HTTP_REFERER'] ) ? parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_HOST ) : '' ) );
|
$referer = wp_parse_url( wp_get_raw_referer() );
|
||||||
|
$referer = strtolower( ( isset( $referer['host'] ) ? $referer['host'] : '' ) );
|
||||||
|
|
||||||
// Get blacklist.
|
// Get blacklist.
|
||||||
$blacklist = self::$_options['referer']['blacklist'];
|
$blacklist = self::$_options['referer']['blacklist'];
|
||||||
|
|
||||||
// Check blacklist.
|
// Check blacklist.
|
||||||
if ( isset( $blacklist[$referer] ) ) {
|
if ( isset( $blacklist[ $referer ] ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Target blacklist (since 1.4.0)
|
// Target blacklist (since 1.4.0).
|
||||||
if ( isset( self::$_options['target']['active'] ) && 0 !== self::$_options['target']['active'] ) {
|
if ( isset( self::$_options['target']['active'] ) && 0 !== self::$_options['target']['active'] ) {
|
||||||
// Regular Expression filtering since 1.3.0.
|
// Regular Expression filtering since 1.3.0.
|
||||||
if ( isset( self::$_options['target']['regexp'] ) && 0 < self::$_options['target']['regexp'] ) {
|
if ( isset( self::$_options['target']['regexp'] ) && 0 < self::$_options['target']['regexp'] ) {
|
||||||
// Get full referer string.
|
// Get full referer string.
|
||||||
$target = ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '/' );
|
// @codingStandardsIgnoreStart The globals are checked.
|
||||||
// Merge given regular expressions into one
|
$target = ( isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '/' );
|
||||||
$regexp = '/' . implode( "|", array_keys( self::$_options['target']['blacklist'] ) ) . '/';
|
// @codingStandardsIgnoreEnd
|
||||||
|
// Merge given regular expressions into one.
|
||||||
|
$regexp = '/' . implode( '|', array_keys( self::$_options['target']['blacklist'] ) ) . '/';
|
||||||
if ( 2 === self::$_options['target']['regexp'] ) {
|
if ( 2 === self::$_options['target']['regexp'] ) {
|
||||||
$regexp .= 'i';
|
$regexp .= 'i';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check blacklist (return NULL to continue filtering).
|
// Check blacklist (return NULL to continue filtering).
|
||||||
|
|
||||||
return ( 1 === preg_match( $regexp, $target ) ) ? true : null;
|
return ( 1 === preg_match( $regexp, $target ) ) ? true : null;
|
||||||
} else {
|
} else {
|
||||||
// Extract target page.
|
// Extract target page.
|
||||||
$target = ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '/' );
|
// @codingStandardsIgnoreStart The globals are checked.
|
||||||
|
$target = ( isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '/' );
|
||||||
|
// @codingStandardsIgnoreEnd
|
||||||
// Get blacklist.
|
// Get blacklist.
|
||||||
$blacklist = self::$_options['target']['blacklist'];
|
$blacklist = self::$_options['target']['blacklist'];
|
||||||
// Check blacklist.
|
// Check blacklist.
|
||||||
if ( isset( $blacklist[$target] ) ) {
|
if ( isset( $blacklist[ $target ] ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IP blacklist (since 1.4.0).
|
// IP blacklist (since 1.4.0).
|
||||||
if ( isset ( self::$_options['ip']['active'] ) && 0 !== self::$_options['ip']['active'] ) {
|
if ( isset( self::$_options['ip']['active'] ) && 0 !== self::$_options['ip']['active'] ) {
|
||||||
if ( false !== ( $ip = self::getIP() ) ) {
|
if ( false !== ( $ip = self::get_ip() ) ) {
|
||||||
foreach ( self::$_options['ip']['blacklist'] as $net ) {
|
foreach ( self::$_options['ip']['blacklist'] as $net ) {
|
||||||
if ( self::cidrMatch( $ip, $net ) ) {
|
if ( self::cidr_match( $ip, $net ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -226,7 +233,6 @@ class StatifyBlacklist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Skip and continue (return NULL), if all blacklists are inactive.
|
// Skip and continue (return NULL), if all blacklists are inactive.
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +245,7 @@ class StatifyBlacklist {
|
|||||||
*
|
*
|
||||||
* @return string|bool the client's IP address or FALSE, if none could be determined.
|
* @return string|bool the client's IP address or FALSE, if none could be determined.
|
||||||
*/
|
*/
|
||||||
private static function getIP() {
|
private static function get_ip() {
|
||||||
foreach (
|
foreach (
|
||||||
array(
|
array(
|
||||||
// 'HTTP_CLIENT_IP',
|
// 'HTTP_CLIENT_IP',
|
||||||
@ -249,16 +255,18 @@ class StatifyBlacklist {
|
|||||||
// 'HTTP_X_CLUSTER_CLIENT_IP',
|
// 'HTTP_X_CLUSTER_CLIENT_IP',
|
||||||
// 'HTTP_FORWARDED_FOR',
|
// 'HTTP_FORWARDED_FOR',
|
||||||
// 'HTTP_FORWARDED',
|
// 'HTTP_FORWARDED',
|
||||||
'REMOTE_ADDR'
|
'REMOTE_ADDR',
|
||||||
) as $k
|
) as $k
|
||||||
) {
|
) {
|
||||||
if ( isset( $_SERVER[$k] ) ) {
|
// @codingStandardsIgnoreStart The globals are checked.
|
||||||
foreach ( explode( ',', $_SERVER[$k] ) as $ip ) {
|
if ( isset( $_SERVER[ $k ] ) ) {
|
||||||
|
foreach ( explode( ',', $_SERVER[ $k ] ) as $ip ) {
|
||||||
if ( false !== filter_var( $ip, FILTER_VALIDATE_IP ) ) {
|
if ( false !== filter_var( $ip, FILTER_VALIDATE_IP ) ) {
|
||||||
return $ip;
|
return $ip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// @codingStandardsIgnoreEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -272,9 +280,9 @@ class StatifyBlacklist {
|
|||||||
*
|
*
|
||||||
* @return bool TRUE, if the given IP addresses matches the given subnet.
|
* @return bool TRUE, if the given IP addresses matches the given subnet.
|
||||||
*/
|
*/
|
||||||
private static function cidrMatch( $ip, $net ) {
|
private static function cidr_match( $ip, $net ) {
|
||||||
if ( substr_count( $net, ':' ) > 1 ) { // Check for IPv6.
|
if ( substr_count( $net, ':' ) > 1 ) { // Check for IPv6.
|
||||||
if ( ! ( ( extension_loaded( 'sockets' ) && defined( 'AF_INET6' ) ) || @inet_pton( '::1' ) ) ) {
|
if ( ! ( ( extension_loaded( 'sockets' ) && defined( 'AF_INET6' ) ) || inet_pton( '::1' ) ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,8 +297,8 @@ class StatifyBlacklist {
|
|||||||
$mask = 128;
|
$mask = 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
$bytesAddr = unpack( 'n*', @inet_pton( $base ) );
|
$bytesAddr = unpack( 'n*', inet_pton( $base ) );
|
||||||
$bytesTest = unpack( 'n*', @inet_pton( $ip ) );
|
$bytesTest = unpack( 'n*', inet_pton( $ip ) );
|
||||||
|
|
||||||
if ( ! $bytesAddr || ! $bytesTest ) {
|
if ( ! $bytesAddr || ! $bytesTest ) {
|
||||||
return false;
|
return false;
|
||||||
@ -300,7 +308,7 @@ class StatifyBlacklist {
|
|||||||
$left = $mask - 16 * ( $i - 1 );
|
$left = $mask - 16 * ( $i - 1 );
|
||||||
$left = ( $left <= 16 ) ? $left : 16;
|
$left = ( $left <= 16 ) ? $left : 16;
|
||||||
$maskB = ~( 0xffff >> $left ) & 0xffff;
|
$maskB = ~( 0xffff >> $left ) & 0xffff;
|
||||||
if ( ( $bytesAddr[$i] & $maskB ) !== ( $bytesTest[$i] & $maskB ) ) {
|
if ( ( $bytesAddr[ $i ] & $maskB ) !== ( $bytesTest[ $i ] & $maskB ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -314,7 +322,7 @@ class StatifyBlacklist {
|
|||||||
if ( false !== strpos( $net, '/' ) ) { // Parse CIDR subnet.
|
if ( false !== strpos( $net, '/' ) ) { // Parse CIDR subnet.
|
||||||
list( $base, $mask ) = explode( '/', $net, 2 );
|
list( $base, $mask ) = explode( '/', $net, 2 );
|
||||||
|
|
||||||
if ( $mask === '0' ) {
|
if ( '0' === $mask ) {
|
||||||
return filter_var( $base, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 );
|
return filter_var( $base, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,34 +1,42 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
Plugin Name: Statify Blacklist
|
* Statify Blacklist
|
||||||
Plugin URI: https://de.wordpress.org/plugins/statify-blacklist/
|
*
|
||||||
Description: Extension for the Statify plugin to add a customizable blacklists.
|
* @package PluginPackage
|
||||||
Version: 1.4.0
|
* @author Stefan Kalscheuer <stefan@stklcode.de>
|
||||||
Author: Stefan Kalscheuer (@stklcode)
|
* @license GPL-2.0+
|
||||||
Author URI: https://www.stklcode.de
|
*
|
||||||
Plugin URI: https://wordpress.org/plugins/statify-blacklist
|
* @wordpress-plugin
|
||||||
Text Domain: statify-blacklist
|
*
|
||||||
Domain Path: /lang
|
* Plugin Name: Statify Blacklist
|
||||||
License: GPLv2 or later
|
* Plugin URI: https://de.wordpress.org/plugins/statify-blacklist/
|
||||||
|
* Description: Extension for the Statify plugin to add a customizable blacklists.
|
||||||
|
* Version: 1.4.0
|
||||||
|
* Author: Stefan Kalscheuer (@stklcode)
|
||||||
|
* Author URI: https://www.stklcode.de
|
||||||
|
* Plugin URI: https://wordpress.org/plugins/statify-blacklist
|
||||||
|
* Text Domain: statify-blacklist
|
||||||
|
* Domain Path: /lang
|
||||||
|
* License: GPLv2 or later
|
||||||
|
*
|
||||||
|
* Statify Blacklist is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Statify Blacklist is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Statify Blacklist. If not, see http://www.gnu.org/licenses/gpl-2.0.html.
|
||||||
|
*/
|
||||||
|
|
||||||
Statify Blacklist is free software: you can redistribute it and/or modify
|
// Quit.
|
||||||
it under the terms of the GNU General Public License as published by
|
defined( 'ABSPATH' ) or exit;
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
|
||||||
any later version.
|
|
||||||
|
|
||||||
Statify Blacklist is distributed in the hope that it will be useful,
|
// Constants.
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Statify Blacklist. If not, see http://www.gnu.org/licenses/gpl-2.0.html.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Quit
|
|
||||||
defined( 'ABSPATH' ) OR exit;
|
|
||||||
|
|
||||||
// Constants
|
|
||||||
define( 'STATIFYBLACKLIST_FILE', __FILE__ );
|
define( 'STATIFYBLACKLIST_FILE', __FILE__ );
|
||||||
define( 'STATIFYBLACKLIST_DIR', dirname( __FILE__ ) );
|
define( 'STATIFYBLACKLIST_DIR', dirname( __FILE__ ) );
|
||||||
define( 'STATIFYBLACKLIST_BASE', plugin_basename( __FILE__ ) );
|
define( 'STATIFYBLACKLIST_BASE', plugin_basename( __FILE__ ) );
|
||||||
@ -40,27 +48,33 @@ register_activation_hook( STATIFYBLACKLIST_FILE, array( 'StatifyBlacklist_System
|
|||||||
|
|
||||||
register_uninstall_hook( STATIFYBLACKLIST_FILE, array( 'StatifyBlacklist_System', 'uninstall' ) );
|
register_uninstall_hook( STATIFYBLACKLIST_FILE, array( 'StatifyBlacklist_System', 'uninstall' ) );
|
||||||
|
|
||||||
// Upgrade hook
|
// Upgrade hook.
|
||||||
register_activation_hook( STATIFYBLACKLIST_FILE, array( 'StatifyBlacklist_System', 'upgrade' ) );
|
register_activation_hook( STATIFYBLACKLIST_FILE, array( 'StatifyBlacklist_System', 'upgrade' ) );
|
||||||
|
|
||||||
// Autoload
|
// Autoload.
|
||||||
spl_autoload_register( 'statifyBlacklist_autoload' );
|
spl_autoload_register( 'statify_blacklist_autoload' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Autoloader for StatifyBlacklist classes.
|
* Autoloader for StatifyBlacklist classes.
|
||||||
*
|
*
|
||||||
* @param string $class Name of the class to load.
|
* @param string $class Name of the class to load.
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
function statifyBlacklist_autoload( $class ) {
|
function statify_blacklist_autoload( $class ) {
|
||||||
$plugin_classes = array(
|
$plugin_classes = array(
|
||||||
'StatifyBlacklist',
|
'StatifyBlacklist',
|
||||||
'StatifyBlacklist_Admin',
|
'StatifyBlacklist_Admin',
|
||||||
'StatifyBlacklist_System'
|
'StatifyBlacklist_System',
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( in_array( $class, $plugin_classes ) ) {
|
if ( in_array( $class, $plugin_classes ) ) {
|
||||||
require_once( sprintf( '%s/inc/%s.class.php', STATIFYBLACKLIST_DIR, strtolower( $class ) ) );
|
require_once(
|
||||||
|
sprintf(
|
||||||
|
'%s/inc/%s.class.php',
|
||||||
|
STATIFYBLACKLIST_DIR,
|
||||||
|
strtolower( str_replace( '_', '-', $class ) )
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,17 +20,17 @@ const ABSPATH = false;
|
|||||||
/**
|
/**
|
||||||
* The StatifyBlacklist base class.
|
* The StatifyBlacklist base class.
|
||||||
*/
|
*/
|
||||||
require_once( '../inc/statifyblacklist.class.php' );
|
require_once( 'inc/statifyblacklist.class.php' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The StatifyBlacklist system class.
|
* The StatifyBlacklist system class.
|
||||||
*/
|
*/
|
||||||
require_once( '../inc/statifyblacklist_system.class.php' );
|
require_once( 'inc/statifyblacklist-system.class.php' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The StatifyBlacklist admin class.
|
* The StatifyBlacklist admin class.
|
||||||
*/
|
*/
|
||||||
require_once( '../inc/statifyblacklist_admin.class.php' );
|
require_once( 'inc/statifyblacklist-admin.class.php' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class StatifyBlacklistTest.
|
* Class StatifyBlacklistTest.
|
||||||
@ -39,13 +39,13 @@ require_once( '../inc/statifyblacklist_admin.class.php' );
|
|||||||
*
|
*
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
class StatifyBlacklistTest extends PHPUnit\Framework\TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test simple referer filter.
|
* Test simple referer filter.
|
||||||
*/
|
*/
|
||||||
public function testRefererFilter() {
|
public function testRefererFilter() {
|
||||||
// Prepare Options: 2 blacklisted domains, disabled
|
// Prepare Options: 2 blacklisted domains, disabled.
|
||||||
StatifyBlacklist::$_options = array(
|
StatifyBlacklist::$_options = array(
|
||||||
'referer' => array(
|
'referer' => array(
|
||||||
'active' => 0,
|
'active' => 0,
|
||||||
@ -53,20 +53,20 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
'regexp' => 0,
|
'regexp' => 0,
|
||||||
'blacklist' => array(
|
'blacklist' => array(
|
||||||
'example.com' => 0,
|
'example.com' => 0,
|
||||||
'example.net' => 1
|
'example.net' => 1,
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
'target' => array(
|
'target' => array(
|
||||||
'active' => 0,
|
'active' => 0,
|
||||||
'cron' => 0,
|
'cron' => 0,
|
||||||
'regexp' => 0,
|
'regexp' => 0,
|
||||||
'blacklist' => array()
|
'blacklist' => array(),
|
||||||
),
|
),
|
||||||
'ip' => array(
|
'ip' => array(
|
||||||
'active' => 0,
|
'active' => 0,
|
||||||
'blacklist' => array()
|
'blacklist' => array(),
|
||||||
),
|
),
|
||||||
'version' => StatifyBlacklist::VERSION_MAIN
|
'version' => StatifyBlacklist::VERSION_MAIN,
|
||||||
);
|
);
|
||||||
|
|
||||||
// No multisite.
|
// No multisite.
|
||||||
@ -113,20 +113,20 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
'regexp' => 1,
|
'regexp' => 1,
|
||||||
'blacklist' => array(
|
'blacklist' => array(
|
||||||
'example.[a-z]+' => 0,
|
'example.[a-z]+' => 0,
|
||||||
'test' => 1
|
'test' => 1,
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
'target' => array(
|
'target' => array(
|
||||||
'active' => 0,
|
'active' => 0,
|
||||||
'cron' => 0,
|
'cron' => 0,
|
||||||
'regexp' => 0,
|
'regexp' => 0,
|
||||||
'blacklist' => array()
|
'blacklist' => array(),
|
||||||
),
|
),
|
||||||
'ip' => array(
|
'ip' => array(
|
||||||
'active' => 0,
|
'active' => 0,
|
||||||
'blacklist' => array()
|
'blacklist' => array(),
|
||||||
),
|
),
|
||||||
'version' => StatifyBlacklist::VERSION_MAIN
|
'version' => StatifyBlacklist::VERSION_MAIN,
|
||||||
);
|
);
|
||||||
|
|
||||||
// No multisite.
|
// No multisite.
|
||||||
@ -166,10 +166,10 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
'cron_referer' => 0,
|
'cron_referer' => 0,
|
||||||
'referer' => array(
|
'referer' => array(
|
||||||
'example.net' => 0,
|
'example.net' => 0,
|
||||||
'example.com' => 1
|
'example.com' => 1,
|
||||||
),
|
),
|
||||||
'referer_regexp' => 0,
|
'referer_regexp' => 0,
|
||||||
'version' => 1.3
|
'version' => 1.3,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set options in mock.
|
// Set options in mock.
|
||||||
@ -182,10 +182,10 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
$optionsUpdated = get_option( 'statify-blacklist' );
|
$optionsUpdated = get_option( 'statify-blacklist' );
|
||||||
|
|
||||||
// Verify size against default options (no junk left).
|
// Verify size against default options (no junk left).
|
||||||
$this->assertEquals( 4, sizeof( $optionsUpdated ) );
|
$this->assertEquals( 4, count( $optionsUpdated ) );
|
||||||
$this->assertEquals( 4, sizeof( $optionsUpdated['referer'] ) );
|
$this->assertEquals( 4, count( $optionsUpdated['referer'] ) );
|
||||||
$this->assertEquals( 4, sizeof( $optionsUpdated['target'] ) );
|
$this->assertEquals( 4, count( $optionsUpdated['target'] ) );
|
||||||
$this->assertEquals( 2, sizeof( $optionsUpdated['ip'] ) );
|
$this->assertEquals( 2, count( $optionsUpdated['ip'] ) );
|
||||||
|
|
||||||
// Verify that original attributes are unchanged.
|
// Verify that original attributes are unchanged.
|
||||||
$this->assertEquals( $options13['active_referer'], $optionsUpdated['referer']['active'] );
|
$this->assertEquals( $options13['active_referer'], $optionsUpdated['referer']['active'] );
|
||||||
@ -210,92 +210,92 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
*/
|
*/
|
||||||
public function testCidrMatch() {
|
public function testCidrMatch() {
|
||||||
// IPv4 tests.
|
// IPv4 tests.
|
||||||
$this->assertTrue( invokeStatic( StatifyBlacklist::class, 'cidrMatch', array( '127.0.0.1', '127.0.0.1' ) ) );
|
$this->assertTrue( invokeStatic( StatifyBlacklist::class, 'cidr_match', array( '127.0.0.1', '127.0.0.1' ) ) );
|
||||||
$this->assertTrue( invokeStatic( StatifyBlacklist::class, 'cidrMatch', array( '127.0.0.1', '127.0.0.1/32' ) ) );
|
$this->assertTrue( invokeStatic( StatifyBlacklist::class, 'cidr_match', array( '127.0.0.1', '127.0.0.1/32' ) ) );
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
invokeStatic(
|
invokeStatic(
|
||||||
StatifyBlacklist::class, 'cidrMatch', array(
|
StatifyBlacklist::class, 'cidr_match', array(
|
||||||
'127.0.0.1',
|
'127.0.0.1',
|
||||||
'127.0.0.1/33'
|
'127.0.0.1/33',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
invokeStatic(
|
invokeStatic(
|
||||||
StatifyBlacklist::class, 'cidrMatch', array(
|
StatifyBlacklist::class, 'cidr_match', array(
|
||||||
'127.0.0.1',
|
'127.0.0.1',
|
||||||
'127.0.0.1/-1'
|
'127.0.0.1/-1',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
invokeStatic(
|
invokeStatic(
|
||||||
StatifyBlacklist::class, 'cidrMatch', array(
|
StatifyBlacklist::class, 'cidr_match', array(
|
||||||
'192.0.2.123',
|
'192.0.2.123',
|
||||||
'192.0.2.0/24'
|
'192.0.2.0/24',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
invokeStatic(
|
invokeStatic(
|
||||||
StatifyBlacklist::class, 'cidrMatch', array(
|
StatifyBlacklist::class, 'cidr_match', array(
|
||||||
'192.0.3.123',
|
'192.0.3.123',
|
||||||
'192.0.2.0/24'
|
'192.0.2.0/24',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
invokeStatic(
|
invokeStatic(
|
||||||
StatifyBlacklist::class, 'cidrMatch', array(
|
StatifyBlacklist::class, 'cidr_match', array(
|
||||||
'192.0.2.123',
|
'192.0.2.123',
|
||||||
'192.0.2.120/29'
|
'192.0.2.120/29',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
invokeStatic(
|
invokeStatic(
|
||||||
StatifyBlacklist::class, 'cidrMatch', array(
|
StatifyBlacklist::class, 'cidr_match', array(
|
||||||
'192.0.2.128',
|
'192.0.2.128',
|
||||||
'192.0.2.120/29'
|
'192.0.2.120/29',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->assertTrue( invokeStatic( StatifyBlacklist::class, 'cidrMatch', array( '10.11.12.13', '10.0.0.0/8' ) ) );
|
$this->assertTrue( invokeStatic( StatifyBlacklist::class, 'cidr_match', array( '10.11.12.13', '10.0.0.0/8' ) ) );
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
invokeStatic(
|
invokeStatic(
|
||||||
StatifyBlacklist::class, 'cidrMatch', array(
|
StatifyBlacklist::class, 'cidr_match', array(
|
||||||
'10.11.12.345',
|
'10.11.12.345',
|
||||||
'10.0.0.0/8'
|
'10.0.0.0/8',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// IPv6 tests.
|
// IPv6 tests.
|
||||||
$this->assertTrue( invokeStatic( StatifyBlacklist::class, 'cidrMatch', array( '::1', '::1' ) ) );
|
$this->assertTrue( invokeStatic( StatifyBlacklist::class, 'cidr_match', array( '::1', '::1' ) ) );
|
||||||
$this->assertTrue( invokeStatic( StatifyBlacklist::class, 'cidrMatch', array( '::1', '::1/128' ) ) );
|
$this->assertTrue( invokeStatic( StatifyBlacklist::class, 'cidr_match', array( '::1', '::1/128' ) ) );
|
||||||
$this->assertFalse( invokeStatic( StatifyBlacklist::class, 'cidrMatch', array( '::1', '::1/129' ) ) );
|
$this->assertFalse( invokeStatic( StatifyBlacklist::class, 'cidr_match', array( '::1', '::1/129' ) ) );
|
||||||
$this->assertFalse( invokeStatic( StatifyBlacklist::class, 'cidrMatch', array( '::1', '::1/-1' ) ) );
|
$this->assertFalse( invokeStatic( StatifyBlacklist::class, 'cidr_match', array( '::1', '::1/-1' ) ) );
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
invokeStatic(
|
invokeStatic(
|
||||||
StatifyBlacklist::class, 'cidrMatch', array(
|
StatifyBlacklist::class, 'cidr_match', array(
|
||||||
'2001:db8:a0b:12f0:1:2:3:4',
|
'2001:db8:a0b:12f0:1:2:3:4',
|
||||||
'2001:db8:a0b:12f0::1/64 '
|
'2001:db8:a0b:12f0::1/64 ',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
invokeStatic(
|
invokeStatic(
|
||||||
StatifyBlacklist::class, 'cidrMatch', array(
|
StatifyBlacklist::class, 'cidr_match', array(
|
||||||
'2001:db8:a0b:12f0::123:456',
|
'2001:db8:a0b:12f0::123:456',
|
||||||
'2001:db8:a0b:12f0::1/96 '
|
'2001:db8:a0b:12f0::1/96 ',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
invokeStatic(
|
invokeStatic(
|
||||||
StatifyBlacklist::class, 'cidrMatch', array(
|
StatifyBlacklist::class, 'cidr_match', array(
|
||||||
'2001:db8:a0b:12f0::1:132:465',
|
'2001:db8:a0b:12f0::1:132:465',
|
||||||
'2001:db8:a0b:12f0::1/96 '
|
'2001:db8:a0b:12f0::1/96 ',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -318,14 +318,14 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
'2001:db8:a0b:12f0::',
|
'2001:db8:a0b:12f0::',
|
||||||
'2001:db8:a0b:12f0::1',
|
'2001:db8:a0b:12f0::1',
|
||||||
'2001:db8:a0b:12f0::1/128',
|
'2001:db8:a0b:12f0::1/128',
|
||||||
'2001:db8:a0b:12f0::/64'
|
'2001:db8:a0b:12f0::/64',
|
||||||
);
|
);
|
||||||
$invalid = array(
|
$invalid = array(
|
||||||
'2001:db8:a0b:12f0::x',
|
'2001:db8:a0b:12f0::x',
|
||||||
'2001:db8:a0b:12f0:::',
|
'2001:db8:a0b:12f0:::',
|
||||||
'2001:fffff:a0b:12f0::1',
|
'2001:fffff:a0b:12f0::1',
|
||||||
'2001:db8:a0b:12f0::/129',
|
'2001:db8:a0b:12f0::/129',
|
||||||
'1:2:3:4:5:6:7:8:9'
|
'1:2:3:4:5:6:7:8:9',
|
||||||
);
|
);
|
||||||
$result = invokeStatic( StatifyBlacklist_Admin::class, 'sanitizeIPs', array( array_merge( $valid, $invalid ) ) );
|
$result = invokeStatic( StatifyBlacklist_Admin::class, 'sanitizeIPs', array( array_merge( $valid, $invalid ) ) );
|
||||||
$this->assertNotFalse( $result );
|
$this->assertNotFalse( $result );
|
||||||
@ -343,22 +343,22 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
'active' => 0,
|
'active' => 0,
|
||||||
'cron' => 0,
|
'cron' => 0,
|
||||||
'regexp' => 0,
|
'regexp' => 0,
|
||||||
'blacklist' => array()
|
'blacklist' => array(),
|
||||||
),
|
),
|
||||||
'target' => array(
|
'target' => array(
|
||||||
'active' => 0,
|
'active' => 0,
|
||||||
'cron' => 0,
|
'cron' => 0,
|
||||||
'regexp' => 0,
|
'regexp' => 0,
|
||||||
'blacklist' => array()
|
'blacklist' => array(),
|
||||||
),
|
),
|
||||||
'ip' => array(
|
'ip' => array(
|
||||||
'active' => 0,
|
'active' => 0,
|
||||||
'blacklist' => array(
|
'blacklist' => array(
|
||||||
'192.0.2.123',
|
'192.0.2.123',
|
||||||
'2001:db8:a0b:12f0::1'
|
'2001:db8:a0b:12f0::1',
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
'version' => StatifyBlacklist::VERSION_MAIN
|
'version' => StatifyBlacklist::VERSION_MAIN,
|
||||||
);
|
);
|
||||||
|
|
||||||
// No multisite.
|
// No multisite.
|
||||||
@ -381,7 +381,7 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
// Subnet matching.
|
// Subnet matching.
|
||||||
StatifyBlacklist::$_options['ip']['blacklist'] = array(
|
StatifyBlacklist::$_options['ip']['blacklist'] = array(
|
||||||
'192.0.2.0/25',
|
'192.0.2.0/25',
|
||||||
'2001:db8:a0b:12f0::/96'
|
'2001:db8:a0b:12f0::/96',
|
||||||
);
|
);
|
||||||
$_SERVER['REMOTE_ADDR'] = '192.0.2.123';
|
$_SERVER['REMOTE_ADDR'] = '192.0.2.123';
|
||||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
||||||
@ -413,7 +413,7 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
'active' => 0,
|
'active' => 0,
|
||||||
'cron' => 0,
|
'cron' => 0,
|
||||||
'regexp' => 0,
|
'regexp' => 0,
|
||||||
'blacklist' => array()
|
'blacklist' => array(),
|
||||||
),
|
),
|
||||||
'target' => array(
|
'target' => array(
|
||||||
'active' => 0,
|
'active' => 0,
|
||||||
@ -421,14 +421,14 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
'regexp' => 0,
|
'regexp' => 0,
|
||||||
'blacklist' => array(
|
'blacklist' => array(
|
||||||
'/excluded/page/' => 0,
|
'/excluded/page/' => 0,
|
||||||
'/?page_id=3' => 1
|
'/?page_id=3' => 1,
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
'ip' => array(
|
'ip' => array(
|
||||||
'active' => 0,
|
'active' => 0,
|
||||||
'blacklist' => array()
|
'blacklist' => array(),
|
||||||
),
|
),
|
||||||
'version' => StatifyBlacklist::VERSION_MAIN
|
'version' => StatifyBlacklist::VERSION_MAIN,
|
||||||
);
|
);
|
||||||
|
|
||||||
// No multisite.
|
// No multisite.
|
||||||
@ -471,12 +471,7 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// TODO: Test target regex filter.
|
||||||
* Test target filter using regular expressions.
|
|
||||||
*/
|
|
||||||
public function testTargetRegexFilter() {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -491,7 +486,6 @@ function invokeStatic( $class, $methodName, $parameters = array() ) {
|
|||||||
|
|
||||||
|
|
||||||
// Some mocked WP functions.
|
// Some mocked WP functions.
|
||||||
|
|
||||||
$mock_options = array();
|
$mock_options = array();
|
||||||
$mock_multisite = false;
|
$mock_multisite = false;
|
||||||
|
|
||||||
@ -523,13 +517,22 @@ function wp_parse_args( $args, $defaults = '' ) {
|
|||||||
function get_option( $option, $default = false ) {
|
function get_option( $option, $default = false ) {
|
||||||
global $mock_options;
|
global $mock_options;
|
||||||
|
|
||||||
return isset( $mock_options[$option] ) ? $mock_options[$option] : $default;
|
return isset( $mock_options[ $option ] ) ? $mock_options[ $option ] : $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @ignore */
|
/** @ignore */
|
||||||
function update_option( $option, $value, $autoload = null ) {
|
function update_option( $option, $value, $autoload = null ) {
|
||||||
global $mock_options;
|
global $mock_options;
|
||||||
$mock_options[$option] = $value;
|
$mock_options[ $option ] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @ignore */
|
||||||
|
function wp_get_raw_referer() {
|
||||||
|
return isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function wp_parse_url( $value ) {
|
||||||
|
return parse_url( $value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @ignore */
|
/** @ignore */
|
@ -10,7 +10,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Quit.
|
// Quit.
|
||||||
defined( 'ABSPATH' ) OR exit;
|
defined( 'ABSPATH' ) or exit;
|
||||||
|
|
||||||
// Update plugin options.
|
// Update plugin options.
|
||||||
if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
||||||
@ -51,27 +51,27 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
|||||||
$statifyBlacklistUpdateResult = StatifyBlacklist_Admin::update_options(
|
$statifyBlacklistUpdateResult = StatifyBlacklist_Admin::update_options(
|
||||||
array(
|
array(
|
||||||
'referer' => array(
|
'referer' => array(
|
||||||
'active' => (int) @$_POST['statifyblacklist']['referer']['active'],
|
'active' => (int) $_POST['statifyblacklist']['referer']['active'],
|
||||||
'cron' => (int) @$_POST['statifyblacklist']['referer']['cron'],
|
'cron' => (int) $_POST['statifyblacklist']['referer']['cron'],
|
||||||
'regexp' => (int) @$_POST['statifyblacklist']['referer']['regexp'],
|
'regexp' => (int) $_POST['statifyblacklist']['referer']['regexp'],
|
||||||
'blacklist' => array_flip( $referer )
|
'blacklist' => array_flip( $referer ),
|
||||||
),
|
),
|
||||||
'target' => array(
|
'target' => array(
|
||||||
'active' => (int) @$_POST['statifyblacklist']['target']['active'],
|
'active' => (int) $_POST['statifyblacklist']['target']['active'],
|
||||||
'cron' => (int) @$_POST['statifyblacklist']['target']['cron'],
|
'cron' => (int) $_POST['statifyblacklist']['target']['cron'],
|
||||||
'regexp' => (int) @$_POST['statifyblacklist']['target']['regexp'],
|
'regexp' => (int) $_POST['statifyblacklist']['target']['regexp'],
|
||||||
'blacklist' => array_flip( $target )
|
'blacklist' => array_flip( $target ),
|
||||||
),
|
),
|
||||||
'ip' => array(
|
'ip' => array(
|
||||||
'active' => (int) @$_POST['statifyblacklist']['ip']['active'],
|
'active' => (int) $_POST['statifyblacklist']['ip']['active'],
|
||||||
'blacklist' => $ip
|
'blacklist' => $ip,
|
||||||
),
|
),
|
||||||
'version' => StatifyBlacklist::VERSION_MAIN
|
'version' => StatifyBlacklist::VERSION_MAIN,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Generate messages.
|
// Generate messages.
|
||||||
if ( $statifyBlacklistUpdateResult !== false ) {
|
if ( false !== $statifyBlacklistUpdateResult ) {
|
||||||
if ( array_key_exists( 'referer', $statifyBlacklistUpdateResult ) ) {
|
if ( array_key_exists( 'referer', $statifyBlacklistUpdateResult ) ) {
|
||||||
$statifyBlacklistPostWarning = __( 'Some URLs are invalid and have been sanitized.', 'statify-blacklist' );
|
$statifyBlacklistPostWarning = __( 'Some URLs are invalid and have been sanitized.', 'statify-blacklist' );
|
||||||
} elseif ( array_key_exists( 'ip', $statifyBlacklistUpdateResult ) ) {
|
} elseif ( array_key_exists( 'ip', $statifyBlacklistUpdateResult ) ) {
|
||||||
@ -85,7 +85,7 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h1><?php _e( 'Statify Blacklist', 'statify-blacklist' ) ?></h1>
|
<h1><?php esc_html_e( 'Statify Blacklist', 'statify-blacklist' ) ?></h1>
|
||||||
<?php
|
<?php
|
||||||
if ( is_plugin_inactive( 'statify/statify.php' ) ) {
|
if ( is_plugin_inactive( 'statify/statify.php' ) ) {
|
||||||
print '<div class="notice notice-warning"><p>';
|
print '<div class="notice notice-warning"><p>';
|
||||||
@ -152,11 +152,11 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
|||||||
<label for="statify-blacklist_referer">
|
<label for="statify-blacklist_referer">
|
||||||
<?php esc_html_e( 'Referer blacklist', 'statify-blacklist' ); ?>:<br />
|
<?php esc_html_e( 'Referer blacklist', 'statify-blacklist' ); ?>:<br />
|
||||||
<textarea cols="40" rows="5" name="statifyblacklist[referer][blacklist]" id="statify-blacklist_referer"><?php
|
<textarea cols="40" rows="5" name="statifyblacklist[referer][blacklist]" id="statify-blacklist_referer"><?php
|
||||||
if ( isset( $statifyBlacklistUpdateResult['referer'] ) ) {
|
if ( isset( $statifyBlacklistUpdateResult['referer'] ) ) {
|
||||||
print esc_html( implode( "\r\n", array_keys( $statifyBlacklistUpdateResult['referer'] ) ) );
|
print esc_html( implode( "\r\n", array_keys( $statifyBlacklistUpdateResult['referer'] ) ) );
|
||||||
} else {
|
} else {
|
||||||
print esc_html( implode( "\r\n", array_keys( StatifyBlacklist::$_options['referer']['blacklist'] ) ) );
|
print esc_html( implode( "\r\n", array_keys( StatifyBlacklist::$_options['referer']['blacklist'] ) ) );
|
||||||
}
|
}
|
||||||
?></textarea>
|
?></textarea>
|
||||||
<br />
|
<br />
|
||||||
<small>
|
<small>
|
||||||
@ -214,11 +214,11 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
|||||||
<label for="statify-blacklist_target">
|
<label for="statify-blacklist_target">
|
||||||
<?php esc_html_e( 'Target blacklist', 'statify-blacklist' ); ?>:<br />
|
<?php esc_html_e( 'Target blacklist', 'statify-blacklist' ); ?>:<br />
|
||||||
<textarea cols="40" rows="5" name="statifyblacklist[target][blacklist]" id="statify-blacklist_target"><?php
|
<textarea cols="40" rows="5" name="statifyblacklist[target][blacklist]" id="statify-blacklist_target"><?php
|
||||||
if ( isset( $statifyBlacklistUpdateResult['target'] ) ) {
|
if ( isset( $statifyBlacklistUpdateResult['target'] ) ) {
|
||||||
print esc_html( implode( "\r\n", array_keys( $statifyBlacklistUpdateResult['target'] ) ) );
|
print esc_html( implode( "\r\n", array_keys( $statifyBlacklistUpdateResult['target'] ) ) );
|
||||||
} else {
|
} else {
|
||||||
print esc_html( implode( "\r\n", array_keys( StatifyBlacklist::$_options['target']['blacklist'] ) ) );
|
print esc_html( implode( "\r\n", array_keys( StatifyBlacklist::$_options['target']['blacklist'] ) ) );
|
||||||
}
|
}
|
||||||
?></textarea>
|
?></textarea>
|
||||||
<br />
|
<br />
|
||||||
<small>
|
<small>
|
||||||
@ -251,11 +251,11 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
|||||||
<label for="statify-blacklist_ip">
|
<label for="statify-blacklist_ip">
|
||||||
<?php esc_html_e( 'IP blacklist', 'statify-blacklist' ); ?>:<br />
|
<?php esc_html_e( 'IP blacklist', 'statify-blacklist' ); ?>:<br />
|
||||||
<textarea cols="40" rows="5" name="statifyblacklist[ip][blacklist]" id="statify-blacklist_ip"><?php
|
<textarea cols="40" rows="5" name="statifyblacklist[ip][blacklist]" id="statify-blacklist_ip"><?php
|
||||||
if ( isset( $statifyBlacklistUpdateResult['ip'] ) ) {
|
if ( isset( $statifyBlacklistUpdateResult['ip'] ) ) {
|
||||||
print esc_html( $_POST['statifyblacklist']['ip']['blacklist'] );
|
print esc_html( $_POST['statifyblacklist']['ip']['blacklist'] );
|
||||||
} else {
|
} else {
|
||||||
print esc_html( implode( "\r\n", StatifyBlacklist::$_options['ip']['blacklist'] ) );
|
print esc_html( implode( "\r\n", StatifyBlacklist::$_options['ip']['blacklist'] ) );
|
||||||
}
|
}
|
||||||
?></textarea>
|
?></textarea>
|
||||||
<br />
|
<br />
|
||||||
<small>
|
<small>
|
||||||
@ -271,7 +271,7 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
|||||||
<?php wp_nonce_field( 'statify-blacklist-settings' ); ?>
|
<?php wp_nonce_field( 'statify-blacklist-settings' ); ?>
|
||||||
|
|
||||||
<p class="submit">
|
<p class="submit">
|
||||||
<input class="button-primary" type="submit" name="submit" value="<?php _e( 'Save Changes' ) ?>">
|
<input class="button-primary" type="submit" name="submit" value="<?php esc_html_e( 'Save Changes' ) ?>">
|
||||||
<hr />
|
<hr />
|
||||||
<input class="button-secondary" type="submit" name="cleanUp"
|
<input class="button-secondary" type="submit" name="cleanUp"
|
||||||
value="<?php esc_html_e( 'CleanUp Database', 'statify-blacklist' ) ?>"
|
value="<?php esc_html_e( 'CleanUp Database', 'statify-blacklist' ) ?>"
|
Loading…
x
Reference in New Issue
Block a user