ManageWP Worker - Version 3.9.21

Version Description

  • New: Continuous updates! Read more at http://managewp.com/continuous-updates
Download this release

Release Info

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

Code changes from version 3.9.20 to 3.9.21

Files changed (6) hide show
  1. backup.class.php +2 -2
  2. core.class.php +3 -3
  3. helper.class.php +2 -1
  4. init.php +1203 -1180
  5. plugins/cleanup/cleanup.php +1 -1
  6. readme.txt +3 -0
backup.class.php CHANGED
@@ -1136,7 +1136,7 @@ class MMB_Backup extends MMB_Core
1136
  }
1137
 
1138
  $brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
1139
- $command = $brace . $paths['mysql'] . $brace . ' --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" ' . DB_NAME . ' < ' . $brace . $file_name . $brace;
1140
 
1141
  ob_start();
1142
  $result = $this->mmb_exec($command);
@@ -1199,7 +1199,7 @@ class MMB_Backup extends MMB_Core
1199
  function optimize_tables()
1200
  {
1201
  global $wpdb;
1202
- $query = 'SHOW TABLE STATUS FROM ' . DB_NAME;
1203
  $tables = $wpdb->get_results($wpdb->prepare($query), ARRAY_A);
1204
  foreach ($tables as $table) {
1205
  if (in_array($table['Engine'], array(
1136
  }
1137
 
1138
  $brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
1139
+ $command = $brace . $paths['mysql'] . $brace . ' --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" --default-character-set="utf8" ' . DB_NAME . ' < ' . $brace . $file_name . $brace;
1140
 
1141
  ob_start();
1142
  $result = $this->mmb_exec($command);
1199
  function optimize_tables()
1200
  {
1201
  global $wpdb;
1202
+ $query = 'SHOW TABLES';
1203
  $tables = $wpdb->get_results($wpdb->prepare($query), ARRAY_A);
1204
  foreach ($tables as $table) {
1205
  if (in_array($table['Engine'], array(
core.class.php CHANGED
@@ -423,7 +423,7 @@ class MMB_Core extends MMB_Helper
423
  delete_option('_action_message_id');
424
  }
425
 
426
- delete_option('mwp_backup_tasks');
427
  delete_option('mwp_notifications');
428
  delete_option('mwp_worker_brand');
429
  delete_option('mwp_pageview_alerts');
@@ -461,7 +461,7 @@ class MMB_Core extends MMB_Helper
461
  delete_blog_option($blog_id, '_worker_public_key');
462
  delete_blog_option($blog_id, '_action_message_id');
463
  delete_blog_option($blog_id, 'mwp_maintenace_mode');
464
- delete_blog_option($blog_id, 'mwp_backup_tasks');
465
  delete_blog_option($blog_id, 'mwp_notifications');
466
  delete_blog_option($blog_id, 'mwp_worker_brand');
467
  delete_blog_option($blog_id, 'mwp_pageview_alerts');
@@ -485,7 +485,7 @@ class MMB_Core extends MMB_Helper
485
 
486
  //Delete options
487
  delete_option('mwp_maintenace_mode');
488
- delete_option('mwp_backup_tasks');
489
  delete_option('mwp_notifications');
490
  delete_option('mwp_worker_brand');
491
  delete_option('mwp_pageview_alerts');
423
  delete_option('_action_message_id');
424
  }
425
 
426
+ //delete_option('mwp_backup_tasks');
427
  delete_option('mwp_notifications');
428
  delete_option('mwp_worker_brand');
429
  delete_option('mwp_pageview_alerts');
461
  delete_blog_option($blog_id, '_worker_public_key');
462
  delete_blog_option($blog_id, '_action_message_id');
463
  delete_blog_option($blog_id, 'mwp_maintenace_mode');
464
+ //delete_blog_option($blog_id, 'mwp_backup_tasks');
465
  delete_blog_option($blog_id, 'mwp_notifications');
466
  delete_blog_option($blog_id, 'mwp_worker_brand');
467
  delete_blog_option($blog_id, 'mwp_pageview_alerts');
485
 
486
  //Delete options
487
  delete_option('mwp_maintenace_mode');
488
+ //delete_option('mwp_backup_tasks');
489
  delete_option('mwp_notifications');
490
  delete_option('mwp_worker_brand');
491
  delete_option('mwp_pageview_alerts');
helper.class.php CHANGED
@@ -118,7 +118,7 @@ class MMB_Helper
118
  foreach($params['item_filter'] as $_items){
119
  if(!empty($_items)){
120
  foreach($_items as $_item){
121
- if(in_array($_item[0], $_mmb_item_filter[$key])){
122
  $_item[1] = isset($_item[1]) ? $_item[1] : array();
123
  $return = call_user_func(array( &$call_object, 'get_'.$_item[0]), $return, $_item[1]);
124
  }
@@ -519,6 +519,7 @@ class MMB_Helper
519
  }
520
 
521
  function is_server_writable(){
 
522
  if((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && (get_filesystem_method(array(), false) != 'direct'))
523
  return false;
524
  else
118
  foreach($params['item_filter'] as $_items){
119
  if(!empty($_items)){
120
  foreach($_items as $_item){
121
+ if(isset($_item[0]) && in_array($_item[0], $_mmb_item_filter[$key])){
122
  $_item[1] = isset($_item[1]) ? $_item[1] : array();
123
  $return = call_user_func(array( &$call_object, 'get_'.$_item[0]), $return, $_item[1]);
124
  }
519
  }
520
 
521
  function is_server_writable(){
522
+
523
  if((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && (get_filesystem_method(array(), false) != 'direct'))
524
  return false;
525
  else
init.php CHANGED
@@ -1,1184 +1,1207 @@
1
- <?php
2
- /*
3
- 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.20
8
- Author URI: http://www.prelovac.com
9
- */
10
-
11
- /*************************************************************
12
- *
13
- * init.php
14
- *
15
- * Initialize the communication with master
16
- *
17
- *
18
- * Copyright (c) 2011 Prelovac Media
19
- * www.prelovac.com
20
- **************************************************************/
21
- if(basename($_SERVER['SCRIPT_FILENAME']) == "init.php"):
22
- exit;
23
- endif;
24
- if(!defined('MMB_WORKER_VERSION'))
25
- define('MMB_WORKER_VERSION', '3.9.20');
26
-
27
- if ( !defined('MMB_XFRAME_COOKIE')){
28
- $siteurl = function_exists( 'get_site_option' ) ? get_site_option( 'siteurl' ) : get_option( 'siteurl' );
29
- define('MMB_XFRAME_COOKIE', $xframe = 'wordpress_'.md5($siteurl).'_xframe');
30
- }
31
- global $wpdb, $mmb_plugin_dir, $mmb_plugin_url, $wp_version, $mmb_filters, $_mmb_item_filter;
32
- if (version_compare(PHP_VERSION, '5.0.0', '<')) // min version 5 supported
33
- exit("<p>ManageWP Worker plugin requires PHP 5 or higher.</p>");
34
-
35
-
36
- $mmb_wp_version = $wp_version;
37
- $mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
38
- $mmb_plugin_url = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
39
-
40
- require_once("$mmb_plugin_dir/helper.class.php");
41
- require_once("$mmb_plugin_dir/core.class.php");
42
- require_once("$mmb_plugin_dir/post.class.php");
43
- require_once("$mmb_plugin_dir/comment.class.php");
44
- require_once("$mmb_plugin_dir/stats.class.php");
45
- require_once("$mmb_plugin_dir/backup.class.php");
46
- require_once("$mmb_plugin_dir/installer.class.php");
47
- require_once("$mmb_plugin_dir/link.class.php");
48
- require_once("$mmb_plugin_dir/user.class.php");
49
- require_once("$mmb_plugin_dir/api.php");
50
-
51
- require_once("$mmb_plugin_dir/plugins/search/search.php");
52
- require_once("$mmb_plugin_dir/plugins/cleanup/cleanup.php");
53
-
54
- require_once("$mmb_plugin_dir/widget.class.php");
55
-
56
- if(!function_exists( 'json_decode' ) && !function_exists( 'json_encode' )){
57
- global $mmb_plugin_dir;
58
- require_once ($mmb_plugin_dir.'/lib/json/JSON.php' );
59
-
60
- function json_decode($json_object, $assoc = false) {
61
- $json = $assoc == true ? new Services_JSON(SERVICES_JSON_LOOSE_TYPE) : new Services_JSON();
62
- return $json->decode($json_object);
63
- }
64
-
65
- function json_encode($object_data) {
66
- $json = new Services_JSON();
67
- return $json->encode($object_data);
68
- }
69
- }
70
-
71
- if( !function_exists ( 'mmb_parse_data' )) {
72
- function mmb_parse_data( $data = array() ){
73
- if( empty($data) )
74
- return $data;
75
-
76
- $data = (array) $data;
77
- if( isset($data['params']) )
78
- $data['params'] = mmb_filter_params( $data['params'] );
79
-
80
- $postkeys = array('action', 'params', 'id', 'signature', 'setting' );
81
-
82
- if( !empty($data) ){
83
- foreach($data as $key => $items){
84
- if( !in_array($key, $postkeys) )
85
- unset($data[$key]);
86
- }
87
- }
88
- return $data;
89
- }
90
- }
91
-
92
- if( !function_exists ( 'mmb_filter_params' )) {
93
- function mmb_filter_params( $array = array() ){
94
-
95
- $filter = array( 'current_user', 'wpdb' );
96
- $return = array();
97
- foreach ($array as $key => $val) {
98
- if( !is_int($key) && in_array($key, $filter) )
99
- continue;
100
-
101
- if( is_array( $val ) ) {
102
- $return[$key] = mmb_filter_params( $val );
103
- } else {
104
- $return[$key] = $val;
105
- }
106
- }
107
-
108
- return $return;
109
- }
110
- }
111
-
112
- if( !function_exists ( 'mmb_parse_request' )) {
113
- function mmb_parse_request(){
114
-
115
- if (!isset($HTTP_RAW_POST_DATA)) {
116
- $HTTP_RAW_POST_DATA = file_get_contents('php://input');
117
- }
118
- ob_start();
119
-
120
- global $current_user, $mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache, $_mmb_options;
121
- if(substr($HTTP_RAW_POST_DATA, 0, 7) == "action="){
122
- $HTTP_RAW_POST_DATA = str_replace("action=", "", $HTTP_RAW_POST_DATA);
123
- }
124
- $data = base64_decode($HTTP_RAW_POST_DATA);
125
- if ($data){
126
- $data = mmb_parse_data( unserialize( $data ) );
127
- $num = @extract( $data );
128
- }
129
- if (isset($action)) {
130
- $_wp_using_ext_object_cache = false;
131
- @set_time_limit(600);
132
-
133
- if (!$mmb_core->check_if_user_exists($params['username']))
134
- mmb_response('Username <b>' . $params['username'] . '</b> does not have administrator capabilities. Enter the correct username in the site options.', false);
135
-
136
- if ($action == 'add_site') {
137
- mmb_add_site($params);
138
- mmb_response('You should never see this.', false);
139
- }
140
-
141
- $auth = $mmb_core->authenticate_message($action . $id, $signature, $id);
142
- if ($auth === true) {
143
-
144
- if(isset($params['username']) && !is_user_logged_in()){
145
- $user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : get_userdatabylogin( $params['username'] );
146
- wp_set_current_user($user->ID);
147
- }
148
-
149
- /* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
150
- if( strlen(trim($wp_db_version)) && !defined('ACX_PLUGIN_DIR') ){
151
- if ( get_option('db_version') != $wp_db_version ) {
152
- /* in multisite network, please update database manualy */
153
- if (empty($wpmu_version) || (function_exists('is_multisite') && !is_multisite())){
154
- if( ! function_exists('wp_upgrade'))
155
- include_once(ABSPATH.'wp-admin/includes/upgrade.php');
156
-
157
- ob_clean();
158
- @wp_upgrade();
159
- @do_action('after_db_upgrade');
160
- ob_end_clean();
161
- }
162
- }
163
- }
164
-
165
- if(isset($params['secure'])){
166
- if($decrypted = $mmb_core->_secure_data($params['secure'])){
167
- $decrypted = maybe_unserialize($decrypted);
168
- if(is_array($decrypted)){
169
- foreach($decrypted as $key => $val){
170
- if(!is_numeric($key))
171
- $params[$key] = $val;
172
- }
173
- unset($params['secure']);
174
- } else $params['secure'] = $decrypted;
175
- }
176
- }
177
-
178
- if( isset($data['setting']) ){
179
- $mmb_core->save_options( $data['setting'] );
180
- }
181
-
182
- if( !$mmb_core->register_action_params( $action, $params ) ){
183
- global $_mmb_plugin_actions;
184
- $_mmb_plugin_actions[$action] = $params;
185
- }
186
-
187
-
188
- } else {
189
- mmb_response($auth['error'], false);
190
- }
191
- } else {
192
- MMB_Stats::set_hit_count();
193
- }
194
- ob_end_clean();
195
- }
196
- }
197
- /* Main response function */
198
- if( !function_exists ( 'mmb_response' )) {
199
-
200
- function mmb_response($response = false, $success = true)
201
- {
202
- $return = array();
203
-
204
- if ((is_array($response) && empty($response)) || (!is_array($response) && strlen($response) == 0))
205
- $return['error'] = 'Empty response.';
206
- else if ($success)
207
- $return['success'] = $response;
208
- else
209
- $return['error'] = $response;
210
-
211
- if( !headers_sent() ){
212
- header('HTTP/1.0 200 OK');
213
- header('Content-Type: text/plain');
214
- }
215
- exit("<MWPHEADER>" . base64_encode(serialize($return))."<ENDMWPHEADER>");
216
- }
217
- }
218
-
219
-
220
-
221
- if( !function_exists ( 'mmb_add_site' )) {
222
- function mmb_add_site($params) {
223
- global $mmb_core;
224
- $num = extract($params);
225
-
226
- if ($num) {
227
- if (!get_option('_action_message_id') && !get_option('_worker_public_key')) {
228
- $public_key = base64_decode($public_key);
229
-
230
- if (function_exists('openssl_verify')) {
231
- $verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
232
- if ($verify == 1) {
233
- $mmb_core->set_master_public_key($public_key);
234
- $mmb_core->set_worker_message_id($id);
235
- $mmb_core->get_stats_instance();
236
- if(is_array($notifications) && !empty($notifications)){
237
- $mmb_core->stats_instance->set_notifications($notifications);
238
- }
239
- if(is_array($brand) && !empty($brand)){
240
- update_option('mwp_worker_brand',$brand);
241
- }
242
-
243
- if( isset( $add_settigns ) && !empty( $add_settigns ) )
244
- apply_filters( 'mwp_website_add', $add_settigns );
245
-
246
- mmb_response($mmb_core->stats_instance->get_initial_stats(), true);
247
- } else if ($verify == 0) {
248
-
249
- //mmb_response('Site could not be added. OpenSSL verification error: "'.openssl_error_string().'". Contact your hosting support to check the OpenSSL configuration.', false);
250
-
251
- } else {
252
- mmb_response('Command not successful. Please try again.', false);
253
- }
254
- }
255
-
256
- if (!get_option('_worker_nossl_key')) {
257
- srand();
258
-
259
- $random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
260
-
261
- $mmb_core->set_random_signature($random_key);
262
- $mmb_core->set_worker_message_id($id);
263
- $mmb_core->set_master_public_key($public_key);
264
- $mmb_core->get_stats_instance();
265
- if(is_array($notifications) && !empty($notifications)){
266
- $mmb_core->stats_instance->set_notifications($notifications);
267
- }
268
-
269
- if(is_array($brand) && !empty($brand)){
270
- update_option('mwp_worker_brand',$brand);
271
- }
272
-
273
- mmb_response($mmb_core->stats_instance->get_initial_stats(), true);
274
- } else
275
- mmb_response('Please deactivate & activate ManageWP Worker plugin on your site, then re-add the site to your dashboard.', false);
276
-
277
- } else {
278
- mmb_response('Please deactivate & activate ManageWP Worker plugin on your site and re-add the site to your dashboard.', false);
279
- }
280
- } else {
281
- mmb_response('Invalid parameters received. Please try again.', false);
282
- }
283
- }
284
- }
285
-
286
- if( !function_exists ( 'mmb_remove_site' )) {
287
- function mmb_remove_site($params)
288
- {
289
- extract($params);
290
- global $mmb_core;
291
- $mmb_core->uninstall( $deactivate );
292
-
293
- include_once(ABSPATH . 'wp-admin/includes/plugin.php');
294
- $plugin_slug = basename(dirname(__FILE__)) . '/' . basename(__FILE__);
295
-
296
- if ($deactivate) {
297
- deactivate_plugins($plugin_slug, true);
298
- }
299
-
300
- if (!is_plugin_active($plugin_slug))
301
- mmb_response(array(
302
- 'deactivated' => 'Site removed successfully. <br /><br />ManageWP Worker plugin successfully deactivated.'
303
- ), true);
304
- else
305
- mmb_response(array(
306
- 'removed_data' => 'Site removed successfully. <br /><br /><b>ManageWP Worker plugin was not deactivated.</b>'
307
- ), true);
308
-
309
- }
310
- }
311
- if( !function_exists ( 'mmb_stats_get' )) {
312
- function mmb_stats_get($params)
313
- {
314
- global $mmb_core;
315
- $mmb_core->get_stats_instance();
316
- mmb_response($mmb_core->stats_instance->get($params), true);
317
- }
318
- }
319
-
320
- if( !function_exists ( 'mmb_worker_header' )) {
321
- function mmb_worker_header()
322
- { global $mmb_core, $current_user;
323
-
324
- if(!headers_sent()){
325
- if(isset($current_user->ID))
326
- $expiration = time() + apply_filters('auth_cookie_expiration', 10800, $current_user->ID, false);
327
- else
328
- $expiration = time() + 10800;
329
-
330
- setcookie(MMB_XFRAME_COOKIE, md5(MMB_XFRAME_COOKIE), $expiration, COOKIEPATH, COOKIE_DOMAIN, false, true);
331
- $_COOKIE[MMB_XFRAME_COOKIE] = md5(MMB_XFRAME_COOKIE);
332
- }
333
- }
334
- }
335
-
336
- if( !function_exists ( 'mmb_pre_init_stats' )) {
337
- function mmb_pre_init_stats( $params )
338
- {
339
- global $mmb_core;
340
- $mmb_core->get_stats_instance();
341
- return $mmb_core->stats_instance->pre_init_stats($params);
342
- }
343
- }
344
-
345
- if( !function_exists ( 'mwp_datasend' )) {
346
- function mwp_datasend( $params = array() )
347
- {
348
- global $mmb_core, $_mmb_item_filter, $_mmb_options;
349
- if( isset($_mmb_options['datacron']) ){
350
-
351
- $_mmb_remoteurl = get_option('home');
352
- $_mmb_remoteown = isset($_mmb_options['dataown']) && !empty($_mmb_options['dataown']) ? $_mmb_options['dataown'] : false;
353
-
354
- if( empty($_mmb_remoteown) )
355
- return;
356
-
357
- $_mmb_item_filter['pre_init_stats'] = array( 'core_update', 'hit_counter', 'comments', 'backups', 'posts', 'drafts', 'scheduled' );
358
- $_mmb_item_filter['get'] = array( 'updates', 'errors' );
359
- $mmb_core->get_stats_instance();
360
-
361
- $filter = array(
362
- 'refresh' => '',
363
- 'item_filter' => array(
364
- 'get_stats' => array(
365
- array('updates', array('plugins' => true, 'themes' => true, 'premium' => true )),
366
- array('core_update', array('core' => true )),
367
- array('posts', array('numberposts' => 5 )),
368
- array('drafts', array('numberposts' => 5 )),
369
- array('scheduled', array('numberposts' => 5 )),
370
- array('hit_counter'),
371
- array('comments', array('numberposts' => 5 )),
372
- array('backups'),
373
- 'plugins' => array('cleanup' => array(
374
- 'overhead' => array(),
375
- 'revisions' => array( 'num_to_keep' => 'r_5'),
376
- 'spam' => array(),
377
- )
378
- ),
379
- ),
380
- )
381
- );
382
-
383
- $pre_init_data = $mmb_core->stats_instance->pre_init_stats($filter);
384
- $init_data = $mmb_core->stats_instance->get($filter);
385
-
386
- $data = array_merge($init_data, $pre_init_data);
387
- $hash = $mmb_core->get_secure_hash();
388
-
389
- $datasend['datasend'] = $mmb_core->encrypt_data($data);
390
- $datasend['sitehome'] = base64_encode($_mmb_remoteown.'[]'.$_mmb_remoteurl);
391
- $datasend['sitehash'] = md5($hash.$_mmb_remoteown.$_mmb_remoteurl);
392
-
393
- if ( !class_exists('WP_Http') )
394
- include_once(ABSPATH . WPINC . '/class-http.php');
395
-
396
- $remote = array();
397
- $remote['body'] = $datasend;
398
- $result = wp_remote_post($_mmb_options['datacron'], $remote);
399
- }
400
- }
401
- }
402
-
403
- //post
404
- if( !function_exists ( 'mmb_post_create' )) {
405
- function mmb_post_create($params)
406
- {
407
- global $mmb_core;
408
- $mmb_core->get_post_instance();
409
- $return = $mmb_core->post_instance->create($params);
410
- if (is_int($return))
411
- mmb_response($return, true);
412
- else{
413
- if(isset($return['error'])){
414
- mmb_response($return['error'], false);
415
- } else {
416
- mmb_response($return, false);
417
- }
418
- }
419
- }
420
- }
421
-
422
- if( !function_exists ( 'mmb_change_post_status' )) {
423
- function mmb_change_post_status($params)
424
- {
425
- global $mmb_core;
426
- $mmb_core->get_post_instance();
427
- $return = $mmb_core->post_instance->change_status($params);
428
- //mmb_response($return, true);
429
-
430
- }
431
- }
432
-
433
- //comments
434
- if( !function_exists ( 'mmb_change_comment_status' )) {
435
- function mmb_change_comment_status($params)
436
- {
437
- global $mmb_core;
438
- $mmb_core->get_comment_instance();
439
- $return = $mmb_core->comment_instance->change_status($params);
440
- //mmb_response($return, true);
441
- if ($return){
442
- $mmb_core->get_stats_instance();
443
- mmb_response($mmb_core->stats_instance->get_comments_stats($params), true);
444
- }else
445
- mmb_response('Comment not updated', false);
446
- }
447
-
448
- }
449
- if( !function_exists ( 'mmb_comment_stats_get' )) {
450
- function mmb_comment_stats_get($params)
451
- {
452
- global $mmb_core;
453
- $mmb_core->get_stats_instance();
454
- mmb_response($mmb_core->stats_instance->get_comments_stats($params), true);
455
- }
456
- }
457
-
458
- if( !function_exists ( 'mmb_backup_now' )) {
459
- //backup
460
- function mmb_backup_now($params)
461
- {
462
- global $mmb_core;
463
-
464
- $mmb_core->get_backup_instance();
465
- $return = $mmb_core->backup_instance->backup($params);
466
-
467
- if (is_array($return) && array_key_exists('error', $return))
468
- mmb_response($return['error'], false);
469
- else {
470
- mmb_response($return, true);
471
- }
472
- }
473
- }
474
-
475
- if( !function_exists ( 'mmb_run_task_now' )) {
476
- function mmb_run_task_now($params)
477
- {
478
- global $mmb_core;
479
- $mmb_core->get_backup_instance();
480
- $return = $mmb_core->backup_instance->task_now($params['task_name']);
481
- if (is_array($return) && array_key_exists('error', $return))
482
- mmb_response($return['error'], false);
483
- else {
484
- mmb_response($return, true);
485
- }
486
- }
487
- }
488
-
489
- if( !function_exists ( 'mmb_email_backup' )) {
490
- function mmb_email_backup($params)
491
- {
492
- global $mmb_core;
493
- $mmb_core->get_backup_instance();
494
- $return = $mmb_core->backup_instance->email_backup($params);
495
-
496
- if (is_array($return) && array_key_exists('error', $return))
497
- mmb_response($return['error'], false);
498
- else {
499
- mmb_response($return, true);
500
- }
501
- }
502
- }
503
-
504
- if( !function_exists ( 'mmb_check_backup_compat' )) {
505
- function mmb_check_backup_compat($params)
506
- {
507
- global $mmb_core;
508
- $mmb_core->get_backup_instance();
509
- $return = $mmb_core->backup_instance->check_backup_compat($params);
510
-
511
- if (is_array($return) && array_key_exists('error', $return))
512
- mmb_response($return['error'], false);
513
- else {
514
- mmb_response($return, true);
515
- }
516
- }
517
- }
518
-
519
- if( !function_exists ( 'mmb_get_backup_req' )) {
520
- function mmb_get_backup_req( $params )
521
- {
522
- global $mmb_core;
523
- $mmb_core->get_stats_instance();
524
- $return = $mmb_core->stats_instance->get_backup_req($params);
525
-
526
- mmb_response($return, true);
527
- }
528
- }
529
-
530
- if( !function_exists ( 'mmb_scheduled_backup' )) {
531
- function mmb_scheduled_backup($params)
532
- {
533
- global $mmb_core;
534
- $mmb_core->get_backup_instance();
535
- $return = $mmb_core->backup_instance->set_backup_task($params);
536
- mmb_response($return, $return);
537
- }
538
- }
539
-
540
- if( !function_exists ( 'mmm_delete_backup' )) {
541
- function mmm_delete_backup($params)
542
- {
543
- global $mmb_core;
544
- $mmb_core->get_backup_instance();
545
- $return = $mmb_core->backup_instance->delete_backup($params);
546
- mmb_response($return, $return);
547
- }
548
- }
549
-
550
- if( !function_exists ( 'mmb_optimize_tables' )) {
551
- function mmb_optimize_tables($params)
552
- {
553
- global $mmb_core;
554
- $mmb_core->get_backup_instance();
555
- $return = $mmb_core->backup_instance->optimize_tables();
556
- if ($return)
557
- mmb_response($return, true);
558
- else
559
- mmb_response(false, false);
560
- }
561
- }
562
- if( !function_exists ( 'mmb_restore_now' )) {
563
- function mmb_restore_now($params)
564
- {
565
- global $mmb_core;
566
- $mmb_core->get_backup_instance();
567
- $return = $mmb_core->backup_instance->restore($params);
568
- if (is_array($return) && array_key_exists('error', $return))
569
- mmb_response($return['error'], false);
570
- else
571
- mmb_response($return, true);
572
-
573
- }
574
- }
575
-
576
- if( !function_exists ( 'mmb_remote_backup_now' )) {
577
- function mmb_remote_backup_now($params)
578
- {
579
- global $mmb_core;
580
- $backup_instance = $mmb_core->get_backup_instance();
581
- $return = $mmb_core->backup_instance->remote_backup_now($params);
582
- if (is_array($return) && array_key_exists('error', $return))
583
- mmb_response($return['error'], false);
584
- else
585
- mmb_response($return, true);
586
- }
587
- }
588
-
589
-
590
- if( !function_exists ( 'mmb_clean_orphan_backups' )) {
591
- function mmb_clean_orphan_backups()
592
- {
593
- global $mmb_core;
594
- $backup_instance = $mmb_core->get_backup_instance();
595
- $return = $mmb_core->backup_instance->cleanup();
596
- if(is_array($return))
597
- mmb_response($return, true);
598
- else
599
- mmb_response($return, false);
600
- }
601
- }
602
-
603
- if( !function_exists ( 'mmb_update_worker_plugin' )) {
604
- function mmb_update_worker_plugin($params)
605
- {
606
- global $mmb_core;
607
- mmb_response($mmb_core->update_worker_plugin($params), true);
608
- }
609
- }
610
-
611
- if( !function_exists ( 'mmb_wp_checkversion' )) {
612
- function mmb_wp_checkversion($params)
613
- {
614
- include_once(ABSPATH . 'wp-includes/version.php');
615
- global $mmb_wp_version, $mmb_core;
616
- mmb_response($mmb_wp_version, true);
617
- }
618
- }
619
- if( !function_exists ( 'mmb_search_posts_by_term' )) {
620
- function mmb_search_posts_by_term($params)
621
- {
622
- global $mmb_core;
623
- $mmb_core->get_search_instance();
624
-
625
- $search_type = trim($params['search_type']);
626
- $search_term = strtolower(trim($params['search_term']));
627
-
628
- switch ($search_type){
629
- case 'page_post':
630
- $return = $mmb_core->search_instance->search_posts_by_term($params);
631
- if($return){
632
- $return = serialize($return);
633
- mmb_response($return, true);
634
- }else{
635
- mmb_response('No posts found', false);
636
- }
637
- break;
638
-
639
- case 'plugin':
640
- $plugins = get_option('active_plugins');
641
-
642
- $have_plugin = false;
643
- foreach ($plugins as $plugin) {
644
- if(strpos($plugin, $search_term)>-1){
645
- $have_plugin = true;
646
- }
647
- }
648
- if($have_plugin){
649
- mmb_response(serialize($plugin), true);
650
- }else{
651
- mmb_response(false, false);
652
- }
653
- break;
654
- case 'theme':
655
- $theme = strtolower(get_option('template'));
656
- if(strpos($theme, $search_term)>-1){
657
- mmb_response($theme, true);
658
- }else{
659
- mmb_response(false, false);
660
- }
661
- break;
662
- default: mmb_response(false, false);
663
- }
664
- $return = $mmb_core->search_instance->search_posts_by_term($params);
665
-
666
-
667
-
668
- if ($return_if_true) {
669
- mmb_response($return_value, true);
670
- } else {
671
- mmb_response($return_if_false, false);
672
- }
673
- }
674
- }
675
-
676
- if( !function_exists ( 'mmb_install_addon' )) {
677
- function mmb_install_addon($params)
678
- {
679
- global $mmb_core;
680
- $mmb_core->get_installer_instance();
681
- $return = $mmb_core->installer_instance->install_remote_file($params);
682
- mmb_response($return, true);
683
-
684
- }
685
- }
686
-
687
- if( !function_exists ( 'mmb_do_upgrade' )) {
688
- function mmb_do_upgrade($params)
689
- {
690
- global $mmb_core, $mmb_upgrading;
691
- $mmb_core->get_installer_instance();
692
- $return = $mmb_core->installer_instance->do_upgrade($params);
693
- mmb_response($return, true);
694
-
695
- }
696
- }
697
-
698
- if( !function_exists ('mmb_get_links')) {
699
- function mmb_get_links($params)
700
- {
701
- global $mmb_core;
702
- $mmb_core->get_link_instance();
703
- $return = $mmb_core->link_instance->get_links($params);
704
- if (is_array($return) && array_key_exists('error', $return))
705
- mmb_response($return['error'], false);
706
- else {
707
- mmb_response($return, true);
708
- }
709
- }
710
- }
711
-
712
- if( !function_exists ( 'mmb_add_link' )) {
713
- function mmb_add_link($params)
714
- {
715
- global $mmb_core;
716
- $mmb_core->get_link_instance();
717
- $return = $mmb_core->link_instance->add_link($params);
718
- if (is_array($return) && array_key_exists('error', $return))
719
-
720
- mmb_response($return['error'], false);
721
- else {
722
- mmb_response($return, true);
723
- }
724
-
725
- }
726
- }
727
-
728
- if( !function_exists ('mmb_delete_link')) {
729
- function mmb_delete_link($params)
730
- {
731
- global $mmb_core;
732
- $mmb_core->get_link_instance();
733
-
734
- $return = $mmb_core->link_instance->delete_link($params);
735
- if (is_array($return) && array_key_exists('error', $return))
736
- mmb_response($return['error'], false);
737
- else {
738
- mmb_response($return, true);
739
- }
740
- }
741
- }
742
-
743
- if( !function_exists ('mmb_delete_links')) {
744
- function mmb_delete_links($params)
745
- {
746
- global $mmb_core;
747
- $mmb_core->get_link_instance();
748
-
749
- $return = $mmb_core->link_instance->delete_links($params);
750
- if (is_array($return) && array_key_exists('error', $return))
751
- mmb_response($return['error'], false);
752
- else {
753
- mmb_response($return, true);
754
- }
755
- }
756
- }
757
-
758
- if( !function_exists ('mmb_get_comments')) {
759
- function mmb_get_comments($params)
760
- {
761
- global $mmb_core;
762
- $mmb_core->get_comment_instance();
763
- $return = $mmb_core->comment_instance->get_comments($params);
764
- if (is_array($return) && array_key_exists('error', $return))
765
- mmb_response($return['error'], false);
766
- else {
767
- mmb_response($return, true);
768
- }
769
- }
770
- }
771
-
772
- if( !function_exists ('mmb_action_comment')) {
773
- function mmb_action_comment($params)
774
- {
775
- global $mmb_core;
776
- $mmb_core->get_comment_instance();
777
-
778
- $return = $mmb_core->comment_instance->action_comment($params);
779
- if (is_array($return) && array_key_exists('error', $return))
780
- mmb_response($return['error'], false);
781
- else {
782
- mmb_response($return, true);
783
- }
784
- }
785
- }
786
-
787
- if( !function_exists ('mmb_bulk_action_comments')) {
788
- function mmb_bulk_action_comments($params)
789
- {
790
- global $mmb_core;
791
- $mmb_core->get_comment_instance();
792
-
793
- $return = $mmb_core->comment_instance->bulk_action_comments($params);
794
- if (is_array($return) && array_key_exists('error', $return))
795
- mmb_response($return['error'], false);
796
- else {
797
- mmb_response($return, true);
798
- }
799
- }
800
- }
801
-
802
- if( !function_exists ('mmb_reply_comment')) {
803
- function mmb_reply_comment($params)
804
- {
805
- global $mmb_core;
806
- $mmb_core->get_comment_instance();
807
-
808
- $return = $mmb_core->comment_instance->reply_comment($params);
809
- if (is_array($return) && array_key_exists('error', $return))
810
- mmb_response($return['error'], false);
811
- else {
812
- mmb_response($return, true);
813
- }
814
- }
815
- }
816
-
817
- if( !function_exists ( 'mmb_add_user' )) {
818
- function mmb_add_user($params)
819
- {
820
- global $mmb_core;
821
- $mmb_core->get_user_instance();
822
- $return = $mmb_core->user_instance->add_user($params);
823
- if (is_array($return) && array_key_exists('error', $return))
824
-
825
- mmb_response($return['error'], false);
826
- else {
827
- mmb_response($return, true);
828
- }
829
-
830
- }
831
- }
832
-
833
- if( !function_exists ('mmb_get_users')) {
834
- function mmb_get_users($params)
835
- {
836
- global $mmb_core;
837
- $mmb_core->get_user_instance();
838
- $return = $mmb_core->user_instance->get_users($params);
839
- if (is_array($return) && array_key_exists('error', $return))
840
- mmb_response($return['error'], false);
841
- else {
842
- mmb_response($return, true);
843
- }
844
- }
845
- }
846
-
847
- if( !function_exists ('mmb_edit_users')) {
848
- function mmb_edit_users($params)
849
- {
850
- global $mmb_core;
851
- $mmb_core->get_user_instance();
852
- $return = $mmb_core->user_instance->edit_users($params);
853
- mmb_response($return, true);
854
- }
855
- }
856
-
857
- if( !function_exists ('mmb_get_posts')) {
858
- function mmb_get_posts($params)
859
- {
860
- global $mmb_core;
861
- $mmb_core->get_post_instance();
862
-
863
- $return = $mmb_core->post_instance->get_posts($params);
864
- if (is_array($return) && array_key_exists('error', $return))
865
- mmb_response($return['error'], false);
866
- else {
867
- mmb_response($return, true);
868
- }
869
- }
870
- }
871
-
872
- if( !function_exists ('mmb_delete_post')) {
873
- function mmb_delete_post($params)
874
- {
875
- global $mmb_core;
876
- $mmb_core->get_post_instance();
877
-
878
- $return = $mmb_core->post_instance->delete_post($params);
879
- if (is_array($return) && array_key_exists('error', $return))
880
- mmb_response($return['error'], false);
881
- else {
882
- mmb_response($return, true);
883
- }
884
- }
885
- }
886
-
887
- if( !function_exists ('mmb_delete_posts')) {
888
- function mmb_delete_posts($params)
889
- {
890
- global $mmb_core;
891
- $mmb_core->get_post_instance();
892
-
893
- $return = $mmb_core->post_instance->delete_posts($params);
894
- if (is_array($return) && array_key_exists('error', $return))
895
- mmb_response($return['error'], false);
896
- else {
897
- mmb_response($return, true);
898
- }
899
- }
900
- }
901
-
902
- if( !function_exists ('mmb_edit_posts')) {
903
- function mmb_edit_posts($params)
904
- {
905
- global $mmb_core;
906
- $mmb_core->get_posts_instance();
907
- $return = $mmb_core->posts_instance->edit_posts($params);
908
- mmb_response($return, true);
909
- }
910
- }
911
-
912
- if( !function_exists ('mmb_get_pages')) {
913
- function mmb_get_pages($params)
914
- {
915
- global $mmb_core;
916
- $mmb_core->get_post_instance();
917
-
918
- $return = $mmb_core->post_instance->get_pages($params);
919
- if (is_array($return) && array_key_exists('error', $return))
920
- mmb_response($return['error'], false);
921
- else {
922
- mmb_response($return, true);
923
- }
924
- }
925
- }
926
-
927
- if( !function_exists ('mmb_delete_page')) {
928
- function mmb_delete_page($params)
929
- {
930
- global $mmb_core;
931
- $mmb_core->get_post_instance();
932
-
933
- $return = $mmb_core->post_instance->delete_page($params);
934
- if (is_array($return) && array_key_exists('error', $return))
935
- mmb_response($return['error'], false);
936
- else {
937
- mmb_response($return, true);
938
- }
939
- }
940
- }
941
-
942
- if( !function_exists ( 'mmb_iframe_plugins_fix' )) {
943
- function mmb_iframe_plugins_fix($update_actions)
944
- {
945
- foreach($update_actions as $key => $action)
946
- {
947
- $update_actions[$key] = str_replace('target="_parent"','',$action);
948
- }
949
-
950
- return $update_actions;
951
-
952
- }
953
- }
954
- if( !function_exists ( 'mmb_execute_php_code' )) {
955
- function mmb_execute_php_code($params)
956
- {
957
- ob_start();
958
- eval($params['code']);
959
- $return = ob_get_flush();
960
- mmb_response(print_r($return, true), true);
961
- }
962
- }
963
-
964
- if( !function_exists ( 'mmb_set_notifications' )) {
965
- function mmb_set_notifications($params)
966
- {
967
- global $mmb_core;
968
- $mmb_core->get_stats_instance();
969
- $return = $mmb_core->stats_instance->set_notifications($params);
970
- if (is_array($return) && array_key_exists('error', $return))
971
- mmb_response($return['error'], false);
972
- else {
973
- mmb_response($return, true);
974
- }
975
-
976
- }
977
- }
978
-
979
- if( !function_exists ( 'mmb_set_alerts' )) {
980
- function mmb_set_alerts($params)
981
- {
982
- global $mmb_core;
983
- $mmb_core->get_stats_instance();
984
- $return = $mmb_core->stats_instance->set_alerts($params);
985
- mmb_response(true, true);
986
- }
987
-
988
- }
989
- if( !function_exists ('mmb_get_dbname')) {
990
- function mmb_get_dbname($params)
991
- {
992
- global $mmb_core;
993
- $mmb_core->get_stats_instance();
994
-
995
- $return = $mmb_core->stats_instance->get_active_db();
996
- if (is_array($return) && array_key_exists('error', $return))
997
- mmb_response($return['error'], false);
998
- else {
999
- mmb_response($return, true);
1000
- }
1001
- }
1002
- }
1003
-
1004
- if( !function_exists('mmb_more_reccurences') ){
1005
- //Backup Tasks
1006
- add_filter('cron_schedules', 'mmb_more_reccurences');
1007
- function mmb_more_reccurences($schedules) {
1008
- $schedules['halfminute'] = array('interval' => 30, 'display' => 'Once in a half minute');
1009
- $schedules['minutely'] = array('interval' => 60, 'display' => 'Once in a minute');
1010
- $schedules['fiveminutes'] = array('interval' => 300, 'display' => 'Once every five minutes');
1011
- $schedules['tenminutes'] = array('interval' => 600, 'display' => 'Once every ten minutes');
1012
- $schedules['sixhours'] = array('interval' => 21600, 'display' => 'Every six hours');
1013
- $schedules['fourhours'] = array('interval' => 14400, 'display' => 'Every four hours');
1014
- $schedules['threehours'] = array('interval' => 10800, 'display' => 'Every three hours');
1015
-
1016
- return $schedules;
1017
- }
1018
- }
1019
-
1020
- add_action('mwp_backup_tasks', 'mwp_check_backup_tasks');
1021
-
1022
- if( !function_exists('mwp_check_backup_tasks') ){
1023
- function mwp_check_backup_tasks() {
1024
- global $mmb_core, $_wp_using_ext_object_cache;
1025
- $_wp_using_ext_object_cache = false;
1026
-
1027
- $mmb_core->get_backup_instance();
1028
- $mmb_core->backup_instance->check_backup_tasks();
1029
- }
1030
- }
1031
-
1032
- // if (!wp_next_scheduled('mwp_notifications')) {
1033
- // wp_schedule_event( time(), 'twicedaily', 'mwp_notifications' );
1034
- // }
1035
- // add_action('mwp_notifications', 'mwp_check_notifications');
1036
-
1037
-
1038
- if (!wp_next_scheduled('mwp_datasend')) {
1039
- wp_schedule_event( time(), 'threehours', 'mwp_datasend' );
1040
- }
1041
- add_action('mwp_datasend', 'mwp_datasend');
1042
-
1043
- if( !function_exists('mwp_check_notifications') ){
1044
- function mwp_check_notifications() {
1045
- global $mmb_core, $_wp_using_ext_object_cache;
1046
- $_wp_using_ext_object_cache = false;
1047
-
1048
- $mmb_core->get_stats_instance();
1049
- $mmb_core->stats_instance->check_notifications();
1050
- }
1051
- }
1052
-
1053
-
1054
- if( !function_exists('mmb_get_plugins_themes') ){
1055
- function mmb_get_plugins_themes($params) {
1056
- global $mmb_core;
1057
- $mmb_core->get_installer_instance();
1058
- $return = $mmb_core->installer_instance->get($params);
1059
- mmb_response($return, true);
1060
- }
1061
- }
1062
-
1063
- if( !function_exists('mmb_edit_plugins_themes') ){
1064
- function mmb_edit_plugins_themes($params) {
1065
- global $mmb_core;
1066
- $mmb_core->get_installer_instance();
1067
- $return = $mmb_core->installer_instance->edit($params);
1068
- mmb_response($return, true);
1069
- }
1070
- }
1071
-
1072
- if( !function_exists('mmb_worker_brand')){
1073
- function mmb_worker_brand($params) {
1074
- update_option("mwp_worker_brand",$params['brand']);
1075
- mmb_response(true, true);
1076
- }
1077
- }
1078
-
1079
- if( !function_exists('mmb_maintenance_mode')){
1080
- function mmb_maintenance_mode( $params ) {
1081
- global $wp_object_cache;
1082
-
1083
- $default = get_option('mwp_maintenace_mode');
1084
- $params = empty($default) ? $params : array_merge($default, $params);
1085
- update_option("mwp_maintenace_mode", $params);
1086
-
1087
- if(!empty($wp_object_cache))
1088
- @$wp_object_cache->flush();
1089
- mmb_response(true, true);
1090
- }
1091
- }
1092
-
1093
- if( !function_exists('mmb_plugin_actions') ){
1094
- function mmb_plugin_actions() {
1095
- global $mmb_actions, $mmb_core;
1096
-
1097
- if(!empty($mmb_actions)){
1098
- global $_mmb_plugin_actions;
1099
- if(!empty($_mmb_plugin_actions)){
1100
- $failed = array();
1101
- foreach($_mmb_plugin_actions as $action => $params){
1102
- if(isset($mmb_actions[$action]))
1103
- call_user_func($mmb_actions[$action], $params);
1104
- else
1105
- $failed[] = $action;
1106
- }
1107
- if(!empty($failed)){
1108
- $f = implode(', ', $failed);
1109
- $s = count($f) > 1 ? 'Actions "' . $f . '" do' : 'Action "' . $f . '" does';
1110
- mmb_response($s.' not exist. Please update your Worker plugin.', false);
1111
- }
1112
-
1113
- }
1114
- }
1115
-
1116
- global $pagenow, $current_user, $mmode;
1117
- if( !is_admin() && !in_array($pagenow, array( 'wp-login.php' ))){
1118
- $mmode = get_option('mwp_maintenace_mode');
1119
- if( !empty($mmode) ){
1120
- if(isset($mmode['active']) && $mmode['active'] == true){
1121
- if(isset($current_user->data) && !empty($current_user->data) && isset($mmode['hidecaps']) && !empty($mmode['hidecaps'])){
1122
- $usercaps = array();
1123
- if(isset($current_user->caps) && !empty($current_user->caps)){
1124
- $usercaps = $current_user->caps;
1125
- }
1126
- foreach($mmode['hidecaps'] as $cap => $hide){
1127
- if(!$hide)
1128
- continue;
1129
-
1130
- foreach($usercaps as $ucap => $val){
1131
- if($ucap == $cap){
1132
- ob_end_clean();
1133
- ob_end_flush();
1134
- die($mmode['template']);
1135
- }
1136
- }
1137
- }
1138
- } else
1139
- die($mmode['template']);
1140
- }
1141
- }
1142
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1143
 
1144
  if (file_exists(dirname(__FILE__) . '/log')) {
1145
  unlink(dirname(__FILE__) . '/log');
1146
- }
1147
- }
1148
- }
1149
-
1150
- $mmb_core = new MMB_Core();
1151
-
1152
- if(isset($_GET['auto_login']))
1153
- $mmb_core->automatic_login();
1154
-
1155
- if (function_exists('register_activation_hook'))
1156
- register_activation_hook( __FILE__ , array( $mmb_core, 'install' ));
1157
-
1158
- if (function_exists('register_deactivation_hook'))
1159
- register_deactivation_hook(__FILE__, array( $mmb_core, 'uninstall' ));
1160
-
1161
- if (function_exists('add_action'))
1162
- add_action('init', 'mmb_plugin_actions', 99999);
1163
-
1164
- if (function_exists('add_filter'))
1165
- add_filter('install_plugin_complete_actions','mmb_iframe_plugins_fix');
1166
-
1167
- if(!function_exists('mwb_edit_redirect_override')){
1168
- function mwb_edit_redirect_override($location = false, $comment_id = false){
1169
- if(isset($_COOKIE[MMB_XFRAME_COOKIE])){
1170
- $location = get_site_url().'/wp-admin/edit-comments.php';
1171
- }
1172
- return $location;
1173
- }
1174
- }
1175
- if (function_exists('add_filter'))
1176
- add_filter('comment_edit_redirect', 'mwb_edit_redirect_override');
1177
-
1178
- if( isset($_COOKIE[MMB_XFRAME_COOKIE]) ){
1179
- remove_action( 'admin_init', 'send_frame_options_header');
1180
- remove_action( 'login_init', 'send_frame_options_header');
1181
- }
1182
-
1183
-
1184
  ?>
1
+ <?php
2
+ /*
3
+ 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.21
8
+ Author URI: http://www.prelovac.com
9
+ */
10
+
11
+ /*************************************************************
12
+ *
13
+ * init.php
14
+ *
15
+ * Initialize the communication with master
16
+ *
17
+ *
18
+ * Copyright (c) 2011 Prelovac Media
19
+ * www.prelovac.com
20
+ **************************************************************/
21
+ if(basename($_SERVER['SCRIPT_FILENAME']) == "init.php"):
22
+ exit;
23
+ endif;
24
+ if(!defined('MMB_WORKER_VERSION'))
25
+ define('MMB_WORKER_VERSION', '3.9.21');
26
+
27
+ if ( !defined('MMB_XFRAME_COOKIE')){
28
+ $siteurl = function_exists( 'get_site_option' ) ? get_site_option( 'siteurl' ) : get_option( 'siteurl' );
29
+ define('MMB_XFRAME_COOKIE', $xframe = 'wordpress_'.md5($siteurl).'_xframe');
30
+ }
31
+ global $wpdb, $mmb_plugin_dir, $mmb_plugin_url, $wp_version, $mmb_filters, $_mmb_item_filter;
32
+ if (version_compare(PHP_VERSION, '5.0.0', '<')) // min version 5 supported
33
+ exit("<p>ManageWP Worker plugin requires PHP 5 or higher.</p>");
34
+
35
+
36
+ $mmb_wp_version = $wp_version;
37
+ $mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
38
+ $mmb_plugin_url = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
39
+
40
+ require_once("$mmb_plugin_dir/helper.class.php");
41
+ require_once("$mmb_plugin_dir/core.class.php");
42
+ require_once("$mmb_plugin_dir/post.class.php");
43
+ require_once("$mmb_plugin_dir/comment.class.php");
44
+ require_once("$mmb_plugin_dir/stats.class.php");
45
+ require_once("$mmb_plugin_dir/backup.class.php");
46
+ require_once("$mmb_plugin_dir/installer.class.php");
47
+ require_once("$mmb_plugin_dir/link.class.php");
48
+ require_once("$mmb_plugin_dir/user.class.php");
49
+ require_once("$mmb_plugin_dir/api.php");
50
+
51
+ require_once("$mmb_plugin_dir/plugins/search/search.php");
52
+ require_once("$mmb_plugin_dir/plugins/cleanup/cleanup.php");
53
+
54
+ require_once("$mmb_plugin_dir/widget.class.php");
55
+
56
+ if(!function_exists( 'json_decode' ) && !function_exists( 'json_encode' )){
57
+ global $mmb_plugin_dir;
58
+ require_once ($mmb_plugin_dir.'/lib/json/JSON.php' );
59
+
60
+ function json_decode($json_object, $assoc = false) {
61
+ $json = $assoc == true ? new Services_JSON(SERVICES_JSON_LOOSE_TYPE) : new Services_JSON();
62
+ return $json->decode($json_object);
63
+ }
64
+
65
+ function json_encode($object_data) {
66
+ $json = new Services_JSON();
67
+ return $json->encode($object_data);
68
+ }
69
+ }
70
+
71
+ if( !function_exists ( 'mmb_parse_data' )) {
72
+ function mmb_parse_data( $data = array() ){
73
+ if( empty($data) )
74
+ return $data;
75
+
76
+ $data = (array) $data;
77
+ if( isset($data['params']) )
78
+ $data['params'] = mmb_filter_params( $data['params'] );
79
+
80
+ $postkeys = array('action', 'params', 'id', 'signature', 'setting' );
81
+
82
+ if( !empty($data) ){
83
+ foreach($data as $key => $items){
84
+ if( !in_array($key, $postkeys) )
85
+ unset($data[$key]);
86
+ }
87
+ }
88
+ return $data;
89
+ }
90
+ }
91
+
92
+ if( !function_exists ( 'mmb_filter_params' )) {
93
+ function mmb_filter_params( $array = array() ){
94
+
95
+ $filter = array( 'current_user', 'wpdb' );
96
+ $return = array();
97
+ foreach ($array as $key => $val) {
98
+ if( !is_int($key) && in_array($key, $filter) )
99
+ continue;
100
+
101
+ if( is_array( $val ) ) {
102
+ $return[$key] = mmb_filter_params( $val );
103
+ } else {
104
+ $return[$key] = $val;
105
+ }
106
+ }
107
+
108
+ return $return;
109
+ }
110
+ }
111
+ if( !function_exists ( 'hex2bin' )) {
112
+ function hex2bin($h){
113
+ if (!is_string($h)) return null;
114
+ $r='';
115
+ for ($a=0; $a<strlen($h); $a+=2) { $r.=chr(hexdec($h{$a}.$h{($a+1)})); }
116
+ return $r;
117
+ }
118
+ }
119
+ if( !function_exists ( 'mmb_parse_request' )) {
120
+ function mmb_parse_request(){
121
+
122
+ if (!isset($HTTP_RAW_POST_DATA)) {
123
+ $HTTP_RAW_POST_DATA = file_get_contents('php://input');
124
+ }
125
+ ob_start();
126
+
127
+ global $current_user, $mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache, $_mmb_options;
128
+ /*$data = array();
129
+ if(substr($HTTP_RAW_POST_DATA, 0, 15) == "mwp_a=managewp&"){
130
+ $HTTP_RAW_POST_DATA = str_replace("mwp_a=managewp&", "", $HTTP_RAW_POST_DATA);
131
+ parse_str($HTTP_RAW_POST_DATA, $data);
132
+ }*/
133
+ if(substr($HTTP_RAW_POST_DATA, 0, 7) == "action="){
134
+ $HTTP_RAW_POST_DATA = str_replace("action=", "", $HTTP_RAW_POST_DATA);
135
+ }
136
+ $data = base64_decode($HTTP_RAW_POST_DATA);
137
+ if ($data){
138
+ $data = mmb_parse_data( @unserialize($data) );
139
+ $num = @extract( $data );
140
+ //$signature = base64_decode($signature);
141
+ }
142
+
143
+ if (isset($action)) {
144
+ $_wp_using_ext_object_cache = false;
145
+ @set_time_limit(600);
146
+
147
+ if (!$mmb_core->check_if_user_exists($params['username']))
148
+ mmb_response('Username <b>' . $params['username'] . '</b> does not have administrator capabilities. Enter the correct username in the site options.', false);
149
+
150
+ if ($action == 'add_site') {
151
+ mmb_add_site($params);
152
+ mmb_response('You should never see this.', false);
153
+ }
154
+
155
+ $auth = $mmb_core->authenticate_message($action . $id, $signature, $id);
156
+ if ($auth === true) {
157
+
158
+ if(isset($params['username']) && !is_user_logged_in()){
159
+ $user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : get_userdatabylogin( $params['username'] );
160
+ wp_set_current_user($user->ID);
161
+ }
162
+
163
+ /* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
164
+ if( strlen(trim($wp_db_version)) && !defined('ACX_PLUGIN_DIR') ){
165
+ if ( get_option('db_version') != $wp_db_version ) {
166
+ /* in multisite network, please update database manualy */
167
+ if (empty($wpmu_version) || (function_exists('is_multisite') && !is_multisite())){
168
+ if( ! function_exists('wp_upgrade'))
169
+ include_once(ABSPATH.'wp-admin/includes/upgrade.php');
170
+
171
+ ob_clean();
172
+ @wp_upgrade();
173
+ @do_action('after_db_upgrade');
174
+ ob_end_clean();
175
+ }
176
+ }
177
+ }
178
+
179
+ if(isset($params['secure'])){
180
+ if($decrypted = $mmb_core->_secure_data($params['secure'])){
181
+ $decrypted = maybe_unserialize($decrypted);
182
+ if(is_array($decrypted)){
183
+ foreach($decrypted as $key => $val){
184
+ if(!is_numeric($key))
185
+ $params[$key] = $val;
186
+ }
187
+ unset($params['secure']);
188
+ } else $params['secure'] = $decrypted;
189
+ }
190
+ }
191
+
192
+ if( isset($data['setting']) ){
193
+ $mmb_core->save_options( $data['setting'] );
194
+ }
195
+
196
+ if( !$mmb_core->register_action_params( $action, $params ) ){
197
+ global $_mmb_plugin_actions;
198
+ $_mmb_plugin_actions[$action] = $params;
199
+ }
200
+
201
+
202
+ } else {
203
+ mmb_response($auth['error'], false);
204
+ }
205
+ } else {
206
+ MMB_Stats::set_hit_count();
207
+ }
208
+ ob_end_clean();
209
+ }
210
+ }
211
+ /* Main response function */
212
+ if( !function_exists ( 'mmb_response' )) {
213
+
214
+ function mmb_response($response = false, $success = true)
215
+ {
216
+ $return = array();
217
+
218
+ if ((is_array($response) && empty($response)) || (!is_array($response) && strlen($response) == 0))
219
+ $return['error'] = 'Empty response.';
220
+ else if ($success)
221
+ $return['success'] = $response;
222
+ else
223
+ $return['error'] = $response;
224
+
225
+ if( !headers_sent() ){
226
+ header('HTTP/1.0 200 OK');
227
+ header('Content-Type: text/plain');
228
+ }
229
+ exit("<MWPHEADER>" . base64_encode(serialize($return))."<ENDMWPHEADER>");
230
+ }
231
+ }
232
+
233
+
234
+
235
+ if( !function_exists ( 'mmb_add_site' )) {
236
+ function mmb_add_site($params) {
237
+ global $mmb_core;
238
+ $num = extract($params);
239
+
240
+ if ($num) {
241
+ if (!get_option('_action_message_id') && !get_option('_worker_public_key')) {
242
+ $public_key = base64_decode($public_key);
243
+
244
+ if (function_exists('openssl_verify')) {
245
+ $verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
246
+ if ($verify == 1) {
247
+ $mmb_core->set_master_public_key($public_key);
248
+ $mmb_core->set_worker_message_id($id);
249
+ $mmb_core->get_stats_instance();
250
+ if(is_array($notifications) && !empty($notifications)){
251
+ $mmb_core->stats_instance->set_notifications($notifications);
252
+ }
253
+ if(is_array($brand) && !empty($brand)){
254
+ update_option('mwp_worker_brand',$brand);
255
+ }
256
+
257
+ if( isset( $add_settigns ) && !empty( $add_settigns ) )
258
+ apply_filters( 'mwp_website_add', $add_settigns );
259
+
260
+ mmb_response($mmb_core->stats_instance->get_initial_stats(), true);
261
+ } else if ($verify == 0) {
262
+
263
+ //mmb_response('Site could not be added. OpenSSL verification error: "'.openssl_error_string().'". Contact your hosting support to check the OpenSSL configuration.', false);
264
+
265
+ } else {
266
+ mmb_response('Command not successful. Please try again.', false);
267
+ }
268
+ }
269
+
270
+ if (!get_option('_worker_nossl_key')) {
271
+ srand();
272
+
273
+ $random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
274
+
275
+ $mmb_core->set_random_signature($random_key);
276
+ $mmb_core->set_worker_message_id($id);
277
+ $mmb_core->set_master_public_key($public_key);
278
+ $mmb_core->get_stats_instance();
279
+ if(is_array($notifications) && !empty($notifications)){
280
+ $mmb_core->stats_instance->set_notifications($notifications);
281
+ }
282
+
283
+ if(is_array($brand) && !empty($brand)){
284
+ update_option('mwp_worker_brand',$brand);
285
+ }
286
+
287
+ mmb_response($mmb_core->stats_instance->get_initial_stats(), true);
288
+ } else
289
+ mmb_response('Please deactivate & activate ManageWP Worker plugin on your site, then re-add the site to your dashboard.', false);
290
+
291
+ } else {
292
+ mmb_response('Please deactivate & activate ManageWP Worker plugin on your site and re-add the site to your dashboard.', false);
293
+ }
294
+ } else {
295
+ mmb_response('Invalid parameters received. Please try again.', false);
296
+ }
297
+ }
298
+ }
299
+
300
+ if( !function_exists ( 'mmb_remove_site' )) {
301
+ function mmb_remove_site($params)
302
+ {
303
+ extract($params);
304
+ global $mmb_core;
305
+ $mmb_core->uninstall( $deactivate );
306
+
307
+ include_once(ABSPATH . 'wp-admin/includes/plugin.php');
308
+ $plugin_slug = basename(dirname(__FILE__)) . '/' . basename(__FILE__);
309
+
310
+ if ($deactivate) {
311
+ deactivate_plugins($plugin_slug, true);
312
+ }
313
+
314
+ if (!is_plugin_active($plugin_slug))
315
+ mmb_response(array(
316
+ 'deactivated' => 'Site removed successfully. <br /><br />ManageWP Worker plugin successfully deactivated.'
317
+ ), true);
318
+ else
319
+ mmb_response(array(
320
+ 'removed_data' => 'Site removed successfully. <br /><br /><b>ManageWP Worker plugin was not deactivated.</b>'
321
+ ), true);
322
+
323
+ }
324
+ }
325
+ if( !function_exists ( 'mmb_stats_get' )) {
326
+ function mmb_stats_get($params)
327
+ {
328
+ global $mmb_core;
329
+ $mmb_core->get_stats_instance();
330
+ mmb_response($mmb_core->stats_instance->get($params), true);
331
+ }
332
+ }
333
+
334
+ if( !function_exists ( 'mmb_worker_header' )) {
335
+ function mmb_worker_header()
336
+ { global $mmb_core, $current_user;
337
+
338
+ if(!headers_sent()){
339
+ if(isset($current_user->ID))
340
+ $expiration = time() + apply_filters('auth_cookie_expiration', 10800, $current_user->ID, false);
341
+ else
342
+ $expiration = time() + 10800;
343
+
344
+ setcookie(MMB_XFRAME_COOKIE, md5(MMB_XFRAME_COOKIE), $expiration, COOKIEPATH, COOKIE_DOMAIN, false, true);
345
+ $_COOKIE[MMB_XFRAME_COOKIE] = md5(MMB_XFRAME_COOKIE);
346
+ }
347
+ }
348
+ }
349
+
350
+ if( !function_exists ( 'mmb_pre_init_stats' )) {
351
+ function mmb_pre_init_stats( $params )
352
+ {
353
+ global $mmb_core;
354
+ $mmb_core->get_stats_instance();
355
+ return $mmb_core->stats_instance->pre_init_stats($params);
356
+ }
357
+ }
358
+
359
+ if( !function_exists ( 'mwp_datasend' )) {
360
+ function mwp_datasend( $params = array() )
361
+ {
362
+ global $mmb_core, $_mmb_item_filter, $_mmb_options;
363
+ if( isset($_mmb_options['datacron']) ){
364
+
365
+ $_mmb_remoteurl = get_option('home');
366
+ $_mmb_remoteown = isset($_mmb_options['dataown']) && !empty($_mmb_options['dataown']) ? $_mmb_options['dataown'] : false;
367
+
368
+ if( empty($_mmb_remoteown) )
369
+ return;
370
+
371
+ $_mmb_item_filter['pre_init_stats'] = array( 'core_update', 'hit_counter', 'comments', 'backups', 'posts', 'drafts', 'scheduled' );
372
+ $_mmb_item_filter['get'] = array( 'updates', 'errors' );
373
+ $mmb_core->get_stats_instance();
374
+
375
+ $filter = array(
376
+ 'refresh' => '',
377
+ 'item_filter' => array(
378
+ 'get_stats' => array(
379
+ array('updates', array('plugins' => true, 'themes' => true, 'premium' => true )),
380
+ array('core_update', array('core' => true )),
381
+ array('posts', array('numberposts' => 5 )),
382
+ array('drafts', array('numberposts' => 5 )),
383
+ array('scheduled', array('numberposts' => 5 )),
384
+ array('hit_counter'),
385
+ array('comments', array('numberposts' => 5 )),
386
+ array('backups'),
387
+ 'plugins' => array('cleanup' => array(
388
+ 'overhead' => array(),
389
+ 'revisions' => array( 'num_to_keep' => 'r_5'),
390
+ 'spam' => array(),
391
+ )
392
+ ),
393
+ ),
394
+ )
395
+ );
396
+
397
+ $pre_init_data = $mmb_core->stats_instance->pre_init_stats($filter);
398
+ $init_data = $mmb_core->stats_instance->get($filter);
399
+
400
+ $data = array_merge($init_data, $pre_init_data);
401
+ $hash = $mmb_core->get_secure_hash();
402
+
403
+ $datasend['datasend'] = $mmb_core->encrypt_data($data);
404
+ $datasend['sitehome'] = base64_encode($_mmb_remoteown.'[]'.$_mmb_remoteurl);
405
+ $datasend['sitehash'] = md5($hash.$_mmb_remoteown.$_mmb_remoteurl);
406
+
407
+ if ( !class_exists('WP_Http') )
408
+ include_once(ABSPATH . WPINC . '/class-http.php');
409
+
410
+ $remote = array();
411
+ $remote['body'] = $datasend;
412
+
413
+ $result = wp_remote_post($_mmb_options['datacron'], $remote);
414
+ if(isset($result['body']) && !empty($result['body'])){
415
+ $settings = @unserialize($result['body']);
416
+ $w_version = $settings['worker_updates']['version'];
417
+ $w_url = $settings['worker_updates']['url'];
418
+ if(version_compare(MMB_WORKER_VERSION, $w_version, '<')){
419
+ //automatic update
420
+ $mmb_core->update_worker_plugin(array("download_url" => $w_url));
421
+ }
422
+ }
423
+ }
424
+ }
425
+ }
426
+
427
+ //post
428
+ if( !function_exists ( 'mmb_post_create' )) {
429
+ function mmb_post_create($params)
430
+ {
431
+ global $mmb_core;
432
+ $mmb_core->get_post_instance();
433
+ $return = $mmb_core->post_instance->create($params);
434
+ if (is_int($return))
435
+ mmb_response($return, true);
436
+ else{
437
+ if(isset($return['error'])){
438
+ mmb_response($return['error'], false);
439
+ } else {
440
+ mmb_response($return, false);
441
+ }
442
+ }
443
+ }
444
+ }
445
+
446
+ if( !function_exists ( 'mmb_change_post_status' )) {
447
+ function mmb_change_post_status($params)
448
+ {
449
+ global $mmb_core;
450
+ $mmb_core->get_post_instance();
451
+ $return = $mmb_core->post_instance->change_status($params);
452
+ //mmb_response($return, true);
453
+
454
+ }
455
+ }
456
+
457
+ //comments
458
+ if( !function_exists ( 'mmb_change_comment_status' )) {
459
+ function mmb_change_comment_status($params)
460
+ {
461
+ global $mmb_core;
462
+ $mmb_core->get_comment_instance();
463
+ $return = $mmb_core->comment_instance->change_status($params);
464
+ //mmb_response($return, true);
465
+ if ($return){
466
+ $mmb_core->get_stats_instance();
467
+ mmb_response($mmb_core->stats_instance->get_comments_stats($params), true);
468
+ }else
469
+ mmb_response('Comment not updated', false);
470
+ }
471
+
472
+ }
473
+ if( !function_exists ( 'mmb_comment_stats_get' )) {
474
+ function mmb_comment_stats_get($params)
475
+ {
476
+ global $mmb_core;
477
+ $mmb_core->get_stats_instance();
478
+ mmb_response($mmb_core->stats_instance->get_comments_stats($params), true);
479
+ }
480
+ }
481
+
482
+ if( !function_exists ( 'mmb_backup_now' )) {
483
+ //backup
484
+ function mmb_backup_now($params)
485
+ {
486
+ global $mmb_core;
487
+
488
+ $mmb_core->get_backup_instance();
489
+ $return = $mmb_core->backup_instance->backup($params);
490
+
491
+ if (is_array($return) && array_key_exists('error', $return))
492
+ mmb_response($return['error'], false);
493
+ else {
494
+ mmb_response($return, true);
495
+ }
496
+ }
497
+ }
498
+
499
+ if( !function_exists ( 'mmb_run_task_now' )) {
500
+ function mmb_run_task_now($params)
501
+ {
502
+ global $mmb_core;
503
+ $mmb_core->get_backup_instance();
504
+ $return = $mmb_core->backup_instance->task_now($params['task_name']);
505
+ if (is_array($return) && array_key_exists('error', $return))
506
+ mmb_response($return['error'], false);
507
+ else {
508
+ mmb_response($return, true);
509
+ }
510
+ }
511
+ }
512
+
513
+ if( !function_exists ( 'mmb_email_backup' )) {
514
+ function mmb_email_backup($params)
515
+ {
516
+ global $mmb_core;
517
+ $mmb_core->get_backup_instance();
518
+ $return = $mmb_core->backup_instance->email_backup($params);
519
+
520
+ if (is_array($return) && array_key_exists('error', $return))
521
+ mmb_response($return['error'], false);
522
+ else {
523
+ mmb_response($return, true);
524
+ }
525
+ }
526
+ }
527
+
528
+ if( !function_exists ( 'mmb_check_backup_compat' )) {
529
+ function mmb_check_backup_compat($params)
530
+ {
531
+ global $mmb_core;
532
+ $mmb_core->get_backup_instance();
533
+ $return = $mmb_core->backup_instance->check_backup_compat($params);
534
+
535
+ if (is_array($return) && array_key_exists('error', $return))
536
+ mmb_response($return['error'], false);
537
+ else {
538
+ mmb_response($return, true);
539
+ }
540
+ }
541
+ }
542
+
543
+ if( !function_exists ( 'mmb_get_backup_req' )) {
544
+ function mmb_get_backup_req( $params )
545
+ {
546
+ global $mmb_core;
547
+ $mmb_core->get_stats_instance();
548
+ $return = $mmb_core->stats_instance->get_backup_req($params);
549
+
550
+ mmb_response($return, true);
551
+ }
552
+ }
553
+
554
+ if( !function_exists ( 'mmb_scheduled_backup' )) {
555
+ function mmb_scheduled_backup($params)
556
+ {
557
+ global $mmb_core;
558
+ $mmb_core->get_backup_instance();
559
+ $return = $mmb_core->backup_instance->set_backup_task($params);
560
+ mmb_response($return, $return);
561
+ }
562
+ }
563
+
564
+ if( !function_exists ( 'mmm_delete_backup' )) {
565
+ function mmm_delete_backup($params)
566
+ {
567
+ global $mmb_core;
568
+ $mmb_core->get_backup_instance();
569
+ $return = $mmb_core->backup_instance->delete_backup($params);
570
+ mmb_response($return, $return);
571
+ }
572
+ }
573
+
574
+ if( !function_exists ( 'mmb_optimize_tables' )) {
575
+ function mmb_optimize_tables($params)
576
+ {
577
+ global $mmb_core;
578
+ $mmb_core->get_backup_instance();
579
+ $return = $mmb_core->backup_instance->optimize_tables();
580
+ if ($return)
581
+ mmb_response($return, true);
582
+ else
583
+ mmb_response(false, false);
584
+ }
585
+ }
586
+ if( !function_exists ( 'mmb_restore_now' )) {
587
+ function mmb_restore_now($params)
588
+ {
589
+ global $mmb_core;
590
+ $mmb_core->get_backup_instance();
591
+ $return = $mmb_core->backup_instance->restore($params);
592
+ if (is_array($return) && array_key_exists('error', $return))
593
+ mmb_response($return['error'], false);
594
+ else
595
+ mmb_response($return, true);
596
+
597
+ }
598
+ }
599
+
600
+ if( !function_exists ( 'mmb_remote_backup_now' )) {
601
+ function mmb_remote_backup_now($params)
602
+ {
603
+ global $mmb_core;
604
+ $backup_instance = $mmb_core->get_backup_instance();
605
+ $return = $mmb_core->backup_instance->remote_backup_now($params);
606
+ if (is_array($return) && array_key_exists('error', $return))
607
+ mmb_response($return['error'], false);
608
+ else
609
+ mmb_response($return, true);
610
+ }
611
+ }
612
+
613
+
614
+ if( !function_exists ( 'mmb_clean_orphan_backups' )) {
615
+ function mmb_clean_orphan_backups()
616
+ {
617
+ global $mmb_core;
618
+ $backup_instance = $mmb_core->get_backup_instance();
619
+ $return = $mmb_core->backup_instance->cleanup();
620
+ if(is_array($return))
621
+ mmb_response($return, true);
622
+ else
623
+ mmb_response($return, false);
624
+ }
625
+ }
626
+
627
+ if( !function_exists ( 'mmb_update_worker_plugin' )) {
628
+ function mmb_update_worker_plugin($params)
629
+ {
630
+ global $mmb_core;
631
+ mmb_response($mmb_core->update_worker_plugin($params), true);
632
+ }
633
+ }
634
+
635
+ if( !function_exists ( 'mmb_wp_checkversion' )) {
636
+ function mmb_wp_checkversion($params)
637
+ {
638
+ include_once(ABSPATH . 'wp-includes/version.php');
639
+ global $mmb_wp_version, $mmb_core;
640
+ mmb_response($mmb_wp_version, true);
641
+ }
642
+ }
643
+ if( !function_exists ( 'mmb_search_posts_by_term' )) {
644
+ function mmb_search_posts_by_term($params)
645
+ {
646
+ global $mmb_core;
647
+ $mmb_core->get_search_instance();
648
+
649
+ $search_type = trim($params['search_type']);
650
+ $search_term = strtolower(trim($params['search_term']));
651
+
652
+ switch ($search_type){
653
+ case 'page_post':
654
+ $return = $mmb_core->search_instance->search_posts_by_term($params);
655
+ if($return){
656
+ $return = serialize($return);
657
+ mmb_response($return, true);
658
+ }else{
659
+ mmb_response('No posts found', false);
660
+ }
661
+ break;
662
+
663
+ case 'plugin':
664
+ $plugins = get_option('active_plugins');
665
+
666
+ $have_plugin = false;
667
+ foreach ($plugins as $plugin) {
668
+ if(strpos($plugin, $search_term)>-1){
669
+ $have_plugin = true;
670
+ }
671
+ }
672
+ if($have_plugin){
673
+ mmb_response(serialize($plugin), true);
674
+ }else{
675
+ mmb_response(false, false);
676
+ }
677
+ break;
678
+ case 'theme':
679
+ $theme = strtolower(get_option('template'));
680
+ if(strpos($theme, $search_term)>-1){
681
+ mmb_response($theme, true);
682
+ }else{
683
+ mmb_response(false, false);
684
+ }
685
+ break;
686
+ default: mmb_response(false, false);
687
+ }
688
+ $return = $mmb_core->search_instance->search_posts_by_term($params);
689
+
690
+
691
+
692
+ if ($return_if_true) {
693
+ mmb_response($return_value, true);
694
+ } else {
695
+ mmb_response($return_if_false, false);
696
+ }
697
+ }
698
+ }
699
+
700
+ if( !function_exists ( 'mmb_install_addon' )) {
701
+ function mmb_install_addon($params)
702
+ {
703
+ global $mmb_core;
704
+ $mmb_core->get_installer_instance();
705
+ $return = $mmb_core->installer_instance->install_remote_file($params);
706
+ mmb_response($return, true);
707
+
708
+ }
709
+ }
710
+
711
+ if( !function_exists ( 'mmb_do_upgrade' )) {
712
+ function mmb_do_upgrade($params)
713
+ {
714
+ global $mmb_core, $mmb_upgrading;
715
+ $mmb_core->get_installer_instance();
716
+ $return = $mmb_core->installer_instance->do_upgrade($params);
717
+ mmb_response($return, true);
718
+
719
+ }
720
+ }
721
+
722
+ if( !function_exists ('mmb_get_links')) {
723
+ function mmb_get_links($params)
724
+ {
725
+ global $mmb_core;
726
+ $mmb_core->get_link_instance();
727
+ $return = $mmb_core->link_instance->get_links($params);
728
+ if (is_array($return) && array_key_exists('error', $return))
729
+ mmb_response($return['error'], false);
730
+ else {
731
+ mmb_response($return, true);
732
+ }
733
+ }
734
+ }
735
+
736
+ if( !function_exists ( 'mmb_add_link' )) {
737
+ function mmb_add_link($params)
738
+ {
739
+ global $mmb_core;
740
+ $mmb_core->get_link_instance();
741
+ $return = $mmb_core->link_instance->add_link($params);
742
+ if (is_array($return) && array_key_exists('error', $return))
743
+
744
+ mmb_response($return['error'], false);
745
+ else {
746
+ mmb_response($return, true);
747
+ }
748
+
749
+ }
750
+ }
751
+
752
+ if( !function_exists ('mmb_delete_link')) {
753
+ function mmb_delete_link($params)
754
+ {
755
+ global $mmb_core;
756
+ $mmb_core->get_link_instance();
757
+
758
+ $return = $mmb_core->link_instance->delete_link($params);
759
+ if (is_array($return) && array_key_exists('error', $return))
760
+ mmb_response($return['error'], false);
761
+ else {
762
+ mmb_response($return, true);
763
+ }
764
+ }
765
+ }
766
+
767
+ if( !function_exists ('mmb_delete_links')) {
768
+ function mmb_delete_links($params)
769
+ {
770
+ global $mmb_core;
771
+ $mmb_core->get_link_instance();
772
+
773
+ $return = $mmb_core->link_instance->delete_links($params);
774
+ if (is_array($return) && array_key_exists('error', $return))
775
+ mmb_response($return['error'], false);
776
+ else {
777
+ mmb_response($return, true);
778
+ }
779
+ }
780
+ }
781
+
782
+ if( !function_exists ('mmb_get_comments')) {
783
+ function mmb_get_comments($params)
784
+ {
785
+ global $mmb_core;
786
+ $mmb_core->get_comment_instance();
787
+ $return = $mmb_core->comment_instance->get_comments($params);
788
+ if (is_array($return) && array_key_exists('error', $return))
789
+ mmb_response($return['error'], false);
790
+ else {
791
+ mmb_response($return, true);
792
+ }
793
+ }
794
+ }
795
+
796
+ if( !function_exists ('mmb_action_comment')) {
797
+ function mmb_action_comment($params)
798
+ {
799
+ global $mmb_core;
800
+ $mmb_core->get_comment_instance();
801
+
802
+ $return = $mmb_core->comment_instance->action_comment($params);
803
+ if (is_array($return) && array_key_exists('error', $return))
804
+ mmb_response($return['error'], false);
805
+ else {
806
+ mmb_response($return, true);
807
+ }
808
+ }
809
+ }
810
+
811
+ if( !function_exists ('mmb_bulk_action_comments')) {
812
+ function mmb_bulk_action_comments($params)
813
+ {
814
+ global $mmb_core;
815
+ $mmb_core->get_comment_instance();
816
+
817
+ $return = $mmb_core->comment_instance->bulk_action_comments($params);
818
+ if (is_array($return) && array_key_exists('error', $return))
819
+ mmb_response($return['error'], false);
820
+ else {
821
+ mmb_response($return, true);
822
+ }
823
+ }
824
+ }
825
+
826
+ if( !function_exists ('mmb_reply_comment')) {
827
+ function mmb_reply_comment($params)
828
+ {
829
+ global $mmb_core;
830
+ $mmb_core->get_comment_instance();
831
+
832
+ $return = $mmb_core->comment_instance->reply_comment($params);
833
+ if (is_array($return) && array_key_exists('error', $return))
834
+ mmb_response($return['error'], false);
835
+ else {
836
+ mmb_response($return, true);
837
+ }
838
+ }
839
+ }
840
+
841
+ if( !function_exists ( 'mmb_add_user' )) {
842
+ function mmb_add_user($params)
843
+ {
844
+ global $mmb_core;
845
+ $mmb_core->get_user_instance();
846
+ $return = $mmb_core->user_instance->add_user($params);
847
+ if (is_array($return) && array_key_exists('error', $return))
848
+
849
+ mmb_response($return['error'], false);
850
+ else {
851
+ mmb_response($return, true);
852
+ }
853
+
854
+ }
855
+ }
856
+
857
+ if( !function_exists ('mmb_get_users')) {
858
+ function mmb_get_users($params)
859
+ {
860
+ global $mmb_core;
861
+ $mmb_core->get_user_instance();
862
+ $return = $mmb_core->user_instance->get_users($params);
863
+ if (is_array($return) && array_key_exists('error', $return))
864
+ mmb_response($return['error'], false);
865
+ else {
866
+ mmb_response($return, true);
867
+ }
868
+ }
869
+ }
870
+
871
+ if( !function_exists ('mmb_edit_users')) {
872
+ function mmb_edit_users($params)
873
+ {
874
+ global $mmb_core;
875
+ $mmb_core->get_user_instance();
876
+ $return = $mmb_core->user_instance->edit_users($params);
877
+ mmb_response($return, true);
878
+ }
879
+ }
880
+
881
+ if( !function_exists ('mmb_get_posts')) {
882
+ function mmb_get_posts($params)
883
+ {
884
+ global $mmb_core;
885
+ $mmb_core->get_post_instance();
886
+
887
+ $return = $mmb_core->post_instance->get_posts($params);
888
+ if (is_array($return) && array_key_exists('error', $return))
889
+ mmb_response($return['error'], false);
890
+ else {
891
+ mmb_response($return, true);
892
+ }
893
+ }
894
+ }
895
+
896
+ if( !function_exists ('mmb_delete_post')) {
897
+ function mmb_delete_post($params)
898
+ {
899
+ global $mmb_core;
900
+ $mmb_core->get_post_instance();
901
+
902
+ $return = $mmb_core->post_instance->delete_post($params);
903
+ if (is_array($return) && array_key_exists('error', $return))
904
+ mmb_response($return['error'], false);
905
+ else {
906
+ mmb_response($return, true);
907
+ }
908
+ }
909
+ }
910
+
911
+ if( !function_exists ('mmb_delete_posts')) {
912
+ function mmb_delete_posts($params)
913
+ {
914
+ global $mmb_core;
915
+ $mmb_core->get_post_instance();
916
+
917
+ $return = $mmb_core->post_instance->delete_posts($params);
918
+ if (is_array($return) && array_key_exists('error', $return))
919
+ mmb_response($return['error'], false);
920
+ else {
921
+ mmb_response($return, true);
922
+ }
923
+ }
924
+ }
925
+
926
+ if( !function_exists ('mmb_edit_posts')) {
927
+ function mmb_edit_posts($params)
928
+ {
929
+ global $mmb_core;
930
+ $mmb_core->get_posts_instance();
931
+ $return = $mmb_core->posts_instance->edit_posts($params);
932
+ mmb_response($return, true);
933
+ }
934
+ }
935
+
936
+ if( !function_exists ('mmb_get_pages')) {
937
+ function mmb_get_pages($params)
938
+ {
939
+ global $mmb_core;
940
+ $mmb_core->get_post_instance();
941
+
942
+ $return = $mmb_core->post_instance->get_pages($params);
943
+ if (is_array($return) && array_key_exists('error', $return))
944
+ mmb_response($return['error'], false);
945
+ else {
946
+ mmb_response($return, true);
947
+ }
948
+ }
949
+ }
950
+
951
+ if( !function_exists ('mmb_delete_page')) {
952
+ function mmb_delete_page($params)
953
+ {
954
+ global $mmb_core;
955
+ $mmb_core->get_post_instance();
956
+
957
+ $return = $mmb_core->post_instance->delete_page($params);
958
+ if (is_array($return) && array_key_exists('error', $return))
959
+ mmb_response($return['error'], false);
960
+ else {
961
+ mmb_response($return, true);
962
+ }
963
+ }
964
+ }
965
+
966
+ if( !function_exists ( 'mmb_iframe_plugins_fix' )) {
967
+ function mmb_iframe_plugins_fix($update_actions)
968
+ {
969
+ foreach($update_actions as $key => $action)
970
+ {
971
+ $update_actions[$key] = str_replace('target="_parent"','',$action);
972
+ }
973
+
974
+ return $update_actions;
975
+
976
+ }
977
+ }
978
+ if( !function_exists ( 'mmb_execute_php_code' )) {
979
+ function mmb_execute_php_code($params)
980
+ {
981
+ ob_start();
982
+ eval($params['code']);
983
+ $return = ob_get_flush();
984
+ mmb_response(print_r($return, true), true);
985
+ }
986
+ }
987
+
988
+ if( !function_exists ( 'mmb_set_notifications' )) {
989
+ function mmb_set_notifications($params)
990
+ {
991
+ global $mmb_core;
992
+ $mmb_core->get_stats_instance();
993
+ $return = $mmb_core->stats_instance->set_notifications($params);
994
+ if (is_array($return) && array_key_exists('error', $return))
995
+ mmb_response($return['error'], false);
996
+ else {
997
+ mmb_response($return, true);
998
+ }
999
+
1000
+ }
1001
+ }
1002
+
1003
+ if( !function_exists ( 'mmb_set_alerts' )) {
1004
+ function mmb_set_alerts($params)
1005
+ {
1006
+ global $mmb_core;
1007
+ $mmb_core->get_stats_instance();
1008
+ $return = $mmb_core->stats_instance->set_alerts($params);
1009
+ mmb_response(true, true);
1010
+ }
1011
+
1012
+ }
1013
+ if( !function_exists ('mmb_get_dbname')) {
1014
+ function mmb_get_dbname($params)
1015
+ {
1016
+ global $mmb_core;
1017
+ $mmb_core->get_stats_instance();
1018
+
1019
+ $return = $mmb_core->stats_instance->get_active_db();
1020
+ if (is_array($return) && array_key_exists('error', $return))
1021
+ mmb_response($return['error'], false);
1022
+ else {
1023
+ mmb_response($return, true);
1024
+ }
1025
+ }
1026
+ }
1027
+
1028
+ if( !function_exists('mmb_more_reccurences') ){
1029
+ //Backup Tasks
1030
+ add_filter('cron_schedules', 'mmb_more_reccurences');
1031
+ function mmb_more_reccurences($schedules) {
1032
+ $schedules['halfminute'] = array('interval' => 30, 'display' => 'Once in a half minute');
1033
+ $schedules['minutely'] = array('interval' => 60, 'display' => 'Once in a minute');
1034
+ $schedules['fiveminutes'] = array('interval' => 300, 'display' => 'Once every five minutes');
1035
+ $schedules['tenminutes'] = array('interval' => 600, 'display' => 'Once every ten minutes');
1036
+ $schedules['sixhours'] = array('interval' => 21600, 'display' => 'Every six hours');
1037
+ $schedules['fourhours'] = array('interval' => 14400, 'display' => 'Every four hours');
1038
+ $schedules['threehours'] = array('interval' => 10800, 'display' => 'Every three hours');
1039
+
1040
+ return $schedules;
1041
+ }
1042
+ }
1043
+
1044
+ add_action('mwp_backup_tasks', 'mwp_check_backup_tasks');
1045
+
1046
+ if( !function_exists('mwp_check_backup_tasks') ){
1047
+ function mwp_check_backup_tasks() {
1048
+ global $mmb_core, $_wp_using_ext_object_cache;
1049
+ $_wp_using_ext_object_cache = false;
1050
+
1051
+ $mmb_core->get_backup_instance();
1052
+ $mmb_core->backup_instance->check_backup_tasks();
1053
+ }
1054
+ }
1055
+
1056
+ // if (!wp_next_scheduled('mwp_notifications')) {
1057
+ // wp_schedule_event( time(), 'twicedaily', 'mwp_notifications' );
1058
+ // }
1059
+ // add_action('mwp_notifications', 'mwp_check_notifications');
1060
+
1061
+ if (!wp_next_scheduled('mwp_datasend')) {
1062
+ wp_schedule_event( time(), 'threehours', 'mwp_datasend' );
1063
+ }
1064
+ add_action('mwp_datasend', 'mwp_datasend');
1065
+
1066
+ if( !function_exists('mwp_check_notifications') ){
1067
+ function mwp_check_notifications() {
1068
+ global $mmb_core, $_wp_using_ext_object_cache;
1069
+ $_wp_using_ext_object_cache = false;
1070
+
1071
+ $mmb_core->get_stats_instance();
1072
+ $mmb_core->stats_instance->check_notifications();
1073
+ }
1074
+ }
1075
+
1076
+
1077
+ if( !function_exists('mmb_get_plugins_themes') ){
1078
+ function mmb_get_plugins_themes($params) {
1079
+ global $mmb_core;
1080
+ $mmb_core->get_installer_instance();
1081
+ $return = $mmb_core->installer_instance->get($params);
1082
+ mmb_response($return, true);
1083
+ }
1084
+ }
1085
+
1086
+ if( !function_exists('mmb_edit_plugins_themes') ){
1087
+ function mmb_edit_plugins_themes($params) {
1088
+ global $mmb_core;
1089
+ $mmb_core->get_installer_instance();
1090
+ $return = $mmb_core->installer_instance->edit($params);
1091
+ mmb_response($return, true);
1092
+ }
1093
+ }
1094
+
1095
+ if( !function_exists('mmb_worker_brand')){
1096
+ function mmb_worker_brand($params) {
1097
+ update_option("mwp_worker_brand",$params['brand']);
1098
+ mmb_response(true, true);
1099
+ }
1100
+ }
1101
+
1102
+ if( !function_exists('mmb_maintenance_mode')){
1103
+ function mmb_maintenance_mode( $params ) {
1104
+ global $wp_object_cache;
1105
+
1106
+ $default = get_option('mwp_maintenace_mode');
1107
+ $params = empty($default) ? $params : array_merge($default, $params);
1108
+ update_option("mwp_maintenace_mode", $params);
1109
+
1110
+ if(!empty($wp_object_cache))
1111
+ @$wp_object_cache->flush();
1112
+ mmb_response(true, true);
1113
+ }
1114
+ }
1115
+
1116
+ if( !function_exists('mmb_plugin_actions') ){
1117
+ function mmb_plugin_actions() {
1118
+ global $mmb_actions, $mmb_core;
1119
+
1120
+ if(!empty($mmb_actions)){
1121
+ global $_mmb_plugin_actions;
1122
+ if(!empty($_mmb_plugin_actions)){
1123
+ $failed = array();
1124
+ foreach($_mmb_plugin_actions as $action => $params){
1125
+ if(isset($mmb_actions[$action]))
1126
+ call_user_func($mmb_actions[$action], $params);
1127
+ else
1128
+ $failed[] = $action;
1129
+ }
1130
+ if(!empty($failed)){
1131
+ $f = implode(', ', $failed);
1132
+ $s = count($f) > 1 ? 'Actions "' . $f . '" do' : 'Action "' . $f . '" does';
1133
+ mmb_response($s.' not exist. Please update your Worker plugin.', false);
1134
+ }
1135
+
1136
+ }
1137
+ }
1138
+
1139
+ global $pagenow, $current_user, $mmode;
1140
+ if( !is_admin() && !in_array($pagenow, array( 'wp-login.php' ))){
1141
+ $mmode = get_option('mwp_maintenace_mode');
1142
+ if( !empty($mmode) ){
1143
+ if(isset($mmode['active']) && $mmode['active'] == true){
1144
+ if(isset($current_user->data) && !empty($current_user->data) && isset($mmode['hidecaps']) && !empty($mmode['hidecaps'])){
1145
+ $usercaps = array();
1146
+ if(isset($current_user->caps) && !empty($current_user->caps)){
1147
+ $usercaps = $current_user->caps;
1148
+ }
1149
+ foreach($mmode['hidecaps'] as $cap => $hide){
1150
+ if(!$hide)
1151
+ continue;
1152
+
1153
+ foreach($usercaps as $ucap => $val){
1154
+ if($ucap == $cap){
1155
+ ob_end_clean();
1156
+ ob_end_flush();
1157
+ die($mmode['template']);
1158
+ }
1159
+ }
1160
+ }
1161
+ } else
1162
+ die($mmode['template']);
1163
+ }
1164
+ }
1165
+ }
1166
 
1167
  if (file_exists(dirname(__FILE__) . '/log')) {
1168
  unlink(dirname(__FILE__) . '/log');
1169
+ }
1170
+ }
1171
+ }
1172
+
1173
+ $mmb_core = new MMB_Core();
1174
+
1175
+ if(isset($_GET['auto_login']))
1176
+ $mmb_core->automatic_login();
1177
+
1178
+ if (function_exists('register_activation_hook'))
1179
+ register_activation_hook( __FILE__ , array( $mmb_core, 'install' ));
1180
+
1181
+ if (function_exists('register_deactivation_hook'))
1182
+ register_deactivation_hook(__FILE__, array( $mmb_core, 'uninstall' ));
1183
+
1184
+ if (function_exists('add_action'))
1185
+ add_action('init', 'mmb_plugin_actions', 99999);
1186
+
1187
+ if (function_exists('add_filter'))
1188
+ add_filter('install_plugin_complete_actions','mmb_iframe_plugins_fix');
1189
+
1190
+ if(!function_exists('mwb_edit_redirect_override')){
1191
+ function mwb_edit_redirect_override($location = false, $comment_id = false){
1192
+ if(isset($_COOKIE[MMB_XFRAME_COOKIE])){
1193
+ $location = get_site_url().'/wp-admin/edit-comments.php';
1194
+ }
1195
+ return $location;
1196
+ }
1197
+ }
1198
+ if (function_exists('add_filter'))
1199
+ add_filter('comment_edit_redirect', 'mwb_edit_redirect_override');
1200
+
1201
+ if( isset($_COOKIE[MMB_XFRAME_COOKIE]) ){
1202
+ remove_action( 'admin_init', 'send_frame_options_header');
1203
+ remove_action( 'login_init', 'send_frame_options_header');
1204
+ }
1205
+
1206
+
1207
  ?>
plugins/cleanup/cleanup.php CHANGED
@@ -137,7 +137,7 @@ function mmb_handle_overhead($clear = false)
137
  $tot_data = 0;
138
  $tot_idx = 0;
139
  $tot_all = 0;
140
- $query = 'SHOW TABLE STATUS FROM ' . DB_NAME;
141
  $tables = $wpdb->get_results($wpdb->prepare($query), ARRAY_A);
142
  $total_gain = 0;
143
  $table_string = '';
137
  $tot_data = 0;
138
  $tot_idx = 0;
139
  $tot_all = 0;
140
+ $query = 'SHOW TABLES';
141
  $tables = $wpdb->get_results($wpdb->prepare($query), ARRAY_A);
142
  $total_gain = 0;
143
  $table_string = '';
readme.txt CHANGED
@@ -34,6 +34,9 @@ Check out [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs").
34
 
35
  == Changelog ==
36
 
 
 
 
37
  = 3.9.20 =
38
  * New: ManageWP iOS app compatibility
39
  * New: Perform security and performance test as you add websites
34
 
35
  == Changelog ==
36
 
37
+ = 3.9.21 =
38
+ * New: Continuous updates! Read more at http://managewp.com/continuous-updates
39
+
40
  = 3.9.20 =
41
  * New: ManageWP iOS app compatibility
42
  * New: Perform security and performance test as you add websites