Version Description
- New: Better support for large database dumps
- Fix: PHP notice for WordPress 3.5
- Fix: Support for automatic backup reports
- Fix: Incorrect backup result message for S3 large files
Download this release
Release Info
Developer | freediver |
Plugin | ManageWP Worker |
Version | 3.9.24 |
Comparing to | |
See all releases |
Code changes from version 3.9.23 to 3.9.24
- backup.class.php +101 -158
- comment.class.php +1 -1
- core.class.php +4 -4
- helper.class.php +2 -2
- init.php +30 -15
- plugins/cleanup/cleanup.php +9 -9
- readme.txt +7 -1
- stats.class.php +1 -1
- version +1 -1
backup.class.php
CHANGED
@@ -198,7 +198,7 @@ class MMB_Backup extends MMB_Core {
|
|
198 |
}
|
199 |
}
|
200 |
|
201 |
-
if ($time) { //set next result time before backup
|
202 |
if (is_array($before[$task_name]['task_results'])) {
|
203 |
$before[$task_name]['task_results'] = array_values($before[$task_name]['task_results']);
|
204 |
}
|
@@ -237,7 +237,7 @@ class MMB_Backup extends MMB_Core {
|
|
237 |
$settings = $this->tasks;
|
238 |
if (is_array($settings) && !empty($settings)) {
|
239 |
foreach ($settings as $task_name => $setting) {
|
240 |
-
if ($setting['task_args']['next'] && $setting['task_args']['next'] < time()) {
|
241 |
//if ($setting['task_args']['next'] && $_GET['force_backup']) {
|
242 |
if ($setting['task_args']['url'] && $setting['task_args']['task_id'] && $setting['task_args']['site_key']) {
|
243 |
//Check orphan task
|
@@ -253,8 +253,14 @@ class MMB_Backup extends MMB_Core {
|
|
253 |
}
|
254 |
|
255 |
$check = $this->validate_task($check_data, $setting['task_args']['url']);
|
|
|
|
|
|
|
256 |
$worker_upto_3_9_22 = (MMB_WORKER_VERSION <= '3.9.22'); // worker version is less or equals to 3.9.22
|
257 |
|
|
|
|
|
|
|
258 |
if ($worker_upto_3_9_22) {
|
259 |
$potential_token = substr($check, 8);
|
260 |
if (substr($check, 0, 8) == 'token - ' && $potential_token != 'not found') {
|
@@ -278,17 +284,13 @@ class MMB_Backup extends MMB_Core {
|
|
278 |
'args' => $settings[$task_name]['task_args']
|
279 |
);
|
280 |
|
281 |
-
if($check != 'paused'){
|
282 |
$update['time'] = time();
|
283 |
}
|
284 |
|
285 |
//Update task with next schedule
|
286 |
$this->set_backup_task($update);
|
287 |
|
288 |
-
if($check == 'paused'){
|
289 |
-
continue;
|
290 |
-
}
|
291 |
-
|
292 |
$result = $this->backup($setting['task_args'], $task_name);
|
293 |
$error = '';
|
294 |
|
@@ -300,28 +302,26 @@ class MMB_Backup extends MMB_Core {
|
|
300 |
'error' => $error
|
301 |
));
|
302 |
} else {
|
303 |
-
$setting = $this->tasks[$task_name];
|
304 |
if (@count($setting['task_args']['account_info'])) {
|
305 |
-
|
306 |
-
|
307 |
-
$
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
/*$nonce = substr(wp_hash(wp_nonce_tick() . 'mmb-backup-nonce' . 0, 'nonce'), -12, 10);
|
313 |
-
$cron_url = site_url('index.php');
|
314 |
$args = array(
|
315 |
'body' => array(
|
316 |
'backup_cron_action' => 'mmb_remote_upload',
|
317 |
'args' => json_encode(array('task_name' => $task_name, 'backup_file' => $backup_file, 'del_host_file' => $del_host_file)),
|
318 |
'mmb_backup_nonce' => $nonce,
|
|
|
319 |
),
|
320 |
'timeout' => 0.01,
|
321 |
'blocking' => false,
|
322 |
'sslverify' => apply_filters('https_local_ssl_verify', true)
|
323 |
);
|
324 |
-
wp_remote_post($cron_url, $args)
|
325 |
}
|
326 |
}
|
327 |
|
@@ -378,8 +378,8 @@ class MMB_Backup extends MMB_Core {
|
|
378 |
* All backups are compressed by zip and placed in wp-content/managewp/backups folder.
|
379 |
*
|
380 |
* @param string $args arguments passed from master
|
381 |
-
* [type] -> db, full
|
382 |
-
* [what] -> daily, weekly, monthly
|
383 |
* [account_info] -> remote destinations ftp, amazons3, dropbox, google_drive, email with their parameters
|
384 |
* [include] -> array of folders from site root which are included to backup (wp-admin, wp-content, wp-includes are default)
|
385 |
* [exclude] -> array of files of folders to exclude, relative to site's root
|
@@ -535,7 +535,7 @@ class MMB_Backup extends MMB_Core {
|
|
535 |
|
536 |
// If there are not remote destination, set up task status to finished
|
537 |
if (@count($backup_settings[$task_name]['task_args']['account_info']) == 0) {
|
538 |
-
$this->update_status($task_name
|
539 |
}
|
540 |
|
541 |
return true;
|
@@ -734,6 +734,7 @@ class MMB_Backup extends MMB_Core {
|
|
734 |
|
735 |
$exclude_file_data = '';
|
736 |
|
|
|
737 |
if (!empty($exclude)) {
|
738 |
foreach ($exclude as $data) {
|
739 |
if (is_dir(ABSPATH . $data)) {
|
@@ -1065,15 +1066,17 @@ class MMB_Backup extends MMB_Core {
|
|
1065 |
* @param string $file absolute path to file in which dump should be placed
|
1066 |
* @return string|array path to dump file if successful, or an array with error message if is failed
|
1067 |
*/
|
1068 |
-
|
1069 |
global $wpdb;
|
1070 |
$tables = $wpdb->get_results('SHOW TABLES', ARRAY_N);
|
1071 |
foreach ($tables as $table) {
|
1072 |
//drop existing table
|
1073 |
$dump_data = "DROP TABLE IF EXISTS $table[0];";
|
|
|
1074 |
//create table
|
1075 |
$create_table = $wpdb->get_row("SHOW CREATE TABLE $table[0]", ARRAY_N);
|
1076 |
-
$dump_data
|
|
|
1077 |
|
1078 |
$count = $wpdb->get_var("SELECT count(*) FROM $table[0]");
|
1079 |
if ($count > 100)
|
@@ -1088,7 +1091,7 @@ class MMB_Backup extends MMB_Core {
|
|
1088 |
if (is_array($rows)) {
|
1089 |
foreach ($rows as $row) {
|
1090 |
//insert single row
|
1091 |
-
$dump_data
|
1092 |
$num_values = count($row);
|
1093 |
$j = 1;
|
1094 |
foreach ($row as $value) {
|
@@ -1099,13 +1102,14 @@ class MMB_Backup extends MMB_Core {
|
|
1099 |
unset($value);
|
1100 |
}
|
1101 |
$dump_data .= ");\n";
|
|
|
1102 |
}
|
1103 |
}
|
1104 |
}
|
1105 |
-
$dump_data
|
|
|
1106 |
|
1107 |
unset($rows);
|
1108 |
-
file_put_contents($file, $dump_data, FILE_APPEND);
|
1109 |
unset($dump_data);
|
1110 |
}
|
1111 |
|
@@ -1314,42 +1318,44 @@ class MMB_Backup extends MMB_Core {
|
|
1314 |
|
1315 |
//Replace options
|
1316 |
$query = "SELECT option_value FROM " . $new_table_prefix . "options WHERE option_name = 'home'";
|
1317 |
-
$old = $wpdb->get_var($
|
1318 |
$old = rtrim($old, "/");
|
1319 |
-
$query = "UPDATE " . $new_table_prefix . "options SET option_value =
|
1320 |
-
$wpdb->query($wpdb->prepare($query));
|
1321 |
-
$query = "UPDATE " . $new_table_prefix . "options SET option_value =
|
1322 |
-
$wpdb->query($wpdb->prepare($query));
|
1323 |
//Replace content urls
|
1324 |
-
$
|
1325 |
-
$
|
|
|
|
|
1326 |
|
1327 |
if (trim($new_password)) {
|
1328 |
$new_password = wp_hash_password($new_password);
|
1329 |
}
|
1330 |
if (!trim($clone_from_url) && !trim($mwp_clone)) {
|
1331 |
if ($new_user && $new_password) {
|
1332 |
-
$query = "UPDATE " . $new_table_prefix . "users SET user_login =
|
1333 |
-
$wpdb->query($wpdb->prepare($query));
|
1334 |
}
|
1335 |
} else {
|
1336 |
if ($clone_from_url) {
|
1337 |
if ($new_user && $new_password) {
|
1338 |
-
$query = "UPDATE " . $new_table_prefix . "users SET user_pass =
|
1339 |
-
$wpdb->query($wpdb->prepare($query));
|
1340 |
}
|
1341 |
}
|
1342 |
|
1343 |
if ($mwp_clone) {
|
1344 |
if ($admin_email) {
|
1345 |
//Clean Install
|
1346 |
-
$query = "UPDATE " . $new_table_prefix . "options SET option_value =
|
1347 |
-
$wpdb->query($wpdb->prepare($query));
|
1348 |
$query = "SELECT * FROM " . $new_table_prefix . "users LIMIT 1";
|
1349 |
$temp_user = $wpdb->get_row($query);
|
1350 |
if (!empty($temp_user)) {
|
1351 |
-
$query = "UPDATE " . $new_table_prefix . "users SET user_email
|
1352 |
-
$wpdb->query($wpdb->prepare($query));
|
1353 |
}
|
1354 |
|
1355 |
}
|
@@ -1359,14 +1365,14 @@ class MMB_Backup extends MMB_Core {
|
|
1359 |
if (is_array($clone_options) && !empty($clone_options)) {
|
1360 |
foreach ($clone_options as $key => $option) {
|
1361 |
if (!empty($key)) {
|
1362 |
-
$query = "SELECT option_value FROM " . $new_table_prefix . "options WHERE option_name =
|
1363 |
-
$res = $wpdb->get_var($query);
|
1364 |
if ($res == false) {
|
1365 |
-
$query = "INSERT INTO " . $new_table_prefix . "options (option_value,option_name) VALUES(
|
1366 |
-
$wpdb->query($wpdb->prepare($query));
|
1367 |
} else {
|
1368 |
-
$query = "UPDATE " . $new_table_prefix . "options SET option_value =
|
1369 |
-
$wpdb->query($wpdb->prepare($query));
|
1370 |
}
|
1371 |
}
|
1372 |
}
|
@@ -1374,7 +1380,7 @@ class MMB_Backup extends MMB_Core {
|
|
1374 |
|
1375 |
//Remove hit count
|
1376 |
$query = "DELETE FROM " . $new_table_prefix . "options WHERE option_name = 'user_hit_count'";
|
1377 |
-
$wpdb->query($
|
1378 |
|
1379 |
//Check for .htaccess permalinks update
|
1380 |
$this->replace_htaccess($home);
|
@@ -1382,7 +1388,7 @@ class MMB_Backup extends MMB_Core {
|
|
1382 |
//restore worker options
|
1383 |
if (is_array($restore_options) && !empty($restore_options)) {
|
1384 |
foreach ($restore_options as $key => $option) {
|
1385 |
-
update_option($key
|
1386 |
}
|
1387 |
}
|
1388 |
}
|
@@ -1486,7 +1492,7 @@ class MMB_Backup extends MMB_Core {
|
|
1486 |
function optimize_tables() {
|
1487 |
global $wpdb;
|
1488 |
$query = 'SHOW TABLES';
|
1489 |
-
$tables = $wpdb->get_results($
|
1490 |
foreach ($tables as $table) {
|
1491 |
if (in_array($table['Engine'], array(
|
1492 |
'MyISAM',
|
@@ -1776,6 +1782,9 @@ class MMB_Backup extends MMB_Core {
|
|
1776 |
* [ftp_hostname] -> ftp hostname of remote host
|
1777 |
* [ftp_remote_folder] -> folder on remote site which backup file should be upload to
|
1778 |
* [ftp_site_folder] -> subfolder with site name in ftp_remote_folder which backup file should be upload to
|
|
|
|
|
|
|
1779 |
* [backup_file] -> absolute path of backup file on local server
|
1780 |
* @return bool|array true is successful, array with error message if not
|
1781 |
*/
|
@@ -1786,6 +1795,12 @@ class MMB_Backup extends MMB_Core {
|
|
1786 |
if ($ftp_ssl) {
|
1787 |
if (function_exists('ftp_ssl_connect')) {
|
1788 |
$conn_id = ftp_ssl_connect($ftp_hostname,$port);
|
|
|
|
|
|
|
|
|
|
|
|
|
1789 |
} else {
|
1790 |
return array(
|
1791 |
'error' => 'FTPS disabled: Please enable ftp_ssl_connect in PHP',
|
@@ -1827,10 +1842,11 @@ class MMB_Backup extends MMB_Core {
|
|
1827 |
@ftp_mkdir($conn_id, $ftp_remote_folder);
|
1828 |
|
1829 |
$upload = @ftp_put($conn_id, $ftp_remote_folder . '/' . basename($backup_file), $backup_file, FTP_BINARY);
|
|
|
1830 |
if ($upload === false) { //Try ascii
|
1831 |
$upload = @ftp_put($conn_id, $ftp_remote_folder . '/' . basename($backup_file), $backup_file, FTP_ASCII);
|
1832 |
}
|
1833 |
-
ftp_close($conn_id);
|
1834 |
|
1835 |
if ($upload === false) {
|
1836 |
return array(
|
@@ -2078,8 +2094,7 @@ class MMB_Backup extends MMB_Core {
|
|
2078 |
if ($s3->putObjectFile($backup_file, $as3_bucket, $as3_directory . '/' . basename($backup_file), mwpS3::ACL_PRIVATE)) {
|
2079 |
return true;
|
2080 |
} else {
|
2081 |
-
|
2082 |
-
return array(
|
2083 |
'error' => 'Failed to upload to Amazon S3. Please check your details and set upload/delete permissions on your bucket.',
|
2084 |
'partial' => 1
|
2085 |
);
|
@@ -2834,15 +2849,19 @@ class MMB_Backup extends MMB_Core {
|
|
2834 |
|
2835 |
//clean_old folder?
|
2836 |
if ((isset($files[0]) && basename($files[0]) == 'index.php' && count($files) == 1) || (empty($files))) {
|
2837 |
-
|
2838 |
-
|
|
|
|
|
2839 |
}
|
2840 |
@rmdir(WP_CONTENT_DIR . '/' . md5('mmb-worker') . '/mwp_backups');
|
2841 |
@rmdir(WP_CONTENT_DIR . '/' . md5('mmb-worker'));
|
2842 |
}
|
2843 |
|
2844 |
-
|
2845 |
-
|
|
|
|
|
2846 |
}
|
2847 |
$deleted = array();
|
2848 |
|
@@ -2904,9 +2923,11 @@ class MMB_Backup extends MMB_Core {
|
|
2904 |
$this->update_status($task_name, $this->statuses['ftp']);
|
2905 |
$account_info['mwp_ftp']['backup_file'] = $backup_file;
|
2906 |
$return = $this->ftp_backup($account_info['mwp_ftp']);
|
|
|
|
|
2907 |
if (!(is_array($return) && isset($return['error']))) {
|
2908 |
$this->update_status($task_name, $this->statuses['ftp'], true);
|
2909 |
-
$this->update_status($task_name
|
2910 |
}
|
2911 |
}
|
2912 |
|
@@ -2914,9 +2935,11 @@ class MMB_Backup extends MMB_Core {
|
|
2914 |
$this->update_status($task_name, $this->statuses['s3']);
|
2915 |
$account_info['mwp_amazon_s3']['backup_file'] = $backup_file;
|
2916 |
$return = $this->amazons3_backup($account_info['mwp_amazon_s3']);
|
|
|
|
|
2917 |
if (!(is_array($return) && isset($return['error']))) {
|
2918 |
$this->update_status($task_name, $this->statuses['s3'], true);
|
2919 |
-
$this->update_status($task_name
|
2920 |
}
|
2921 |
}
|
2922 |
|
@@ -2924,19 +2947,24 @@ class MMB_Backup extends MMB_Core {
|
|
2924 |
$this->update_status($task_name, $this->statuses['dropbox']);
|
2925 |
$account_info['mwp_dropbox']['backup_file'] = $backup_file;
|
2926 |
$return = $this->dropbox_backup($account_info['mwp_dropbox']);
|
|
|
|
|
2927 |
if (!(is_array($return) && isset($return['error']))) {
|
2928 |
$this->update_status($task_name, $this->statuses['dropbox'], true);
|
2929 |
-
$this->update_status($task_name
|
2930 |
}
|
2931 |
}
|
2932 |
|
2933 |
if (isset($account_info['mwp_email']) && !empty($account_info['mwp_email'])) {
|
2934 |
$this->update_status($task_name, $this->statuses['email']);
|
|
|
2935 |
$account_info['mwp_email']['file_path'] = $backup_file;
|
2936 |
$return = $this->email_backup($account_info['mwp_email']);
|
|
|
|
|
2937 |
if (!(is_array($return) && isset($return['error']))) {
|
2938 |
$this->update_status($task_name, $this->statuses['email'], true);
|
2939 |
-
$this->update_status($task_name
|
2940 |
}
|
2941 |
}
|
2942 |
|
@@ -2944,9 +2972,11 @@ class MMB_Backup extends MMB_Core {
|
|
2944 |
$this->update_status($task_name, $this->statuses['google_drive']);
|
2945 |
$account_info['mwp_google_drive']['backup_file'] = $backup_file;
|
2946 |
$return = $this->google_drive_backup($account_info['mwp_google_drive']);
|
|
|
|
|
2947 |
if (!(is_array($return) && isset($return['error']))) {
|
2948 |
$this->update_status($task_name, $this->statuses['google_drive'], true);
|
2949 |
-
$this->update_status($task_name
|
2950 |
}
|
2951 |
}
|
2952 |
|
@@ -2992,9 +3022,10 @@ class MMB_Backup extends MMB_Core {
|
|
2992 |
if (is_array($result) && $result['body'] == 'mwp_delete_task') {
|
2993 |
//$tasks = $this->get_backup_settings();
|
2994 |
$tasks = $this->tasks;
|
|
|
2995 |
$this->update_tasks($tasks);
|
2996 |
$this->cleanup();
|
2997 |
-
|
2998 |
} elseif(is_array($result) && $result['body'] == 'mwp_pause_task'){
|
2999 |
return 'paused';
|
3000 |
} elseif(is_array($result) && substr($result['body'], 0, 8) == 'token - '){
|
@@ -3005,9 +3036,10 @@ class MMB_Backup extends MMB_Core {
|
|
3005 |
$response = unserialize($result['body']);
|
3006 |
if ($response['message'] == 'mwp_delete_task') {
|
3007 |
$tasks = $this->tasks;
|
|
|
3008 |
$this->update_tasks($tasks);
|
3009 |
$this->cleanup();
|
3010 |
-
|
3011 |
} elseif ($response['message'] == 'mwp_pause_task') {
|
3012 |
return 'paused';
|
3013 |
} elseif ($response['message'] == 'mwp_do_task') {
|
@@ -3116,12 +3148,12 @@ class MMB_Backup extends MMB_Core {
|
|
3116 |
}
|
3117 |
|
3118 |
/**
|
3119 |
-
*
|
3120 |
*
|
3121 |
* @param array $params arguments passed to function
|
3122 |
* @return array $params without backups
|
3123 |
*/
|
3124 |
-
public
|
3125 |
global $mmb_core;
|
3126 |
|
3127 |
if( empty($params) || !isset($params['backups']) )
|
@@ -3169,101 +3201,11 @@ class MMB_Backup extends MMB_Core {
|
|
3169 |
return $params;
|
3170 |
}
|
3171 |
|
3172 |
-
/**
|
3173 |
-
* Upload to remote destination in the second step for scheduled backup run by cron.
|
3174 |
-
*
|
3175 |
-
* @param string $task_name name of backup task
|
3176 |
-
* @param string $backup_file absolute path of local backup archive
|
3177 |
-
* @param bool $del_host_file should be deleted local backup archive or not
|
3178 |
-
* @return void
|
3179 |
-
*/
|
3180 |
-
function remote_upload($task_name, $backup_file, $del_host_file) {
|
3181 |
-
$this->set_memory();
|
3182 |
-
|
3183 |
-
$tasks = $this->tasks;
|
3184 |
-
$task = $tasks[$task_name];
|
3185 |
-
|
3186 |
-
if (!empty($task)) {
|
3187 |
-
extract($task['task_args']);
|
3188 |
-
}
|
3189 |
-
|
3190 |
-
if (isset($account_info['mwp_ftp']) && !empty($account_info['mwp_ftp'])) {
|
3191 |
-
$this->update_status($task_name, $this->statuses['ftp']);
|
3192 |
-
$account_info['mwp_ftp']['backup_file'] = $backup_file;
|
3193 |
-
$ftp_result = $this->ftp_backup($account_info['mwp_ftp']);
|
3194 |
-
if ($ftp_result !== true && $del_host_file) {
|
3195 |
-
@unlink($backup_file);
|
3196 |
-
}
|
3197 |
-
if (!(is_array($ftp_result) && isset($ftp_result['error']))) {
|
3198 |
-
$this->update_status($task_name, $this->statuses['ftp'], true);
|
3199 |
-
$this->update_status($task_name,$this->statuses['finished'], true);
|
3200 |
-
}
|
3201 |
-
}
|
3202 |
-
|
3203 |
-
if (isset($account_info['mwp_amazon_s3']) && !empty($account_info['mwp_amazon_s3'])) {
|
3204 |
-
$this->update_status($task_name, $this->statuses['s3']);
|
3205 |
-
$account_info['mwp_amazon_s3']['backup_file'] = $backup_file;
|
3206 |
-
$amazons3_result = $this->amazons3_backup($account_info['mwp_amazon_s3']);
|
3207 |
-
if ($amazons3_result !== true && $del_host_file) {
|
3208 |
-
@unlink($backup_file);
|
3209 |
-
}
|
3210 |
-
if (!(is_array($amazons3_result) && isset($amazons3_result['error']))) {
|
3211 |
-
$this->update_status($task_name, $this->statuses['s3'], true);
|
3212 |
-
$this->update_status($task_name,$this->statuses['finished'], true);
|
3213 |
-
}
|
3214 |
-
}
|
3215 |
-
|
3216 |
-
if (isset($account_info['mwp_dropbox']) && !empty($account_info['mwp_dropbox'])) {
|
3217 |
-
$this->update_status($task_name, $this->statuses['dropbox']);
|
3218 |
-
$account_info['mwp_dropbox']['backup_file'] = $backup_file;
|
3219 |
-
$dropbox_result = $this->dropbox_backup($account_info['mwp_dropbox']);
|
3220 |
-
if ($dropbox_result !== true && $del_host_file) {
|
3221 |
-
@unlink($backup_file);
|
3222 |
-
}
|
3223 |
-
if (!(is_array($dropbox_result) && isset($dropbox_result['error']))) {
|
3224 |
-
$this->update_status($task_name, $this->statuses['dropbox'], true);
|
3225 |
-
$this->update_status($task_name,$this->statuses['finished'], true);
|
3226 |
-
}
|
3227 |
-
}
|
3228 |
-
|
3229 |
-
if (isset($account_info['mwp_email']) && !empty($account_info['mwp_email'])) {
|
3230 |
-
$this->update_status($task_name, $this->statuses['email']);
|
3231 |
-
$account_info['mwp_email']['task_name'] = $task_name;
|
3232 |
-
$account_info['mwp_email']['file_path'] = $backup_file;
|
3233 |
-
$email_result = $this->email_backup($account_info['mwp_email']);
|
3234 |
-
if (!(is_array($email_result) && isset($email_result['error']))) {
|
3235 |
-
$this->update_status($task_name, $this->statuses['email'], true);
|
3236 |
-
$this->update_status($task_name,$this->statuses['finished'], true);
|
3237 |
-
}
|
3238 |
-
}
|
3239 |
-
|
3240 |
-
if (isset($account_info['mwp_google_drive']) && !empty($account_info['mwp_google_drive'])) {
|
3241 |
-
$this->update_status($task_name, $this->statuses['google_drive']);
|
3242 |
-
$account_info['mwp_google_drive']['backup_file'] = $backup_file;
|
3243 |
-
$google_drive_result = $this->google_drive_backup($account_info['mwp_google_drive']);
|
3244 |
-
if ($google_drive_result !== true && $del_host_file) {
|
3245 |
-
@unlink($backup_file);
|
3246 |
-
}
|
3247 |
-
if (!(is_array($google_drive_result) && isset($google_drive_result['error']))) {
|
3248 |
-
$this->update_status($task_name, $this->statuses['google_drive'], true);
|
3249 |
-
$this->update_status($task_name,$this->statuses['finished'], true);
|
3250 |
-
}
|
3251 |
-
}
|
3252 |
-
|
3253 |
-
$tasks = $this->tasks;
|
3254 |
-
@file_put_contents(MWP_BACKUP_DIR.'/mwp_db/index.php', '');
|
3255 |
-
if ($del_host_file) {
|
3256 |
-
@unlink($backup_file);
|
3257 |
-
unset($tasks[$task_name]['task_results'][count($tasks[$task_name]['task_results']) - 1]['server']);
|
3258 |
-
}
|
3259 |
-
$this->update_tasks($tasks);
|
3260 |
-
}
|
3261 |
-
|
3262 |
}
|
3263 |
|
3264 |
-
if( function_exists('add_filter') ) {
|
3265 |
add_filter( 'mwp_website_add', 'MMB_Backup::readd_tasks' );
|
3266 |
-
}
|
3267 |
|
3268 |
if(!function_exists('get_all_files_from_dir')) {
|
3269 |
/**
|
@@ -3317,4 +3259,5 @@ if (!function_exists('get_all_files_from_dir_recursive')) {
|
|
3317 |
@closedir($dh);
|
3318 |
}
|
3319 |
}
|
|
|
3320 |
?>
|
198 |
}
|
199 |
}
|
200 |
|
201 |
+
if (isset($time) && $time) { //set next result time before backup
|
202 |
if (is_array($before[$task_name]['task_results'])) {
|
203 |
$before[$task_name]['task_results'] = array_values($before[$task_name]['task_results']);
|
204 |
}
|
237 |
$settings = $this->tasks;
|
238 |
if (is_array($settings) && !empty($settings)) {
|
239 |
foreach ($settings as $task_name => $setting) {
|
240 |
+
if (isset($setting['task_args']['next']) && $setting['task_args']['next'] < time()) {
|
241 |
//if ($setting['task_args']['next'] && $_GET['force_backup']) {
|
242 |
if ($setting['task_args']['url'] && $setting['task_args']['task_id'] && $setting['task_args']['site_key']) {
|
243 |
//Check orphan task
|
253 |
}
|
254 |
|
255 |
$check = $this->validate_task($check_data, $setting['task_args']['url']);
|
256 |
+
if($check == 'paused' || $check == 'deleted'){
|
257 |
+
continue;
|
258 |
+
}
|
259 |
$worker_upto_3_9_22 = (MMB_WORKER_VERSION <= '3.9.22'); // worker version is less or equals to 3.9.22
|
260 |
|
261 |
+
// This is the patch done in worker 3.9.22 because old worked provided message in the following format:
|
262 |
+
// token - not found or token - {...json...}
|
263 |
+
// The new message is a serialized string with google_drive_token or message.
|
264 |
if ($worker_upto_3_9_22) {
|
265 |
$potential_token = substr($check, 8);
|
266 |
if (substr($check, 0, 8) == 'token - ' && $potential_token != 'not found') {
|
284 |
'args' => $settings[$task_name]['task_args']
|
285 |
);
|
286 |
|
287 |
+
if ($check != 'paused') {
|
288 |
$update['time'] = time();
|
289 |
}
|
290 |
|
291 |
//Update task with next schedule
|
292 |
$this->set_backup_task($update);
|
293 |
|
|
|
|
|
|
|
|
|
294 |
$result = $this->backup($setting['task_args'], $task_name);
|
295 |
$error = '';
|
296 |
|
302 |
'error' => $error
|
303 |
));
|
304 |
} else {
|
|
|
305 |
if (@count($setting['task_args']['account_info'])) {
|
306 |
+
// Old way through sheduling.
|
307 |
+
// wp_schedule_single_event(time(), 'mmb_scheduled_remote_upload', array('args' => array('task_name' => $task_name)));
|
308 |
+
$nonce = substr(wp_hash(wp_nonce_tick() . 'mmb-backup-nonce' . 0, 'nonce'), -12, 10);
|
309 |
+
$cron_url = site_url('index.php');
|
310 |
+
$backup_file = $this->tasks[$task_name]['task_results'][count($this->tasks[$task_name]['task_results']) - 1]['server']['file_url'];
|
311 |
+
$del_host_file = $this->tasks[$task_name]['task_args']['del_host_file'];
|
312 |
+
$public_key = get_option('_worker_public_key');
|
|
|
|
|
313 |
$args = array(
|
314 |
'body' => array(
|
315 |
'backup_cron_action' => 'mmb_remote_upload',
|
316 |
'args' => json_encode(array('task_name' => $task_name, 'backup_file' => $backup_file, 'del_host_file' => $del_host_file)),
|
317 |
'mmb_backup_nonce' => $nonce,
|
318 |
+
'public_key' => $public_key,
|
319 |
),
|
320 |
'timeout' => 0.01,
|
321 |
'blocking' => false,
|
322 |
'sslverify' => apply_filters('https_local_ssl_verify', true)
|
323 |
);
|
324 |
+
wp_remote_post($cron_url, $args);
|
325 |
}
|
326 |
}
|
327 |
|
378 |
* All backups are compressed by zip and placed in wp-content/managewp/backups folder.
|
379 |
*
|
380 |
* @param string $args arguments passed from master
|
381 |
+
* [type] -> db, full
|
382 |
+
* [what] -> daily, weekly, monthly
|
383 |
* [account_info] -> remote destinations ftp, amazons3, dropbox, google_drive, email with their parameters
|
384 |
* [include] -> array of folders from site root which are included to backup (wp-admin, wp-content, wp-includes are default)
|
385 |
* [exclude] -> array of files of folders to exclude, relative to site's root
|
535 |
|
536 |
// If there are not remote destination, set up task status to finished
|
537 |
if (@count($backup_settings[$task_name]['task_args']['account_info']) == 0) {
|
538 |
+
$this->update_status($task_name, $this->statuses['finished'], true);
|
539 |
}
|
540 |
|
541 |
return true;
|
734 |
|
735 |
$exclude_file_data = '';
|
736 |
|
737 |
+
// TODO: Prevent to $exclude include blank string '', beacuse zip 12 error will be occured.
|
738 |
if (!empty($exclude)) {
|
739 |
foreach ($exclude as $data) {
|
740 |
if (is_dir(ABSPATH . $data)) {
|
1066 |
* @param string $file absolute path to file in which dump should be placed
|
1067 |
* @return string|array path to dump file if successful, or an array with error message if is failed
|
1068 |
*/
|
1069 |
+
function backup_db_php($file) {
|
1070 |
global $wpdb;
|
1071 |
$tables = $wpdb->get_results('SHOW TABLES', ARRAY_N);
|
1072 |
foreach ($tables as $table) {
|
1073 |
//drop existing table
|
1074 |
$dump_data = "DROP TABLE IF EXISTS $table[0];";
|
1075 |
+
file_put_contents($file, $dump_data, FILE_APPEND);
|
1076 |
//create table
|
1077 |
$create_table = $wpdb->get_row("SHOW CREATE TABLE $table[0]", ARRAY_N);
|
1078 |
+
$dump_data = "\n\n" . $create_table[1] . ";\n\n";
|
1079 |
+
file_put_contents($file, $dump_data, FILE_APPEND);
|
1080 |
|
1081 |
$count = $wpdb->get_var("SELECT count(*) FROM $table[0]");
|
1082 |
if ($count > 100)
|
1091 |
if (is_array($rows)) {
|
1092 |
foreach ($rows as $row) {
|
1093 |
//insert single row
|
1094 |
+
$dump_data = "INSERT INTO $table[0] VALUES(";
|
1095 |
$num_values = count($row);
|
1096 |
$j = 1;
|
1097 |
foreach ($row as $value) {
|
1102 |
unset($value);
|
1103 |
}
|
1104 |
$dump_data .= ");\n";
|
1105 |
+
file_put_contents($file, $dump_data, FILE_APPEND);
|
1106 |
}
|
1107 |
}
|
1108 |
}
|
1109 |
+
$dump_data = "\n\n\n";
|
1110 |
+
file_put_contents($file, $dump_data, FILE_APPEND);
|
1111 |
|
1112 |
unset($rows);
|
|
|
1113 |
unset($dump_data);
|
1114 |
}
|
1115 |
|
1318 |
|
1319 |
//Replace options
|
1320 |
$query = "SELECT option_value FROM " . $new_table_prefix . "options WHERE option_name = 'home'";
|
1321 |
+
$old = $wpdb->get_var($query);
|
1322 |
$old = rtrim($old, "/");
|
1323 |
+
$query = "UPDATE " . $new_table_prefix . "options SET option_value = %s WHERE option_name = 'home'";
|
1324 |
+
$wpdb->query($wpdb->prepare($query, $home));
|
1325 |
+
$query = "UPDATE " . $new_table_prefix . "options SET option_value = %s WHERE option_name = 'siteurl'";
|
1326 |
+
$wpdb->query($wpdb->prepare($query, $home));
|
1327 |
//Replace content urls
|
1328 |
+
$regexp1 = 'src="(.*)$old(.*)"';
|
1329 |
+
$regexp2 = 'href="(.*)$old(.*)"';
|
1330 |
+
$query = "UPDATE " . $new_table_prefix . "posts SET post_content = REPLACE (post_content, %s,%s) WHERE post_content REGEXP %s OR post_content REGEXP %s";
|
1331 |
+
$wpdb->query($wpdb->prepare($query, array($old, $home, $regexp1, $regexp2)));
|
1332 |
|
1333 |
if (trim($new_password)) {
|
1334 |
$new_password = wp_hash_password($new_password);
|
1335 |
}
|
1336 |
if (!trim($clone_from_url) && !trim($mwp_clone)) {
|
1337 |
if ($new_user && $new_password) {
|
1338 |
+
$query = "UPDATE " . $new_table_prefix . "users SET user_login = %s, user_pass = %s WHERE user_login = %s";
|
1339 |
+
$wpdb->query($wpdb->prepare($query, $new_user, $new_password, $old_user));
|
1340 |
}
|
1341 |
} else {
|
1342 |
if ($clone_from_url) {
|
1343 |
if ($new_user && $new_password) {
|
1344 |
+
$query = "UPDATE " . $new_table_prefix . "users SET user_pass = %s WHERE user_login = %s";
|
1345 |
+
$wpdb->query($wpdb->prepare($query, $new_password, $new_user));
|
1346 |
}
|
1347 |
}
|
1348 |
|
1349 |
if ($mwp_clone) {
|
1350 |
if ($admin_email) {
|
1351 |
//Clean Install
|
1352 |
+
$query = "UPDATE " . $new_table_prefix . "options SET option_value = %s WHERE option_name = 'admin_email'";
|
1353 |
+
$wpdb->query($wpdb->prepare($query, $admin_email));
|
1354 |
$query = "SELECT * FROM " . $new_table_prefix . "users LIMIT 1";
|
1355 |
$temp_user = $wpdb->get_row($query);
|
1356 |
if (!empty($temp_user)) {
|
1357 |
+
$query = "UPDATE " . $new_table_prefix . "users SET user_email=%s, user_login = %s, user_pass = %s WHERE user_login = %s";
|
1358 |
+
$wpdb->query($wpdb->prepare($query, $admin_email, $new_user, $new_password, $temp_user->user_login));
|
1359 |
}
|
1360 |
|
1361 |
}
|
1365 |
if (is_array($clone_options) && !empty($clone_options)) {
|
1366 |
foreach ($clone_options as $key => $option) {
|
1367 |
if (!empty($key)) {
|
1368 |
+
$query = "SELECT option_value FROM " . $new_table_prefix . "options WHERE option_name = %s";
|
1369 |
+
$res = $wpdb->get_var($wpdb->prepare($query, $key));
|
1370 |
if ($res == false) {
|
1371 |
+
$query = "INSERT INTO " . $new_table_prefix . "options (option_value,option_name) VALUES(%s,%s)";
|
1372 |
+
$wpdb->query($wpdb->prepare($query, $option, $key));
|
1373 |
} else {
|
1374 |
+
$query = "UPDATE " . $new_table_prefix . "options SET option_value = %s WHERE option_name = %s";
|
1375 |
+
$wpdb->query($wpdb->prepare($query, $option, $key));
|
1376 |
}
|
1377 |
}
|
1378 |
}
|
1380 |
|
1381 |
//Remove hit count
|
1382 |
$query = "DELETE FROM " . $new_table_prefix . "options WHERE option_name = 'user_hit_count'";
|
1383 |
+
$wpdb->query($query);
|
1384 |
|
1385 |
//Check for .htaccess permalinks update
|
1386 |
$this->replace_htaccess($home);
|
1388 |
//restore worker options
|
1389 |
if (is_array($restore_options) && !empty($restore_options)) {
|
1390 |
foreach ($restore_options as $key => $option) {
|
1391 |
+
update_option($key, $option);
|
1392 |
}
|
1393 |
}
|
1394 |
}
|
1492 |
function optimize_tables() {
|
1493 |
global $wpdb;
|
1494 |
$query = 'SHOW TABLES';
|
1495 |
+
$tables = $wpdb->get_results($query, ARRAY_A);
|
1496 |
foreach ($tables as $table) {
|
1497 |
if (in_array($table['Engine'], array(
|
1498 |
'MyISAM',
|
1782 |
* [ftp_hostname] -> ftp hostname of remote host
|
1783 |
* [ftp_remote_folder] -> folder on remote site which backup file should be upload to
|
1784 |
* [ftp_site_folder] -> subfolder with site name in ftp_remote_folder which backup file should be upload to
|
1785 |
+
* [ftp_passive] -> passive mode or not
|
1786 |
+
* [ftp_ssl] -> ssl or not
|
1787 |
+
* [ftp_port] -> number of port for ssl protocol
|
1788 |
* [backup_file] -> absolute path of backup file on local server
|
1789 |
* @return bool|array true is successful, array with error message if not
|
1790 |
*/
|
1795 |
if ($ftp_ssl) {
|
1796 |
if (function_exists('ftp_ssl_connect')) {
|
1797 |
$conn_id = ftp_ssl_connect($ftp_hostname,$port);
|
1798 |
+
if ($conn_id === false) {
|
1799 |
+
return array(
|
1800 |
+
'error' => 'Failed to connect to ' . $ftp_hostname,
|
1801 |
+
'partial' => 1
|
1802 |
+
);
|
1803 |
+
}
|
1804 |
} else {
|
1805 |
return array(
|
1806 |
'error' => 'FTPS disabled: Please enable ftp_ssl_connect in PHP',
|
1842 |
@ftp_mkdir($conn_id, $ftp_remote_folder);
|
1843 |
|
1844 |
$upload = @ftp_put($conn_id, $ftp_remote_folder . '/' . basename($backup_file), $backup_file, FTP_BINARY);
|
1845 |
+
|
1846 |
if ($upload === false) { //Try ascii
|
1847 |
$upload = @ftp_put($conn_id, $ftp_remote_folder . '/' . basename($backup_file), $backup_file, FTP_ASCII);
|
1848 |
}
|
1849 |
+
@ftp_close($conn_id);
|
1850 |
|
1851 |
if ($upload === false) {
|
1852 |
return array(
|
2094 |
if ($s3->putObjectFile($backup_file, $as3_bucket, $as3_directory . '/' . basename($backup_file), mwpS3::ACL_PRIVATE)) {
|
2095 |
return true;
|
2096 |
} else {
|
2097 |
+
return array(
|
|
|
2098 |
'error' => 'Failed to upload to Amazon S3. Please check your details and set upload/delete permissions on your bucket.',
|
2099 |
'partial' => 1
|
2100 |
);
|
2849 |
|
2850 |
//clean_old folder?
|
2851 |
if ((isset($files[0]) && basename($files[0]) == 'index.php' && count($files) == 1) || (empty($files))) {
|
2852 |
+
if (!empty($files)) {
|
2853 |
+
foreach ($files as $file) {
|
2854 |
+
@unlink($file);
|
2855 |
+
}
|
2856 |
}
|
2857 |
@rmdir(WP_CONTENT_DIR . '/' . md5('mmb-worker') . '/mwp_backups');
|
2858 |
@rmdir(WP_CONTENT_DIR . '/' . md5('mmb-worker'));
|
2859 |
}
|
2860 |
|
2861 |
+
if (!empty($new)) {
|
2862 |
+
foreach ($new as $b) {
|
2863 |
+
$files[] = $b;
|
2864 |
+
}
|
2865 |
}
|
2866 |
$deleted = array();
|
2867 |
|
2923 |
$this->update_status($task_name, $this->statuses['ftp']);
|
2924 |
$account_info['mwp_ftp']['backup_file'] = $backup_file;
|
2925 |
$return = $this->ftp_backup($account_info['mwp_ftp']);
|
2926 |
+
$this->wpdb_reconnect();
|
2927 |
+
|
2928 |
if (!(is_array($return) && isset($return['error']))) {
|
2929 |
$this->update_status($task_name, $this->statuses['ftp'], true);
|
2930 |
+
$this->update_status($task_name, $this->statuses['finished'], true);
|
2931 |
}
|
2932 |
}
|
2933 |
|
2935 |
$this->update_status($task_name, $this->statuses['s3']);
|
2936 |
$account_info['mwp_amazon_s3']['backup_file'] = $backup_file;
|
2937 |
$return = $this->amazons3_backup($account_info['mwp_amazon_s3']);
|
2938 |
+
$this->wpdb_reconnect();
|
2939 |
+
|
2940 |
if (!(is_array($return) && isset($return['error']))) {
|
2941 |
$this->update_status($task_name, $this->statuses['s3'], true);
|
2942 |
+
$this->update_status($task_name, $this->statuses['finished'], true);
|
2943 |
}
|
2944 |
}
|
2945 |
|
2947 |
$this->update_status($task_name, $this->statuses['dropbox']);
|
2948 |
$account_info['mwp_dropbox']['backup_file'] = $backup_file;
|
2949 |
$return = $this->dropbox_backup($account_info['mwp_dropbox']);
|
2950 |
+
$this->wpdb_reconnect();
|
2951 |
+
|
2952 |
if (!(is_array($return) && isset($return['error']))) {
|
2953 |
$this->update_status($task_name, $this->statuses['dropbox'], true);
|
2954 |
+
$this->update_status($task_name, $this->statuses['finished'], true);
|
2955 |
}
|
2956 |
}
|
2957 |
|
2958 |
if (isset($account_info['mwp_email']) && !empty($account_info['mwp_email'])) {
|
2959 |
$this->update_status($task_name, $this->statuses['email']);
|
2960 |
+
$account_info['mwp_email']['task_name'] = $task_name;
|
2961 |
$account_info['mwp_email']['file_path'] = $backup_file;
|
2962 |
$return = $this->email_backup($account_info['mwp_email']);
|
2963 |
+
$this->wpdb_reconnect();
|
2964 |
+
|
2965 |
if (!(is_array($return) && isset($return['error']))) {
|
2966 |
$this->update_status($task_name, $this->statuses['email'], true);
|
2967 |
+
$this->update_status($task_name, $this->statuses['finished'], true);
|
2968 |
}
|
2969 |
}
|
2970 |
|
2972 |
$this->update_status($task_name, $this->statuses['google_drive']);
|
2973 |
$account_info['mwp_google_drive']['backup_file'] = $backup_file;
|
2974 |
$return = $this->google_drive_backup($account_info['mwp_google_drive']);
|
2975 |
+
$this->wpdb_reconnect();
|
2976 |
+
|
2977 |
if (!(is_array($return) && isset($return['error']))) {
|
2978 |
$this->update_status($task_name, $this->statuses['google_drive'], true);
|
2979 |
+
$this->update_status($task_name, $this->statuses['finished'], true);
|
2980 |
}
|
2981 |
}
|
2982 |
|
3022 |
if (is_array($result) && $result['body'] == 'mwp_delete_task') {
|
3023 |
//$tasks = $this->get_backup_settings();
|
3024 |
$tasks = $this->tasks;
|
3025 |
+
unset($tasks[$args['task_name']]);
|
3026 |
$this->update_tasks($tasks);
|
3027 |
$this->cleanup();
|
3028 |
+
return 'deleted';
|
3029 |
} elseif(is_array($result) && $result['body'] == 'mwp_pause_task'){
|
3030 |
return 'paused';
|
3031 |
} elseif(is_array($result) && substr($result['body'], 0, 8) == 'token - '){
|
3036 |
$response = unserialize($result['body']);
|
3037 |
if ($response['message'] == 'mwp_delete_task') {
|
3038 |
$tasks = $this->tasks;
|
3039 |
+
unset($tasks[$args['task_name']]);
|
3040 |
$this->update_tasks($tasks);
|
3041 |
$this->cleanup();
|
3042 |
+
return 'deleted';
|
3043 |
} elseif ($response['message'] == 'mwp_pause_task') {
|
3044 |
return 'paused';
|
3045 |
} elseif ($response['message'] == 'mwp_do_task') {
|
3148 |
}
|
3149 |
|
3150 |
/**
|
3151 |
+
* Re-add tasks on website re-add.
|
3152 |
*
|
3153 |
* @param array $params arguments passed to function
|
3154 |
* @return array $params without backups
|
3155 |
*/
|
3156 |
+
public function readd_tasks($params = array()) {
|
3157 |
global $mmb_core;
|
3158 |
|
3159 |
if( empty($params) || !isset($params['backups']) )
|
3201 |
return $params;
|
3202 |
}
|
3203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3204 |
}
|
3205 |
|
3206 |
+
/*if( function_exists('add_filter') ) {
|
3207 |
add_filter( 'mwp_website_add', 'MMB_Backup::readd_tasks' );
|
3208 |
+
}*/
|
3209 |
|
3210 |
if(!function_exists('get_all_files_from_dir')) {
|
3211 |
/**
|
3259 |
@closedir($dh);
|
3260 |
}
|
3261 |
}
|
3262 |
+
|
3263 |
?>
|
comment.class.php
CHANGED
@@ -35,7 +35,7 @@ class MMB_Comment extends MMB_Core
|
|
35 |
elseif ( 'trash' == $status )
|
36 |
$status_sql = 'trash';
|
37 |
$sql = "update ".$wpdb->prefix."comments set comment_approved = '%s' where comment_ID = '%s'";
|
38 |
-
$success = $wpdb->query($wpdb->prepare($sql,
|
39 |
|
40 |
|
41 |
return $success;
|
35 |
elseif ( 'trash' == $status )
|
36 |
$status_sql = 'trash';
|
37 |
$sql = "update ".$wpdb->prefix."comments set comment_approved = '%s' where comment_ID = '%s'";
|
38 |
+
$success = $wpdb->query($wpdb->prepare($sql, $status_sql, $comment_id));
|
39 |
|
40 |
|
41 |
return $success;
|
core.class.php
CHANGED
@@ -145,7 +145,7 @@ class MMB_Core extends MMB_Helper
|
|
145 |
|
146 |
add_action('admin_init', array(&$this,'admin_actions'));
|
147 |
add_action('init', array( &$this, 'mmb_remote_action'), 9999);
|
148 |
-
|
149 |
add_action('setup_theme', 'mmb_parse_request');
|
150 |
add_action('set_auth_cookie', array( &$this, 'mmb_set_auth_cookie'));
|
151 |
add_action('set_logged_in_cookie', array( &$this, 'mmb_set_logged_in_cookie'));
|
@@ -235,7 +235,7 @@ class MMB_Core extends MMB_Helper
|
|
235 |
private function get_parent_blog_option( $option_name = '' )
|
236 |
{
|
237 |
global $wpdb;
|
238 |
-
$option = $wpdb->get_var( $wpdb->prepare( "SELECT `option_value` FROM {$wpdb->base_prefix}options WHERE option_name =
|
239 |
return $option;
|
240 |
}
|
241 |
|
@@ -401,7 +401,7 @@ class MMB_Core extends MMB_Helper
|
|
401 |
|
402 |
//delete plugin options, just in case
|
403 |
if ($this->mmb_multisite != false) {
|
404 |
-
$network_blogs = $wpdb->get_results(
|
405 |
if(!empty($network_blogs)){
|
406 |
if( is_network_admin() ){
|
407 |
update_option('mmb_network_admin_install', 1);
|
@@ -455,7 +455,7 @@ class MMB_Core extends MMB_Helper
|
|
455 |
$_wp_using_ext_object_cache = false;
|
456 |
|
457 |
if ($this->mmb_multisite != false) {
|
458 |
-
$network_blogs = $wpdb->get_col(
|
459 |
if(!empty($network_blogs)){
|
460 |
if( is_network_admin() ){
|
461 |
if( $deactivate ) {
|
145 |
|
146 |
add_action('admin_init', array(&$this,'admin_actions'));
|
147 |
add_action('init', array( &$this, 'mmb_remote_action'), 9999);
|
148 |
+
add_action('setup_theme', 'mmb_run_backup_action', 1);
|
149 |
add_action('setup_theme', 'mmb_parse_request');
|
150 |
add_action('set_auth_cookie', array( &$this, 'mmb_set_auth_cookie'));
|
151 |
add_action('set_logged_in_cookie', array( &$this, 'mmb_set_logged_in_cookie'));
|
235 |
private function get_parent_blog_option( $option_name = '' )
|
236 |
{
|
237 |
global $wpdb;
|
238 |
+
$option = $wpdb->get_var( $wpdb->prepare( "SELECT `option_value` FROM {$wpdb->base_prefix}options WHERE option_name = %s LIMIT 1", $option_name ) );
|
239 |
return $option;
|
240 |
}
|
241 |
|
401 |
|
402 |
//delete plugin options, just in case
|
403 |
if ($this->mmb_multisite != false) {
|
404 |
+
$network_blogs = $wpdb->get_results("select `blog_id`, `site_id` from `{$wpdb->blogs}`");
|
405 |
if(!empty($network_blogs)){
|
406 |
if( is_network_admin() ){
|
407 |
update_option('mmb_network_admin_install', 1);
|
455 |
$_wp_using_ext_object_cache = false;
|
456 |
|
457 |
if ($this->mmb_multisite != false) {
|
458 |
+
$network_blogs = $wpdb->get_col("select `blog_id` from `{$wpdb->blogs}`");
|
459 |
if(!empty($network_blogs)){
|
460 |
if( is_network_admin() ){
|
461 |
if( $deactivate ) {
|
helper.class.php
CHANGED
@@ -230,7 +230,7 @@ class MMB_Helper
|
|
230 |
global $wpdb;
|
231 |
$option_name = '_site_transient_'. $option_name;
|
232 |
|
233 |
-
$result = $wpdb->get_var( $wpdb->prepare("SELECT `meta_value` FROM `{$wpdb->sitemeta}` WHERE meta_key =
|
234 |
$result = maybe_unserialize($result);
|
235 |
return $result;
|
236 |
}
|
@@ -375,7 +375,7 @@ class MMB_Helper
|
|
375 |
);
|
376 |
}
|
377 |
} else if ($this->get_random_signature()) {
|
378 |
-
if (md5($data . $this->get_random_signature())
|
379 |
$message_id = $this->set_worker_message_id($message_id);
|
380 |
return true;
|
381 |
}
|
230 |
global $wpdb;
|
231 |
$option_name = '_site_transient_'. $option_name;
|
232 |
|
233 |
+
$result = $wpdb->get_var( $wpdb->prepare("SELECT `meta_value` FROM `{$wpdb->sitemeta}` WHERE meta_key = %s AND `site_id` = %s", $option_name, $this->mmb_multisite));
|
234 |
$result = maybe_unserialize($result);
|
235 |
return $result;
|
236 |
}
|
375 |
);
|
376 |
}
|
377 |
} else if ($this->get_random_signature()) {
|
378 |
+
if (md5($data . $this->get_random_signature()) === $signature) {
|
379 |
$message_id = $this->set_worker_message_id($message_id);
|
380 |
return true;
|
381 |
}
|
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: ManageWP
|
7 |
-
Version: 3.9.
|
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.
|
26 |
|
27 |
if ( !defined('MMB_XFRAME_COOKIE')){
|
28 |
$siteurl = function_exists( 'get_site_option' ) ? get_site_option( 'siteurl' ) : get_option( 'siteurl' );
|
@@ -247,14 +247,14 @@ if( !function_exists ( 'mmb_add_site' )) {
|
|
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'
|
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);
|
@@ -565,6 +565,7 @@ if( !function_exists ( 'mmb_get_backup_req' )) {
|
|
565 |
}
|
566 |
}
|
567 |
|
|
|
568 |
if( !function_exists ( 'mmb_scheduled_backup' )) {
|
569 |
function mmb_scheduled_backup($params)
|
570 |
{
|
@@ -638,19 +639,34 @@ if( !function_exists ( 'mmb_clean_orphan_backups' )) {
|
|
638 |
}
|
639 |
}
|
640 |
|
641 |
-
|
642 |
-
if
|
643 |
-
|
|
|
|
|
|
|
644 |
if (!$args) return false;
|
645 |
$cron_action = isset($_POST['backup_cron_action']) ? $_POST['backup_cron_action'] : false;
|
646 |
if ($cron_action) {
|
647 |
do_action($cron_action, $args);
|
648 |
}
|
|
|
649 |
unset($_POST['mmb_backup_nonce']);
|
650 |
unset($_POST['args']);
|
651 |
unset($_POST['backup_cron_action']);
|
652 |
return true;
|
653 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
654 |
|
655 |
if( !function_exists ( 'mmb_update_worker_plugin' )) {
|
656 |
function mmb_update_worker_plugin($params)
|
@@ -1082,18 +1098,17 @@ if( !function_exists('mwp_check_backup_tasks') ){
|
|
1082 |
}
|
1083 |
|
1084 |
// Remote upload in the second request.
|
1085 |
-
add_action('mmb_scheduled_remote_upload', 'mmb_call_scheduled_remote_upload');
|
1086 |
-
|
1087 |
|
1088 |
if( !function_exists('mmb_call_scheduled_remote_upload') ){
|
1089 |
function mmb_call_scheduled_remote_upload($args) {
|
1090 |
global $mmb_core, $_wp_using_ext_object_cache;
|
1091 |
$_wp_using_ext_object_cache = false;
|
1092 |
-
extract($args);
|
1093 |
|
1094 |
$mmb_core->get_backup_instance();
|
1095 |
-
if (isset($task_name)
|
1096 |
-
$mmb_core->backup_instance->
|
1097 |
}
|
1098 |
}
|
1099 |
}
|
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 |
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' );
|
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);
|
252 |
}
|
253 |
+
if(isset($brand) && is_array($brand) && !empty($brand)){
|
254 |
+
update_option('mwp_worker_brand', $brand);
|
255 |
}
|
256 |
|
257 |
+
if( isset( $add_settigns ) && is_array($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);
|
565 |
}
|
566 |
}
|
567 |
|
568 |
+
// Fires when Backup Now, or some backup task is saved.
|
569 |
if( !function_exists ( 'mmb_scheduled_backup' )) {
|
570 |
function mmb_scheduled_backup($params)
|
571 |
{
|
639 |
}
|
640 |
}
|
641 |
|
642 |
+
function mmb_run_backup_action() {
|
643 |
+
if(isset($_POST['mmb_backup_nonce']))
|
644 |
+
if (!wp_verify_nonce($_POST['mmb_backup_nonce'], 'mmb-backup-nonce')) return false;
|
645 |
+
$public_key = get_option('_worker_public_key');
|
646 |
+
if (!isset($_POST['public_key']) || $public_key !== $_POST['public_key']) return false;
|
647 |
+
$args = @json_decode(stripslashes($_POST['args']), true);
|
648 |
if (!$args) return false;
|
649 |
$cron_action = isset($_POST['backup_cron_action']) ? $_POST['backup_cron_action'] : false;
|
650 |
if ($cron_action) {
|
651 |
do_action($cron_action, $args);
|
652 |
}
|
653 |
+
//unset($_POST['public_key']);
|
654 |
unset($_POST['mmb_backup_nonce']);
|
655 |
unset($_POST['args']);
|
656 |
unset($_POST['backup_cron_action']);
|
657 |
return true;
|
658 |
+
}
|
659 |
+
|
660 |
+
add_filter( 'mwp_website_add', 'mmb_readd_backup_task' );
|
661 |
+
|
662 |
+
if (!function_exists('mmb_readd_backup_task')) {
|
663 |
+
function mmb_readd_backup_task($params = array()) {
|
664 |
+
global $mmb_core;
|
665 |
+
$backup_instance = $mmb_core->get_backup_instance();
|
666 |
+
$settings = $backup_instance->readd_tasks($params);
|
667 |
+
return $settings;
|
668 |
+
}
|
669 |
+
}
|
670 |
|
671 |
if( !function_exists ( 'mmb_update_worker_plugin' )) {
|
672 |
function mmb_update_worker_plugin($params)
|
1098 |
}
|
1099 |
|
1100 |
// Remote upload in the second request.
|
1101 |
+
// add_action('mmb_scheduled_remote_upload', 'mmb_call_scheduled_remote_upload');
|
1102 |
+
add_action('mmb_remote_upload', 'mmb_call_scheduled_remote_upload');
|
1103 |
|
1104 |
if( !function_exists('mmb_call_scheduled_remote_upload') ){
|
1105 |
function mmb_call_scheduled_remote_upload($args) {
|
1106 |
global $mmb_core, $_wp_using_ext_object_cache;
|
1107 |
$_wp_using_ext_object_cache = false;
|
|
|
1108 |
|
1109 |
$mmb_core->get_backup_instance();
|
1110 |
+
if (isset($args['task_name'])) {
|
1111 |
+
$mmb_core->backup_instance->remote_backup_now($args);
|
1112 |
}
|
1113 |
}
|
1114 |
}
|
plugins/cleanup/cleanup.php
CHANGED
@@ -78,7 +78,7 @@ function mmb_num_revisions($filter)
|
|
78 |
{
|
79 |
global $wpdb;
|
80 |
$sql = "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'revision'";
|
81 |
-
$num_revisions = $wpdb->get_var($
|
82 |
if(isset($filter['num_to_keep']) && !empty($filter['num_to_keep'])){
|
83 |
$num_rev = str_replace("r_","",$filter['num_to_keep']);
|
84 |
if($num_revisions < $num_rev){
|
@@ -94,7 +94,7 @@ function mmb_select_all_revisions()
|
|
94 |
{
|
95 |
global $wpdb;
|
96 |
$sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'revision'";
|
97 |
-
$revisions = $wpdb->get_results($
|
98 |
return $revisions;
|
99 |
}
|
100 |
|
@@ -120,7 +120,7 @@ function mmb_delete_all_revisions($filter)
|
|
120 |
|
121 |
$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'".$where;
|
122 |
|
123 |
-
$revisions = $wpdb->query($
|
124 |
|
125 |
return $revisions;
|
126 |
}
|
@@ -138,11 +138,11 @@ function mmb_handle_overhead($clear = false)
|
|
138 |
$tot_idx = 0;
|
139 |
$tot_all = 0;
|
140 |
$query = 'SHOW TABLES';
|
141 |
-
$tables = $wpdb->get_results($
|
142 |
$total_gain = 0;
|
143 |
$table_string = '';
|
144 |
foreach ($tables as $table) {
|
145 |
-
if (in_array($table['Engine'], array(
|
146 |
'MyISAM',
|
147 |
'ISAM',
|
148 |
'HEAP',
|
@@ -164,7 +164,7 @@ function mmb_handle_overhead($clear = false)
|
|
164 |
$table_string .= $table['Name'] . ",";
|
165 |
}
|
166 |
}
|
167 |
-
} elseif ($table['Engine'] == 'InnoDB') {
|
168 |
//$total_gain += $table['Data_free'] > 100*1024*1024 ? $table['Data_free'] / 1024 : 0;
|
169 |
}
|
170 |
}
|
@@ -192,7 +192,7 @@ function mmb_num_spam_comments()
|
|
192 |
{
|
193 |
global $wpdb;
|
194 |
$sql = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'spam'";
|
195 |
-
$num_spams = $wpdb->get_var($
|
196 |
return $num_spams;
|
197 |
}
|
198 |
|
@@ -203,7 +203,7 @@ function mmb_delete_spam_comments()
|
|
203 |
$total = 0;
|
204 |
while ($spams) {
|
205 |
$sql = "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' LIMIT 200";
|
206 |
-
$spams = $wpdb->query($
|
207 |
$total += $spams;
|
208 |
if ($spams)
|
209 |
usleep(100000);
|
@@ -216,7 +216,7 @@ function mmb_get_spam_comments()
|
|
216 |
{
|
217 |
global $wpdb;
|
218 |
$sql = "SELECT * FROM $wpdb->comments as a LEFT JOIN $wpdb->commentmeta as b WHERE a.comment_ID = b.comment_id AND a.comment_approved = 'spam'";
|
219 |
-
$spams = $wpdb->get_results($
|
220 |
return $spams;
|
221 |
}
|
222 |
?>
|
78 |
{
|
79 |
global $wpdb;
|
80 |
$sql = "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'revision'";
|
81 |
+
$num_revisions = $wpdb->get_var($sql);
|
82 |
if(isset($filter['num_to_keep']) && !empty($filter['num_to_keep'])){
|
83 |
$num_rev = str_replace("r_","",$filter['num_to_keep']);
|
84 |
if($num_revisions < $num_rev){
|
94 |
{
|
95 |
global $wpdb;
|
96 |
$sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'revision'";
|
97 |
+
$revisions = $wpdb->get_results($sql);
|
98 |
return $revisions;
|
99 |
}
|
100 |
|
120 |
|
121 |
$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'".$where;
|
122 |
|
123 |
+
$revisions = $wpdb->query($sql);
|
124 |
|
125 |
return $revisions;
|
126 |
}
|
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 = '';
|
144 |
foreach ($tables as $table) {
|
145 |
+
if (isset($table['Engine']) && in_array($table['Engine'], array(
|
146 |
'MyISAM',
|
147 |
'ISAM',
|
148 |
'HEAP',
|
164 |
$table_string .= $table['Name'] . ",";
|
165 |
}
|
166 |
}
|
167 |
+
} elseif (isset($table['Engine']) && $table['Engine'] == 'InnoDB') {
|
168 |
//$total_gain += $table['Data_free'] > 100*1024*1024 ? $table['Data_free'] / 1024 : 0;
|
169 |
}
|
170 |
}
|
192 |
{
|
193 |
global $wpdb;
|
194 |
$sql = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'spam'";
|
195 |
+
$num_spams = $wpdb->get_var($sql);
|
196 |
return $num_spams;
|
197 |
}
|
198 |
|
203 |
$total = 0;
|
204 |
while ($spams) {
|
205 |
$sql = "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' LIMIT 200";
|
206 |
+
$spams = $wpdb->query($sql);
|
207 |
$total += $spams;
|
208 |
if ($spams)
|
209 |
usleep(100000);
|
216 |
{
|
217 |
global $wpdb;
|
218 |
$sql = "SELECT * FROM $wpdb->comments as a LEFT JOIN $wpdb->commentmeta as b WHERE a.comment_ID = b.comment_id AND a.comment_approved = 'spam'";
|
219 |
+
$spams = $wpdb->get_results($sql);
|
220 |
return $spams;
|
221 |
}
|
222 |
?>
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ 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.
|
7 |
Stable tag: trunk
|
8 |
|
9 |
ManageWP Worker plugin allows you to remotely manage your WordPress sites from one dashboard.
|
@@ -34,6 +34,12 @@ Check out [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs").
|
|
34 |
|
35 |
== Changelog ==
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
= 3.9.23 =
|
38 |
- New: SEO reports can be branded and viewed by sharing an URL
|
39 |
- New: Set custom database prefix for new clone destination
|
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
|
8 |
|
9 |
ManageWP Worker plugin allows you to remotely manage your WordPress sites from one dashboard.
|
34 |
|
35 |
== Changelog ==
|
36 |
|
37 |
+
= 3.9.24 =
|
38 |
+
- New: Better support for large database dumps
|
39 |
+
- Fix: PHP notice for WordPress 3.5
|
40 |
+
- Fix: Support for automatic backup reports
|
41 |
+
- Fix: Incorrect backup result message for S3 large files
|
42 |
+
|
43 |
= 3.9.23 =
|
44 |
- New: SEO reports can be branded and viewed by sharing an URL
|
45 |
- New: Set custom database prefix for new clone destination
|
stats.class.php
CHANGED
@@ -430,7 +430,7 @@ class MMB_Stats extends MMB_Core
|
|
430 |
{
|
431 |
global $current_user, $wpdb;
|
432 |
$user_blogs = get_blogs_of_user( $current_user->ID );
|
433 |
-
$network_blogs = $wpdb->get_results(
|
434 |
if ($this->network_admin_install == '1' && is_super_admin()) {
|
435 |
if (!empty($network_blogs)) {
|
436 |
$blogs = 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();
|
version
CHANGED
@@ -1 +1 @@
|
|
1 |
-
3.9.
|
1 |
+
3.9.24
|