#8 Target filter implemented
This commit is contained in:
parent
0cf4548d45
commit
152a800a4a
@ -15,6 +15,9 @@ This plugin adds customizable blacklist to Statify to allow blocking of referer
|
||||
#### Referer Blacklist ####
|
||||
Add a list of domains (for simplicity only second-level, e.g. _example.com_ which blocks _everything.example.com_).
|
||||
|
||||
#### Target Blacklist ####
|
||||
Add a list of target pages (e.g. _/test/page/_, _/?page_id=123_) that will be excluded from tracking.
|
||||
|
||||
#### IP Blacklist ####
|
||||
Add a list of IP addresses or subnets (e.g. _192.0.2.123_, _198.51.100.0/24_, _2001:db8:a0b:12f0::/64_).
|
||||
|
||||
@ -74,6 +77,7 @@ Because of this, an IP blacklist can only be applied while processing the reques
|
||||
|
||||
### 1.4.0 / work in progress ###
|
||||
* IP blacklist implemented (#7)
|
||||
* Target page blacklist implemented (#8)
|
||||
|
||||
### 1.3.1 / 09.12.2016 ###
|
||||
* Continue filtering if no filter applies (#6)
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 66 KiB |
@ -85,7 +85,7 @@ class StatifyBlacklist {
|
||||
|
||||
/* CronJob to clean up database */
|
||||
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
|
||||
if ( self::$_options['cron_referer'] == 1 ) {
|
||||
if ( self::$_options['cron_referer'] == 1 || self::$_options['cron_target'] == 1 ) {
|
||||
add_action( 'statify_cleanup', array( 'StatifyBlacklist_Admin', 'cleanup_database' ) );
|
||||
}
|
||||
}
|
||||
@ -119,6 +119,10 @@ class StatifyBlacklist {
|
||||
'cron_referer' => 0,
|
||||
'referer' => array(),
|
||||
'referer_regexp' => 0,
|
||||
'active_target' => 0,
|
||||
'cron_target' => 0,
|
||||
'target' => array(),
|
||||
'target_regexp' => 0,
|
||||
'active_ip' => 0,
|
||||
'ip' => array(),
|
||||
'version' => self::VERSION_MAIN
|
||||
@ -131,7 +135,7 @@ class StatifyBlacklist {
|
||||
* @return TRUE if referer matches blacklist.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @changed 1.4.0
|
||||
* @since 1.4.0 Target and IP blacklist
|
||||
*/
|
||||
public static function apply_blacklist_filter() {
|
||||
/* Referer blacklist */
|
||||
@ -163,6 +167,33 @@ class StatifyBlacklist {
|
||||
}
|
||||
}
|
||||
|
||||
/* Target blacklist (since 1.4.0) */
|
||||
if ( isset( self::$_options['active_target'] ) && self::$_options['active_target'] != 0 ) {
|
||||
/* Regular Expression filtering since 1.3.0 */
|
||||
if ( isset( self::$_options['target_regexp'] ) && self::$_options['target_regexp'] > 0 ) {
|
||||
/* Get full referer string */
|
||||
$target = ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '/' );
|
||||
/* Merge given regular expressions into one */
|
||||
$regexp = '/' . implode( "|", array_keys( self::$_options['target'] ) ) . '/';
|
||||
if ( self::$_options['target_regexp'] == 2 ) {
|
||||
$regexp .= 'i';
|
||||
}
|
||||
|
||||
/* Check blacklist (return NULL to continue filtering) */
|
||||
|
||||
return ( preg_match( $regexp, $target ) === 1 ) ? true : null;
|
||||
} else {
|
||||
/* Extract target page */
|
||||
$target = ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '/' );
|
||||
/* Get blacklist */
|
||||
$blacklist = self::$_options['target'];
|
||||
/* Check blacklist */
|
||||
if ( isset( $blacklist[ $target ] ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* IP blacklist (since 1.4.0) */
|
||||
if ( isset ( self::$_options['active_ip'] ) && self::$_options['active_ip'] != 0 ) {
|
||||
if ( ( $ip = self::getIP() ) !== false ) {
|
||||
|
@ -131,8 +131,16 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
||||
die( __( 'Are you sure you want to do this?' ) );
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
|
||||
$cleanRef = ( self::$_options['cron_referer'] == 1 );
|
||||
$cleanTrg = ( self::$_options['cron_target'] == 1 );
|
||||
} else {
|
||||
$cleanRef = true;
|
||||
$cleanTrg = true;
|
||||
}
|
||||
|
||||
|
||||
if ( $cleanRef ) {
|
||||
if ( isset( self::$_options['referer_regexp'] ) && self::$_options['referer_regexp'] > 0 ) {
|
||||
/* Merge given regular expressions into one */
|
||||
$refererRegexp = implode( "|", array_keys( self::$_options['referer'] ) );
|
||||
@ -143,14 +151,37 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
||||
/* Build filter regexp */
|
||||
$refererRegexp = str_replace( '.', '\.', implode( '|', array_flip( $referer ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $cleanTrg ) {
|
||||
if ( isset( self::$_options['target_regexp'] ) && self::$_options['target_regexp'] > 0 ) {
|
||||
/* Merge given regular expressions into one */
|
||||
$targetRegexp = implode( "|", array_keys( self::$_options['target'] ) );
|
||||
} else {
|
||||
/* Build filter regexp */
|
||||
$targetRegexp = str_replace( '.', '\.', implode( '|', array_flip( self::$_options['target'] ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( ! empty( $refererRegexp ) || ! empty( $targetRegexp ) ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( ! empty( $refererRegexp ) ) {
|
||||
/* Execute filter on database */
|
||||
if ( ! empty( $refererRegexp ) ) {
|
||||
$wpdb->query(
|
||||
$wpdb->prepare( "DELETE FROM `$wpdb->statify` WHERE "
|
||||
. ( ( self::$_options['referer_regexp'] == 1 ) ? " BINARY " : "" )
|
||||
. "referrer REGEXP %s", $refererRegexp )
|
||||
);
|
||||
}
|
||||
if ( ! empty( $targetRegexp ) ) {
|
||||
$wpdb->query(
|
||||
$wpdb->prepare( "DELETE FROM `$wpdb->statify` WHERE "
|
||||
. ( ( self::$_options['target_regexp'] == 1 ) ? " BINARY " : "" )
|
||||
. "target REGEXP %s", $targetRegexp )
|
||||
);
|
||||
}
|
||||
|
||||
/* Optimize DB */
|
||||
$wpdb->query( "OPTIMIZE TABLE `$wpdb->statify`" );
|
||||
@ -195,10 +226,10 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
||||
*/
|
||||
private static function sanitizeIPs( $ips ) {
|
||||
return array_filter( $ips, function ( $ip ) {
|
||||
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])'.
|
||||
'(\/([0-9]|[1-2][0-9]|3[0-2]))?$/', $ip) ||
|
||||
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-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?$/', $ip);
|
||||
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])' .
|
||||
'(\/([0-9]|[1-2][0-9]|3[0-2]))?$/', $ip ) ||
|
||||
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-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?$/', $ip );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
||||
$optionsUpdated = get_option( 'statify-blacklist' );
|
||||
|
||||
/* Verify size against default options (no junk left) */
|
||||
$this->assertEquals( 7, sizeof( $optionsUpdated ) );
|
||||
$this->assertEquals( 11, sizeof( $optionsUpdated ) );
|
||||
|
||||
/* Verify that original attributes are unchanged */
|
||||
$this->assertEquals( $options13['active_referer'], $optionsUpdated['active_referer'] );
|
||||
@ -294,6 +294,114 @@ class StatifyBlacklistTest extends PHPUnit_Framework_TestCase {
|
||||
$_SERVER['HTTP_X_REAL_IP'] = '2001:db8:a0b:12f0:0::1';
|
||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test simple target filter.
|
||||
*/
|
||||
public function testTargetFilter() {
|
||||
/* Prepare Options: 2 blacklisted domains, disabled */
|
||||
StatifyBlacklist::$_options = array(
|
||||
'active_referer' => 0,
|
||||
'cron_referer' => 0,
|
||||
'referer' => array(
|
||||
'example.com' => 0,
|
||||
'example.net' => 1
|
||||
),
|
||||
'referer_regexp' => 0,
|
||||
'active_target' => 0,
|
||||
'cron_target' => 0,
|
||||
'target' => array(
|
||||
'/excluded/page/' => 0,
|
||||
'/?page_id=3' => 1
|
||||
),
|
||||
'target_regexp' => 0,
|
||||
'active_ip' => 0,
|
||||
'ip' => array(),
|
||||
'version' => StatifyBlacklist::VERSION_MAIN
|
||||
);
|
||||
|
||||
/* No multisite */
|
||||
StatifyBlacklist::$multisite = false;
|
||||
|
||||
/* Empty target */
|
||||
unset( $_SERVER['REQUEST_URI'] );
|
||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||
/* Non-blacklisted targets */
|
||||
$_SERVER['REQUEST_URI'] = '';
|
||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||
$_SERVER['REQUEST_URI'] = '/';
|
||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||
$_SERVER['REQUEST_URI'] = '/?page_id=1';
|
||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||
/* Blacklisted referer */
|
||||
$_SERVER['REQUEST_URI'] = '/excluded/page/';
|
||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||
$_SERVER['REQUEST_URI'] = '/?page_id=3';
|
||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||
|
||||
/* Activate filter and run tests again */
|
||||
StatifyBlacklist::$_options['active_target'] = 1;
|
||||
|
||||
unset( $_SERVER['REQUEST_URI'] );
|
||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||
|
||||
$_SERVER['REQUEST_URI'] = '';
|
||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||
$_SERVER['REQUEST_URI'] = '/';
|
||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||
$_SERVER['REQUEST_URI'] = '/?page_id=1';
|
||||
$this->assertNull( StatifyBlacklist::apply_blacklist_filter() );
|
||||
|
||||
$_SERVER['REQUEST_URI'] = '/excluded/page/';
|
||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
||||
$_SERVER['REQUEST_URI'] = '/?page_id=3';
|
||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
||||
$_SERVER['REQUEST_URI'] = '/?page_id=3';
|
||||
$this->assertTrue( StatifyBlacklist::apply_blacklist_filter() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test target filter using regular expressions.
|
||||
*/
|
||||
public function testTargetRegexFilter() {
|
||||
/* Prepare Options: 2 regular expressions */
|
||||
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() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -346,3 +454,7 @@ function update_option( $option, $value, $autoload = null ) {
|
||||
global $mock_options;
|
||||
$mock_options[ $option ] = $value;
|
||||
}
|
||||
|
||||
function wp_unslash ( $value ) {
|
||||
return is_string( $value ) ? stripslashes( $value ) : $value;
|
||||
}
|
@ -24,6 +24,13 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
||||
$referer = explode( "\r\n", $_POST['statifyblacklist']['referer'] );
|
||||
}
|
||||
|
||||
/* Extract target array */
|
||||
if ( empty( trim( $_POST['statifyblacklist']['target'] ) ) ) {
|
||||
$target = array();
|
||||
} else {
|
||||
$target = explode( "\r\n", str_replace( '\\\\', '\\', $_POST['statifyblacklist']['target'] ) );
|
||||
}
|
||||
|
||||
/* Extract IP array */
|
||||
if ( empty( trim( $_POST['statifyblacklist']['ip'] ) ) ) {
|
||||
$ip = array();
|
||||
@ -38,6 +45,10 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
||||
'cron_referer' => (int) @$_POST['statifyblacklist']['cron_referer'],
|
||||
'referer' => array_flip( $referer ),
|
||||
'referer_regexp' => (int) @$_POST['statifyblacklist']['referer_regexp'],
|
||||
'active_target' => (int) @$_POST['statifyblacklist']['active_target'],
|
||||
'cron_target' => (int) @$_POST['statifyblacklist']['cron_target'],
|
||||
'target' => array_flip( $target ),
|
||||
'target_regexp' => (int) @$_POST['statifyblacklist']['target_regexp'],
|
||||
'active_ip' => (int) @$_POST['statifyblacklist']['active_ip'],
|
||||
'ip' => $ip,
|
||||
'version' => StatifyBlacklist::VERSION_MAIN
|
||||
@ -52,7 +63,7 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
||||
$statifyBlacklistPostWarning = sprintf( __( 'Some IPs are invalid : %s', 'statify-blacklist' ), implode( ', ', $statifyBlacklistUpdateResult['ip'] ) );
|
||||
}
|
||||
} else {
|
||||
$statifyBlacklistPostSuccess = __('Settings updated successfully.', 'statify-blacklist');
|
||||
$statifyBlacklistPostSuccess = __( 'Settings updated successfully.', 'statify-blacklist' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -63,19 +74,19 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
||||
<?php
|
||||
if ( is_plugin_inactive( 'statify/statify.php' ) ) {
|
||||
print '<div class="notice notice-warning"><p>';
|
||||
esc_html( 'Statify plugin is not active.');
|
||||
esc_html( 'Statify plugin is not active.' );
|
||||
print '</p></div>';
|
||||
}
|
||||
if ( isset( $statifyBlacklistPostWarning ) ) {
|
||||
print '<div class="notice notice-warning"><p>' .
|
||||
esc_html( $statifyBlacklistPostWarning );
|
||||
print '<br/>';
|
||||
esc_html_e('Settings have not been saved yet.', 'statify-blacklist');
|
||||
esc_html_e( 'Settings have not been saved yet.', 'statify-blacklist' );
|
||||
print '</p></div>';
|
||||
}
|
||||
if ( isset( $statifyBlacklistPostSuccess ) ) {
|
||||
print '<div class="notice notice-success"><p>'.
|
||||
esc_html( $statifyBlacklistPostSuccess ).
|
||||
print '<div class="notice notice-success"><p>' .
|
||||
esc_html( $statifyBlacklistPostSuccess ) .
|
||||
'</p></div>';
|
||||
}
|
||||
?>
|
||||
@ -85,7 +96,8 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
||||
<ul style="list-style: none;">
|
||||
<li>
|
||||
<label for="statify-blacklist_active_referer">
|
||||
<input type="checkbox" name="statifyblacklist[active_referer]" id="statifyblacklist_active_referer"
|
||||
<input type="checkbox" name="statifyblacklist[active_referer]"
|
||||
id="statifyblacklist_active_referer"
|
||||
value="1" <?php checked( StatifyBlacklist::$_options['active_referer'], 1 ); ?> />
|
||||
<?php esc_html_e( 'Activate live fiter', 'statify-blacklist' ); ?>
|
||||
</label>
|
||||
@ -95,13 +107,15 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
||||
<input type="checkbox" name="statifyblacklist[cron_referer]" id="statifyblacklist_cron_referer"
|
||||
value="1" <?php checked( StatifyBlacklist::$_options['cron_referer'], 1 ); ?> />
|
||||
<?php esc_html_e( 'CronJob execution', 'statify-blacklist' ); ?>
|
||||
<small>(<?php esc_html_e( 'Clean database periodically in background', 'statify-blacklist' ); ?>)</small>
|
||||
<small>(<?php esc_html_e( 'Clean database periodically in background', 'statify-blacklist' ); ?>
|
||||
)
|
||||
</small>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label for="statify-blacklist_referer_regexp">
|
||||
<?php esc_html_e( 'Use regular expressions', 'statify-blacklist' ); ?>:
|
||||
<br />
|
||||
<br/>
|
||||
<select name="statifyblacklist[referer_regexp]" id="statifyblacklist_referer_regexp">
|
||||
<option value="0" <?php selected( StatifyBlacklist::$_options['referer_regexp'], 0 ); ?>>
|
||||
<?php esc_html_e( 'Disabled', 'statify-blacklist' ); ?>
|
||||
@ -113,7 +127,10 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
||||
<?php esc_html_e( 'Case-insensitive', 'statify-blacklist' ); ?>
|
||||
</option>
|
||||
</select>
|
||||
<small>(<?php esc_html_e( 'Performance slower than standard domain filter. Recommended for cron or manual execition only.', 'statify-blacklist' ); ?>)</small>
|
||||
<small>
|
||||
(<?php esc_html_e( 'Performance slower than standard filter. Recommended for cron or manual execition only.', 'statify-blacklist' ); ?>
|
||||
)
|
||||
</small>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
@ -126,7 +143,7 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
||||
print esc_html( implode( "\r\n", array_keys( StatifyBlacklist::$_options['referer'] ) ) );
|
||||
}
|
||||
?></textarea>
|
||||
<br />
|
||||
<br/>
|
||||
<small>
|
||||
(<?php esc_html_e( 'Add one domain (without subdomains) each line, e.g. example.com', 'statify-blacklist' ); ?>
|
||||
)
|
||||
@ -136,6 +153,69 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
||||
</ul>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<h2><?php esc_html_e( 'Target blacklist', 'statify-blacklist' ); ?></h2>
|
||||
<ul style="list-style: none;">
|
||||
<li>
|
||||
<label for="statify-blacklist_active_target">
|
||||
<input type="checkbox" name="statifyblacklist[active_target]"
|
||||
id="statifyblacklist_active_target"
|
||||
value="1" <?php checked( StatifyBlacklist::$_options['active_target'], 1 ); ?> />
|
||||
<?php esc_html_e( 'Activate live fiter', 'statify-blacklist' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label for="statify-blacklist_cron_target">
|
||||
<input type="checkbox" name="statifyblacklist[cron_target]" id="statifyblacklist_cron_target"
|
||||
value="1" <?php checked( StatifyBlacklist::$_options['cron_target'], 1 ); ?> />
|
||||
<?php esc_html_e( 'CronJob execution', 'statify-blacklist' ); ?>
|
||||
<small>(<?php esc_html_e( 'Clean database periodically in background', 'statify-blacklist' ); ?>
|
||||
)
|
||||
</small>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label for="statify-blacklist_target_regexp">
|
||||
<?php esc_html_e( 'Use regular expressions', 'statify-blacklist' ); ?>:
|
||||
<br/>
|
||||
<select name="statifyblacklist[target_regexp]" id="statifyblacklist_target_regexp">
|
||||
<option value="0" <?php selected( StatifyBlacklist::$_options['target_regexp'], 0 ); ?>>
|
||||
<?php esc_html_e( 'Disabled', 'statify-blacklist' ); ?>
|
||||
</option>
|
||||
<option value="1" <?php selected( StatifyBlacklist::$_options['target_regexp'], 1 ); ?>>
|
||||
<?php esc_html_e( 'Case-sensitive', 'statify-blacklist' ); ?>
|
||||
</option>
|
||||
<option value="2" <?php selected( StatifyBlacklist::$_options['target_regexp'], 2 ); ?>>
|
||||
<?php esc_html_e( 'Case-insensitive', 'statify-blacklist' ); ?>
|
||||
</option>
|
||||
</select>
|
||||
<small>
|
||||
(<?php esc_html_e( 'Performance slower than standard filter. Recommended for cron or manual execition only.', 'statify-blacklist' ); ?>
|
||||
)
|
||||
</small>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label for="statify-blacklist_target">
|
||||
<?php esc_html_e( 'Target blacklist:', 'statify-blacklist' ); ?><br/>
|
||||
<textarea cols="40" rows="5" name="statifyblacklist[target]" id="statify-blacklist_target"><?php
|
||||
if ( isset( $statifyBlacklistUpdateResult['target'] ) ) {
|
||||
print esc_html( implode( "\r\n", array_keys( $statifyBlacklistUpdateResult['target'] ) ) );
|
||||
} else {
|
||||
print esc_html( implode( "\r\n", array_keys( StatifyBlacklist::$_options['target'] ) ) );
|
||||
}
|
||||
?></textarea>
|
||||
<br/>
|
||||
<small>
|
||||
(<?php esc_html_e( 'Add one target URL each line, e.g.', 'statify-blacklist' );
|
||||
print ' /, /test/page/, /?page_id=123' ?>
|
||||
)
|
||||
</small>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<h2><?php esc_html_e( 'IP blacklist', 'statify-blacklist' ); ?></h2>
|
||||
<ul style="list-style: none;">
|
||||
@ -147,7 +227,10 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<small>(<?php esc_html_e( 'Cron execution is not possible for IP filter, because IP addresses are not stored.', 'statify-blacklist' ); ?>)</small>
|
||||
<small>
|
||||
(<?php esc_html_e( 'Cron execution is not possible for IP filter, because IP addresses are not stored.', 'statify-blacklist' ); ?>
|
||||
)
|
||||
</small>
|
||||
</li>
|
||||
<li>
|
||||
<label for="statify-blacklist_ip">
|
||||
@ -174,12 +257,12 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
|
||||
|
||||
<p class="submit">
|
||||
<input class="button-primary" type="submit" name="submit" value="<?php _e( 'Save Changes' ) ?>">
|
||||
<hr />
|
||||
<hr/>
|
||||
<input class="button-secondary" type="submit" name="cleanUp"
|
||||
value="<?php esc_html_e( 'CleanUp Database', 'statify-blacklist' ) ?>"
|
||||
onclick="return confirm('Do you really want to apply filters to database? This cannot be undone.');">
|
||||
<br />
|
||||
<small><?php esc_html_e( 'Applies referer filter (even if disabled) to data stored in database. This cannot be undone!', 'statify-blacklist' ); ?></small>
|
||||
<br/>
|
||||
<small><?php esc_html_e( 'Applies referer and target filter (even if disabled) to data stored in database.', 'statify-blacklist' ); ?> <b><?php esc_html_e( 'This cannot be undone!', 'statify-blacklist' ); ?></b></small>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user