ManageWP Worker - Version 3.9.25

Version Description

  • New: Improved Worker branding feature
  • Fix: Traffic alerts feature was not functioning properly
  • Fix: Backup information was sometimes incorrectly displayed
  • Fix: DB Table overhead was not shown on the dashboard
Download this release

Release Info

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

Code changes from version 3.9.24 to 3.9.25

backup.class.php CHANGED
@@ -585,9 +585,12 @@ class MMB_Backup extends MMB_Core {
585
  @unlink(MWP_BACKUP_DIR.'/mwp_db/index.php');
586
  @unlink($db_result);
587
  @rmdir(MWP_DB_DIR);
588
-
 
 
 
589
  return array(
590
- 'error' => 'Failed to zip database. pclZip error (' . $archive->error_code . '): .' . $archive->error_string
591
  );
592
  }
593
  }
585
  @unlink(MWP_BACKUP_DIR.'/mwp_db/index.php');
586
  @unlink($db_result);
587
  @rmdir(MWP_DB_DIR);
588
+
589
+ if($archive->error_code!=''){
590
+ $archive->error_code = 'pclZip error ('.$archive->error_code . '): .';
591
+ }
592
  return array(
593
+ 'error' => 'Failed to zip database. ' . $archive->error_code . $archive->error_string
594
  );
595
  }
596
  }
core.class.php CHANGED
@@ -132,14 +132,13 @@ class MMB_Core extends MMB_Helper
132
  'get_plugins_themes' => 'mmb_get_plugins_themes',
133
  'edit_plugins_themes' => 'mmb_edit_plugins_themes',
134
  'worker_brand' => 'mmb_worker_brand',
135
- 'set_alerts' => 'mmb_set_alerts',
136
  'maintenance' => 'mmb_maintenance_mode',
137
  'get_dbname' => 'mmb_get_dbname',
138
  );
139
 
140
  $mwp_worker_brand = get_option("mwp_worker_brand");
141
-
142
- if (!$mwp_worker_brand['hide_managed_remotely']) {
143
  add_action('rightnow_end', array( &$this, 'add_right_now_info' ));
144
  }
145
 
132
  'get_plugins_themes' => 'mmb_get_plugins_themes',
133
  'edit_plugins_themes' => 'mmb_edit_plugins_themes',
134
  'worker_brand' => 'mmb_worker_brand',
 
135
  'maintenance' => 'mmb_maintenance_mode',
136
  'get_dbname' => 'mmb_get_dbname',
137
  );
138
 
139
  $mwp_worker_brand = get_option("mwp_worker_brand");
140
+ //!$mwp_worker_brand['hide_managed_remotely']
141
+ if ($mwp_worker_brand == false || (is_array($mwp_worker_brand) && !array_key_exists('hide_managed_remotely', $mwp_worker_brand))) {
142
  add_action('rightnow_end', array( &$this, 'add_right_now_info' ));
143
  }
144
 
init.php CHANGED
@@ -2,9 +2,9 @@
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: ManageWP
7
- Version: 3.9.24
8
  Author URI: http://managewp.com
9
  */
10
 
@@ -22,7 +22,7 @@ if(basename($_SERVER['SCRIPT_FILENAME']) == "init.php"):
22
  exit;
23
  endif;
24
  if(!defined('MMB_WORKER_VERSION'))
25
- define('MMB_WORKER_VERSION', '3.9.24');
26
 
27
  if ( !defined('MMB_XFRAME_COOKIE')){
28
  $siteurl = function_exists( 'get_site_option' ) ? get_site_option( 'siteurl' ) : get_option( 'siteurl' );
@@ -145,9 +145,11 @@ if( !function_exists ( 'mmb_parse_request' )) {
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
  }
@@ -246,6 +248,9 @@ if( !function_exists ( 'mmb_add_site' )) {
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(isset($notifications) && is_array($notifications) && !empty($notifications)){
251
  $mmb_core->stats_instance->set_notifications($notifications);
@@ -275,6 +280,8 @@ if( !function_exists ( 'mmb_add_site' )) {
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);
@@ -286,10 +293,10 @@ if( !function_exists ( 'mmb_add_site' )) {
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);
@@ -373,7 +380,7 @@ if( !function_exists ( 'mwp_datasend' )) {
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 )),
@@ -403,7 +410,6 @@ if( !function_exists ( 'mwp_datasend' )) {
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
 
@@ -414,12 +420,19 @@ if( !function_exists ( 'mwp_datasend' )) {
414
  if(!is_wp_error($result)){
415
  if(isset($result['body']) && !empty($result['body'])){
416
  $settings = @unserialize($result['body']);
 
 
 
 
 
 
 
417
  $w_version = $settings['worker_updates']['version'];
418
  $w_url = $settings['worker_updates']['url'];
419
  if(version_compare(MMB_WORKER_VERSION, $w_version, '<')){
420
  //automatic update
421
  $mmb_core->update_worker_plugin(array("download_url" => $w_url));
422
- }
423
  }
424
  }else{
425
  //$mmb_core->_log($result);
@@ -1044,16 +1057,6 @@ if( !function_exists ( 'mmb_set_notifications' )) {
1044
  }
1045
  }
1046
 
1047
- if( !function_exists ( 'mmb_set_alerts' )) {
1048
- function mmb_set_alerts($params)
1049
- {
1050
- global $mmb_core;
1051
- $mmb_core->get_stats_instance();
1052
- $return = $mmb_core->stats_instance->set_alerts($params);
1053
- mmb_response(true, true);
1054
- }
1055
-
1056
- }
1057
  if( !function_exists ('mmb_get_dbname')) {
1058
  function mmb_get_dbname($params)
1059
  {
2
  /*
3
  Plugin Name: ManageWP - Worker
4
  Plugin URI: http://managewp.com/
5
+ Description: Manage Multiple WordPress sites from one dashboard. Visit <a href="https://managewp.com">ManageWP.com</a> to sign up.
6
  Author: ManageWP
7
+ Version: 3.9.25
8
  Author URI: http://managewp.com
9
  */
10
 
22
  exit;
23
  endif;
24
  if(!defined('MMB_WORKER_VERSION'))
25
+ define('MMB_WORKER_VERSION', '3.9.25');
26
 
27
  if ( !defined('MMB_XFRAME_COOKIE')){
28
  $siteurl = function_exists( 'get_site_option' ) ? get_site_option( 'siteurl' ) : get_option( 'siteurl' );
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. Please check the Admin username.', false);
149
 
150
  if ($action == 'add_site') {
151
+ $userspec = get_user_by('login',$params['username']);
152
+ wp_set_current_user($userspec->ID);
153
  mmb_add_site($params);
154
  mmb_response('You should never see this.', false);
155
  }
248
  if ($verify == 1) {
249
  $mmb_core->set_master_public_key($public_key);
250
  $mmb_core->set_worker_message_id($id);
251
+
252
+
253
+
254
  $mmb_core->get_stats_instance();
255
  if(isset($notifications) && is_array($notifications) && !empty($notifications)){
256
  $mmb_core->stats_instance->set_notifications($notifications);
280
  $mmb_core->set_random_signature($random_key);
281
  $mmb_core->set_worker_message_id($id);
282
  $mmb_core->set_master_public_key($public_key);
283
+
284
+
285
  $mmb_core->get_stats_instance();
286
  if(is_array($notifications) && !empty($notifications)){
287
  $mmb_core->stats_instance->set_notifications($notifications);
293
 
294
  mmb_response($mmb_core->stats_instance->get_initial_stats(), true);
295
  } else
296
+ mmb_response('Handshake not successful. Please deactivate, then activate ManageWP Worker plugin on your site, and re-add this site to your dashboard.', false);
297
 
298
  } else {
299
+ mmb_response('Handshake not successful. Please deactivate, then activate ManageWP Worker plugin on your site, and re-add this site to your dashboard.', false);
300
  }
301
  } else {
302
  mmb_response('Invalid parameters received. Please try again.', false);
380
  $mmb_core->get_stats_instance();
381
 
382
  $filter = array(
383
+ 'refresh' => 'transient',
384
  'item_filter' => array(
385
  'get_stats' => array(
386
  array('updates', array('plugins' => true, 'themes' => true, 'premium' => true )),
410
  $datasend['datasend'] = $mmb_core->encrypt_data($data);
411
  $datasend['sitehome'] = base64_encode($_mmb_remoteown.'[]'.$_mmb_remoteurl);
412
  $datasend['sitehash'] = md5($hash.$_mmb_remoteown.$_mmb_remoteurl);
 
413
  if ( !class_exists('WP_Http') )
414
  include_once(ABSPATH . WPINC . '/class-http.php');
415
 
420
  if(!is_wp_error($result)){
421
  if(isset($result['body']) && !empty($result['body'])){
422
  $settings = @unserialize($result['body']);
423
+ /* rebrand worker or set default */
424
+ $brand = '';
425
+ if($settings['worker_brand']){
426
+ $brand = $settings['worker_brand'];
427
+ }
428
+ update_option("mwp_worker_brand",$brand);
429
+ /* change worker version */
430
  $w_version = $settings['worker_updates']['version'];
431
  $w_url = $settings['worker_updates']['url'];
432
  if(version_compare(MMB_WORKER_VERSION, $w_version, '<')){
433
  //automatic update
434
  $mmb_core->update_worker_plugin(array("download_url" => $w_url));
435
+ }
436
  }
437
  }else{
438
  //$mmb_core->_log($result);
1057
  }
1058
  }
1059
 
 
 
 
 
 
 
 
 
 
 
1060
  if( !function_exists ('mmb_get_dbname')) {
1061
  function mmb_get_dbname($params)
1062
  {
installer.class.php CHANGED
@@ -384,6 +384,9 @@ class MMB_Installer extends MMB_Core
384
  if(isset($current->checked[$plugin])){
385
  $versions[$current->checked[$plugin]] = $plugin;
386
  }
 
 
 
387
  }
388
  }
389
  $return = array();
@@ -489,7 +492,7 @@ class MMB_Installer extends MMB_Core
489
  return array(
490
  'error' => 'No premium files for upgrade.'
491
  );
492
-
493
  $upgrader = false;
494
  $pr_update = array();
495
  $themes = array();
@@ -524,7 +527,7 @@ class MMB_Installer extends MMB_Core
524
 
525
  // try default wordpress upgrader
526
  if(!empty($plugins)){
527
- $updateplugins = $this->upgrade_plugins(array_keys($plugins));
528
  if(!empty($updateplugins) && isset($updateplugins['upgraded'])){
529
  foreach ($premium_update as $key => $update) {
530
  $update = array_change_key_case($update, CASE_LOWER);
384
  if(isset($current->checked[$plugin])){
385
  $versions[$current->checked[$plugin]] = $plugin;
386
  }
387
+ if ( !isset( $current->response[ $plugin ] ) ) {
388
+ unset($plugins[$plugin]);
389
+ }
390
  }
391
  }
392
  $return = array();
492
  return array(
493
  'error' => 'No premium files for upgrade.'
494
  );
495
+
496
  $upgrader = false;
497
  $pr_update = array();
498
  $themes = array();
527
 
528
  // try default wordpress upgrader
529
  if(!empty($plugins)){
530
+ $updateplugins = $this->upgrade_plugins(array_values($plugins));
531
  if(!empty($updateplugins) && isset($updateplugins['upgraded'])){
532
  foreach ($premium_update as $key => $update) {
533
  $update = array_change_key_case($update, CASE_LOWER);
plugins/cleanup/cleanup.php CHANGED
@@ -46,21 +46,21 @@ function cleanup_delete_worker($params = array())
46
  if (mmb_delete_all_revisions($revision_filter['revisions'])) {
47
  $return_array['revision'] = 'OK';
48
  } else {
49
- $return_array['revision_error'] = 'Failed, please try again';
50
  }
51
  break;
52
  case 'overhead':
53
  if (mmb_handle_overhead(true)) {
54
  $return_array['overhead'] = 'OK';
55
  } else {
56
- $return_array['overhead_error'] = 'Failed, please try again';
57
  }
58
  break;
59
  case 'comment':
60
  if (mmb_delete_spam_comments()) {
61
  $return_array['comment'] = 'OK';
62
  } else {
63
- $return_array['comment_error'] = 'Failed, please try again';
64
  }
65
  break;
66
  default:
@@ -133,11 +133,12 @@ function mmb_delete_all_revisions($filter)
133
 
134
  function mmb_handle_overhead($clear = false)
135
  {
 
136
  global $wpdb, $mmb_core;
137
  $tot_data = 0;
138
  $tot_idx = 0;
139
  $tot_all = 0;
140
- $query = 'SHOW TABLES';
141
  $tables = $wpdb->get_results($query, ARRAY_A);
142
  $total_gain = 0;
143
  $table_string = '';
@@ -168,7 +169,7 @@ function mmb_handle_overhead($clear = false)
168
  //$total_gain += $table['Data_free'] > 100*1024*1024 ? $table['Data_free'] / 1024 : 0;
169
  }
170
  }
171
-
172
  if ($clear) {
173
  $table_string = substr($table_string, 0, strlen($table_string) - 1); //remove last ,
174
 
@@ -186,6 +187,7 @@ function mmb_handle_overhead($clear = false)
186
 
187
 
188
 
 
189
  /* Spam Comments */
190
 
191
  function mmb_num_spam_comments()
46
  if (mmb_delete_all_revisions($revision_filter['revisions'])) {
47
  $return_array['revision'] = 'OK';
48
  } else {
49
+ $return_array['revision_error'] = 'OK, nothing to do';
50
  }
51
  break;
52
  case 'overhead':
53
  if (mmb_handle_overhead(true)) {
54
  $return_array['overhead'] = 'OK';
55
  } else {
56
+ $return_array['overhead_error'] = 'OK, nothing to do';
57
  }
58
  break;
59
  case 'comment':
60
  if (mmb_delete_spam_comments()) {
61
  $return_array['comment'] = 'OK';
62
  } else {
63
+ $return_array['comment_error'] = 'OK, nothing to do';
64
  }
65
  break;
66
  default:
133
 
134
  function mmb_handle_overhead($clear = false)
135
  {
136
+
137
  global $wpdb, $mmb_core;
138
  $tot_data = 0;
139
  $tot_idx = 0;
140
  $tot_all = 0;
141
+ $query = 'SHOW TABLE STATUS';
142
  $tables = $wpdb->get_results($query, ARRAY_A);
143
  $total_gain = 0;
144
  $table_string = '';
169
  //$total_gain += $table['Data_free'] > 100*1024*1024 ? $table['Data_free'] / 1024 : 0;
170
  }
171
  }
172
+
173
  if ($clear) {
174
  $table_string = substr($table_string, 0, strlen($table_string) - 1); //remove last ,
175
 
187
 
188
 
189
 
190
+
191
  /* Spam Comments */
192
 
193
  function mmb_num_spam_comments()
plugins/search/search.php CHANGED
@@ -9,7 +9,7 @@
9
  * Copyright (c) 2011 Prelovac Media
10
  * www.prelovac.com
11
  **************************************************************/
12
- if(basename($_SERVER['SCRIPT_FILENAME']) == "search.php"):
13
  exit;
14
  endif;
15
  mmb_add_action('search_posts_by_term', 'search_posts_by_term');
9
  * Copyright (c) 2011 Prelovac Media
10
  * www.prelovac.com
11
  **************************************************************/
12
+ if($_SERVER['SCRIPT_FILENAME'] == __FILE__):
13
  exit;
14
  endif;
15
  mmb_add_action('search_posts_by_term', 'search_posts_by_term');
post.class.php CHANGED
@@ -453,7 +453,7 @@ class MMB_Post extends MMB_Core
453
 
454
  if(!empty($filter_posts))
455
  {
456
- $where.=" AND post_title LIKE '%".mysql_real_escape_string($filter_posts)."%'";
457
  }
458
 
459
  if(!empty($mwp_get_posts_date_from) && !empty($mwp_get_posts_date_to))
453
 
454
  if(!empty($filter_posts))
455
  {
456
+ $where.=" AND (post_title LIKE '%".mysql_real_escape_string($filter_posts)."%' OR post_content LIKE '%".mysql_real_escape_string($filter_posts)."%')";
457
  }
458
 
459
  if(!empty($mwp_get_posts_date_from) && !empty($mwp_get_posts_date_to))
readme.txt CHANGED
@@ -1,7 +1,7 @@
1
  === ManageWP Worker ===
2
  Contributors: freediver
3
  Donate link: https://www.networkforgood.org/donation/MakeDonation.aspx?ORGID2=520781390
4
- Tags: admin, administration, amazon, api, authentication, automatic, dashboard, dropbox, events, integration, manage, multsite, notification, performance, s3, security, seo, stats, tracking, managewp
5
  Requires at least: 3.0
6
  Tested up to: 3.5.1
7
  Stable tag: trunk
@@ -10,30 +10,35 @@ ManageWP Worker plugin allows you to remotely manage your WordPress sites from o
10
 
11
  == Description ==
12
 
13
- [ManageWP](http://managewp.com/ "Manage Multiple Blogs") is a revolutionary plugin that helps users manage multiple WordPress blogs from one dashboard.
14
 
15
  Main features:
16
 
17
- * Secure and fast solution for managing your WordPress sites
18
  * One click upgrades for WordPress, plugin and themes across all your sites
19
  * Schedule automatic backups of your websites (Amazon S3, Google Drive and Dropbox supported)
20
  * One click to access WP admin of any site
21
  * Install WordPress, clone or migrate a website to another domain
22
  * Bulk install themes and plugins to multiple sites at once
23
  * Add sub-users (writers, staff..) to your account
24
- * Bulk publish posts to multiple sites at once
25
  * SEO Statistics, track your keyword rankings
26
- * Uptime monitoring
27
- * Much, much more...
28
 
29
- Check out the [ManageWP Tour video](http://vimeo.com/22099014).
30
 
31
- http://vimeo.com/22099014
32
 
33
  Check out [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs").
34
 
35
  == Changelog ==
36
 
 
 
 
 
 
 
37
  = 3.9.24 =
38
  - New: Better support for large database dumps
39
  - Fix: PHP notice for WordPress 3.5
@@ -238,7 +243,6 @@ Check out [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs").
238
  * No passwords required
239
  * Improved clone/backup
240
 
241
-
242
  = 3.6.3 =
243
  * Initial public release
244
 
@@ -246,11 +250,11 @@ Check out [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs").
246
 
247
  1. Upload the plugin folder to your /wp-content/plugins/ folder
248
  2. Go to the Plugins page and activate ManageWP Worker
249
- 3. Visit [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs"), sign up and add your site
250
 
251
  Alternately
252
 
253
- 1. Visit [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs"), sign up and add your site
254
  2. ManageWP will warn you the worker plugin is not installed and offer a link for quick installation
255
 
256
  == Screenshots ==
@@ -278,4 +282,4 @@ Make sure you use the latest version of the worker plugin on the site you are tr
278
 
279
  = I have problems installing new plugins or upgrading WordPress through ManageWP =
280
 
281
- ManageWP Worker relies on properly set file permissions on your server. See the [user guide](http://managewp.com/user-guide#ftp "ManageWP user guide") for more tips.
1
  === ManageWP Worker ===
2
  Contributors: freediver
3
  Donate link: https://www.networkforgood.org/donation/MakeDonation.aspx?ORGID2=520781390
4
+ Tags: admin, analytics, administration, amazon, api, google drive, authentication, automatic, dashboard, dropbox, events, integration, manage, multsite, notification, performance, s3, security, seo, stats, tracking, managewp
5
  Requires at least: 3.0
6
  Tested up to: 3.5.1
7
  Stable tag: trunk
10
 
11
  == Description ==
12
 
13
+ [ManageWP](https://managewp.com/ "Manage Multiple Blogs") is a revolutionary plugin that helps users manage multiple WordPress blogs from one dashboard.
14
 
15
  Main features:
16
 
17
+ * Secure and fast solution for managing multiple WordPress sites
18
  * One click upgrades for WordPress, plugin and themes across all your sites
19
  * Schedule automatic backups of your websites (Amazon S3, Google Drive and Dropbox supported)
20
  * One click to access WP admin of any site
21
  * Install WordPress, clone or migrate a website to another domain
22
  * Bulk install themes and plugins to multiple sites at once
23
  * Add sub-users (writers, staff..) to your account
 
24
  * SEO Statistics, track your keyword rankings
25
+ * Uptime monitoring - receive an SMS notification ifyour site goes down
26
+ * Bulk publish posts to multiple sites at once
27
 
28
+ Check out the [ManageWP Tour video](http://vimeo.com/61268162).
29
 
30
+ http://vimeo.com/61268162
31
 
32
  Check out [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs").
33
 
34
  == Changelog ==
35
 
36
+ = 3.9.25 =
37
+ - New: Improved Worker branding feature
38
+ - Fix: Traffic alerts feature was not functioning properly
39
+ - Fix: Backup information was sometimes incorrectly displayed
40
+ - Fix: DB Table overhead was not shown on the dashboard
41
+
42
  = 3.9.24 =
43
  - New: Better support for large database dumps
44
  - Fix: PHP notice for WordPress 3.5
243
  * No passwords required
244
  * Improved clone/backup
245
 
 
246
  = 3.6.3 =
247
  * Initial public release
248
 
250
 
251
  1. Upload the plugin folder to your /wp-content/plugins/ folder
252
  2. Go to the Plugins page and activate ManageWP Worker
253
+ 3. Visit [ManageWP.com](https://managewp.com/ "ManageWP"), sign up and add your site
254
 
255
  Alternately
256
 
257
+ 1. Visit [ManageWP.com](https://managewp.com/ "Manage Multiple WordPress Sites"), sign up and add your site
258
  2. ManageWP will warn you the worker plugin is not installed and offer a link for quick installation
259
 
260
  == Screenshots ==
282
 
283
  = I have problems installing new plugins or upgrading WordPress through ManageWP =
284
 
285
+ ManageWP Worker relies on properly set file permissions on your server. See the [user guide](https://managewp.com/user-guide#ftp "ManageWP user guide") for more tips.
stats.class.php CHANGED
@@ -9,7 +9,7 @@
9
  * Copyright (c) 2011 Prelovac Media
10
  * www.prelovac.com
11
  **************************************************************/
12
- if(basename($_SERVER['SCRIPT_FILENAME']) == "stats.class.php"):
13
  exit;
14
  endif;
15
 
@@ -134,9 +134,9 @@ class MMB_Stats extends MMB_Core
134
  $recent = new stdClass();
135
  $recent->post_permalink = get_permalink($recent_page_published->ID);
136
  $recent->post_type = $recent_page_published->post_type;
137
- $recent->ID = $recent_page_published->ID;
138
- $recent->post_date = $recent_page_published->post_date;
139
- $recent->post_title = $recent_page_published->post_title;
140
 
141
  $recent_posts[] = $recent;
142
  }
@@ -259,22 +259,22 @@ class MMB_Stats extends MMB_Core
259
  function get_updates($stats, $options = array())
260
  {
261
  $upgrades = false;
262
- $premium = array();
263
  if (isset($options['premium']) && $options['premium']) {
264
  $premium_updates = array();
265
- $upgrades = apply_filters('mwp_premium_update_notification', $premium_updates);
266
- if (!empty($upgrades)) {
267
- foreach( $upgrades as $data ){
268
- if( isset($data['Name']) )
269
- $premium[] = $data['Name'];
270
- }
271
  $stats['premium_updates'] = $upgrades;
272
  $upgrades = false;
273
  }
274
  }
275
  if (isset($options['themes']) && $options['themes']) {
276
  $this->get_installer_instance();
277
- $upgrades = $this->installer_instance->get_upgradable_themes( $premium );
278
  if (!empty($upgrades)) {
279
  $stats['upgradable_themes'] = $upgrades;
280
  $upgrades = false;
@@ -283,7 +283,7 @@ class MMB_Stats extends MMB_Core
283
 
284
  if (isset($options['plugins']) && $options['plugins']) {
285
  $this->get_installer_instance();
286
- $upgrades = $this->installer_instance->get_upgradable_plugins( $premium );
287
  if (!empty($upgrades)) {
288
  $stats['upgradable_plugins'] = $upgrades;
289
  $upgrades = false;
@@ -293,57 +293,57 @@ class MMB_Stats extends MMB_Core
293
  return $stats;
294
  }
295
 
296
- function get_errors($stats, $options = array())
297
  {
298
- $period = isset($options['days']) ? (int) $options['days'] * 86400 : 86400;
299
- $maxerrors = isset($options['max']) ? (int) $options['max'] : 20;
300
- $errors = array();
301
  if (isset($options['get']) && $options['get'] == true) {
302
  if (function_exists('ini_get')) {
303
  $logpath = ini_get('error_log');
304
  if (!empty($logpath) && file_exists($logpath)) {
305
- $logfile = @fopen($logpath, 'r');
306
  if ($logfile && filesize($logpath) > 0) {
307
  $maxlines = 1;
308
  $linesize = -4096;
309
  $lines = array();
310
  $line = true;
311
  while ($line !== false) {
312
- if( fseek($logfile, ($maxlines * $linesize), SEEK_END) !== -1){
313
- $maxlines++;
314
- if ($line) {
315
- $line = fread($logfile, ($linesize * -1)) . $line;
316
-
317
- foreach ((array) preg_split("/(\r|\n|\r\n)/U", $line) as $l) {
318
- preg_match('/\[(.*)\]/Ui', $l, $match);
319
- if (!empty($match)) {
320
- $key = str_replace($match[0], '', $l);
321
- if(!isset($errors[$key])){
322
- $errors[$key] = 1;
323
- } else {
324
- $errors[$key] = $errors[$key] + 1;
325
- }
326
-
327
- if ((strtotime($match[1]) < ((int) time() - $period)) || count($errors) >= $maxerrors) {
328
- $line = false;
329
- break;
330
- }
331
- }
332
- }
333
- }
334
- } else
335
- break;
336
  }
337
  }
338
- if (!empty($errors)){
339
- $stats['errors'] = $errors;
340
- $stats['logpath'] = $logpath;
341
- $stats['logsize'] = @filesize($logpath);
342
- }
343
  }
344
  }
345
  }
346
-
347
  return $stats;
348
  }
349
 
@@ -360,8 +360,8 @@ class MMB_Stats extends MMB_Core
360
  if ($refresh == 'transient') {
361
  $current = $this->mmb_get_transient('update_core');
362
  if (isset($current->last_checked) || get_option('mmb_forcerefresh')) {
363
- update_option('mmb_forcerefresh', false);
364
- if (time() - $current->last_checked > 14400) {
365
  @wp_version_check();
366
  @wp_update_plugins();
367
  @wp_update_themes();
@@ -379,13 +379,13 @@ class MMB_Stats extends MMB_Core
379
  $stats['wp_multisite'] = $this->mmb_multisite;
380
  $stats['network_install'] = $this->network_admin_install;
381
 
382
- if ( !function_exists('get_filesystem_method') )
383
  include_once(ABSPATH . 'wp-admin/includes/file.php');
384
  $mmode = get_option('mwp_maintenace_mode');
385
-
386
- if( !empty($mmode) && isset($mmode['active']) && $mmode['active'] == true){
387
- $stats['maintenance'] = true;
388
- }
389
  $stats['writable'] = $this->is_server_writable();
390
 
391
  return $stats;
@@ -394,12 +394,13 @@ class MMB_Stats extends MMB_Core
394
  function get($params)
395
  {
396
  global $wpdb, $mmb_wp_version, $mmb_plugin_dir, $_mmb_item_filter;
397
-
398
  include_once(ABSPATH . 'wp-includes/update.php');
399
  include_once(ABSPATH . '/wp-admin/includes/update.php');
400
 
401
- $stats = $this->mmb_parse_action_params('get', $params, $this);
402
- $update_check = array();
 
403
  $num = extract($params);
404
  if ($refresh == 'transient') {
405
  $update_check = apply_filters('mwp_premium_update_check', $update_check);
@@ -420,33 +421,37 @@ class MMB_Stats extends MMB_Core
420
  if ($this->mmb_multisite) {
421
  $stats = $this->get_multisite($stats);
422
  }
423
-
424
- update_option('mmb_stats_filter', $params['item_filter']['get_stats']);
425
- $stats = apply_filters('mmb_stats_filter', $stats);
 
426
  return $stats;
427
  }
428
 
429
  function get_multisite($stats = array())
430
  {
431
  global $current_user, $wpdb;
432
- $user_blogs = get_blogs_of_user( $current_user->ID );
433
- $network_blogs = $wpdb->get_results( "select `blog_id`, `site_id` from `{$wpdb->blogs}`" );
434
- if ($this->network_admin_install == '1' && is_super_admin()) {
435
- if (!empty($network_blogs)) {
436
  $blogs = array();
437
- foreach ( $network_blogs as $details) {
438
- if($details->site_id == $details->blog_id)
439
- continue;
440
- else {
441
- $data = get_blog_details($details->blog_id);
442
- if(in_array($details->blog_id, array_keys($user_blogs)))
443
- $stats['network_blogs'][] = $data->siteurl;
444
- else {
445
- $user = get_users( array( 'blog_id' => $details->blog_id, 'number' => 1) );
446
- if( !empty($user) )
447
- $stats['other_blogs'][$data->siteurl] = $user[0]->user_login;
448
- }
449
- }
 
 
 
450
  }
451
  }
452
  }
@@ -477,7 +482,7 @@ class MMB_Stats extends MMB_Core
477
 
478
  function get_initial_stats()
479
  {
480
- global $mmb_plugin_dir;
481
 
482
  $stats = array();
483
 
@@ -488,7 +493,7 @@ class MMB_Stats extends MMB_Core
488
  $stats['worker_version'] = MMB_WORKER_VERSION;
489
  $stats['site_title'] = get_bloginfo('name');
490
  $stats['site_tagline'] = get_bloginfo('description');
491
- $stats['db_name'] = $this->get_active_db();
492
  $stats['site_home'] = get_option('home');
493
  $stats['admin_url'] = admin_url();
494
  $stats['wp_multisite'] = $this->mmb_multisite;
@@ -507,27 +512,66 @@ class MMB_Stats extends MMB_Core
507
 
508
  $stats['writable'] = $this->is_server_writable();
509
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
510
  return $stats;
511
  }
512
-
513
- function get_active_db(){
514
- global $wpdb;
515
- $sql='SELECT DATABASE() as db_name';
516
-
517
- $sqlresult = $wpdb->get_row($sql);
518
- $active_db=$sqlresult->db_name;
519
-
520
- return $active_db;
521
-
522
- }
 
523
 
524
  function set_hit_count($fix_count = false)
525
  {
526
- global $mmb_core;
527
- $uptime_robot = array("74.86.158.106", "74.86.179.130", "74.86.179.131", "46.137.190.132", "122.248.234.23", "74.86.158.107"); //don't let uptime robot to affect visit count
528
-
529
- if ($fix_count || (!is_admin() && !MMB_Stats::is_bot() && !isset($_GET['doing_wp_cron']) && !in_array($_SERVER['REMOTE_ADDR'],$uptime_robot)) ) {
530
-
 
 
 
 
 
 
 
531
  $date = date('Y-m-d');
532
  $user_hit_count = (array) get_option('user_hit_count');
533
  if (!$user_hit_count) {
@@ -587,6 +631,7 @@ class MMB_Stats extends MMB_Core
587
 
588
  return get_option('user_hit_count');
589
  }
 
590
 
591
  function is_bot()
592
  {
@@ -672,9 +717,9 @@ class MMB_Stats extends MMB_Core
672
 
673
  $mwp_notifications = get_option('mwp_notifications', true);
674
 
675
- $args = array();
676
- $updates = array();
677
- $send = 0;
678
  if (is_array($mwp_notifications) && $mwp_notifications != false) {
679
  include_once(ABSPATH . 'wp-includes/update.php');
680
  include_once(ABSPATH . '/wp-admin/includes/update.php');
@@ -728,35 +773,35 @@ class MMB_Stats extends MMB_Core
728
 
729
 
730
  if (!empty($updates)) {
731
- $args['body']['updates'] = $updates;
732
  $args['body']['notification_key'] = $notification_key;
733
- $send = 1;
734
  }
735
 
736
  }
737
 
738
 
739
- $alert_data = get_option('mwp_pageview_alerts',true);
740
- if(is_array($alert_data) && $alert_data['alert']){
741
- $pageviews = get_option('user_hit_count');
742
- $args['body']['alerts']['pageviews'] = $pageviews;
743
- $args['body']['alerts']['site_id'] = $alert_data['site_id'];
744
- if(!isset($url)){
745
- $url = $alert_data['url'];
746
- }
747
- $send = 1;
748
  }
749
 
750
- if($send){
751
- if (!class_exists('WP_Http')) {
752
  include_once(ABSPATH . WPINC . '/class-http.php');
753
  }
754
- $result = wp_remote_post($url, $args);
755
-
756
- if (is_array($result) && $result['body'] == 'mwp_delete_alert') {
757
- delete_option('mwp_pageview_alerts');
758
- }
759
- }
760
 
761
 
762
  }
@@ -777,11 +822,7 @@ class MMB_Stats extends MMB_Core
777
  return $content;
778
  }
779
 
780
- function set_alerts($args){
781
- extract($args);
782
- update_option('mwp_pageview_alerts',array('site_id' => $site_id,'alert' => $alert,'url' => $url));
783
- }
784
-
785
  public static function readd_alerts( $params = array() ){
786
  if( empty($params) || !isset($params['alerts']))
787
  return $params;
@@ -795,7 +836,7 @@ class MMB_Stats extends MMB_Core
795
  }
796
  }
797
 
798
- if( function_exists('add_filter') ){
799
- add_filter( 'mwp_website_add', 'MMB_Stats::readd_alerts' );
800
  }
801
  ?>
9
  * Copyright (c) 2011 Prelovac Media
10
  * www.prelovac.com
11
  **************************************************************/
12
+ if (basename($_SERVER['SCRIPT_FILENAME']) == "stats.class.php"):
13
  exit;
14
  endif;
15
 
134
  $recent = new stdClass();
135
  $recent->post_permalink = get_permalink($recent_page_published->ID);
136
  $recent->post_type = $recent_page_published->post_type;
137
+ $recent->ID = $recent_page_published->ID;
138
+ $recent->post_date = $recent_page_published->post_date;
139
+ $recent->post_title = $recent_page_published->post_title;
140
 
141
  $recent_posts[] = $recent;
142
  }
259
  function get_updates($stats, $options = array())
260
  {
261
  $upgrades = false;
262
+ $premium = array();
263
  if (isset($options['premium']) && $options['premium']) {
264
  $premium_updates = array();
265
+ $upgrades = apply_filters('mwp_premium_update_notification', $premium_updates);
266
+ if (!empty($upgrades)) {
267
+ foreach ($upgrades as $data) {
268
+ if (isset($data['Name']))
269
+ $premium[] = $data['Name'];
270
+ }
271
  $stats['premium_updates'] = $upgrades;
272
  $upgrades = false;
273
  }
274
  }
275
  if (isset($options['themes']) && $options['themes']) {
276
  $this->get_installer_instance();
277
+ $upgrades = $this->installer_instance->get_upgradable_themes($premium);
278
  if (!empty($upgrades)) {
279
  $stats['upgradable_themes'] = $upgrades;
280
  $upgrades = false;
283
 
284
  if (isset($options['plugins']) && $options['plugins']) {
285
  $this->get_installer_instance();
286
+ $upgrades = $this->installer_instance->get_upgradable_plugins($premium);
287
  if (!empty($upgrades)) {
288
  $stats['upgradable_plugins'] = $upgrades;
289
  $upgrades = false;
293
  return $stats;
294
  }
295
 
296
+ function get_errors($stats, $options = array())
297
  {
298
+ $period = isset($options['days']) ? (int) $options['days'] * 86400 : 86400;
299
+ $maxerrors = isset($options['max']) ? (int) $options['max'] : 20;
300
+ $errors = array();
301
  if (isset($options['get']) && $options['get'] == true) {
302
  if (function_exists('ini_get')) {
303
  $logpath = ini_get('error_log');
304
  if (!empty($logpath) && file_exists($logpath)) {
305
+ $logfile = @fopen($logpath, 'r');
306
  if ($logfile && filesize($logpath) > 0) {
307
  $maxlines = 1;
308
  $linesize = -4096;
309
  $lines = array();
310
  $line = true;
311
  while ($line !== false) {
312
+ if (fseek($logfile, ($maxlines * $linesize), SEEK_END) !== -1) {
313
+ $maxlines++;
314
+ if ($line) {
315
+ $line = fread($logfile, ($linesize * -1)) . $line;
316
+
317
+ foreach ((array) preg_split("/(\r|\n|\r\n)/U", $line) as $l) {
318
+ preg_match('/\[(.*)\]/Ui', $l, $match);
319
+ if (!empty($match)) {
320
+ $key = str_replace($match[0], '', $l);
321
+ if (!isset($errors[$key])) {
322
+ $errors[$key] = 1;
323
+ } else {
324
+ $errors[$key] = $errors[$key] + 1;
325
+ }
326
+
327
+ if ((strtotime($match[1]) < ((int) time() - $period)) || count($errors) >= $maxerrors) {
328
+ $line = false;
329
+ break;
330
+ }
331
+ }
332
+ }
333
+ }
334
+ } else
335
+ break;
336
  }
337
  }
338
+ if (!empty($errors)) {
339
+ $stats['errors'] = $errors;
340
+ $stats['logpath'] = $logpath;
341
+ $stats['logsize'] = @filesize($logpath);
342
+ }
343
  }
344
  }
345
  }
346
+
347
  return $stats;
348
  }
349
 
360
  if ($refresh == 'transient') {
361
  $current = $this->mmb_get_transient('update_core');
362
  if (isset($current->last_checked) || get_option('mmb_forcerefresh')) {
363
+ update_option('mmb_forcerefresh', false);
364
+ if (time() - $current->last_checked > 7200) {
365
  @wp_version_check();
366
  @wp_update_plugins();
367
  @wp_update_themes();
379
  $stats['wp_multisite'] = $this->mmb_multisite;
380
  $stats['network_install'] = $this->network_admin_install;
381
 
382
+ if (!function_exists('get_filesystem_method'))
383
  include_once(ABSPATH . 'wp-admin/includes/file.php');
384
  $mmode = get_option('mwp_maintenace_mode');
385
+
386
+ if (!empty($mmode) && isset($mmode['active']) && $mmode['active'] == true) {
387
+ $stats['maintenance'] = true;
388
+ }
389
  $stats['writable'] = $this->is_server_writable();
390
 
391
  return $stats;
394
  function get($params)
395
  {
396
  global $wpdb, $mmb_wp_version, $mmb_plugin_dir, $_mmb_item_filter;
397
+
398
  include_once(ABSPATH . 'wp-includes/update.php');
399
  include_once(ABSPATH . '/wp-admin/includes/update.php');
400
 
401
+ $stats = $this->mmb_parse_action_params('get', $params, $this);
402
+
403
+ $update_check = array();
404
  $num = extract($params);
405
  if ($refresh == 'transient') {
406
  $update_check = apply_filters('mwp_premium_update_check', $update_check);
421
  if ($this->mmb_multisite) {
422
  $stats = $this->get_multisite($stats);
423
  }
424
+
425
+ update_option('mmb_stats_filter', $params['item_filter']['get_stats']);
426
+ $stats = apply_filters('mmb_stats_filter', $stats);
427
+
428
  return $stats;
429
  }
430
 
431
  function get_multisite($stats = array())
432
  {
433
  global $current_user, $wpdb;
434
+ $user_blogs = get_blogs_of_user($current_user->ID);
435
+ $network_blogs = $wpdb->get_results("select `blog_id`, `site_id` from `{$wpdb->blogs}`");
436
+ if ($this->network_admin_install == '1' && is_super_admin()) {
437
+ if (!empty($network_blogs)) {
438
  $blogs = array();
439
+ foreach ($network_blogs as $details) {
440
+ if ($details->site_id == $details->blog_id)
441
+ continue;
442
+ else {
443
+ $data = get_blog_details($details->blog_id);
444
+ if (in_array($details->blog_id, array_keys($user_blogs)))
445
+ $stats['network_blogs'][] = $data->siteurl;
446
+ else {
447
+ $user = get_users(array(
448
+ 'blog_id' => $details->blog_id,
449
+ 'number' => 1
450
+ ));
451
+ if (!empty($user))
452
+ $stats['other_blogs'][$data->siteurl] = $user[0]->user_login;
453
+ }
454
+ }
455
  }
456
  }
457
  }
482
 
483
  function get_initial_stats()
484
  {
485
+ global $mmb_plugin_dir,$_mmb_item_filter;;
486
 
487
  $stats = array();
488
 
493
  $stats['worker_version'] = MMB_WORKER_VERSION;
494
  $stats['site_title'] = get_bloginfo('name');
495
  $stats['site_tagline'] = get_bloginfo('description');
496
+ $stats['db_name'] = $this->get_active_db();
497
  $stats['site_home'] = get_option('home');
498
  $stats['admin_url'] = admin_url();
499
  $stats['wp_multisite'] = $this->mmb_multisite;
512
 
513
  $stats['writable'] = $this->is_server_writable();
514
 
515
+ $_mmb_item_filter['pre_init_stats'] = array( 'core_update', 'hit_counter', 'comments', 'backups', 'posts', 'drafts', 'scheduled' );
516
+ $_mmb_item_filter['get'] = array( 'updates', 'errors' );
517
+
518
+ $filter = array(
519
+ 'refresh' => 'transient',
520
+ 'item_filter' => array(
521
+ 'get_stats' => array(
522
+ array('updates', array('plugins' => true, 'themes' => true, 'premium' => true )),
523
+ array('core_update', array('core' => true )),
524
+ array('posts', array('numberposts' => 5 )),
525
+ array('drafts', array('numberposts' => 5 )),
526
+ array('scheduled', array('numberposts' => 5 )),
527
+ array('hit_counter'),
528
+ array('comments', array('numberposts' => 5 )),
529
+ array('backups'),
530
+ 'plugins' => array('cleanup' => array(
531
+ 'overhead' => array(),
532
+ 'revisions' => array( 'num_to_keep' => 'r_5'),
533
+ 'spam' => array(),
534
+ )
535
+ ),
536
+ ),
537
+ )
538
+ );
539
+
540
+ $pre_init_data = $this->pre_init_stats($filter);
541
+ $init_data = $this->get($filter);
542
+
543
+ $stats['initial_stats']=array_merge($init_data, $pre_init_data); ;
544
+
545
+
546
  return $stats;
547
  }
548
+
549
+ function get_active_db()
550
+ {
551
+ global $wpdb;
552
+ $sql = 'SELECT DATABASE() as db_name';
553
+
554
+ $sqlresult = $wpdb->get_row($sql);
555
+ $active_db = $sqlresult->db_name;
556
+
557
+ return $active_db;
558
+
559
+ }
560
 
561
  function set_hit_count($fix_count = false)
562
  {
563
+ global $mmb_core;
564
+ $uptime_robot = array(
565
+ "74.86.158.106",
566
+ "74.86.179.130",
567
+ "74.86.179.131",
568
+ "46.137.190.132",
569
+ "122.248.234.23",
570
+ "74.86.158.107"
571
+ ); //don't let uptime robot to affect visit count
572
+
573
+ if ($fix_count || (!is_admin() && !MMB_Stats::is_bot() && !isset($_GET['doing_wp_cron']) && !in_array($_SERVER['REMOTE_ADDR'], $uptime_robot))) {
574
+
575
  $date = date('Y-m-d');
576
  $user_hit_count = (array) get_option('user_hit_count');
577
  if (!$user_hit_count) {
631
 
632
  return get_option('user_hit_count');
633
  }
634
+
635
 
636
  function is_bot()
637
  {
717
 
718
  $mwp_notifications = get_option('mwp_notifications', true);
719
 
720
+ $args = array();
721
+ $updates = array();
722
+ $send = 0;
723
  if (is_array($mwp_notifications) && $mwp_notifications != false) {
724
  include_once(ABSPATH . 'wp-includes/update.php');
725
  include_once(ABSPATH . '/wp-admin/includes/update.php');
773
 
774
 
775
  if (!empty($updates)) {
776
+ $args['body']['updates'] = $updates;
777
  $args['body']['notification_key'] = $notification_key;
778
+ $send = 1;
779
  }
780
 
781
  }
782
 
783
 
784
+ $alert_data = get_option('mwp_pageview_alerts', true);
785
+ if (is_array($alert_data) && $alert_data['alert']) {
786
+ $pageviews = get_option('user_hit_count');
787
+ $args['body']['alerts']['pageviews'] = $pageviews;
788
+ $args['body']['alerts']['site_id'] = $alert_data['site_id'];
789
+ if (!isset($url)) {
790
+ $url = $alert_data['url'];
791
+ }
792
+ $send = 1;
793
  }
794
 
795
+ if ($send) {
796
+ if (!class_exists('WP_Http')) {
797
  include_once(ABSPATH . WPINC . '/class-http.php');
798
  }
799
+ $result = wp_remote_post($url, $args);
800
+
801
+ if (is_array($result) && $result['body'] == 'mwp_delete_alert') {
802
+ delete_option('mwp_pageview_alerts');
803
+ }
804
+ }
805
 
806
 
807
  }
822
  return $content;
823
  }
824
 
825
+
 
 
 
 
826
  public static function readd_alerts( $params = array() ){
827
  if( empty($params) || !isset($params['alerts']))
828
  return $params;
836
  }
837
  }
838
 
839
+ if (function_exists('add_filter')) {
840
+ add_filter('mwp_website_add', 'MMB_Stats::readd_alerts');
841
  }
842
  ?>
version CHANGED
@@ -1 +1 @@
1
- 3.9.24
1
+ 3.9.25