ManageWP Worker - Version 3.9.2

Version Description

Download this release

Release Info

Developer freediver
Plugin Icon 128x128 ManageWP Worker
Version 3.9.2
Comparing to
See all releases

Code changes from version 3.9.1 to 3.9.2

Files changed (8) hide show
  1. backup.class.php +30 -38
  2. core.class.php +31 -9
  3. helper.class.php +9 -9
  4. index.html +0 -0
  5. init.php +406 -346
  6. installer.class.php +120 -68
  7. stats.class.php +27 -21
  8. version +1 -1
backup.class.php CHANGED
@@ -19,31 +19,37 @@ class MMB_Backup extends MMB_Core
19
 
20
  function backup($args)
21
  {
22
-
23
  @ini_set('memory_limit', '300M');
24
- @set_time_limit(300);
25
- //type like manual, weekly, daily
26
- $type = $args['type'];
27
- //what like full or only db
28
- $what = $args['what'];
29
 
30
  if (trim($type) == '')
31
  $type = 'manual'; //default
 
32
  $sec_string = md5('mmb-worker');
33
  $file = "/$sec_string/mwp_backups";
34
- $file_path = WP_CONTENT_DIR . $file;
35
- @ini_set('memory_limit', '300M');
36
- @set_time_limit(300);
37
  if (!file_exists($file_path)) {
38
  if (!mkdir($file_path, 0755, true))
39
  return array(
40
  'error' => 'Permission denied, make sure you have write permission to wp-content folder.'
41
  );
42
  }
43
- file_put_contents($file_path . '/index.php', ''); //safe
44
-
 
 
 
 
 
 
 
 
 
45
  if (trim($what) == 'full') {
46
- //take wp-content backup
47
  $content_backup = $this->backup_wpcontent($type);
48
  if (array_key_exists('error',$content_backup)) {
49
  @unlink($content_backup['path']);
@@ -68,15 +74,8 @@ class MMB_Backup extends MMB_Core
68
  }
69
 
70
  include_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
71
-
72
- // Get previous backup in tmp
73
- $worker_options = get_option('mmb-worker');
74
- $tmp_file = WP_CONTENT_DIR . '/' . basename($worker_options['backups'][$type]['path']);
75
-
76
- if (rename($worker_options['backups'][$type]['path'], $tmp_file)) {
77
- @unlink($worker_options['backups'][$type]['path']);
78
- }
79
-
80
  //Prepare .zip file name
81
  $site_name = $this->remove_http(get_bloginfo('url'));
82
  $site_name = str_replace(array(
@@ -94,6 +93,7 @@ class MMB_Backup extends MMB_Core
94
  $archive = new PclZip($backup_file);
95
  }
96
 
 
97
  if (trim($what) == 'full') {
98
  $htaccess_path = ABSPATH . ".htaccess";
99
  $wp_config_path = ABSPATH . "wp-config.php";
@@ -103,11 +103,8 @@ class MMB_Backup extends MMB_Core
103
  $result = $this->mmb_exec($command);
104
  ob_get_clean();
105
  } else {
106
- $result = $archive->add($content_backup['path'], PCLZIP_OPT_REMOVE_ALL_PATH);
107
- $result = $archive->add($db_backup['path'], PCLZIP_OPT_REMOVE_ALL_PATH);
108
- $result = $archive->add($htaccess_path, PCLZIP_OPT_REMOVE_ALL_PATH);
109
- $result = $archive->add($wp_config_path, PCLZIP_OPT_REMOVE_ALL_PATH);
110
-
111
  }
112
 
113
  } elseif (trim($what) == 'db') {
@@ -123,21 +120,18 @@ class MMB_Backup extends MMB_Core
123
  }
124
 
125
  if (!$result) {
126
- if (rename($tmp_file, $worker_options['backups'][$type]['path'])) {
127
- @unlink($tmp_file);
128
- }
129
  return array(
130
  'error' => 'Backup failed. Cannot create backup zip file.'
131
  );
132
  }
133
 
134
- @unlink($tmp_file);
135
  @unlink($content_backup['path']);
136
  @unlink($db_backup['path']);
137
 
138
  $backup_url = WP_CONTENT_URL . $file . '/' . $site_name . '_' . $type . '_' . $what . '_' . date('Y-m-d') .'_'.$hash. '.zip';
139
-
140
  $worker_options = get_option('mmb-worker');
 
141
  //remove old file
142
  if ($worker_options['backups'][$type]['path'] != $backup_file) {
143
  @unlink($worker_options['backups'][$type]['path']);
@@ -160,7 +154,6 @@ class MMB_Backup extends MMB_Core
160
  $content_dir = $content_dir[(count($content_dir)-1)];
161
 
162
  if ($this->mmb_exec('which zip')) {
163
-
164
  chdir(ABSPATH);
165
  $command = "zip -r $file_path './' -x '$content_dir/" . $sec_string . "/*'";
166
  ob_start();
@@ -174,7 +167,7 @@ class MMB_Backup extends MMB_Core
174
  );
175
  }
176
  else{
177
- return array('error' => 'Failed to backup site. Try to enable Zip Command on your server.');
178
  }
179
 
180
 
@@ -182,8 +175,7 @@ class MMB_Backup extends MMB_Core
182
  require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
183
  $archive = new PclZip($file_path);
184
  $result = $archive->add(ABSPATH, PCLZIP_OPT_REMOVE_PATH, ABSPATH);
185
- //$result = $archive->delete(PCLZIP_OPT_BY_NAME, $content_dir.'/'.$sec_string.'/');
186
- $this->_log($archive);
187
  if ($result) {
188
  $file_url = WP_CONTENT_URL . $file;
189
  return array(
@@ -194,10 +186,10 @@ class MMB_Backup extends MMB_Core
194
  else {
195
  @unlink($file_path);
196
  if($archive->error_code == '-10'){
197
- return array('error' => 'Failed to zip backup file. Try increasing memory limit and/or free space on your server.');
198
  }
199
  else{
200
- return array('error' => 'Failed to backup site. Try to enable Zip Command on your server.');
201
  }
202
  }
203
  }
@@ -282,7 +274,7 @@ class MMB_Backup extends MMB_Core
282
  $j = 1;
283
  foreach ($row as $value) {
284
  $value = addslashes($value);
285
- $value = preg_replace("\n", "\\n", $value);
286
  $num_values == $j ? $dump_data .= "'" . $value . "'" : $dump_data .= "'" . $value . "', ";
287
  $j++;
288
  unset($value);
19
 
20
  function backup($args)
21
  {
 
22
  @ini_set('memory_limit', '300M');
23
+ @set_time_limit(300); //five minutes
24
+
25
+ $type = $args['type']; //type like manual, weekly, daily
26
+ $what = $args['what']; //what like full or only db
 
27
 
28
  if (trim($type) == '')
29
  $type = 'manual'; //default
30
+
31
  $sec_string = md5('mmb-worker');
32
  $file = "/$sec_string/mwp_backups";
33
+ $file_path = WP_CONTENT_DIR . $file;
34
+
 
35
  if (!file_exists($file_path)) {
36
  if (!mkdir($file_path, 0755, true))
37
  return array(
38
  'error' => 'Permission denied, make sure you have write permission to wp-content folder.'
39
  );
40
  }
41
+
42
+ @file_put_contents($file_path . '/index.php', ''); //safe
43
+
44
+ //delete possible breaked previous backups
45
+ foreach (glob($file_path."/*.zip") as $filename) {
46
+ $short = basename($filename);
47
+ preg_match('/^wp\-content(.*)/Ui',$short,$matches);
48
+ if($matches)
49
+ @unlink($filename);
50
+ }
51
+
52
  if (trim($what) == 'full') {
 
53
  $content_backup = $this->backup_wpcontent($type);
54
  if (array_key_exists('error',$content_backup)) {
55
  @unlink($content_backup['path']);
74
  }
75
 
76
  include_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
77
+ //$worker_options = get_option('mmb-worker');
78
+
 
 
 
 
 
 
 
79
  //Prepare .zip file name
80
  $site_name = $this->remove_http(get_bloginfo('url'));
81
  $site_name = str_replace(array(
93
  $archive = new PclZip($backup_file);
94
  }
95
 
96
+
97
  if (trim($what) == 'full') {
98
  $htaccess_path = ABSPATH . ".htaccess";
99
  $wp_config_path = ABSPATH . "wp-config.php";
103
  $result = $this->mmb_exec($command);
104
  ob_get_clean();
105
  } else {
106
+ $files_to_add = array($content_backup['path'],$db_backup['path'],$htaccess_path,$wp_config_path);
107
+ $result = $archive->add($files_to_add, PCLZIP_OPT_REMOVE_ALL_PATH);
 
 
 
108
  }
109
 
110
  } elseif (trim($what) == 'db') {
120
  }
121
 
122
  if (!$result) {
 
 
 
123
  return array(
124
  'error' => 'Backup failed. Cannot create backup zip file.'
125
  );
126
  }
127
 
128
+
129
  @unlink($content_backup['path']);
130
  @unlink($db_backup['path']);
131
 
132
  $backup_url = WP_CONTENT_URL . $file . '/' . $site_name . '_' . $type . '_' . $what . '_' . date('Y-m-d') .'_'.$hash. '.zip';
 
133
  $worker_options = get_option('mmb-worker');
134
+
135
  //remove old file
136
  if ($worker_options['backups'][$type]['path'] != $backup_file) {
137
  @unlink($worker_options['backups'][$type]['path']);
154
  $content_dir = $content_dir[(count($content_dir)-1)];
155
 
156
  if ($this->mmb_exec('which zip')) {
 
157
  chdir(ABSPATH);
158
  $command = "zip -r $file_path './' -x '$content_dir/" . $sec_string . "/*'";
159
  ob_start();
167
  );
168
  }
169
  else{
170
+ return array('error' => 'Failed to backup site. Try to enable Zip on your server.');
171
  }
172
 
173
 
175
  require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
176
  $archive = new PclZip($file_path);
177
  $result = $archive->add(ABSPATH, PCLZIP_OPT_REMOVE_PATH, ABSPATH);
178
+ $result = $archive->delete(PCLZIP_OPT_BY_NAME, $content_dir.'/'.$sec_string.'/');
 
179
  if ($result) {
180
  $file_url = WP_CONTENT_URL . $file;
181
  return array(
186
  else {
187
  @unlink($file_path);
188
  if($archive->error_code == '-10'){
189
+ return array('error' => 'Failed to zip backup. Try increasing memory limit and/or free space on your server.');
190
  }
191
  else{
192
+ return array('error' => 'Failed to backup site. Try to enable Zip on your server.');
193
  }
194
  }
195
  }
274
  $j = 1;
275
  foreach ($row as $value) {
276
  $value = addslashes($value);
277
+ $value = preg_replace("/\n/Ui", "\\n", $value);
278
  $num_values == $j ? $dump_data .= "'" . $value . "'" : $dump_data .= "'" . $value . "', ";
279
  $j++;
280
  unset($value);
core.class.php CHANGED
@@ -258,14 +258,25 @@ class MMB_Core extends MMB_Helper
258
  */
259
  function install()
260
  {
261
- global $wp_object_cache;
262
  if(!empty($wp_object_cache))
263
  @$wp_object_cache->flush();
264
 
265
  // delete plugin options, just in case
266
- delete_option('_worker_nossl_key');
267
- delete_option('_worker_public_key');
268
- delete_option('_action_message_id');
 
 
 
 
 
 
 
 
 
 
 
269
 
270
  }
271
 
@@ -288,13 +299,24 @@ class MMB_Core extends MMB_Helper
288
  */
289
  function uninstall()
290
  {
291
- global $wp_object_cache;
292
  if(!empty($wp_object_cache))
293
  @$wp_object_cache->flush();
294
-
295
- delete_option('_worker_nossl_key');
296
- delete_option('_worker_public_key');
297
- delete_option('_action_message_id');
 
 
 
 
 
 
 
 
 
 
 
298
  }
299
 
300
  /**
258
  */
259
  function install()
260
  {
261
+ global $wp_object_cache, $wpdb;
262
  if(!empty($wp_object_cache))
263
  @$wp_object_cache->flush();
264
 
265
  // delete plugin options, just in case
266
+ if($this->mmb_multisite != false){
267
+ $blog_ids = $wpdb->get_results($wpdb->prepare('SELECT blog_id FROM `wp_blogs`'));
268
+ if(!empty($blog_ids)){
269
+ foreach($blog_ids as $blog_id){
270
+ $wpdb->query($wpdb->prepare('DELETE FROM '.$wpdb->prefix.$blog->blog_id.'_options WHERE `option_name` = "_worker_nossl_key";'));
271
+ $wpdb->query($wpdb->prepare('DELETE FROM '.$wpdb->prefix.$blog->blog_id.'_options WHERE `option_name` = "_worker_public_key";'));
272
+ $wpdb->query($wpdb->prepare('DELETE FROM '.$wpdb->prefix.$blog->blog_id.'_options WHERE `option_name` = "_action_message_id";'));
273
+ }
274
+ }
275
+ } else {
276
+ delete_option('_worker_nossl_key');
277
+ delete_option('_worker_public_key');
278
+ delete_option('_action_message_id');
279
+ }
280
 
281
  }
282
 
299
  */
300
  function uninstall()
301
  {
302
+ global $wp_object_cache, $wpdb;
303
  if(!empty($wp_object_cache))
304
  @$wp_object_cache->flush();
305
+
306
+ if($this->mmb_multisite != false){
307
+ $blog_ids = $wpdb->get_results($wpdb->prepare('SELECT blog_id FROM `wp_blogs`'));
308
+ if(!empty($blog_ids)){
309
+ foreach($blog_ids as $blog){
310
+ $wpdb->query($wpdb->prepare('DELETE FROM '.$wpdb->prefix.$blog->blog_id.'_options WHERE `option_name` = "_worker_nossl_key";'));
311
+ $wpdb->query($wpdb->prepare('DELETE FROM '.$wpdb->prefix.$blog->blog_id.'_options WHERE `option_name` = "_worker_public_key";'));
312
+ $wpdb->query($wpdb->prepare('DELETE FROM '.$wpdb->prefix.$blog->blog_id.'_options WHERE `option_name` = "_action_message_id";'));
313
+ }
314
+ }
315
+ } else {
316
+ delete_option('_worker_nossl_key');
317
+ delete_option('_worker_public_key');
318
+ delete_option('_action_message_id');
319
+ }
320
  }
321
 
322
  /**
helper.class.php CHANGED
@@ -85,11 +85,11 @@ class MMB_Helper
85
  if($this->mmb_multisite)
86
  return $this->mmb_set_sitemeta_transient($option_name, $data);
87
 
88
- global $mmb_wp_version;
89
 
90
- if (version_compare($mmb_wp_version, '2.7.9', '<=')) {
91
  update_option($option_name, $data);
92
- } else if (version_compare($mmb_wp_version, '2.9.9', '<=')) {
93
  update_option('_transient_' . $option_name, $data);
94
  } else {
95
  update_option('_site_transient_' . $option_name, $data);
@@ -104,12 +104,12 @@ class MMB_Helper
104
  if($this->mmb_multisite)
105
  return $this->mmb_get_sitemeta_transient($option_name);
106
 
107
- global $mmb_wp_version;
108
 
109
 
110
- if (version_compare($mmb_wp_version, '2.7.9', '<=')) {
111
  return get_option($option_name);
112
- } else if (version_compare($mmb_wp_version, '2.9.9', '<=')) {
113
  return get_option('_transient_' . $option_name);
114
  } else {
115
  return get_option('_site_transient_' . $option_name);
@@ -122,11 +122,11 @@ class MMB_Helper
122
  return FALSE;
123
  }
124
 
125
- global $mmb_wp_version;
126
 
127
- if (version_compare($mmb_wp_version, '2.7.9', '<=')) {
128
  delete_option($option_name);
129
- } else if (version_compare($mmb_wp_version, '2.9.9', '<=')) {
130
  delete_option('_transient_' . $option_name);
131
  } else {
132
  delete_option('_site_transient_' . $option_name);
85
  if($this->mmb_multisite)
86
  return $this->mmb_set_sitemeta_transient($option_name, $data);
87
 
88
+ global $wp_version;
89
 
90
+ if (version_compare($wp_version, '2.7.9', '<=')) {
91
  update_option($option_name, $data);
92
+ } else if (version_compare($wp_version, '2.9.9', '<=')) {
93
  update_option('_transient_' . $option_name, $data);
94
  } else {
95
  update_option('_site_transient_' . $option_name, $data);
104
  if($this->mmb_multisite)
105
  return $this->mmb_get_sitemeta_transient($option_name);
106
 
107
+ global $wp_version;
108
 
109
 
110
+ if (version_compare($wp_version, '2.7.9', '<=')) {
111
  return get_option($option_name);
112
+ } else if (version_compare($wp_version, '2.9.9', '<=')) {
113
  return get_option('_transient_' . $option_name);
114
  } else {
115
  return get_option('_site_transient_' . $option_name);
122
  return FALSE;
123
  }
124
 
125
+ global $wp_version;
126
 
127
+ if (version_compare($wp_version, '2.7.9', '<=')) {
128
  delete_option($option_name);
129
+ } else if (version_compare($wp_version, '2.9.9', '<=')) {
130
  delete_option('_transient_' . $option_name);
131
  } else {
132
  delete_option('_site_transient_' . $option_name);
index.html ADDED
File without changes
init.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: ManageWP - Worker
4
  Plugin URI: http://managewp.com/
5
  Description: Manage all your blogs from one dashboard. Visit <a href="http://managewp.com">ManageWP.com</a> to sign up.
6
  Author: Prelovac Media
7
- Version: 3.9.1
8
  Author URI: http://www.prelovac.com
9
  */
10
 
@@ -20,7 +20,7 @@ Author URI: http://www.prelovac.com
20
  **************************************************************/
21
 
22
 
23
- define('MMB_WORKER_VERSION', '3.9.1');
24
 
25
  global $wpdb, $mmb_plugin_dir, $mmb_plugin_url;
26
 
@@ -93,392 +93,452 @@ if (function_exists('register_deactivation_hook'))
93
  $mmb_core,
94
  'uninstall'
95
  ));
 
 
96
 
97
-
98
-
99
- function mmb_parse_request()
100
- {
101
-
102
- if (!isset($HTTP_RAW_POST_DATA)) {
103
- $HTTP_RAW_POST_DATA = file_get_contents('php://input');
104
- }
105
- ob_start();
106
-
107
- global $mmb_core, $mmb_actions, $new_actions;
108
-
109
- $data = base64_decode($HTTP_RAW_POST_DATA);
110
- if ($data)
111
- $num = @extract(unserialize($data));
112
-
113
- if ($action) {
114
- global $w3_plugin_totalcache;
115
- if(!empty($w3_plugin_totalcache)){
116
- @$w3_plugin_totalcache->flush_dbcache();
117
- @$w3_plugin_totalcache->flush_objectcache();
118
  }
 
119
 
120
- update_option('mwp_iframe_options_header', microtime(true));
121
- // mmb_response($mmb_actions, false);
122
- if (!$mmb_core->check_if_user_exists($params['username']))
123
- mmb_response('Username <b>' . $params['username'] . '</b> does not have administrator capabilities. Enter the correct username in the site options.', false);
124
-
125
- if ($action == 'add_site') {
126
- mmb_add_site($params);
127
- mmb_response('You should never see this.', false);
128
- }
129
-
130
- $auth = $mmb_core->authenticate_message($action . $id, $signature, $id);
131
- if ($auth === true) {
132
- if (array_key_exists($action, $mmb_actions) && function_exists($mmb_actions[$action]))
133
- call_user_func($mmb_actions[$action], $params);
134
- else
135
- mmb_response('Action "' . $action . '" does not exist.', false);
136
- } else {
137
- mmb_response($auth['error'], false);
138
- }
139
- }
140
-
141
-
142
- ob_end_clean();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  }
144
-
145
  /* Main response function */
 
146
 
147
- function mmb_response($response = false, $success = true)
148
- {
149
- $return = array();
150
-
151
- if (empty($response))
152
- $return['error'] = 'Empty response.';
153
- else if ($success)
154
- $return['success'] = $response;
155
- else
156
- $return['error'] = $response;
157
-
158
- if( !headers_sent() ){
159
- header('HTTP/1.0 200 OK');
160
- header('Content-Type: text/plain');
 
 
161
  }
162
- exit("<MWPHEADER>" . base64_encode(serialize($return))."<ENDMWPHEADER>");
163
  }
164
 
165
- function mmb_add_site($params)
166
- {
167
- global $mmb_core;
168
-
169
- $num = extract($params);
170
-
171
- if ($num) {
172
- if (!get_option('_action_message_id') && !get_option('_worker_public_key')) {
173
- $public_key = base64_decode($public_key);
174
-
175
- if (function_exists('openssl_verify')) {
176
- $verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
177
- if ($verify == 1) {
178
- $mmb_core->set_master_public_key($public_key);
179
- $mmb_core->set_worker_message_id($id);
180
- $mmb_core->get_stats_instance();
181
- mmb_response($mmb_core->stats_instance->get_initial_stats(), true);
182
- } else if ($verify == 0) {
183
- mmb_response('Invalid message signature. Please contact us if you see this message often.', false);
184
- } else {
185
- mmb_response('Command not successful. Please try again.', false);
186
- }
187
- } else {
188
- if (!get_option('_worker_nossl_key')) {
189
- srand();
190
- $random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
191
-
192
- $mmb_core->set_random_signature($random_key);
193
- $mmb_core->set_worker_message_id($id);
194
- $mmb_core->set_master_public_key($public_key);
195
- $mmb_core->get_stats_instance();
196
- mmb_response($mmb_core->stats_instance->get_initial_stats(), true);
197
- } else
198
- mmb_response('Please deactivate & activate ManageWP Worker plugin on your site, then re-add the site to your dashboard.', false);
199
- }
200
- } else {
201
- mmb_response('Please deactivate & activate ManageWP Worker plugin on your site and re-add the site to your dashboard.', false);
202
- }
203
- } else {
204
- mmb_response('Invalid parameters received. Please try again.', false);
205
- }
 
 
206
  }
207
 
208
- function mmb_remove_site($params)
209
- {
210
- extract($params);
211
- global $mmb_core;
212
- $mmb_core->uninstall();
213
-
214
- include_once(ABSPATH . 'wp-admin/includes/plugin.php');
215
- $plugin_slug = basename(dirname(__FILE__)) . '/' . basename(__FILE__);
216
-
217
- if ($deactivate) {
218
- deactivate_plugins($plugin_slug, true);
219
- }
220
-
221
- if (!is_plugin_active($plugin_slug))
222
- mmb_response(array(
223
- 'deactivated' => 'Site removed successfully. <br /><br />ManageWP Worker plugin successfully deactivated.'
224
- ), true);
225
- else
226
- mmb_response(array(
227
- 'removed_data' => 'Site removed successfully. <br /><br /><b>ManageWP Worker plugin was not deactivated.</b>'
228
- ), true);
229
-
 
 
230
  }
231
-
232
-
233
- function mmb_stats_get($params)
234
- {
235
- global $mmb_core;
236
- $mmb_core->get_stats_instance();
237
- mmb_response($mmb_core->stats_instance->get($params), true);
238
  }
239
- function mmb_get_stats_notification($params)
240
- {
241
- global $mmb_core;
242
- $mmb_core->get_stats_instance();
243
- $stat = $mmb_core->stats_instance->get_stats_notification($params);
244
- mmb_response($stat, true);
 
 
245
  }
246
-
247
  //post
248
- function mmb_post_create($params)
249
- {
250
- global $mmb_core;
251
- $mmb_core->get_post_instance();
252
- $return = $mmb_core->post_instance->create($params);
253
- if (is_int($return))
254
- mmb_response($return, true);
255
- else
256
- mmb_response($return, false);
 
 
257
  }
258
- function mmb_change_post_status($params)
259
- {
260
- global $mmb_core;
261
- $mmb_core->get_post_instance();
262
- $return = $mmb_core->post_instance->change_status($params);
263
- //mmb_response($return, true);
264
 
 
 
 
 
 
 
 
 
 
265
  }
 
266
  //comments
267
- function mmb_change_comment_status($params)
268
- {
269
- global $mmb_core;
270
- $mmb_core->get_comment_instance();
271
- $return = $mmb_core->comment_instance->change_status($params);
272
- //mmb_response($return, true);
273
- if ($return){
274
- $mmb_core->get_stats_instance();
275
- mmb_response($mmb_core->stats_instance->get_comments_stats($params), true);
276
- }else
277
- mmb_response('Comment not updated', false);
 
 
 
278
  }
279
- function mmb_comment_stats_get($params)
280
- {
281
- global $mmb_core;
282
- $mmb_core->get_stats_instance();
283
- mmb_response($mmb_core->stats_instance->get_comments_stats($params), true);
 
 
284
  }
285
 
 
286
  //backup
287
- function mmb_backup_now($params)
288
- {
289
- global $mmb_core;
290
-
291
- $mmb_core->get_backup_instance();
292
- $return = $mmb_core->backup_instance->backup($params);
293
-
294
- if (is_array($return) && array_key_exists('error', $return))
295
- mmb_response($return['error'], false);
296
- else {
297
- mmb_response($return, true);
298
- }
 
299
  }
300
 
301
- function mmb_email_backup($params)
302
- {
303
- global $mmb_core;
304
- $mmb_core->get_backup_instance();
305
- $return = $mmb_core->backup_instance->email_backup($params);
306
-
307
- if (is_array($return) && array_key_exists('error', $return))
308
- mmb_response($return['error'], false);
309
- else {
310
- mmb_response($return, true);
311
- }
 
 
312
  }
313
-
314
- function mmb_check_backup_compat($params)
315
- {
316
- global $mmb_core;
317
- $mmb_core->get_backup_instance();
318
- $return = $mmb_core->backup_instance->check_backup_compat($params);
319
-
320
- if (is_array($return) && array_key_exists('error', $return))
321
- mmb_response($return['error'], false);
322
- else {
323
- mmb_response($return, true);
324
- }
 
325
  }
326
-
327
- function mmb_optimize_tables($params)
328
- {
329
- global $mmb_core;
330
- $mmb_core->get_backup_instance();
331
- $return = $mmb_core->backup_instance->optimize_tables();
332
- if ($return)
333
- mmb_response($return, true);
334
- else
335
- mmb_response(false, false);
 
336
  }
337
-
338
- function mmb_restore_now($params)
339
- {
340
- global $mmb_core;
341
- $mmb_core->get_backup_instance();
342
- $return = $mmb_core->backup_instance->restore($params);
343
- if (is_array($return) && array_key_exists('error', $return))
344
- mmb_response($return['error'], false);
345
- else
346
- mmb_response($return, true);
347
-
 
348
  }
349
-
350
- function mmb_update_worker_plugin($params)
351
- {
352
- global $mmb_core;
353
- mmb_response($mmb_core->update_worker_plugin($params), true);
 
354
  }
355
 
356
- function mmb_wp_checkversion($params)
357
- {
358
- include_once(ABSPATH . 'wp-includes/version.php');
359
- global $mmb_wp_version, $mmb_core;
360
- mmb_response($mmb_wp_version, true);
 
 
361
  }
362
-
363
- function mmb_search_posts_by_term($params)
364
- {
365
- global $mmb_core;
366
- $mmb_core->get_search_instance();
367
- //$mmb_core->_log($params);
368
-
369
- $search_type = trim($params['search_type']);
370
- $search_term = strtolower(trim($params['search_term']));
371
-
372
- switch ($search_type){
373
- case 'page_post':
374
- $return = $mmb_core->search_instance->search_posts_by_term($params);
375
- if($return){
376
- $return = serialize($return);
377
- mmb_response($return, true);
378
- }else{
379
- mmb_response('No posts found', false);
380
- }
381
- break;
382
-
383
- case 'plugin':
384
- $plugins = get_option('active_plugins');
385
-
386
- $have_plugin = false;
387
- foreach ($plugins as $plugin) {
388
- if(strpos($plugin, $search_term)>-1){
389
- $have_plugin = true;
390
- }
391
- }
392
- if($have_plugin){
393
- mmb_response(serialize($plugin), true);
394
- }else{
395
- mmb_response(false, false);
396
- }
397
- break;
398
- case 'theme':
399
- $theme = strtolower(get_option('template'));
400
- if(strpos($theme, $search_term)>-1){
401
- mmb_response($theme, true);
402
- }else{
403
- mmb_response(false, false);
404
- }
405
- break;
406
- default: mmb_response(false, false);
407
- }
408
- $return = $mmb_core->search_instance->search_posts_by_term($params);
409
-
410
-
411
-
412
- if ($return_if_true) {
413
- mmb_response($return_value, true);
414
- } else {
415
- mmb_response($return_if_false, false);
416
- }
 
417
  }
418
 
419
- function mmb_install_addon($params)
420
- {
421
- global $mmb_core;
422
- $mmb_core->get_installer_instance();
423
- $return = $mmb_core->installer_instance->install_remote_file($params);
424
- mmb_response($return, true);
425
-
426
- }
427
- function mmb_do_upgrade($params)
428
- {
429
- global $mmb_core, $mmb_upgrading;
430
- $mmb_core->get_installer_instance();
431
- $return = $mmb_core->installer_instance->do_upgrade($params);
432
- mmb_response($return, true);
433
-
434
  }
435
 
436
- function mmb_add_link($params)
437
- {
438
- global $mmb_core;
439
- $mmb_core->get_link_instance();
440
- $return = $mmb_core->link_instance->add_link($params);
441
- if (is_array($return) && array_key_exists('error', $return))
442
-
443
- mmb_response($return['error'], false);
444
- else {
445
- mmb_response($return, true);
446
- }
447
-
448
  }
449
-
450
- function mmb_add_user($params)
451
- {
452
- global $mmb_core;
453
- $mmb_core->get_user_instance();
454
- $return = $mmb_core->user_instance->add_user($params);
455
- if (is_array($return) && array_key_exists('error', $return))
456
-
457
- mmb_response($return['error'], false);
458
- else {
459
- mmb_response($return, true);
460
- }
461
-
 
462
  }
463
-
464
- function mmb_iframe_plugins_fix($update_actions)
465
- {
466
- foreach($update_actions as $key => $action)
467
  {
468
- $update_actions[$key] = str_replace('target="_parent"','',$action);
 
 
 
 
 
 
 
 
 
469
  }
470
-
471
- return $update_actions;
472
-
473
  }
474
- function mmb_execute_php_code($params)
475
- {
476
- ob_start();
477
- eval($params['code']);
478
- $return = ob_get_flush();
479
- mmb_response(print_r($return, true), true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
  }
481
-
482
  add_filter('install_plugin_complete_actions','mmb_iframe_plugins_fix');
483
 
484
 
4
  Plugin URI: http://managewp.com/
5
  Description: Manage all your blogs from one dashboard. Visit <a href="http://managewp.com">ManageWP.com</a> to sign up.
6
  Author: Prelovac Media
7
+ Version: 3.9.2
8
  Author URI: http://www.prelovac.com
9
  */
10
 
20
  **************************************************************/
21
 
22
 
23
+ define('MMB_WORKER_VERSION', '3.9.2');
24
 
25
  global $wpdb, $mmb_plugin_dir, $mmb_plugin_url;
26
 
93
  $mmb_core,
94
  'uninstall'
95
  ));
96
+ do_action('after_db_upgrade');
97
+ if( !function_exists ( 'mmb_parse_request' )) {
98
 
99
+ function mmb_parse_request()
100
+ {
101
+
102
+ if (!isset($HTTP_RAW_POST_DATA)) {
103
+ $HTTP_RAW_POST_DATA = file_get_contents('php://input');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  }
105
+ ob_start();
106
 
107
+ global $mmb_core, $mmb_actions, $new_actions, $wp_db_version, $wpmu_version;
108
+
109
+ $data = base64_decode($HTTP_RAW_POST_DATA);
110
+ if ($data)
111
+ $num = @extract(unserialize($data));
112
+
113
+ if ($action) {
114
+ global $w3_plugin_totalcache, $wp_object_cache;
115
+ @set_time_limit(300);
116
+
117
+ if(is_object($w3_plugin_totalcache) && !empty($w3_plugin_totalcache)){
118
+ @$w3_plugin_totalcache->flush_dbcache();
119
+ @$w3_plugin_totalcache->flush_objectcache();
120
+ }
121
+
122
+ if(is_object($wp_object_cache) && !empty($wp_object_cache)){
123
+ $wp_object_cache->flush();
124
+ }
125
+ update_option('mwp_iframe_options_header', microtime(true));
126
+ // mmb_response($mmb_actions, false);
127
+ if (!$mmb_core->check_if_user_exists($params['username']))
128
+ mmb_response('Username <b>' . $params['username'] . '</b> does not have administrator capabilities. Enter the correct username in the site options.', false);
129
+
130
+
131
+ /* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
132
+ if( strlen(trim($wp_db_version)) ){
133
+ if ( get_option('db_version') != $wp_db_version ) {
134
+ /* in multisite network, please update database manualy */
135
+ if (empty($wpmu_version) || (function_exists('is_multisite') && !is_multisite())){
136
+ if( ! function_exists('wp_upgrade'))
137
+ include_once(ABSPATH.'wp-admin/includes/upgrade.php');
138
+
139
+ ob_clean();
140
+ @wp_upgrade();
141
+ @do_action('after_db_upgrade');
142
+ ob_end_clean();
143
+ }
144
+ }
145
+ }
146
+
147
+ if ($action == 'add_site') {
148
+ mmb_add_site($params);
149
+ mmb_response('You should never see this.', false);
150
+ }
151
+
152
+ $auth = $mmb_core->authenticate_message($action . $id, $signature, $id);
153
+ if ($auth === true) {
154
+ if (array_key_exists($action, $mmb_actions) && function_exists($mmb_actions[$action]))
155
+ call_user_func($mmb_actions[$action], $params);
156
+ else
157
+ mmb_response('Action "' . $action . '" does not exist.', false);
158
+ } else {
159
+ mmb_response($auth['error'], false);
160
+ }
161
+ }
162
+
163
+
164
+ ob_end_clean();
165
+ }
166
  }
 
167
  /* Main response function */
168
+ if( !function_exists ( 'mmb_response' )) {
169
 
170
+ function mmb_response($response = false, $success = true)
171
+ {
172
+ $return = array();
173
+
174
+ if (empty($response))
175
+ $return['error'] = 'Empty response.';
176
+ else if ($success)
177
+ $return['success'] = $response;
178
+ else
179
+ $return['error'] = $response;
180
+
181
+ if( !headers_sent() ){
182
+ header('HTTP/1.0 200 OK');
183
+ header('Content-Type: text/plain');
184
+ }
185
+ exit("<MWPHEADER>" . base64_encode(serialize($return))."<ENDMWPHEADER>");
186
  }
 
187
  }
188
 
189
+ if( !function_exists ( 'mmb_add_site' )) {
190
+ function mmb_add_site($params)
191
+ {
192
+ global $mmb_core;
193
+
194
+ $num = extract($params);
195
+
196
+ if ($num) {
197
+ if (!get_option('_action_message_id') && !get_option('_worker_public_key')) {
198
+ $public_key = base64_decode($public_key);
199
+
200
+ if (function_exists('openssl_verify')) {
201
+ $verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
202
+ if ($verify == 1) {
203
+ $mmb_core->set_master_public_key($public_key);
204
+ $mmb_core->set_worker_message_id($id);
205
+ $mmb_core->get_stats_instance();
206
+ mmb_response($mmb_core->stats_instance->get_initial_stats(), true);
207
+ } else if ($verify == 0) {
208
+ mmb_response('Invalid message signature. Please contact us if you see this message often.', false);
209
+ } else {
210
+ mmb_response('Command not successful. Please try again.', false);
211
+ }
212
+ } else {
213
+ if (!get_option('_worker_nossl_key')) {
214
+ srand();
215
+ $random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
216
+
217
+ $mmb_core->set_random_signature($random_key);
218
+ $mmb_core->set_worker_message_id($id);
219
+ $mmb_core->set_master_public_key($public_key);
220
+ $mmb_core->get_stats_instance();
221
+ mmb_response($mmb_core->stats_instance->get_initial_stats(), true);
222
+ } else
223
+ mmb_response('Please deactivate & activate ManageWP Worker plugin on your site, then re-add the site to your dashboard.', false);
224
+ }
225
+ } else {
226
+ mmb_response('Please deactivate & activate ManageWP Worker plugin on your site and re-add the site to your dashboard.', false);
227
+ }
228
+ } else {
229
+ mmb_response('Invalid parameters received. Please try again.', false);
230
+ }
231
+ }
232
  }
233
 
234
+ if( !function_exists ( 'mmb_remove_site' )) {
235
+ function mmb_remove_site($params)
236
+ {
237
+ extract($params);
238
+ global $mmb_core;
239
+ $mmb_core->uninstall();
240
+
241
+ include_once(ABSPATH . 'wp-admin/includes/plugin.php');
242
+ $plugin_slug = basename(dirname(__FILE__)) . '/' . basename(__FILE__);
243
+
244
+ if ($deactivate) {
245
+ deactivate_plugins($plugin_slug, true);
246
+ }
247
+
248
+ if (!is_plugin_active($plugin_slug))
249
+ mmb_response(array(
250
+ 'deactivated' => 'Site removed successfully. <br /><br />ManageWP Worker plugin successfully deactivated.'
251
+ ), true);
252
+ else
253
+ mmb_response(array(
254
+ 'removed_data' => 'Site removed successfully. <br /><br /><b>ManageWP Worker plugin was not deactivated.</b>'
255
+ ), true);
256
+
257
+ }
258
  }
259
+ if( !function_exists ( 'mmb_stats_get' )) {
260
+ function mmb_stats_get($params)
261
+ {
262
+ global $mmb_core;
263
+ $mmb_core->get_stats_instance();
264
+ mmb_response($mmb_core->stats_instance->get($params), true);
265
+ }
266
  }
267
+ if( !function_exists ( 'mmb_get_stats_notification' )) {
268
+ function mmb_get_stats_notification($params)
269
+ {
270
+ global $mmb_core;
271
+ $mmb_core->get_stats_instance();
272
+ $stat = $mmb_core->stats_instance->get_stats_notification($params);
273
+ mmb_response($stat, true);
274
+ }
275
  }
 
276
  //post
277
+ if( !function_exists ( 'mmb_post_create' )) {
278
+ function mmb_post_create($params)
279
+ {
280
+ global $mmb_core;
281
+ $mmb_core->get_post_instance();
282
+ $return = $mmb_core->post_instance->create($params);
283
+ if (is_int($return))
284
+ mmb_response($return, true);
285
+ else
286
+ mmb_response($return, false);
287
+ }
288
  }
 
 
 
 
 
 
289
 
290
+ if( !function_exists ( 'mmb_change_post_status' )) {
291
+ function mmb_change_post_status($params)
292
+ {
293
+ global $mmb_core;
294
+ $mmb_core->get_post_instance();
295
+ $return = $mmb_core->post_instance->change_status($params);
296
+ //mmb_response($return, true);
297
+
298
+ }
299
  }
300
+
301
  //comments
302
+ if( !function_exists ( 'mmb_change_comment_status' )) {
303
+ function mmb_change_comment_status($params)
304
+ {
305
+ global $mmb_core;
306
+ $mmb_core->get_comment_instance();
307
+ $return = $mmb_core->comment_instance->change_status($params);
308
+ //mmb_response($return, true);
309
+ if ($return){
310
+ $mmb_core->get_stats_instance();
311
+ mmb_response($mmb_core->stats_instance->get_comments_stats($params), true);
312
+ }else
313
+ mmb_response('Comment not updated', false);
314
+ }
315
+
316
  }
317
+ if( !function_exists ( 'mmb_comment_stats_get' )) {
318
+ function mmb_comment_stats_get($params)
319
+ {
320
+ global $mmb_core;
321
+ $mmb_core->get_stats_instance();
322
+ mmb_response($mmb_core->stats_instance->get_comments_stats($params), true);
323
+ }
324
  }
325
 
326
+ if( !function_exists ( 'mmb_backup_now' )) {
327
  //backup
328
+ function mmb_backup_now($params)
329
+ {
330
+ global $mmb_core;
331
+
332
+ $mmb_core->get_backup_instance();
333
+ $return = $mmb_core->backup_instance->backup($params);
334
+
335
+ if (is_array($return) && array_key_exists('error', $return))
336
+ mmb_response($return['error'], false);
337
+ else {
338
+ mmb_response($return, true);
339
+ }
340
+ }
341
  }
342
 
343
+ if( !function_exists ( 'mmb_email_backup' )) {
344
+ function mmb_email_backup($params)
345
+ {
346
+ global $mmb_core;
347
+ $mmb_core->get_backup_instance();
348
+ $return = $mmb_core->backup_instance->email_backup($params);
349
+
350
+ if (is_array($return) && array_key_exists('error', $return))
351
+ mmb_response($return['error'], false);
352
+ else {
353
+ mmb_response($return, true);
354
+ }
355
+ }
356
  }
357
+ if( !function_exists ( 'mmb_check_backup_compat' )) {
358
+ function mmb_check_backup_compat($params)
359
+ {
360
+ global $mmb_core;
361
+ $mmb_core->get_backup_instance();
362
+ $return = $mmb_core->backup_instance->check_backup_compat($params);
363
+
364
+ if (is_array($return) && array_key_exists('error', $return))
365
+ mmb_response($return['error'], false);
366
+ else {
367
+ mmb_response($return, true);
368
+ }
369
+ }
370
  }
371
+ if( !function_exists ( 'mmb_optimize_tables' )) {
372
+ function mmb_optimize_tables($params)
373
+ {
374
+ global $mmb_core;
375
+ $mmb_core->get_backup_instance();
376
+ $return = $mmb_core->backup_instance->optimize_tables();
377
+ if ($return)
378
+ mmb_response($return, true);
379
+ else
380
+ mmb_response(false, false);
381
+ }
382
  }
383
+ if( !function_exists ( 'mmb_restore_now' )) {
384
+ function mmb_restore_now($params)
385
+ {
386
+ global $mmb_core;
387
+ $mmb_core->get_backup_instance();
388
+ $return = $mmb_core->backup_instance->restore($params);
389
+ if (is_array($return) && array_key_exists('error', $return))
390
+ mmb_response($return['error'], false);
391
+ else
392
+ mmb_response($return, true);
393
+
394
+ }
395
  }
396
+ if( !function_exists ( 'mmb_update_worker_plugin' )) {
397
+ function mmb_update_worker_plugin($params)
398
+ {
399
+ global $mmb_core;
400
+ mmb_response($mmb_core->update_worker_plugin($params), true);
401
+ }
402
  }
403
 
404
+ if( !function_exists ( 'mmb_wp_checkversion' )) {
405
+ function mmb_wp_checkversion($params)
406
+ {
407
+ include_once(ABSPATH . 'wp-includes/version.php');
408
+ global $mmb_wp_version, $mmb_core;
409
+ mmb_response($mmb_wp_version, true);
410
+ }
411
  }
412
+ if( !function_exists ( 'mmb_search_posts_by_term' )) {
413
+ function mmb_search_posts_by_term($params)
414
+ {
415
+ global $mmb_core;
416
+ $mmb_core->get_search_instance();
417
+ //$mmb_core->_log($params);
418
+
419
+ $search_type = trim($params['search_type']);
420
+ $search_term = strtolower(trim($params['search_term']));
421
+
422
+ switch ($search_type){
423
+ case 'page_post':
424
+ $return = $mmb_core->search_instance->search_posts_by_term($params);
425
+ if($return){
426
+ $return = serialize($return);
427
+ mmb_response($return, true);
428
+ }else{
429
+ mmb_response('No posts found', false);
430
+ }
431
+ break;
432
+
433
+ case 'plugin':
434
+ $plugins = get_option('active_plugins');
435
+
436
+ $have_plugin = false;
437
+ foreach ($plugins as $plugin) {
438
+ if(strpos($plugin, $search_term)>-1){
439
+ $have_plugin = true;
440
+ }
441
+ }
442
+ if($have_plugin){
443
+ mmb_response(serialize($plugin), true);
444
+ }else{
445
+ mmb_response(false, false);
446
+ }
447
+ break;
448
+ case 'theme':
449
+ $theme = strtolower(get_option('template'));
450
+ if(strpos($theme, $search_term)>-1){
451
+ mmb_response($theme, true);
452
+ }else{
453
+ mmb_response(false, false);
454
+ }
455
+ break;
456
+ default: mmb_response(false, false);
457
+ }
458
+ $return = $mmb_core->search_instance->search_posts_by_term($params);
459
+
460
+
461
+
462
+ if ($return_if_true) {
463
+ mmb_response($return_value, true);
464
+ } else {
465
+ mmb_response($return_if_false, false);
466
+ }
467
+ }
468
  }
469
 
470
+ if( !function_exists ( 'mmb_install_addon' )) {
471
+ function mmb_install_addon($params)
472
+ {
473
+ global $mmb_core;
474
+ $mmb_core->get_installer_instance();
475
+ $return = $mmb_core->installer_instance->install_remote_file($params);
476
+ mmb_response($return, true);
477
+
478
+ }
 
 
 
 
 
 
479
  }
480
 
481
+ if( !function_exists ( 'mmb_do_upgrade' )) {
482
+ function mmb_do_upgrade($params)
483
+ {
484
+ global $mmb_core, $mmb_upgrading;
485
+ $mmb_core->get_installer_instance();
486
+ $return = $mmb_core->installer_instance->do_upgrade($params);
487
+ mmb_response($return, true);
488
+
489
+ }
 
 
 
490
  }
491
+ if( !function_exists ( 'mmb_add_link' )) {
492
+ function mmb_add_link($params)
493
+ {
494
+ global $mmb_core;
495
+ $mmb_core->get_link_instance();
496
+ $return = $mmb_core->link_instance->add_link($params);
497
+ if (is_array($return) && array_key_exists('error', $return))
498
+
499
+ mmb_response($return['error'], false);
500
+ else {
501
+ mmb_response($return, true);
502
+ }
503
+
504
+ }
505
  }
506
+ if( !function_exists ( 'mmb_add_user' )) {
507
+ function mmb_add_user($params)
 
 
508
  {
509
+ global $mmb_core;
510
+ $mmb_core->get_user_instance();
511
+ $return = $mmb_core->user_instance->add_user($params);
512
+ if (is_array($return) && array_key_exists('error', $return))
513
+
514
+ mmb_response($return['error'], false);
515
+ else {
516
+ mmb_response($return, true);
517
+ }
518
+
519
  }
 
 
 
520
  }
521
+ if( !function_exists ( 'mmb_iframe_plugins_fix' )) {
522
+ function mmb_iframe_plugins_fix($update_actions)
523
+ {
524
+ foreach($update_actions as $key => $action)
525
+ {
526
+ $update_actions[$key] = str_replace('target="_parent"','',$action);
527
+ }
528
+
529
+ return $update_actions;
530
+
531
+ }
532
+ }
533
+ if( !function_exists ( 'mmb_execute_php_code' )) {
534
+ function mmb_execute_php_code($params)
535
+ {
536
+ ob_start();
537
+ eval($params['code']);
538
+ $return = ob_get_flush();
539
+ mmb_response(print_r($return, true), true);
540
+ }
541
  }
 
542
  add_filter('install_plugin_complete_actions','mmb_iframe_plugins_fix');
543
 
544
 
installer.class.php CHANGED
@@ -164,78 +164,130 @@ class MMB_Installer extends MMB_Core
164
  function upgrade_core($current)
165
  {
166
  ob_start();
167
- global $mmb_wp_version, $wp_filesystem;
 
168
 
169
- if(!class_exists('WP_Upgrader')){
170
- include_once(ABSPATH.'wp-admin/includes/update.php');
171
- if(function_exists('wp_update_core')){
172
- $update = wp_update_core($current);
173
- if(is_wp_error($update)){
174
- return array(
175
- 'error' => $this->mmb_get_error($update)
176
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  }
178
- else
179
- return array(
180
- 'upgraded' => ' Upgraded successfully.'
181
- );
182
  }
183
- }
 
 
 
 
 
 
 
184
 
185
- $upgrader = new WP_Upgrader();
186
-
187
- // Is an update available?
188
- if (!isset($current->response) || $current->response == 'latest')
189
- return array(
190
- 'upgraded' => ' Upgraded successfully.'
191
- );
192
-
193
- $res = $upgrader->fs_connect(array(
194
- ABSPATH,
195
- WP_CONTENT_DIR
196
- ));
197
- if (is_wp_error($res))
198
- return array(
199
- 'error' => $this->mmb_get_error($res)
200
- );
201
-
202
- $wp_dir = trailingslashit($wp_filesystem->abspath());
203
-
204
- $download = $upgrader->download_package($current->package);
205
- if (is_wp_error($download))
206
- return array(
207
- 'error' => $this->mmb_get_error($download)
208
- );
209
-
210
- $working_dir = $upgrader->unpack_package($download);
211
- if (is_wp_error($working_dir))
212
- return array(
213
- 'error' => $this->mmb_get_error($working_dir)
214
- );
215
-
216
- if (!$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true)) {
217
- $wp_filesystem->delete($working_dir, true);
218
- return array(
219
- 'error' => 'Unable to move update files.'
220
- );
221
- }
222
-
223
- $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
224
-
225
- require(ABSPATH . 'wp-admin/includes/update-core.php');
226
-
227
-
228
- $update_core = update_core($working_dir, $wp_dir);
229
- ob_end_clean();
230
-
231
- if (is_wp_error($update_core))
232
- return array(
233
- 'error' => $this->mmb_get_error($update_core)
234
- );
235
- ob_end_flush();
236
- return array(
237
- 'upgraded' => 'Upgraded successfully.'
238
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  }
240
 
241
 
164
  function upgrade_core($current)
165
  {
166
  ob_start();
167
+ if(!function_exists('wp_version_check'))
168
+ include_once(ABSPATH.'/wp-admin/includes/update.php');
169
 
170
+ @wp_version_check();
171
+
172
+ if(!function_exists('get_core_updates'))
173
+ include_once(ABSPATH.'/wp-admin/includes/update.php');
174
+
175
+ $updates = get_core_updates();
176
+ $current_update = false;
177
+ ob_end_flush();
178
+ ob_end_clean();
179
+
180
+ if(!empty($updates)){
181
+ $updated = $updates[0];
182
+ if ( !isset( $updated->response ) || $updated->response == 'latest' )
183
+ return array('upgraded' => ' Upgraded successfully.');
184
+
185
+ if ($updated->response == "development" && $current->response == "upgrade") {
186
+ return array('upgraded' => '<font color="#900">Transient mismatch. Please upgrade manualy</font>');
187
+ }
188
+ else if ($updated->response == $current->response || ($updated->response == "upgrade" && $current->response == "development")){
189
+ if($updated->locale != $current->locale){
190
+ foreach($updates as $update){
191
+ if($update->locale == $current->locale){
192
+ $current_update = $update;
193
+ break;
194
+ }
195
  }
196
+ if($current_update == false)
197
+ return array('error' => ' Localization mismatch. Try again.');
198
+ } else {
199
+ $current_update = $updated;
200
  }
201
+ }
202
+ else
203
+ return array('error' => ' Transient mismatch. Try again.');
204
+ } else
205
+ return array('error' => ' Refresh transient failed. Try again.');
206
+
207
+ if($current_update != false){
208
+ global $mmb_wp_version, $wp_filesystem, $wp_version;
209
 
210
+ if(!class_exists('WP_Upgrader')){
211
+ include_once(ABSPATH.'wp-admin/includes/update.php');
212
+ if(function_exists('wp_update_core')){
213
+ $result = wp_update_core($current_update);
214
+ if(is_wp_error($result)){
215
+ return array(
216
+ 'error' => $this->mmb_get_error($result)
217
+ );
218
+ }
219
+ else
220
+ return array(
221
+ 'upgraded' => ' Upgraded successfully.'
222
+ );
223
+ }
224
+ }
225
+
226
+ if(class_exists('WP_Upgrader')){
227
+ $upgrader = new WP_Upgrader();
228
+
229
+ // Is an update available?
230
+ if (!isset($current_update->response) || $current_update->response == 'latest')
231
+ return array(
232
+ 'upgraded' => ' Upgraded successfully.'
233
+ );
234
+
235
+ $res = $upgrader->fs_connect(array(
236
+ ABSPATH,
237
+ WP_CONTENT_DIR
238
+ ));
239
+ if (is_wp_error($res))
240
+ return array(
241
+ 'error' => $this->mmb_get_error($res)
242
+ );
243
+
244
+ $wp_dir = trailingslashit($wp_filesystem->abspath());
245
+
246
+ $download = $upgrader->download_package($current_update->package);
247
+ if (is_wp_error($download))
248
+ return array(
249
+ 'error' => $this->mmb_get_error($download)
250
+ );
251
+
252
+ $working_dir = $upgrader->unpack_package($download);
253
+ if (is_wp_error($working_dir))
254
+ return array(
255
+ 'error' => $this->mmb_get_error($working_dir)
256
+ );
257
+
258
+ if (!$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true)) {
259
+ $wp_filesystem->delete($working_dir, true);
260
+ return array(
261
+ 'error' => 'Unable to move update files.'
262
+ );
263
+ }
264
+
265
+ $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
266
+
267
+ require(ABSPATH . 'wp-admin/includes/update-core.php');
268
+
269
+
270
+ $update_core = update_core($working_dir, $wp_dir);
271
+ ob_end_clean();
272
+
273
+ if (is_wp_error($update_core))
274
+ return array(
275
+ 'error' => $this->mmb_get_error($update_core)
276
+ );
277
+ ob_end_flush();
278
+ return array(
279
+ 'upgraded' => 'Upgraded successfully.'
280
+ );
281
+ } else {
282
+ return array(
283
+ 'error' => 'Upgrade failed.'
284
+ );
285
+ }
286
+ } else {
287
+ return array(
288
+ 'error' => 'Upgrade failed.'
289
+ );
290
+ }
291
  }
292
 
293
 
stats.class.php CHANGED
@@ -26,14 +26,15 @@ class MMB_Stats extends MMB_Core
26
  function get($params)
27
  {
28
  $num = extract($params);
 
29
  if($refresh == 'transient'){
30
  include_once(ABSPATH.'wp-includes/update.php');
31
- wp_update_plugins();
32
- wp_update_themes();
33
- wp_version_check();
34
  }
35
 
36
- global $wpdb, $mmb_wp_version, $mmb_plugin_dir;
37
  $stats = array();
38
 
39
  //define constants
@@ -43,22 +44,27 @@ class MMB_Stats extends MMB_Core
43
  $num_draft_comments = 0;
44
  $num_trash_comments = 0;
45
 
46
- require_once(ABSPATH . '/wp-admin/includes/update.php');
47
 
48
  $stats['worker_version'] = MMB_WORKER_VERSION;
49
- $stats['wordpress_version'] = $mmb_wp_version;
50
  $stats['wp_multisite'] = $this->mmb_multisite;
51
  $stats['php_version'] = phpversion();
52
  $stats['mysql_version'] = $wpdb->db_version();
53
 
54
- $updates = $this->mmb_get_transient('update_core');
55
-
56
- if ($updates->updates[0]->response == 'development' || version_compare($mmb_wp_version, $updates->updates[0]->current, '<')) {
57
- $updates->updates[0]->current_version = $mmb_wp_version;
58
- $stats['core_updates'] = $updates->updates[0];
59
- } else
60
- $stats['core_updates'] = false;
61
-
 
 
 
 
 
62
  $mmb_user_hits = get_option('user_hit_count');
63
  if (is_array($mmb_user_hits)) {
64
  end($mmb_user_hits);
@@ -104,7 +110,7 @@ class MMB_Stats extends MMB_Core
104
  }
105
 
106
 
107
- $all_drafts = get_posts('post_status=draft&numberposts=3&orderby=modified&order=desc');
108
  $recent_drafts = array();
109
  foreach ($all_drafts as $id => $recent_draft) {
110
  $recent = new stdClass();
@@ -117,7 +123,7 @@ class MMB_Stats extends MMB_Core
117
  $recent_drafts[] = $recent;
118
  }
119
 
120
- $all_scheduled = get_posts('post_status=future&numberposts=3&orderby=post_date&order=desc');
121
  $scheduled_posts = array();
122
  foreach ($all_scheduled as $id => $scheduled) {
123
  $recent = new stdClass();
@@ -145,9 +151,9 @@ class MMB_Stats extends MMB_Core
145
  $recent_posts[] = $recent;
146
  }
147
  usort($recent_posts, 'cmp_posts_worker');
148
- $stats['posts'] = array_slice($recent_posts, 0, 3);
149
 
150
- $all_pages_drafts = get_pages('post_status=draft&numberposts=3&orderby=modified&order=desc');
151
  $recent_pages_drafts = array();
152
  foreach ((array)$all_pages_drafts as $id => $recent_pages_draft) {
153
  $recent = new stdClass();
@@ -160,10 +166,10 @@ class MMB_Stats extends MMB_Core
160
  $recent_drafts[] = $recent;
161
  }
162
  usort($recent_drafts, 'cmp_posts_worker');
163
- $stats['drafts'] = array_slice($recent_drafts, 0, 3);
164
 
165
 
166
- $pages_scheduled = get_pages('post_status=future&numberposts=3&orderby=modified&order=desc');
167
  $recent_pages_drafts = array();
168
  foreach ((array)$pages_scheduled as $id => $scheduled) {
169
  $recent = new stdClass();
@@ -176,7 +182,7 @@ class MMB_Stats extends MMB_Core
176
  $scheduled_posts[] = $recent;
177
  }
178
  usort($scheduled_posts, 'cmp_posts_worker');
179
- $stats['scheduled'] = array_slice($scheduled_posts, 0, 3);
180
 
181
 
182
 
26
  function get($params)
27
  {
28
  $num = extract($params);
29
+
30
  if($refresh == 'transient'){
31
  include_once(ABSPATH.'wp-includes/update.php');
32
+ @wp_update_plugins();
33
+ @wp_update_themes();
34
+ @wp_version_check();
35
  }
36
 
37
+ global $wpdb, $mmb_wp_version, $mmb_plugin_dir, $wp_version;
38
  $stats = array();
39
 
40
  //define constants
44
  $num_draft_comments = 0;
45
  $num_trash_comments = 0;
46
 
47
+ include_once(ABSPATH . '/wp-admin/includes/update.php');
48
 
49
  $stats['worker_version'] = MMB_WORKER_VERSION;
50
+ $stats['wordpress_version'] = $wp_version;
51
  $stats['wp_multisite'] = $this->mmb_multisite;
52
  $stats['php_version'] = phpversion();
53
  $stats['mysql_version'] = $wpdb->db_version();
54
 
55
+ if(function_exists('get_core_updates')) {
56
+ $updates = get_core_updates();
57
+ if(!empty($updates)){
58
+ $current_transient = $updates[0];
59
+ if ($current_transient->response == "development" || version_compare($wp_version, $current_transient->current, '<')) {
60
+ $current_transient->current_version = $wp_version;
61
+ $stats['core_updates'] = $current_transient;
62
+ }
63
+ else $stats['core_updates'] = false;
64
+ }
65
+ else $stats['core_updates'] = false;
66
+ }
67
+
68
  $mmb_user_hits = get_option('user_hit_count');
69
  if (is_array($mmb_user_hits)) {
70
  end($mmb_user_hits);
110
  }
111
 
112
 
113
+ $all_drafts = get_posts('post_status=draft&numberposts=20&orderby=modified&order=desc');
114
  $recent_drafts = array();
115
  foreach ($all_drafts as $id => $recent_draft) {
116
  $recent = new stdClass();
123
  $recent_drafts[] = $recent;
124
  }
125
 
126
+ $all_scheduled = get_posts('post_status=future&numberposts=20&orderby=post_date&order=desc');
127
  $scheduled_posts = array();
128
  foreach ($all_scheduled as $id => $scheduled) {
129
  $recent = new stdClass();
151
  $recent_posts[] = $recent;
152
  }
153
  usort($recent_posts, 'cmp_posts_worker');
154
+ $stats['posts'] = array_slice($recent_posts, 0, 20);
155
 
156
+ $all_pages_drafts = get_pages('post_status=draft&numberposts=20&orderby=modified&order=desc');
157
  $recent_pages_drafts = array();
158
  foreach ((array)$all_pages_drafts as $id => $recent_pages_draft) {
159
  $recent = new stdClass();
166
  $recent_drafts[] = $recent;
167
  }
168
  usort($recent_drafts, 'cmp_posts_worker');
169
+ $stats['drafts'] = array_slice($recent_drafts, 0, 20);
170
 
171
 
172
+ $pages_scheduled = get_pages('post_status=future&numberposts=20&orderby=modified&order=desc');
173
  $recent_pages_drafts = array();
174
  foreach ((array)$pages_scheduled as $id => $scheduled) {
175
  $recent = new stdClass();
182
  $scheduled_posts[] = $recent;
183
  }
184
  usort($scheduled_posts, 'cmp_posts_worker');
185
+ $stats['scheduled'] = array_slice($scheduled_posts, 0, 20);
186
 
187
 
188
 
version CHANGED
@@ -1 +1 @@
1
- 3.9.1
1
+ 3.9.2