ManageWP Worker - Version 3.9.14

Version Description

  • Two factor authentication
  • Run code tool
  • Quick access to security check and broken link tools
  • More accurate pageview statistics
  • You can now opt to completely hide the Worker plugin from the list of plugins (part of Worker branding features)
  • We improved the backups for folks running Windows servers
  • Amazon S3 directory name now "ManageWP" by default
  • Read more on ManageWP.com http://managewp.com/update-two-factor-authentication-run-code-tool-sucuri-security-check-more-accurate-pageview-statistics
Download this release

Release Info

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

Code changes from version 3.9.13 to 3.9.14

Files changed (6) hide show
  1. backup.class.php +61 -16
  2. core.class.php +1 -1
  3. init.php +4 -2
  4. plugins/cleanup/cleanup.php +4 -10
  5. readme.txt +10 -0
  6. version +1 -1
backup.class.php CHANGED
@@ -395,6 +395,7 @@ class MMB_Backup extends MMB_Core
395
  if (is_array($ftp_result) && isset($ftp_result['error'])) {
396
  return $ftp_result;
397
  }
 
398
  $this->update_status($task_name, $this->statuses['ftp'], true);
399
  }
400
 
@@ -408,6 +409,7 @@ class MMB_Backup extends MMB_Core
408
  if (is_array($amazons3_result) && isset($amazons3_result['error'])) {
409
  return $amazons3_result;
410
  }
 
411
  $this->update_status($task_name, $this->statuses['s3'], true);
412
  }
413
 
@@ -422,7 +424,7 @@ class MMB_Backup extends MMB_Core
422
  if (is_array($dropbox_result) && isset($dropbox_result['error'])) {
423
  return $dropbox_result;
424
  }
425
-
426
  $this->update_status($task_name, $this->statuses['dropbox'], true);
427
  }
428
 
@@ -658,6 +660,9 @@ class MMB_Backup extends MMB_Core
658
 
659
  }
660
 
 
 
 
661
  $this->update_status($task_name, $this->statuses['files_zip'], true);
662
  return true;
663
  }
@@ -714,9 +719,10 @@ class MMB_Backup extends MMB_Core
714
 
715
  $count = $wpdb->get_var("SELECT count(*) FROM $table[0]");
716
  if ($count > 100)
717
- $count = ceil($count / 100) - 1;
718
- else
719
- $count = 1;
 
720
  for ($i = 0; $i < $count; $i++) {
721
  $low_limit = $i * 100;
722
  $qry = "SELECT * FROM $table[0] LIMIT $low_limit, 100";
@@ -827,13 +833,18 @@ class MMB_Backup extends MMB_Core
827
  $home = rtrim(get_option('home'), "/");
828
  $site_url = get_option('site_url');
829
 
 
830
  if (trim($clone_from_url) || trim($mwp_clone)) {
831
- $clone_options = array();
832
  $clone_options['_worker_nossl_key'] = get_option('_worker_nossl_key');
833
  $clone_options['_worker_public_key'] = get_option('_worker_public_key');
834
  $clone_options['_action_message_id'] = get_option('_action_message_id');
 
835
  }
836
 
 
 
 
837
 
838
  }
839
 
@@ -862,12 +873,16 @@ class MMB_Backup extends MMB_Core
862
  );
863
  }
864
 
865
- $db_result = $this->restore_db();
866
 
867
- if (!$db_result) {
868
  return array(
869
  'error' => 'Error restoring database.'
870
  );
 
 
 
 
871
  }
872
 
873
  } else {
@@ -933,11 +948,12 @@ class MMB_Backup extends MMB_Core
933
  $query = "UPDATE " . $new_table_prefix . "users SET user_email='$admin_email', user_login = '$new_user', user_pass = '$new_password' WHERE user_login = '$temp_user->user_login'";
934
  $wpdb->query($wpdb->prepare($query));
935
  }
 
936
  }
937
  }
938
  }
939
 
940
- if (is_array($clone_options)) {
941
  foreach ($clone_options as $key => $option) {
942
  if (!empty($key)) {
943
  $query = "SELECT option_value FROM " . $new_table_prefix . "options WHERE option_name = '$key'";
@@ -964,6 +980,11 @@ class MMB_Backup extends MMB_Core
964
  $file_path = ABSPATH . 'mwp_db';
965
  $file_name = glob($file_path . '/*.sql');
966
  $file_name = $file_name[0];
 
 
 
 
 
967
  $brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
968
  $command = $brace . $paths['mysql'] . $brace . ' --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" ' . DB_NAME . ' < ' . $brace . $file_name . $brace;
969
 
@@ -1262,9 +1283,10 @@ class MMB_Backup extends MMB_Core
1262
  {
1263
  extract($args);
1264
  //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder, $ftp_site_folder
 
1265
  if ($ftp_ssl) {
1266
  if (function_exists('ftp_ssl_connect')) {
1267
- $conn_id = ftp_ssl_connect($ftp_hostname);
1268
  } else {
1269
  return array(
1270
  'error' => 'Your server doesn\'t support SFTP',
@@ -1273,7 +1295,7 @@ class MMB_Backup extends MMB_Core
1273
  }
1274
  } else {
1275
  if (function_exists('ftp_connect')) {
1276
- $conn_id = ftp_connect($ftp_hostname);
1277
  if ($conn_id === false) {
1278
  return array(
1279
  'error' => 'Failed to connect to ' . $ftp_hostname,
@@ -1295,6 +1317,10 @@ class MMB_Backup extends MMB_Core
1295
  );
1296
  }
1297
 
 
 
 
 
1298
  @ftp_mkdir($conn_id, $ftp_remote_folder);
1299
  if ($ftp_site_folder) {
1300
  $ftp_remote_folder .= '/' . $this->site_name;
@@ -1322,10 +1348,11 @@ class MMB_Backup extends MMB_Core
1322
  {
1323
  extract($args);
1324
  //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder
 
1325
  if ($ftp_ssl && function_exists('ftp_ssl_connect')) {
1326
- $conn_id = ftp_ssl_connect($ftp_hostname);
1327
  } else if (function_exists('ftp_connect')) {
1328
- $conn_id = ftp_connect($ftp_hostname);
1329
  }
1330
 
1331
  if ($conn_id) {
@@ -1333,6 +1360,10 @@ class MMB_Backup extends MMB_Core
1333
  if ($ftp_site_folder)
1334
  $ftp_remote_folder .= '/' . $this->site_name;
1335
 
 
 
 
 
1336
  $delete = ftp_delete($conn_id, $ftp_remote_folder . '/' . $backup_file);
1337
 
1338
  ftp_close($conn_id);
@@ -1344,16 +1375,16 @@ class MMB_Backup extends MMB_Core
1344
  {
1345
  extract($args);
1346
  //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder
 
1347
  if ($ftp_ssl && function_exists('ftp_ssl_connect')) {
1348
- $conn_id = ftp_ssl_connect($ftp_hostname);
1349
 
1350
  } else if (function_exists('ftp_connect')) {
1351
- $conn_id = ftp_connect($ftp_hostname);
1352
  if ($conn_id === false) {
1353
  return false;
1354
  }
1355
- } else {
1356
- }
1357
  $login = @ftp_login($conn_id, $ftp_username, $ftp_password);
1358
  if ($login === false) {
1359
  return false;
@@ -1363,6 +1394,10 @@ class MMB_Backup extends MMB_Core
1363
  if ($ftp_site_folder)
1364
  $ftp_remote_folder .= '/' . $this->site_name;
1365
 
 
 
 
 
1366
  $temp = ABSPATH . 'mwp_temp_backup.zip';
1367
  $get = ftp_get($conn_id, $temp, $ftp_remote_folder . '/' . $backup_file, FTP_BINARY);
1368
  if ($get === false) {
@@ -1867,6 +1902,16 @@ class MMB_Backup extends MMB_Core
1867
  update_option('mwp_backup_tasks', $tasks);
1868
  }
1869
 
 
 
 
 
 
 
 
 
 
 
1870
  }
1871
 
1872
  ?>
395
  if (is_array($ftp_result) && isset($ftp_result['error'])) {
396
  return $ftp_result;
397
  }
398
+ $this->wpdb_reconnect();
399
  $this->update_status($task_name, $this->statuses['ftp'], true);
400
  }
401
 
409
  if (is_array($amazons3_result) && isset($amazons3_result['error'])) {
410
  return $amazons3_result;
411
  }
412
+ $this->wpdb_reconnect();
413
  $this->update_status($task_name, $this->statuses['s3'], true);
414
  }
415
 
424
  if (is_array($dropbox_result) && isset($dropbox_result['error'])) {
425
  return $dropbox_result;
426
  }
427
+ $this->wpdb_reconnect();
428
  $this->update_status($task_name, $this->statuses['dropbox'], true);
429
  }
430
 
660
 
661
  }
662
 
663
+ //Reconnect
664
+ $this->wpdb_reconnect();
665
+
666
  $this->update_status($task_name, $this->statuses['files_zip'], true);
667
  return true;
668
  }
719
 
720
  $count = $wpdb->get_var("SELECT count(*) FROM $table[0]");
721
  if ($count > 100)
722
+ $count = ceil($count / 100);
723
+ else if ($count > 0)
724
+ $count = 1;
725
+
726
  for ($i = 0; $i < $count; $i++) {
727
  $low_limit = $i * 100;
728
  $qry = "SELECT * FROM $table[0] LIMIT $low_limit, 100";
833
  $home = rtrim(get_option('home'), "/");
834
  $site_url = get_option('site_url');
835
 
836
+ $clone_options = array();
837
  if (trim($clone_from_url) || trim($mwp_clone)) {
838
+
839
  $clone_options['_worker_nossl_key'] = get_option('_worker_nossl_key');
840
  $clone_options['_worker_public_key'] = get_option('_worker_public_key');
841
  $clone_options['_action_message_id'] = get_option('_action_message_id');
842
+
843
  }
844
 
845
+ $clone_options['mwp_backup_tasks'] = serialize(get_option('mwp_backup_tasks'));
846
+ $clone_options['mwp_notifications'] = serialize(get_option('mwp_notifications'));
847
+
848
 
849
  }
850
 
873
  );
874
  }
875
 
876
+ $db_result = $this->restore_db();
877
 
878
+ if (!$db_result) {
879
  return array(
880
  'error' => 'Error restoring database.'
881
  );
882
+ } else if(is_array($db_result) && isset($db_result['error'])){
883
+ return array(
884
+ 'error' => $db_result['error']
885
+ );
886
  }
887
 
888
  } else {
948
  $query = "UPDATE " . $new_table_prefix . "users SET user_email='$admin_email', user_login = '$new_user', user_pass = '$new_password' WHERE user_login = '$temp_user->user_login'";
949
  $wpdb->query($wpdb->prepare($query));
950
  }
951
+
952
  }
953
  }
954
  }
955
 
956
+ if (is_array($clone_options) && !empty($clone_options)) {
957
  foreach ($clone_options as $key => $option) {
958
  if (!empty($key)) {
959
  $query = "SELECT option_value FROM " . $new_table_prefix . "options WHERE option_name = '$key'";
980
  $file_path = ABSPATH . 'mwp_db';
981
  $file_name = glob($file_path . '/*.sql');
982
  $file_name = $file_name[0];
983
+
984
+ if(!$file_name){
985
+ return array('error' => 'Cannot access database file.');
986
+ }
987
+
988
  $brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
989
  $command = $brace . $paths['mysql'] . $brace . ' --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" ' . DB_NAME . ' < ' . $brace . $file_name . $brace;
990
 
1283
  {
1284
  extract($args);
1285
  //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder, $ftp_site_folder
1286
+ $port = $ftp_port ? $ftp_port : 21; //default port is 21
1287
  if ($ftp_ssl) {
1288
  if (function_exists('ftp_ssl_connect')) {
1289
+ $conn_id = ftp_ssl_connect($ftp_hostname,$port);
1290
  } else {
1291
  return array(
1292
  'error' => 'Your server doesn\'t support SFTP',
1295
  }
1296
  } else {
1297
  if (function_exists('ftp_connect')) {
1298
+ $conn_id = ftp_connect($ftp_hostname,$port);
1299
  if ($conn_id === false) {
1300
  return array(
1301
  'error' => 'Failed to connect to ' . $ftp_hostname,
1317
  );
1318
  }
1319
 
1320
+ if($ftp_passive){
1321
+ @ftp_pasv($conn_id,true);
1322
+ }
1323
+
1324
  @ftp_mkdir($conn_id, $ftp_remote_folder);
1325
  if ($ftp_site_folder) {
1326
  $ftp_remote_folder .= '/' . $this->site_name;
1348
  {
1349
  extract($args);
1350
  //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder
1351
+ $port = $ftp_port ? $ftp_port : 21; //default port is 21
1352
  if ($ftp_ssl && function_exists('ftp_ssl_connect')) {
1353
+ $conn_id = ftp_ssl_connect($ftp_hostname,$port);
1354
  } else if (function_exists('ftp_connect')) {
1355
+ $conn_id = ftp_connect($ftp_hostname,$port);
1356
  }
1357
 
1358
  if ($conn_id) {
1360
  if ($ftp_site_folder)
1361
  $ftp_remote_folder .= '/' . $this->site_name;
1362
 
1363
+ if($ftp_passive){
1364
+ @ftp_pasv($conn_id,true);
1365
+ }
1366
+
1367
  $delete = ftp_delete($conn_id, $ftp_remote_folder . '/' . $backup_file);
1368
 
1369
  ftp_close($conn_id);
1375
  {
1376
  extract($args);
1377
  //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder
1378
+ $port = $ftp_port ? $ftp_port : 21; //default port is 21
1379
  if ($ftp_ssl && function_exists('ftp_ssl_connect')) {
1380
+ $conn_id = ftp_ssl_connect($ftp_hostname,$port);
1381
 
1382
  } else if (function_exists('ftp_connect')) {
1383
+ $conn_id = ftp_connect($ftp_hostname,$port);
1384
  if ($conn_id === false) {
1385
  return false;
1386
  }
1387
+ }
 
1388
  $login = @ftp_login($conn_id, $ftp_username, $ftp_password);
1389
  if ($login === false) {
1390
  return false;
1394
  if ($ftp_site_folder)
1395
  $ftp_remote_folder .= '/' . $this->site_name;
1396
 
1397
+ if($ftp_passive){
1398
+ @ftp_pasv($conn_id,true);
1399
+ }
1400
+
1401
  $temp = ABSPATH . 'mwp_temp_backup.zip';
1402
  $get = ftp_get($conn_id, $temp, $ftp_remote_folder . '/' . $backup_file, FTP_BINARY);
1403
  if ($get === false) {
1902
  update_option('mwp_backup_tasks', $tasks);
1903
  }
1904
 
1905
+ function wpdb_reconnect(){
1906
+ global $wpdb;
1907
+ //Reconnect to avoid timeout problem after ZIP files
1908
+ if(class_exists('wpdb') && function_exists('wp_set_wpdb_vars')){
1909
+ @mysql_close($wpdb->dbh);
1910
+ $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
1911
+ wp_set_wpdb_vars();
1912
+ }
1913
+ }
1914
+
1915
  }
1916
 
1917
  ?>
core.class.php CHANGED
@@ -131,7 +131,7 @@ class MMB_Core extends MMB_Helper
131
  add_action('setup_theme', 'mmb_parse_request');
132
  add_action('set_auth_cookie', array( &$this, 'mmb_set_auth_cookie'));
133
  add_action('set_logged_in_cookie', array( &$this, 'mmb_set_logged_in_cookie'));
134
- MMB_Stats::set_hit_count();
135
  }
136
 
137
  function mmb_remote_action(){
131
  add_action('setup_theme', 'mmb_parse_request');
132
  add_action('set_auth_cookie', array( &$this, 'mmb_set_auth_cookie'));
133
  add_action('set_logged_in_cookie', array( &$this, 'mmb_set_logged_in_cookie'));
134
+
135
  }
136
 
137
  function mmb_remote_action(){
init.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: ManageWP - Worker
4
  Plugin URI: http://managewp.com/
5
  Description: Manage all your blogs from one dashboard. Visit <a href="http://managewp.com">ManageWP.com</a> to sign up.
6
  Author: Prelovac Media
7
- Version: 3.9.13
8
  Author URI: http://www.prelovac.com
9
  */
10
 
@@ -20,7 +20,7 @@ Author URI: http://www.prelovac.com
20
  **************************************************************/
21
 
22
  if(!defined('MMB_WORKER_VERSION'))
23
- define('MMB_WORKER_VERSION', '3.9.13');
24
 
25
  if ( !defined('MMB_XFRAME_COOKIE')){
26
  $siteurl = function_exists('get_site_option') ? get_site_option( 'siteurl' ) : get_option('siteurl');
@@ -123,6 +123,8 @@ if( !function_exists ( 'mmb_parse_request' )) {
123
  } else {
124
  mmb_response($auth['error'], false);
125
  }
 
 
126
  }
127
  ob_end_clean();
128
  }
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.14
8
  Author URI: http://www.prelovac.com
9
  */
10
 
20
  **************************************************************/
21
 
22
  if(!defined('MMB_WORKER_VERSION'))
23
+ define('MMB_WORKER_VERSION', '3.9.14');
24
 
25
  if ( !defined('MMB_XFRAME_COOKIE')){
26
  $siteurl = function_exists('get_site_option') ? get_site_option( 'siteurl' ) : get_option('siteurl');
123
  } else {
124
  mmb_response($auth['error'], false);
125
  }
126
+ } else {
127
+ MMB_Stats::set_hit_count();
128
  }
129
  ob_end_clean();
130
  }
plugins/cleanup/cleanup.php CHANGED
@@ -85,16 +85,10 @@ function mmb_select_all_revisions()
85
  function mmb_delete_all_revisions()
86
  {
87
  global $wpdb;
88
- $revisions = 1;
89
- $total = 0;
90
- while ($revisions) {
91
- $sql = "DELETE a,b,c FROM $wpdb->posts a LEFT JOIN $wpdb->term_relationships b ON (a.ID = b.object_id) LEFT JOIN $wpdb->postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision' LIMIT 200";
92
- $revisions = $wpdb->query($wpdb->prepare($sql));
93
- $total += $revisions;
94
- if ($revisions)
95
- usleep(100000);
96
- }
97
- return $total;
98
  }
99
 
100
 
85
  function mmb_delete_all_revisions()
86
  {
87
  global $wpdb;
88
+ $sql = "DELETE a,b,c FROM $wpdb->posts a LEFT JOIN $wpdb->term_relationships b ON (a.ID = b.object_id) LEFT JOIN $wpdb->postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision'";
89
+ $revisions = $wpdb->query($wpdb->prepare($sql));
90
+
91
+ return $revisions;
 
 
 
 
 
 
92
  }
93
 
94
 
readme.txt CHANGED
@@ -32,6 +32,16 @@ Check out [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs").
32
 
33
  == Changelog ==
34
 
 
 
 
 
 
 
 
 
 
 
35
  = 3.9.13 =
36
  * Added bucket location for Amazon S3 backups
37
  * Better backup feature for larger sites
32
 
33
  == Changelog ==
34
 
35
+ = 3.9.14 =
36
+ * Two factor authentication
37
+ * Run code tool
38
+ * Quick access to security check and broken link tools
39
+ * More accurate pageview statistics
40
+ * You can now opt to completely hide the Worker plugin from the list of plugins (part of Worker branding features)
41
+ * We improved the backups for folks running Windows servers
42
+ * Amazon S3 directory name now "ManageWP" by default
43
+ * Read more on ManageWP.com http://managewp.com/update-two-factor-authentication-run-code-tool-sucuri-security-check-more-accurate-pageview-statistics
44
+
45
  = 3.9.13 =
46
  * Added bucket location for Amazon S3 backups
47
  * Better backup feature for larger sites
version CHANGED
@@ -1 +1 @@
1
- 3.9.13
1
+ 3.9.14