Version Description
- 1-22-2020 =
- Fixed: an issue with logging some backups
- Fixed: an issue with logging Maintenance data
- Fixed: an issue with logging security scan data
- Fixed: an issue with displaying empty data
Download this release
Release Info
Developer | mainwp |
Plugin | MainWP Child Reports |
Version | 2.0.2 |
Comparing to | |
See all releases |
Code changes from version 2.0.1 to 2.0.2
- classes/class-admin.php +43 -0
- classes/class-db.php +74 -0
- classes/class-install.php +1 -0
- classes/class-plugin.php +1 -27
- classes/class-settings.php +20 -0
- connectors/class-connector-mainwp-backups.php +4 -4
- connectors/class-connector-mainwp-maintenance.php +1 -1
- includes/db-updates.php +248 -1
- mainwp-child-reports.php +1 -1
- readme.txt +8 -2
- ui/js/admin.js +9 -0
classes/class-admin.php
CHANGED
@@ -178,6 +178,14 @@ class Admin {
|
|
178 |
)
|
179 |
);
|
180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
// Reset Streams database.
|
182 |
// add_action(
|
183 |
// 'wp_ajax_wp_mainwp_stream_convert', array(
|
@@ -710,6 +718,41 @@ class Admin {
|
|
710 |
return $current_version;
|
711 |
}
|
712 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
713 |
/**
|
714 |
* Handle the reset AJAX request to reset logs.
|
715 |
*
|
178 |
)
|
179 |
);
|
180 |
|
181 |
+
// Reset Streams database.
|
182 |
+
add_action(
|
183 |
+
'wp_ajax_wp_mainwp_stream_try_repair', array(
|
184 |
+
$this,
|
185 |
+
'wp_ajax_try_repair',
|
186 |
+
)
|
187 |
+
);
|
188 |
+
|
189 |
// Reset Streams database.
|
190 |
// add_action(
|
191 |
// 'wp_ajax_wp_mainwp_stream_convert', array(
|
718 |
return $current_version;
|
719 |
}
|
720 |
|
721 |
+
/**
|
722 |
+
* Handle the reset AJAX request to reset logs.
|
723 |
+
*
|
724 |
+
* @return bool
|
725 |
+
*/
|
726 |
+
public function wp_ajax_try_repair() {
|
727 |
+
check_ajax_referer( 'mainwp_stream_nonce_repair', 'wp_mainwp_stream_nonce_try_repair' );
|
728 |
+
|
729 |
+
if ( ! current_user_can( $this->settings_cap ) ) {
|
730 |
+
wp_die(
|
731 |
+
esc_html__( "You don't have sufficient privileges to do this action.", 'mainwp-child-reports' )
|
732 |
+
);
|
733 |
+
}
|
734 |
+
include_once $this->plugin->locations['inc_dir'] . 'db-updates.php';
|
735 |
+
|
736 |
+
// force to repair
|
737 |
+
if ( function_exists( 'wp_mainwp_stream_update_auto_352')) {
|
738 |
+
|
739 |
+
wp_mainwp_stream_update_auto_352( true, true );
|
740 |
+
|
741 |
+
}
|
742 |
+
|
743 |
+
wp_redirect(
|
744 |
+
add_query_arg(
|
745 |
+
array(
|
746 |
+
'page' => is_network_admin() ? $this->network->network_settings_page_slug : $this->settings_page_slug,
|
747 |
+
'message' => 'data_repaired',
|
748 |
+
//'try_repair' => 'yes'
|
749 |
+
),
|
750 |
+
self_admin_url( $this->admin_parent_page )
|
751 |
+
)
|
752 |
+
);
|
753 |
+
exit;
|
754 |
+
}
|
755 |
+
|
756 |
/**
|
757 |
* Handle the reset AJAX request to reset logs.
|
758 |
*
|
classes/class-db.php
CHANGED
@@ -16,6 +16,9 @@ class DB {
|
|
16 |
*/
|
17 |
protected $found_records_count = 0;
|
18 |
|
|
|
|
|
|
|
19 |
/**
|
20 |
* Class constructor.
|
21 |
*
|
@@ -23,6 +26,11 @@ class DB {
|
|
23 |
*/
|
24 |
public function __construct( $driver ) {
|
25 |
$this->driver = $driver;
|
|
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
|
28 |
/**
|
@@ -234,4 +242,70 @@ class DB {
|
|
234 |
public function get_table_names() {
|
235 |
return $this->driver->get_table_names();
|
236 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
}
|
16 |
*/
|
17 |
protected $found_records_count = 0;
|
18 |
|
19 |
+
/** @var $wpdb wpdb */
|
20 |
+
private $wpdb;
|
21 |
+
|
22 |
/**
|
23 |
* Class constructor.
|
24 |
*
|
26 |
*/
|
27 |
public function __construct( $driver ) {
|
28 |
$this->driver = $driver;
|
29 |
+
|
30 |
+
global $wpdb;
|
31 |
+
|
32 |
+
$this->wpdb = &$wpdb;
|
33 |
+
|
34 |
}
|
35 |
|
36 |
/**
|
242 |
public function get_table_names() {
|
243 |
return $this->driver->get_table_names();
|
244 |
}
|
245 |
+
|
246 |
+
// public static function _query( $query, $link ) {
|
247 |
+
// if ( self::use_mysqli() ) {
|
248 |
+
// return mysqli_query( $link, $query );
|
249 |
+
// } else {
|
250 |
+
// return mysql_query( $query, $link );
|
251 |
+
// }
|
252 |
+
// }
|
253 |
+
|
254 |
+
// public static function num_rows( $result ) {
|
255 |
+
// if ( $result === false ) {
|
256 |
+
// return 0;
|
257 |
+
// }
|
258 |
+
//
|
259 |
+
// if ( self::use_mysqli() ) {
|
260 |
+
// return mysqli_num_rows( $result );
|
261 |
+
// } else {
|
262 |
+
// return mysql_num_rows( $result );
|
263 |
+
// }
|
264 |
+
// }
|
265 |
+
|
266 |
+
// public function db_query( $sql ) {
|
267 |
+
// if ( $sql == null ) {
|
268 |
+
// return false;
|
269 |
+
// }
|
270 |
+
//
|
271 |
+
// $result = @self::_query( $sql, $this->wpdb->dbh );
|
272 |
+
//
|
273 |
+
// if ( !$result || ( @self::num_rows( $result ) == 0 ) ) {
|
274 |
+
// return false;
|
275 |
+
// }
|
276 |
+
//
|
277 |
+
// return $result;
|
278 |
+
// }
|
279 |
+
|
280 |
+
|
281 |
+
// public function fetch_object( $result ) {
|
282 |
+
// if ( $result === false ) {
|
283 |
+
// return false;
|
284 |
+
// }
|
285 |
+
//
|
286 |
+
// if ( self::use_mysqli() ) {
|
287 |
+
// return mysqli_fetch_object( $result );
|
288 |
+
// } else {
|
289 |
+
// return mysql_fetch_object( $result );
|
290 |
+
// }
|
291 |
+
// }
|
292 |
+
|
293 |
+
// public function free_result( $result ) {
|
294 |
+
// if ( $result === false ) {
|
295 |
+
// return false;
|
296 |
+
// }
|
297 |
+
//
|
298 |
+
// if ( self::use_mysqli() ) {
|
299 |
+
// return mysqli_free_result( $result );
|
300 |
+
// } else {
|
301 |
+
// return mysql_free_result( $result );
|
302 |
+
// }
|
303 |
+
// }
|
304 |
+
|
305 |
+
// public static function use_mysqli() {
|
306 |
+
// if ( function_exists( 'mysqli_connect' ) ) {
|
307 |
+
// return true;
|
308 |
+
// }
|
309 |
+
// return false;
|
310 |
+
// }
|
311 |
}
|
classes/class-install.php
CHANGED
@@ -382,6 +382,7 @@ class Install {
|
|
382 |
'3.0.2', /* @version 3.0.2 Fix uppercase values in stream table, connector column */
|
383 |
'3.0.8', /* @version 3.0.8 Increase size of user role IDs, user_roll column */
|
384 |
'3.5.0', /* @version 3.5.0 Fix connector values */
|
|
|
385 |
);
|
386 |
|
387 |
/**
|
382 |
'3.0.2', /* @version 3.0.2 Fix uppercase values in stream table, connector column */
|
383 |
'3.0.8', /* @version 3.0.8 Increase size of user role IDs, user_roll column */
|
384 |
'3.5.0', /* @version 3.5.0 Fix connector values */
|
385 |
+
'3.5.2', /* @version 3.5.2 Fix meta data */
|
386 |
);
|
387 |
|
388 |
/**
|
classes/class-plugin.php
CHANGED
@@ -7,7 +7,7 @@ class Plugin {
|
|
7 |
*
|
8 |
* @const string
|
9 |
*/
|
10 |
-
const VERSION = '3.5.
|
11 |
|
12 |
/**
|
13 |
* WP-CLI command
|
@@ -120,8 +120,6 @@ class Plugin {
|
|
120 |
// Load settings and connectors after widgets_init and before the default init priority
|
121 |
add_action( 'init', array( $this, 'init' ), 9 );
|
122 |
|
123 |
-
// Add frontend indicator
|
124 |
-
add_action( 'wp_head', array( $this, 'frontend_indicator' ) );
|
125 |
|
126 |
// Change DB driver after plugin loaded if any add-ons want to replace
|
127 |
add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ), 20 );
|
@@ -192,30 +190,6 @@ class Plugin {
|
|
192 |
|
193 |
}
|
194 |
|
195 |
-
/**
|
196 |
-
* Displays an HTML comment in the frontend head to indicate that Stream is activated,
|
197 |
-
* and which version of Stream is currently in use.
|
198 |
-
*
|
199 |
-
* @action wp_head
|
200 |
-
*
|
201 |
-
* @return string|void An HTML comment, or nothing if the value is filtered out.
|
202 |
-
*/
|
203 |
-
public function frontend_indicator() {
|
204 |
-
$comment = sprintf( 'Reports WordPress user activity plugin v%s', esc_html( $this->get_version() ) ); // Localization not needed
|
205 |
-
|
206 |
-
/**
|
207 |
-
* Filter allows the HTML output of the frontend indicator comment
|
208 |
-
* to be altered or removed, if desired.
|
209 |
-
*
|
210 |
-
* @return string The content of the HTML comment
|
211 |
-
*/
|
212 |
-
$comment = apply_filters( 'wp_mainwp_stream_frontend_indicator', $comment );
|
213 |
-
|
214 |
-
if ( ! empty( $comment ) ) {
|
215 |
-
echo sprintf( "<!-- %s -->\n", esc_html( $comment ) ); // xss ok
|
216 |
-
}
|
217 |
-
}
|
218 |
-
|
219 |
/**
|
220 |
* Version of plugin_dir_url() which works for plugins installed in the plugins directory,
|
221 |
* and for plugins bundled with themes.
|
7 |
*
|
8 |
* @const string
|
9 |
*/
|
10 |
+
const VERSION = '3.5.5';
|
11 |
|
12 |
/**
|
13 |
* WP-CLI command
|
120 |
// Load settings and connectors after widgets_init and before the default init priority
|
121 |
add_action( 'init', array( $this, 'init' ), 9 );
|
122 |
|
|
|
|
|
123 |
|
124 |
// Change DB driver after plugin loaded if any add-ons want to replace
|
125 |
add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ), 20 );
|
190 |
|
191 |
}
|
192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
/**
|
194 |
* Version of plugin_dir_url() which works for plugins installed in the plugins directory,
|
195 |
* and for plugins bundled with themes.
|
classes/class-settings.php
CHANGED
@@ -376,6 +376,26 @@ class Settings {
|
|
376 |
),
|
377 |
),
|
378 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
379 |
|
380 |
// If Akismet is active, allow Admins to opt-in to Akismet tracking
|
381 |
if ( class_exists( 'Akismet' ) ) {
|
376 |
),
|
377 |
),
|
378 |
);
|
379 |
+
|
380 |
+
//if ( isset( $_GET['try_repair'] ) && $_GET['try_repair'] == 'yes') {
|
381 |
+
$repair_data = array(
|
382 |
+
'name' => 'try_repair',
|
383 |
+
'title' => esc_html__( 'Repair Data', 'mainwp-child-reports' ),
|
384 |
+
'type' => 'link',
|
385 |
+
'href' => add_query_arg(
|
386 |
+
array(
|
387 |
+
'action' => 'wp_mainwp_stream_try_repair',
|
388 |
+
'wp_mainwp_stream_nonce_try_repair' => wp_create_nonce( 'mainwp_stream_nonce_repair' )
|
389 |
+
),
|
390 |
+
admin_url( 'admin-ajax.php' )
|
391 |
+
),
|
392 |
+
'class' => 'warning',
|
393 |
+
'desc' => '',
|
394 |
+
'default' => 0,
|
395 |
+
'sticky' => 'bottom',
|
396 |
+
);
|
397 |
+
array_push( $fields['advanced']['fields'], $repair_data );
|
398 |
+
//}
|
399 |
|
400 |
// If Akismet is active, allow Admins to opt-in to Akismet tracking
|
401 |
if ( class_exists( 'Akismet' ) ) {
|
connectors/class-connector-mainwp-backups.php
CHANGED
@@ -40,11 +40,11 @@ class Connector_MainWP_Backups extends Connector {
|
|
40 |
public function get_action_labels() {
|
41 |
return array(
|
42 |
'mainwp_backup' => esc_html__( 'MainWP Backup', 'mainwp-child-reports' ),
|
43 |
-
'
|
44 |
-
'
|
45 |
-
'
|
46 |
'updraftplus_backup' => __( 'Updraftplus Backup', 'mainwp-child-reports' ),
|
47 |
-
'
|
48 |
);
|
49 |
}
|
50 |
|
40 |
public function get_action_labels() {
|
41 |
return array(
|
42 |
'mainwp_backup' => esc_html__( 'MainWP Backup', 'mainwp-child-reports' ),
|
43 |
+
'backupbuddy_backup' => esc_html__( 'BackupBuddy Backup', 'mainwp-child-reports' ),
|
44 |
+
'backupwordpress_backup' => esc_html__( 'BackupWordPress Backup', 'mainwp-child-reports' ),
|
45 |
+
'backwpup_backup' => __( 'BackWPup Backup', 'mainwp-child-reports' ),
|
46 |
'updraftplus_backup' => __( 'Updraftplus Backup', 'mainwp-child-reports' ),
|
47 |
+
'wptimecapsule_backup' => __( 'WP Time Capsule Backup', 'mainwp-child-reports' ),
|
48 |
);
|
49 |
}
|
50 |
|
connectors/class-connector-mainwp-maintenance.php
CHANGED
@@ -16,7 +16,7 @@ class Connector_MainWP_Maintenance extends Connector {
|
|
16 |
|
17 |
public function get_action_labels() {
|
18 |
return array(
|
19 |
-
'
|
20 |
);
|
21 |
}
|
22 |
|
16 |
|
17 |
public function get_action_labels() {
|
18 |
return array(
|
19 |
+
'maintenance' => __( 'Maintenance', 'default' ),
|
20 |
);
|
21 |
}
|
22 |
|
includes/db-updates.php
CHANGED
@@ -1,4 +1,246 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
/**
|
3 |
* Version 3.5.0
|
4 |
*
|
@@ -149,6 +391,11 @@ function wp_mainwp_stream_update_auto_300( $db_version, $current_version ) {
|
|
149 |
$context = $wpdb->get_row(
|
150 |
$wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}mainwp_stream_context_tmp WHERE record_id = %s LIMIT 1", $entry->ID )
|
151 |
);
|
|
|
|
|
|
|
|
|
|
|
152 |
$new_entry = array(
|
153 |
'site_id' => $entry->site_id,
|
154 |
'blog_id' => $entry->blog_id,
|
@@ -180,7 +427,7 @@ function wp_mainwp_stream_update_auto_300( $db_version, $current_version ) {
|
|
180 |
}
|
181 |
|
182 |
$starting_row += $rows_per_round;
|
183 |
-
|
184 |
$stream_entries = $wpdb->get_results( "SELECT * FROM {$wpdb->base_prefix}mainwp_stream_tmp WHERE 1 = 1 " . $where . $orderby . $wpdb->prepare( "LIMIT %d, %d", $starting_row, $rows_per_round ) );
|
185 |
}
|
186 |
//$wpdb->query( "DROP TABLE {$wpdb->base_prefix}mainwp_stream_tmp, {$wpdb->base_prefix}mainwp_stream_context_tmp" );
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Version 3.5.2
|
4 |
+
*
|
5 |
+
* To fix meta data.
|
6 |
+
*
|
7 |
+
* @param string $db_version
|
8 |
+
* @param string $current_version
|
9 |
+
*
|
10 |
+
* @return string
|
11 |
+
*/
|
12 |
+
function wp_mainwp_stream_update_auto_352( $db_version, $current_version ) {
|
13 |
+
global $wpdb;
|
14 |
+
|
15 |
+
$first_correct = $wpdb->get_results(
|
16 |
+
" SELECT sm.record_id, sm.meta_id
|
17 |
+
FROM {$wpdb->prefix}mainwp_stream as s
|
18 |
+
LEFT JOIN {$wpdb->prefix}mainwp_stream_meta as sm
|
19 |
+
ON s.ID = sm.record_id
|
20 |
+
where sm.meta_key = 'user_meta'
|
21 |
+
ORDER BY s.ID ASC LIMIT 1 "
|
22 |
+
);
|
23 |
+
|
24 |
+
$first_correct_record_id = 0;
|
25 |
+
if ( $first_correct ) {
|
26 |
+
$first_correct = current( $first_correct );
|
27 |
+
$first_correct_record_id = $first_correct->record_id;
|
28 |
+
}
|
29 |
+
|
30 |
+
if ( empty( $first_correct_record_id ) ) {
|
31 |
+
return; // this is correct conversion
|
32 |
+
}
|
33 |
+
|
34 |
+
// to get first correct meta id
|
35 |
+
$sql = $wpdb->prepare(
|
36 |
+
"SELECT * FROM {$wpdb->base_prefix}mainwp_stream_meta
|
37 |
+
WHERE record_id = %d ORDER BY meta_id ASC LIMIT 1",
|
38 |
+
$first_correct_record_id
|
39 |
+
);
|
40 |
+
|
41 |
+
$first_correct_meta_id = 0;
|
42 |
+
|
43 |
+
$correct_meta = $wpdb->get_results( $sql );
|
44 |
+
if ( $correct_meta ) {
|
45 |
+
$correct_meta = current( $correct_meta );
|
46 |
+
$first_correct_meta_id = $correct_meta->meta_id;
|
47 |
+
}
|
48 |
+
|
49 |
+
//$date = new DateTime( '2019-8-31 23:59:59', $timezone = new DateTimeZone( 'UTC' ) ); // fixed value, around 3 months ago
|
50 |
+
//$where = " AND ( `created` > STR_TO_DATE(" . $wpdb->prepare('%s', $date->format( 'Y-m-d H:i:s' )) . ", '%Y-%m-%d %H:%i:%s') ) ";
|
51 |
+
$where = " AND ID < " . intval( $first_correct_record_id );
|
52 |
+
$orderby = ' ORDER BY ID DESC '; // DESC importance
|
53 |
+
|
54 |
+
$starting_row = 0;
|
55 |
+
$rows_per_round = 5000;
|
56 |
+
|
57 |
+
$stream_entries = $wpdb->get_results( "SELECT * FROM {$wpdb->base_prefix}mainwp_stream WHERE 1 = 1 " .
|
58 |
+
$where . $orderby .
|
59 |
+
$wpdb->prepare( " LIMIT %d, %d", $starting_row, $rows_per_round ) );
|
60 |
+
$stop = false;
|
61 |
+
|
62 |
+
|
63 |
+
$fix_what = array(
|
64 |
+
'plugin_updated',
|
65 |
+
'plugin_activated_deactivated',
|
66 |
+
'theme_updated',
|
67 |
+
'theme_activated_deactivated',
|
68 |
+
'wordpress_update',
|
69 |
+
'post_page',
|
70 |
+
'mainwp_backups',
|
71 |
+
'wordfence_scan',
|
72 |
+
'sucuri_scan'
|
73 |
+
);
|
74 |
+
|
75 |
+
|
76 |
+
while ( ! empty( $stream_entries ) ) {
|
77 |
+
|
78 |
+
foreach( $fix_what as $fix_value ) {
|
79 |
+
$correct_meta_id = $first_correct_meta_id;
|
80 |
+
|
81 |
+
foreach ( $stream_entries as $entry ) {
|
82 |
+
|
83 |
+
if ( $fix_value == 'plugin_updated' ) {
|
84 |
+
if ( $entry->connector != 'installer' || $entry->context != 'plugins' || $entry->action !== 'updated') {
|
85 |
+
continue; // next entry
|
86 |
+
}
|
87 |
+
} else if ( $fix_value == 'plugin_activated_deactivated' ) {
|
88 |
+
if ( $entry->connector != 'installer' || $entry->context != 'plugins' || ( $entry->action !== 'activated' && $entry->action !== 'deactivated' ) ) {
|
89 |
+
continue; // next entry
|
90 |
+
}
|
91 |
+
} else if ( $fix_value == 'theme_updated' ) {
|
92 |
+
if ( $entry->connector != 'installer' || $entry->context !== 'themes' || $entry->action !== 'updated' ) {
|
93 |
+
continue; // next entry
|
94 |
+
}
|
95 |
+
} else if ( $fix_value == 'theme_activated_deactivated' ) {
|
96 |
+
if ( $entry->connector != 'installer' || $entry->context != 'themes' || ( $entry->action !== 'activated' && $entry->action !== 'deactivated' ) ) {
|
97 |
+
continue; // next entry
|
98 |
+
}
|
99 |
+
} else if ($fix_value == 'wordpress_update') {
|
100 |
+
if ( $entry->connector != 'installer' || $entry->context !== 'wordpress' || $entry->action != 'updated' ) {
|
101 |
+
continue; // next entry
|
102 |
+
}
|
103 |
+
} else if ($fix_value == 'post_page') {
|
104 |
+
if ( $entry->connector != 'posts' || ( $entry->context !== 'post' && $entry->context !== 'page' ) ) {
|
105 |
+
continue; // next entry
|
106 |
+
}
|
107 |
+
} else if ($fix_value == 'mainwp_backups') {
|
108 |
+
if ( $entry->connector != 'mainwp_backups' || $entry->context != 'backups' ) {
|
109 |
+
continue; // next entry
|
110 |
+
}
|
111 |
+
} else if ($fix_value == 'wordfence_scan') {
|
112 |
+
if ( $entry->context !== 'wordfence_scan' ) {
|
113 |
+
continue; // next entry
|
114 |
+
}
|
115 |
+
} else if ($fix_value == 'sucuri_scan') {
|
116 |
+
if ( $entry->context !== 'sucuri_scan' ) {
|
117 |
+
continue; // next entry
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
$fix_next_type = false;
|
122 |
+
|
123 |
+
// loop meta records
|
124 |
+
while ( true ) {
|
125 |
+
|
126 |
+
$fix_next_entry = false;
|
127 |
+
|
128 |
+
$sql = $wpdb->prepare(
|
129 |
+
"SELECT * FROM {$wpdb->base_prefix}mainwp_stream_meta
|
130 |
+
WHERE meta_id < %d ORDER BY meta_id DESC LIMIT 20", // get 20 meta items to fix
|
131 |
+
$correct_meta_id
|
132 |
+
);
|
133 |
+
|
134 |
+
$incorrect_metas = $wpdb->get_results( $sql );
|
135 |
+
|
136 |
+
if ( empty( $incorrect_metas ) ) {
|
137 |
+
|
138 |
+
// valid meta, fix next type
|
139 |
+
$fix_next_type = true;
|
140 |
+
break;
|
141 |
+
}
|
142 |
+
|
143 |
+
foreach( $incorrect_metas as $incorr) {
|
144 |
+
// guess to fix record_id
|
145 |
+
$update_it = false;
|
146 |
+
if ( $fix_value == 'plugin_updated' ) {
|
147 |
+
if ( $incorr->meta_key == 'type' && $incorr->meta_value === 'plugin') {
|
148 |
+
$update_it = true;
|
149 |
+
}
|
150 |
+
} else if ( $fix_value == 'plugin_activated_deactivated' ) {
|
151 |
+
if ( $incorr->meta_key == 'type' && $incorr->meta_value === 'plugin') {
|
152 |
+
$update_it = true;
|
153 |
+
}
|
154 |
+
} else if ( $fix_value == 'theme_updated' ) {
|
155 |
+
if ( $incorr->meta_key == 'type' && $incorr->meta_value === 'theme' ) {
|
156 |
+
$update_it = true;
|
157 |
+
}
|
158 |
+
} else if ( $fix_value == 'theme_activated_deactivated' ) {
|
159 |
+
if ( $incorr->meta_key == 'type' && $incorr->meta_value === 'theme') {
|
160 |
+
$update_it = true;
|
161 |
+
}
|
162 |
+
} else if ($fix_value == 'wordpress_update') {
|
163 |
+
if ( $incorr->meta_key == 'auto_updated' ) {
|
164 |
+
$update_it = true;
|
165 |
+
}
|
166 |
+
} else if ($fix_value == 'post_page') {
|
167 |
+
if ( $incorr->meta_key == 'singular_name' && ( $incorr->meta_value == 'page' || $incorr->meta_value == 'post' ) ) {
|
168 |
+
$update_it = true;
|
169 |
+
}
|
170 |
+
} else if ($fix_value == 'mainwp_backups') {
|
171 |
+
if ( $incorr->meta_key == 'backup_time' ) {
|
172 |
+
$update_it = true;
|
173 |
+
}
|
174 |
+
} else if ($fix_value == 'wordfence_scan') {
|
175 |
+
if ( $incorr->meta_key == 'result' && strpos( $incorr->meta_value, 'SUM_FINAL' ) !== false ) {
|
176 |
+
$update_it = true;
|
177 |
+
}
|
178 |
+
} else if ($fix_value == 'sucuri_scan') {
|
179 |
+
if ( $incorr->meta_key == 'scan_status' ) {
|
180 |
+
$update_it = true;
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
// it's ok
|
185 |
+
$correct_meta_id -= 1;
|
186 |
+
|
187 |
+
if ( $update_it ) {
|
188 |
+
|
189 |
+
$sql = $wpdb->prepare(
|
190 |
+
"SELECT * FROM {$wpdb->base_prefix}mainwp_stream_meta
|
191 |
+
WHERE record_id = %d AND meta_id < %d ",
|
192 |
+
$incorr->record_id, $incorr->meta_id + 10 // + 10 to sure it does not update fixed meta
|
193 |
+
);
|
194 |
+
|
195 |
+
$fix_metas = $wpdb->get_results( $sql );
|
196 |
+
|
197 |
+
if ( $fix_metas ) {
|
198 |
+
// verify one more time
|
199 |
+
if ( $fix_value == 'plugin_activated_deactivated' || $fix_value == 'theme_activated_deactivated' ) {
|
200 |
+
if ( count($fix_metas) > 3 )
|
201 |
+
continue;
|
202 |
+
}
|
203 |
+
|
204 |
+
if ( count($fix_metas) > 20 ) //not valid
|
205 |
+
continue;
|
206 |
+
|
207 |
+
$fixed_ids = array();
|
208 |
+
foreach( $fix_metas as $item ) {
|
209 |
+
$fixed_ids[] = $item->meta_id;
|
210 |
+
}
|
211 |
+
|
212 |
+
if ($fixed_ids) {
|
213 |
+
$wpdb->query( 'UPDATE ' . $wpdb->base_prefix . 'mainwp_stream_meta' . ' SET record_id=' . $entry->ID . ' WHERE meta_id IN (' . implode( ",", $fixed_ids) . ')');
|
214 |
+
}
|
215 |
+
}
|
216 |
+
|
217 |
+
// found the correct meta so go to fix next entry
|
218 |
+
$fix_next_entry = true;
|
219 |
+
break;
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
$wpdb->flush();
|
224 |
+
|
225 |
+
if ( $fix_next_entry )
|
226 |
+
break;
|
227 |
+
|
228 |
+
}
|
229 |
+
|
230 |
+
if ( $fix_next_type ) {
|
231 |
+
break; // to fix next type
|
232 |
+
}
|
233 |
+
}
|
234 |
+
}
|
235 |
+
|
236 |
+
$starting_row += $rows_per_round;
|
237 |
+
if ( !$stop )
|
238 |
+
$stream_entries = $wpdb->get_results( "SELECT * FROM {$wpdb->base_prefix}mainwp_stream WHERE 1 = 1 " . $where . $orderby . $wpdb->prepare( "LIMIT %d, %d", $starting_row, $rows_per_round ) );
|
239 |
+
}
|
240 |
+
|
241 |
+
return $current_version;
|
242 |
+
}
|
243 |
+
|
244 |
/**
|
245 |
* Version 3.5.0
|
246 |
*
|
391 |
$context = $wpdb->get_row(
|
392 |
$wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}mainwp_stream_context_tmp WHERE record_id = %s LIMIT 1", $entry->ID )
|
393 |
);
|
394 |
+
|
395 |
+
if (empty($context)) {
|
396 |
+
continue;
|
397 |
+
}
|
398 |
+
|
399 |
$new_entry = array(
|
400 |
'site_id' => $entry->site_id,
|
401 |
'blog_id' => $entry->blog_id,
|
427 |
}
|
428 |
|
429 |
$starting_row += $rows_per_round;
|
430 |
+
|
431 |
$stream_entries = $wpdb->get_results( "SELECT * FROM {$wpdb->base_prefix}mainwp_stream_tmp WHERE 1 = 1 " . $where . $orderby . $wpdb->prepare( "LIMIT %d, %d", $starting_row, $rows_per_round ) );
|
432 |
}
|
433 |
//$wpdb->query( "DROP TABLE {$wpdb->base_prefix}mainwp_stream_tmp, {$wpdb->base_prefix}mainwp_stream_context_tmp" );
|
mainwp-child-reports.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: The MainWP Child Report plugin tracks Child sites for the MainWP Client Reports Extension. The plugin is only useful if you are using MainWP and the Client Reports Extension.
|
6 |
* Author: MainWP
|
7 |
* Author URI: https://mainwp.com
|
8 |
-
* Version: 2.0.
|
9 |
*/
|
10 |
|
11 |
/*
|
5 |
* Description: The MainWP Child Report plugin tracks Child sites for the MainWP Client Reports Extension. The plugin is only useful if you are using MainWP and the Client Reports Extension.
|
6 |
* Author: MainWP
|
7 |
* Author URI: https://mainwp.com
|
8 |
+
* Version: 2.0.2
|
9 |
*/
|
10 |
|
11 |
/*
|
readme.txt
CHANGED
@@ -5,9 +5,9 @@ Author: mainwp
|
|
5 |
Author URI: https://mainwp.com
|
6 |
Plugin URI: https://mainwp.com
|
7 |
Requires at least: 3.6
|
8 |
-
Tested up to: 5.3.
|
9 |
Requires PHP: 5.6
|
10 |
-
Stable tag: 2.0.
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
@@ -36,6 +36,12 @@ Credit to the [Stream Plugin](https://wordpress.org/plugins/stream/) which the M
|
|
36 |
|
37 |
== Changelog ==
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
= 2.0.1 - 12-13-2019 =
|
40 |
* Fixed: data Child Reports conversion problem
|
41 |
|
5 |
Author URI: https://mainwp.com
|
6 |
Plugin URI: https://mainwp.com
|
7 |
Requires at least: 3.6
|
8 |
+
Tested up to: 5.3.2
|
9 |
Requires PHP: 5.6
|
10 |
+
Stable tag: 2.0.2
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
36 |
|
37 |
== Changelog ==
|
38 |
|
39 |
+
= 2.0.2 - 1-22-2020 =
|
40 |
+
* Fixed: an issue with logging some backups
|
41 |
+
* Fixed: an issue with logging Maintenance data
|
42 |
+
* Fixed: an issue with logging security scan data
|
43 |
+
* Fixed: an issue with displaying empty data
|
44 |
+
|
45 |
= 2.0.1 - 12-13-2019 =
|
46 |
* Fixed: data Child Reports conversion problem
|
47 |
|
ui/js/admin.js
CHANGED
@@ -155,6 +155,15 @@ jQuery(
|
|
155 |
}
|
156 |
}
|
157 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
$( 'body' ).on(
|
160 |
'click', '#wp_mainwp_stream_advanced_reset_site_settings, #wp_mainwp_stream_network_advanced_reset_site_settings', function( e ) {
|
155 |
}
|
156 |
}
|
157 |
);
|
158 |
+
|
159 |
+
// Confirmation on some important actions
|
160 |
+
$( 'body' ).on(
|
161 |
+
'click', '#wp_mainwp_stream_advanced_try_repair', function( e ) {
|
162 |
+
if ( ! window.confirm( 'Are you sure?' ) ) {
|
163 |
+
e.preventDefault();
|
164 |
+
}
|
165 |
+
}
|
166 |
+
);
|
167 |
|
168 |
$( 'body' ).on(
|
169 |
'click', '#wp_mainwp_stream_advanced_reset_site_settings, #wp_mainwp_stream_network_advanced_reset_site_settings', function( e ) {
|