Config array restructured
This commit is contained in:
parent
152a800a4a
commit
df59e43b29
@ -57,7 +57,7 @@ class StatifyBlacklist {
|
|||||||
self::$multisite = ( is_multisite() && array_key_exists( STATIFYBLACKLIST_BASE, (array) get_site_option( 'active_sitewide_plugins' ) ) );
|
self::$multisite = ( is_multisite() && array_key_exists( STATIFYBLACKLIST_BASE, (array) get_site_option( 'active_sitewide_plugins' ) ) );
|
||||||
|
|
||||||
/* Add Filter to statify hook if enabled */
|
/* Add Filter to statify hook if enabled */
|
||||||
if ( self::$_options['active_referer'] != 0 ) {
|
if ( self::$_options['referer']['active'] != 0 ) {
|
||||||
add_filter( 'statify_skip_tracking', array( 'StatifyBlacklist', 'apply_blacklist_filter' ) );
|
add_filter( 'statify_skip_tracking', array( 'StatifyBlacklist', 'apply_blacklist_filter' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ class StatifyBlacklist {
|
|||||||
|
|
||||||
/* CronJob to clean up database */
|
/* CronJob to clean up database */
|
||||||
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
|
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
|
||||||
if ( self::$_options['cron_referer'] == 1 || self::$_options['cron_target'] == 1 ) {
|
if ( self::$_options['referer']['cron'] == 1 || self::$_options['target']['cron'] == 1 ) {
|
||||||
add_action( 'statify_cleanup', array( 'StatifyBlacklist_Admin', 'cleanup_database' ) );
|
add_action( 'statify_cleanup', array( 'StatifyBlacklist_Admin', 'cleanup_database' ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,16 +115,22 @@ class StatifyBlacklist {
|
|||||||
*/
|
*/
|
||||||
protected static function defaultOptions() {
|
protected static function defaultOptions() {
|
||||||
return array(
|
return array(
|
||||||
'active_referer' => 0,
|
'referer' => array(
|
||||||
'cron_referer' => 0,
|
'active' => 0,
|
||||||
'referer' => array(),
|
'cron' => 0,
|
||||||
'referer_regexp' => 0,
|
'regexp' => 0,
|
||||||
'active_target' => 0,
|
'blacklist' => array()
|
||||||
'cron_target' => 0,
|
),
|
||||||
'target' => array(),
|
'target' => array(
|
||||||
'target_regexp' => 0,
|
'active' => 0,
|
||||||
'active_ip' => 0,
|
'cron' => 0,
|
||||||
'ip' => array(),
|
'regexp' => 0,
|
||||||
|
'blacklist' => array()
|
||||||
|
),
|
||||||
|
'ip' => array(
|
||||||
|
'active' => 0,
|
||||||
|
'blacklist' => array()
|
||||||
|
),
|
||||||
'version' => self::VERSION_MAIN
|
'version' => self::VERSION_MAIN
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -139,14 +145,14 @@ class StatifyBlacklist {
|
|||||||
*/
|
*/
|
||||||
public static function apply_blacklist_filter() {
|
public static function apply_blacklist_filter() {
|
||||||
/* Referer blacklist */
|
/* Referer blacklist */
|
||||||
if ( isset( self::$_options['active_referer'] ) && self::$_options['active_referer'] != 0 ) {
|
if ( isset( self::$_options['referer']['active'] ) && self::$_options['referer']['active'] != 0 ) {
|
||||||
/* 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 = ( isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '' );
|
||||||
/* Merge given regular expressions into one */
|
/* Merge given regular expressions into one */
|
||||||
$regexp = '/' . implode( "|", array_keys( self::$_options['referer'] ) ) . '/';
|
$regexp = '/' . implode( "|", array_keys( self::$_options['referer']['blacklist'] ) ) . '/';
|
||||||
if ( self::$_options['referer_regexp'] == 2 ) {
|
if ( self::$_options['referer']['regexp'] == 2 ) {
|
||||||
$regexp .= 'i';
|
$regexp .= 'i';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +164,7 @@ class StatifyBlacklist {
|
|||||||
$referer = strtolower( ( isset( $_SERVER['HTTP_REFERER'] ) ? parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_HOST ) : '' ) );
|
$referer = strtolower( ( isset( $_SERVER['HTTP_REFERER'] ) ? parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_HOST ) : '' ) );
|
||||||
|
|
||||||
/* Get blacklist */
|
/* Get blacklist */
|
||||||
$blacklist = self::$_options['referer'];
|
$blacklist = self::$_options['referer']['blacklist'];
|
||||||
|
|
||||||
/* Check blacklist */
|
/* Check blacklist */
|
||||||
if ( isset( $blacklist[ $referer ] ) ) {
|
if ( isset( $blacklist[ $referer ] ) ) {
|
||||||
@ -168,14 +174,14 @@ class StatifyBlacklist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Target blacklist (since 1.4.0) */
|
/* Target blacklist (since 1.4.0) */
|
||||||
if ( isset( self::$_options['active_target'] ) && self::$_options['active_target'] != 0 ) {
|
if ( isset( self::$_options['target']['active'] ) && self::$_options['target']['active'] != 0 ) {
|
||||||
/* Regular Expression filtering since 1.3.0 */
|
/* Regular Expression filtering since 1.3.0 */
|
||||||
if ( isset( self::$_options['target_regexp'] ) && self::$_options['target_regexp'] > 0 ) {
|
if ( isset( self::$_options['target']['regexp'] ) && self::$_options['target']['regexp'] > 0 ) {
|
||||||
/* Get full referer string */
|
/* Get full referer string */
|
||||||
$target = ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '/' );
|
$target = ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '/' );
|
||||||
/* Merge given regular expressions into one */
|
/* Merge given regular expressions into one */
|
||||||
$regexp = '/' . implode( "|", array_keys( self::$_options['target'] ) ) . '/';
|
$regexp = '/' . implode( "|", array_keys( self::$_options['target']['blacklist'] ) ) . '/';
|
||||||
if ( self::$_options['target_regexp'] == 2 ) {
|
if ( self::$_options['target']['regexp'] == 2 ) {
|
||||||
$regexp .= 'i';
|
$regexp .= 'i';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +192,7 @@ class StatifyBlacklist {
|
|||||||
/* Extract target page */
|
/* Extract target page */
|
||||||
$target = ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '/' );
|
$target = ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '/' );
|
||||||
/* Get blacklist */
|
/* Get blacklist */
|
||||||
$blacklist = self::$_options['target'];
|
$blacklist = self::$_options['target']['blacklist'];
|
||||||
/* Check blacklist */
|
/* Check blacklist */
|
||||||
if ( isset( $blacklist[ $target ] ) ) {
|
if ( isset( $blacklist[ $target ] ) ) {
|
||||||
return true;
|
return true;
|
||||||
@ -195,9 +201,9 @@ class StatifyBlacklist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* IP blacklist (since 1.4.0) */
|
/* IP blacklist (since 1.4.0) */
|
||||||
if ( isset ( self::$_options['active_ip'] ) && self::$_options['active_ip'] != 0 ) {
|
if ( isset ( self::$_options['ip']['active'] ) && self::$_options['ip']['active'] != 0 ) {
|
||||||
if ( ( $ip = self::getIP() ) !== false ) {
|
if ( ( $ip = self::getIP() ) !== false ) {
|
||||||
foreach ( self::$_options['ip'] as $net ) {
|
foreach ( self::$_options['ip']['blacklist'] as $net ) {
|
||||||
if ( self::cidrMatch( $ip, $net ) ) {
|
if ( self::cidrMatch( $ip, $net ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -22,15 +22,15 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
|||||||
public static function update_options( $options = null ) {
|
public static function update_options( $options = null ) {
|
||||||
if ( isset( $options ) && current_user_can( 'manage_options' ) ) {
|
if ( isset( $options ) && current_user_can( 'manage_options' ) ) {
|
||||||
/* Sanitize URLs and remove empty inputs */
|
/* Sanitize URLs and remove empty inputs */
|
||||||
$givenReferer = $options['referer'];
|
$givenReferer = $options['referer']['blacklist'];
|
||||||
if ( $options['referer_regexp'] == 0 ) {
|
if ( $options['referer']['regexp'] == 0 ) {
|
||||||
$sanitizedReferer = self::sanitizeURLs( $givenReferer );
|
$sanitizedReferer = self::sanitizeURLs( $givenReferer );
|
||||||
} else {
|
} else {
|
||||||
$sanitizedReferer = $givenReferer;
|
$sanitizedReferer = $givenReferer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sanitize IPs and Subnets and remove empty inputs */
|
/* Sanitize IPs and Subnets and remove empty inputs */
|
||||||
$givenIP = $options['ip'];
|
$givenIP = $options['ip']['blacklist'];
|
||||||
$sanitizedIP = self::sanitizeIPs( $givenIP );
|
$sanitizedIP = self::sanitizeIPs( $givenIP );
|
||||||
|
|
||||||
/* Abort on errors */
|
/* Abort on errors */
|
||||||
@ -132,8 +132,8 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
|
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
|
||||||
$cleanRef = ( self::$_options['cron_referer'] == 1 );
|
$cleanRef = ( self::$_options['referer']['cron'] == 1 );
|
||||||
$cleanTrg = ( self::$_options['cron_target'] == 1 );
|
$cleanTrg = ( self::$_options['target']['cron'] == 1 );
|
||||||
} else {
|
} else {
|
||||||
$cleanRef = true;
|
$cleanRef = true;
|
||||||
$cleanTrg = true;
|
$cleanTrg = true;
|
||||||
@ -141,12 +141,12 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
|||||||
|
|
||||||
|
|
||||||
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'] ) );
|
$refererRegexp = implode( "|", array_keys( self::$_options['referer']['blacklist'] ) );
|
||||||
} else {
|
} else {
|
||||||
/* Sanitize URLs */
|
/* Sanitize URLs */
|
||||||
$referer = self::sanitizeURLs( self::$_options['referer'] );
|
$referer = self::sanitizeURLs( self::$_options['referer']['blacklist'] );
|
||||||
|
|
||||||
/* Build filter regexp */
|
/* Build filter regexp */
|
||||||
$refererRegexp = str_replace( '.', '\.', implode( '|', array_flip( $referer ) ) );
|
$refererRegexp = str_replace( '.', '\.', implode( '|', array_flip( $referer ) ) );
|
||||||
@ -154,12 +154,12 @@ 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'] ) );
|
$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'] ) ) );
|
$targetRegexp = str_replace( '.', '\.', implode( '|', array_flip( self::$_options['target']['blacklist'] ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,14 +171,14 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
|||||||
if ( ! empty( $refererRegexp ) ) {
|
if ( ! empty( $refererRegexp ) ) {
|
||||||
$wpdb->query(
|
$wpdb->query(
|
||||||
$wpdb->prepare( "DELETE FROM `$wpdb->statify` WHERE "
|
$wpdb->prepare( "DELETE FROM `$wpdb->statify` WHERE "
|
||||||
. ( ( self::$_options['referer_regexp'] == 1 ) ? " BINARY " : "" )
|
. ( ( self::$_options['referer']['regexp'] == 1 ) ? " BINARY " : "" )
|
||||||
. "referrer REGEXP %s", $refererRegexp )
|
. "referrer REGEXP %s", $refererRegexp )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ( ! empty( $targetRegexp ) ) {
|
if ( ! empty( $targetRegexp ) ) {
|
||||||
$wpdb->query(
|
$wpdb->query(
|
||||||
$wpdb->prepare( "DELETE FROM `$wpdb->statify` WHERE "
|
$wpdb->prepare( "DELETE FROM `$wpdb->statify` WHERE "
|
||||||
. ( ( self::$_options['target_regexp'] == 1 ) ? " BINARY " : "" )
|
. ( ( self::$_options['target']['regexp'] == 1 ) ? " BINARY " : "" )
|
||||||
. "target REGEXP %s", $targetRegexp )
|
. "target REGEXP %s", $targetRegexp )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -97,8 +97,38 @@ class StatifyBlacklist_System extends StatifyBlacklist {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Version not set (pre 1.3.0) or older than current major release */
|
/* Version not set (pre 1.3.0) or older than 1.4 */
|
||||||
if ( ! isset( self::$_options['version'] ) || self::$_options['version'] < self::VERSION_MAIN ) {
|
if ( ! isset( self::$_options['version'] ) || self::$_options['version'] < 1.4 ) {
|
||||||
|
/* Upgrade options to new schema */
|
||||||
|
$options = array(
|
||||||
|
'referer' => array(
|
||||||
|
'active' => self::$_options['active_referer'],
|
||||||
|
'cron' => self::$_options['cron_referer'],
|
||||||
|
'regexp' => self::$_options['referer_regexp'],
|
||||||
|
'blacklist' => self::$_options['referer']
|
||||||
|
),
|
||||||
|
'target' => array(
|
||||||
|
'active' => 0,
|
||||||
|
'cron' => 0,
|
||||||
|
'regexp' => 0,
|
||||||
|
'blacklist' => array()
|
||||||
|
),
|
||||||
|
'ip' => array(
|
||||||
|
'active' => 0,
|
||||||
|
'blacklist' => array()
|
||||||
|
),
|
||||||
|
'version' => 1.4
|
||||||
|
);
|
||||||
|
if ( ( is_multisite() && array_key_exists( STATIFYBLACKLIST_BASE, (array) get_site_option( 'active_sitewide_plugins' ) ) ) ) {
|
||||||
|
update_site_option( 'statify-blacklist', $options );
|
||||||
|
} else {
|
||||||
|
update_option( 'statify-blacklist', $options );
|
||||||
|
}
|
||||||
|
self::update_options();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Version older than current major release */
|
||||||
|
if ( self::$_options['version'] < self::VERSION_MAIN ) {
|
||||||
/* Merge default options with current config, assuming only additive changes */
|
/* Merge default options with current config, assuming only additive changes */
|
||||||
$options = array_merge( self::defaultOptions(), self::$_options );
|
$options = array_merge( self::defaultOptions(), self::$_options );
|
||||||
$options['version'] = self::VERSION_MAIN;
|
$options['version'] = self::VERSION_MAIN;
|
||||||
|
@ -20,14 +20,25 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
public function testRefererFilter() {
|
public function testRefererFilter() {
|
||||||
/* Prepare Options: 2 blacklisted domains, disabled */
|
/* Prepare Options: 2 blacklisted domains, disabled */
|
||||||
StatifyBlacklist::$_options = array(
|
StatifyBlacklist::$_options = array(
|
||||||
'active_referer' => 0,
|
|
||||||
'cron_referer' => 0,
|
|
||||||
'referer' => array(
|
'referer' => array(
|
||||||
|
'active' => 0,
|
||||||
|
'cron' => 0,
|
||||||
|
'regexp' => 0,
|
||||||
|
'blacklist' => array(
|
||||||
'example.com' => 0,
|
'example.com' => 0,
|
||||||
'example.net' => 1
|
'example.net' => 1
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'target' => array(
|
||||||
|
'active' => 0,
|
||||||
|
'cron' => 0,
|
||||||
|
'regexp' => 0,
|
||||||
|
'blacklist' => array()
|
||||||
|
),
|
||||||
|
'ip' => array(
|
||||||
|
'active' => 0,
|
||||||
|
'blacklist' => array()
|
||||||
),
|
),
|
||||||
'active_ip' => 0,
|
|
||||||
'ip' => array(),
|
|
||||||
'version' => StatifyBlacklist::VERSION_MAIN
|
'version' => StatifyBlacklist::VERSION_MAIN
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -48,7 +59,7 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||||
|
|
||||||
/* Activate filter and run tests again */
|
/* Activate filter and run tests again */
|
||||||
StatifyBlacklist::$_options['active_referer'] = 1;
|
StatifyBlacklist::$_options['referer']['active'] = 1;
|
||||||
|
|
||||||
unset( $_SERVER['HTTP_REFERER'] );
|
unset( $_SERVER['HTTP_REFERER'] );
|
||||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||||
@ -69,14 +80,26 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
public function testRefererRegexFilter() {
|
public function testRefererRegexFilter() {
|
||||||
/* Prepare Options: 2 regular expressions */
|
/* Prepare Options: 2 regular expressions */
|
||||||
StatifyBlacklist::$_options = array(
|
StatifyBlacklist::$_options = array(
|
||||||
'active_referer' => 1,
|
|
||||||
'cron_referer' => 0,
|
|
||||||
'referer' => array(
|
'referer' => array(
|
||||||
|
'active' => 1,
|
||||||
|
'cron' => 0,
|
||||||
|
'regexp' => 1,
|
||||||
|
'blacklist' => array(
|
||||||
'example.[a-z]+' => 0,
|
'example.[a-z]+' => 0,
|
||||||
'test' => 1
|
'test' => 1
|
||||||
|
)
|
||||||
),
|
),
|
||||||
'referer_regexp' => 1,
|
'target' => array(
|
||||||
'version' => 1.3
|
'active' => 0,
|
||||||
|
'cron' => 0,
|
||||||
|
'regexp' => 0,
|
||||||
|
'blacklist' => array()
|
||||||
|
),
|
||||||
|
'ip' => array(
|
||||||
|
'active' => 0,
|
||||||
|
'blacklist' => array()
|
||||||
|
),
|
||||||
|
'version' => StatifyBlacklist::VERSION_MAIN
|
||||||
);
|
);
|
||||||
|
|
||||||
/* No multisite */
|
/* No multisite */
|
||||||
@ -102,7 +125,7 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||||
|
|
||||||
/* Set RegExp filter to case insensitive */
|
/* Set RegExp filter to case insensitive */
|
||||||
StatifyBlacklist::$_options['referer_regexp'] = 2;
|
StatifyBlacklist::$_options['referer']['regexp'] = 2;
|
||||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,17 +155,24 @@ 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( 11, sizeof( $optionsUpdated ) );
|
$this->assertEquals( 4, sizeof( $optionsUpdated ) );
|
||||||
|
$this->assertEquals( 4, sizeof( $optionsUpdated['referer'] ) );
|
||||||
|
$this->assertEquals( 4, sizeof( $optionsUpdated['target'] ) );
|
||||||
|
$this->assertEquals( 2, sizeof( $optionsUpdated['ip'] ) );
|
||||||
|
|
||||||
/* Verify that original attributes are unchanged */
|
/* Verify that original attributes are unchanged */
|
||||||
$this->assertEquals( $options13['active_referer'], $optionsUpdated['active_referer'] );
|
$this->assertEquals( $options13['active_referer'], $optionsUpdated['referer']['active'] );
|
||||||
$this->assertEquals( $options13['cron_referer'], $optionsUpdated['cron_referer'] );
|
$this->assertEquals( $options13['cron_referer'], $optionsUpdated['referer']['cron'] );
|
||||||
$this->assertEquals( $options13['referer'], $optionsUpdated['referer'] );
|
$this->assertEquals( $options13['referer'], $optionsUpdated['referer']['blacklist'] );
|
||||||
$this->assertEquals( $options13['referer_regexp'], $optionsUpdated['referer_regexp'] );
|
$this->assertEquals( $options13['referer_regexp'], $optionsUpdated['referer']['regexp'] );
|
||||||
|
|
||||||
/* Verify that new attributes are present in config */
|
/* Verify that new attributes are present in config and filled with default values (disabled, empty) */
|
||||||
$this->assertEquals( 0, $optionsUpdated['active_ip'] );
|
$this->assertEquals( 0, $optionsUpdated['target']['active'] );
|
||||||
$this->assertEquals( array(), $optionsUpdated['ip'] );
|
$this->assertEquals( 0, $optionsUpdated['target']['cron'] );
|
||||||
|
$this->assertEquals( 0, $optionsUpdated['target']['regexp'] );
|
||||||
|
$this->assertEquals( array(), $optionsUpdated['target']['blacklist'] );
|
||||||
|
$this->assertEquals( 0, $optionsUpdated['ip']['active'] );
|
||||||
|
$this->assertEquals( array(), $optionsUpdated['ip']['blacklist'] );
|
||||||
|
|
||||||
/* Verify that version number has changed to current release */
|
/* Verify that version number has changed to current release */
|
||||||
$this->assertEquals( StatifyBlacklist::VERSION_MAIN, $optionsUpdated['version'] );
|
$this->assertEquals( StatifyBlacklist::VERSION_MAIN, $optionsUpdated['version'] );
|
||||||
@ -242,13 +272,24 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
public function testIPFilter() {
|
public function testIPFilter() {
|
||||||
/* Prepare Options: 2 blacklisted IPs, disabled */
|
/* Prepare Options: 2 blacklisted IPs, disabled */
|
||||||
StatifyBlacklist::$_options = array(
|
StatifyBlacklist::$_options = array(
|
||||||
'active_referer' => 0,
|
'referer' => array(
|
||||||
'cron_referer' => 0,
|
'active' => 0,
|
||||||
'referer' => array(),
|
'cron' => 0,
|
||||||
'active_ip' => 0,
|
'regexp' => 0,
|
||||||
|
'blacklist' => array()
|
||||||
|
),
|
||||||
|
'target' => array(
|
||||||
|
'active' => 0,
|
||||||
|
'cron' => 0,
|
||||||
|
'regexp' => 0,
|
||||||
|
'blacklist' => array()
|
||||||
|
),
|
||||||
'ip' => array(
|
'ip' => array(
|
||||||
|
'active' => 0,
|
||||||
|
'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
|
||||||
);
|
);
|
||||||
@ -260,7 +301,7 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
$_SERVER['REMOTE_ADDR'] = '192.0.2.123';
|
$_SERVER['REMOTE_ADDR'] = '192.0.2.123';
|
||||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||||
/* Activate filter */
|
/* Activate filter */
|
||||||
StatifyBlacklist::$_options['active_ip'] = 1;
|
StatifyBlacklist::$_options['ip']['active'] = 1;
|
||||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
||||||
/* Try matching v6 address */
|
/* Try matching v6 address */
|
||||||
$_SERVER['REMOTE_ADDR'] = '2001:db8:a0b:12f0::1';
|
$_SERVER['REMOTE_ADDR'] = '2001:db8:a0b:12f0::1';
|
||||||
@ -271,7 +312,7 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
$_SERVER['REMOTE_ADDR'] = '2001:db8:a0b:12f0::2';
|
$_SERVER['REMOTE_ADDR'] = '2001:db8:a0b:12f0::2';
|
||||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||||
/* Subnet matching */
|
/* Subnet matching */
|
||||||
StatifyBlacklist::$_options['ip'] = 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'
|
||||||
);
|
);
|
||||||
@ -301,22 +342,25 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
public function testTargetFilter() {
|
public function testTargetFilter() {
|
||||||
/* Prepare Options: 2 blacklisted domains, disabled */
|
/* Prepare Options: 2 blacklisted domains, disabled */
|
||||||
StatifyBlacklist::$_options = array(
|
StatifyBlacklist::$_options = array(
|
||||||
'active_referer' => 0,
|
|
||||||
'cron_referer' => 0,
|
|
||||||
'referer' => array(
|
'referer' => array(
|
||||||
'example.com' => 0,
|
'active' => 0,
|
||||||
'example.net' => 1
|
'cron' => 0,
|
||||||
|
'regexp' => 0,
|
||||||
|
'blacklist' => array()
|
||||||
),
|
),
|
||||||
'referer_regexp' => 0,
|
|
||||||
'active_target' => 0,
|
|
||||||
'cron_target' => 0,
|
|
||||||
'target' => array(
|
'target' => array(
|
||||||
|
'active' => 0,
|
||||||
|
'cron' => 0,
|
||||||
|
'regexp' => 0,
|
||||||
|
'blacklist' => array(
|
||||||
'/excluded/page/' => 0,
|
'/excluded/page/' => 0,
|
||||||
'/?page_id=3' => 1
|
'/?page_id=3' => 1
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'ip' => array(
|
||||||
|
'active' => 0,
|
||||||
|
'blacklist' => array()
|
||||||
),
|
),
|
||||||
'target_regexp' => 0,
|
|
||||||
'active_ip' => 0,
|
|
||||||
'ip' => array(),
|
|
||||||
'version' => StatifyBlacklist::VERSION_MAIN
|
'version' => StatifyBlacklist::VERSION_MAIN
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -340,7 +384,7 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||||
|
|
||||||
/* Activate filter and run tests again */
|
/* Activate filter and run tests again */
|
||||||
StatifyBlacklist::$_options['active_target'] = 1;
|
StatifyBlacklist::$_options['target']['active'] = 1;
|
||||||
|
|
||||||
unset( $_SERVER['REQUEST_URI'] );
|
unset( $_SERVER['REQUEST_URI'] );
|
||||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||||
@ -364,43 +408,7 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
|||||||
* Test target filter using regular expressions.
|
* Test target filter using regular expressions.
|
||||||
*/
|
*/
|
||||||
public function testTargetRegexFilter() {
|
public function testTargetRegexFilter() {
|
||||||
/* Prepare Options: 2 regular expressions */
|
// TODO
|
||||||
StatifyBlacklist::$_options = array(
|
|
||||||
'active_referer' => 1,
|
|
||||||
'cron_referer' => 0,
|
|
||||||
'referer' => array(
|
|
||||||
'example.[a-z]+' => 0,
|
|
||||||
'test' => 1
|
|
||||||
),
|
|
||||||
'referer_regexp' => 1,
|
|
||||||
'version' => 1.3
|
|
||||||
);
|
|
||||||
|
|
||||||
/* No multisite */
|
|
||||||
StatifyBlacklist::$multisite = false;
|
|
||||||
|
|
||||||
/* No referer */
|
|
||||||
unset( $_SERVER['HTTP_REFERER'] );
|
|
||||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
|
||||||
/* Non-blacklisted referer */
|
|
||||||
$_SERVER['HTTP_REFERER'] = 'http://not.evil';
|
|
||||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
|
||||||
/* Blacklisted referer */
|
|
||||||
$_SERVER['HTTP_REFERER'] = 'http://example.com';
|
|
||||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
|
||||||
/* Blacklisted referer with path */
|
|
||||||
$_SERVER['HTTP_REFERER'] = 'http://foobar.net/test/me';
|
|
||||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
|
||||||
/* Matching both */
|
|
||||||
$_SERVER['HTTP_REFERER'] = 'http://example.net/test/me';
|
|
||||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
|
||||||
/* Mathinc with wrong case */
|
|
||||||
$_SERVER['HTTP_REFERER'] = 'http://eXaMpLe.NeT/tEsT/mE';
|
|
||||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
|
||||||
|
|
||||||
/* Set RegExp filter to case insensitive */
|
|
||||||
StatifyBlacklist::$_options['referer_regexp'] = 2;
|
|
||||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,39 +18,45 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
|||||||
StatifyBlacklist_Admin::cleanup_database();
|
StatifyBlacklist_Admin::cleanup_database();
|
||||||
} else {
|
} else {
|
||||||
/* Extract referer array */
|
/* Extract referer array */
|
||||||
if ( empty( trim( $_POST['statifyblacklist']['referer'] ) ) ) {
|
if ( empty( trim( $_POST['statifyblacklist']['referer']['blacklist'] ) ) ) {
|
||||||
$referer = array();
|
$referer = array();
|
||||||
} else {
|
} else {
|
||||||
$referer = explode( "\r\n", $_POST['statifyblacklist']['referer'] );
|
$referer = explode( "\r\n", $_POST['statifyblacklist']['referer']['blacklist'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extract target array */
|
/* Extract target array */
|
||||||
if ( empty( trim( $_POST['statifyblacklist']['target'] ) ) ) {
|
if ( empty( trim( $_POST['statifyblacklist']['target']['blacklist'] ) ) ) {
|
||||||
$target = array();
|
$target = array();
|
||||||
} else {
|
} else {
|
||||||
$target = explode( "\r\n", str_replace( '\\\\', '\\', $_POST['statifyblacklist']['target'] ) );
|
$target = explode( "\r\n", str_replace( '\\\\', '\\', $_POST['statifyblacklist']['target']['blacklist'] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extract IP array */
|
/* Extract IP array */
|
||||||
if ( empty( trim( $_POST['statifyblacklist']['ip'] ) ) ) {
|
if ( empty( trim( $_POST['statifyblacklist']['ip']['blacklist'] ) ) ) {
|
||||||
$ip = array();
|
$ip = array();
|
||||||
} else {
|
} else {
|
||||||
$ip = explode( "\r\n", $_POST['statifyblacklist']['ip'] );
|
$ip = explode( "\r\n", $_POST['statifyblacklist']['ip']['blacklist'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update options (data will be sanitized) */
|
/* Update options (data will be sanitized) */
|
||||||
$statifyBlacklistUpdateResult = StatifyBlacklist_Admin::update_options(
|
$statifyBlacklistUpdateResult = StatifyBlacklist_Admin::update_options(
|
||||||
array(
|
array(
|
||||||
'active_referer' => (int) @$_POST['statifyblacklist']['active_referer'],
|
'referer' => array(
|
||||||
'cron_referer' => (int) @$_POST['statifyblacklist']['cron_referer'],
|
'active' => (int) @$_POST['statifyblacklist']['referer']['active'],
|
||||||
'referer' => array_flip( $referer ),
|
'cron' => (int) @$_POST['statifyblacklist']['referer']['cron'],
|
||||||
'referer_regexp' => (int) @$_POST['statifyblacklist']['referer_regexp'],
|
'regexp' => (int) @$_POST['statifyblacklist']['referer']['regexp'],
|
||||||
'active_target' => (int) @$_POST['statifyblacklist']['active_target'],
|
'blacklist' => array_flip( $referer )
|
||||||
'cron_target' => (int) @$_POST['statifyblacklist']['cron_target'],
|
),
|
||||||
'target' => array_flip( $target ),
|
'target' => array(
|
||||||
'target_regexp' => (int) @$_POST['statifyblacklist']['target_regexp'],
|
'active' => (int) @$_POST['statifyblacklist']['target']['active'],
|
||||||
'active_ip' => (int) @$_POST['statifyblacklist']['active_ip'],
|
'cron' => (int) @$_POST['statifyblacklist']['target']['cron'],
|
||||||
'ip' => $ip,
|
'regexp' => (int) @$_POST['statifyblacklist']['target']['regexp'],
|
||||||
|
'blacklist' => array_flip( $target )
|
||||||
|
),
|
||||||
|
'ip' => array(
|
||||||
|
'active' => (int) @$_POST['statifyblacklist']['ip']['active'],
|
||||||
|
'blacklist' => $ip
|
||||||
|
),
|
||||||
'version' => StatifyBlacklist::VERSION_MAIN
|
'version' => StatifyBlacklist::VERSION_MAIN
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -96,16 +102,16 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
|||||||
<ul style="list-style: none;">
|
<ul style="list-style: none;">
|
||||||
<li>
|
<li>
|
||||||
<label for="statify-blacklist_active_referer">
|
<label for="statify-blacklist_active_referer">
|
||||||
<input type="checkbox" name="statifyblacklist[active_referer]"
|
<input type="checkbox" name="statifyblacklist[referer][active]"
|
||||||
id="statifyblacklist_active_referer"
|
id="statifyblacklist_active_referer"
|
||||||
value="1" <?php checked( StatifyBlacklist::$_options['active_referer'], 1 ); ?> />
|
value="1" <?php checked( StatifyBlacklist::$_options['referer']['active'], 1 ); ?> />
|
||||||
<?php esc_html_e( 'Activate live fiter', 'statify-blacklist' ); ?>
|
<?php esc_html_e( 'Activate live fiter', 'statify-blacklist' ); ?>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<label for="statify-blacklist_cron_referer">
|
<label for="statify-blacklist_cron_referer">
|
||||||
<input type="checkbox" name="statifyblacklist[cron_referer]" id="statifyblacklist_cron_referer"
|
<input type="checkbox" name="statifyblacklist[referer][cron]" id="statifyblacklist_cron_referer"
|
||||||
value="1" <?php checked( StatifyBlacklist::$_options['cron_referer'], 1 ); ?> />
|
value="1" <?php checked( StatifyBlacklist::$_options['referer']['cron'], 1 ); ?> />
|
||||||
<?php esc_html_e( 'CronJob execution', 'statify-blacklist' ); ?>
|
<?php esc_html_e( 'CronJob execution', 'statify-blacklist' ); ?>
|
||||||
<small>(<?php esc_html_e( 'Clean database periodically in background', 'statify-blacklist' ); ?>
|
<small>(<?php esc_html_e( 'Clean database periodically in background', 'statify-blacklist' ); ?>
|
||||||
)
|
)
|
||||||
@ -116,14 +122,14 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
|||||||
<label for="statify-blacklist_referer_regexp">
|
<label for="statify-blacklist_referer_regexp">
|
||||||
<?php esc_html_e( 'Use regular expressions', 'statify-blacklist' ); ?>:
|
<?php esc_html_e( 'Use regular expressions', 'statify-blacklist' ); ?>:
|
||||||
<br/>
|
<br/>
|
||||||
<select name="statifyblacklist[referer_regexp]" id="statifyblacklist_referer_regexp">
|
<select name="statifyblacklist[referer][regexp]" id="statifyblacklist_referer_regexp">
|
||||||
<option value="0" <?php selected( StatifyBlacklist::$_options['referer_regexp'], 0 ); ?>>
|
<option value="0" <?php selected( StatifyBlacklist::$_options['referer']['regexp'], 0 ); ?>>
|
||||||
<?php esc_html_e( 'Disabled', 'statify-blacklist' ); ?>
|
<?php esc_html_e( 'Disabled', 'statify-blacklist' ); ?>
|
||||||
</option>
|
</option>
|
||||||
<option value="1" <?php selected( StatifyBlacklist::$_options['referer_regexp'], 1 ); ?>>
|
<option value="1" <?php selected( StatifyBlacklist::$_options['referer']['regexp'], 1 ); ?>>
|
||||||
<?php esc_html_e( 'Case-sensitive', 'statify-blacklist' ); ?>
|
<?php esc_html_e( 'Case-sensitive', 'statify-blacklist' ); ?>
|
||||||
</option>
|
</option>
|
||||||
<option value="2" <?php selected( StatifyBlacklist::$_options['referer_regexp'], 2 ); ?>>
|
<option value="2" <?php selected( StatifyBlacklist::$_options['referer']['regexp'], 2 ); ?>>
|
||||||
<?php esc_html_e( 'Case-insensitive', 'statify-blacklist' ); ?>
|
<?php esc_html_e( 'Case-insensitive', 'statify-blacklist' ); ?>
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
@ -136,11 +142,11 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
|||||||
<li>
|
<li>
|
||||||
<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]" 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'] ) ) );
|
print esc_html( implode( "\r\n", array_keys( StatifyBlacklist::$_options['referer']['blacklist'] ) ) );
|
||||||
}
|
}
|
||||||
?></textarea>
|
?></textarea>
|
||||||
<br/>
|
<br/>
|
||||||
@ -158,16 +164,16 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
|||||||
<ul style="list-style: none;">
|
<ul style="list-style: none;">
|
||||||
<li>
|
<li>
|
||||||
<label for="statify-blacklist_active_target">
|
<label for="statify-blacklist_active_target">
|
||||||
<input type="checkbox" name="statifyblacklist[active_target]"
|
<input type="checkbox" name="statifyblacklist[target][active]"
|
||||||
id="statifyblacklist_active_target"
|
id="statifyblacklist_active_target"
|
||||||
value="1" <?php checked( StatifyBlacklist::$_options['active_target'], 1 ); ?> />
|
value="1" <?php checked( StatifyBlacklist::$_options['target']['active'], 1 ); ?> />
|
||||||
<?php esc_html_e( 'Activate live fiter', 'statify-blacklist' ); ?>
|
<?php esc_html_e( 'Activate live fiter', 'statify-blacklist' ); ?>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<label for="statify-blacklist_cron_target">
|
<label for="statify-blacklist_cron_target">
|
||||||
<input type="checkbox" name="statifyblacklist[cron_target]" id="statifyblacklist_cron_target"
|
<input type="checkbox" name="statifyblacklist[target][cron]" id="statifyblacklist_cron_target"
|
||||||
value="1" <?php checked( StatifyBlacklist::$_options['cron_target'], 1 ); ?> />
|
value="1" <?php checked( StatifyBlacklist::$_options['target']['cron'], 1 ); ?> />
|
||||||
<?php esc_html_e( 'CronJob execution', 'statify-blacklist' ); ?>
|
<?php esc_html_e( 'CronJob execution', 'statify-blacklist' ); ?>
|
||||||
<small>(<?php esc_html_e( 'Clean database periodically in background', 'statify-blacklist' ); ?>
|
<small>(<?php esc_html_e( 'Clean database periodically in background', 'statify-blacklist' ); ?>
|
||||||
)
|
)
|
||||||
@ -178,14 +184,14 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
|||||||
<label for="statify-blacklist_target_regexp">
|
<label for="statify-blacklist_target_regexp">
|
||||||
<?php esc_html_e( 'Use regular expressions', 'statify-blacklist' ); ?>:
|
<?php esc_html_e( 'Use regular expressions', 'statify-blacklist' ); ?>:
|
||||||
<br/>
|
<br/>
|
||||||
<select name="statifyblacklist[target_regexp]" id="statifyblacklist_target_regexp">
|
<select name="statifyblacklist[target][regexp]" id="statifyblacklist_target_regexp">
|
||||||
<option value="0" <?php selected( StatifyBlacklist::$_options['target_regexp'], 0 ); ?>>
|
<option value="0" <?php selected( StatifyBlacklist::$_options['target']['regexp'], 0 ); ?>>
|
||||||
<?php esc_html_e( 'Disabled', 'statify-blacklist' ); ?>
|
<?php esc_html_e( 'Disabled', 'statify-blacklist' ); ?>
|
||||||
</option>
|
</option>
|
||||||
<option value="1" <?php selected( StatifyBlacklist::$_options['target_regexp'], 1 ); ?>>
|
<option value="1" <?php selected( StatifyBlacklist::$_options['target']['regexp'], 1 ); ?>>
|
||||||
<?php esc_html_e( 'Case-sensitive', 'statify-blacklist' ); ?>
|
<?php esc_html_e( 'Case-sensitive', 'statify-blacklist' ); ?>
|
||||||
</option>
|
</option>
|
||||||
<option value="2" <?php selected( StatifyBlacklist::$_options['target_regexp'], 2 ); ?>>
|
<option value="2" <?php selected( StatifyBlacklist::$_options['target']['regexp'], 2 ); ?>>
|
||||||
<?php esc_html_e( 'Case-insensitive', 'statify-blacklist' ); ?>
|
<?php esc_html_e( 'Case-insensitive', 'statify-blacklist' ); ?>
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
@ -198,11 +204,11 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
|||||||
<li>
|
<li>
|
||||||
<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]" 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'] ) ) );
|
print esc_html( implode( "\r\n", array_keys( StatifyBlacklist::$_options['target']['blacklist'] ) ) );
|
||||||
}
|
}
|
||||||
?></textarea>
|
?></textarea>
|
||||||
<br/>
|
<br/>
|
||||||
@ -221,8 +227,8 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
|||||||
<ul style="list-style: none;">
|
<ul style="list-style: none;">
|
||||||
<li>
|
<li>
|
||||||
<label for="statify-blacklist_active_ip">
|
<label for="statify-blacklist_active_ip">
|
||||||
<input type="checkbox" name="statifyblacklist[active_ip]" id="statifyblacklist_active_ip"
|
<input type="checkbox" name="statifyblacklist[ip][active]" id="statifyblacklist_active_ip"
|
||||||
value="1" <?php checked( StatifyBlacklist::$_options['active_ip'], 1 ); ?> />
|
value="1" <?php checked( StatifyBlacklist::$_options['ip']['active'], 1 ); ?> />
|
||||||
<?php esc_html_e( 'Activate live fiter', 'statify-blacklist' ); ?>
|
<?php esc_html_e( 'Activate live fiter', 'statify-blacklist' ); ?>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
@ -235,11 +241,11 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
|||||||
<li>
|
<li>
|
||||||
<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]" 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'] );
|
print esc_html( $_POST['statifyblacklist']['ip']['blacklist'] );
|
||||||
} else {
|
} else {
|
||||||
print esc_html( implode( "\r\n", StatifyBlacklist::$_options['ip'] ) );
|
print esc_html( implode( "\r\n", StatifyBlacklist::$_options['ip']['blacklist'] ) );
|
||||||
}
|
}
|
||||||
?></textarea>
|
?></textarea>
|
||||||
<br/>
|
<br/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user