Version Description
- Fixed remote dashboard problems for sites with redirects
- Fixed IE7 issues in the dashboard
Download this release
Release Info
| Developer | freediver |
| Plugin | |
| Version | 3.8.4 |
| Comparing to | |
| See all releases | |
Code changes from version 3.8.3 to 3.8.4
- backup.class.php +126 -101
- core.class.php +4 -3
- helper.class.php +20 -46
- init.php +13 -18
- plugin.class.php +2 -2
- post.class.php +4 -26
- readme.txt +6 -1
- stats.class.php +7 -4
- theme.class.php +3 -4
- version +1 -1
- wp.class.php +1 -27
backup.class.php
CHANGED
|
@@ -20,8 +20,8 @@ class MMB_Backup extends MMB_Core
|
|
| 20 |
$file_path = $upload_dir['basedir'] . $file;
|
| 21 |
file_put_contents($file_path . '/index.php', '');
|
| 22 |
if (!file_exists($file_path)) {
|
| 23 |
-
|
| 24 |
-
|
| 25 |
}
|
| 26 |
parent::__construct();
|
| 27 |
}
|
|
@@ -43,10 +43,11 @@ class MMB_Backup extends MMB_Core
|
|
| 43 |
$file_path = $upload_dir['basedir'] . $file;
|
| 44 |
|
| 45 |
if (!file_exists($file_path)) {
|
| 46 |
-
mkdir($file_path, 0755, true)
|
|
|
|
| 47 |
}
|
| 48 |
|
| 49 |
-
if (trim($what) == 'full'
|
| 50 |
//take wp-content backup
|
| 51 |
$content_backup = $this->backup_wpcontent($type);
|
| 52 |
if (!$content_backup) {
|
|
@@ -71,9 +72,9 @@ class MMB_Backup extends MMB_Core
|
|
| 71 |
}
|
| 72 |
}
|
| 73 |
|
| 74 |
-
|
| 75 |
|
| 76 |
-
// Get previous backup in tmp
|
| 77 |
$worker_options = get_option('mmb-worker');
|
| 78 |
$tmp_file = $upload_dir['basedir'] . '/' . basename($worker_options['backups'][$type]['path']);
|
| 79 |
|
|
@@ -81,6 +82,7 @@ class MMB_Backup extends MMB_Core
|
|
| 81 |
@unlink($worker_options['backups'][$type]['path']);
|
| 82 |
}
|
| 83 |
|
|
|
|
| 84 |
$site_name = $this->remove_http(get_bloginfo('url'));
|
| 85 |
$site_name = str_replace(array(
|
| 86 |
"_",
|
|
@@ -98,10 +100,17 @@ class MMB_Backup extends MMB_Core
|
|
| 98 |
if (trim($what) == 'full') {
|
| 99 |
$htaccess_path = ABSPATH . ".htaccess";
|
| 100 |
$wp_config_path = ABSPATH . "wp-config.php";
|
| 101 |
-
if ($this->check_zip()) {
|
| 102 |
$command = "zip $backup_file -j $content_backup[path] -j $db_backup[path] -j $htaccess_path -j $wp_config_path";
|
| 103 |
ob_start();
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
ob_get_clean();
|
| 106 |
} else {
|
| 107 |
$result = $archive->add($content_backup['path'], PCLZIP_OPT_REMOVE_ALL_PATH);
|
|
@@ -112,25 +121,22 @@ class MMB_Backup extends MMB_Core
|
|
| 112 |
}
|
| 113 |
|
| 114 |
} elseif (trim($what) == 'db') {
|
| 115 |
-
if ($this->check_zip()) {
|
| 116 |
$command = "zip $backup_file -j $db_backup[path]";
|
| 117 |
ob_start();
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
ob_get_clean();
|
| 120 |
} else {
|
| 121 |
$result = $archive->add($db_backup['path'], PCLZIP_OPT_REMOVE_ALL_PATH);
|
| 122 |
$err = !$result;
|
| 123 |
}
|
| 124 |
-
} elseif (trim($what) == 'content') {
|
| 125 |
-
if ($this->check_zip()) {
|
| 126 |
-
$command = "zip $backup_file -j $content_backup[path]";
|
| 127 |
-
ob_start();
|
| 128 |
-
passthru($command, $err);
|
| 129 |
-
ob_get_clean();
|
| 130 |
-
} else {
|
| 131 |
-
$result = $archive->add($content_backup['path'], PCLZIP_OPT_REMOVE_ALL_PATH);
|
| 132 |
-
$err = !$result;
|
| 133 |
-
}
|
| 134 |
}
|
| 135 |
|
| 136 |
if ($err) {
|
|
@@ -138,7 +144,7 @@ class MMB_Backup extends MMB_Core
|
|
| 138 |
@unlink($tmp_file);
|
| 139 |
}
|
| 140 |
return array(
|
| 141 |
-
'error' => 'Backup failed.'
|
| 142 |
);
|
| 143 |
}
|
| 144 |
|
|
@@ -156,7 +162,7 @@ class MMB_Backup extends MMB_Core
|
|
| 156 |
$worker_options['backups'][$type]['url'] = $backup_url;
|
| 157 |
update_option('mmb-worker', $worker_options);
|
| 158 |
|
| 159 |
-
|
| 160 |
return $worker_options['backups'][$type]['url'];
|
| 161 |
}
|
| 162 |
|
|
@@ -166,11 +172,18 @@ class MMB_Backup extends MMB_Core
|
|
| 166 |
$sec_string = md5('mmb-worker');
|
| 167 |
$file = '/' . $sec_string . '/backups/wp-content_' . date('Y-m-d') . '.zip';
|
| 168 |
$file_path = $upload_dir['basedir'] . $file;
|
| 169 |
-
if ($this->check_zip()) {
|
| 170 |
chdir(WP_CONTENT_DIR);
|
| 171 |
$command = "zip -r $file_path 'plugins/' 'themes/' 'uploads/' -x 'uploads/" . $sec_string . "/*'";
|
| 172 |
ob_start();
|
| 173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
ob_get_clean();
|
| 175 |
if (!$err || $err == 18) {
|
| 176 |
$file_url = $upload_dir['baseurl'] . $file;
|
|
@@ -188,7 +201,7 @@ class MMB_Backup extends MMB_Core
|
|
| 188 |
$result = $archive->add(WP_CONTENT_DIR . '/plugins', PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR);
|
| 189 |
$result = $archive->add(WP_CONTENT_DIR . '/themes', PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR);
|
| 190 |
$result = $archive->add(WP_CONTENT_DIR . '/uploads', PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR);
|
| 191 |
-
|
| 192 |
$result = $archive->delete(PCLZIP_OPT_BY_NAME, 'uploads/' . $sec_string . '/');
|
| 193 |
if ($result) {
|
| 194 |
$file_url = $upload_dir['baseurl'] . $file;
|
|
@@ -208,9 +221,8 @@ class MMB_Backup extends MMB_Core
|
|
| 208 |
$mysqldump_exists = $this->check_mysqldump();
|
| 209 |
|
| 210 |
|
| 211 |
-
if (is_array($mysqldump_exists)) {
|
| 212 |
-
|
| 213 |
-
|
| 214 |
$result = $this->backup_db_dump($type, $mysqldump_exists);
|
| 215 |
|
| 216 |
} else {
|
|
@@ -231,9 +243,16 @@ class MMB_Backup extends MMB_Core
|
|
| 231 |
$file_url = $upload_dir['baseurl'] . '/' . DB_NAME . '.sql';
|
| 232 |
|
| 233 |
$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;
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
|
| 238 |
if ($error) {
|
| 239 |
$result = $this->backup_db_php($type);
|
|
@@ -332,7 +351,8 @@ class MMB_Backup extends MMB_Core
|
|
| 332 |
// If manual backup - get backup file from master, if not - get backup file from worker
|
| 333 |
if ($type != 'weekly' && $type != 'daily') {
|
| 334 |
// Download backup file from master
|
| 335 |
-
|
|
|
|
| 336 |
$backup_file = $backup_path . "/" . basename($type);
|
| 337 |
if (rename($tmp_file, $backup_file)) {
|
| 338 |
@unlink($tmp_file);
|
|
@@ -347,13 +367,24 @@ class MMB_Backup extends MMB_Core
|
|
| 347 |
|
| 348 |
|
| 349 |
if ($backup_file) {
|
| 350 |
-
if ($this->check_unzip()) {
|
| 351 |
-
|
|
|
|
|
|
|
|
|
|
| 352 |
chdir($file_path);
|
| 353 |
$command = "unzip -o $backup_file";
|
| 354 |
ob_start();
|
| 355 |
-
|
| 356 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 357 |
} else {
|
| 358 |
require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
|
| 359 |
$archive = new PclZip($backup_file);
|
|
@@ -361,7 +392,6 @@ class MMB_Backup extends MMB_Core
|
|
| 361 |
$err = !$extracted;
|
| 362 |
}
|
| 363 |
|
| 364 |
-
|
| 365 |
if ($err) {
|
| 366 |
return array(
|
| 367 |
'error' => 'Error extracting backup file.'
|
|
@@ -378,9 +408,7 @@ class MMB_Backup extends MMB_Core
|
|
| 378 |
}
|
| 379 |
}
|
| 380 |
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
if (trim($what) == 'full' || trim($what) == 'content') {
|
| 384 |
if (!$this->restore_wpcontent($type, $file_path)) {
|
| 385 |
return array(
|
| 386 |
'error' => 'Error restoring wp-content.'
|
|
@@ -388,7 +416,13 @@ class MMB_Backup extends MMB_Core
|
|
| 388 |
}
|
| 389 |
}
|
| 390 |
|
| 391 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 392 |
}
|
| 393 |
|
| 394 |
return true;
|
|
@@ -400,27 +434,32 @@ class MMB_Backup extends MMB_Core
|
|
| 400 |
$content_file = glob($file_path . "/*.zip");
|
| 401 |
$wp_config_file = glob($file_path . "/wp-config.php");
|
| 402 |
$htaccess_file = glob($file_path . "/.htaccess");
|
| 403 |
-
if ($this->check_unzip()) {
|
|
|
|
| 404 |
chdir(WP_CONTENT_DIR);
|
| 405 |
$con_file = $content_file[0];
|
| 406 |
$command = "unzip -o $con_file";
|
| 407 |
ob_start();
|
| 408 |
-
|
| 409 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 410 |
} else {
|
| 411 |
$archive = new PclZip($content_file[0]);
|
| 412 |
$restore_content = $archive->extract(PCLZIP_OPT_PATH, WP_CONTENT_DIR, PCLZIP_OPT_REPLACE_NEWER);
|
| 413 |
$err = !$restore_content;
|
| 414 |
}
|
| 415 |
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
if (!rename($htaccess_file[0], ABSPATH . ".htaccess"))
|
| 419 |
-
$err = 1;
|
| 420 |
-
|
| 421 |
@unlink($wp_config_file[0]);
|
| 422 |
@unlink($htaccess_file[0]);
|
| 423 |
-
|
| 424 |
if ($err)
|
| 425 |
return false;
|
| 426 |
else
|
|
@@ -433,13 +472,21 @@ class MMB_Backup extends MMB_Core
|
|
| 433 |
|
| 434 |
$mysqldump = $this->check_mysqldump();
|
| 435 |
|
| 436 |
-
if (is_array($mysqldump)) {
|
| 437 |
$brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
|
| 438 |
|
| 439 |
foreach (glob($file_path . '/*.sql') as $filename) {
|
| 440 |
$command = $brace . $mysqldump['mysql'] . $brace . ' --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" ' . DB_NAME . ' < ' . $brace . $filename . $brace;
|
| 441 |
-
|
| 442 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 443 |
break;
|
| 444 |
}
|
| 445 |
|
|
@@ -502,23 +549,17 @@ class MMB_Backup extends MMB_Core
|
|
| 502 |
}
|
| 503 |
}
|
| 504 |
|
| 505 |
-
|
| 506 |
-
function get_backup_details($args)
|
| 507 |
{
|
| 508 |
-
$
|
| 509 |
-
$
|
| 510 |
-
$type = $args[2];
|
| 511 |
-
if (trim($type) == '') {
|
| 512 |
-
return false;
|
| 513 |
-
}
|
| 514 |
-
|
| 515 |
-
$worker_options = get_option('mmb-worker');
|
| 516 |
-
$backup_file = $worker_options['backups'][$type]['url'];
|
| 517 |
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
|
|
|
|
|
|
| 522 |
}
|
| 523 |
|
| 524 |
### Function: Auto Detect MYSQL and MYSQL Dump Paths
|
|
@@ -556,27 +597,39 @@ class MMB_Backup extends MMB_Core
|
|
| 556 |
return false;
|
| 557 |
}
|
| 558 |
|
| 559 |
-
$
|
| 560 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 561 |
if (!function_exists('passthru')) {
|
| 562 |
$stats_function_disabled++;
|
|
|
|
|
|
|
| 563 |
}
|
|
|
|
| 564 |
if (!function_exists('system')) {
|
| 565 |
$stats_function_disabled++;
|
|
|
|
|
|
|
| 566 |
}
|
|
|
|
| 567 |
if (!function_exists('exec')) {
|
| 568 |
$stats_function_disabled++;
|
|
|
|
|
|
|
| 569 |
}
|
| 570 |
|
| 571 |
if ($stats_function_disabled == 3) {
|
| 572 |
return false;
|
| 573 |
}
|
| 574 |
|
| 575 |
-
|
| 576 |
-
}
|
| 577 |
|
| 578 |
function check_zip()
|
| 579 |
-
{
|
| 580 |
$zip = @exec('which zip');
|
| 581 |
return $zip ? true : false;
|
| 582 |
}
|
|
@@ -587,33 +640,5 @@ class MMB_Backup extends MMB_Core
|
|
| 587 |
return $zip ? true : false;
|
| 588 |
}
|
| 589 |
|
| 590 |
-
|
| 591 |
-
function mmb_download_url($url, $file_name)
|
| 592 |
-
{
|
| 593 |
-
$destination = fopen($file_name, 'wb');
|
| 594 |
-
$source = @fopen($url, "r");
|
| 595 |
-
|
| 596 |
-
while ($a = fread($source, 1024)) {
|
| 597 |
-
$ret = fwrite($destination, $a);
|
| 598 |
-
}
|
| 599 |
-
|
| 600 |
-
fclose($source);
|
| 601 |
-
fclose($destination);
|
| 602 |
-
return $file_name;
|
| 603 |
-
}
|
| 604 |
-
|
| 605 |
-
function optimize_tables()
|
| 606 |
-
{
|
| 607 |
-
global $wpdb;
|
| 608 |
-
$tables = $wpdb->get_col("SHOW TABLES");
|
| 609 |
-
|
| 610 |
-
foreach ($tables as $table_name) {
|
| 611 |
-
$table_string .= $table_name . ",";
|
| 612 |
-
}
|
| 613 |
-
$table_string = rtrim($table_string);
|
| 614 |
-
$optimize = $wpdb->query("OPTIMIZE TABLE $table_string");
|
| 615 |
-
return true;
|
| 616 |
-
}
|
| 617 |
-
|
| 618 |
}
|
| 619 |
?>
|
| 20 |
$file_path = $upload_dir['basedir'] . $file;
|
| 21 |
file_put_contents($file_path . '/index.php', '');
|
| 22 |
if (!file_exists($file_path)) {
|
| 23 |
+
if(!mkdir($file_path, 0755, true))
|
| 24 |
+
return array('error' => 'Failed to create backup folder.');
|
| 25 |
}
|
| 26 |
parent::__construct();
|
| 27 |
}
|
| 43 |
$file_path = $upload_dir['basedir'] . $file;
|
| 44 |
|
| 45 |
if (!file_exists($file_path)) {
|
| 46 |
+
if(!mkdir($file_path, 0755, true))
|
| 47 |
+
return array('error' => 'Failed to create backup folder.');
|
| 48 |
}
|
| 49 |
|
| 50 |
+
if (trim($what) == 'full') {
|
| 51 |
//take wp-content backup
|
| 52 |
$content_backup = $this->backup_wpcontent($type);
|
| 53 |
if (!$content_backup) {
|
| 72 |
}
|
| 73 |
}
|
| 74 |
|
| 75 |
+
include_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
|
| 76 |
|
| 77 |
+
// Get previous backup in tmp
|
| 78 |
$worker_options = get_option('mmb-worker');
|
| 79 |
$tmp_file = $upload_dir['basedir'] . '/' . basename($worker_options['backups'][$type]['path']);
|
| 80 |
|
| 82 |
@unlink($worker_options['backups'][$type]['path']);
|
| 83 |
}
|
| 84 |
|
| 85 |
+
//Prepare .zip file name
|
| 86 |
$site_name = $this->remove_http(get_bloginfo('url'));
|
| 87 |
$site_name = str_replace(array(
|
| 88 |
"_",
|
| 100 |
if (trim($what) == 'full') {
|
| 101 |
$htaccess_path = ABSPATH . ".htaccess";
|
| 102 |
$wp_config_path = ABSPATH . "wp-config.php";
|
| 103 |
+
if ($this->check_zip() && $this->check_sys()) {
|
| 104 |
$command = "zip $backup_file -j $content_backup[path] -j $db_backup[path] -j $htaccess_path -j $wp_config_path";
|
| 105 |
ob_start();
|
| 106 |
+
$func = $this->check_sys();
|
| 107 |
+
switch($func)
|
| 108 |
+
{
|
| 109 |
+
case 'passthru': passthru($command, $err); break;
|
| 110 |
+
case 'exec': exec($command); break;
|
| 111 |
+
case 'system': system($command); break;
|
| 112 |
+
default: break;
|
| 113 |
+
}
|
| 114 |
ob_get_clean();
|
| 115 |
} else {
|
| 116 |
$result = $archive->add($content_backup['path'], PCLZIP_OPT_REMOVE_ALL_PATH);
|
| 121 |
}
|
| 122 |
|
| 123 |
} elseif (trim($what) == 'db') {
|
| 124 |
+
if ($this->check_zip() && $this->check_sys()) {
|
| 125 |
$command = "zip $backup_file -j $db_backup[path]";
|
| 126 |
ob_start();
|
| 127 |
+
$func = $this->check_sys();
|
| 128 |
+
switch($func)
|
| 129 |
+
{
|
| 130 |
+
case 'passthru': passthru($command, $err); break;
|
| 131 |
+
case 'exec': exec($command); break;
|
| 132 |
+
case 'system': system($command); break;
|
| 133 |
+
default: break;
|
| 134 |
+
}
|
| 135 |
ob_get_clean();
|
| 136 |
} else {
|
| 137 |
$result = $archive->add($db_backup['path'], PCLZIP_OPT_REMOVE_ALL_PATH);
|
| 138 |
$err = !$result;
|
| 139 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
}
|
| 141 |
|
| 142 |
if ($err) {
|
| 144 |
@unlink($tmp_file);
|
| 145 |
}
|
| 146 |
return array(
|
| 147 |
+
'error' => 'Backup failed. Cannot create backup zip file.'
|
| 148 |
);
|
| 149 |
}
|
| 150 |
|
| 162 |
$worker_options['backups'][$type]['url'] = $backup_url;
|
| 163 |
update_option('mmb-worker', $worker_options);
|
| 164 |
|
| 165 |
+
//Everything went fine, return backup url to master
|
| 166 |
return $worker_options['backups'][$type]['url'];
|
| 167 |
}
|
| 168 |
|
| 172 |
$sec_string = md5('mmb-worker');
|
| 173 |
$file = '/' . $sec_string . '/backups/wp-content_' . date('Y-m-d') . '.zip';
|
| 174 |
$file_path = $upload_dir['basedir'] . $file;
|
| 175 |
+
if ($this->check_zip() && $this->check_sys()) {
|
| 176 |
chdir(WP_CONTENT_DIR);
|
| 177 |
$command = "zip -r $file_path 'plugins/' 'themes/' 'uploads/' -x 'uploads/" . $sec_string . "/*'";
|
| 178 |
ob_start();
|
| 179 |
+
$func = $this->check_sys();
|
| 180 |
+
switch($func)
|
| 181 |
+
{
|
| 182 |
+
case 'passthru': passthru($command, $err); break;
|
| 183 |
+
case 'exec': exec($command); break;
|
| 184 |
+
case 'system': system($command); break;
|
| 185 |
+
default: break;
|
| 186 |
+
}
|
| 187 |
ob_get_clean();
|
| 188 |
if (!$err || $err == 18) {
|
| 189 |
$file_url = $upload_dir['baseurl'] . $file;
|
| 201 |
$result = $archive->add(WP_CONTENT_DIR . '/plugins', PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR);
|
| 202 |
$result = $archive->add(WP_CONTENT_DIR . '/themes', PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR);
|
| 203 |
$result = $archive->add(WP_CONTENT_DIR . '/uploads', PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR);
|
| 204 |
+
|
| 205 |
$result = $archive->delete(PCLZIP_OPT_BY_NAME, 'uploads/' . $sec_string . '/');
|
| 206 |
if ($result) {
|
| 207 |
$file_url = $upload_dir['baseurl'] . $file;
|
| 221 |
$mysqldump_exists = $this->check_mysqldump();
|
| 222 |
|
| 223 |
|
| 224 |
+
if (is_array($mysqldump_exists) && $this->check_sys()) {
|
| 225 |
+
|
|
|
|
| 226 |
$result = $this->backup_db_dump($type, $mysqldump_exists);
|
| 227 |
|
| 228 |
} else {
|
| 243 |
$file_url = $upload_dir['baseurl'] . '/' . DB_NAME . '.sql';
|
| 244 |
|
| 245 |
$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;
|
| 246 |
+
ob_start();
|
| 247 |
+
$func = $this->check_sys();
|
| 248 |
+
switch($func)
|
| 249 |
+
{
|
| 250 |
+
case 'passthru': passthru($command, $error); break;
|
| 251 |
+
case 'exec': exec($command); break;
|
| 252 |
+
case 'system': system($command); break;
|
| 253 |
+
default: break;
|
| 254 |
+
}
|
| 255 |
+
ob_get_clean();
|
| 256 |
|
| 257 |
if ($error) {
|
| 258 |
$result = $this->backup_db_php($type);
|
| 351 |
// If manual backup - get backup file from master, if not - get backup file from worker
|
| 352 |
if ($type != 'weekly' && $type != 'daily') {
|
| 353 |
// Download backup file from master
|
| 354 |
+
include_once(ABSPATH . 'wp-admin/includes/file.php');
|
| 355 |
+
$tmp_file = download_url($type);
|
| 356 |
$backup_file = $backup_path . "/" . basename($type);
|
| 357 |
if (rename($tmp_file, $backup_file)) {
|
| 358 |
@unlink($tmp_file);
|
| 367 |
|
| 368 |
|
| 369 |
if ($backup_file) {
|
| 370 |
+
if ($this->check_unzip() && $this->check_sys()) {
|
| 371 |
+
|
| 372 |
+
if(!mkdir($file_path))
|
| 373 |
+
return array('error' => 'Failed to create restore folder.');
|
| 374 |
+
|
| 375 |
chdir($file_path);
|
| 376 |
$command = "unzip -o $backup_file";
|
| 377 |
ob_start();
|
| 378 |
+
$func = $this->check_sys();
|
| 379 |
+
switch($func)
|
| 380 |
+
{
|
| 381 |
+
case 'passthru': passthru($command, $err); break;
|
| 382 |
+
case 'exec': exec($command); break;
|
| 383 |
+
case 'system': system($command); break;
|
| 384 |
+
default: break;
|
| 385 |
+
}
|
| 386 |
+
ob_get_clean();
|
| 387 |
+
|
| 388 |
} else {
|
| 389 |
require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
|
| 390 |
$archive = new PclZip($backup_file);
|
| 392 |
$err = !$extracted;
|
| 393 |
}
|
| 394 |
|
|
|
|
| 395 |
if ($err) {
|
| 396 |
return array(
|
| 397 |
'error' => 'Error extracting backup file.'
|
| 408 |
}
|
| 409 |
}
|
| 410 |
|
| 411 |
+
if (trim($what) == 'full') {
|
|
|
|
|
|
|
| 412 |
if (!$this->restore_wpcontent($type, $file_path)) {
|
| 413 |
return array(
|
| 414 |
'error' => 'Error restoring wp-content.'
|
| 416 |
}
|
| 417 |
}
|
| 418 |
|
| 419 |
+
$this->delete_temp_dir($file_path);
|
| 420 |
+
}
|
| 421 |
+
else
|
| 422 |
+
{
|
| 423 |
+
return array(
|
| 424 |
+
'error' => 'Error restoring. Cannot find backup file.'
|
| 425 |
+
);
|
| 426 |
}
|
| 427 |
|
| 428 |
return true;
|
| 434 |
$content_file = glob($file_path . "/*.zip");
|
| 435 |
$wp_config_file = glob($file_path . "/wp-config.php");
|
| 436 |
$htaccess_file = glob($file_path . "/.htaccess");
|
| 437 |
+
if ($this->check_unzip() && $this->check_sys()) {
|
| 438 |
+
|
| 439 |
chdir(WP_CONTENT_DIR);
|
| 440 |
$con_file = $content_file[0];
|
| 441 |
$command = "unzip -o $con_file";
|
| 442 |
ob_start();
|
| 443 |
+
$func = $this->check_sys();
|
| 444 |
+
switch($func)
|
| 445 |
+
{
|
| 446 |
+
case 'passthru': passthru($command, $err); break;
|
| 447 |
+
case 'exec': exec($command); break;
|
| 448 |
+
case 'system': system($command); break;
|
| 449 |
+
default: break;
|
| 450 |
+
}
|
| 451 |
+
ob_get_clean();
|
| 452 |
} else {
|
| 453 |
$archive = new PclZip($content_file[0]);
|
| 454 |
$restore_content = $archive->extract(PCLZIP_OPT_PATH, WP_CONTENT_DIR, PCLZIP_OPT_REPLACE_NEWER);
|
| 455 |
$err = !$restore_content;
|
| 456 |
}
|
| 457 |
|
| 458 |
+
@rename($wp_config_file[0], ABSPATH . "wp-config.php");
|
| 459 |
+
@rename($htaccess_file[0], ABSPATH . ".htaccess");
|
|
|
|
|
|
|
|
|
|
| 460 |
@unlink($wp_config_file[0]);
|
| 461 |
@unlink($htaccess_file[0]);
|
| 462 |
+
|
| 463 |
if ($err)
|
| 464 |
return false;
|
| 465 |
else
|
| 472 |
|
| 473 |
$mysqldump = $this->check_mysqldump();
|
| 474 |
|
| 475 |
+
if (is_array($mysqldump) && $this->check_sys()) {
|
| 476 |
$brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
|
| 477 |
|
| 478 |
foreach (glob($file_path . '/*.sql') as $filename) {
|
| 479 |
$command = $brace . $mysqldump['mysql'] . $brace . ' --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" ' . DB_NAME . ' < ' . $brace . $filename . $brace;
|
| 480 |
+
ob_start();
|
| 481 |
+
$func = $this->check_sys();
|
| 482 |
+
switch($func)
|
| 483 |
+
{
|
| 484 |
+
case 'passthru': passthru($command, $error); break;
|
| 485 |
+
case 'exec': exec($command); break;
|
| 486 |
+
case 'system': system($command); break;
|
| 487 |
+
default: break;
|
| 488 |
+
}
|
| 489 |
+
ob_get_clean();
|
| 490 |
break;
|
| 491 |
}
|
| 492 |
|
| 549 |
}
|
| 550 |
}
|
| 551 |
|
| 552 |
+
function optimize_tables()
|
|
|
|
| 553 |
{
|
| 554 |
+
global $wpdb;
|
| 555 |
+
$tables = $wpdb->get_col("SHOW TABLES");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 556 |
|
| 557 |
+
foreach ($tables as $table_name) {
|
| 558 |
+
$table_string .= $table_name . ",";
|
| 559 |
+
}
|
| 560 |
+
$table_string = rtrim($table_string);
|
| 561 |
+
$optimize = $wpdb->query("OPTIMIZE TABLE $table_string");
|
| 562 |
+
return $optimize ? true : false;
|
| 563 |
}
|
| 564 |
|
| 565 |
### Function: Auto Detect MYSQL and MYSQL Dump Paths
|
| 597 |
return false;
|
| 598 |
}
|
| 599 |
|
| 600 |
+
return $paths;
|
| 601 |
+
}
|
| 602 |
+
|
| 603 |
+
//Check if passthru, system or exec functions exist
|
| 604 |
+
function check_sys()
|
| 605 |
+
{
|
| 606 |
+
$stats_function_disabled = 0;
|
| 607 |
if (!function_exists('passthru')) {
|
| 608 |
$stats_function_disabled++;
|
| 609 |
+
} else {
|
| 610 |
+
return 'passthru';
|
| 611 |
}
|
| 612 |
+
|
| 613 |
if (!function_exists('system')) {
|
| 614 |
$stats_function_disabled++;
|
| 615 |
+
} else {
|
| 616 |
+
return 'system';
|
| 617 |
}
|
| 618 |
+
|
| 619 |
if (!function_exists('exec')) {
|
| 620 |
$stats_function_disabled++;
|
| 621 |
+
} else {
|
| 622 |
+
return 'exec';
|
| 623 |
}
|
| 624 |
|
| 625 |
if ($stats_function_disabled == 3) {
|
| 626 |
return false;
|
| 627 |
}
|
| 628 |
|
| 629 |
+
}
|
|
|
|
| 630 |
|
| 631 |
function check_zip()
|
| 632 |
+
{
|
| 633 |
$zip = @exec('which zip');
|
| 634 |
return $zip ? true : false;
|
| 635 |
}
|
| 640 |
return $zip ? true : false;
|
| 641 |
}
|
| 642 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 643 |
}
|
| 644 |
?>
|
core.class.php
CHANGED
|
@@ -210,7 +210,7 @@ class MMB_Core extends MMB_Helper
|
|
| 210 |
* Saves the (modified) options into the database
|
| 211 |
*
|
| 212 |
*/
|
| 213 |
-
function
|
| 214 |
{
|
| 215 |
if (get_option($this->slug)) {
|
| 216 |
update_option($this->slug, $this->settings);
|
|
@@ -235,7 +235,7 @@ class MMB_Core extends MMB_Helper
|
|
| 235 |
*
|
| 236 |
* @param mixed $base_page
|
| 237 |
*/
|
| 238 |
-
function
|
| 239 |
{
|
| 240 |
$url = "$base_page?_wpnonce=" . wp_create_nonce($this->slug);
|
| 241 |
foreach ($params as $key => $value) {
|
|
@@ -293,12 +293,13 @@ class MMB_Core extends MMB_Helper
|
|
| 293 |
function automatic_login()
|
| 294 |
{
|
| 295 |
$where = ($_GET['mwp_goto']);
|
|
|
|
| 296 |
if (!is_user_logged_in() && $_GET['auto_login']) {
|
| 297 |
$signature = base64_decode($_GET['signature']);
|
| 298 |
$message_id = trim($_GET['message_id']);
|
| 299 |
$username = $_GET['username'];
|
| 300 |
|
| 301 |
-
$auth = $this->
|
| 302 |
if ($auth === true) {
|
| 303 |
$user = get_user_by('login', $username);
|
| 304 |
$user_id = $user->ID;
|
| 210 |
* Saves the (modified) options into the database
|
| 211 |
*
|
| 212 |
*/
|
| 213 |
+
function save_options()
|
| 214 |
{
|
| 215 |
if (get_option($this->slug)) {
|
| 216 |
update_option($this->slug, $this->settings);
|
| 235 |
*
|
| 236 |
* @param mixed $base_page
|
| 237 |
*/
|
| 238 |
+
function construct_url($params = array(), $base_page = 'index.php')
|
| 239 |
{
|
| 240 |
$url = "$base_page?_wpnonce=" . wp_create_nonce($this->slug);
|
| 241 |
foreach ($params as $key => $value) {
|
| 293 |
function automatic_login()
|
| 294 |
{
|
| 295 |
$where = ($_GET['mwp_goto']);
|
| 296 |
+
|
| 297 |
if (!is_user_logged_in() && $_GET['auto_login']) {
|
| 298 |
$signature = base64_decode($_GET['signature']);
|
| 299 |
$message_id = trim($_GET['message_id']);
|
| 300 |
$username = $_GET['username'];
|
| 301 |
|
| 302 |
+
$auth = $this->authenticate_message($where . $message_id, $signature, $message_id);
|
| 303 |
if ($auth === true) {
|
| 304 |
$user = get_user_by('login', $username);
|
| 305 |
$user_id = $user->ID;
|
helper.class.php
CHANGED
|
@@ -55,7 +55,7 @@ class MMB_Helper
|
|
| 55 |
* Initializes the file system
|
| 56 |
*
|
| 57 |
*/
|
| 58 |
-
function
|
| 59 |
{
|
| 60 |
global $wp_filesystem;
|
| 61 |
|
|
@@ -121,24 +121,12 @@ class MMB_Helper
|
|
| 121 |
delete_option('_site_transient_' . $option_name);
|
| 122 |
}
|
| 123 |
}
|
| 124 |
-
|
| 125 |
-
function
|
| 126 |
-
{
|
| 127 |
-
//do nothing
|
| 128 |
-
if (!ob_get_level())
|
| 129 |
-
ob_start(array(
|
| 130 |
-
$this,
|
| 131 |
-
'mmb_null_op_buffer'
|
| 132 |
-
));
|
| 133 |
-
return '';
|
| 134 |
-
}
|
| 135 |
-
|
| 136 |
-
function _deleteTempDir($directory)
|
| 137 |
{
|
| 138 |
if (substr($directory, -1) == "/") {
|
| 139 |
$directory = substr($directory, 0, -1);
|
| 140 |
}
|
| 141 |
-
// $this->_log($directory);
|
| 142 |
if (!file_exists($directory) || !is_dir($directory)) {
|
| 143 |
return false;
|
| 144 |
} elseif (!is_readable($directory)) {
|
|
@@ -151,7 +139,7 @@ class MMB_Helper
|
|
| 151 |
$path = $directory . "/" . $contents;
|
| 152 |
|
| 153 |
if (is_dir($path)) {
|
| 154 |
-
$this->
|
| 155 |
} else {
|
| 156 |
unlink($path);
|
| 157 |
}
|
|
@@ -163,15 +151,7 @@ class MMB_Helper
|
|
| 163 |
}
|
| 164 |
}
|
| 165 |
|
| 166 |
-
function
|
| 167 |
-
{
|
| 168 |
-
if (defined('FTP_PASS')) {
|
| 169 |
-
return true;
|
| 170 |
-
} else
|
| 171 |
-
return false;
|
| 172 |
-
}
|
| 173 |
-
|
| 174 |
-
function _set_worker_message_id($message_id = false)
|
| 175 |
{
|
| 176 |
if ($message_id) {
|
| 177 |
add_option('_action_message_id', $message_id) or update_option('_action_message_id', $message_id);
|
|
@@ -180,12 +160,12 @@ class MMB_Helper
|
|
| 180 |
return false;
|
| 181 |
}
|
| 182 |
|
| 183 |
-
function
|
| 184 |
{
|
| 185 |
return (int) get_option('_action_message_id');
|
| 186 |
}
|
| 187 |
|
| 188 |
-
function
|
| 189 |
{
|
| 190 |
if ($public_key && !get_option('_worker_public_key')) {
|
| 191 |
add_option('_worker_public_key', base64_encode($public_key));
|
|
@@ -194,28 +174,22 @@ class MMB_Helper
|
|
| 194 |
return false;
|
| 195 |
}
|
| 196 |
|
| 197 |
-
function
|
| 198 |
{
|
| 199 |
if (!get_option('_worker_public_key'))
|
| 200 |
return false;
|
| 201 |
return base64_decode(get_option('_worker_public_key'));
|
| 202 |
}
|
| 203 |
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
if (!get_option('_master_referer'))
|
| 207 |
-
return false;
|
| 208 |
-
return base64_decode(get_option('_master_referer'));
|
| 209 |
-
}
|
| 210 |
-
|
| 211 |
-
function _get_random_signature()
|
| 212 |
{
|
| 213 |
if (!get_option('_worker_nossl_key'))
|
| 214 |
return false;
|
| 215 |
return base64_decode(get_option('_worker_nossl_key'));
|
| 216 |
}
|
| 217 |
|
| 218 |
-
function
|
| 219 |
{
|
| 220 |
if ($random_key && !get_option('_worker_nossl_key')) {
|
| 221 |
add_option('_worker_nossl_key', base64_encode($random_key));
|
|
@@ -225,7 +199,7 @@ class MMB_Helper
|
|
| 225 |
}
|
| 226 |
|
| 227 |
|
| 228 |
-
function
|
| 229 |
{
|
| 230 |
if (!$data && !$signature) {
|
| 231 |
return array(
|
|
@@ -233,24 +207,24 @@ class MMB_Helper
|
|
| 233 |
);
|
| 234 |
}
|
| 235 |
|
| 236 |
-
$current_message = $this->
|
| 237 |
|
| 238 |
if ((int) $current_message > (int) $message_id)
|
| 239 |
return array(
|
| 240 |
'error' => 'Invalid message recieved. You can try to reinstall worker plugin and re-add the site to your account.'
|
| 241 |
);
|
| 242 |
|
| 243 |
-
$pl_key = $this->
|
| 244 |
if (!$pl_key) {
|
| 245 |
return array(
|
| 246 |
'error' => 'Authentication failed (public key). You can try to reinstall worker plugin and re-add the site to your account.'
|
| 247 |
);
|
| 248 |
}
|
| 249 |
|
| 250 |
-
if (function_exists('openssl_verify') && !$this->
|
| 251 |
$verify = openssl_verify($data, $signature, $pl_key);
|
| 252 |
if ($verify == 1) {
|
| 253 |
-
$message_id = $this->
|
| 254 |
return true;
|
| 255 |
} else if ($verify == 0) {
|
| 256 |
return array(
|
|
@@ -261,9 +235,9 @@ class MMB_Helper
|
|
| 261 |
'error' => 'Command not successful! Please try again.'
|
| 262 |
);
|
| 263 |
}
|
| 264 |
-
} else if ($this->
|
| 265 |
-
if (md5($data . $this->
|
| 266 |
-
$message_id = $this->
|
| 267 |
return true;
|
| 268 |
}
|
| 269 |
return array(
|
|
@@ -277,7 +251,7 @@ class MMB_Helper
|
|
| 277 |
);
|
| 278 |
}
|
| 279 |
|
| 280 |
-
function
|
| 281 |
{
|
| 282 |
global $wpdb;
|
| 283 |
if ($username) {
|
| 55 |
* Initializes the file system
|
| 56 |
*
|
| 57 |
*/
|
| 58 |
+
function init_filesystem()
|
| 59 |
{
|
| 60 |
global $wp_filesystem;
|
| 61 |
|
| 121 |
delete_option('_site_transient_' . $option_name);
|
| 122 |
}
|
| 123 |
}
|
| 124 |
+
|
| 125 |
+
function delete_temp_dir($directory)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
{
|
| 127 |
if (substr($directory, -1) == "/") {
|
| 128 |
$directory = substr($directory, 0, -1);
|
| 129 |
}
|
|
|
|
| 130 |
if (!file_exists($directory) || !is_dir($directory)) {
|
| 131 |
return false;
|
| 132 |
} elseif (!is_readable($directory)) {
|
| 139 |
$path = $directory . "/" . $contents;
|
| 140 |
|
| 141 |
if (is_dir($path)) {
|
| 142 |
+
$this->delete_temp_dir($path);
|
| 143 |
} else {
|
| 144 |
unlink($path);
|
| 145 |
}
|
| 151 |
}
|
| 152 |
}
|
| 153 |
|
| 154 |
+
function set_worker_message_id( $message_id = false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
{
|
| 156 |
if ($message_id) {
|
| 157 |
add_option('_action_message_id', $message_id) or update_option('_action_message_id', $message_id);
|
| 160 |
return false;
|
| 161 |
}
|
| 162 |
|
| 163 |
+
function get_worker_message_id()
|
| 164 |
{
|
| 165 |
return (int) get_option('_action_message_id');
|
| 166 |
}
|
| 167 |
|
| 168 |
+
function set_master_public_key($public_key = false)
|
| 169 |
{
|
| 170 |
if ($public_key && !get_option('_worker_public_key')) {
|
| 171 |
add_option('_worker_public_key', base64_encode($public_key));
|
| 174 |
return false;
|
| 175 |
}
|
| 176 |
|
| 177 |
+
function get_master_public_key()
|
| 178 |
{
|
| 179 |
if (!get_option('_worker_public_key'))
|
| 180 |
return false;
|
| 181 |
return base64_decode(get_option('_worker_public_key'));
|
| 182 |
}
|
| 183 |
|
| 184 |
+
|
| 185 |
+
function get_random_signature()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
{
|
| 187 |
if (!get_option('_worker_nossl_key'))
|
| 188 |
return false;
|
| 189 |
return base64_decode(get_option('_worker_nossl_key'));
|
| 190 |
}
|
| 191 |
|
| 192 |
+
function set_random_signature($random_key = false)
|
| 193 |
{
|
| 194 |
if ($random_key && !get_option('_worker_nossl_key')) {
|
| 195 |
add_option('_worker_nossl_key', base64_encode($random_key));
|
| 199 |
}
|
| 200 |
|
| 201 |
|
| 202 |
+
function authenticate_message($data = false, $signature = false, $message_id = false)
|
| 203 |
{
|
| 204 |
if (!$data && !$signature) {
|
| 205 |
return array(
|
| 207 |
);
|
| 208 |
}
|
| 209 |
|
| 210 |
+
$current_message = $this->get_worker_message_id();
|
| 211 |
|
| 212 |
if ((int) $current_message > (int) $message_id)
|
| 213 |
return array(
|
| 214 |
'error' => 'Invalid message recieved. You can try to reinstall worker plugin and re-add the site to your account.'
|
| 215 |
);
|
| 216 |
|
| 217 |
+
$pl_key = $this->get_master_public_key();
|
| 218 |
if (!$pl_key) {
|
| 219 |
return array(
|
| 220 |
'error' => 'Authentication failed (public key). You can try to reinstall worker plugin and re-add the site to your account.'
|
| 221 |
);
|
| 222 |
}
|
| 223 |
|
| 224 |
+
if (function_exists('openssl_verify') && !$this->get_random_signature()) {
|
| 225 |
$verify = openssl_verify($data, $signature, $pl_key);
|
| 226 |
if ($verify == 1) {
|
| 227 |
+
$message_id = $this->set_worker_message_id( $message_id);
|
| 228 |
return true;
|
| 229 |
} else if ($verify == 0) {
|
| 230 |
return array(
|
| 235 |
'error' => 'Command not successful! Please try again.'
|
| 236 |
);
|
| 237 |
}
|
| 238 |
+
} else if ($this->get_random_signature()) {
|
| 239 |
+
if (md5($data . $this->get_random_signature()) == $signature) {
|
| 240 |
+
$message_id = $this->set_worker_message_id( $message_id);
|
| 241 |
return true;
|
| 242 |
}
|
| 243 |
return array(
|
| 251 |
);
|
| 252 |
}
|
| 253 |
|
| 254 |
+
function check_if_user_exists($username = false)
|
| 255 |
{
|
| 256 |
global $wpdb;
|
| 257 |
if ($username) {
|
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
|
| 6 |
Author: Prelovac Media
|
| 7 |
-
Version: 3.8.
|
| 8 |
Author URI: http://www.prelovac.com
|
| 9 |
*/
|
| 10 |
|
|
@@ -19,12 +19,8 @@ Author URI: http://www.prelovac.com
|
|
| 19 |
* www.prelovac.com
|
| 20 |
**************************************************************/
|
| 21 |
|
| 22 |
-
// PHP warnings can break our XML stuffs
|
| 23 |
-
if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
|
| 24 |
-
error_reporting(E_ERROR);
|
| 25 |
-
}
|
| 26 |
|
| 27 |
-
define('MMB_WORKER_VERSION', '3.8.
|
| 28 |
|
| 29 |
global $wpdb, $mmb_plugin_dir, $mmb_plugin_url;
|
| 30 |
|
|
@@ -42,7 +38,7 @@ require_once("$mmb_plugin_dir/stats.class.php");
|
|
| 42 |
require_once("$mmb_plugin_dir/backup.class.php");
|
| 43 |
|
| 44 |
$mmb_core = new MMB_Core();
|
| 45 |
-
add_action('init', '
|
| 46 |
|
| 47 |
if (function_exists('register_activation_hook'))
|
| 48 |
register_activation_hook(__FILE__, array(
|
|
@@ -56,7 +52,7 @@ if (function_exists('register_deactivation_hook'))
|
|
| 56 |
'uninstall'
|
| 57 |
));
|
| 58 |
|
| 59 |
-
function
|
| 60 |
{
|
| 61 |
if (!isset($HTTP_RAW_POST_DATA)) {
|
| 62 |
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
|
|
@@ -68,7 +64,7 @@ function _mmb_parse_request()
|
|
| 68 |
$num = extract(unserialize($data));
|
| 69 |
|
| 70 |
if ($action) {
|
| 71 |
-
if (!$mmb_core->
|
| 72 |
mmb_response('Username <b>' . $params['username'] . '</b> does not have administrator capabilities. Enter the correct username in the site options.', false);
|
| 73 |
|
| 74 |
if ($action == 'add_site') {
|
|
@@ -76,7 +72,7 @@ function _mmb_parse_request()
|
|
| 76 |
mmb_response('You should never see this.', false);
|
| 77 |
}
|
| 78 |
|
| 79 |
-
$auth = $mmb_core->
|
| 80 |
if ($auth === true) {
|
| 81 |
$mmb_actions = array(
|
| 82 |
'remove_site' => 'mmb_remove_site',
|
|
@@ -136,8 +132,8 @@ function mmb_add_site($params)
|
|
| 136 |
if (function_exists('openssl_verify')) {
|
| 137 |
$verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
|
| 138 |
if ($verify == 1) {
|
| 139 |
-
$mmb_core->
|
| 140 |
-
$mmb_core->
|
| 141 |
|
| 142 |
mmb_response($mmb_core->get_stats_instance()->get_initial_stats(), true);
|
| 143 |
} else if ($verify == 0) {
|
|
@@ -150,9 +146,9 @@ function mmb_add_site($params)
|
|
| 150 |
srand();
|
| 151 |
$random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
|
| 152 |
|
| 153 |
-
$mmb_core->
|
| 154 |
-
$mmb_core->
|
| 155 |
-
$mmb_core->
|
| 156 |
mmb_response($mmb_core->get_stats_instance()->get_initial_stats(), true);
|
| 157 |
} else
|
| 158 |
mmb_response('Please deactivate & activate ManageWP Worker plugin on your site, then re-add the site to your dashboard.', false);
|
|
@@ -253,15 +249,14 @@ function mmb_post_create($params)
|
|
| 253 |
function mmb_backup_now($params)
|
| 254 |
{
|
| 255 |
global $mmb_core;
|
|
|
|
| 256 |
$return = $mmb_core->get_backup_instance()->backup($params);
|
| 257 |
|
| 258 |
if (is_array($return) && array_key_exists('error', $return))
|
| 259 |
mmb_response($return['error'], false);
|
| 260 |
else {
|
| 261 |
-
$mmb_core->_log($return);
|
| 262 |
mmb_response($return, true);
|
| 263 |
-
}
|
| 264 |
-
|
| 265 |
}
|
| 266 |
|
| 267 |
function mmb_optimize_tables($params)
|
| 4 |
Plugin URI: http://managewp.com/
|
| 5 |
Description: Manage all your blogs from one dashboard
|
| 6 |
Author: Prelovac Media
|
| 7 |
+
Version: 3.8.4
|
| 8 |
Author URI: http://www.prelovac.com
|
| 9 |
*/
|
| 10 |
|
| 19 |
* www.prelovac.com
|
| 20 |
**************************************************************/
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
define('MMB_WORKER_VERSION', '3.8.4');
|
| 24 |
|
| 25 |
global $wpdb, $mmb_plugin_dir, $mmb_plugin_url;
|
| 26 |
|
| 38 |
require_once("$mmb_plugin_dir/backup.class.php");
|
| 39 |
|
| 40 |
$mmb_core = new MMB_Core();
|
| 41 |
+
add_action('init', 'mmb_parse_request');
|
| 42 |
|
| 43 |
if (function_exists('register_activation_hook'))
|
| 44 |
register_activation_hook(__FILE__, array(
|
| 52 |
'uninstall'
|
| 53 |
));
|
| 54 |
|
| 55 |
+
function mmb_parse_request()
|
| 56 |
{
|
| 57 |
if (!isset($HTTP_RAW_POST_DATA)) {
|
| 58 |
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
|
| 64 |
$num = extract(unserialize($data));
|
| 65 |
|
| 66 |
if ($action) {
|
| 67 |
+
if (!$mmb_core->check_if_user_exists($params['username']))
|
| 68 |
mmb_response('Username <b>' . $params['username'] . '</b> does not have administrator capabilities. Enter the correct username in the site options.', false);
|
| 69 |
|
| 70 |
if ($action == 'add_site') {
|
| 72 |
mmb_response('You should never see this.', false);
|
| 73 |
}
|
| 74 |
|
| 75 |
+
$auth = $mmb_core->authenticate_message($action . $id, $signature, $id);
|
| 76 |
if ($auth === true) {
|
| 77 |
$mmb_actions = array(
|
| 78 |
'remove_site' => 'mmb_remove_site',
|
| 132 |
if (function_exists('openssl_verify')) {
|
| 133 |
$verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
|
| 134 |
if ($verify == 1) {
|
| 135 |
+
$mmb_core->set_master_public_key($public_key);
|
| 136 |
+
$mmb_core->set_worker_message_id( $id);
|
| 137 |
|
| 138 |
mmb_response($mmb_core->get_stats_instance()->get_initial_stats(), true);
|
| 139 |
} else if ($verify == 0) {
|
| 146 |
srand();
|
| 147 |
$random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
|
| 148 |
|
| 149 |
+
$mmb_core->set_random_signature($random_key);
|
| 150 |
+
$mmb_core->set_worker_message_id( $id);
|
| 151 |
+
$mmb_core->set_master_public_key($public_key);
|
| 152 |
mmb_response($mmb_core->get_stats_instance()->get_initial_stats(), true);
|
| 153 |
} else
|
| 154 |
mmb_response('Please deactivate & activate ManageWP Worker plugin on your site, then re-add the site to your dashboard.', false);
|
| 249 |
function mmb_backup_now($params)
|
| 250 |
{
|
| 251 |
global $mmb_core;
|
| 252 |
+
|
| 253 |
$return = $mmb_core->get_backup_instance()->backup($params);
|
| 254 |
|
| 255 |
if (is_array($return) && array_key_exists('error', $return))
|
| 256 |
mmb_response($return['error'], false);
|
| 257 |
else {
|
|
|
|
| 258 |
mmb_response($return, true);
|
| 259 |
+
}
|
|
|
|
| 260 |
}
|
| 261 |
|
| 262 |
function mmb_optimize_tables($params)
|
plugin.class.php
CHANGED
|
@@ -24,7 +24,7 @@ class MMB_Plugin extends MMB_Core
|
|
| 24 |
*/
|
| 25 |
function upgrade_all($params)
|
| 26 |
{
|
| 27 |
-
$upgradable_plugins = $this->
|
| 28 |
|
| 29 |
$ready_for_upgrade = array();
|
| 30 |
if (!empty($upgradable_plugins)) {
|
|
@@ -137,7 +137,7 @@ class MMB_Plugin extends MMB_Core
|
|
| 137 |
|
| 138 |
}
|
| 139 |
|
| 140 |
-
function
|
| 141 |
{
|
| 142 |
$current = $this->mmb_get_transient('update_plugins');
|
| 143 |
$upgradable_plugins = array();
|
| 24 |
*/
|
| 25 |
function upgrade_all($params)
|
| 26 |
{
|
| 27 |
+
$upgradable_plugins = $this->get_upgradable_plugins();
|
| 28 |
|
| 29 |
$ready_for_upgrade = array();
|
| 30 |
if (!empty($upgradable_plugins)) {
|
| 137 |
|
| 138 |
}
|
| 139 |
|
| 140 |
+
function get_upgradable_plugins()
|
| 141 |
{
|
| 142 |
$current = $this->mmb_get_transient('update_plugins');
|
| 143 |
$upgradable_plugins = array();
|
post.class.php
CHANGED
|
@@ -28,6 +28,7 @@ class MMB_Post extends MMB_Core
|
|
| 28 |
|
| 29 |
include_once ABSPATH . 'wp-admin/includes/taxonomy.php';
|
| 30 |
include_once ABSPATH . 'wp-admin/includes/image.php';
|
|
|
|
| 31 |
|
| 32 |
$post_struct = $args['post_data'];
|
| 33 |
|
|
@@ -120,10 +121,7 @@ class MMB_Post extends MMB_Core
|
|
| 120 |
$no_thumb = $get_url[4];
|
| 121 |
}
|
| 122 |
$file_name = basename($no_thumb);
|
| 123 |
-
|
| 124 |
-
//$tmp_file = $upload['path'].'/tempfile.tmp';
|
| 125 |
-
$tmp_file = $this->mmb_download_url($no_thumb, $upload['path'] . '/tempfile' . md5(time()) . '.tmp');
|
| 126 |
-
//$tmp_file = download_url($no_thumb);
|
| 127 |
|
| 128 |
$attach_upload['url'] = $upload['url'] . '/' . $file_name;
|
| 129 |
$attach_upload['path'] = $upload['path'] . '/' . $file_name;
|
|
@@ -207,12 +205,7 @@ class MMB_Post extends MMB_Core
|
|
| 207 |
if (count($post_atta_img)) {
|
| 208 |
foreach ($post_atta_img as $img) {
|
| 209 |
$file_name = basename($img['src']);
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
$tmp_file = $this->mmb_download_url($img['src'], $upload['path'] . '/tempfile.tmp');
|
| 213 |
-
|
| 214 |
-
//$tmp_file = download_url($img['src']);
|
| 215 |
-
|
| 216 |
$attach_upload['url'] = $upload['url'] . '/' . $file_name;
|
| 217 |
$attach_upload['path'] = $upload['path'] . '/' . $file_name;
|
| 218 |
$renamed = @rename($tmp_file, $attach_upload['path']);
|
|
@@ -274,8 +267,7 @@ class MMB_Post extends MMB_Core
|
|
| 274 |
// featured image
|
| 275 |
if ($post_featured_img != '') {
|
| 276 |
$file_name = basename($post_featured_img);
|
| 277 |
-
|
| 278 |
-
$tmp_file = $this->mmb_download_url($no_thumb, $upload['path'] . '/tempfile_feat.tmp');
|
| 279 |
$attach_upload['url'] = $upload['url'] . '/' . $file_name;
|
| 280 |
$attach_upload['path'] = $upload['path'] . '/' . $file_name;
|
| 281 |
$renamed = @rename($tmp_file, $attach_upload['path']);
|
|
@@ -328,19 +320,5 @@ class MMB_Post extends MMB_Core
|
|
| 328 |
return $post_id;
|
| 329 |
}
|
| 330 |
|
| 331 |
-
/**
|
| 332 |
-
* Aleternate function for WordPress download_url()
|
| 333 |
-
*/
|
| 334 |
-
function mmb_download_url($url, $file_name)
|
| 335 |
-
{
|
| 336 |
-
$destination = fopen($file_name, 'wb');
|
| 337 |
-
$source = @fopen($url, "r");
|
| 338 |
-
while ($a = fread($source, 1024)) {
|
| 339 |
-
$ret = fwrite($destination, $a);
|
| 340 |
-
}
|
| 341 |
-
fclose($source);
|
| 342 |
-
fclose($destination);
|
| 343 |
-
return $file_name;
|
| 344 |
-
}
|
| 345 |
}
|
| 346 |
?>
|
| 28 |
|
| 29 |
include_once ABSPATH . 'wp-admin/includes/taxonomy.php';
|
| 30 |
include_once ABSPATH . 'wp-admin/includes/image.php';
|
| 31 |
+
include_once ABSPATH . 'wp-admin/includes/file.php';
|
| 32 |
|
| 33 |
$post_struct = $args['post_data'];
|
| 34 |
|
| 121 |
$no_thumb = $get_url[4];
|
| 122 |
}
|
| 123 |
$file_name = basename($no_thumb);
|
| 124 |
+
$tmp_file = download_url($no_thumb);
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
$attach_upload['url'] = $upload['url'] . '/' . $file_name;
|
| 127 |
$attach_upload['path'] = $upload['path'] . '/' . $file_name;
|
| 205 |
if (count($post_atta_img)) {
|
| 206 |
foreach ($post_atta_img as $img) {
|
| 207 |
$file_name = basename($img['src']);
|
| 208 |
+
$tmp_file = download_url($img['src']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
$attach_upload['url'] = $upload['url'] . '/' . $file_name;
|
| 210 |
$attach_upload['path'] = $upload['path'] . '/' . $file_name;
|
| 211 |
$renamed = @rename($tmp_file, $attach_upload['path']);
|
| 267 |
// featured image
|
| 268 |
if ($post_featured_img != '') {
|
| 269 |
$file_name = basename($post_featured_img);
|
| 270 |
+
$tmp_file = download_url($post_featured_img);
|
|
|
|
| 271 |
$attach_upload['url'] = $upload['url'] . '/' . $file_name;
|
| 272 |
$attach_upload['path'] = $upload['path'] . '/' . $file_name;
|
| 273 |
$renamed = @rename($tmp_file, $attach_upload['path']);
|
| 320 |
return $post_id;
|
| 321 |
}
|
| 322 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
}
|
| 324 |
?>
|
readme.txt
CHANGED
|
@@ -14,6 +14,7 @@ ManageWP is a revolutionary plugin that allows you to manage multiple WordPress
|
|
| 14 |
|
| 15 |
Main features:
|
| 16 |
|
|
|
|
| 17 |
* One click upgrades of WordPress, plugin and themes across all your sites
|
| 18 |
* One click to access administration dashboard for any site
|
| 19 |
* Bulk publish posts to multiple sites at once
|
|
@@ -26,6 +27,10 @@ Check out [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs")
|
|
| 26 |
|
| 27 |
== Changelog ==
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
= 3.8.3 =
|
| 30 |
* Fixed problem with capabilities
|
| 31 |
|
|
@@ -48,7 +53,7 @@ Check out [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs")
|
|
| 48 |
Alternately
|
| 49 |
|
| 50 |
1. Visit [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs"), sign up and add your site
|
| 51 |
-
2. ManageWP
|
| 52 |
|
| 53 |
== Screenshots ==
|
| 54 |
|
| 14 |
|
| 15 |
Main features:
|
| 16 |
|
| 17 |
+
* Secure! No passwords for sites required, uses OpenSSL encrypted protocol
|
| 18 |
* One click upgrades of WordPress, plugin and themes across all your sites
|
| 19 |
* One click to access administration dashboard for any site
|
| 20 |
* Bulk publish posts to multiple sites at once
|
| 27 |
|
| 28 |
== Changelog ==
|
| 29 |
|
| 30 |
+
= 3.8.4 =
|
| 31 |
+
* Fixed remote dashboard problems for sites with redirects
|
| 32 |
+
* Fixed IE7 issues in the dashboard
|
| 33 |
+
|
| 34 |
= 3.8.3 =
|
| 35 |
* Fixed problem with capabilities
|
| 36 |
|
| 53 |
Alternately
|
| 54 |
|
| 55 |
1. Visit [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs"), sign up and add your site
|
| 56 |
+
2. ManageWP will warn you the worker plugin is not installed and offer a link for quick installation
|
| 57 |
|
| 58 |
== Screenshots ==
|
| 59 |
|
stats.class.php
CHANGED
|
@@ -37,7 +37,8 @@ class MMB_Stats extends MMB_Core
|
|
| 37 |
|
| 38 |
require_once(ABSPATH . '/wp-admin/includes/update.php');
|
| 39 |
|
| 40 |
-
|
|
|
|
| 41 |
$updates = $this->mmb_get_transient('update_core');
|
| 42 |
|
| 43 |
if ($updates->updates[0]->response == 'development' || version_compare($wp_version, $updates->updates[0]->current, '<')) {
|
|
@@ -56,8 +57,9 @@ class MMB_Stats extends MMB_Core
|
|
| 56 |
}
|
| 57 |
$stats['hit_counter'] = get_option('user_hit_count');
|
| 58 |
|
| 59 |
-
|
| 60 |
-
$stats['
|
|
|
|
| 61 |
|
| 62 |
$pending_comments = get_comments('status=hold&number=' . $num_pending_comments);
|
| 63 |
foreach ($pending_comments as &$comment) {
|
|
@@ -136,12 +138,13 @@ class MMB_Stats extends MMB_Core
|
|
| 136 |
$stats = array();
|
| 137 |
|
| 138 |
$stats['email'] = get_option('admin_email');
|
| 139 |
-
$stats['no_openssl'] = $this->
|
| 140 |
$stats['content_path'] = WP_CONTENT_DIR;
|
| 141 |
$stats['worker_path'] = $mmb_plugin_dir;
|
| 142 |
$stats['worker_version'] = MMB_WORKER_VERSION;
|
| 143 |
$stats['site_title'] = get_bloginfo('name');
|
| 144 |
$stats['site_tagline'] = get_bloginfo('description');
|
|
|
|
| 145 |
|
| 146 |
|
| 147 |
if ((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && !is_writable(WP_CONTENT_DIR)) {
|
| 37 |
|
| 38 |
require_once(ABSPATH . '/wp-admin/includes/update.php');
|
| 39 |
|
| 40 |
+
$stats['worker_version'] = MMB_WORKER_VERSION;
|
| 41 |
+
|
| 42 |
$updates = $this->mmb_get_transient('update_core');
|
| 43 |
|
| 44 |
if ($updates->updates[0]->response == 'development' || version_compare($wp_version, $updates->updates[0]->current, '<')) {
|
| 57 |
}
|
| 58 |
$stats['hit_counter'] = get_option('user_hit_count');
|
| 59 |
|
| 60 |
+
|
| 61 |
+
$stats['upgradable_themes'] = $this->get_theme_instance()->get_upgradable_themes();
|
| 62 |
+
$stats['upgradable_plugins'] = $this->get_plugin_instance()->get_upgradable_plugins();
|
| 63 |
|
| 64 |
$pending_comments = get_comments('status=hold&number=' . $num_pending_comments);
|
| 65 |
foreach ($pending_comments as &$comment) {
|
| 138 |
$stats = array();
|
| 139 |
|
| 140 |
$stats['email'] = get_option('admin_email');
|
| 141 |
+
$stats['no_openssl'] = $this->get_random_signature();
|
| 142 |
$stats['content_path'] = WP_CONTENT_DIR;
|
| 143 |
$stats['worker_path'] = $mmb_plugin_dir;
|
| 144 |
$stats['worker_version'] = MMB_WORKER_VERSION;
|
| 145 |
$stats['site_title'] = get_bloginfo('name');
|
| 146 |
$stats['site_tagline'] = get_bloginfo('description');
|
| 147 |
+
$stats['site_url'] = get_bloginfo('home');
|
| 148 |
|
| 149 |
|
| 150 |
if ((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && !is_writable(WP_CONTENT_DIR)) {
|
theme.class.php
CHANGED
|
@@ -10,8 +10,7 @@ class MMB_Theme extends MMB_Core
|
|
| 10 |
|
| 11 |
function upload_theme_by_url($args){
|
| 12 |
|
| 13 |
-
|
| 14 |
-
$url = $args['url'];
|
| 15 |
|
| 16 |
//return (print_r($args, true));
|
| 17 |
ob_start();
|
|
@@ -39,7 +38,7 @@ class MMB_Theme extends MMB_Core
|
|
| 39 |
|
| 40 |
function upgrade_all($params){
|
| 41 |
|
| 42 |
-
$upgradable_themes = $this->
|
| 43 |
|
| 44 |
$ready_for_upgrade = array();
|
| 45 |
if(!empty($upgradable_themes)){
|
|
@@ -73,7 +72,7 @@ class MMB_Theme extends MMB_Core
|
|
| 73 |
}
|
| 74 |
}
|
| 75 |
|
| 76 |
-
function
|
| 77 |
|
| 78 |
$all_themes = get_themes();
|
| 79 |
$upgrade_themes = array();
|
| 10 |
|
| 11 |
function upload_theme_by_url($args){
|
| 12 |
|
| 13 |
+
$url = $args['url'];
|
|
|
|
| 14 |
|
| 15 |
//return (print_r($args, true));
|
| 16 |
ob_start();
|
| 38 |
|
| 39 |
function upgrade_all($params){
|
| 40 |
|
| 41 |
+
$upgradable_themes = $this->get_upgradable_themes();
|
| 42 |
|
| 43 |
$ready_for_upgrade = array();
|
| 44 |
if(!empty($upgradable_themes)){
|
| 72 |
}
|
| 73 |
}
|
| 74 |
|
| 75 |
+
function get_upgradable_themes(){
|
| 76 |
|
| 77 |
$all_themes = get_themes();
|
| 78 |
$upgrade_themes = array();
|
version
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
3.8.
|
| 1 |
+
3.8.4
|
wp.class.php
CHANGED
|
@@ -15,33 +15,7 @@ class MMB_WP extends MMB_Core
|
|
| 15 |
{
|
| 16 |
parent::__construct();
|
| 17 |
}
|
| 18 |
-
|
| 19 |
-
/*************************************************************
|
| 20 |
-
* FACADE functions
|
| 21 |
-
* (functions to be called after a remote call from Master)
|
| 22 |
-
**************************************************************/
|
| 23 |
-
function check_version()
|
| 24 |
-
{
|
| 25 |
-
require_once(ABSPATH . 'wp-includes/version.php');
|
| 26 |
-
require_once(ABSPATH . '/wp-admin/includes/update.php');
|
| 27 |
-
|
| 28 |
-
$updates = get_core_updates();
|
| 29 |
-
$update = $updates[0];
|
| 30 |
-
global $wp_version;
|
| 31 |
-
|
| 32 |
-
if (!isset($update->response) || 'latest' == $update->response) {
|
| 33 |
-
return array(
|
| 34 |
-
'current_version' => $wp_version,
|
| 35 |
-
'latest_version' => false
|
| 36 |
-
);
|
| 37 |
-
} else {
|
| 38 |
-
return array(
|
| 39 |
-
'current_version' => $wp_version,
|
| 40 |
-
'latest_version' => $update
|
| 41 |
-
);
|
| 42 |
-
}
|
| 43 |
-
}
|
| 44 |
-
|
| 45 |
/**
|
| 46 |
* Upgrades WordPress locally
|
| 47 |
*
|
| 15 |
{
|
| 16 |
parent::__construct();
|
| 17 |
}
|
| 18 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
/**
|
| 20 |
* Upgrades WordPress locally
|
| 21 |
*
|
