WP Security Audit Log - Version 0.6.2

Version Description

(2014-02-03) = * Bug Fix * Fixed a number of database issues introduced with the WordPress Multisite Support * Fixed issue with supporting pre WordPress 3.0 multisite installations (support tickets here and here)

Download this release

Release Info

Developer WPWhiteSecurity
Plugin Icon 128x128 WP Security Audit Log
Version 0.6.2
Comparing to
See all releases

Code changes from version 0.6.1 to 0.6.2

inc/WPPHLogger.php CHANGED
@@ -8,7 +8,7 @@ function wpphLog($message, $data=null, $function=null,$line=null){ WPPHLogger::w
8
  */
9
  class WPPHLogger
10
  {
11
- private static $_debugLoggingEnabled = false;
12
 
13
  private static $_fileName = 'debug.log';
14
 
8
  */
9
  class WPPHLogger
10
  {
11
+ private static $_debugLoggingEnabled = true;
12
 
13
  private static $_fileName = 'debug.log';
14
 
inc/WPPHNetwork.php CHANGED
@@ -84,9 +84,23 @@ class WPPHNetwork
84
  wpphLog("Plugin successfully uninstalled.");
85
  }
86
 
87
- static function networkActivate($networkwide=false)
88
  {
89
  global $wpdb;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  if (WPPH::isMultisite()) {
91
  // check if it is a network activation - if so, run the activation function for each blog id
92
  if ($networkwide)
@@ -103,7 +117,7 @@ class WPPHNetwork
103
  }
104
  }
105
  update_option('WPPH_NETWORK_INSTALL',0);
106
- self::_activate($wpdb->blogid);
107
  }
108
 
109
  static function networkDeactivate($networkwide=false){
@@ -154,29 +168,21 @@ class WPPHNetwork
154
  if(empty($results)){
155
  return $out;
156
  }
157
- $basePrefix = WPPHDatabase::getDefaultPrefix();
158
  foreach($results as $entry){
159
- $blogID = $entry['blog_id'];
160
- if($blogID == 1){
161
- $blogName = $wpdb->get_var("SELECT option_value FROM ".$basePrefix."options WHERE option_name = 'blogname';");
162
- }
163
- else { $blogName = $wpdb->get_var("SELECT option_value FROM ".$basePrefix.$blogID."_options WHERE option_name = 'blogname';"); }
164
- $out[$blogID] = $blogName;
165
  }
166
  return $out;
167
  }
168
 
169
  static function getBlogName($blogID)
170
  {
171
- global $wpdb;
172
- $basePrefix = WPPHDatabase::getDefaultPrefix();
173
- if(empty($blogID) || (int)$blogID == 1){
174
- $table = $wpdb->prefix . 'options';
175
- }
176
- else { $table = $basePrefix.$blogID.'_options'; }
177
- return $wpdb->get_var("SELECT option_value FROM {$table} WHERE option_name = 'blogname';");
178
  }
179
 
 
 
 
 
180
  /**
181
  * Retrive the value of a global option
182
  * @param $optionName
@@ -187,24 +193,7 @@ class WPPHNetwork
187
  */
188
  static function getGlobalOption($optionName, $unserialize = false, $isConstant = false, $default = null)
189
  {
190
- global $wpdb;
191
- $table = WPPHDatabase::getDefaultPrefix();
192
- if($isConstant){
193
- $optionName = "'{$optionName}'";
194
- }
195
- $query = "SELECT option_value FROM {$table}options WHERE option_name = {$optionName}";
196
- wpphLog(__METHOD__.'() -> Query executed: '.$query);
197
- $result = $wpdb->get_var($query);
198
- if(is_null($result)){
199
- return $default;
200
- }
201
- if($unserialize)
202
- {
203
- if(! is_array($result)){
204
- $result = unserialize($result);
205
- }
206
- }
207
- return $result;
208
  }
209
 
210
  /**
@@ -217,32 +206,27 @@ class WPPHNetwork
217
  */
218
  static function updateGlobalOption($optionName, $optionValue, $serialize = false, $isConstant = false)
219
  {
220
- global $wpdb;
221
- $table = WPPHDatabase::getDefaultPrefix().'options';
222
- if($isConstant){ $optionName = "'{$optionName}'"; }
223
- if($serialize){ $optionValue = serialize($optionValue); }
224
- $query = "UPDATE $table SET option_value = '$optionValue' WHERE option_name = $optionName";
225
- wpphLog(__METHOD__.'() -> Executing query: '.$query);
226
- $result = $wpdb->query($query);
227
- return (is_null($result) ? false : true);
228
  }
229
 
230
  static function addGlobalOption($optionName, $optionValue, $serialize = false, $isConstant = false)
231
  {
232
- $r = self::getGlobalOption($optionName, $serialize, $isConstant, null);
233
- if(! is_null($r)){
234
- return true;
235
- }
236
- global $wpdb;
237
- $table = WPPHDatabase::getDefaultPrefix().'options';
238
- if($isConstant || is_string($optionName)){ $optionName = "'{$optionName}'"; }
239
- if($serialize || is_array($optionValue) || is_object($optionValue)){ $optionValue = "'".serialize($optionValue)."'"; }
240
- else {
241
- if(is_string($optionValue)){ $optionValue = "'".$optionValue."'"; }
242
- }
243
- $query = "INSERT INTO $table (option_name, option_value) VALUES ($optionName, $optionValue)";
244
- wpphLog(__METHOD__.'() -> Executing query: '.$query);
245
- $result = $wpdb->query($query);
246
- return (is_null($result) ? false : true);
247
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
  }
84
  wpphLog("Plugin successfully uninstalled.");
85
  }
86
 
87
+ static function networkActivate(/*$networkwide=false*/)
88
  {
89
  global $wpdb;
90
+ if (WPPH::isMultisite()) {
91
+ $old_blog = $wpdb->blogid;
92
+ $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
93
+ foreach ($blogids as $blog_id) {
94
+ switch_to_blog($blog_id);
95
+ self::_activate($blog_id);
96
+ }
97
+ switch_to_blog($old_blog);
98
+ update_option('WPPH_NETWORK_INSTALL',1);
99
+ }else{
100
+ update_option('WPPH_NETWORK_INSTALL',0);
101
+ self::_activate($wpdb->blogid);
102
+ }
103
+ /*global $wpdb;
104
  if (WPPH::isMultisite()) {
105
  // check if it is a network activation - if so, run the activation function for each blog id
106
  if ($networkwide)
117
  }
118
  }
119
  update_option('WPPH_NETWORK_INSTALL',0);
120
+ self::_activate($wpdb->blogid);*/
121
  }
122
 
123
  static function networkDeactivate($networkwide=false){
168
  if(empty($results)){
169
  return $out;
170
  }
 
171
  foreach($results as $entry){
172
+ $out[$entry['blog_id']] = self::getBlogName($entry['blog_id']);
 
 
 
 
 
173
  }
174
  return $out;
175
  }
176
 
177
  static function getBlogName($blogID)
178
  {
179
+ return self::callOptionFunc('get', $blogID, 'blogname');
 
 
 
 
 
 
180
  }
181
 
182
+ static function getGlobalBlogId(){
183
+ return 1; // this is the norm
184
+ }
185
+
186
  /**
187
  * Retrive the value of a global option
188
  * @param $optionName
193
  */
194
  static function getGlobalOption($optionName, $unserialize = false, $isConstant = false, $default = null)
195
  {
196
+ return self::callOptionFunc('get', self::getGlobalBlogId(), $optionName, $default);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  }
198
 
199
  /**
206
  */
207
  static function updateGlobalOption($optionName, $optionValue, $serialize = false, $isConstant = false)
208
  {
209
+ return self::callOptionFunc('update', self::getGlobalBlogId(), $optionName, $optionValue);
 
 
 
 
 
 
 
210
  }
211
 
212
  static function addGlobalOption($optionName, $optionValue, $serialize = false, $isConstant = false)
213
  {
214
+ return self::callOptionFunc('add', self::getGlobalBlogId(), $optionName, $optionValue);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  }
216
+
217
+ /**
218
+ * Gets, adds or updates a wordpress option.
219
+ * @param string $action An action: get, add, update
220
+ * @param integer $blogid Blog id, used on multisite only.
221
+ * @param mixed Rest of the function arguments.
222
+ * @return type
223
+ */
224
+ static function callOptionFunc($action, $blogid){
225
+ $args = func_get_args();
226
+ $action = array_shift($args);
227
+ $musite = function_exists($action.'_blog_option');
228
+ $fnname = $musite ? "{$action}_blog_option" : "{$action}_option";
229
+ if(!$musite)$blogid = array_shift($args); // remove blogid when not multisite
230
+ return call_user_func_array($fnname, $args);
231
+ }
232
  }
readme.txt CHANGED
@@ -4,8 +4,8 @@ License: GPLv3
4
  License URI: http://www.gnu.org/licenses/gpl.html
5
  Tags: wordpress security plugin, wordpress security audit log, audit log, event log wordpress, wordpress user tracking, wordpress activity log, wordpress audit, security event log, audit trail, security audit trail, wordpress security alerts, wordpress monitor, wordpress security monitor, wordpress admin, wordpress admin monitoring, wordpress security monitor, analytics, activity, admin, multisite, wordpress multisite
6
  Requires at least: 3.0
7
- Tested up to: 3.8
8
- Stable tag: 0.6.1
9
 
10
  Identify WordPress issues before they become a security problem by keeping an audit log of users and all of the under the hood WordPress activity.
11
 
@@ -96,6 +96,11 @@ Yes, WP Security Audit Log works on WordPress Multisite networkds. For more info
96
 
97
  == Changelog ==
98
 
 
 
 
 
 
99
  = 0.6.1 (2014-01-16) =
100
  * Bug Fix
101
  * Fixed errors in debug code (used for when debugging is enabled in plugin)
4
  License URI: http://www.gnu.org/licenses/gpl.html
5
  Tags: wordpress security plugin, wordpress security audit log, audit log, event log wordpress, wordpress user tracking, wordpress activity log, wordpress audit, security event log, audit trail, security audit trail, wordpress security alerts, wordpress monitor, wordpress security monitor, wordpress admin, wordpress admin monitoring, wordpress security monitor, analytics, activity, admin, multisite, wordpress multisite
6
  Requires at least: 3.0
7
+ Tested up to: 3.8.1
8
+ Stable tag: 0.6.2
9
 
10
  Identify WordPress issues before they become a security problem by keeping an audit log of users and all of the under the hood WordPress activity.
11
 
96
 
97
  == Changelog ==
98
 
99
+ = 0.6.2 (2014-02-03) =
100
+ * Bug Fix
101
+ * Fixed a number of database issues introduced with the WordPress Multisite Support
102
+ * Fixed issue with supporting pre WordPress 3.0 multisite installations (support tickets [here](http://wordpress.org/support/topic/errors-on-06-fresh-installation?replies=9) and [here](http://wordpress.org/support/topic/upgrade-to-06-infinite-do-loop-in-refresh-alerts-list?replies=3))
103
+
104
  = 0.6.1 (2014-01-16) =
105
  * Bug Fix
106
  * Fixed errors in debug code (used for when debugging is enabled in plugin)
wp-security-audit-log.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WP Security Audit Log
4
  Plugin URI: http://www.wpwhitesecurity.com/wordpress-security-plugins/wp-security-audit-log/
5
  Description: Identify WordPress security issues before they become a problem and keep track of everything happening on your WordPress, including WordPress users activity. Similar to Windows Event Log and Linux Syslog, WP Security Audit Log will generate a security alert for everything that happens on your WordPress blog or website. Use the Audit Log Viewer included in the plugin to see all the security alerts.
6
  Author: WP White Security
7
- Version: 0.6.1
8
  Author URI: http://www.wpwhitesecurity.com/
9
  License: GPL2
10
  Text Domain: wp-security-audit-log
@@ -26,7 +26,7 @@ Domain Path: /languages
26
  along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
  */
29
- define('WPPH_PLUGIN_VERSION','0.6.1');
30
  define('WPPH_PLUGIN_PREFIX', 'wpph_');
31
  define('WPPH_PLUGIN_NAME', 'WP Security Audit Log');
32
  define('WPPH_PLUGIN_URL', trailingslashit(plugins_url('', __FILE__)));
4
  Plugin URI: http://www.wpwhitesecurity.com/wordpress-security-plugins/wp-security-audit-log/
5
  Description: Identify WordPress security issues before they become a problem and keep track of everything happening on your WordPress, including WordPress users activity. Similar to Windows Event Log and Linux Syslog, WP Security Audit Log will generate a security alert for everything that happens on your WordPress blog or website. Use the Audit Log Viewer included in the plugin to see all the security alerts.
6
  Author: WP White Security
7
+ Version: 0.6.2
8
  Author URI: http://www.wpwhitesecurity.com/
9
  License: GPL2
10
  Text Domain: wp-security-audit-log
26
  along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
  */
29
+ define('WPPH_PLUGIN_VERSION','0.6.2');
30
  define('WPPH_PLUGIN_PREFIX', 'wpph_');
31
  define('WPPH_PLUGIN_NAME', 'WP Security Audit Log');
32
  define('WPPH_PLUGIN_URL', trailingslashit(plugins_url('', __FILE__)));