InfiniteWP Client - Version 1.6.0

Version Description

  • June 27th 2016 =
  • Feature: Activity log for updates and backups to be used in new version of client reporting beta will be saved and retrieved from the WP Admin instead of the IWP Admin Panel, provided the client reporting addon is active.
  • Improvement: The code in the backup_status_table has been refactored.
  • Fix: Failed backups with date 01 Jan 1970 were not cleared from the database.
Download this release

Release Info

Developer infinitewp
Plugin Icon 128x128 InfiniteWP Client
Version 1.6.0
Comparing to
See all releases

Code changes from version 1.5.1.3 to 1.6.0

activities_log.class.php ADDED
@@ -0,0 +1,713 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /************************************************************
3
+ * This plugin was modified by Revmakx *
4
+ * Copyright (c) 2012 Revmakx *
5
+ * www.revmakx.com *
6
+ * *
7
+ ************************************************************/
8
+ /*************************************************************
9
+ *
10
+ * activities_log.class.php
11
+ *
12
+ * Utility functions
13
+ *
14
+ *
15
+ * Copyright (c) 2011 Prelovac Media
16
+ * www.prelovac.com
17
+ **************************************************************/
18
+ if(basename($_SERVER['SCRIPT_FILENAME']) == "activities_log.class.php"):
19
+ exit;
20
+ endif;
21
+ class IWP_MMB_Activities_log {
22
+
23
+ function __construct() {
24
+ if(function_exists('add_action')) {
25
+ add_action('core_upgrade_preamble',array( &$this, 'iwp_mmb_core_upgrade_preamble'));
26
+ add_action('_core_updated_successfully',array( &$this, 'iwp_mmb_core_updated_successfully'), 1, 1); // It will call after "wordpress core updates via wp-admin or wp-cron" completed. It is available from wordpress 3.3.
27
+ add_action('upgrader_process_complete', array( &$this, 'iwp_mmb_upgrader_process_complete'), 1, 2); // It is available from wordpress 3.7. It is for plugins upgrade, themes upgrade, plugins install and themes install.
28
+ add_action('automatic_updates_complete', array( &$this, 'iwp_mmb_automatic_updates_complete'), 10, 1); // It is available since wordpress 3.8. It is for automatic translation updates.
29
+ add_action('updated_option', array( &$this, 'iwp_mmb_check_and_update_all_plugins_themes_history'), 10, 3);
30
+ }
31
+
32
+ if(function_exists('add_filter')) {
33
+
34
+ add_filter('update_theme_complete_actions', array( &$this, 'iwp_mmb_update_theme_complete_actions'), 1, 2); // It is available from wordpress 2.7 to 3.6.
35
+ add_filter('update_bulk_theme_complete_actions', array( &$this, 'iwp_mmb_update_bulk_theme_complete_actions'), 1, 2); // It is available from wordpress 2.7 to 3.6.
36
+
37
+ add_filter('async_update_translation', array( &$this, 'iwp_mmb_async_update_translation'), 1, 2); // why we added this hook? Because, whenever we tried to update the core, plugins and themes, translation updates automatically trigger. To prevent it, we added this line. It is available since wordpress 4.0.
38
+
39
+ add_filter('update_translations_complete_actions', array( &$this, 'iwp_mmb_update_translations_complete_actions'), 10, 1); // It is available since wordpress 3.7.
40
+ add_filter('upgrader_post_install', array( &$this, 'iwp_mmb_upgrader_post_install'), 10, 3);
41
+ // We couldn't get the error for failure translations updates (in wordpress 3.7 DE) when individual plugin updates happened. But the above line solved it.
42
+ // Activities log for automatic translation updates wont work in wordpress 3.7. Because, wordpress 3.7 hasnt given any option to achieve it. But the above line solved it.
43
+ }
44
+ }
45
+
46
+ // whenever iwp client plugin updated also, it will call the following function for creating options like iwp_client_all_plugins_history, iwp_client_all_themes_history and iwp_client_wp_version_old.
47
+ function iwp_mmb_save_options_for_activity_log($activity = '') {
48
+ global $wp_version;
49
+
50
+ // The following three lines are used for Client Reporting (Beta) - activities log.
51
+ if(!get_option('iwp_client_all_plugins_history') || in_array($activity, array('update_client_plugin', 'install'))) {
52
+ $this->iwp_mmb_update_all_plugins_history();
53
+ }
54
+ if(!get_option('iwp_client_all_themes_history') || in_array($activity, array('update_client_plugin', 'install'))) {
55
+ $this->iwp_mmb_update_all_themes_history();
56
+ }
57
+
58
+ if(!get_option('iwp_client_wp_version_old') || in_array($activity, array('update_client_plugin', 'install'))) {
59
+ update_option('iwp_client_wp_version_old',$wp_version); // It is mainly used when wp core auto updates happened.
60
+ }
61
+ }
62
+
63
+ function iwp_mmb_collect_backup_details($params) {
64
+ global $iwp_activities_log_post_type;
65
+
66
+ $user = get_user_by( 'login', $params['username'] );
67
+ $userid = $user->data->ID;
68
+
69
+ $details = array();
70
+ $details['backup_name'] = isset($params['args']['backup_name']) ? $params['args']['backup_name'] : '';
71
+ $details['limit'] = isset($params['args']['limit']) ? $params['args']['limit'] : '';
72
+ $details['disable_comp'] = isset($params['args']['disable_comp']) ? $params['args']['disable_comp'] : '';
73
+ $details['optimize_tables'] = isset($params['args']['optimize_tables']) ? $params['args']['optimize_tables'] : '';
74
+ $details['what'] = isset($params['args']['what']) ? $params['args']['what'] : '';
75
+ $details['exclude'] = isset($params['args']['exclude']) ? $params['args']['exclude'] : '';
76
+ $details['exclude_extensions'] = isset($params['args']['exclude_extensions']) ? $params['args']['exclude_extensions'] : '';
77
+ $details['exclude_file_size'] = isset($params['args']['exclude_file_size']) ? $params['args']['exclude_file_size'] : '';
78
+ $details['include'] = isset($params['args']['include']) ? $params['args']['include'] : '';
79
+ $details['mechanism'] = isset($params['mechanism']) ? $params['mechanism'] : '';
80
+ $details['fail_safe_files'] = isset($params['args']['fail_safe_files']) ? $params['args']['fail_safe_files'] : '';
81
+ $details['fail_safe_db'] = isset($params['args']['fail_safe_db']) ? $params['args']['fail_safe_db'] : '';
82
+ $details['del_host_file'] = isset($params['args']['del_host_file']) ? $params['args']['del_host_file'] : '';
83
+ $details['backup_repo_type'] = isset($params['args']['backup_repo_type']) ? $params['args']['backup_repo_type'] : '';
84
+ $details['when'] = isset($params['args']['when']) ? $params['args']['when'] : '';
85
+ $details['at'] = isset($params['args']['at']) ? $params['args']['at'] : '';
86
+
87
+ $this->iwp_mmb_save_iwp_activities(isset($params['args']['type'])?$params['args']['type']:'backup', isset($params['args']['action'])?$params['args']['action']:'now', $iwp_activities_log_post_type, (object)$details, $userid);
88
+
89
+ unset($details);
90
+ }
91
+
92
+ function iwp_mmb_save_iwp_activities($iwp_type, $iwp_action, $activities_type, $params, $userid) {
93
+ global $wpdb,$iwp_activities_log_post_type;
94
+
95
+ if(!$this->iwp_mmb_get_is_save_activity_log()) {
96
+ return false;
97
+ }
98
+
99
+ $iwp_activities = array(
100
+ 'post_title' => uniqid( $iwp_activities_log_post_type.'_' ),
101
+ 'post_author' => $userid,
102
+ 'post_status' => 'publish',
103
+ 'post_type' => $iwp_activities_log_post_type
104
+ );
105
+
106
+ if(!empty($GLOBALS['activities_log_datetime'])) {
107
+ $iwp_activities['post_date'] = $iwp_activities[' post_date_gmt'] = $iwp_activities[' post_modified'] = $iwp_activities['post_modified_gmt'] = $GLOBALS['activities_log_datetime'];
108
+ }
109
+
110
+ $post_id = wp_insert_post( $iwp_activities );
111
+
112
+ unset($iwp_activities);
113
+ /*
114
+ meta keys
115
+ ==========
116
+ iwp_log_type
117
+ iwp_log_action
118
+ iwp_log_activities_type - i. iwp_activities_log ii. direct iii. automatic
119
+ iwp_log_details
120
+ iwp_log_actions - i. core-updated ii. plugins-updated iii. themes-updated iv. translations-updated
121
+ */
122
+ $details = array();
123
+ $actions = '';
124
+ switch($iwp_action) {
125
+ case 'update':
126
+ switch($iwp_type) {
127
+ case 'core':
128
+ $details['old_version'] = $params->current_version;
129
+ $details['updated_version'] = $params->current;
130
+ update_option('iwp_client_wp_version_old',$params->current);
131
+ break;
132
+ case 'plugins':
133
+ case 'themes':
134
+ $details['name'] = $params->name;
135
+ $details['slug'] = $params->slug;
136
+ $details['old_version'] = $params->old_version;
137
+ $details['updated_version'] = $params->updated_version;
138
+ break;
139
+ case 'translations':
140
+ break;
141
+ }
142
+ $actions = $iwp_type.'-updated';
143
+ break;
144
+ case 'now':
145
+ case 'schedule':
146
+ switch($iwp_type) {
147
+ case 'backup':
148
+ case 'scheduleBackup':
149
+ $details = (array) $params;
150
+ break;
151
+ }
152
+ $actions = 'backups';
153
+ break;
154
+ }
155
+
156
+ if(!function_exists('update_post_meta')) {
157
+ require_once(ABSPATH.'wp-includes/post.php');
158
+ }
159
+
160
+ update_post_meta($post_id,$iwp_activities_log_post_type.'_type',$iwp_type);
161
+ update_post_meta($post_id,$iwp_activities_log_post_type.'_action',$iwp_action);
162
+ update_post_meta($post_id,$iwp_activities_log_post_type.'_activities_type',$activities_type);
163
+ update_post_meta($post_id,$iwp_activities_log_post_type.'_actions',$actions);
164
+ update_post_meta($post_id,$iwp_activities_log_post_type.'_details',$details);
165
+ unset($details);
166
+ }
167
+
168
+ function iwp_mmb_get_is_save_activity_log() {
169
+ return get_option('is_save_activity_log');
170
+ }
171
+
172
+ function iwp_mmb_core_upgrade_preamble() {
173
+
174
+ }
175
+
176
+ function iwp_mmb_core_updated_successfully($new_version) {
177
+ global $pagenow;
178
+
179
+ $current = array();
180
+ $current['current_version'] = get_option('iwp_client_wp_version_old');
181
+ $current['current'] = $new_version;
182
+ $activities_type = ('update-core.php' !== $pagenow)?'automatic':'direct';
183
+
184
+ $userid = $this->iwp_mmb_get_current_user_id();
185
+
186
+ $this->iwp_mmb_save_iwp_activities('core', 'update', $activities_type, (object)$current, $userid);
187
+ }
188
+
189
+ function iwp_mmb_get_current_user_id() {
190
+ if(!function_exists('get_current_user_id')) {
191
+ include_once (ABSPATH . 'wp-admin/includes/user.php');
192
+ }
193
+ return get_current_user_id();
194
+ }
195
+
196
+ function iwp_mmb_upgrader_process_complete($upgrader, $extra) {
197
+ global $pagenow,$wp_version;
198
+
199
+ if(version_compare($wp_version,'3.6','<=')) {
200
+ return false;
201
+ }
202
+
203
+ $success = ! is_wp_error( $upgrader->skin->result );
204
+ $error = null;
205
+
206
+ if ( ! $success ) {
207
+ $errors = $upgrader->skin->result->errors;
208
+
209
+ list( $error ) = reset( $errors );
210
+ }
211
+
212
+ // This would have failed down the road anyway
213
+ if ( ! isset( $extra['type'] ) ) {
214
+ return false;
215
+ }
216
+
217
+ $type = $extra['type'];
218
+ $action = $extra['action'];
219
+
220
+ if ( ! in_array( $type, array( 'plugin', 'theme' ) ) ) {
221
+ return false;
222
+ }
223
+
224
+ if ( 'install' === $action ) {
225
+ if ( 'plugin' === $type ) {
226
+ } else { // theme
227
+ }
228
+ } elseif ( 'update' === $action ) {
229
+ if(
230
+ (
231
+ 'theme' === $type
232
+ )
233
+ || (
234
+ 'plugin' === $type
235
+ && version_compare($wp_version,'3.7','>=')
236
+ && version_compare($wp_version,'3.8','<')
237
+ && isset( $extra['bulk'] )
238
+ && true === $extra['bulk']
239
+ && isset($extra['themes'])
240
+ && is_array($extra['themes'])
241
+ && count($extra['themes'])
242
+ ) // In wordpress 3.7, it is behaving differently. Thats why, we have written this "or" condition.
243
+ ) { // theme
244
+ if(isset($extra['theme']) && $extra['theme']) { // It is mainly used when wp cron themes updates happened.
245
+ $slugs = array( $extra['theme'] );
246
+ } else if ( isset( $extra['bulk'] ) && true === $extra['bulk'] ) {
247
+ $slugs = $extra['themes'];
248
+ } else {
249
+ $slugs = array( $upgrader->skin->theme );
250
+ }
251
+
252
+ foreach ( $slugs as $slug ) {
253
+ $this->iwp_mmb_collect_theme_details($slug);
254
+ }
255
+ } else if ( 'plugin' === $type ) {
256
+ if(isset($extra['plugin']) && $extra['plugin']) { // It is mainly used when wp cron plugins updates happened.
257
+ $slugs = array( $extra['plugin'] );
258
+ } else if ( isset( $extra['bulk'] ) && true === $extra['bulk'] ) {
259
+ $slugs = $extra['plugins'];
260
+ } else {
261
+ $slugs = array( $upgrader->skin->plugin );
262
+ }
263
+
264
+ foreach ( $slugs as $slug ) {
265
+ if($slug!='iwp-client/init.php') {
266
+ $this->iwp_mmb_collect_plugin_details($slug);
267
+ }
268
+ }
269
+ }
270
+ unset($current);
271
+ } else {
272
+ return false;
273
+ }
274
+ }
275
+
276
+ function iwp_mmb_collect_theme_details($theme_slug) {
277
+ global $pagenow;
278
+
279
+ $activities_type = (!in_array($pagenow,array('update.php','admin-ajax.php')))?'automatic':'direct';
280
+
281
+ $theme = $this->iwp_mmb_get_theme_details($theme_slug);
282
+
283
+ if(!count($theme)) {
284
+ return false;
285
+ }
286
+
287
+ $userid = $this->iwp_mmb_get_current_user_id();
288
+
289
+ $current = array();
290
+
291
+ $stylesheet = $theme['Stylesheet Dir'] . '/style.css';
292
+
293
+ if(!function_exists('get_file_data')) {
294
+ require_once(ABSPATH.'wp-includes/functions.php');
295
+ }
296
+
297
+ $theme_data = get_file_data( $stylesheet, array( 'Version' => 'Version' ) );
298
+ $current['name'] = $current['slug'] = $theme['Name']; // slug is used to get short description. Here theme name as slug.
299
+ $current['updated_version'] = $theme_data['Version'];
300
+ $current['old_version'] = $theme['Version'];
301
+
302
+ $all_themes_history = get_option('iwp_client_all_themes_history');
303
+
304
+ if(empty($current['name'])) {
305
+ return false;
306
+ }
307
+
308
+ if(!empty($current['updated_version']) && !empty($current['old_version']) && version_compare($current['updated_version'],$current['old_version'],'==') && isset($all_themes_history) && isset($all_themes_history[$theme_slug]) && $all_themes_history[$theme_slug]) {
309
+ $current['old_version'] = $all_themes_history[$theme_slug];
310
+ $all_themes_history[$theme_slug] = $current['updated_version'];
311
+ update_option('iwp_client_all_themes_history',$all_themes_history);
312
+ }
313
+
314
+ if(!empty($current['updated_version']) && !empty($current['old_version']) && version_compare($current['updated_version'],$current['old_version'],'==')) {
315
+ return false;
316
+ } // From wordpress 3.6 to lower versions, even though we got errors when we tried to update the themes, wordpress wont inform us about error via hooks. Thats why we have written this "if".
317
+
318
+ $this->iwp_mmb_save_iwp_activities('themes','update',$activities_type,(object)$current,$userid);
319
+ unset($current);
320
+ return true;
321
+ }
322
+
323
+ function iwp_mmb_get_theme_details($theme_slug) {
324
+ if(!function_exists('wp_get_theme')) {
325
+ require_once(ABSPATH.'wp-includes/theme.php');
326
+ }
327
+ if(function_exists('wp_get_theme')) {
328
+ $theme = wp_get_theme( $theme_slug );
329
+ } else if(function_exists('get_theme_data') && file_exists(ABSPATH . 'wp-content/themes/'. $theme_slug . '/style.css')) {
330
+ $theme = get_theme_data( ABSPATH . 'wp-content/themes/'. $theme_slug . '/style.css');
331
+ } else {
332
+ $theme = array();
333
+ }
334
+
335
+ return $theme;
336
+ }
337
+
338
+ function iwp_mmb_collect_plugin_details($plugin_file) {
339
+ global $pagenow;
340
+
341
+ $activities_type = (!in_array($pagenow,array('update.php','admin-ajax.php')))?'automatic':'direct';
342
+
343
+ $userid = $this->iwp_mmb_get_current_user_id();
344
+
345
+ $current = array();
346
+
347
+ $_plugins = $this->iwp_mmb_get_all_plugin_details();
348
+
349
+ if(!count($_plugins)) {
350
+ return false;
351
+ }
352
+
353
+ $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin_file );
354
+ $current['name'] = isset($plugin_data['Name'])?$plugin_data['Name']:'';
355
+ $current['slug'] = $plugin_file;
356
+ $current['updated_version'] = isset($plugin_data['Version'])?$plugin_data['Version']:'';
357
+ $current['old_version'] = isset($_plugins[ $plugin_file ]['Version'])?$_plugins[ $plugin_file ]['Version']:'';
358
+
359
+ $all_plugins_history = get_option('iwp_client_all_plugins_history');
360
+
361
+ if(!empty($current['updated_version']) && !empty($current['old_version']) && version_compare($current['updated_version'],$current['old_version'],'==') && isset($all_plugins_history) && isset($all_plugins_history[$plugin_file]) && $all_plugins_history[$plugin_file]) {
362
+ $current['old_version'] = $all_plugins_history[$plugin_file];
363
+ $all_plugins_history[$plugin_file] = $current['updated_version'];
364
+ update_option('iwp_client_all_plugins_history',$all_plugins_history);
365
+ }
366
+
367
+ if(!empty($current['updated_version']) && !empty($current['old_version']) && version_compare($current['updated_version'],$current['old_version'],'==')) {
368
+ return false;
369
+ } // From wordpress 3.6 to lower versions, even though we got errors when we tried to update the plugins, wordpress wont inform us about error via hooks. Thats why we have written this "if".
370
+
371
+ $this->iwp_mmb_save_iwp_activities('plugins','update',$activities_type,(object)$current,$userid);
372
+ unset($current);
373
+ return true;
374
+ }
375
+
376
+ function iwp_mmb_get_all_plugin_details() {
377
+
378
+ if ( ! function_exists( 'get_plugins' ) ) {
379
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
380
+ }
381
+ $_plugins = get_plugins();
382
+ if (empty($_plugins) || !is_array($_plugins)) {
383
+ return array();
384
+ }
385
+ return $_plugins;
386
+ }
387
+
388
+ function iwp_mmb_automatic_updates_complete($update_results) {
389
+ if(empty($update_results['translation'])) {
390
+ return false;
391
+ }
392
+ return $this->iwp_mmb_post_update_translations_complete_actions(array());
393
+ }
394
+
395
+ function iwp_mmb_post_update_translations_complete_actions($update_actions) {
396
+ global $pagenow,$iwp_client_plugin_translations,$iwp_client_plugin_ptc_updates,$wp_version,$iwp_activities_log_post_type;
397
+
398
+ $activities_type = (!in_array($pagenow,array('update.php','update-core.php')))?'automatic':'direct';
399
+
400
+ if(
401
+ isset($iwp_client_plugin_ptc_updates)
402
+ && $iwp_client_plugin_ptc_updates==1
403
+ ) {
404
+ $activities_type = $iwp_activities_log_post_type;
405
+ }
406
+
407
+ $userid = $this->iwp_mmb_get_current_user_id();
408
+
409
+ $details = array();
410
+ $this->iwp_mmb_save_iwp_activities('translations', 'update', $activities_type, (object)$details, $userid);
411
+ return $update_actions;
412
+ }
413
+
414
+ function iwp_mmb_check_and_update_all_plugins_themes_history($option, $old_value, $value) {
415
+ if(in_array($option,array('_site_transient_update_plugins','_site_transient_update_themes'))) {
416
+
417
+ $this->iwp_mmb_update_all_plugins_history();
418
+ $this->iwp_mmb_update_all_themes_history();
419
+ }
420
+ }
421
+
422
+ function iwp_mmb_update_all_plugins_history() {
423
+ $all_plugins = $this->get_all_plugins();
424
+ unset($all_plugins['iwp-client/init.php']);
425
+ $all_plugins_history = array();
426
+ foreach($all_plugins as $key=>$plugin) {
427
+ $all_plugins_history[$key] = $plugin['Version'];
428
+ }
429
+
430
+ update_option('iwp_client_all_plugins_history',$all_plugins_history);
431
+ unset($all_plugins,$all_plugins_history);
432
+ }
433
+
434
+ function iwp_mmb_update_all_themes_history() {
435
+ $all_themes = $this->get_all_themes();
436
+ $all_themes_history = array();
437
+ $theme_details = array();
438
+ foreach($all_themes as $key=>$theme) {
439
+ $theme_details = $this->iwp_mmb_get_theme_details($key);
440
+ $all_themes_history[$key] = $theme_details->Version;
441
+ }
442
+
443
+ update_option('iwp_client_all_themes_history',$all_themes_history);
444
+ unset($all_themes,$all_themes_history,$theme_details);
445
+ }
446
+
447
+ function get_all_plugins() {
448
+ if (!function_exists('get_plugins')) {
449
+ include_once(ABSPATH . 'wp-admin/includes/plugin.php');
450
+ }
451
+ $all_plugins = get_plugins();
452
+ return $all_plugins;
453
+ }
454
+
455
+ function get_all_themes() {
456
+ if (!function_exists('wp_get_themes')) {
457
+ include_once(ABSPATH . WPINC . '/theme.php');
458
+ }
459
+ if(function_exists('wp_get_themes')){
460
+ $all_themes = wp_get_themes();
461
+ }else{
462
+ $all_themes = get_themes();
463
+ }
464
+ return $all_themes;
465
+ }
466
+
467
+ function iwp_mmb_update_theme_complete_actions($update_actions, $theme_slug) {
468
+ global $wp_version;
469
+
470
+ if(version_compare($wp_version,'3.7','>=') or empty($theme_slug)) {
471
+ return $update_actions;
472
+ }
473
+
474
+ $this->iwp_mmb_collect_theme_details($theme_slug);
475
+
476
+ return $update_actions;
477
+ }
478
+
479
+ function iwp_mmb_update_bulk_theme_complete_actions($update_actions, $theme_info) {
480
+ global $wp_version,$iwp_client_plugin_ptc_updates;
481
+
482
+ if(
483
+ (
484
+ version_compare($wp_version,'3.7','>=')
485
+ )
486
+ or (
487
+ isset($iwp_client_plugin_ptc_updates)
488
+ && $iwp_client_plugin_ptc_updates==1
489
+ )
490
+ ) {
491
+ return $update_actions;
492
+ }
493
+
494
+ $theme_info = (array) $theme_info;
495
+ $theme_slug = '';
496
+
497
+ foreach($theme_info as $key=>$value) {
498
+ if(isset($value['TextDomain']) && $value['TextDomain']) {
499
+ $theme_slug = $value['TextDomain'];
500
+ break;
501
+ } else if(strstr($key,'stylesheet') || strstr($key,'template')) {
502
+ $theme_slug = $value;
503
+ break;
504
+ } else if($key=='Name') {
505
+ $theme_slug = str_replace(array(' '),array(''),strtolower($value));
506
+ break;
507
+ }
508
+ }
509
+
510
+ if($theme_slug=='') {
511
+ return $update_actions;
512
+ }
513
+
514
+ $this->iwp_mmb_collect_theme_details($theme_slug);
515
+
516
+ return $update_actions;
517
+ }
518
+
519
+ function iwp_mmb_async_update_translation($update, $language_update) {
520
+ return false;
521
+ }
522
+
523
+ function iwp_mmb_update_translations_complete_actions($update_actions) {
524
+ global $pagenow,$iwp_client_plugin_translations,$iwp_client_plugin_ptc_updates,$wp_version;
525
+
526
+ if(
527
+ (
528
+ isset($iwp_client_plugin_translations)
529
+ && $iwp_client_plugin_translations==1
530
+ )
531
+ or (
532
+ version_compare($wp_version,'4.0','<')
533
+ )
534
+ ) {
535
+ return $update_actions;
536
+ }
537
+
538
+ return $this->iwp_mmb_post_update_translations_complete_actions($update_actions);
539
+ }
540
+
541
+ function iwp_mmb_upgrader_post_install($flag, $hook_extra, $result) {
542
+ global $wp_version;
543
+
544
+ if(
545
+ isset($hook_extra['language_update_type'])
546
+ && isset($hook_extra['language_update'])
547
+ && is_object($hook_extra['language_update'])
548
+ ) {
549
+ remove_filter('update_translations_complete_actions', array(&$this,'iwp_mmb_update_translations_complete_actions'));
550
+ return $this->iwp_mmb_post_update_translations_complete_actions(array());
551
+ }
552
+
553
+ if(
554
+ version_compare($wp_version,'3.6','<=')
555
+ && isset($hook_extra['plugin'])
556
+ && $hook_extra['plugin']
557
+ && strstr($hook_extra['plugin'],'.zip')===false
558
+ ) {
559
+ $this->iwp_mmb_collect_plugin_details($hook_extra['plugin']);
560
+ }
561
+
562
+ return $result;
563
+ }
564
+
565
+ function iwp_mmb_update_is_save_activity_log($is_save_activity_log) {
566
+ if(isset($is_save_activity_log)) {
567
+ update_option('is_save_activity_log', $is_save_activity_log);
568
+ }
569
+ }
570
+
571
+ function iwp_mmb_process_and_fetch_activities_log($params) {
572
+ global $wpdb,$iwp_activities_log_post_type;
573
+
574
+ $updated_key = 'updated';
575
+ $backups_key = 'backups';
576
+ $count_key = 'count';
577
+ $name_key = 'name';
578
+ $date_key = 'date';
579
+ $time_key = 'time';
580
+ $type_key = 'type';
581
+ $from_key = 'from';
582
+ $to_key = 'to';
583
+ $translations_updated = 'translations-updated';
584
+
585
+ if(
586
+ !is_array($params['originalActions'])
587
+ || !is_array($params['actions'])
588
+ || !count($params['originalActions'])
589
+ || !count($params['actions'])
590
+ || empty($params['fromDate'])
591
+ || empty($params['toDate'])
592
+ ) {
593
+ iwp_mmb_response(array('error' => 'Invalid request', 'error_code' => 'invalid_request'), false);
594
+ }
595
+
596
+ $iwp_action = implode("','",$params['actions']);
597
+
598
+ $query = "
599
+ select
600
+ p.ID as post_id,
601
+ p.post_date as date,
602
+ pm.meta_value as actions
603
+ from
604
+ {$wpdb->prefix}posts as p
605
+ left join {$wpdb->prefix}postmeta as pm on pm.post_id = p.ID
606
+ where
607
+ p.post_type = '".$iwp_activities_log_post_type."'
608
+ and unix_timestamp(p.post_date)>='".$params['fromDate']."'
609
+ and unix_timestamp(p.post_date)<='".$params['toDate']."'
610
+ and pm.meta_key in ('".$iwp_activities_log_post_type."_actions')
611
+ and pm.meta_value in ('".$iwp_action."')
612
+ order by p.post_date asc
613
+ ";
614
+
615
+ $activities_log_result = $wpdb->get_results($query,ARRAY_A);
616
+ $return = array();
617
+ $return['detailed'] = $params['detailed'];
618
+ $return[$count_key] = array_map('iwp_make_values_as_zero',array_flip($params['actions']));
619
+
620
+ foreach($activities_log_result as $key=>$activities_log) {
621
+
622
+ $date = date('M d, y',strtotime($activities_log['date']));
623
+ $time = date('g',strtotime($activities_log['date'])).':'.date('i',strtotime($activities_log['date'])).' '.date('a',strtotime($activities_log['date']));
624
+
625
+ $detailed_array = array(
626
+ $date_key => $date,
627
+ $time_key => $time
628
+ );
629
+
630
+ $activities_log_details = get_post_meta($activities_log['post_id'],$iwp_activities_log_post_type.'_details',true);
631
+
632
+ // The following lines are for CR New
633
+ if($activities_log['actions']==$backups_key) {
634
+ $return['detailed'][$activities_log['actions']]['details'][$return['detailed'][$activities_log['actions']][$count_key]] = $detailed_array;
635
+ if($activities_log_details['what']=='full') {
636
+ $backup_what_type = 'Files & DB';
637
+ } else if($activities_log_details['what']=='files') {
638
+ $backup_what_type = 'Files';
639
+ } else {
640
+ $backup_what_type = 'DB';
641
+ }
642
+ $return['detailed'][$activities_log['actions']]['details'][$return['detailed'][$activities_log['actions']][$count_key]][$type_key] = $backup_what_type;
643
+ $return['detailed'][$activities_log['actions']][$count_key]++;
644
+ } else {
645
+
646
+ $return['detailed'][$updated_key][$count_key]++;
647
+
648
+ $return['detailed'][$updated_key][$activities_log['actions']]['details'][$return['detailed'][$updated_key][$activities_log['actions']][$count_key]] = $detailed_array;
649
+
650
+ if($activities_log['actions']!=$translations_updated) {
651
+
652
+ $name = str_replace(array($translations_updated,'s-updated','core-updated'),array(''),$activities_log['actions']);
653
+ $what_updated = isset($activities_log_details['name'])?$activities_log_details['name']:'Wordpress Core Updates';
654
+
655
+ $return['detailed'][$updated_key][$activities_log['actions']]['details'][$return['detailed'][$updated_key][$activities_log['actions']][$count_key]][$name.$name_key] = $what_updated;
656
+ $return['detailed'][$updated_key][$activities_log['actions']]['details'][$return['detailed'][$updated_key][$activities_log['actions']][$count_key]][$from_key] = $activities_log_details['old_version'];
657
+ $return['detailed'][$updated_key][$activities_log['actions']]['details'][$return['detailed'][$updated_key][$activities_log['actions']][$count_key]][$to_key] = $activities_log_details['updated_version'];
658
+ }
659
+ $return['detailed'][$updated_key][$activities_log['actions']][$count_key]++;
660
+ }
661
+ // The above lines are for CR New
662
+ $return[$count_key][$activities_log['actions']]++; // This line is for CR Old
663
+ }
664
+ foreach($return[$count_key] as $key => &$value) {
665
+ if($value==0) {
666
+ unset($return[$count_key][$key]);
667
+ }
668
+ }
669
+ foreach($return['detailed'] as $key => &$mainActionArray) {
670
+ if(!$mainActionArray[$count_key]) {
671
+ unset($return['detailed'][$key]);
672
+ } else if(!array_key_exists('details',$mainActionArray)) {
673
+ foreach($mainActionArray as $key_inner => &$subActionsArray) {
674
+ if(!$subActionsArray[$count_key] && $key_inner!=$count_key) {
675
+ unset($mainActionArray[$key_inner]);
676
+ }
677
+ }
678
+ }
679
+ }
680
+
681
+ iwp_mmb_response($return, true);
682
+ }
683
+
684
+ function iwp_mmb_do_remove_upgrader_process_complete_action() {
685
+ remove_action('upgrader_process_complete', array( &$this, 'iwp_mmb_upgrader_process_complete'), 1);
686
+ }
687
+
688
+ function iwp_mmb_do_remove_theme_filters() {
689
+ remove_filter('update_theme_complete_actions', array( &$this, 'iwp_mmb_update_theme_complete_actions')); // It is available from wordpress 2.7 to 3.6.
690
+ remove_filter('update_bulk_theme_complete_actions', array( &$this, 'iwp_mmb_update_bulk_theme_complete_actions')); // It is available from wordpress 2.7 to 3.6.
691
+ }
692
+
693
+ function iwp_mmb_do_remove_upgrader_post_install_filter() {
694
+ remove_filter('upgrader_post_install', array( &$this, 'iwp_mmb_upgrader_post_install'));
695
+ }
696
+
697
+ function iwp_mmb_do_remove_core_updated_successfully() {
698
+ remove_action('_core_updated_successfully', array( &$this, 'iwp_mmb_core_updated_successfully'),1);
699
+ }
700
+ }
701
+
702
+ if(!function_exists('iwp_make_values_as_zero')) {
703
+ function iwp_make_values_as_zero($value) {
704
+ return 0;
705
+ }
706
+ }
707
+ if( !function_exists ( 'iwp_mmb_fetch_activities_log' )) {
708
+ function iwp_mmb_fetch_activities_log($params) {
709
+ global $iwp_mmb_activities_log;
710
+
711
+ $iwp_mmb_activities_log->iwp_mmb_process_and_fetch_activities_log($params);
712
+ }
713
+ }
backup.class.multicall.php CHANGED
@@ -186,6 +186,8 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
186
 
187
  function set_backup_task($params)
188
  {
 
 
189
  if(!empty($params))
190
  {
191
  initialize_manual_debug();
@@ -314,6 +316,9 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
314
  $responseParams = array();
315
  $responseParams['nextFunc'] = 'backup';
316
  $responseParams['mechanism'] = 'multiCall';
 
 
 
317
  return $this->statusLog($historyID, array('stage' => 'verification', 'status' => 'completed', 'statusMsg' => 'verified', 'nextFunc' => 'backup', 'responseParams' => $responseParams));
318
  }
319
  }
@@ -2298,8 +2303,8 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
2298
  $stats = array();
2299
  $table_name = $wpdb->base_prefix . "iwp_backup_status";
2300
 
2301
- $rows = $wpdb->get_results("SELECT taskName,taskResults FROM ".$table_name, ARRAY_A);
2302
-
2303
  $task_res = array();
2304
  foreach($rows as $key => $value){
2305
  $task_results = unserialize($value['taskResults']);
@@ -2314,7 +2319,31 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
2314
  return $task_res;
2315
  }
2316
 
2317
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2318
  function get_this_tasks(){
2319
  $this->wpdb_reconnect();
2320
 
@@ -2380,7 +2409,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
2380
  $this->wpdb_reconnect();
2381
  if(empty($historyID))
2382
  {
2383
- $insert = $wpdb->insert($wpdb->base_prefix.'iwp_backup_status',array( 'stage' => $statusArray['stage'], 'status' => $statusArray['status'], 'action' => $params['args']['action'], 'type' => $params['args']['type'],'category' => $params['args']['what'],'historyID' => $params['args']['parentHID'],'finalStatus' => 'pending','startTime' => microtime(true),'endTime' => '','statusMsg' => $statusArray['statusMsg'],'requestParams' => serialize($params),'taskName' => $params['task_name']), array( '%s', '%s','%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%s', '%s', '%s' ) );
2384
  if($insert)
2385
  {
2386
  $insertID = $wpdb->insert_id;
@@ -2388,12 +2417,12 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
2388
  }
2389
  else if((isset($statusArray['responseParams']))||(isset($statusArray['task_result'])))
2390
  {
2391
- $update = $wpdb->update($wpdb->base_prefix.'iwp_backup_status',array( 'responseParams' => $this->maybe_serialize_compress($statusArray['responseParams']),'stage' => $statusArray['stage'], 'status' => $statusArray['status'],'statusMsg' => $statusArray['statusMsg'],'taskResults' => isset($statusArray['task_result']) ? serialize($statusArray['task_result']) : serialize(array()) ),array( 'historyID' => $historyID),array('%s','%s', '%s', '%s','%s'),array('%d'));
2392
  }
2393
  else
2394
  {
2395
  //$responseParams = $this -> getRequiredData($historyID,"responseParams");
2396
- $update = $wpdb->update($wpdb->base_prefix.'iwp_backup_status',array('stage' => $statusArray['stage'], 'status' => $statusArray['status'],'statusMsg' => $statusArray['statusMsg'] ),array( 'historyID' => $historyID),array( '%s', '%s', '%s'),array('%d'));
2397
  }
2398
  if( (isset($update)&&($update === false)) || (isset($insert)&&($insert === false)) )
2399
  {
@@ -3182,7 +3211,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
3182
  $delete = $wpdb->query("DROP TABLE '".$table."' ");
3183
  }
3184
 
3185
- iwp_mmb_create_backup_table();
3186
 
3187
  if(!empty($clone_restore_options['iwp_client_backup_tasks'])){
3188
  $this->insertBackupStatusContens($clone_restore_options['iwp_client_backup_tasks']);
@@ -6032,7 +6061,7 @@ function ftp_backup($historyID,$args = '')
6032
  global $wpdb;
6033
  $this_table_name = $wpdb->base_prefix . 'iwp_file_list'; //in case, if we are changing table name.
6034
  $result = true;
6035
-
6036
  $IWP_FILE_LIST_TABLE_VERSION = iwp_mmb_get_site_option('iwp_file_list_table_version');
6037
 
6038
  //write in db and refresh for_every_count, all_files_detail;
@@ -6302,14 +6331,14 @@ function ftp_backup($historyID,$args = '')
6302
  $sql = array();
6303
 
6304
  $columnData = $wpdb->get_var("SHOW COLUMNS FROM $table_name WHERE Field = 'thisFileNameHash'");
6305
- if(empty($columnData)) {
6306
- $sql[] = "ALTER TABLE $table_name ADD `thisFileNameHash` VARCHAR(32) $cachecollation NULL DEFAULT NULL AFTER `thisFileName`";
6307
- $sql[] = "ALTER IGNORE TABLE $table_name ADD UNIQUE `thisFileNameHash` (`thisFileNameHash`(32))";
6308
- }
6309
- $indexData = $wpdb->get_var("SHOW KEYS FROM $table_name WHERE Key_name = 'thisFileName'");
6310
- if(!empty($indexData)){
6311
- $sql[] = "ALTER TABLE $table_name DROP INDEX thisFileName;";
6312
- }
6313
 
6314
  //Running the alter queries to the table
6315
  foreach($sql as $v){
@@ -6325,6 +6354,7 @@ function ftp_backup($historyID,$args = '')
6325
  }
6326
  }
6327
  }
 
6328
  /*if( function_exists('add_filter') ){
6329
  add_filter( 'iwp_website_add', 'IWP_MMB_Backup::readd_tasks' );
6330
  }*/
186
 
187
  function set_backup_task($params)
188
  {
189
+ global $iwp_mmb_activities_log;
190
+
191
  if(!empty($params))
192
  {
193
  initialize_manual_debug();
316
  $responseParams = array();
317
  $responseParams['nextFunc'] = 'backup';
318
  $responseParams['mechanism'] = 'multiCall';
319
+
320
+ $iwp_mmb_activities_log->iwp_mmb_collect_backup_details($params);
321
+
322
  return $this->statusLog($historyID, array('stage' => 'verification', 'status' => 'completed', 'statusMsg' => 'verified', 'nextFunc' => 'backup', 'responseParams' => $responseParams));
323
  }
324
  }
2303
  $stats = array();
2304
  $table_name = $wpdb->base_prefix . "iwp_backup_status";
2305
 
2306
+ $rows = $wpdb->get_results("SELECT ID, taskName, taskResults FROM ".$table_name." ORDER BY ID DESC", ARRAY_A);
2307
+ $this->cleanup_failed_backups($rows);
2308
  $task_res = array();
2309
  foreach($rows as $key => $value){
2310
  $task_results = unserialize($value['taskResults']);
2319
  return $task_res;
2320
  }
2321
 
2322
+ function cleanup_failed_backups($rows){
2323
+ $rowCount = 0;
2324
+ if (empty($rows) || !is_array($rows)) {
2325
+ return false;
2326
+ }
2327
+ foreach($rows as $key => $value){
2328
+ $task_results = unserialize($value['taskResults']);
2329
+ if(empty($task_results['task_results'])){
2330
+ if ($rowCount > 0) {
2331
+ $this->remove_failed_backups($value['ID']);
2332
+ }
2333
+ $rowCount++;
2334
+ continue;
2335
+ }
2336
+ $rowCount++;
2337
+ }
2338
+ }
2339
+
2340
+ function remove_failed_backups($ID){
2341
+ global $wpdb;
2342
+ $table_name = $wpdb->base_prefix . "iwp_backup_status";
2343
+ $delete_query = "DELETE FROM ".$table_name." WHERE ID = '".$ID."' ";
2344
+ $deleteRes = $wpdb->query($delete_query);
2345
+ }
2346
+
2347
  function get_this_tasks(){
2348
  $this->wpdb_reconnect();
2349
 
2409
  $this->wpdb_reconnect();
2410
  if(empty($historyID))
2411
  {
2412
+ $insert = $wpdb->insert($wpdb->base_prefix.'iwp_backup_status',array( 'stage' => $statusArray['stage'], 'status' => $statusArray['status'], 'action' => $params['args']['action'], 'type' => $params['args']['type'],'category' => $params['args']['what'],'historyID' => $params['args']['parentHID'],'finalStatus' => 'pending','startTime' => microtime(true), 'lastUpdateTime' => microtime(true), 'endTime' => '','statusMsg' => $statusArray['statusMsg'],'requestParams' => serialize($params),'taskName' => $params['task_name']), array( '%s', '%s','%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%s', '%s', '%s' ) );
2413
  if($insert)
2414
  {
2415
  $insertID = $wpdb->insert_id;
2417
  }
2418
  else if((isset($statusArray['responseParams']))||(isset($statusArray['task_result'])))
2419
  {
2420
+ $update = $wpdb->update($wpdb->base_prefix.'iwp_backup_status',array( 'responseParams' => $this->maybe_serialize_compress($statusArray['responseParams']),'stage' => $statusArray['stage'], 'status' => $statusArray['status'],'statusMsg' => $statusArray['statusMsg'],'taskResults' => isset($statusArray['task_result']) ? serialize($statusArray['task_result']) : serialize(array()), 'lastUpdateTime' => microtime(true)),array( 'historyID' => $historyID),array('%s','%s', '%s', '%s','%s'),array('%d'));
2421
  }
2422
  else
2423
  {
2424
  //$responseParams = $this -> getRequiredData($historyID,"responseParams");
2425
+ $update = $wpdb->update($wpdb->base_prefix.'iwp_backup_status',array('stage' => $statusArray['stage'], 'status' => $statusArray['status'],'statusMsg' => $statusArray['statusMsg'], 'lastUpdateTime' => microtime(true)),array( 'historyID' => $historyID),array( '%s', '%s', '%s'),array('%d'));
2426
  }
2427
  if( (isset($update)&&($update === false)) || (isset($insert)&&($insert === false)) )
2428
  {
3211
  $delete = $wpdb->query("DROP TABLE '".$table."' ");
3212
  }
3213
 
3214
+ iwp_mmb_backup_db_changes();
3215
 
3216
  if(!empty($clone_restore_options['iwp_client_backup_tasks'])){
3217
  $this->insertBackupStatusContens($clone_restore_options['iwp_client_backup_tasks']);
6061
  global $wpdb;
6062
  $this_table_name = $wpdb->base_prefix . 'iwp_file_list'; //in case, if we are changing table name.
6063
  $result = true;
6064
+
6065
  $IWP_FILE_LIST_TABLE_VERSION = iwp_mmb_get_site_option('iwp_file_list_table_version');
6066
 
6067
  //write in db and refresh for_every_count, all_files_detail;
6331
  $sql = array();
6332
 
6333
  $columnData = $wpdb->get_var("SHOW COLUMNS FROM $table_name WHERE Field = 'thisFileNameHash'");
6334
+ if(empty($columnData)) {
6335
+ $sql[] = "ALTER TABLE $table_name ADD `thisFileNameHash` VARCHAR(32) $cachecollation NULL DEFAULT NULL AFTER `thisFileName`";
6336
+ $sql[] = "ALTER IGNORE TABLE $table_name ADD UNIQUE `thisFileNameHash` (`thisFileNameHash`(32))";
6337
+ }
6338
+ $indexData = $wpdb->get_var("SHOW KEYS FROM $table_name WHERE Key_name = 'thisFileName'");
6339
+ if(!empty($indexData)){
6340
+ $sql[] = "ALTER TABLE $table_name DROP INDEX thisFileName;";
6341
+ }
6342
 
6343
  //Running the alter queries to the table
6344
  foreach($sql as $v){
6354
  }
6355
  }
6356
  }
6357
+
6358
  /*if( function_exists('add_filter') ){
6359
  add_filter( 'iwp_website_add', 'IWP_MMB_Backup::readd_tasks' );
6360
  }*/
backup.class.singlecall.php CHANGED
@@ -146,7 +146,9 @@ class IWP_MMB_Backup_Singlecall extends IWP_MMB_Core
146
  }*/
147
 
148
  function set_backup_task($params){
149
- if (!empty($params)) {
 
 
150
 
151
  $this->statusLog($historyID, array('stage' => 'verification', 'status' => 'processing', 'statusMsg' => 'verificationInitiated'), $params);
152
 
@@ -165,6 +167,8 @@ class IWP_MMB_Backup_Singlecall extends IWP_MMB_Core
165
  if (is_array($result) && array_key_exists('error', $result)) {
166
  $return = $result;
167
  } else {
 
 
168
  $return = unserialize($backup_settings['taskResults']);
169
  }
170
  //}
@@ -2514,15 +2518,13 @@ function ftp_backup($args)
2514
  $stats = array();
2515
  $table_name = $wpdb->base_prefix . "iwp_backup_status";
2516
 
2517
- $rows = $wpdb->get_results("SELECT taskName,taskResults FROM ".$table_name, ARRAY_A);
2518
-
2519
  $task_res = array();
2520
  foreach($rows as $key => $value){
2521
  $task_results = unserialize($value['taskResults']);
2522
-
2523
- if(!empty($task_results['task_results']))
2524
  foreach($task_results['task_results'] as $key => $data){
2525
-
2526
  $task_res[$value['taskName']]['task_results'][$key] = $data;
2527
  }
2528
  }
@@ -2530,6 +2532,31 @@ function ftp_backup($args)
2530
  return $task_res;
2531
  }
2532
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2533
  function get_this_tasks($requestParams = ''){
2534
  $this->wpdb_reconnect();
2535
 
@@ -2796,7 +2823,6 @@ function ftp_backup($args)
2796
  function cleanup()
2797
  {
2798
  $tasks = $this->get_all_tasks(); //all backups task results array.
2799
-
2800
  $backup_folder = WP_CONTENT_DIR . '/' . md5('iwp_mmb-client') . '/iwp_backups/';
2801
  $backup_folder_new = IWP_BACKUP_DIR . '/';
2802
  $backup_temp_folder = IWP_PCLZIP_TEMPORARY_DIR;
@@ -2921,8 +2947,7 @@ function ftp_backup($args)
2921
 
2922
  if(empty($historyID))
2923
  {
2924
-
2925
- $insert = $wpdb->insert($wpdb->base_prefix.'iwp_backup_status',array( 'stage' => $statusArray['stage'], 'status' => $statusArray['status'], 'action' => $params['args']['action'], 'type' => $params['args']['type'],'category' => $params['args']['what'],'historyID' => $GLOBALS['IWP_CLIENT_HISTORY_ID'],'finalStatus' => 'pending','startTime' => microtime(true),'endTime' => '','statusMsg' => $statusArray['statusMsg'],'requestParams' => serialize($params),'taskName' => $params['task_name']), array( '%s', '%s','%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%s', '%s', '%s' ) );
2926
  if($insert)
2927
  {
2928
  $insertID = $wpdb->insert_id;
@@ -2931,16 +2956,15 @@ function ftp_backup($args)
2931
  else if(isset($statusArray['responseParams']))
2932
  {
2933
 
2934
- $update = $wpdb->update($wpdb->base_prefix.'iwp_backup_status',array( 'responseParams' => serialize($statusArray['responseParams']),'stage' => $statusArray['stage'], 'status' => $statusArray['status'],'statusMsg' => $statusArray['statusMsg'], 'taskResults' => serialize($statusArray['task_result'])),array( 'historyID' => $historyID),array('%s','%s', '%s', '%s', '%s'),array('%d'));
2935
 
2936
 
2937
  }
2938
  else
2939
  {
2940
- $update = $wpdb->update($wpdb->base_prefix.'iwp_backup_status',array( 'stage' => $statusArray['stage'], 'status' => $statusArray['status'],'statusMsg' => $statusArray['statusMsg'], 'taskResults' => serialize($statusArray['task_result']) ),array( 'historyID' => $historyID),array('%s', '%s', '%s', '%s'),array('%d'));
2941
 
2942
  }
2943
-
2944
  if( (isset($update)&&(!$update)) || (isset($insert)&&(!$insert)) )
2945
  {
2946
  //return array('error'=> $statusArray['statusMsg']);
146
  }*/
147
 
148
  function set_backup_task($params){
149
+ global $iwp_mmb_activities_log;
150
+
151
+ if (!empty($params)) {
152
 
153
  $this->statusLog($historyID, array('stage' => 'verification', 'status' => 'processing', 'statusMsg' => 'verificationInitiated'), $params);
154
 
167
  if (is_array($result) && array_key_exists('error', $result)) {
168
  $return = $result;
169
  } else {
170
+ $iwp_mmb_activities_log->iwp_mmb_collect_backup_details($params);
171
+
172
  $return = unserialize($backup_settings['taskResults']);
173
  }
174
  //}
2518
  $stats = array();
2519
  $table_name = $wpdb->base_prefix . "iwp_backup_status";
2520
 
2521
+ $rows = $wpdb->get_results("SELECT ID, taskName, taskResults FROM ".$table_name." ORDER BY ID DESC", ARRAY_A);
2522
+ $this->cleanup_failed_backups($rows);
2523
  $task_res = array();
2524
  foreach($rows as $key => $value){
2525
  $task_results = unserialize($value['taskResults']);
2526
+ if (!empty($task_results['task_results']))
 
2527
  foreach($task_results['task_results'] as $key => $data){
 
2528
  $task_res[$value['taskName']]['task_results'][$key] = $data;
2529
  }
2530
  }
2532
  return $task_res;
2533
  }
2534
 
2535
+ function cleanup_failed_backups($rows){
2536
+ $rowCount = 0;
2537
+ if (empty($rows) || !is_array($rows)) {
2538
+ return false;
2539
+ }
2540
+ foreach($rows as $key => $value){
2541
+ $task_results = unserialize($value['taskResults']);
2542
+ if(empty($task_results['task_results'])){
2543
+ if ($rowCount > 0) {
2544
+ $this->remove_failed_backups($value['ID']);
2545
+ }
2546
+ $rowCount++;
2547
+ continue;
2548
+ }
2549
+ $rowCount++;
2550
+ }
2551
+ }
2552
+
2553
+ function remove_failed_backups($ID){
2554
+ global $wpdb;
2555
+ $table_name = $wpdb->base_prefix . "iwp_backup_status";
2556
+ $delete_query = "DELETE FROM ".$table_name." WHERE ID = '".$ID."' ";
2557
+ $deleteRes = $wpdb->query($delete_query);
2558
+ }
2559
+
2560
  function get_this_tasks($requestParams = ''){
2561
  $this->wpdb_reconnect();
2562
 
2823
  function cleanup()
2824
  {
2825
  $tasks = $this->get_all_tasks(); //all backups task results array.
 
2826
  $backup_folder = WP_CONTENT_DIR . '/' . md5('iwp_mmb-client') . '/iwp_backups/';
2827
  $backup_folder_new = IWP_BACKUP_DIR . '/';
2828
  $backup_temp_folder = IWP_PCLZIP_TEMPORARY_DIR;
2947
 
2948
  if(empty($historyID))
2949
  {
2950
+ $insert = $wpdb->insert($wpdb->base_prefix.'iwp_backup_status',array( 'stage' => $statusArray['stage'], 'status' => $statusArray['status'], 'action' => $params['args']['action'], 'type' => $params['args']['type'],'category' => $params['args']['what'],'historyID' => $GLOBALS['IWP_CLIENT_HISTORY_ID'],'finalStatus' => 'pending','startTime' => microtime(true),'lastUpdateTime' => microtime(true), 'endTime' => '','statusMsg' => $statusArray['statusMsg'],'requestParams' => serialize($params),'taskName' => $params['task_name']), array( '%s', '%s','%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%s', '%s', '%s' ) );
 
2951
  if($insert)
2952
  {
2953
  $insertID = $wpdb->insert_id;
2956
  else if(isset($statusArray['responseParams']))
2957
  {
2958
 
2959
+ $update = $wpdb->update($wpdb->base_prefix.'iwp_backup_status',array( 'responseParams' => serialize($statusArray['responseParams']),'stage' => $statusArray['stage'], 'status' => $statusArray['status'],'statusMsg' => $statusArray['statusMsg'], 'taskResults' => serialize($statusArray['task_result']), 'lastUpdateTime' => microtime(true)),array( 'historyID' => $historyID),array('%s','%s', '%s', '%s', '%s'),array('%d'));
2960
 
2961
 
2962
  }
2963
  else
2964
  {
2965
+ $update = $wpdb->update($wpdb->base_prefix.'iwp_backup_status',array( 'stage' => $statusArray['stage'], 'status' => $statusArray['status'],'statusMsg' => $statusArray['statusMsg'], 'taskResults' => serialize($statusArray['task_result']), 'lastUpdateTime' => microtime(true)),array( 'historyID' => $historyID),array('%s', '%s', '%s', '%s'),array('%d'));
2966
 
2967
  }
 
2968
  if( (isset($update)&&(!$update)) || (isset($insert)&&(!$insert)) )
2969
  {
2970
  //return array('error'=> $statusArray['statusMsg']);
core.class.php CHANGED
@@ -184,7 +184,8 @@ class IWP_MMB_Core extends IWP_MMB_Helper
184
  'backup_test_site' => 'iwp_mmb_backup_test_site',
185
  'ithemes_security_load' => 'iwp_mmb_ithemes_security_load',
186
  'get_seo_info' => 'iwp_mmb_yoast_get_seo_info',
187
- 'save_seo_info' => 'iwp_mmb_yoast_save_seo_info'
 
188
  );
189
 
190
  add_action('rightnow_end', array( &$this, 'add_right_now_info' ));
@@ -628,7 +629,7 @@ class IWP_MMB_Core extends IWP_MMB_Helper
628
  */
629
  function install() {
630
 
631
- global $wpdb, $_wp_using_ext_object_cache, $current_user;
632
  $_wp_using_ext_object_cache = false;
633
 
634
  //delete plugin options, just in case
@@ -666,7 +667,8 @@ class IWP_MMB_Core extends IWP_MMB_Helper
666
  delete_option('iwp_client_pageview_alerts');
667
 
668
  add_option('iwp_client_activate_key', sha1( rand(1, 99999). uniqid('', true) . get_option('siteurl') ) );
669
-
 
670
  }
671
 
672
  /**
@@ -730,6 +732,10 @@ class IWP_MMB_Core extends IWP_MMB_Helper
730
  delete_option('iwp_client_pageview_alerts');
731
 
732
  delete_option('iwp_client_activate_key');
 
 
 
 
733
  }
734
 
735
 
@@ -754,7 +760,7 @@ class IWP_MMB_Core extends IWP_MMB_Helper
754
  */
755
  function update_client_plugin($params)
756
  {
757
-
758
  extract($params);
759
  if ($download_url) {
760
  @include_once ABSPATH . 'wp-admin/includes/file.php';
@@ -785,52 +791,14 @@ class IWP_MMB_Core extends IWP_MMB_Helper
785
  ob_end_clean();
786
  @wp_update_plugins();
787
 
788
- //iwp_mmb_create_backup_table();
789
-
790
- //add_action( 'plugins_loaded', 'iwp_mmb_create_backup_table' );
791
-
792
- /*global $wpdb;
793
-
794
-
795
- $IWP_MMB_BACKUP_TABLE_VERSION = '1.0';
796
- if (get_site_option( 'iwp_backup_table_version' ) != $IWP_MMB_BACKUP_TABLE_VERSION) {
797
-
798
- $table_name = $wpdb->base_prefix . "iwp_backup_status";
799
-
800
- $sql = "
801
- CREATE TABLE IF NOT EXISTS $table_name (
802
- `ID` int(11) NOT NULL AUTO_INCREMENT,
803
- `historyID` int(11) NOT NULL,
804
- `taskName` varchar(255) NOT NULL,
805
- `action` varchar(50) NOT NULL,
806
- `type` varchar(50) NOT NULL,
807
- `category` varchar(50) NOT NULL,
808
- `stage` varchar(255) NOT NULL,
809
- `status` varchar(255) NOT NULL,
810
- `finalStatus` varchar(50) DEFAULT NULL,
811
- `statusMsg` varchar(255) NOT NULL,
812
- `requestParams` text NOT NULL,
813
- `responseParams` longtext,
814
- `taskResults` text,
815
- `startTime` int(11) DEFAULT NULL,
816
- `endTime` int(11) NOT NULL,
817
- PRIMARY KEY (`ID`)
818
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
819
- ";
820
-
821
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
822
- dbDelta( $sql );
823
-
824
- add_option( "iwp_backup_table_version", $IWP_MMB_BACKUP_TABLE_VERSION);
825
- }*/
826
- // import iwp_client_backup_tasks option table array to row data.
827
-
828
-
829
  if (is_wp_error($result) || !$result) {
830
  return array(
831
  'error' => 'InfiniteWP Client plugin could not be updated.', 'error_code' => 'client_plugin_could_not_be_updated'
832
  );
833
- } else {
 
 
 
834
  return array(
835
  'success' => 'InfiniteWP Client plugin successfully updated.'
836
  );
184
  'backup_test_site' => 'iwp_mmb_backup_test_site',
185
  'ithemes_security_load' => 'iwp_mmb_ithemes_security_load',
186
  'get_seo_info' => 'iwp_mmb_yoast_get_seo_info',
187
+ 'save_seo_info' => 'iwp_mmb_yoast_save_seo_info',
188
+ 'fetch_activities_log' => 'iwp_mmb_fetch_activities_log'
189
  );
190
 
191
  add_action('rightnow_end', array( &$this, 'add_right_now_info' ));
629
  */
630
  function install() {
631
 
632
+ global $wpdb, $_wp_using_ext_object_cache, $current_user, $iwp_mmb_activities_log;
633
  $_wp_using_ext_object_cache = false;
634
 
635
  //delete plugin options, just in case
667
  delete_option('iwp_client_pageview_alerts');
668
 
669
  add_option('iwp_client_activate_key', sha1( rand(1, 99999). uniqid('', true) . get_option('siteurl') ) );
670
+
671
+ $iwp_mmb_activities_log->iwp_mmb_save_options_for_activity_log('install');
672
  }
673
 
674
  /**
732
  delete_option('iwp_client_pageview_alerts');
733
 
734
  delete_option('iwp_client_activate_key');
735
+ delete_option('iwp_client_all_themes_history');
736
+ delete_option('iwp_client_all_plugins_history');
737
+ delete_option('iwp_client_wp_version_old');
738
+ delete_option('is_save_activity_log');
739
  }
740
 
741
 
760
  */
761
  function update_client_plugin($params)
762
  {
763
+ global $iwp_mmb_activities_log;
764
  extract($params);
765
  if ($download_url) {
766
  @include_once ABSPATH . 'wp-admin/includes/file.php';
791
  ob_end_clean();
792
  @wp_update_plugins();
793
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
794
  if (is_wp_error($result) || !$result) {
795
  return array(
796
  'error' => 'InfiniteWP Client plugin could not be updated.', 'error_code' => 'client_plugin_could_not_be_updated'
797
  );
798
+ } else {
799
+
800
+ $iwp_mmb_activities_log->iwp_mmb_save_options_for_activity_log('update_client_plugin');
801
+
802
  return array(
803
  'success' => 'InfiniteWP Client plugin successfully updated.'
804
  );
init.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: InfiniteWP - Client
4
  Plugin URI: http://infinitewp.com/
5
  Description: This is the client plugin of InfiniteWP that communicates with the InfiniteWP Admin panel.
6
  Author: Revmakx
7
- Version: 1.5.1.3
8
  Author URI: http://www.revmakx.com
9
  */
10
  /************************************************************
@@ -28,7 +28,7 @@ if(basename($_SERVER['SCRIPT_FILENAME']) == "init.php"):
28
  exit;
29
  endif;
30
  if(!defined('IWP_MMB_CLIENT_VERSION'))
31
- define('IWP_MMB_CLIENT_VERSION', '1.5.1.3');
32
 
33
 
34
 
@@ -47,6 +47,7 @@ $iwp_mmb_plugin_url = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
47
 
48
  require_once("$iwp_mmb_plugin_dir/helper.class.php");
49
  require_once("$iwp_mmb_plugin_dir/core.class.php");
 
50
  require_once("$iwp_mmb_plugin_dir/stats.class.php");
51
  //require_once("$iwp_mmb_plugin_dir/backup.class.php");
52
  //require_once("$iwp_mmb_plugin_dir/backup.class.singlecall.php");
@@ -91,7 +92,7 @@ if( !function_exists ( 'iwp_mmb_filter_params' )) {
91
  if( !function_exists ('iwp_mmb_parse_request')) {
92
  function iwp_mmb_parse_request()
93
  {
94
- global $HTTP_RAW_POST_DATA;
95
  $HTTP_RAW_POST_DATA_LOCAL = NULL;
96
  $HTTP_RAW_POST_DATA_LOCAL = file_get_contents('php://input');
97
  if(empty($HTTP_RAW_POST_DATA_LOCAL)){
@@ -111,10 +112,14 @@ if( !function_exists ('iwp_mmb_parse_request')) {
111
  $unserialized_data['params'] = iwp_mmb_filter_params($unserialized_data['params']);
112
  }
113
 
114
- $iwp_action = $unserialized_data['iwp_action'];
115
- $params = $unserialized_data['params'];
116
- $id = $unserialized_data['id'];
117
- $signature = $unserialized_data['signature'];
 
 
 
 
118
  }
119
 
120
  if (isset($iwp_action)) {
@@ -126,7 +131,7 @@ if( !function_exists ('iwp_mmb_parse_request')) {
126
  error_reporting(E_ALL ^ E_NOTICE);
127
  @ini_set("display_errors", 1);
128
 
129
- iwp_mmb_create_backup_table();
130
 
131
  run_hash_change_process();
132
 
@@ -138,12 +143,14 @@ if( !function_exists ('iwp_mmb_parse_request')) {
138
  iwp_mmb_response(array('error' => 'Username <b>' . $params['username'] . '</b> does not have administrative access. Enter the correct username in the site options.', 'error_code' => 'username_does_not_have_administrative_access'), false);
139
 
140
  if ($action == 'add_site') {
 
141
  iwp_mmb_add_site($params);
142
  iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
143
  }
144
  if ($action == 'readd_site') {
145
- $params['id'] = $id;
146
- $params['signature'] = $signature;
 
147
  iwp_mmb_readd_site($params);
148
  iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
149
  }
@@ -207,7 +214,8 @@ if( !function_exists ('iwp_mmb_parse_request')) {
207
  global $_iwp_mmb_plugin_actions;
208
  $_iwp_mmb_plugin_actions[$action] = $params;
209
  }
210
-
 
211
  } else {
212
  iwp_mmb_response($auth, false);
213
  }
@@ -293,7 +301,7 @@ if( !function_exists ( 'iwp_mmb_response' )) {
293
  if( !function_exists ( 'iwp_mmb_add_site' )) {
294
  function iwp_mmb_add_site($params)
295
  {
296
- global $iwp_mmb_core;
297
  $num = extract($params);
298
 
299
  if ($num) {
@@ -320,6 +328,8 @@ if( !function_exists ( 'iwp_mmb_add_site' )) {
320
  }
321
 
322
  iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
 
 
323
  delete_option('iwp_client_activate_key');//iwp
324
  } else if ($verify == 0) {
325
  iwp_mmb_response(array('error' => 'Invalid message signature. Please contact us if you see this message often.', 'error_code' => 'iwp_mmb_add_site_invalid_message_signature'), false);
@@ -343,7 +353,8 @@ if( !function_exists ( 'iwp_mmb_add_site' )) {
343
  if(is_array($brand) && !empty($brand)){
344
  update_option('iwp_client_brand',$brand);
345
  }
346
-
 
347
  iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
348
  delete_option('iwp_client_activate_key');//IWP
349
  } else
@@ -360,7 +371,7 @@ if( !function_exists ( 'iwp_mmb_add_site' )) {
360
 
361
  if( !function_exists ( 'iwp_mmb_readd_site' )) {
362
  function iwp_mmb_readd_site($params){
363
- global $iwp_mmb_core;
364
  $num = extract($params);
365
  if ($num) {
366
  if (!get_option('iwp_client_action_message_id') && !get_option('iwp_client_public_key')) {
@@ -382,6 +393,8 @@ if( !function_exists ( 'iwp_mmb_readd_site' )) {
382
  if(isset($brand) && is_array($brand) && !empty($brand)){
383
  update_option('iwp_client_brand',$brand);
384
  }
 
 
385
  iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
386
  delete_option('iwp_client_activate_key');//iwp
387
  } else if ($verify == 0) {
@@ -406,7 +419,8 @@ if( !function_exists ( 'iwp_mmb_readd_site' )) {
406
  if(is_array($brand) && !empty($brand)){
407
  update_option('iwp_client_brand',$brand);
408
  }
409
-
 
410
  iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
411
  delete_option('iwp_client_activate_key');//IWP
412
  } else
@@ -593,7 +607,6 @@ if( !function_exists ( 'iwp_mmb_scheduled_backup' )) {
593
  function iwp_mmb_scheduled_backup($params)
594
  {
595
  global $iwp_mmb_core;
596
-
597
  $iwp_mmb_core->get_backup_instance($params['mechanism']);
598
  $return = $iwp_mmb_core->backup_instance->set_backup_task($params);
599
  iwp_mmb_response($return, $return);
@@ -1694,13 +1707,73 @@ if(!function_exists('iwp_mmb_convert_data')){
1694
  }
1695
  }
1696
 
1697
- if(!function_exists('iwp_mmb_alter_backup_table')){
1698
- function iwp_mmb_alter_backup_table(){
1699
  $IWP_MMB_BACKUP_TABLE_VERSION = iwp_mmb_get_site_option('iwp_backup_table_version');
1700
-
1701
- if(version_compare($IWP_MMB_BACKUP_TABLE_VERSION, '1.1.2') != -1){
1702
- return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1703
  }
 
 
 
 
 
1704
  global $wpdb;
1705
  if(method_exists($wpdb, 'get_charset_collate')){
1706
  $charset_collate = $wpdb->get_charset_collate();
@@ -1764,55 +1837,20 @@ if(!function_exists('iwp_mmb_alter_backup_table')){
1764
  }
1765
  }
1766
 
1767
- if(!function_exists('iwp_mmb_create_backup_table')){
1768
- function iwp_mmb_create_backup_table(){
1769
  global $wpdb;
1770
- if(method_exists($wpdb, 'get_charset_collate')){
1771
- $charset_collate = $wpdb->get_charset_collate();
1772
- }
1773
-
1774
- $IWP_MMB_BACKUP_TABLE_VERSION = iwp_mmb_get_site_option('iwp_backup_table_version');
1775
- $table_name = $wpdb->base_prefix . "iwp_backup_status";
1776
-
1777
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name){
1778
- if (!empty($charset_collate)){
1779
- $cachecollation = $charset_collate;
1780
- }
1781
- else{
1782
- $cachecollation = ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci ';
1783
- }
1784
-
1785
- $sql = "
1786
- CREATE TABLE IF NOT EXISTS $table_name (
1787
- `ID` int(11) NOT NULL AUTO_INCREMENT,
1788
- `historyID` int(11) NOT NULL,
1789
- `taskName` varchar(255) NOT NULL,
1790
- `action` varchar(50) NOT NULL,
1791
- `type` varchar(50) NOT NULL,
1792
- `category` varchar(50) NOT NULL,
1793
- `stage` varchar(255) NOT NULL,
1794
- `status` varchar(255) NOT NULL,
1795
- `finalStatus` varchar(50) DEFAULT NULL,
1796
- `statusMsg` varchar(255) NOT NULL,
1797
- `requestParams` text NOT NULL,
1798
- `responseParams` longtext,
1799
- `taskResults` text,
1800
- `startTime` int(11) DEFAULT NULL,
1801
- `endTime` int(11) NOT NULL,
1802
- PRIMARY KEY (`ID`)
1803
- )".$cachecollation." ;
1804
- ";
1805
-
1806
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1807
- dbDelta( $sql );
1808
-
1809
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) {
1810
- update_option( "iwp_backup_table_version", '1.1.1');
1811
- }
1812
  }
1813
- else if(version_compare($IWP_MMB_BACKUP_TABLE_VERSION, '1.1.1') == -1){
1814
- iwp_mmb_alter_backup_table();
 
 
1815
  }
 
1816
  }
1817
  }
1818
 
@@ -1881,7 +1919,9 @@ if( !function_exists('iwp_mmb_backup_test_site')){
1881
  //register_activation_hook( __FILE__, 'iwp_mmb_create_backup_table' );
1882
 
1883
  $iwp_mmb_core = new IWP_MMB_Core();
 
1884
  $mmb_core = 1;
 
1885
 
1886
  if(isset($_GET['auto_login']))
1887
  $iwp_mmb_core->automatic_login();
@@ -2095,6 +2135,4 @@ if(!function_exists('iwp_mmb_get_site_option')) {
2095
  if ( !get_option('iwp_client_public_key') && function_exists('add_action')){
2096
  add_action('admin_enqueue_scripts', 'iwp_mmb_add_zero_clipboard_scripts');
2097
  }
2098
-
2099
-
2100
  ?>
4
  Plugin URI: http://infinitewp.com/
5
  Description: This is the client plugin of InfiniteWP that communicates with the InfiniteWP Admin panel.
6
  Author: Revmakx
7
+ Version: 1.6.0
8
  Author URI: http://www.revmakx.com
9
  */
10
  /************************************************************
28
  exit;
29
  endif;
30
  if(!defined('IWP_MMB_CLIENT_VERSION'))
31
+ define('IWP_MMB_CLIENT_VERSION', '1.6.0');
32
 
33
 
34
 
47
 
48
  require_once("$iwp_mmb_plugin_dir/helper.class.php");
49
  require_once("$iwp_mmb_plugin_dir/core.class.php");
50
+ require_once("$iwp_mmb_plugin_dir/activities_log.class.php");
51
  require_once("$iwp_mmb_plugin_dir/stats.class.php");
52
  //require_once("$iwp_mmb_plugin_dir/backup.class.php");
53
  //require_once("$iwp_mmb_plugin_dir/backup.class.singlecall.php");
92
  if( !function_exists ('iwp_mmb_parse_request')) {
93
  function iwp_mmb_parse_request()
94
  {
95
+ global $HTTP_RAW_POST_DATA, $iwp_mmb_activities_log;
96
  $HTTP_RAW_POST_DATA_LOCAL = NULL;
97
  $HTTP_RAW_POST_DATA_LOCAL = file_get_contents('php://input');
98
  if(empty($HTTP_RAW_POST_DATA_LOCAL)){
112
  $unserialized_data['params'] = iwp_mmb_filter_params($unserialized_data['params']);
113
  }
114
 
115
+ $iwp_action = $unserialized_data['iwp_action'];
116
+ $params = $unserialized_data['params'];
117
+ $id = $unserialized_data['id'];
118
+ $signature = $unserialized_data['signature'];
119
+ if(isset($unserialized_data['is_save_activity_log'])) {
120
+ $is_save_activity_log = $unserialized_data['is_save_activity_log'];
121
+ }
122
+ $GLOBALS['activities_log_datetime'] = $unserialized_data['activities_log_datetime'];
123
  }
124
 
125
  if (isset($iwp_action)) {
131
  error_reporting(E_ALL ^ E_NOTICE);
132
  @ini_set("display_errors", 1);
133
 
134
+ iwp_mmb_backup_db_changes();
135
 
136
  run_hash_change_process();
137
 
143
  iwp_mmb_response(array('error' => 'Username <b>' . $params['username'] . '</b> does not have administrative access. Enter the correct username in the site options.', 'error_code' => 'username_does_not_have_administrative_access'), false);
144
 
145
  if ($action == 'add_site') {
146
+ $params['is_save_activity_log'] = $is_save_activity_log;
147
  iwp_mmb_add_site($params);
148
  iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
149
  }
150
  if ($action == 'readd_site') {
151
+ $params['id'] = $id;
152
+ $params['signature'] = $signature;
153
+ $params['is_save_activity_log'] = $is_save_activity_log;
154
  iwp_mmb_readd_site($params);
155
  iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
156
  }
214
  global $_iwp_mmb_plugin_actions;
215
  $_iwp_mmb_plugin_actions[$action] = $params;
216
  }
217
+ $iwp_mmb_activities_log->iwp_mmb_update_is_save_activity_log($is_save_activity_log);
218
+ $iwp_mmb_activities_log->iwp_mmb_save_options_for_activity_log('parse_request');
219
  } else {
220
  iwp_mmb_response($auth, false);
221
  }
301
  if( !function_exists ( 'iwp_mmb_add_site' )) {
302
  function iwp_mmb_add_site($params)
303
  {
304
+ global $iwp_mmb_core, $iwp_mmb_activities_log;
305
  $num = extract($params);
306
 
307
  if ($num) {
328
  }
329
 
330
  iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
331
+ $iwp_mmb_activities_log->iwp_mmb_update_is_save_activity_log($params['is_save_activity_log']);
332
+ $iwp_mmb_activities_log->iwp_mmb_save_options_for_activity_log('add_site');
333
  delete_option('iwp_client_activate_key');//iwp
334
  } else if ($verify == 0) {
335
  iwp_mmb_response(array('error' => 'Invalid message signature. Please contact us if you see this message often.', 'error_code' => 'iwp_mmb_add_site_invalid_message_signature'), false);
353
  if(is_array($brand) && !empty($brand)){
354
  update_option('iwp_client_brand',$brand);
355
  }
356
+ $iwp_mmb_activities_log->iwp_mmb_update_is_save_activity_log($params['is_save_activity_log']);
357
+ $iwp_mmb_activities_log->iwp_mmb_save_options_for_activity_log('add_site');
358
  iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
359
  delete_option('iwp_client_activate_key');//IWP
360
  } else
371
 
372
  if( !function_exists ( 'iwp_mmb_readd_site' )) {
373
  function iwp_mmb_readd_site($params){
374
+ global $iwp_mmb_core,$iwp_mmb_activities_log;
375
  $num = extract($params);
376
  if ($num) {
377
  if (!get_option('iwp_client_action_message_id') && !get_option('iwp_client_public_key')) {
393
  if(isset($brand) && is_array($brand) && !empty($brand)){
394
  update_option('iwp_client_brand',$brand);
395
  }
396
+ $iwp_mmb_activities_log->iwp_mmb_update_is_save_activity_log($params['is_save_activity_log']);
397
+ $iwp_mmb_activities_log->iwp_mmb_save_options_for_activity_log('readd_site');
398
  iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
399
  delete_option('iwp_client_activate_key');//iwp
400
  } else if ($verify == 0) {
419
  if(is_array($brand) && !empty($brand)){
420
  update_option('iwp_client_brand',$brand);
421
  }
422
+ $iwp_mmb_activities_log->iwp_mmb_update_is_save_activity_log($params['is_save_activity_log']);
423
+ $iwp_mmb_activities_log->iwp_mmb_save_options_for_activity_log('readd_site');
424
  iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
425
  delete_option('iwp_client_activate_key');//IWP
426
  } else
607
  function iwp_mmb_scheduled_backup($params)
608
  {
609
  global $iwp_mmb_core;
 
610
  $iwp_mmb_core->get_backup_instance($params['mechanism']);
611
  $return = $iwp_mmb_core->backup_instance->set_backup_task($params);
612
  iwp_mmb_response($return, $return);
1707
  }
1708
  }
1709
 
1710
+ if (!function_exists('iwp_mmb_backup_db_changes')) {
1711
+ function iwp_mmb_backup_db_changes(){
1712
  $IWP_MMB_BACKUP_TABLE_VERSION = iwp_mmb_get_site_option('iwp_backup_table_version');
1713
+ if (empty($IWP_MMB_BACKUP_TABLE_VERSION) || $IWP_MMB_BACKUP_TABLE_VERSION == false ) {
1714
+ iwp_mmb_create_backup_status_table();
1715
+ }
1716
+ if(version_compare(iwp_mmb_get_site_option('iwp_backup_table_version'), '1.1.2', '<')){
1717
+ iwp_mmb_change_collation_backup_status_table();
1718
+ }
1719
+ if(version_compare(iwp_mmb_get_site_option('iwp_backup_table_version'), '1.1.3', '<')){
1720
+ iwp_mmb_add_lastUpdateTime_column_backup_status_table();
1721
+ }
1722
+ }
1723
+ }
1724
+
1725
+ if(!function_exists('iwp_mmb_create_backup_status_table')){
1726
+ //write new backup_status_table changes also in this function.
1727
+ function iwp_mmb_create_backup_status_table(){
1728
+ global $wpdb;
1729
+ if(method_exists($wpdb, 'get_charset_collate')){
1730
+ $charset_collate = $wpdb->get_charset_collate();
1731
+ }
1732
+
1733
+ $table_name = $wpdb->base_prefix . "iwp_backup_status";
1734
+
1735
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name){
1736
+ if (!empty($charset_collate)){
1737
+ $cachecollation = $charset_collate;
1738
+ }
1739
+ else{
1740
+ $cachecollation = ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci ';
1741
+ }
1742
+
1743
+ $sql = "
1744
+ CREATE TABLE IF NOT EXISTS $table_name (
1745
+ `ID` int(11) NOT NULL AUTO_INCREMENT,
1746
+ `historyID` int(11) NOT NULL,
1747
+ `taskName` varchar(255) NOT NULL,
1748
+ `action` varchar(50) NOT NULL,
1749
+ `type` varchar(50) NOT NULL,
1750
+ `category` varchar(50) NOT NULL,
1751
+ `stage` varchar(255) NOT NULL,
1752
+ `status` varchar(255) NOT NULL,
1753
+ `finalStatus` varchar(50) DEFAULT NULL,
1754
+ `statusMsg` varchar(255) NOT NULL,
1755
+ `requestParams` text NOT NULL,
1756
+ `responseParams` longtext,
1757
+ `taskResults` text,
1758
+ `startTime` int(11) DEFAULT NULL,
1759
+ `lastUpdateTime` int(10) unsigned DEFAULT NULL,
1760
+ `endTime` int(11) NOT NULL,
1761
+ PRIMARY KEY (`ID`)
1762
+ )".$cachecollation." ;
1763
+ ";
1764
+
1765
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1766
+ dbDelta( $sql );
1767
+
1768
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) {
1769
+ update_option( "iwp_backup_table_version", '1.1.3');
1770
+ }
1771
  }
1772
+ }
1773
+ }
1774
+
1775
+ if(!function_exists('iwp_mmb_change_collation_backup_status_table')){
1776
+ function iwp_mmb_change_collation_backup_status_table(){
1777
  global $wpdb;
1778
  if(method_exists($wpdb, 'get_charset_collate')){
1779
  $charset_collate = $wpdb->get_charset_collate();
1837
  }
1838
  }
1839
 
1840
+ if(!function_exists('iwp_mmb_add_lastUpdateTime_column_backup_status_table')){
1841
+ function iwp_mmb_add_lastUpdateTime_column_backup_status_table(){
1842
  global $wpdb;
1843
+ $table_name = $wpdb->base_prefix . "iwp_backup_status";
1844
+ if($wpdb->get_var("SHOW COLUMNS FROM `$table_name` WHERE Field = 'lastUpdateTime'")){
1845
+ update_option( "iwp_backup_table_version", '1.1.3');
1846
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1847
  }
1848
+ $sql = "ALTER TABLE ".$table_name." ADD `lastUpdateTime` INT(10) UNSIGNED NULL;";
1849
+ $isDone = $wpdb->query($sql);
1850
+ if ($isDone) {
1851
+ update_option( "iwp_backup_table_version", '1.1.3');
1852
  }
1853
+
1854
  }
1855
  }
1856
 
1919
  //register_activation_hook( __FILE__, 'iwp_mmb_create_backup_table' );
1920
 
1921
  $iwp_mmb_core = new IWP_MMB_Core();
1922
+ $GLOBALS['iwp_mmb_activities_log'] = new IWP_MMB_Activities_log();
1923
  $mmb_core = 1;
1924
+ $GLOBALS['iwp_activities_log_post_type'] = 'iwp_log';
1925
 
1926
  if(isset($_GET['auto_login']))
1927
  $iwp_mmb_core->automatic_login();
2135
  if ( !get_option('iwp_client_public_key') && function_exists('add_action')){
2136
  add_action('admin_enqueue_scripts', 'iwp_mmb_add_zero_clipboard_scripts');
2137
  }
 
 
2138
  ?>
installer.class.php CHANGED
@@ -162,6 +162,8 @@ class IWP_MMB_Installer extends IWP_MMB_Core
162
 
163
  function do_upgrade($params = null)
164
  {
 
 
165
  if ($params == null || empty($params))
166
  return array(
167
  'error' => 'No upgrades passed.', 'error_code' => 'no_upgrades_passed'
@@ -181,38 +183,57 @@ class IWP_MMB_Installer extends IWP_MMB_Core
181
  $upgrade_translations = isset($params['upgrade_translations']) ? $params['upgrade_translations'] : array();
182
  $upgrades = array();
183
  $premium_upgrades = array();
 
 
 
 
 
 
 
 
 
 
 
 
184
  if (!empty($core_upgrade)) {
185
- $upgrades['core'] = $this->upgrade_core($core_upgrade);
 
186
  }
187
  if (!empty($upgrade_plugins)) {
188
- $plugin_files = array();
189
  foreach ($upgrade_plugins as $plugin) {
190
- if (isset($plugin->file))
 
191
  $plugin_files[$plugin->file] = $plugin->old_version;
192
- else
 
193
  $premium_upgrades[md5($plugin->name)] = $plugin;
 
 
 
 
194
  }
195
- if (!empty($plugin_files))
196
- $upgrades['plugins'] = $this->upgrade_plugins($plugin_files);
197
-
198
  }
199
 
200
  if (!empty($upgrade_themes)) {
201
- $theme_temps = array();
202
  foreach ($upgrade_themes as $theme) {
203
- if (isset($theme['theme_tmp']))
 
204
  $theme_temps[] = $theme['theme_tmp'];
205
- else
 
206
  $premium_upgrades[md5($theme['name'])] = $theme;
 
207
  }
208
 
209
  if (!empty($theme_temps))
210
- $upgrades['themes'] = $this->upgrade_themes($theme_temps);
211
 
212
  }
213
 
214
  if (!empty($premium_upgrades)) {
215
- $premium_upgrades = $this->upgrade_premium($premium_upgrades);
216
  if (!empty($premium_upgrades)) {
217
  if (!empty($upgrades)) {
218
  foreach ($upgrades as $key => $val) {
@@ -226,7 +247,7 @@ class IWP_MMB_Installer extends IWP_MMB_Core
226
  }
227
  }
228
  if (!empty($upgrade_translations)) {
229
- $upgrades['translations'] = $this->upgrade_translations($upgrade_translations);
230
  }
231
  ob_clean();
232
  $this->iwp_mmb_maintenance_mode(false);
@@ -237,10 +258,9 @@ class IWP_MMB_Installer extends IWP_MMB_Core
237
  * Upgrades WordPress locally
238
  *
239
  */
240
-
241
-
242
-
243
- function upgrade_translations($current){
244
  include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
245
  $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
246
  $result = $upgrader->bulk_upgrade();
@@ -254,6 +274,8 @@ class IWP_MMB_Installer extends IWP_MMB_Core
254
  }
255
  }
256
  if(!$upgradeFailed){
 
 
257
  $return = 'updated';
258
  }
259
  return array('upgraded' => $return);
@@ -264,9 +286,11 @@ class IWP_MMB_Installer extends IWP_MMB_Core
264
  }
265
  }
266
 
267
- function upgrade_core($current)
268
  {
 
269
  ob_start();
 
270
  if (!function_exists('wp_version_check') || !function_exists('get_core_checksums'))
271
  include_once(ABSPATH . '/wp-admin/includes/update.php');
272
 
@@ -326,11 +350,12 @@ class IWP_MMB_Installer extends IWP_MMB_Core
326
  return array(
327
  'error' => $this->iwp_mmb_get_error($result), 'error_code' => 'maintenance_mode_upgrade_core'
328
  );
329
- } else
 
330
  return array(
331
  'upgraded' => 'updated'
332
  );
333
-
334
  } else {
335
  if (!class_exists('WP_Upgrader')) {
336
  include_once(ABSPATH . 'wp-admin/includes/update.php');
@@ -340,10 +365,12 @@ class IWP_MMB_Installer extends IWP_MMB_Core
340
  return array(
341
  'error' => $this->iwp_mmb_get_error($result), 'error_code' => 'wp_update_core_upgrade_core'
342
  );
343
- } else
 
344
  return array(
345
  'upgraded' => 'updated'
346
  );
 
347
  }
348
  }
349
 
@@ -409,6 +436,7 @@ class IWP_MMB_Installer extends IWP_MMB_Core
409
  'error' => $this->iwp_mmb_get_error($update_core), 'error_code' => 'upgrade_core_wp_error'
410
  );
411
  ob_end_flush();
 
412
  return array(
413
  'upgraded' => 'updated'
414
  );
@@ -425,13 +453,13 @@ class IWP_MMB_Installer extends IWP_MMB_Core
425
  }
426
  }
427
 
428
- function upgrade_plugins($plugins = false)
429
  {
 
430
  if (!$plugins || empty($plugins))
431
  return array(
432
  'error' => 'No plugin files for upgrade.', 'error_code' => 'no_plugin_files_for_upgrade'
433
- );
434
-
435
  $current = $this->iwp_mmb_get_transient('update_plugins');
436
  $versions = array();
437
  if(!empty($current)){
@@ -445,17 +473,67 @@ class IWP_MMB_Installer extends IWP_MMB_Core
445
  if (class_exists('Plugin_Upgrader') && class_exists('Bulk_Plugin_Upgrader_Skin')) {
446
  $upgrader = new Plugin_Upgrader(new Bulk_Plugin_Upgrader_Skin(compact('nonce', 'url')));
447
  $result = $upgrader->bulk_upgrade(array_keys($plugins));
 
448
  if (!function_exists('wp_update_plugins'))
449
  include_once(ABSPATH . 'wp-includes/update.php');
450
 
451
  @wp_update_plugins();
452
  $current = $this->iwp_mmb_get_transient('update_plugins');
 
453
  if (!empty($result)) {
454
  foreach ($result as $plugin_slug => $plugin_info) {
455
  if (!$plugin_info || is_wp_error($plugin_info)) {
456
  $return[$plugin_slug] = array('error' => $this->iwp_mmb_get_error($plugin_info), 'error_code' => 'upgrade_plugins_wp_error');
457
  } else {
458
- if(!empty($result[$plugin_slug]) || (isset($current->checked[$plugin_slug]) && version_compare(array_search($plugin_slug, $versions), $current->checked[$plugin_slug], '<') == true)){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
459
  $return[$plugin_slug] = 1;
460
  } else {
461
  update_option('iwp_client_forcerefresh', true);
@@ -479,8 +557,9 @@ class IWP_MMB_Installer extends IWP_MMB_Core
479
  }
480
  }
481
 
482
- function upgrade_themes($themes = false)
483
  {
 
484
  if (!$themes || empty($themes))
485
  return array(
486
  'error' => 'No theme files for upgrade.', 'error_code' => 'no_theme_files_for_upgrade'
@@ -511,6 +590,17 @@ class IWP_MMB_Installer extends IWP_MMB_Core
511
  $return[$theme_tmp] = array('error' => $this->iwp_mmb_get_error($theme_info), 'error_code' => 'upgrade_themes_wp_error');
512
  } else {
513
  if(!empty($result[$theme_tmp]) || (isset($current->checked[$theme_tmp]) && version_compare(array_search($theme_tmp, $versions), $current->checked[$theme_tmp], '<') == true)){
 
 
 
 
 
 
 
 
 
 
 
514
  $return[$theme_tmp] = 1;
515
  } else {
516
  update_option('iwp_client_forcerefresh', true);
@@ -533,7 +623,7 @@ class IWP_MMB_Installer extends IWP_MMB_Core
533
  }
534
  }
535
 
536
- function upgrade_premium($premium = false)
537
  {
538
  global $iwp_mmb_plugin_url;
539
 
@@ -579,7 +669,7 @@ class IWP_MMB_Installer extends IWP_MMB_Core
579
 
580
  // try default wordpress upgrader
581
  if(!empty($plugins)){
582
- $updateplugins = $this->upgrade_plugins($plugins);
583
  if(!empty($updateplugins) && isset($updateplugins['upgraded'])){
584
  foreach ($premium_update as $key => $update) {
585
  $update = array_change_key_case($update, CASE_LOWER);
@@ -596,7 +686,7 @@ class IWP_MMB_Installer extends IWP_MMB_Core
596
  }
597
 
598
  if(!empty($themes)){
599
- $updatethemes = $this->upgrade_themes(array_keys($themes));
600
  if(!empty($updatethemes) && isset($updatethemes['upgraded'])){
601
  foreach ($premium_update as $key => $update) {
602
  $update = array_change_key_case($update, CASE_LOWER);
@@ -613,43 +703,43 @@ class IWP_MMB_Installer extends IWP_MMB_Core
613
  }
614
 
615
  //try direct install with overwrite
616
- if (!empty($premium_update)) {
617
  foreach ($premium_update as $update) {
618
  $update = array_change_key_case($update, CASE_LOWER);
619
- $update_result = false;
620
- if (isset($update['url'])) {
621
- if (defined('WP_INSTALLING') && file_exists(ABSPATH . '.maintenance'))
622
- $pr_update[$update['type'] . 's']['upgraded'][md5($update['name'])] = 'Site under maintanace.';
623
-
624
- $upgrader_skin = new WP_Upgrader_Skin();
625
- $upgrader_skin->done_header = true;
626
- $upgrader = new WP_Upgrader();
627
- @$update_result = $upgrader->run(array(
628
- 'package' => $update['url'],
629
- 'destination' => isset($update['type']) && $update['type'] == 'theme' ? WP_CONTENT_DIR . '/themes' : WP_PLUGIN_DIR,
630
- 'clear_destination' => true,
631
- 'clear_working' => true,
632
- 'is_multi' => true,
633
- 'hook_extra' => array()
634
- ));
635
- $update_result = !$update_result || is_wp_error($update_result) ? $this->iwp_mmb_get_error($update_result) : 1;
636
-
637
- } else if (isset($update['callback'])) {
638
- if (is_array($update['callback'])) {
639
- $update_result = call_user_func(array( $update['callback'][0], $update['callback'][1] ));
640
- } else if (is_string($update['callback'])) {
641
- $update_result = call_user_func($update['callback']);
642
- } else {
643
- $update_result = array('error' => 'Upgrade function "' . $update['callback'] . '" does not exists.', 'error_code' => 'upgrade_func_callback_does_not_exists');
644
- }
645
-
646
- $update_result = $update_result !== true ? array('error' => $this->iwp_mmb_get_error($update_result), 'error_code' => 'upgrade_premium_wp_error') : 1;
647
- } else
648
- $update_result = array('error' => 'Bad update params.', 'error_code' => 'bad_update_params');
649
-
650
- $pr_update[$update['type'] . 's']['upgraded'][md5($update['name'])] = $update_result;
651
- }
652
  }
 
653
  return $pr_update;
654
  } else {
655
  foreach ($premium as $pr) {
@@ -721,7 +811,7 @@ class IWP_MMB_Installer extends IWP_MMB_Core
721
  continue;
722
  }
723
 
724
- if (!$theme_data->parent()) {
725
  foreach ($current->response as $current_themes => $theme) {
726
  if ($theme_data->Template == $current_themes) {
727
  if (strlen($theme_data->Name) > 0 && strlen($theme_data->Version) > 0) {
@@ -753,22 +843,23 @@ class IWP_MMB_Installer extends IWP_MMB_Core
753
  if (isset($theme_data['Name']) && in_array($theme_data['Name'], $filter)) {
754
  continue;
755
  }
756
- if (!$theme_data->parent()) {
757
- foreach ($current->response as $current_themes => $theme) {
758
- if ($theme_data['Template'] == $current_themes) {
759
- if (strlen($theme_data['Name']) > 0 && strlen($theme_data['Version']) > 0) {
760
- $current->response[$current_themes]['name'] = $theme_data['Name'];
761
- $current->response[$current_themes]['old_version'] = $theme_data['Version'];
762
- $current->response[$current_themes]['theme_tmp'] = $theme_data['Template'];
763
- $upgrade_themes[] = $current->response[$current_themes];
764
- }
765
- }
766
- }
767
- }
768
- }
769
- }
 
770
 
771
- }
772
 
773
  return $upgrade_themes;
774
  }
162
 
163
  function do_upgrade($params = null)
164
  {
165
+ global $iwp_mmb_activities_log;
166
+
167
  if ($params == null || empty($params))
168
  return array(
169
  'error' => 'No upgrades passed.', 'error_code' => 'no_upgrades_passed'
183
  $upgrade_translations = isset($params['upgrade_translations']) ? $params['upgrade_translations'] : array();
184
  $upgrades = array();
185
  $premium_upgrades = array();
186
+ $user = get_user_by( 'login', $params['username'] );
187
+ $userid = $user->data->ID;
188
+
189
+ if (!empty($core_upgrade) || !empty($upgrade_plugins) || !empty($upgrade_themes) || !empty($upgrade_translations)) {
190
+ $iwp_mmb_activities_log->iwp_mmb_do_remove_upgrader_process_complete_action();
191
+ $iwp_mmb_activities_log->iwp_mmb_do_remove_theme_filters();
192
+ $iwp_mmb_activities_log->iwp_mmb_do_remove_upgrader_post_install_filter();
193
+ }
194
+ if (!empty($core_upgrade) || !empty($upgrade_plugins) || !empty($upgrade_themes)) {
195
+ $GLOBALS['iwp_client_plugin_ptc_updates'] = 1;
196
+ }
197
+
198
  if (!empty($core_upgrade)) {
199
+ $iwp_mmb_activities_log->iwp_mmb_do_remove_core_updated_successfully();
200
+ $upgrades['core'] = $this->upgrade_core($core_upgrade,$userid);
201
  }
202
  if (!empty($upgrade_plugins)) {
203
+ $plugin_files = $plugin_details = $premium_plugin_details = array();
204
  foreach ($upgrade_plugins as $plugin) {
205
+ if (isset($plugin->file)) {
206
+ $plugin_details[] = $plugin;
207
  $plugin_files[$plugin->file] = $plugin->old_version;
208
+ } else {
209
+ $premium_plugin_details[] = $plugin;
210
  $premium_upgrades[md5($plugin->name)] = $plugin;
211
+ }
212
+ }
213
+ if (!empty($plugin_files)) {
214
+ $upgrades['plugins'] = $this->upgrade_plugins($plugin_files,$plugin_details,$userid);
215
  }
 
 
 
216
  }
217
 
218
  if (!empty($upgrade_themes)) {
219
+ $theme_temps = $theme_details = $premium_theme_details = array();
220
  foreach ($upgrade_themes as $theme) {
221
+ if (isset($theme['theme_tmp'])) {
222
+ $theme_details[] = $theme;
223
  $theme_temps[] = $theme['theme_tmp'];
224
+ } else {
225
+ $premium_theme_details[] = $theme;
226
  $premium_upgrades[md5($theme['name'])] = $theme;
227
+ }
228
  }
229
 
230
  if (!empty($theme_temps))
231
+ $upgrades['themes'] = $this->upgrade_themes($theme_temps,$theme_details,$userid);
232
 
233
  }
234
 
235
  if (!empty($premium_upgrades)) {
236
+ $premium_upgrades = $this->upgrade_premium($premium_upgrades,$premium_plugin_details,$premium_theme_details,$userid);
237
  if (!empty($premium_upgrades)) {
238
  if (!empty($upgrades)) {
239
  foreach ($upgrades as $key => $val) {
247
  }
248
  }
249
  if (!empty($upgrade_translations)) {
250
+ $upgrades['translations'] = $this->upgrade_translations($upgrade_translations,$userid);
251
  }
252
  ob_clean();
253
  $this->iwp_mmb_maintenance_mode(false);
258
  * Upgrades WordPress locally
259
  *
260
  */
261
+ function upgrade_translations($current,$userid){
262
+ global $iwp_activities_log_post_type, $iwp_mmb_activities_log;
263
+ $GLOBALS['iwp_client_plugin_translations'] = 1;
 
264
  include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
265
  $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
266
  $result = $upgrader->bulk_upgrade();
274
  }
275
  }
276
  if(!$upgradeFailed){
277
+ $details = array();
278
+ $iwp_mmb_activities_log->iwp_mmb_save_iwp_activities('translations', 'update', $iwp_activities_log_post_type, (object)$details, $userid);
279
  $return = 'updated';
280
  }
281
  return array('upgraded' => $return);
286
  }
287
  }
288
 
289
+ function upgrade_core($current,$userid)
290
  {
291
+ global $iwp_activities_log_post_type, $iwp_mmb_activities_log;
292
  ob_start();
293
+
294
  if (!function_exists('wp_version_check') || !function_exists('get_core_checksums'))
295
  include_once(ABSPATH . '/wp-admin/includes/update.php');
296
 
350
  return array(
351
  'error' => $this->iwp_mmb_get_error($result), 'error_code' => 'maintenance_mode_upgrade_core'
352
  );
353
+ } else {
354
+ $iwp_mmb_activities_log->iwp_mmb_save_iwp_activities('core', 'update', $iwp_activities_log_post_type, $current, $userid);
355
  return array(
356
  'upgraded' => 'updated'
357
  );
358
+ }
359
  } else {
360
  if (!class_exists('WP_Upgrader')) {
361
  include_once(ABSPATH . 'wp-admin/includes/update.php');
365
  return array(
366
  'error' => $this->iwp_mmb_get_error($result), 'error_code' => 'wp_update_core_upgrade_core'
367
  );
368
+ } else {
369
+ $iwp_mmb_activities_log->iwp_mmb_save_iwp_activities('core', 'update', $iwp_activities_log_post_type, $current, $userid);
370
  return array(
371
  'upgraded' => 'updated'
372
  );
373
+ }
374
  }
375
  }
376
 
436
  'error' => $this->iwp_mmb_get_error($update_core), 'error_code' => 'upgrade_core_wp_error'
437
  );
438
  ob_end_flush();
439
+ $iwp_mmb_activities_log->iwp_mmb_save_iwp_activities('core', 'update', $iwp_activities_log_post_type, $current, $userid);
440
  return array(
441
  'upgraded' => 'updated'
442
  );
453
  }
454
  }
455
 
456
+ function upgrade_plugins($plugins = false,$plugin_details = false,$userid)
457
  {
458
+ global $iwp_activities_log_post_type, $iwp_mmb_activities_log;
459
  if (!$plugins || empty($plugins))
460
  return array(
461
  'error' => 'No plugin files for upgrade.', 'error_code' => 'no_plugin_files_for_upgrade'
462
+ );
 
463
  $current = $this->iwp_mmb_get_transient('update_plugins');
464
  $versions = array();
465
  if(!empty($current)){
473
  if (class_exists('Plugin_Upgrader') && class_exists('Bulk_Plugin_Upgrader_Skin')) {
474
  $upgrader = new Plugin_Upgrader(new Bulk_Plugin_Upgrader_Skin(compact('nonce', 'url')));
475
  $result = $upgrader->bulk_upgrade(array_keys($plugins));
476
+
477
  if (!function_exists('wp_update_plugins'))
478
  include_once(ABSPATH . 'wp-includes/update.php');
479
 
480
  @wp_update_plugins();
481
  $current = $this->iwp_mmb_get_transient('update_plugins');
482
+
483
  if (!empty($result)) {
484
  foreach ($result as $plugin_slug => $plugin_info) {
485
  if (!$plugin_info || is_wp_error($plugin_info)) {
486
  $return[$plugin_slug] = array('error' => $this->iwp_mmb_get_error($plugin_info), 'error_code' => 'upgrade_plugins_wp_error');
487
  } else {
488
+ if(
489
+ !empty($result[$plugin_slug])
490
+ || (
491
+ isset($current->checked[$plugin_slug])
492
+ && version_compare(array_search($plugin_slug, $versions), $current->checked[$plugin_slug], '<') == true
493
+ )
494
+ ){
495
+ foreach($plugin_details as $key=>$plugin_detail) {
496
+ /* the following "if" is used to detect premium plugin properties.*/
497
+ if(is_array($plugin_detail)) {
498
+ $plugin_detail = (object) $plugin_detail;
499
+ }
500
+ /* the above "if" is used to detect premium plugin properties.*/
501
+
502
+ if(
503
+ (
504
+ isset($plugin_detail->plugin)
505
+ && $plugin_slug==$plugin_detail->plugin
506
+ )
507
+ || ( // This condition is used to detect premium plugin properties.
508
+ isset($plugin_detail->slug)
509
+ && $plugin_slug==$plugin_detail->slug
510
+ )
511
+ ) {
512
+ $current_plugin = array();
513
+ $current_plugin['name'] = isset($plugin_detail->name)?$plugin_detail->name:'';
514
+
515
+ if(isset($plugin_detail->textdomain)) { // this "if" is used to detect premium plugin properties.
516
+ $current_plugin['slug'] = $plugin_detail->textdomain;
517
+ } else if(isset($plugin_detail->slug)) {
518
+ $current_plugin['slug'] = $plugin_detail->slug;
519
+ } else {
520
+ $current_plugin['slug'] = '';
521
+ }
522
+
523
+ if(isset($plugin_detail->old_version)) {
524
+ $current_plugin['old_version'] = $plugin_detail->old_version;
525
+ } else if(isset($plugin_detail->version)) {
526
+ $current_plugin['old_version'] = $plugin_detail->version;
527
+ } else {
528
+ $current_plugin['old_version'] = '';
529
+ }
530
+
531
+ $current_plugin['updated_version'] = isset($plugin_detail->new_version) ? $plugin_detail->new_version : '';
532
+ $iwp_mmb_activities_log->iwp_mmb_save_iwp_activities('plugins', 'update', $iwp_activities_log_post_type, (object)$current_plugin, $userid);
533
+ unset($current_plugin);
534
+ break;
535
+ }
536
+ }
537
  $return[$plugin_slug] = 1;
538
  } else {
539
  update_option('iwp_client_forcerefresh', true);
557
  }
558
  }
559
 
560
+ function upgrade_themes($themes = false,$theme_details = false,$userid)
561
  {
562
+ global $iwp_activities_log_post_type, $iwp_mmb_activities_log;
563
  if (!$themes || empty($themes))
564
  return array(
565
  'error' => 'No theme files for upgrade.', 'error_code' => 'no_theme_files_for_upgrade'
590
  $return[$theme_tmp] = array('error' => $this->iwp_mmb_get_error($theme_info), 'error_code' => 'upgrade_themes_wp_error');
591
  } else {
592
  if(!empty($result[$theme_tmp]) || (isset($current->checked[$theme_tmp]) && version_compare(array_search($theme_tmp, $versions), $current->checked[$theme_tmp], '<') == true)){
593
+ foreach($theme_details as $key=>$theme_detail) {
594
+ if($theme_tmp==$theme_detail['theme_tmp']) {
595
+ $current_theme = array();
596
+ $current_theme['name'] = $current_theme['slug'] = $theme_detail['name']; // slug is used to get short description. Here theme name as slug.
597
+ $current_theme['old_version'] = $theme_detail['old_version'];
598
+ $current_theme['updated_version'] = $theme_detail['new_version'];
599
+ $iwp_mmb_activities_log->iwp_mmb_save_iwp_activities('themes', 'update', $iwp_activities_log_post_type, (object)$current_theme, $userid);
600
+ unset($current_theme);
601
+ break;
602
+ }
603
+ }
604
  $return[$theme_tmp] = 1;
605
  } else {
606
  update_option('iwp_client_forcerefresh', true);
623
  }
624
  }
625
 
626
+ function upgrade_premium($premium = false,$premium_plugin_details = false,$premium_theme_details = false,$userid)
627
  {
628
  global $iwp_mmb_plugin_url;
629
 
669
 
670
  // try default wordpress upgrader
671
  if(!empty($plugins)){
672
+ $updateplugins = $this->upgrade_plugins($plugins,$premium_plugin_details,$userid);
673
  if(!empty($updateplugins) && isset($updateplugins['upgraded'])){
674
  foreach ($premium_update as $key => $update) {
675
  $update = array_change_key_case($update, CASE_LOWER);
686
  }
687
 
688
  if(!empty($themes)){
689
+ $updatethemes = $this->upgrade_themes(array_keys($themes),$premium_theme_details,$userid);
690
  if(!empty($updatethemes) && isset($updatethemes['upgraded'])){
691
  foreach ($premium_update as $key => $update) {
692
  $update = array_change_key_case($update, CASE_LOWER);
703
  }
704
 
705
  //try direct install with overwrite
706
+ if (!empty($premium_update)) {
707
  foreach ($premium_update as $update) {
708
  $update = array_change_key_case($update, CASE_LOWER);
709
+ $update_result = false;
710
+ if (isset($update['url'])) {
711
+ if (defined('WP_INSTALLING') && file_exists(ABSPATH . '.maintenance'))
712
+ $pr_update[$update['type'] . 's']['upgraded'][md5($update['name'])] = 'Site under maintanace.';
713
+
714
+ $upgrader_skin = new WP_Upgrader_Skin();
715
+ $upgrader_skin->done_header = true;
716
+ $upgrader = new WP_Upgrader();
717
+ @$update_result = $upgrader->run(array(
718
+ 'package' => $update['url'],
719
+ 'destination' => isset($update['type']) && $update['type'] == 'theme' ? WP_CONTENT_DIR . '/themes' : WP_PLUGIN_DIR,
720
+ 'clear_destination' => true,
721
+ 'clear_working' => true,
722
+ 'is_multi' => true,
723
+ 'hook_extra' => array()
724
+ ));
725
+ $update_result = !$update_result || is_wp_error($update_result) ? $this->iwp_mmb_get_error($update_result) : 1;
726
+
727
+ } else if (isset($update['callback'])) {
728
+ if (is_array($update['callback'])) {
729
+ $update_result = call_user_func(array( $update['callback'][0], $update['callback'][1] ));
730
+ } else if (is_string($update['callback'])) {
731
+ $update_result = call_user_func($update['callback']);
732
+ } else {
733
+ $update_result = array('error' => 'Upgrade function "' . $update['callback'] . '" does not exists.', 'error_code' => 'upgrade_func_callback_does_not_exists');
734
+ }
735
+
736
+ $update_result = $update_result !== true ? array('error' => $this->iwp_mmb_get_error($update_result), 'error_code' => 'upgrade_premium_wp_error') : 1;
737
+ } else
738
+ $update_result = array('error' => 'Bad update params.', 'error_code' => 'bad_update_params');
739
+
740
+ $pr_update[$update['type'] . 's']['upgraded'][md5($update['name'])] = $update_result;
 
741
  }
742
+ }
743
  return $pr_update;
744
  } else {
745
  foreach ($premium as $pr) {
811
  continue;
812
  }
813
 
814
+ if (method_exists($theme_data,'parent') && !$theme_data->parent()) {
815
  foreach ($current->response as $current_themes => $theme) {
816
  if ($theme_data->Template == $current_themes) {
817
  if (strlen($theme_data->Name) > 0 && strlen($theme_data->Version) > 0) {
843
  if (isset($theme_data['Name']) && in_array($theme_data['Name'], $filter)) {
844
  continue;
845
  }
846
+
847
+ if (method_exists($theme_data,'parent') && !$theme_data->parent()) {
848
+ foreach ($current->response as $current_themes => $theme) {
849
+ if ($theme_data['Template'] == $current_themes) {
850
+ if (strlen($theme_data['Name']) > 0 && strlen($theme_data['Version']) > 0) {
851
+ $current->response[$current_themes]['name'] = $theme_data['Name'];
852
+ $current->response[$current_themes]['old_version'] = $theme_data['Version'];
853
+ $current->response[$current_themes]['theme_tmp'] = $theme_data['Template'];
854
+ $upgrade_themes[] = $current->response[$current_themes];
855
+ }
856
+ }
857
+ }
858
+ }
859
+ }
860
+ }
861
 
862
+ }
863
 
864
  return $upgrade_themes;
865
  }
readme.txt CHANGED
@@ -1,16 +1,16 @@
1
- === InfiniteWP Client ===
2
  Contributors: infinitewp
3
  Tags: admin, administration, amazon, api, authentication, automatic, dashboard, dropbox, events, integration, manage, multisite, multiple, notification, performance, s3, security, seo, stats, tracking, infinitewp, updates, backup, restore, iwp, infinite
4
  Requires at least: 3.1
5
- Tested up to: 4.4.2
6
- Stable tag: trunk
7
 
8
  Install this plugin on unlimited sites and manage them all from a central dashboard.
9
  This plugin communicates with your InfiniteWP Admin Panel.
10
 
11
  == Description ==
12
 
13
- [InfiniteWP](http://infinitewp.com/ "Manage Multiple WordPress") allows users to manage unlimited number of WordPress sites from their own server.
14
 
15
  Main features:
16
 
@@ -22,11 +22,11 @@ Main features:
22
  * Bulk Install plugins & themes in multiple sites at once
23
  * and more..
24
 
25
- Visit us at [InfiniteWP.com](http://infinitewp.com/ "Manage Multiple WordPress").
26
 
27
- Check out the [InfiniteWP Overview Video](http://www.youtube.com/watch?v=IOu7LdyPOSs) below.
28
 
29
- http://www.youtube.com/watch?v=IOu7LdyPOSs
30
 
31
  Credits: [Vladimir Prelovac](http://prelovac.com/vladimir) for his worker plugin on which the client plugin is being developed.
32
 
@@ -48,7 +48,12 @@ Credits: [Vladimir Prelovac](http://prelovac.com/vladimir) for his worker plugin
48
 
49
  == Changelog ==
50
 
51
- = 1.5.1.3 - Jun 1st 2016 =
 
 
 
 
 
52
  * Fix: "Unable to update File list table : Can’t DROP ‘thisFileName’; check that column/key exists" error would be thrown while taking Multi-call backups in the Multi-site WordPress environment.
53
 
54
  = 1.5.1.2 - May 18th 2016 =
1
+ === InfiniteWP Client ===
2
  Contributors: infinitewp
3
  Tags: admin, administration, amazon, api, authentication, automatic, dashboard, dropbox, events, integration, manage, multisite, multiple, notification, performance, s3, security, seo, stats, tracking, infinitewp, updates, backup, restore, iwp, infinite
4
  Requires at least: 3.1
5
+ Tested up to: 4.5.3
6
+ Stable tag: trunk
7
 
8
  Install this plugin on unlimited sites and manage them all from a central dashboard.
9
  This plugin communicates with your InfiniteWP Admin Panel.
10
 
11
  == Description ==
12
 
13
+ [InfiniteWP](https://infinitewp.com/ "Manage Multiple WordPress") allows users to manage unlimited number of WordPress sites from their own server.
14
 
15
  Main features:
16
 
22
  * Bulk Install plugins & themes in multiple sites at once
23
  * and more..
24
 
25
+ Visit us at [InfiniteWP.com](https://infinitewp.com/ "Manage Multiple WordPress").
26
 
27
+ Check out the [InfiniteWP Overview Video](https://youtu.be/8wOMewY2EBY) below.
28
 
29
+ https://youtu.be/8wOMewY2EBY
30
 
31
  Credits: [Vladimir Prelovac](http://prelovac.com/vladimir) for his worker plugin on which the client plugin is being developed.
32
 
48
 
49
  == Changelog ==
50
 
51
+ = 1.6.0 - June 27th 2016 =
52
+ * Feature: Activity log for updates and backups to be used in new version of client reporting beta will be saved and retrieved from the WP Admin instead of the IWP Admin Panel, provided the client reporting addon is active.
53
+ * Improvement: The code in the backup_status_table has been refactored.
54
+ * Fix: Failed backups with date “01 Jan 1970” were not cleared from the database.
55
+
56
+ = 1.5.1.3 - May 24th 2016 =
57
  * Fix: "Unable to update File list table : Can’t DROP ‘thisFileName’; check that column/key exists" error would be thrown while taking Multi-call backups in the Multi-site WordPress environment.
58
 
59
  = 1.5.1.2 - May 18th 2016 =