Version Description
- Minor bug fixes
Download this release
Release Info
| Developer | freediver |
| Plugin | |
| Version | 3.9.11 |
| Comparing to | |
| See all releases | |
Code changes from version 3.9.10 to 3.9.11
- backup.class.php +267 -221
- core.class.php +25 -11
- helper.class.php +4 -0
- init.php +19 -7
- lib/s3.php +56 -13
- readme.txt +19 -3
- stats.class.php +169 -101
- version +1 -1
backup.class.php
CHANGED
|
@@ -9,6 +9,8 @@
|
|
| 9 |
* Copyright (c) 2011 Prelovac Media
|
| 10 |
* www.prelovac.com
|
| 11 |
**************************************************************/
|
|
|
|
|
|
|
| 12 |
|
| 13 |
class MMB_Backup extends MMB_Core
|
| 14 |
{
|
|
@@ -16,9 +18,9 @@ class MMB_Backup extends MMB_Core
|
|
| 16 |
var $statuses;
|
| 17 |
|
| 18 |
function __construct()
|
| 19 |
-
{
|
| 20 |
-
|
| 21 |
-
$this->site_name = str_replace("/","-",rtrim($this->remove_http(get_bloginfo('url')),"/"));
|
| 22 |
$this->statuses = array(
|
| 23 |
'db_dump' => 1,
|
| 24 |
'db_zip' => 2,
|
|
@@ -88,6 +90,7 @@ class MMB_Backup extends MMB_Core
|
|
| 88 |
if ($task_name == 'Backup Now') {
|
| 89 |
$result = $this->backup($args, $task_name);
|
| 90 |
$backup_settings = $this->get_backup_settings();
|
|
|
|
| 91 |
if (is_array($result) && array_key_exists('error', $result)) {
|
| 92 |
$return = $result;
|
| 93 |
} else {
|
|
@@ -112,11 +115,10 @@ class MMB_Backup extends MMB_Core
|
|
| 112 |
$check_data = array(
|
| 113 |
'task_name' => $task_name,
|
| 114 |
'task_id' => $setting['task_args']['task_id'],
|
| 115 |
-
'
|
| 116 |
-
'site_key' => $setting['task_args']['site_key'],
|
| 117 |
);
|
| 118 |
|
| 119 |
-
$this->validate_task($check_data);
|
| 120 |
}
|
| 121 |
|
| 122 |
//Update task with next schedule
|
|
@@ -158,20 +160,19 @@ class MMB_Backup extends MMB_Core
|
|
| 158 |
|
| 159 |
function backup($args, $task_name = false)
|
| 160 |
{
|
| 161 |
-
|
| 162 |
if (!$args || empty($args))
|
| 163 |
return false;
|
| 164 |
|
| 165 |
extract($args); //extract settings
|
| 166 |
|
| 167 |
-
//
|
| 168 |
-
@ini_set('memory_limit', '
|
| 169 |
@set_time_limit(600); //ten minutes
|
| 170 |
|
| 171 |
//Remove old backup(s)
|
| 172 |
$this->remove_old_backups($task_name);
|
| 173 |
|
| 174 |
-
$new_file_path =
|
| 175 |
|
| 176 |
if (!file_exists($new_file_path)) {
|
| 177 |
if (!mkdir($new_file_path, 0755, true))
|
|
@@ -182,7 +183,7 @@ class MMB_Backup extends MMB_Core
|
|
| 182 |
|
| 183 |
@file_put_contents($new_file_path . '/index.php', ''); //safe
|
| 184 |
|
| 185 |
-
//Delete possible
|
| 186 |
foreach (glob($new_file_path . "/*.zip") as $filename) {
|
| 187 |
$short = basename($filename);
|
| 188 |
preg_match('/^wp\-content(.*)/Ui', $short, $matches);
|
|
@@ -190,24 +191,15 @@ class MMB_Backup extends MMB_Core
|
|
| 190 |
@unlink($filename);
|
| 191 |
}
|
| 192 |
|
| 193 |
-
//Prepare .zip file name
|
| 194 |
-
$site_name = $this->remove_http(get_bloginfo('url'));
|
| 195 |
-
$site_name = str_replace(array(
|
| 196 |
-
"_",
|
| 197 |
-
"/"
|
| 198 |
-
), array(
|
| 199 |
-
"",
|
| 200 |
-
"-"
|
| 201 |
-
), $site_name);
|
| 202 |
-
|
| 203 |
$hash = md5(time());
|
| 204 |
$label = $type ? $type : 'manual';
|
| 205 |
-
$backup_file = $new_file_path . '/' . $site_name . '_' . $label . '_' . $what . '_' . date('Y-m-d') . '_' . $hash . '.zip';
|
| 206 |
-
$backup_url = WP_CONTENT_URL . '/managewp/backups/' . $site_name . '_' . $label . '_' . $what . '_' . date('Y-m-d') . '_' . $hash . '.zip';
|
| 207 |
|
| 208 |
-
//What to backup - db or full
|
| 209 |
-
if
|
| 210 |
-
//
|
| 211 |
$this->update_status($task_name,$this->statuses['db_dump']);
|
| 212 |
$db_result = $this->backup_db();
|
| 213 |
if ($db_result == false) {
|
|
@@ -218,33 +210,37 @@ class MMB_Backup extends MMB_Core
|
|
| 218 |
return array(
|
| 219 |
'error' => $db_result['error']
|
| 220 |
);
|
| 221 |
-
|
| 222 |
} else {
|
| 223 |
-
|
| 224 |
$this->update_status($task_name,$this->statuses['db_dump'],true);
|
| 225 |
-
|
| 226 |
$this->update_status($task_name,$this->statuses['db_zip']);
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
} else {
|
| 236 |
require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
|
| 237 |
$archive = new PclZip($backup_file);
|
| 238 |
-
$result = $archive->add($db_result, PCLZIP_OPT_REMOVE_PATH,
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
return array(
|
| 245 |
'error' => 'Failed to zip database.'
|
| 246 |
);
|
| 247 |
-
|
|
|
|
| 248 |
}
|
| 249 |
} elseif (trim($what) == 'full') {
|
| 250 |
$content_backup = $this->backup_full($task_name,$backup_file, $exclude);
|
|
@@ -401,79 +397,84 @@ class MMB_Backup extends MMB_Core
|
|
| 401 |
}
|
| 402 |
|
| 403 |
$this->update_status($task_name,$this->statuses['db_dump'],true);
|
|
|
|
| 404 |
|
| 405 |
-
$
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
|
|
|
|
|
|
|
|
|
| 409 |
|
| 410 |
-
if ($this->mmb_exec('which zip')) {
|
| 411 |
-
$this->update_status($task_name,$this->statuses['db_zip']);
|
| 412 |
-
//Add database file
|
| 413 |
-
chdir(WP_CONTENT_DIR);
|
| 414 |
-
$command = "zip -r $backup_file 'mwp_db'";
|
| 415 |
-
ob_start();
|
| 416 |
-
$result = $this->mmb_exec($command);
|
| 417 |
-
ob_get_clean();
|
| 418 |
-
@unlink($db_result);
|
| 419 |
-
@rmdir(WP_CONTENT_DIR.'/mwp_db');
|
| 420 |
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
|
| 427 |
-
|
|
|
|
| 428 |
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 433 |
foreach ($exclude as $data) {
|
| 434 |
if ($data)
|
| 435 |
$exclude_data .= " '$data/*'";
|
| 436 |
}
|
| 437 |
-
|
| 438 |
|
| 439 |
-
|
| 440 |
$exclude_data .= " '$data/*'";
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
if ($result) {
|
| 450 |
-
$this->update_status($task_name,$this->statuses['files_zip'],true);
|
| 451 |
-
return true;
|
| 452 |
-
} else {
|
| 453 |
-
return array(
|
| 454 |
-
'error' => 'Failed to backup files.'
|
| 455 |
-
);
|
| 456 |
-
}
|
| 457 |
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
|
|
|
|
|
|
| 461 |
$archive = new PclZip($backup_file);
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
'error' => 'Failed to backup site. Try to enable Zip on your server.'
|
| 471 |
);
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
$result = $archive->add(ABSPATH, PCLZIP_OPT_REMOVE_PATH, ABSPATH);
|
| 476 |
-
$exclude_data = array();
|
| 477 |
if (!empty($exclude) && $result) {
|
| 478 |
$exclude_data = array();
|
| 479 |
foreach ($exclude as $data) {
|
|
@@ -481,63 +482,52 @@ class MMB_Backup extends MMB_Core
|
|
| 481 |
$exclude_data[] = $data . '/';
|
| 482 |
}
|
| 483 |
}
|
| 484 |
-
|
|
|
|
| 485 |
$exclude_data[] = $rem . '/';
|
| 486 |
}
|
| 487 |
|
| 488 |
$result_excl = $archive->delete(PCLZIP_OPT_BY_NAME, $exclude_data);
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
$this->update_status($task_name,$this->statuses['files_zip'],true);
|
| 494 |
-
return true;
|
| 495 |
-
} else {
|
| 496 |
-
if ($archive->error_code == '-10') {
|
| 497 |
-
return array(
|
| 498 |
-
'error' => 'Failed to backup site. Try increasing memory limit and/or free space on your server.'
|
| 499 |
-
);
|
| 500 |
-
} else {
|
| 501 |
-
return array(
|
| 502 |
-
'error' => 'Failed to backup site. Try to enable Zip on your server.'
|
| 503 |
);
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
|
|
|
|
|
|
|
|
|
| 508 |
|
| 509 |
|
| 510 |
function backup_db()
|
| 511 |
{
|
| 512 |
-
$db_folder =
|
| 513 |
if (!file_exists($db_folder)) {
|
| 514 |
if (!mkdir($db_folder, 0755, true))
|
| 515 |
return array(
|
| 516 |
-
'error' => 'Error creating database backup folder. Make sure you have write permissions
|
| 517 |
);
|
| 518 |
}
|
| 519 |
|
| 520 |
$file = $db_folder . DB_NAME . '.sql';
|
| 521 |
-
$
|
| 522 |
-
if (is_array($mysqldump)) {
|
| 523 |
-
$result = $this->backup_db_dump($file, $mysqldump);
|
| 524 |
-
|
| 525 |
-
} else {
|
| 526 |
-
$result = $this->backup_db_php($file);
|
| 527 |
-
}
|
| 528 |
return $result;
|
| 529 |
}
|
| 530 |
|
| 531 |
-
function backup_db_dump($file
|
| 532 |
{
|
| 533 |
global $wpdb;
|
|
|
|
| 534 |
$brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
|
| 535 |
-
$command = $brace . $
|
| 536 |
-
|
| 537 |
ob_start();
|
| 538 |
-
|
| 539 |
ob_get_clean();
|
| 540 |
-
|
|
|
|
| 541 |
$result = $this->backup_db_php($file);
|
| 542 |
return $result;
|
| 543 |
}
|
|
@@ -567,6 +557,7 @@ class MMB_Backup extends MMB_Core
|
|
| 567 |
else
|
| 568 |
$count = 1;
|
| 569 |
for ($i = 0; $i < $count; $i++) {
|
|
|
|
| 570 |
$low_limit = $i * 100;
|
| 571 |
$qry = "SELECT * FROM $table[0] LIMIT $low_limit, 100";
|
| 572 |
$rows = $wpdb->get_results($qry, ARRAY_A);
|
|
@@ -596,7 +587,9 @@ class MMB_Backup extends MMB_Core
|
|
| 596 |
|
| 597 |
if (filesize($file) == 0 || !is_file($file)) {
|
| 598 |
@unlink($file);
|
| 599 |
-
return
|
|
|
|
|
|
|
| 600 |
}
|
| 601 |
|
| 602 |
return $file;
|
|
@@ -604,7 +597,8 @@ class MMB_Backup extends MMB_Core
|
|
| 604 |
}
|
| 605 |
|
| 606 |
function restore($args)
|
| 607 |
-
{
|
|
|
|
| 608 |
global $wpdb;
|
| 609 |
if (empty($args)) {
|
| 610 |
return false;
|
|
@@ -612,7 +606,7 @@ class MMB_Backup extends MMB_Core
|
|
| 612 |
|
| 613 |
extract($args);
|
| 614 |
@ini_set('memory_limit', '300M');
|
| 615 |
-
@set_time_limit(
|
| 616 |
|
| 617 |
$unlink_file = true; //Delete file after restore
|
| 618 |
|
|
@@ -640,7 +634,7 @@ class MMB_Backup extends MMB_Core
|
|
| 640 |
$backup_file = $this->get_ftp_backup($args);
|
| 641 |
if ($backup_file == false) {
|
| 642 |
return array(
|
| 643 |
-
'error' => 'Failed to download file from FTP'
|
| 644 |
);
|
| 645 |
}
|
| 646 |
} elseif (isset($task['task_results'][$result_id]['amazons3'])) {
|
|
@@ -650,7 +644,7 @@ class MMB_Backup extends MMB_Core
|
|
| 650 |
$backup_file = $this->get_amazons3_backup($args);
|
| 651 |
if ($backup_file == false) {
|
| 652 |
return array(
|
| 653 |
-
'error' => 'Failed to download file from Amazon S3'
|
| 654 |
);
|
| 655 |
}
|
| 656 |
}
|
|
@@ -673,19 +667,30 @@ class MMB_Backup extends MMB_Core
|
|
| 673 |
$db_password = DB_PASSWORD;
|
| 674 |
$home = rtrim(get_option('home'),"/");
|
| 675 |
$site_url = get_option('site_url');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 676 |
}
|
| 677 |
|
| 678 |
-
|
| 679 |
chdir(ABSPATH);
|
| 680 |
-
$
|
|
|
|
| 681 |
ob_start();
|
| 682 |
$result = $this->mmb_exec($command);
|
| 683 |
ob_get_clean();
|
| 684 |
|
| 685 |
-
|
|
|
|
| 686 |
require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
|
| 687 |
$archive = new PclZip($backup_file);
|
| 688 |
-
$result = $archive->extract(PCLZIP_OPT_PATH, ABSPATH);
|
| 689 |
}
|
| 690 |
|
| 691 |
if ($unlink_file) {
|
|
@@ -693,9 +698,9 @@ class MMB_Backup extends MMB_Core
|
|
| 693 |
}
|
| 694 |
|
| 695 |
if (!$result) {
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
}
|
| 700 |
|
| 701 |
$db_result = $this->restore_db();
|
|
@@ -717,12 +722,12 @@ class MMB_Backup extends MMB_Core
|
|
| 717 |
|
| 718 |
//Get New Table prefix
|
| 719 |
$new_table_prefix = trim($this->get_table_prefix());
|
| 720 |
-
|
| 721 |
//Retrieve old wp_config
|
| 722 |
@unlink(ABSPATH . 'wp-config.php');
|
| 723 |
|
| 724 |
//Replace table prefix
|
| 725 |
$lines = file(ABSPATH . 'mwp-temp-wp-config.php');
|
|
|
|
| 726 |
foreach ($lines as $line) {
|
| 727 |
if (strstr($line, '$table_prefix')) {
|
| 728 |
$line = '$table_prefix = "' . $new_table_prefix . '";' . PHP_EOL;
|
|
@@ -742,7 +747,28 @@ class MMB_Backup extends MMB_Core
|
|
| 742 |
$wpdb->query($wpdb->prepare($query));
|
| 743 |
//Replace content urls
|
| 744 |
$query = "UPDATE " . $new_table_prefix . "posts SET post_content = REPLACE (post_content, '$old','$home') WHERE post_content REGEXP 'src=\"(.*)$old(.*)\"' OR post_content REGEXP 'href=\"(.*)$old(.*)\"'";
|
| 745 |
-
$wpdb->query($wpdb->prepare($query));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 746 |
}
|
| 747 |
|
| 748 |
return true;
|
|
@@ -751,33 +777,33 @@ class MMB_Backup extends MMB_Core
|
|
| 751 |
function restore_db()
|
| 752 |
{
|
| 753 |
global $wpdb;
|
| 754 |
-
$
|
| 755 |
$file_path = ABSPATH . 'mwp_db';
|
| 756 |
$file_name = glob($file_path . '/*.sql');
|
| 757 |
$file_name = $file_name[0];
|
| 758 |
|
| 759 |
-
|
| 760 |
$brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
|
| 761 |
-
$command = $brace
|
| 762 |
|
| 763 |
ob_start();
|
| 764 |
$result = $this->mmb_exec($command);
|
| 765 |
ob_get_clean();
|
| 766 |
if (!$result) {
|
| 767 |
//try php
|
|
|
|
| 768 |
$this->restore_db_php($file_name);
|
| 769 |
}
|
| 770 |
|
| 771 |
-
} else {
|
| 772 |
-
$this->restore_db_php($file_name);
|
| 773 |
-
}
|
| 774 |
|
| 775 |
@unlink($file_name);
|
| 776 |
return true;
|
| 777 |
}
|
| 778 |
|
| 779 |
function restore_db_php($file_name)
|
| 780 |
-
{
|
|
|
|
|
|
|
| 781 |
$current_query = '';
|
| 782 |
// Read in entire file
|
| 783 |
$lines = file($file_name);
|
|
@@ -794,7 +820,7 @@ class MMB_Backup extends MMB_Core
|
|
| 794 |
// Perform the query
|
| 795 |
$result = $wpdb->query($current_query);
|
| 796 |
if ($result === false)
|
| 797 |
-
return
|
| 798 |
// Reset temp variable to empty
|
| 799 |
$current_query = '';
|
| 800 |
}
|
|
@@ -805,7 +831,7 @@ class MMB_Backup extends MMB_Core
|
|
| 805 |
}
|
| 806 |
|
| 807 |
function get_table_prefix()
|
| 808 |
-
{
|
| 809 |
$lines = file(ABSPATH . 'wp-config.php');
|
| 810 |
foreach ($lines as $line) {
|
| 811 |
if (strstr($line, '$table_prefix')) {
|
|
@@ -845,11 +871,11 @@ class MMB_Backup extends MMB_Core
|
|
| 845 |
}
|
| 846 |
|
| 847 |
### Function: Auto Detect MYSQL and MYSQL Dump Paths
|
| 848 |
-
function
|
| 849 |
{
|
| 850 |
global $wpdb;
|
| 851 |
$paths = array(
|
| 852 |
-
'
|
| 853 |
'mysqldump' => ''
|
| 854 |
);
|
| 855 |
if (substr(PHP_OS, 0, 3) == 'WIN') {
|
|
@@ -863,21 +889,17 @@ class MMB_Backup extends MMB_Core
|
|
| 863 |
$paths['mysqldump'] = 'mysqldump.exe';
|
| 864 |
}
|
| 865 |
} else {
|
| 866 |
-
|
| 867 |
$paths['mysql'] = $this->mmb_exec('which mysql', true);
|
|
|
|
|
|
|
|
|
|
| 868 |
$paths['mysqldump'] = $this->mmb_exec('which mysqldump', true);
|
| 869 |
-
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
}
|
| 873 |
-
}
|
| 874 |
-
|
| 875 |
-
if (!@file_exists(stripslashes($paths['mysqldump']))) {
|
| 876 |
-
return false;
|
| 877 |
-
}
|
| 878 |
-
if (!@file_exists(stripslashes($paths['mysql']))) {
|
| 879 |
-
return false;
|
| 880 |
}
|
|
|
|
| 881 |
|
| 882 |
return $paths;
|
| 883 |
}
|
|
@@ -915,13 +937,29 @@ class MMB_Backup extends MMB_Core
|
|
| 915 |
if ($string)
|
| 916 |
return $log;
|
| 917 |
return $return ? false : true;
|
| 918 |
-
} elseif ($this->mmb_function_exists('passthru')) {
|
| 919 |
$log = passthru($command, $return);
|
| 920 |
-
|
| 921 |
return $return ? false : true;
|
| 922 |
-
} else {
|
| 923 |
-
return false;
|
| 924 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 925 |
}
|
| 926 |
|
| 927 |
function check_backup_compat()
|
|
@@ -932,7 +970,7 @@ class MMB_Backup extends MMB_Core
|
|
| 932 |
$reqs['Server OS']['pass'] = true;
|
| 933 |
} else {
|
| 934 |
$reqs['Server OS']['status'] = 'Windows';
|
| 935 |
-
$reqs['Server OS']['pass'] =
|
| 936 |
$pass = false;
|
| 937 |
}
|
| 938 |
$reqs['PHP Version']['status'] = phpversion();
|
|
@@ -953,7 +991,7 @@ class MMB_Backup extends MMB_Core
|
|
| 953 |
}
|
| 954 |
|
| 955 |
|
| 956 |
-
$file_path =
|
| 957 |
$reqs['Backup Folder']['status'] .= ' (' . $file_path . ')';
|
| 958 |
|
| 959 |
if ($func = $this->check_sys()) {
|
|
@@ -961,33 +999,27 @@ class MMB_Backup extends MMB_Core
|
|
| 961 |
$reqs['Execute Function']['pass'] = true;
|
| 962 |
} else {
|
| 963 |
$reqs['Execute Function']['status'] = "not found";
|
| 964 |
-
$reqs['Execute Function']['info'] = "(will try
|
| 965 |
$reqs['Execute Function']['pass'] = false;
|
| 966 |
}
|
|
|
|
| 967 |
|
| 968 |
-
|
| 969 |
-
$reqs['Zip']['status'] = "enabled";
|
| 970 |
-
$reqs['Zip']['pass'] = true;
|
| 971 |
-
} else {
|
| 972 |
-
$reqs['Zip']['status'] = "not found";
|
| 973 |
-
$reqs['Zip']['info'] = "(will try with PHP pclZip class)";
|
| 974 |
-
$reqs['Zip']['pass'] = false;
|
| 975 |
-
}
|
| 976 |
|
| 977 |
-
|
| 978 |
-
|
| 979 |
-
|
| 980 |
-
|
| 981 |
-
|
| 982 |
-
|
| 983 |
-
|
| 984 |
-
|
| 985 |
-
if (
|
| 986 |
-
$reqs['MySQL Dump']['status'] =
|
| 987 |
$reqs['MySQL Dump']['pass'] = true;
|
| 988 |
} else {
|
| 989 |
$reqs['MySQL Dump']['status'] = "not found";
|
| 990 |
-
$reqs['MySQL Dump']['info'] = "(will try PHP)";
|
| 991 |
$reqs['MySQL Dump']['pass'] = false;
|
| 992 |
}
|
| 993 |
|
|
@@ -1006,11 +1038,16 @@ class MMB_Backup extends MMB_Core
|
|
| 1006 |
$headers = 'From: ManageWP <no-reply@managewp.com>' . "\r\n";
|
| 1007 |
$subject = "ManageWP - " . $task_name . " - ".$this->site_name;
|
| 1008 |
ob_start();
|
| 1009 |
-
wp_mail($email, $subject, $subject, $headers, $attachments);
|
| 1010 |
ob_end_clean();
|
| 1011 |
|
| 1012 |
}
|
| 1013 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1014 |
return true;
|
| 1015 |
|
| 1016 |
}
|
|
@@ -1166,6 +1203,7 @@ class MMB_Backup extends MMB_Core
|
|
| 1166 |
|
| 1167 |
function amazons3_backup($args)
|
| 1168 |
{
|
|
|
|
| 1169 |
require_once('lib/s3.php');
|
| 1170 |
extract($args);
|
| 1171 |
|
|
@@ -1173,7 +1211,7 @@ class MMB_Backup extends MMB_Core
|
|
| 1173 |
$as3_directory .= '/'.$this->site_name;
|
| 1174 |
|
| 1175 |
|
| 1176 |
-
$s3 = new S3($as3_access_key, str_replace(' ', '+', $as3_secure_key));
|
| 1177 |
|
| 1178 |
$s3->putBucket($as3_bucket, S3::ACL_PUBLIC_READ);
|
| 1179 |
|
|
@@ -1185,7 +1223,12 @@ class MMB_Backup extends MMB_Core
|
|
| 1185 |
'partial' => 1
|
| 1186 |
);
|
| 1187 |
}
|
| 1188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1189 |
}
|
| 1190 |
|
| 1191 |
function remove_amazons3_backup($args)
|
|
@@ -1334,9 +1377,12 @@ class MMB_Backup extends MMB_Core
|
|
| 1334 |
|
| 1335 |
function remove_old_backups($task_name)
|
| 1336 |
{
|
| 1337 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1338 |
$backups = $this->get_backup_settings();
|
| 1339 |
-
|
| 1340 |
if($task_name == 'Backup Now'){
|
| 1341 |
$num = 0;
|
| 1342 |
} else {
|
|
@@ -1437,10 +1483,21 @@ class MMB_Backup extends MMB_Core
|
|
| 1437 |
{
|
| 1438 |
$tasks = $this->get_backup_settings();
|
| 1439 |
$backup_folder = WP_CONTENT_DIR . '/' . md5('mmb-worker') . '/mwp_backups/';
|
| 1440 |
-
$backup_folder_new =
|
| 1441 |
$files = glob($backup_folder . "*");
|
| 1442 |
$new = glob($backup_folder_new . "*");
|
| 1443 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1444 |
//clean_old folder?
|
| 1445 |
if((basename($files[0]) == 'index.php' && count($files) == 1) || (empty($files))){
|
| 1446 |
foreach($files as $file){
|
|
@@ -1455,10 +1512,6 @@ class MMB_Backup extends MMB_Core
|
|
| 1455 |
$files[] = $b;
|
| 1456 |
}
|
| 1457 |
$deleted = array();
|
| 1458 |
-
$clone_backup = get_option('mwp_manual_backup');
|
| 1459 |
-
if(isset($clone_backup['file_path'])){
|
| 1460 |
-
$clone_backup = $clone_backup['file_path'];
|
| 1461 |
-
}
|
| 1462 |
|
| 1463 |
if (is_array($files) && count($files)) {
|
| 1464 |
$results = array();
|
|
@@ -1476,7 +1529,7 @@ class MMB_Backup extends MMB_Core
|
|
| 1476 |
|
| 1477 |
$num_deleted = 0;
|
| 1478 |
foreach ($files as $file) {
|
| 1479 |
-
if (!in_array($file, $results) && basename($file) != 'index.php'
|
| 1480 |
@unlink($file);
|
| 1481 |
$deleted[] = basename($file);
|
| 1482 |
$num_deleted++;
|
|
@@ -1484,14 +1537,7 @@ class MMB_Backup extends MMB_Core
|
|
| 1484 |
}
|
| 1485 |
}
|
| 1486 |
|
| 1487 |
-
|
| 1488 |
-
$db_folder = WP_CONTENT_DIR . '/mwp_db/';
|
| 1489 |
-
$files = glob($db_folder . "*.*");
|
| 1490 |
-
if (is_array($files) && count($files)) {
|
| 1491 |
-
foreach ($files as $file) {
|
| 1492 |
-
@unlink($file);
|
| 1493 |
-
}
|
| 1494 |
-
}
|
| 1495 |
|
| 1496 |
return $deleted;
|
| 1497 |
}
|
|
@@ -1567,13 +1613,13 @@ class MMB_Backup extends MMB_Core
|
|
| 1567 |
|
| 1568 |
}
|
| 1569 |
|
| 1570 |
-
function validate_task($args){
|
| 1571 |
if( !class_exists( 'WP_Http' ) ){
|
| 1572 |
include_once( ABSPATH . WPINC. '/class-http.php' );
|
| 1573 |
}
|
| 1574 |
$params = array();
|
| 1575 |
$params['body'] = $args;
|
| 1576 |
-
$result= wp_remote_post($
|
| 1577 |
if(is_array($result) && $result['body'] == 'mwp_delete_task'){
|
| 1578 |
$tasks = $this->get_backup_settings();
|
| 1579 |
unset($tasks[$args['task_name']]);
|
| 9 |
* Copyright (c) 2011 Prelovac Media
|
| 10 |
* www.prelovac.com
|
| 11 |
**************************************************************/
|
| 12 |
+
define ('MWP_BACKUP_DIR', WP_CONTENT_DIR.'/managewp/backups');
|
| 13 |
+
define ('MWP_DB_DIR', MWP_BACKUP_DIR.'/mwp_db');
|
| 14 |
|
| 15 |
class MMB_Backup extends MMB_Core
|
| 16 |
{
|
| 18 |
var $statuses;
|
| 19 |
|
| 20 |
function __construct()
|
| 21 |
+
{
|
| 22 |
+
parent::__construct();
|
| 23 |
+
$this->site_name = str_replace(array("_","/"), array("","-"),rtrim($this->remove_http(get_bloginfo('url')),"/"));
|
| 24 |
$this->statuses = array(
|
| 25 |
'db_dump' => 1,
|
| 26 |
'db_zip' => 2,
|
| 90 |
if ($task_name == 'Backup Now') {
|
| 91 |
$result = $this->backup($args, $task_name);
|
| 92 |
$backup_settings = $this->get_backup_settings();
|
| 93 |
+
|
| 94 |
if (is_array($result) && array_key_exists('error', $result)) {
|
| 95 |
$return = $result;
|
| 96 |
} else {
|
| 115 |
$check_data = array(
|
| 116 |
'task_name' => $task_name,
|
| 117 |
'task_id' => $setting['task_args']['task_id'],
|
| 118 |
+
'site_key' => $setting['task_args']['site_key']
|
|
|
|
| 119 |
);
|
| 120 |
|
| 121 |
+
$this->validate_task($check_data,$setting['task_args']['url']);
|
| 122 |
}
|
| 123 |
|
| 124 |
//Update task with next schedule
|
| 160 |
|
| 161 |
function backup($args, $task_name = false)
|
| 162 |
{
|
|
|
|
| 163 |
if (!$args || empty($args))
|
| 164 |
return false;
|
| 165 |
|
| 166 |
extract($args); //extract settings
|
| 167 |
|
| 168 |
+
//Try increase memory limit and execution time
|
| 169 |
+
@ini_set('memory_limit', '300M');
|
| 170 |
@set_time_limit(600); //ten minutes
|
| 171 |
|
| 172 |
//Remove old backup(s)
|
| 173 |
$this->remove_old_backups($task_name);
|
| 174 |
|
| 175 |
+
$new_file_path = MWP_BACKUP_DIR;
|
| 176 |
|
| 177 |
if (!file_exists($new_file_path)) {
|
| 178 |
if (!mkdir($new_file_path, 0755, true))
|
| 183 |
|
| 184 |
@file_put_contents($new_file_path . '/index.php', ''); //safe
|
| 185 |
|
| 186 |
+
//Delete possible broken previous backups - don't need it anymore (works only for previous worker versions)
|
| 187 |
foreach (glob($new_file_path . "/*.zip") as $filename) {
|
| 188 |
$short = basename($filename);
|
| 189 |
preg_match('/^wp\-content(.*)/Ui', $short, $matches);
|
| 191 |
@unlink($filename);
|
| 192 |
}
|
| 193 |
|
| 194 |
+
//Prepare .zip file name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
$hash = md5(time());
|
| 196 |
$label = $type ? $type : 'manual';
|
| 197 |
+
$backup_file = $new_file_path . '/' . $this->site_name . '_' . $label . '_' . $what . '_' . date('Y-m-d') . '_' . $hash . '.zip';
|
| 198 |
+
$backup_url = WP_CONTENT_URL . '/managewp/backups/' . $this->site_name . '_' . $label . '_' . $what . '_' . date('Y-m-d') . '_' . $hash . '.zip';
|
| 199 |
|
| 200 |
+
//What to backup - db or full?
|
| 201 |
+
if(trim($what) == 'db') {
|
| 202 |
+
//Take database backup
|
| 203 |
$this->update_status($task_name,$this->statuses['db_dump']);
|
| 204 |
$db_result = $this->backup_db();
|
| 205 |
if ($db_result == false) {
|
| 210 |
return array(
|
| 211 |
'error' => $db_result['error']
|
| 212 |
);
|
|
|
|
| 213 |
} else {
|
|
|
|
| 214 |
$this->update_status($task_name,$this->statuses['db_dump'],true);
|
|
|
|
| 215 |
$this->update_status($task_name,$this->statuses['db_zip']);
|
| 216 |
+
chdir(MWP_BACKUP_DIR);
|
| 217 |
+
$zip = $this->get_zip();
|
| 218 |
+
$command = "$zip -r $backup_file 'mwp_db'";
|
| 219 |
+
ob_start();
|
| 220 |
+
$result = $this->mmb_exec($command);
|
| 221 |
+
ob_get_clean();
|
| 222 |
+
if (!$result) { // fallback to pclzip
|
| 223 |
+
define('PCLZIP_TEMPORARY_DIR', MWP_BACKUP_DIR.'/');
|
|
|
|
| 224 |
require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
|
| 225 |
$archive = new PclZip($backup_file);
|
| 226 |
+
$result = $archive->add($db_result, PCLZIP_OPT_REMOVE_PATH, MWP_BACKUP_DIR);
|
| 227 |
+
@unlink($db_result);
|
| 228 |
+
@rmdir(MWP_DB_DIR);
|
| 229 |
+
if (!$result){
|
| 230 |
+
return array(
|
| 231 |
+
'error' => 'Failed to zip database. pclZip error ('.$archive->error_code.'): .'.$archive->error_string
|
| 232 |
+
);
|
| 233 |
+
}
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
@unlink($db_result);
|
| 237 |
+
@rmdir(MWP_DB_DIR);
|
| 238 |
+
if (!$result){
|
| 239 |
return array(
|
| 240 |
'error' => 'Failed to zip database.'
|
| 241 |
);
|
| 242 |
+
}
|
| 243 |
+
$this->update_status($task_name,$this->statuses['db_zip'],true);
|
| 244 |
}
|
| 245 |
} elseif (trim($what) == 'full') {
|
| 246 |
$content_backup = $this->backup_full($task_name,$backup_file, $exclude);
|
| 397 |
}
|
| 398 |
|
| 399 |
$this->update_status($task_name,$this->statuses['db_dump'],true);
|
| 400 |
+
$this->update_status($task_name,$this->statuses['db_zip']);
|
| 401 |
|
| 402 |
+
$zip = $this->get_zip();
|
| 403 |
+
//Add database file
|
| 404 |
+
chdir(MWP_BACKUP_DIR);
|
| 405 |
+
$command = "$zip -r $backup_file 'mwp_db'";
|
| 406 |
+
ob_start();
|
| 407 |
+
$result = $this->mmb_exec($command);
|
| 408 |
+
ob_get_clean();
|
| 409 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 410 |
|
| 411 |
+
if (!$result) {
|
| 412 |
+
define('PCLZIP_TEMPORARY_DIR', MWP_BACKUP_DIR.'/');
|
| 413 |
+
require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
|
| 414 |
+
$archive = new PclZip($backup_file);
|
| 415 |
+
$result_db = $archive->add($db_result, PCLZIP_OPT_REMOVE_PATH, MWP_BACKUP_DIR);
|
| 416 |
|
| 417 |
+
@unlink($db_result);
|
| 418 |
+
@rmdir(MWP_DB_DIR);
|
| 419 |
|
| 420 |
+
if(!$result_db){
|
| 421 |
+
return array(
|
| 422 |
+
'error' => 'Failed to zip database. pclZip error ('.$archive->error_code.'): .'.$archive->error_string
|
| 423 |
+
);
|
| 424 |
+
}
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
@unlink($db_result);
|
| 428 |
+
@rmdir(MWP_DB_DIR);
|
| 429 |
+
|
| 430 |
+
$this->update_status($task_name,$this->statuses['db_zip'],true);
|
| 431 |
+
|
| 432 |
+
|
| 433 |
+
//Always remove backup folders
|
| 434 |
+
$remove = array(
|
| 435 |
+
"wp-content/managewp/backups",
|
| 436 |
+
"wp-content/".md5('mmb-worker')."/mwp_backups"
|
| 437 |
+
);
|
| 438 |
+
|
| 439 |
+
|
| 440 |
+
//exclude paths
|
| 441 |
+
$exclude_data = "-x";
|
| 442 |
+
if (!empty($exclude)) {
|
| 443 |
foreach ($exclude as $data) {
|
| 444 |
if ($data)
|
| 445 |
$exclude_data .= " '$data/*'";
|
| 446 |
}
|
| 447 |
+
}
|
| 448 |
|
| 449 |
+
foreach ($remove as $data) {
|
| 450 |
$exclude_data .= " '$data/*'";
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
$this->update_status($task_name,$this->statuses['files_zip']);
|
| 454 |
+
chdir(ABSPATH);
|
| 455 |
+
$command = "$zip -r $backup_file './' $exclude_data";
|
| 456 |
+
ob_start();
|
| 457 |
+
$result = $this->mmb_exec($command);
|
| 458 |
+
ob_get_clean();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 459 |
|
| 460 |
+
if (!$result) { //Try pclZip
|
| 461 |
+
|
| 462 |
+
if(!isset($archive)){
|
| 463 |
+
define('PCLZIP_TEMPORARY_DIR', MWP_BACKUP_DIR.'/');
|
| 464 |
+
require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
|
| 465 |
$archive = new PclZip($backup_file);
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
$result = $archive->add(ABSPATH, PCLZIP_OPT_REMOVE_PATH, ABSPATH);
|
| 469 |
+
|
| 470 |
+
if(!$result){
|
| 471 |
+
@unlink($backup_file);
|
| 472 |
+
return array(
|
| 473 |
+
'error' => 'Failed to zip files. pclZip error ('.$archive->error_code.'): .'.$archive->error_string
|
|
|
|
| 474 |
);
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
$exclude_data = array();
|
|
|
|
|
|
|
| 478 |
if (!empty($exclude) && $result) {
|
| 479 |
$exclude_data = array();
|
| 480 |
foreach ($exclude as $data) {
|
| 482 |
$exclude_data[] = $data . '/';
|
| 483 |
}
|
| 484 |
}
|
| 485 |
+
|
| 486 |
+
foreach ($remove as $rem) {
|
| 487 |
$exclude_data[] = $rem . '/';
|
| 488 |
}
|
| 489 |
|
| 490 |
$result_excl = $archive->delete(PCLZIP_OPT_BY_NAME, $exclude_data);
|
| 491 |
+
if(!$result){
|
| 492 |
+
@unlink($backup_file);
|
| 493 |
+
return array(
|
| 494 |
+
'error' => 'Failed to zip files. pclZip error ('.$archive->error_code.'): .'.$archive->error_string
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 495 |
);
|
| 496 |
+
}
|
| 497 |
+
|
| 498 |
+
}
|
| 499 |
+
|
| 500 |
+
$this->update_status($task_name,$this->statuses['files_zip'],true);
|
| 501 |
+
return true;
|
| 502 |
+
}
|
| 503 |
|
| 504 |
|
| 505 |
function backup_db()
|
| 506 |
{
|
| 507 |
+
$db_folder = MWP_DB_DIR.'/';
|
| 508 |
if (!file_exists($db_folder)) {
|
| 509 |
if (!mkdir($db_folder, 0755, true))
|
| 510 |
return array(
|
| 511 |
+
'error' => 'Error creating database backup folder ('.$db_folder.'). Make sure you have corrrect write permissions.'
|
| 512 |
);
|
| 513 |
}
|
| 514 |
|
| 515 |
$file = $db_folder . DB_NAME . '.sql';
|
| 516 |
+
$result = $this->backup_db_dump($file); // try mysqldump always then fallback to php dump
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 517 |
return $result;
|
| 518 |
}
|
| 519 |
|
| 520 |
+
function backup_db_dump($file)
|
| 521 |
{
|
| 522 |
global $wpdb;
|
| 523 |
+
$paths = $this->check_mysql_paths();
|
| 524 |
$brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
|
| 525 |
+
$command = $brace . $paths['mysqldump'] . $brace . ' --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" --add-drop-table --skip-lock-tables "' . DB_NAME . '" > ' . $brace . $file . $brace;
|
|
|
|
| 526 |
ob_start();
|
| 527 |
+
$result = $this->mmb_exec($command);
|
| 528 |
ob_get_clean();
|
| 529 |
+
|
| 530 |
+
if (!$result) { // Fallback to php
|
| 531 |
$result = $this->backup_db_php($file);
|
| 532 |
return $result;
|
| 533 |
}
|
| 557 |
else
|
| 558 |
$count = 1;
|
| 559 |
for ($i = 0; $i < $count; $i++) {
|
| 560 |
+
|
| 561 |
$low_limit = $i * 100;
|
| 562 |
$qry = "SELECT * FROM $table[0] LIMIT $low_limit, 100";
|
| 563 |
$rows = $wpdb->get_results($qry, ARRAY_A);
|
| 587 |
|
| 588 |
if (filesize($file) == 0 || !is_file($file)) {
|
| 589 |
@unlink($file);
|
| 590 |
+
return array(
|
| 591 |
+
'error' => 'Database backup failed. Try to enable MySQL dump on your server.'
|
| 592 |
+
);
|
| 593 |
}
|
| 594 |
|
| 595 |
return $file;
|
| 597 |
}
|
| 598 |
|
| 599 |
function restore($args)
|
| 600 |
+
{
|
| 601 |
+
|
| 602 |
global $wpdb;
|
| 603 |
if (empty($args)) {
|
| 604 |
return false;
|
| 606 |
|
| 607 |
extract($args);
|
| 608 |
@ini_set('memory_limit', '300M');
|
| 609 |
+
@set_time_limit(600);
|
| 610 |
|
| 611 |
$unlink_file = true; //Delete file after restore
|
| 612 |
|
| 634 |
$backup_file = $this->get_ftp_backup($args);
|
| 635 |
if ($backup_file == false) {
|
| 636 |
return array(
|
| 637 |
+
'error' => 'Failed to download file from FTP.'
|
| 638 |
);
|
| 639 |
}
|
| 640 |
} elseif (isset($task['task_results'][$result_id]['amazons3'])) {
|
| 644 |
$backup_file = $this->get_amazons3_backup($args);
|
| 645 |
if ($backup_file == false) {
|
| 646 |
return array(
|
| 647 |
+
'error' => 'Failed to download file from Amazon S3.'
|
| 648 |
);
|
| 649 |
}
|
| 650 |
}
|
| 667 |
$db_password = DB_PASSWORD;
|
| 668 |
$home = rtrim(get_option('home'),"/");
|
| 669 |
$site_url = get_option('site_url');
|
| 670 |
+
|
| 671 |
+
if(trim($clone_from_url)){
|
| 672 |
+
$clone_options = array();
|
| 673 |
+
$clone_options['_worker_nossl_key'] = get_option('_worker_nossl_key');
|
| 674 |
+
$clone_options['_worker_public_key'] = get_option('_worker_public_key');
|
| 675 |
+
$clone_options['_action_message_id'] = get_option('_action_message_id');
|
| 676 |
+
}
|
| 677 |
+
|
| 678 |
+
|
| 679 |
}
|
| 680 |
|
| 681 |
+
|
| 682 |
chdir(ABSPATH);
|
| 683 |
+
$unzip=$this->get_unzip();
|
| 684 |
+
$command = "$unzip -o $backup_file";
|
| 685 |
ob_start();
|
| 686 |
$result = $this->mmb_exec($command);
|
| 687 |
ob_get_clean();
|
| 688 |
|
| 689 |
+
if (!$result) { //fallback to pclzip
|
| 690 |
+
define('PCLZIP_TEMPORARY_DIR', MWP_BACKUP_DIR.'/');
|
| 691 |
require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
|
| 692 |
$archive = new PclZip($backup_file);
|
| 693 |
+
$result = $archive->extract(PCLZIP_OPT_PATH, ABSPATH, PCLZIP_OPT_REPLACE_NEWER);
|
| 694 |
}
|
| 695 |
|
| 696 |
if ($unlink_file) {
|
| 698 |
}
|
| 699 |
|
| 700 |
if (!$result) {
|
| 701 |
+
return array(
|
| 702 |
+
'error' => 'Failed to unzip files. pclZip error ('.$archive->error_code.'): .'.$archive->error_string
|
| 703 |
+
);
|
| 704 |
}
|
| 705 |
|
| 706 |
$db_result = $this->restore_db();
|
| 722 |
|
| 723 |
//Get New Table prefix
|
| 724 |
$new_table_prefix = trim($this->get_table_prefix());
|
|
|
|
| 725 |
//Retrieve old wp_config
|
| 726 |
@unlink(ABSPATH . 'wp-config.php');
|
| 727 |
|
| 728 |
//Replace table prefix
|
| 729 |
$lines = file(ABSPATH . 'mwp-temp-wp-config.php');
|
| 730 |
+
|
| 731 |
foreach ($lines as $line) {
|
| 732 |
if (strstr($line, '$table_prefix')) {
|
| 733 |
$line = '$table_prefix = "' . $new_table_prefix . '";' . PHP_EOL;
|
| 747 |
$wpdb->query($wpdb->prepare($query));
|
| 748 |
//Replace content urls
|
| 749 |
$query = "UPDATE " . $new_table_prefix . "posts SET post_content = REPLACE (post_content, '$old','$home') WHERE post_content REGEXP 'src=\"(.*)$old(.*)\"' OR post_content REGEXP 'href=\"(.*)$old(.*)\"'";
|
| 750 |
+
$wpdb->query($wpdb->prepare($query));
|
| 751 |
+
if($new_user && $new_password){
|
| 752 |
+
$new_password = wp_hash_password($new_password);
|
| 753 |
+
$query = "UPDATE " . $new_table_prefix . "users SET user_login = '$new_user', user_pass = '$new_password' WHERE user_login = '$old_user'";
|
| 754 |
+
$wpdb->query($wpdb->prepare($query));
|
| 755 |
+
}
|
| 756 |
+
|
| 757 |
+
if(is_array($clone_options)){
|
| 758 |
+
|
| 759 |
+
foreach($clone_options as $key => $option){
|
| 760 |
+
if(!empty($key)){
|
| 761 |
+
$query = "UPDATE " . $new_table_prefix . "options SET option_value = '$option' WHERE option_name = '$key'";
|
| 762 |
+
|
| 763 |
+
$wpdb->query($wpdb->prepare($query));
|
| 764 |
+
}
|
| 765 |
+
}
|
| 766 |
+
}
|
| 767 |
+
$clone_options['_worker_nossl_key'] = get_option('_worker_nossl_key');
|
| 768 |
+
$clone_options['_worker_public_key'] = get_option('_worker_public_key');
|
| 769 |
+
$clone_options['_action_message_id'] = get_option('_action_message_id');
|
| 770 |
+
|
| 771 |
+
|
| 772 |
}
|
| 773 |
|
| 774 |
return true;
|
| 777 |
function restore_db()
|
| 778 |
{
|
| 779 |
global $wpdb;
|
| 780 |
+
$paths = $this->check_mysql_paths();
|
| 781 |
$file_path = ABSPATH . 'mwp_db';
|
| 782 |
$file_name = glob($file_path . '/*.sql');
|
| 783 |
$file_name = $file_name[0];
|
| 784 |
|
| 785 |
+
|
| 786 |
$brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
|
| 787 |
+
$command = $brace .$paths['mysql'] . $brace . ' --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" ' . DB_NAME . ' < ' . $brace . $file_name . $brace;
|
| 788 |
|
| 789 |
ob_start();
|
| 790 |
$result = $this->mmb_exec($command);
|
| 791 |
ob_get_clean();
|
| 792 |
if (!$result) {
|
| 793 |
//try php
|
| 794 |
+
|
| 795 |
$this->restore_db_php($file_name);
|
| 796 |
}
|
| 797 |
|
|
|
|
|
|
|
|
|
|
| 798 |
|
| 799 |
@unlink($file_name);
|
| 800 |
return true;
|
| 801 |
}
|
| 802 |
|
| 803 |
function restore_db_php($file_name)
|
| 804 |
+
{
|
| 805 |
+
|
| 806 |
+
global $wpdb;
|
| 807 |
$current_query = '';
|
| 808 |
// Read in entire file
|
| 809 |
$lines = file($file_name);
|
| 820 |
// Perform the query
|
| 821 |
$result = $wpdb->query($current_query);
|
| 822 |
if ($result === false)
|
| 823 |
+
return false;
|
| 824 |
// Reset temp variable to empty
|
| 825 |
$current_query = '';
|
| 826 |
}
|
| 831 |
}
|
| 832 |
|
| 833 |
function get_table_prefix()
|
| 834 |
+
{
|
| 835 |
$lines = file(ABSPATH . 'wp-config.php');
|
| 836 |
foreach ($lines as $line) {
|
| 837 |
if (strstr($line, '$table_prefix')) {
|
| 871 |
}
|
| 872 |
|
| 873 |
### Function: Auto Detect MYSQL and MYSQL Dump Paths
|
| 874 |
+
function check_mysql_paths()
|
| 875 |
{
|
| 876 |
global $wpdb;
|
| 877 |
$paths = array(
|
| 878 |
+
'mysql' => '',
|
| 879 |
'mysqldump' => ''
|
| 880 |
);
|
| 881 |
if (substr(PHP_OS, 0, 3) == 'WIN') {
|
| 889 |
$paths['mysqldump'] = 'mysqldump.exe';
|
| 890 |
}
|
| 891 |
} else {
|
| 892 |
+
|
| 893 |
$paths['mysql'] = $this->mmb_exec('which mysql', true);
|
| 894 |
+
if (empty( $paths['mysql']))
|
| 895 |
+
$paths['mysql']='mysql'; // try anyway
|
| 896 |
+
|
| 897 |
$paths['mysqldump'] = $this->mmb_exec('which mysqldump', true);
|
| 898 |
+
if (empty( $paths['mysqldump']))
|
| 899 |
+
$paths['mysqldump']='mysqldump'; // try anyway
|
| 900 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 901 |
}
|
| 902 |
+
|
| 903 |
|
| 904 |
return $paths;
|
| 905 |
}
|
| 937 |
if ($string)
|
| 938 |
return $log;
|
| 939 |
return $return ? false : true;
|
| 940 |
+
} elseif ($this->mmb_function_exists('passthru') && !$string) {
|
| 941 |
$log = passthru($command, $return);
|
|
|
|
| 942 |
return $return ? false : true;
|
|
|
|
|
|
|
| 943 |
}
|
| 944 |
+
|
| 945 |
+
|
| 946 |
+
return false;
|
| 947 |
+
}
|
| 948 |
+
|
| 949 |
+
function get_zip()
|
| 950 |
+
{
|
| 951 |
+
$zip=$this->mmb_exec('which zip', true);
|
| 952 |
+
if (!$zip)
|
| 953 |
+
$zip="zip";
|
| 954 |
+
return $zip;
|
| 955 |
+
}
|
| 956 |
+
|
| 957 |
+
function get_unzip()
|
| 958 |
+
{
|
| 959 |
+
$unzip=$this->mmb_exec('which unzip', true);
|
| 960 |
+
if (!$unzip)
|
| 961 |
+
$unzip="unzip";
|
| 962 |
+
return $unzip;
|
| 963 |
}
|
| 964 |
|
| 965 |
function check_backup_compat()
|
| 970 |
$reqs['Server OS']['pass'] = true;
|
| 971 |
} else {
|
| 972 |
$reqs['Server OS']['status'] = 'Windows';
|
| 973 |
+
$reqs['Server OS']['pass'] = true;
|
| 974 |
$pass = false;
|
| 975 |
}
|
| 976 |
$reqs['PHP Version']['status'] = phpversion();
|
| 991 |
}
|
| 992 |
|
| 993 |
|
| 994 |
+
$file_path = MWP_BACKUP_DIR;
|
| 995 |
$reqs['Backup Folder']['status'] .= ' (' . $file_path . ')';
|
| 996 |
|
| 997 |
if ($func = $this->check_sys()) {
|
| 999 |
$reqs['Execute Function']['pass'] = true;
|
| 1000 |
} else {
|
| 1001 |
$reqs['Execute Function']['status'] = "not found";
|
| 1002 |
+
$reqs['Execute Function']['info'] = "(will try PHP replacement)";
|
| 1003 |
$reqs['Execute Function']['pass'] = false;
|
| 1004 |
}
|
| 1005 |
+
$reqs['Zip']['status'] = $this->get_zip();
|
| 1006 |
|
| 1007 |
+
$reqs['Zip']['pass'] = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1008 |
|
| 1009 |
+
|
| 1010 |
+
|
| 1011 |
+
$reqs['Unzip']['status'] = $this->get_unzip();
|
| 1012 |
+
|
| 1013 |
+
$reqs['Unzip']['pass'] = true;
|
| 1014 |
+
|
| 1015 |
+
$paths=$this->check_mysql_paths();
|
| 1016 |
+
|
| 1017 |
+
if (!empty($paths['mysqldump'])) {
|
| 1018 |
+
$reqs['MySQL Dump']['status'] = $paths['mysqldump'];
|
| 1019 |
$reqs['MySQL Dump']['pass'] = true;
|
| 1020 |
} else {
|
| 1021 |
$reqs['MySQL Dump']['status'] = "not found";
|
| 1022 |
+
$reqs['MySQL Dump']['info'] = "(will try PHP replacement)";
|
| 1023 |
$reqs['MySQL Dump']['pass'] = false;
|
| 1024 |
}
|
| 1025 |
|
| 1038 |
$headers = 'From: ManageWP <no-reply@managewp.com>' . "\r\n";
|
| 1039 |
$subject = "ManageWP - " . $task_name . " - ".$this->site_name;
|
| 1040 |
ob_start();
|
| 1041 |
+
$result = wp_mail($email, $subject, $subject, $headers, $attachments);
|
| 1042 |
ob_end_clean();
|
| 1043 |
|
| 1044 |
}
|
| 1045 |
|
| 1046 |
+
if(!$result){
|
| 1047 |
+
return array(
|
| 1048 |
+
'error' => 'Email not sent. Maybe your backup is too big for email or email server is not available on your website.',
|
| 1049 |
+
);
|
| 1050 |
+
}
|
| 1051 |
return true;
|
| 1052 |
|
| 1053 |
}
|
| 1203 |
|
| 1204 |
function amazons3_backup($args)
|
| 1205 |
{
|
| 1206 |
+
if($this->mmb_function_exists('curl_init')){
|
| 1207 |
require_once('lib/s3.php');
|
| 1208 |
extract($args);
|
| 1209 |
|
| 1211 |
$as3_directory .= '/'.$this->site_name;
|
| 1212 |
|
| 1213 |
|
| 1214 |
+
$s3 = new S3(trim($as3_access_key), trim(str_replace(' ', '+', $as3_secure_key)));
|
| 1215 |
|
| 1216 |
$s3->putBucket($as3_bucket, S3::ACL_PUBLIC_READ);
|
| 1217 |
|
| 1223 |
'partial' => 1
|
| 1224 |
);
|
| 1225 |
}
|
| 1226 |
+
} else {
|
| 1227 |
+
return array(
|
| 1228 |
+
'error' => 'You cannot use AmazonS3 on your server. Please enable curl first.',
|
| 1229 |
+
'partial' => 1
|
| 1230 |
+
);
|
| 1231 |
+
}
|
| 1232 |
}
|
| 1233 |
|
| 1234 |
function remove_amazons3_backup($args)
|
| 1377 |
|
| 1378 |
function remove_old_backups($task_name)
|
| 1379 |
{
|
| 1380 |
+
|
| 1381 |
+
//Check for previous failed backups first
|
| 1382 |
+
$this->cleanup();
|
| 1383 |
+
|
| 1384 |
+
//Remove by limit
|
| 1385 |
$backups = $this->get_backup_settings();
|
|
|
|
| 1386 |
if($task_name == 'Backup Now'){
|
| 1387 |
$num = 0;
|
| 1388 |
} else {
|
| 1483 |
{
|
| 1484 |
$tasks = $this->get_backup_settings();
|
| 1485 |
$backup_folder = WP_CONTENT_DIR . '/' . md5('mmb-worker') . '/mwp_backups/';
|
| 1486 |
+
$backup_folder_new = MWP_BACKUP_DIR.'/';
|
| 1487 |
$files = glob($backup_folder . "*");
|
| 1488 |
$new = glob($backup_folder_new . "*");
|
| 1489 |
|
| 1490 |
+
//Failed db files first
|
| 1491 |
+
$db_folder = MWP_DB_DIR.'/';
|
| 1492 |
+
$db_files = glob($db_folder . "*");
|
| 1493 |
+
if (is_array($db_files) && !empty($db_files)) {
|
| 1494 |
+
foreach ($db_files as $file) {
|
| 1495 |
+
@unlink($file);
|
| 1496 |
+
}
|
| 1497 |
+
@rmdir(MWP_DB_DIR);
|
| 1498 |
+
}
|
| 1499 |
+
|
| 1500 |
+
|
| 1501 |
//clean_old folder?
|
| 1502 |
if((basename($files[0]) == 'index.php' && count($files) == 1) || (empty($files))){
|
| 1503 |
foreach($files as $file){
|
| 1512 |
$files[] = $b;
|
| 1513 |
}
|
| 1514 |
$deleted = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1515 |
|
| 1516 |
if (is_array($files) && count($files)) {
|
| 1517 |
$results = array();
|
| 1529 |
|
| 1530 |
$num_deleted = 0;
|
| 1531 |
foreach ($files as $file) {
|
| 1532 |
+
if (!in_array($file, $results) && basename($file) != 'index.php') {
|
| 1533 |
@unlink($file);
|
| 1534 |
$deleted[] = basename($file);
|
| 1535 |
$num_deleted++;
|
| 1537 |
}
|
| 1538 |
}
|
| 1539 |
|
| 1540 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1541 |
|
| 1542 |
return $deleted;
|
| 1543 |
}
|
| 1613 |
|
| 1614 |
}
|
| 1615 |
|
| 1616 |
+
function validate_task($args,$url){
|
| 1617 |
if( !class_exists( 'WP_Http' ) ){
|
| 1618 |
include_once( ABSPATH . WPINC. '/class-http.php' );
|
| 1619 |
}
|
| 1620 |
$params = array();
|
| 1621 |
$params['body'] = $args;
|
| 1622 |
+
$result= wp_remote_post($url, $params);
|
| 1623 |
if(is_array($result) && $result['body'] == 'mwp_delete_task'){
|
| 1624 |
$tasks = $this->get_backup_settings();
|
| 1625 |
unset($tasks[$args['task_name']]);
|
core.class.php
CHANGED
|
@@ -92,7 +92,8 @@ class MMB_Core extends MMB_Helper
|
|
| 92 |
$_mmb_item_filter['get'] = array( 'updates', 'errors' );
|
| 93 |
|
| 94 |
$this->mmb_pre_init_actions = array(
|
| 95 |
-
'do_upgrade' => 'mmb_do_upgrade'
|
|
|
|
| 96 |
);
|
| 97 |
$this->mmb_init_actions = array(
|
| 98 |
'get_stats' => 'mmb_stats_get',
|
|
@@ -126,7 +127,7 @@ class MMB_Core extends MMB_Helper
|
|
| 126 |
|
| 127 |
add_action('rightnow_end', array( 'MMB_Stats', 'add_right_now_info' ));
|
| 128 |
add_action('wp_footer', array( 'MMB_Stats', 'set_hit_count' ));
|
| 129 |
-
|
| 130 |
add_action('init', array( &$this, 'mmb_remote_action'), 9999);
|
| 131 |
add_action('setup_theme', 'mmb_parse_request');
|
| 132 |
}
|
|
@@ -562,8 +563,8 @@ class MMB_Core extends MMB_Helper
|
|
| 562 |
if (!headers_sent())
|
| 563 |
header('P3P: CP="CAO PSA OUR"');
|
| 564 |
|
| 565 |
-
$siteurl = get_site_option( 'siteurl' );
|
| 566 |
-
$user =
|
| 567 |
wp_set_current_user($user->ID);
|
| 568 |
|
| 569 |
$expiration = time() + apply_filters('auth_cookie_expiration', 10800, $user->ID, false);
|
|
@@ -572,10 +573,20 @@ class MMB_Core extends MMB_Helper
|
|
| 572 |
$_COOKIE['wordpress_'.md5( $siteurl )] = $auth_cookie;
|
| 573 |
$_COOKIE['wordpress_logged_in_'.md5( $siteurl )] = $logged_in_cookie;
|
| 574 |
|
|
|
|
|
|
|
|
|
|
| 575 |
wp_set_auth_cookie($user->ID);
|
| 576 |
setcookie(MMB_XFRAME_COOKIE, md5(MMB_XFRAME_COOKIE), $expiration, COOKIEPATH, COOKIE_DOMAIN, false, true);
|
| 577 |
$_COOKIE[MMB_XFRAME_COOKIE] = md5(MMB_XFRAME_COOKIE);
|
| 578 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 579 |
wp_die($auth['error']);
|
| 580 |
}
|
| 581 |
} elseif( is_user_logged_in() ) {
|
|
@@ -590,14 +601,17 @@ class MMB_Core extends MMB_Helper
|
|
| 590 |
function worker_replace($all_plugins){
|
| 591 |
$replace = get_option("mwp_worker_brand");
|
| 592 |
if(is_array($replace)){
|
| 593 |
-
if($replace['name']){
|
| 594 |
$all_plugins['worker/init.php']['Name'] = $replace['name'];
|
| 595 |
-
$all_plugins['worker/init.php']['Title'] = $replace['name'];
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
$all_plugins['worker/init.php']['
|
|
|
|
|
|
|
|
|
|
| 599 |
}
|
| 600 |
-
|
| 601 |
|
| 602 |
return $all_plugins;
|
| 603 |
}
|
| 92 |
$_mmb_item_filter['get'] = array( 'updates', 'errors' );
|
| 93 |
|
| 94 |
$this->mmb_pre_init_actions = array(
|
| 95 |
+
'do_upgrade' => 'mmb_do_upgrade',
|
| 96 |
+
'backup_req' => 'mmb_get_backup_req'
|
| 97 |
);
|
| 98 |
$this->mmb_init_actions = array(
|
| 99 |
'get_stats' => 'mmb_stats_get',
|
| 127 |
|
| 128 |
add_action('rightnow_end', array( 'MMB_Stats', 'add_right_now_info' ));
|
| 129 |
add_action('wp_footer', array( 'MMB_Stats', 'set_hit_count' ));
|
| 130 |
+
add_action('admin_init', array($this,'admin_actions'));
|
| 131 |
add_action('init', array( &$this, 'mmb_remote_action'), 9999);
|
| 132 |
add_action('setup_theme', 'mmb_parse_request');
|
| 133 |
}
|
| 563 |
if (!headers_sent())
|
| 564 |
header('P3P: CP="CAO PSA OUR"');
|
| 565 |
|
| 566 |
+
$siteurl = function_exists('get_site_option') ? get_site_option( 'siteurl' ) : get_option('siteurl');
|
| 567 |
+
$user = $this->mmb_get_user_info($username);
|
| 568 |
wp_set_current_user($user->ID);
|
| 569 |
|
| 570 |
$expiration = time() + apply_filters('auth_cookie_expiration', 10800, $user->ID, false);
|
| 573 |
$_COOKIE['wordpress_'.md5( $siteurl )] = $auth_cookie;
|
| 574 |
$_COOKIE['wordpress_logged_in_'.md5( $siteurl )] = $logged_in_cookie;
|
| 575 |
|
| 576 |
+
if(isset($this->mmb_multisite) && $this->mmb_multisite )
|
| 577 |
+
wp_cookie_constants();
|
| 578 |
+
|
| 579 |
wp_set_auth_cookie($user->ID);
|
| 580 |
setcookie(MMB_XFRAME_COOKIE, md5(MMB_XFRAME_COOKIE), $expiration, COOKIEPATH, COOKIE_DOMAIN, false, true);
|
| 581 |
$_COOKIE[MMB_XFRAME_COOKIE] = md5(MMB_XFRAME_COOKIE);
|
| 582 |
+
|
| 583 |
+
if(isset($this->mmb_multisite) && $this->mmb_multisite ){
|
| 584 |
+
if(function_exists('wp_safe_redirect') && function_exists('admin_url')){
|
| 585 |
+
wp_safe_redirect(admin_url($where));
|
| 586 |
+
exit();
|
| 587 |
+
}
|
| 588 |
+
}
|
| 589 |
+
} else {
|
| 590 |
wp_die($auth['error']);
|
| 591 |
}
|
| 592 |
} elseif( is_user_logged_in() ) {
|
| 601 |
function worker_replace($all_plugins){
|
| 602 |
$replace = get_option("mwp_worker_brand");
|
| 603 |
if(is_array($replace)){
|
| 604 |
+
if($replace['name'] || $replace['desc'] || $replace['author'] || $replace['author_url']){
|
| 605 |
$all_plugins['worker/init.php']['Name'] = $replace['name'];
|
| 606 |
+
$all_plugins['worker/init.php']['Title'] = $replace['name'];
|
| 607 |
+
$all_plugins['worker/init.php']['Description'] = $replace['desc'];
|
| 608 |
+
$all_plugins['worker/init.php']['AuthorURI'] = $replace['author_url'];
|
| 609 |
+
$all_plugins['worker/init.php']['Author'] = $replace['author'];
|
| 610 |
+
$all_plugins['worker/init.php']['AuthorName'] = $replace['author'];
|
| 611 |
+
$all_plugins['worker/init.php']['PluginURI'] = '';
|
| 612 |
+
}
|
| 613 |
}
|
| 614 |
+
|
| 615 |
|
| 616 |
return $all_plugins;
|
| 617 |
}
|
helper.class.php
CHANGED
|
@@ -137,6 +137,10 @@ class MMB_Helper
|
|
| 137 |
if(!function_exists($function_callback))
|
| 138 |
return false;
|
| 139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
if (extension_loaded('suhosin')) {
|
| 141 |
$suhosin = @ini_get("suhosin.executor.func.blacklist");
|
| 142 |
if (empty($suhosin) == false) {
|
| 137 |
if(!function_exists($function_callback))
|
| 138 |
return false;
|
| 139 |
|
| 140 |
+
$disabled = explode(', ', @ini_get('disable_functions'));
|
| 141 |
+
if (in_array($function_callback, $disabled))
|
| 142 |
+
return false;
|
| 143 |
+
|
| 144 |
if (extension_loaded('suhosin')) {
|
| 145 |
$suhosin = @ini_get("suhosin.executor.func.blacklist");
|
| 146 |
if (empty($suhosin) == false) {
|
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.
|
| 8 |
Author URI: http://www.prelovac.com
|
| 9 |
*/
|
| 10 |
|
|
@@ -20,11 +20,12 @@ Author URI: http://www.prelovac.com
|
|
| 20 |
**************************************************************/
|
| 21 |
|
| 22 |
if(!defined('MMB_WORKER_VERSION'))
|
| 23 |
-
define('MMB_WORKER_VERSION', '3.9.
|
| 24 |
-
|
| 25 |
-
if ( function_exists('get_site_option') && !defined('MMB_XFRAME_COOKIE'))
|
| 26 |
-
define('MMB_XFRAME_COOKIE', $xframe = 'wordpress_'.md5(get_site_option( 'siteurl' )).'_xframe');
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
global $wpdb, $mmb_plugin_dir, $mmb_plugin_url, $wp_version, $mmb_filters, $_mmb_item_filter;
|
| 29 |
|
| 30 |
if (version_compare(PHP_VERSION, '5.0.0', '<')) // min version 5 supported
|
|
@@ -80,7 +81,7 @@ if( !function_exists ( 'mmb_parse_request' )) {
|
|
| 80 |
if ($auth === true) {
|
| 81 |
|
| 82 |
if(isset($params['username']) && !is_user_logged_in()){
|
| 83 |
-
$user = get_user_by('login', $params['username']);
|
| 84 |
wp_set_current_user($user->ID);
|
| 85 |
}
|
| 86 |
|
|
@@ -351,6 +352,7 @@ if( !function_exists ( 'mmb_email_backup' )) {
|
|
| 351 |
}
|
| 352 |
}
|
| 353 |
}
|
|
|
|
| 354 |
if( !function_exists ( 'mmb_check_backup_compat' )) {
|
| 355 |
function mmb_check_backup_compat($params)
|
| 356 |
{
|
|
@@ -366,10 +368,20 @@ if( !function_exists ( 'mmb_check_backup_compat' )) {
|
|
| 366 |
}
|
| 367 |
}
|
| 368 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
if( !function_exists ( 'mmb_scheduled_backup' )) {
|
| 370 |
function mmb_scheduled_backup($params)
|
| 371 |
{
|
| 372 |
-
|
| 373 |
global $mmb_core;
|
| 374 |
$mmb_core->get_backup_instance();
|
| 375 |
$return = $mmb_core->backup_instance->set_backup_task($params);
|
| 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.11
|
| 8 |
Author URI: http://www.prelovac.com
|
| 9 |
*/
|
| 10 |
|
| 20 |
**************************************************************/
|
| 21 |
|
| 22 |
if(!defined('MMB_WORKER_VERSION'))
|
| 23 |
+
define('MMB_WORKER_VERSION', '3.9.11');
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
if ( !defined('MMB_XFRAME_COOKIE')){
|
| 26 |
+
$siteurl = function_exists('get_site_option') ? get_site_option( 'siteurl' ) : get_option('siteurl');
|
| 27 |
+
define('MMB_XFRAME_COOKIE', $xframe = 'wordpress_'.md5($siteurl).'_xframe');
|
| 28 |
+
}
|
| 29 |
global $wpdb, $mmb_plugin_dir, $mmb_plugin_url, $wp_version, $mmb_filters, $_mmb_item_filter;
|
| 30 |
|
| 31 |
if (version_compare(PHP_VERSION, '5.0.0', '<')) // min version 5 supported
|
| 81 |
if ($auth === true) {
|
| 82 |
|
| 83 |
if(isset($params['username']) && !is_user_logged_in()){
|
| 84 |
+
$user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : get_userdatabylogin( $params['username'] );
|
| 85 |
wp_set_current_user($user->ID);
|
| 86 |
}
|
| 87 |
|
| 352 |
}
|
| 353 |
}
|
| 354 |
}
|
| 355 |
+
|
| 356 |
if( !function_exists ( 'mmb_check_backup_compat' )) {
|
| 357 |
function mmb_check_backup_compat($params)
|
| 358 |
{
|
| 368 |
}
|
| 369 |
}
|
| 370 |
|
| 371 |
+
if( !function_exists ( 'mmb_get_backup_req' )) {
|
| 372 |
+
function mmb_get_backup_req( $params )
|
| 373 |
+
{
|
| 374 |
+
global $mmb_core;
|
| 375 |
+
$mmb_core->get_stats_instance();
|
| 376 |
+
$return = $mmb_core->stats_instance->get_backup_req($params);
|
| 377 |
+
|
| 378 |
+
mmb_response($return, true);
|
| 379 |
+
}
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
if( !function_exists ( 'mmb_scheduled_backup' )) {
|
| 383 |
function mmb_scheduled_backup($params)
|
| 384 |
{
|
|
|
|
| 385 |
global $mmb_core;
|
| 386 |
$mmb_core->get_backup_instance();
|
| 387 |
$return = $mmb_core->backup_instance->set_backup_task($params);
|
lib/s3.php
CHANGED
|
@@ -371,7 +371,7 @@ class S3
|
|
| 371 |
{
|
| 372 |
$dom = new DOMDocument;
|
| 373 |
$createBucketConfiguration = $dom->createElement('CreateBucketConfiguration');
|
| 374 |
-
$locationConstraint = $dom->createElement('LocationConstraint',
|
| 375 |
$createBucketConfiguration->appendChild($locationConstraint);
|
| 376 |
$dom->appendChild($createBucketConfiguration);
|
| 377 |
$rest->data = $dom->saveXML();
|
|
@@ -967,7 +967,8 @@ class S3
|
|
| 967 |
$expires = time() + $lifetime;
|
| 968 |
$uri = str_replace('%2F', '/', rawurlencode($uri)); // URI should be encoded (thanks Sean O'Dea)
|
| 969 |
return sprintf(($https ? 'https' : 'http').'://%s/%s?AWSAccessKeyId=%s&Expires=%u&Signature=%s',
|
| 970 |
-
$hostBucket ? $bucket : $bucket.'.s3.amazonaws.com', $uri, self::$__accessKey, $expires,
|
|
|
|
| 971 |
urlencode(self::__getHash("GET\n\n\n{$expires}\n/{$bucket}/{$uri}")));
|
| 972 |
}
|
| 973 |
|
|
@@ -988,7 +989,6 @@ class S3
|
|
| 988 |
$signature = str_replace(array('+', '='), array('-', '_', '~'), base64_encode($signature));
|
| 989 |
|
| 990 |
$url = $policy['Statement'][0]['Resource'] . '?';
|
| 991 |
-
|
| 992 |
foreach (array('Policy' => $encoded, 'Signature' => $signature, 'Key-Pair-Id' => self::$__signingKeyPairId) as $k => $v)
|
| 993 |
$url .= $k.'='.str_replace('%2F', '/', rawurlencode($v)).'&';
|
| 994 |
return substr($url, 0, -1);
|
|
@@ -1650,18 +1650,35 @@ final class S3Request
|
|
| 1650 |
$this->bucket = $bucket;
|
| 1651 |
$this->uri = $uri !== '' ? '/'.str_replace('%2F', '/', rawurlencode($uri)) : '/';
|
| 1652 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1653 |
if ($this->bucket !== '')
|
| 1654 |
{
|
| 1655 |
-
$this->
|
| 1656 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1657 |
}
|
| 1658 |
else
|
| 1659 |
{
|
| 1660 |
$this->headers['Host'] = $this->endpoint;
|
| 1661 |
$this->resource = $this->uri;
|
| 1662 |
}
|
| 1663 |
-
$this->headers['Date'] = gmdate('D, d M Y H:i:s T');
|
| 1664 |
|
|
|
|
|
|
|
| 1665 |
$this->response = new STDClass;
|
| 1666 |
$this->response->error = false;
|
| 1667 |
}
|
|
@@ -1727,11 +1744,13 @@ final class S3Request
|
|
| 1727 |
if (array_key_exists('acl', $this->parameters) ||
|
| 1728 |
array_key_exists('location', $this->parameters) ||
|
| 1729 |
array_key_exists('torrent', $this->parameters) ||
|
|
|
|
| 1730 |
array_key_exists('logging', $this->parameters))
|
| 1731 |
$this->resource .= $query;
|
| 1732 |
}
|
| 1733 |
-
$url = (S3::$useSSL ? 'https://' : 'http://') . $this->headers['Host']
|
| 1734 |
-
|
|
|
|
| 1735 |
|
| 1736 |
// Basic setup
|
| 1737 |
$curl = curl_init();
|
|
@@ -1779,11 +1798,18 @@ final class S3Request
|
|
| 1779 |
if (S3::hasAuth())
|
| 1780 |
{
|
| 1781 |
// Authorization string (CloudFront stringToSign should only contain a date)
|
| 1782 |
-
$headers[]
|
| 1783 |
-
$
|
| 1784 |
-
|
| 1785 |
-
|
| 1786 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1787 |
}
|
| 1788 |
|
| 1789 |
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
|
@@ -1879,6 +1905,23 @@ final class S3Request
|
|
| 1879 |
}
|
| 1880 |
|
| 1881 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1882 |
/**
|
| 1883 |
* CURL header callback
|
| 1884 |
*
|
| 371 |
{
|
| 372 |
$dom = new DOMDocument;
|
| 373 |
$createBucketConfiguration = $dom->createElement('CreateBucketConfiguration');
|
| 374 |
+
$locationConstraint = $dom->createElement('LocationConstraint', $location);
|
| 375 |
$createBucketConfiguration->appendChild($locationConstraint);
|
| 376 |
$dom->appendChild($createBucketConfiguration);
|
| 377 |
$rest->data = $dom->saveXML();
|
| 967 |
$expires = time() + $lifetime;
|
| 968 |
$uri = str_replace('%2F', '/', rawurlencode($uri)); // URI should be encoded (thanks Sean O'Dea)
|
| 969 |
return sprintf(($https ? 'https' : 'http').'://%s/%s?AWSAccessKeyId=%s&Expires=%u&Signature=%s',
|
| 970 |
+
// $hostBucket ? $bucket : $bucket.'.s3.amazonaws.com', $uri, self::$__accessKey, $expires,
|
| 971 |
+
$hostBucket ? $bucket : 's3.amazonaws.com/'.$bucket, $uri, self::$__accessKey, $expires,
|
| 972 |
urlencode(self::__getHash("GET\n\n\n{$expires}\n/{$bucket}/{$uri}")));
|
| 973 |
}
|
| 974 |
|
| 989 |
$signature = str_replace(array('+', '='), array('-', '_', '~'), base64_encode($signature));
|
| 990 |
|
| 991 |
$url = $policy['Statement'][0]['Resource'] . '?';
|
|
|
|
| 992 |
foreach (array('Policy' => $encoded, 'Signature' => $signature, 'Key-Pair-Id' => self::$__signingKeyPairId) as $k => $v)
|
| 993 |
$url .= $k.'='.str_replace('%2F', '/', rawurlencode($v)).'&';
|
| 994 |
return substr($url, 0, -1);
|
| 1650 |
$this->bucket = $bucket;
|
| 1651 |
$this->uri = $uri !== '' ? '/'.str_replace('%2F', '/', rawurlencode($uri)) : '/';
|
| 1652 |
|
| 1653 |
+
//if ($this->bucket !== '')
|
| 1654 |
+
// $this->resource = '/'.$this->bucket.$this->uri;
|
| 1655 |
+
//else
|
| 1656 |
+
// $this->resource = $this->uri;
|
| 1657 |
+
|
| 1658 |
if ($this->bucket !== '')
|
| 1659 |
{
|
| 1660 |
+
if ($this->__dnsBucketName($this->bucket))
|
| 1661 |
+
{
|
| 1662 |
+
$this->headers['Host'] = $this->bucket.'.'.$this->endpoint;
|
| 1663 |
+
$this->resource = '/'.$this->bucket.$this->uri;
|
| 1664 |
+
}
|
| 1665 |
+
else
|
| 1666 |
+
{
|
| 1667 |
+
$this->headers['Host'] = $this->endpoint;
|
| 1668 |
+
$this->uri = $this->uri;
|
| 1669 |
+
if ($this->bucket !== '') $this->uri = '/'.$this->bucket.$this->uri;
|
| 1670 |
+
$this->bucket = '';
|
| 1671 |
+
$this->resource = $this->uri;
|
| 1672 |
+
}
|
| 1673 |
}
|
| 1674 |
else
|
| 1675 |
{
|
| 1676 |
$this->headers['Host'] = $this->endpoint;
|
| 1677 |
$this->resource = $this->uri;
|
| 1678 |
}
|
|
|
|
| 1679 |
|
| 1680 |
+
|
| 1681 |
+
$this->headers['Date'] = gmdate('D, d M Y H:i:s T');
|
| 1682 |
$this->response = new STDClass;
|
| 1683 |
$this->response->error = false;
|
| 1684 |
}
|
| 1744 |
if (array_key_exists('acl', $this->parameters) ||
|
| 1745 |
array_key_exists('location', $this->parameters) ||
|
| 1746 |
array_key_exists('torrent', $this->parameters) ||
|
| 1747 |
+
array_key_exists('website', $this->parameters) ||
|
| 1748 |
array_key_exists('logging', $this->parameters))
|
| 1749 |
$this->resource .= $query;
|
| 1750 |
}
|
| 1751 |
+
$url = (S3::$useSSL ? 'https://' : 'http://') . ($this->headers['Host'] !== '' ? $this->headers['Host'] : $this->endpoint) . $this->uri;
|
| 1752 |
+
|
| 1753 |
+
//var_dump('bucket: ' . $this->bucket, 'uri: ' . $this->uri, 'resource: ' . $this->resource, 'url: ' . $url);
|
| 1754 |
|
| 1755 |
// Basic setup
|
| 1756 |
$curl = curl_init();
|
| 1798 |
if (S3::hasAuth())
|
| 1799 |
{
|
| 1800 |
// Authorization string (CloudFront stringToSign should only contain a date)
|
| 1801 |
+
if ($this->headers['Host'] == 'cloudfront.amazonaws.com')
|
| 1802 |
+
$headers[] = 'Authorization: ' . S3::__getSignature($this->headers['Date']);
|
| 1803 |
+
else
|
| 1804 |
+
{
|
| 1805 |
+
$headers[] = 'Authorization: ' . S3::__getSignature(
|
| 1806 |
+
$this->verb."\n".
|
| 1807 |
+
$this->headers['Content-MD5']."\n".
|
| 1808 |
+
$this->headers['Content-Type']."\n".
|
| 1809 |
+
$this->headers['Date'].$amz."\n".
|
| 1810 |
+
$this->resource
|
| 1811 |
+
);
|
| 1812 |
+
}
|
| 1813 |
}
|
| 1814 |
|
| 1815 |
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
| 1905 |
}
|
| 1906 |
|
| 1907 |
|
| 1908 |
+
/**
|
| 1909 |
+
* Check DNS conformity
|
| 1910 |
+
*
|
| 1911 |
+
* @param string $bucket Bucket name
|
| 1912 |
+
* @return boolean
|
| 1913 |
+
*/
|
| 1914 |
+
private function __dnsBucketName($bucket)
|
| 1915 |
+
{
|
| 1916 |
+
if (strlen($bucket) > 63 || !preg_match("/[^a-z0-9\.-]/", $bucket)) return false;
|
| 1917 |
+
if (strstr($bucket, '-.') !== false) return false;
|
| 1918 |
+
if (strstr($bucket, '..') !== false) return false;
|
| 1919 |
+
if (!preg_match("/^[0-9a-z]/", $bucket)) return false;
|
| 1920 |
+
if (!preg_match("/[0-9a-z]$/", $bucket)) return false;
|
| 1921 |
+
return true;
|
| 1922 |
+
}
|
| 1923 |
+
|
| 1924 |
+
|
| 1925 |
/**
|
| 1926 |
* CURL header callback
|
| 1927 |
*
|
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 blogs from one dashboard.
|
|
@@ -16,10 +16,10 @@ Main features:
|
|
| 16 |
|
| 17 |
* Secure and fast solution for managing your WordPress sites
|
| 18 |
* One click upgrades of WordPress, plugin and themes across all your sites
|
| 19 |
-
*
|
| 20 |
* One click to access WP admin of any site
|
| 21 |
* Bulk install themes and plugins to multiple sites at once
|
| 22 |
-
*
|
| 23 |
* Bulk publish posts to multiple sites at once
|
| 24 |
* Install WordPress, clone or migrate a website to another domain
|
| 25 |
* Much, much more...
|
|
@@ -32,6 +32,22 @@ Check out [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs").
|
|
| 32 |
|
| 33 |
== Changelog ==
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
= 3.9.9 =
|
| 36 |
* New widget on the dashboard - Backup status
|
| 37 |
* New screen for managing plugins and themes (activate, deactivate, delete, add to favorites, install) across all sites
|
| 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.3
|
| 7 |
Stable tag: trunk
|
| 8 |
|
| 9 |
ManageWP Worker plugin allows you to remotely manage your blogs from one dashboard.
|
| 16 |
|
| 17 |
* Secure and fast solution for managing your WordPress sites
|
| 18 |
* One click upgrades of WordPress, plugin and themes across all your sites
|
| 19 |
+
* Schedule automatic backups of your websites (Amazon S3 and Dropbox supported)
|
| 20 |
* One click to access WP admin of any site
|
| 21 |
* Bulk install themes and plugins to multiple sites at once
|
| 22 |
+
* Add sub-users (writers, staff..) to your account
|
| 23 |
* Bulk publish posts to multiple sites at once
|
| 24 |
* Install WordPress, clone or migrate a website to another domain
|
| 25 |
* Much, much more...
|
| 32 |
|
| 33 |
== Changelog ==
|
| 34 |
|
| 35 |
+
= 3.9.11 =
|
| 36 |
+
* Minor bug fixes
|
| 37 |
+
|
| 38 |
+
= 3.9.10 =
|
| 39 |
+
* Supporting updates for more premium plugins/themes
|
| 40 |
+
* Backup notifications (users can now get notices when the backup succeeds or fails)
|
| 41 |
+
* Support for WordPress 3.3
|
| 42 |
+
* Worker Branding (useful for web agencies, add your own Name/Description)
|
| 43 |
+
* Manage Groups screen
|
| 44 |
+
* Specify wp-admin path if your site uses a custom one
|
| 45 |
+
* Amazon S3 backups support for mixed case bucket names
|
| 46 |
+
* Bulk Add Links has additional options
|
| 47 |
+
* Better Multisite support
|
| 48 |
+
* Option to set the number of items for Google Analytics
|
| 49 |
+
* ManageWP backup folder changed to wp-content/managewp/backups
|
| 50 |
+
|
| 51 |
= 3.9.9 =
|
| 52 |
* New widget on the dashboard - Backup status
|
| 53 |
* New screen for managing plugins and themes (activate, deactivate, delete, add to favorites, install) across all sites
|
stats.class.php
CHANGED
|
@@ -60,22 +60,46 @@ class MMB_Stats extends MMB_Core
|
|
| 60 |
function get_comments( $stats, $options = array() ){
|
| 61 |
|
| 62 |
$nposts = isset($options['numberposts']) ? (int) $options['numberposts'] : 20;
|
|
|
|
| 63 |
|
| 64 |
if( $nposts ){
|
| 65 |
-
$
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
}
|
| 70 |
-
$stats['comments']['pending'] = $pending_comments;
|
| 71 |
-
|
| 72 |
|
| 73 |
-
$
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
}
|
| 78 |
-
$stats['comments']['approved'] = $approved_comments;
|
| 79 |
}
|
| 80 |
return $stats;
|
| 81 |
}
|
|
@@ -85,35 +109,38 @@ class MMB_Stats extends MMB_Core
|
|
| 85 |
$nposts = isset($options['numberposts']) ? (int) $options['numberposts'] : 20;
|
| 86 |
|
| 87 |
if( $nposts ){
|
| 88 |
-
$
|
| 89 |
$recent_posts = array();
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
}
|
| 101 |
|
| 102 |
-
$
|
| 103 |
-
$recent_pages_published
|
| 104 |
-
|
| 105 |
-
$
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
}
|
| 115 |
-
usort($recent_posts, array($this, 'cmp_posts_worker'));
|
| 116 |
-
$stats['posts'] = array_slice($recent_posts, 0, $nposts);
|
| 117 |
}
|
| 118 |
return $stats;
|
| 119 |
}
|
|
@@ -123,33 +150,36 @@ class MMB_Stats extends MMB_Core
|
|
| 123 |
$nposts = isset($options['numberposts']) ? (int) $options['numberposts'] : 20;
|
| 124 |
|
| 125 |
if( $nposts ){
|
| 126 |
-
$
|
| 127 |
-
$recent_drafts
|
| 128 |
-
|
| 129 |
-
$
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
$
|
| 140 |
$recent_pages_drafts = array();
|
| 141 |
-
|
| 142 |
-
$
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
}
|
| 151 |
-
usort($recent_drafts, array($this, 'cmp_posts_worker'));
|
| 152 |
-
$stats['drafts'] = array_slice($recent_drafts, 0, $nposts);
|
| 153 |
}
|
| 154 |
return $stats;
|
| 155 |
}
|
|
@@ -159,32 +189,35 @@ class MMB_Stats extends MMB_Core
|
|
| 159 |
$nposts = isset($options['numberposts']) ? (int) $options['numberposts'] : 20;
|
| 160 |
|
| 161 |
if( $nposts ){
|
| 162 |
-
$
|
| 163 |
-
$scheduled_posts
|
| 164 |
-
|
| 165 |
-
$
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
|
|
|
| 172 |
}
|
| 173 |
-
|
| 174 |
-
$
|
| 175 |
-
$
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
}
|
| 186 |
-
usort($scheduled_posts, array($this, 'cmp_posts_worker'));
|
| 187 |
-
$stats['scheduled'] = array_slice($scheduled_posts, 0, $nposts);
|
| 188 |
}
|
| 189 |
return $stats;
|
| 190 |
}
|
|
@@ -193,25 +226,47 @@ class MMB_Stats extends MMB_Core
|
|
| 193 |
|
| 194 |
$stats['mwp_backups'] = $this->get_backup_instance()->get_backup_stats();
|
| 195 |
$stats['mwp_next_backups'] = $this->get_backup_instance()->get_next_schedules();
|
| 196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
|
| 198 |
return $stats;
|
| 199 |
}
|
| 200 |
|
| 201 |
function get_updates( $stats, $options = array() ){
|
| 202 |
|
|
|
|
|
|
|
| 203 |
if(isset($options['premium']) && $options['premium']){
|
| 204 |
$premium_updates = array();
|
| 205 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
}
|
| 207 |
if(isset($options['themes']) && $options['themes']){
|
| 208 |
$this->get_installer_instance();
|
| 209 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
}
|
| 211 |
|
| 212 |
if(isset($options['plugins']) && $options['plugins']){
|
| 213 |
$this->get_installer_instance();
|
| 214 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
}
|
| 216 |
|
| 217 |
return $stats;
|
|
@@ -254,7 +309,9 @@ class MMB_Stats extends MMB_Core
|
|
| 254 |
}
|
| 255 |
}
|
| 256 |
}
|
| 257 |
-
$
|
|
|
|
|
|
|
| 258 |
return $stats;
|
| 259 |
}
|
| 260 |
|
|
@@ -265,13 +322,13 @@ class MMB_Stats extends MMB_Core
|
|
| 265 |
include_once(ABSPATH . 'wp-includes/update.php');
|
| 266 |
include_once(ABSPATH . '/wp-admin/includes/update.php');
|
| 267 |
|
| 268 |
-
$stats = $this->mmb_parse_action_params( 'pre_init_stats', $params,
|
| 269 |
$num = extract($params);
|
| 270 |
|
| 271 |
if ($refresh == 'transient') {
|
| 272 |
$current = $this->mmb_get_transient('update_core');
|
| 273 |
if(isset($current->last_checked)){
|
| 274 |
-
if(time() - $current->last_checked >
|
| 275 |
@wp_version_check();
|
| 276 |
@wp_update_plugins();
|
| 277 |
@wp_update_themes();
|
|
@@ -299,12 +356,13 @@ class MMB_Stats extends MMB_Core
|
|
| 299 |
|
| 300 |
function get( $params )
|
| 301 |
{
|
|
|
|
| 302 |
global $wpdb, $mmb_wp_version, $mmb_plugin_dir, $_mmb_item_filter;
|
| 303 |
|
| 304 |
include_once(ABSPATH . 'wp-includes/update.php');
|
| 305 |
include_once(ABSPATH . '/wp-admin/includes/update.php');
|
| 306 |
|
| 307 |
-
$stats = $this->mmb_parse_action_params( 'get', $params,
|
| 308 |
$update_check = array();
|
| 309 |
$num = extract($params);
|
| 310 |
if ($refresh == 'transient') {
|
|
@@ -558,7 +616,7 @@ class MMB_Stats extends MMB_Core
|
|
| 558 |
|
| 559 |
$mwp_notifications = get_option('mwp_notifications',true);
|
| 560 |
$updates = array();
|
| 561 |
-
|
| 562 |
if(is_array($mwp_notifications) && $mwp_notifications != false){
|
| 563 |
include_once(ABSPATH . 'wp-includes/update.php');
|
| 564 |
include_once(ABSPATH . '/wp-admin/includes/update.php');
|
|
@@ -595,9 +653,7 @@ class MMB_Stats extends MMB_Core
|
|
| 595 |
|
| 596 |
$updates['upgradable_themes'] = $this->installer_instance->get_upgradable_themes();
|
| 597 |
}
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
if($backups){
|
| 602 |
$this->get_backup_instance();
|
| 603 |
$backups = $this->backup_instance->get_backup_stats();
|
|
@@ -616,9 +672,11 @@ class MMB_Stats extends MMB_Core
|
|
| 616 |
include_once( ABSPATH . WPINC. '/class-http.php' );
|
| 617 |
}
|
| 618 |
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
|
|
|
|
|
|
| 622 |
|
| 623 |
}
|
| 624 |
|
|
@@ -628,7 +686,17 @@ class MMB_Stats extends MMB_Core
|
|
| 628 |
|
| 629 |
function cmp_posts_worker($a, $b)
|
| 630 |
{
|
| 631 |
-
return ($a->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 632 |
}
|
| 633 |
|
| 634 |
}
|
| 60 |
function get_comments( $stats, $options = array() ){
|
| 61 |
|
| 62 |
$nposts = isset($options['numberposts']) ? (int) $options['numberposts'] : 20;
|
| 63 |
+
$trimlen = isset($options['trimcontent']) ? (int) $options['trimcontent'] : 200;
|
| 64 |
|
| 65 |
if( $nposts ){
|
| 66 |
+
$comments = get_comments('status=hold&number=' . $nposts);
|
| 67 |
+
if(!empty($comments)){
|
| 68 |
+
foreach ($comments as &$comment) {
|
| 69 |
+
$commented_post = get_post($comment->comment_post_ID);
|
| 70 |
+
$comment->post_title = $commented_post->post_title;
|
| 71 |
+
$comment->comment_content = $this->trim_content($comment->comment_content, $trimlen);
|
| 72 |
+
unset($comment->comment_author_url);
|
| 73 |
+
unset($comment->comment_author_email);
|
| 74 |
+
unset($comment->comment_author_IP);
|
| 75 |
+
unset($comment->comment_date_gmt);
|
| 76 |
+
unset($comment->comment_karma);
|
| 77 |
+
unset($comment->comment_agent);
|
| 78 |
+
unset($comment->comment_type);
|
| 79 |
+
unset($comment->comment_parent);
|
| 80 |
+
unset($comment->user_id);
|
| 81 |
+
}
|
| 82 |
+
$stats['comments']['pending'] = $comments;
|
| 83 |
}
|
|
|
|
|
|
|
| 84 |
|
| 85 |
+
$comments = get_comments('status=approve&number=' . $nposts);
|
| 86 |
+
if(!empty($comments)){
|
| 87 |
+
foreach ($comments as &$comment) {
|
| 88 |
+
$commented_post = get_post($comment->comment_post_ID);
|
| 89 |
+
$comment->post_title = $commented_post->post_title;
|
| 90 |
+
$comment->comment_content = $this->trim_content($comment->comment_content, $trimlen);
|
| 91 |
+
unset($comment->comment_author_url);
|
| 92 |
+
unset($comment->comment_author_email);
|
| 93 |
+
unset($comment->comment_author_IP);
|
| 94 |
+
unset($comment->comment_date_gmt);
|
| 95 |
+
unset($comment->comment_karma);
|
| 96 |
+
unset($comment->comment_agent);
|
| 97 |
+
unset($comment->comment_type);
|
| 98 |
+
unset($comment->comment_parent);
|
| 99 |
+
unset($comment->user_id);
|
| 100 |
+
}
|
| 101 |
+
$stats['comments']['approved'] = $comments;
|
| 102 |
}
|
|
|
|
| 103 |
}
|
| 104 |
return $stats;
|
| 105 |
}
|
| 109 |
$nposts = isset($options['numberposts']) ? (int) $options['numberposts'] : 20;
|
| 110 |
|
| 111 |
if( $nposts ){
|
| 112 |
+
$posts = get_posts('post_status=publish&numberposts='.$nposts.'&orderby=post_date&order=desc');
|
| 113 |
$recent_posts = array();
|
| 114 |
+
if(!empty($posts)){
|
| 115 |
+
foreach ($posts as $id => $recent_post) {
|
| 116 |
+
$recent = new stdClass();
|
| 117 |
+
$recent->post_permalink = get_permalink($recent_post->ID);
|
| 118 |
+
$recent->ID = $recent_post->ID;
|
| 119 |
+
$recent->post_date = $recent_post->post_date;
|
| 120 |
+
$recent->post_title = $recent_post->post_title;
|
| 121 |
+
$recent->comment_count = (int)$recent_post->comment_count;
|
| 122 |
+
$recent_posts[] = $recent;
|
| 123 |
+
}
|
| 124 |
}
|
| 125 |
|
| 126 |
+
$posts = get_pages('post_status=publish&numberposts='.$nposts.'&orderby=post_date&order=desc');
|
| 127 |
+
$recent_pages_published = array();
|
| 128 |
+
if(!empty($posts)){
|
| 129 |
+
foreach ((array)$posts as $id => $recent_page_published) {
|
| 130 |
+
$recent = new stdClass();
|
| 131 |
+
$recent->post_permalink = get_permalink($recent_page_published->ID);
|
| 132 |
+
|
| 133 |
+
$recent->ID = $recent_page_published->ID;
|
| 134 |
+
$recent->post_date = $recent_page_published->post_date;
|
| 135 |
+
$recent->post_title = $recent_page_published->post_title;
|
| 136 |
+
|
| 137 |
+
$recent_posts[] = $recent;
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
if(!empty($recent_posts)){
|
| 141 |
+
usort($recent_posts, array($this, 'cmp_posts_worker'));
|
| 142 |
+
$stats['posts'] = array_slice($recent_posts, 0, $nposts);
|
| 143 |
}
|
|
|
|
|
|
|
| 144 |
}
|
| 145 |
return $stats;
|
| 146 |
}
|
| 150 |
$nposts = isset($options['numberposts']) ? (int) $options['numberposts'] : 20;
|
| 151 |
|
| 152 |
if( $nposts ){
|
| 153 |
+
$drafts = get_posts('post_status=draft&numberposts='.$nposts.'&orderby=post_date&order=desc');
|
| 154 |
+
$recent_drafts = array();
|
| 155 |
+
if(!empty($drafts)){
|
| 156 |
+
foreach ($drafts as $id => $recent_draft) {
|
| 157 |
+
$recent = new stdClass();
|
| 158 |
+
$recent->post_permalink = get_permalink($recent_draft->ID);
|
| 159 |
+
$recent->ID = $recent_draft->ID;
|
| 160 |
+
$recent->post_date = $recent_draft->post_date;
|
| 161 |
+
$recent->post_title = $recent_draft->post_title;
|
| 162 |
+
|
| 163 |
+
$recent_drafts[] = $recent;
|
| 164 |
+
}
|
| 165 |
+
}
|
| 166 |
+
$drafts = get_pages('post_status=draft&numberposts='.$nposts.'&orderby=post_date&order=desc');
|
| 167 |
$recent_pages_drafts = array();
|
| 168 |
+
if(!empty($drafts)){
|
| 169 |
+
foreach ((array)$drafts as $id => $recent_pages_draft) {
|
| 170 |
+
$recent = new stdClass();
|
| 171 |
+
$recent->post_permalink = get_permalink($recent_pages_draft->ID);
|
| 172 |
+
$recent->ID = $recent_pages_draft->ID;
|
| 173 |
+
$recent->post_date = $recent_pages_draft->post_date;
|
| 174 |
+
$recent->post_title = $recent_pages_draft->post_title;
|
| 175 |
+
|
| 176 |
+
$recent_drafts[] = $recent;
|
| 177 |
+
}
|
| 178 |
+
}
|
| 179 |
+
if(!empty($recent_drafts)){
|
| 180 |
+
usort($recent_drafts, array($this, 'cmp_posts_worker'));
|
| 181 |
+
$stats['drafts'] = array_slice($recent_drafts, 0, $nposts);
|
| 182 |
}
|
|
|
|
|
|
|
| 183 |
}
|
| 184 |
return $stats;
|
| 185 |
}
|
| 189 |
$nposts = isset($options['numberposts']) ? (int) $options['numberposts'] : 20;
|
| 190 |
|
| 191 |
if( $nposts ){
|
| 192 |
+
$scheduled = get_posts('post_status=future&numberposts='.$nposts.'&orderby=post_date&order=desc');
|
| 193 |
+
$scheduled_posts = array();
|
| 194 |
+
if(!empty($scheduled)){
|
| 195 |
+
foreach ($scheduled as $id => $scheduled) {
|
| 196 |
+
$recent = new stdClass();
|
| 197 |
+
$recent->post_permalink = get_permalink($scheduled->ID);
|
| 198 |
+
$recent->ID = $scheduled->ID;
|
| 199 |
+
$recent->post_date = $scheduled->post_date;
|
| 200 |
+
$recent->post_title = $scheduled->post_title;
|
| 201 |
+
$scheduled_posts[] = $recent;
|
| 202 |
+
}
|
| 203 |
}
|
| 204 |
+
$scheduled = get_pages('post_status=future&numberposts='.$nposts.'&orderby=post_date&order=desc');
|
| 205 |
+
$recent_pages_drafts = array();
|
| 206 |
+
if(!empty($scheduled)){
|
| 207 |
+
foreach ((array)$scheduled as $id => $scheduled) {
|
| 208 |
+
$recent = new stdClass();
|
| 209 |
+
$recent->post_permalink = get_permalink($scheduled->ID);
|
| 210 |
+
$recent->ID = $scheduled->ID;
|
| 211 |
+
$recent->post_date = $scheduled->post_date;
|
| 212 |
+
$recent->post_title = $scheduled->post_title;
|
| 213 |
+
|
| 214 |
+
$scheduled_posts[] = $recent;
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
if(!empty($scheduled_posts)){
|
| 218 |
+
usort($scheduled_posts, array($this, 'cmp_posts_worker'));
|
| 219 |
+
$stats['scheduled'] = array_slice($scheduled_posts, 0, $nposts);
|
| 220 |
}
|
|
|
|
|
|
|
| 221 |
}
|
| 222 |
return $stats;
|
| 223 |
}
|
| 226 |
|
| 227 |
$stats['mwp_backups'] = $this->get_backup_instance()->get_backup_stats();
|
| 228 |
$stats['mwp_next_backups'] = $this->get_backup_instance()->get_next_schedules();
|
| 229 |
+
|
| 230 |
+
return $stats;
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
function get_backup_req( $stats = array(), $options = array() ){
|
| 234 |
+
|
| 235 |
+
$stats['mwp_backups'] = $this->get_backup_instance()->get_backup_stats();
|
| 236 |
+
$stats['mwp_next_backups'] = $this->get_backup_instance()->get_next_schedules();
|
| 237 |
+
$stats['mwp_backup_req'] = $this->get_backup_instance()->check_backup_compat();
|
| 238 |
|
| 239 |
return $stats;
|
| 240 |
}
|
| 241 |
|
| 242 |
function get_updates( $stats, $options = array() ){
|
| 243 |
|
| 244 |
+
$upgrades = false;
|
| 245 |
+
|
| 246 |
if(isset($options['premium']) && $options['premium']){
|
| 247 |
$premium_updates = array();
|
| 248 |
+
$upgrades = apply_filters('mwp_premium_update_notification', $premium_updates);
|
| 249 |
+
if(!empty($upgrades)){
|
| 250 |
+
$stats['premium_updates'] = $upgrades;
|
| 251 |
+
$upgrades = false;
|
| 252 |
+
}
|
| 253 |
}
|
| 254 |
if(isset($options['themes']) && $options['themes']){
|
| 255 |
$this->get_installer_instance();
|
| 256 |
+
$upgrades = $this->installer_instance->get_upgradable_themes();
|
| 257 |
+
if(!empty($upgrades)){
|
| 258 |
+
$stats['upgradable_themes'] = $upgrades;
|
| 259 |
+
$upgrades = false;
|
| 260 |
+
}
|
| 261 |
}
|
| 262 |
|
| 263 |
if(isset($options['plugins']) && $options['plugins']){
|
| 264 |
$this->get_installer_instance();
|
| 265 |
+
$upgrades = $this->installer_instance->get_upgradable_plugins();
|
| 266 |
+
if(!empty($upgrades)){
|
| 267 |
+
$stats['upgradable_plugins'] = $upgrades;
|
| 268 |
+
$upgrades = false;
|
| 269 |
+
}
|
| 270 |
}
|
| 271 |
|
| 272 |
return $stats;
|
| 309 |
}
|
| 310 |
}
|
| 311 |
}
|
| 312 |
+
if(!empty($errors))
|
| 313 |
+
$stats['errors'] = $errors;
|
| 314 |
+
|
| 315 |
return $stats;
|
| 316 |
}
|
| 317 |
|
| 322 |
include_once(ABSPATH . 'wp-includes/update.php');
|
| 323 |
include_once(ABSPATH . '/wp-admin/includes/update.php');
|
| 324 |
|
| 325 |
+
$stats = $this->mmb_parse_action_params( 'pre_init_stats', $params, $this );
|
| 326 |
$num = extract($params);
|
| 327 |
|
| 328 |
if ($refresh == 'transient') {
|
| 329 |
$current = $this->mmb_get_transient('update_core');
|
| 330 |
if(isset($current->last_checked)){
|
| 331 |
+
if(time() - $current->last_checked > 14400 ) {
|
| 332 |
@wp_version_check();
|
| 333 |
@wp_update_plugins();
|
| 334 |
@wp_update_themes();
|
| 356 |
|
| 357 |
function get( $params )
|
| 358 |
{
|
| 359 |
+
|
| 360 |
global $wpdb, $mmb_wp_version, $mmb_plugin_dir, $_mmb_item_filter;
|
| 361 |
|
| 362 |
include_once(ABSPATH . 'wp-includes/update.php');
|
| 363 |
include_once(ABSPATH . '/wp-admin/includes/update.php');
|
| 364 |
|
| 365 |
+
$stats = $this->mmb_parse_action_params( 'get', $params, $this );
|
| 366 |
$update_check = array();
|
| 367 |
$num = extract($params);
|
| 368 |
if ($refresh == 'transient') {
|
| 616 |
|
| 617 |
$mwp_notifications = get_option('mwp_notifications',true);
|
| 618 |
$updates = array();
|
| 619 |
+
|
| 620 |
if(is_array($mwp_notifications) && $mwp_notifications != false){
|
| 621 |
include_once(ABSPATH . 'wp-includes/update.php');
|
| 622 |
include_once(ABSPATH . '/wp-admin/includes/update.php');
|
| 653 |
|
| 654 |
$updates['upgradable_themes'] = $this->installer_instance->get_upgradable_themes();
|
| 655 |
}
|
| 656 |
+
|
|
|
|
|
|
|
| 657 |
if($backups){
|
| 658 |
$this->get_backup_instance();
|
| 659 |
$backups = $this->backup_instance->get_backup_stats();
|
| 672 |
include_once( ABSPATH . WPINC. '/class-http.php' );
|
| 673 |
}
|
| 674 |
|
| 675 |
+
if(!empty($updates)){
|
| 676 |
+
$args = array();
|
| 677 |
+
$args['body'] = array('updates' => $updates, 'notification_key' => $notification_key);
|
| 678 |
+
$result= wp_remote_post($url, $args);
|
| 679 |
+
}
|
| 680 |
|
| 681 |
}
|
| 682 |
|
| 686 |
|
| 687 |
function cmp_posts_worker($a, $b)
|
| 688 |
{
|
| 689 |
+
return ($a->post_date < $b->post_date);
|
| 690 |
+
}
|
| 691 |
+
|
| 692 |
+
function trim_content($content = '', $length = 200){
|
| 693 |
+
|
| 694 |
+
if( function_exists('mb_strlen') && function_exists('mb_substr') )
|
| 695 |
+
$content = (mb_strlen($content) > ($length + 3)) ? mb_substr($content, 0, $length) . '...' : $content;
|
| 696 |
+
else
|
| 697 |
+
$content = (strlen($content) > ($length + 3)) ? substr($content, 0, $length) . '...' : $content;
|
| 698 |
+
|
| 699 |
+
return $content;
|
| 700 |
}
|
| 701 |
|
| 702 |
}
|
version
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
3.9.
|
| 1 |
+
3.9.11
|
