diff --git a/README.md b/README.md index 0f2586d..802c9e0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ * Contributors: Stefan Kalscheuer * Requires at least: 3.9 * Tested up to: 4.5.3 -* Stable tag: 1.1.0 +* Stable tag: 1.1.1 * License: GPLv3 or later * License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -12,31 +12,39 @@ A blacklist extension for the famous [Statify](http://statify.de) Wordpress plug This plugin adds customizable blacklist to Statify to allow blocking of referer spam or internal interactions. ### Current Features ## -####Referer Blacklist +#### Referer Blacklist #### Add a list of domains (for simplicity onl second-level, e.g. _example.com_ which blocks _everything.example.com_). -#### CleanUp Database +#### CleanUp Database #### Filters can be applied to data stored in database after modifying filter rules or for one-time clean-up. - -### Compatibility ### +#### Compatibility #### This plugin requires Statify to be installed. The extension has been tested with Statify 1.4.2 The plugin is capable of handling multisite installations. ### Credits ### * Author: Stefan Kalscheuer +* Special Thanks to [pluginkollektiv](http://pluginkollektiv.org/) for maintaining _Statify_ ## Installation ## * If you don’t know how to install a plugin for WordPress, [here’s how](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins). +* Make sure _Statify_ plugin is installed and active +* Goto _Settings_ -> _Statify Blacklist_ to configure the plugin ### Requirements ### * PHP 5.2.4 * WordPress 3.9 -* Statify plugin installed and activated (tested with 1.4.2) +* Statify plugin installed and activated (tested up to 1.4.3) -## Changelog -#### 1.1.0 / 15.08.2016 +## Screenshots ## +1. Statify Blacklist settings page + +## Changelog ## +### 1.1.1 / 16.08.2016 ### +* Some security fixes + +### 1.1.0 / 15.08.2016 ### * One-time execution on database -#### 1.0.0 / 14.08.2016 +### 1.0.0 / 14.08.2016 ### * First release \ No newline at end of file diff --git a/inc/statifyblacklist.class.php b/inc/statifyblacklist.class.php index 39c3a54..b7b859d 100644 --- a/inc/statifyblacklist.class.php +++ b/inc/statifyblacklist.class.php @@ -79,15 +79,9 @@ class StatifyBlacklist * Update options * * @since 1.0.0 + * @changed 1.1.1 */ - public static function update_options($options = null) { - if (isset($options)) { - 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); - } - + public static function update_options() { self::$_options = wp_parse_args( get_option('statify-blacklist'), array( diff --git a/inc/statifyblacklist_admin.class.php b/inc/statifyblacklist_admin.class.php index 0e16331..aea2e09 100644 --- a/inc/statifyblacklist_admin.class.php +++ b/inc/statifyblacklist_admin.class.php @@ -1,5 +1,8 @@ query( $wpdb->prepare("DELETE FROM `$wpdb->statify` WHERE referrer REGEXP %s", $refererRegexp) ); - } - /* Optimize DB */ - $wpdb->query("OPTIMIZE TABLE `$wpdb->statify`"); + /* Optimize DB */ + $wpdb->query("OPTIMIZE TABLE `$wpdb->statify`"); + } + } + + + /** + * Sanitize URLs and remove empty results + * @param $urls array given array of URLs + * @return array sanitized array + * + * @since 1.1.1 + */ + private static function sanitizeURLs($urls) { + return array_filter( + array_map( + function($r) { + return preg_replace('/[^\da-z\.-]/i', '', filter_var($r, FILTER_SANITIZE_URL)); + }, + $urls + ) + ); } } \ No newline at end of file diff --git a/readme.txt b/readme.txt deleted file mode 100644 index a0fdfa0..0000000 --- a/readme.txt +++ /dev/null @@ -1,35 +0,0 @@ -=== Statify Blacklist === -Contributors: Stefan Kalscheuer -Tags: stats, extension, blacklist, filter -Requires at least: 3.9 -Tested up to: 4.5.3 -Stable tag: trunk -License: GPLv3 or later -License URI: https://www.gnu.org/licenses/gpl-3.0.html - -Extension for the Statify statistics plugin. Provides a customizable referer blacklist. - -== Description == -A blacklist extension for the famous [Statify](http://statify.de) Wordpress plugin. - -This plugin adds customizable blacklist to Statify to allow blocking of referer spam or internal interactions. - -== Requirements == -* PHP 5.2.4 -* WordPress 3.9 -* Statify plugin (tested with 1.4.2) - -== Installation == -1. Upload the plugin files to the `/wp-content/plugins/statify-blacklist` directory, or install the plugin through the WordPress plugins screen directly. -1. Activate the plugin through the 'Plugins' screen in WordPress -1. Use the Settings->Plugin Name screen to configure the plugin -1. (Make your instructions match the desired user flow for activating and installing your plugin. Include any steps that might be needed for explanatory purposes) - - -== Changelog == - -= 1.1.0 / 15.08.2016 = -* One-time execution on database - -= 1.0.0 / 14.08.2016 = -* First release diff --git a/statifyblacklist.php b/statifyblacklist.php index af81033..65e4639 100644 --- a/statifyblacklist.php +++ b/statifyblacklist.php @@ -4,11 +4,11 @@ Plugin Name: Statify Blacklist Description: Extension for the statify plugin to add a customizable blacklists. Text Domain: statify-blacklist Domain Path: /lang -Author: stklcode +Author: Stefan Kalscheuer Author URI: https://stklcode.de Plugin URI: https://wordpress.org/plugins/statify-blacklist License: GPLv3 or later -Version: 1.1.0 +Version: 1.1.1 */ /* Quit */ diff --git a/views/settings_page.php b/views/settings_page.php index d86f407..6a19a16 100644 --- a/views/settings_page.php +++ b/views/settings_page.php @@ -1,17 +1,40 @@ (int)@$_POST['statifyblacklist']['active_referer'], - 'referer' => explode("\r\n", $_POST['statifyblacklist']['referer']) + 'referer' => $referer ) ); + + /* Generate messages */ + if ($statifyBlacklistUpdateResult !== false) { + $statifyBlacklistPostWarning = 'Some URLs are invalid and have been sanitized. Settings have not been saved yet.'; + } else { + $statifyBlacklistPostSuccess = 'Settings updated successfully.'; + } } } @@ -19,7 +42,23 @@ if ( !empty($_POST['statifyblacklist']) ) {

-

'; esc_html_e('Statify plugin is not active.', 'statify-blacklist'); print '

'; } ?> +

'; + esc_html_e('Statify plugin is not active.', 'statify-blacklist'); + print '

'; + } + if (isset($statifyBlacklistPostWarning)) { + print '

'; + esc_html_e($statifyBlacklistPostWarning); + print '

'; + } + if (isset($statifyBlacklistPostSuccess)) { + print '

'; + esc_html_e($statifyBlacklistPostSuccess); + print '

'; + } + ?>