Version Description
- Added seach websites feature
- Added improved dashboard information
- Added developer [API] (http://managewp.com/api "ManageWP API)
- Improved Migrate/Clone site feature
Download this release
Release Info
Developer | freediver |
Plugin | ManageWP Worker |
Version | 3.8.5 |
Comparing to | |
See all releases |
Code changes from version 3.8.4 to 3.8.5
- api.php +36 -0
- backup.class.php +21 -39
- core.class.php +40 -3
- helper.class.php +1 -1
- init.php +66 -23
- installer.class.php +162 -0
- plugin.class.php +0 -71
- plugins/cleanup/cleanup.php +161 -0
- plugins/extra_html_example/extra_html_example.php +18 -0
- plugins/search/search.php +88 -0
- readme.txt +6 -0
- stats.class.php +6 -2
- version +1 -1
api.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*************************************************************
|
3 |
+
*
|
4 |
+
* api.php
|
5 |
+
*
|
6 |
+
* ManageWP addons api
|
7 |
+
*
|
8 |
+
* Copyright (c) 2011 Prelovac Media
|
9 |
+
* www.prelovac.com
|
10 |
+
**************************************************************/
|
11 |
+
|
12 |
+
function mmb_add_action($action = false, $callback = false){
|
13 |
+
if(!$action || !$callback)
|
14 |
+
return false;
|
15 |
+
|
16 |
+
global $mmb_actions;
|
17 |
+
mmb_function_exists($callback);
|
18 |
+
|
19 |
+
if(isset($mmb_actions[$action]))
|
20 |
+
wp_die('Cannot redeclare ManageWP action "'.$action.'".');
|
21 |
+
|
22 |
+
$mmb_actions[$action] = $callback;
|
23 |
+
}
|
24 |
+
|
25 |
+
function mmb_function_exists($callback){
|
26 |
+
global $mwp_core;
|
27 |
+
if(count($callback) === 2){
|
28 |
+
if( !method_exists ( $callback[0], $callback[1] ) )
|
29 |
+
wp_die($mwp_core->mwp_dashboard_widget('Information', '', '<p>Class '.get_class($callback[0]).' does not contain <b>"'.$callback[1].'"</b> function</p>', '', '50%'));
|
30 |
+
}else {
|
31 |
+
if( !function_exists( $callback ))
|
32 |
+
wp_die($mwp_core->mwp_dashboard_widget('Information', '', '<p>Function <b>"'.$callback.'"</b> does not exists.</p>', '', '50%'));
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
?>
|
backup.class.php
CHANGED
@@ -100,10 +100,9 @@ class MMB_Backup extends MMB_Core
|
|
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;
|
@@ -121,10 +120,9 @@ class MMB_Backup extends MMB_Core
|
|
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;
|
@@ -172,11 +170,10 @@ class MMB_Backup extends MMB_Core
|
|
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;
|
@@ -219,8 +216,6 @@ class MMB_Backup extends MMB_Core
|
|
219 |
function backup_db($type)
|
220 |
{
|
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);
|
@@ -367,7 +362,7 @@ class MMB_Backup extends MMB_Core
|
|
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.');
|
@@ -375,7 +370,7 @@ class MMB_Backup extends MMB_Core
|
|
375 |
chdir($file_path);
|
376 |
$command = "unzip -o $backup_file";
|
377 |
ob_start();
|
378 |
-
|
379 |
switch($func)
|
380 |
{
|
381 |
case 'passthru': passthru($command, $err); break;
|
@@ -434,13 +429,12 @@ class MMB_Backup extends MMB_Core
|
|
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;
|
@@ -472,13 +466,12 @@ class MMB_Backup extends MMB_Core
|
|
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;
|
@@ -603,29 +596,18 @@ class MMB_Backup extends MMB_Core
|
|
603 |
//Check if passthru, system or exec functions exist
|
604 |
function check_sys()
|
605 |
{
|
606 |
-
|
607 |
-
if (
|
608 |
-
|
609 |
-
|
610 |
-
|
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()
|
100 |
if (trim($what) == 'full') {
|
101 |
$htaccess_path = ABSPATH . ".htaccess";
|
102 |
$wp_config_path = ABSPATH . "wp-config.php";
|
103 |
+
if ($this->check_zip() && ($func = $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 |
switch($func)
|
107 |
{
|
108 |
case 'passthru': passthru($command, $err); break;
|
120 |
}
|
121 |
|
122 |
} elseif (trim($what) == 'db') {
|
123 |
+
if ($this->check_zip() && ($func = $this->check_sys())) {
|
124 |
$command = "zip $backup_file -j $db_backup[path]";
|
125 |
+
ob_start();
|
|
|
126 |
switch($func)
|
127 |
{
|
128 |
case 'passthru': passthru($command, $err); break;
|
170 |
$sec_string = md5('mmb-worker');
|
171 |
$file = '/' . $sec_string . '/backups/wp-content_' . date('Y-m-d') . '.zip';
|
172 |
$file_path = $upload_dir['basedir'] . $file;
|
173 |
+
if ($this->check_zip() && ($func = $this->check_sys())) {
|
174 |
chdir(WP_CONTENT_DIR);
|
175 |
$command = "zip -r $file_path 'plugins/' 'themes/' 'uploads/' -x 'uploads/" . $sec_string . "/*'";
|
176 |
+
ob_start();
|
|
|
177 |
switch($func)
|
178 |
{
|
179 |
case 'passthru': passthru($command, $err); break;
|
216 |
function backup_db($type)
|
217 |
{
|
218 |
$mysqldump_exists = $this->check_mysqldump();
|
|
|
|
|
219 |
if (is_array($mysqldump_exists) && $this->check_sys()) {
|
220 |
|
221 |
$result = $this->backup_db_dump($type, $mysqldump_exists);
|
362 |
|
363 |
|
364 |
if ($backup_file) {
|
365 |
+
if ($this->check_unzip() && ($func = $this->check_sys())) {
|
366 |
|
367 |
if(!mkdir($file_path))
|
368 |
return array('error' => 'Failed to create restore folder.');
|
370 |
chdir($file_path);
|
371 |
$command = "unzip -o $backup_file";
|
372 |
ob_start();
|
373 |
+
|
374 |
switch($func)
|
375 |
{
|
376 |
case 'passthru': passthru($command, $err); break;
|
429 |
$content_file = glob($file_path . "/*.zip");
|
430 |
$wp_config_file = glob($file_path . "/wp-config.php");
|
431 |
$htaccess_file = glob($file_path . "/.htaccess");
|
432 |
+
if ($this->check_unzip() && ($func = $this->check_sys())) {
|
433 |
|
434 |
chdir(WP_CONTENT_DIR);
|
435 |
$con_file = $content_file[0];
|
436 |
$command = "unzip -o $con_file";
|
437 |
+
ob_start();
|
|
|
438 |
switch($func)
|
439 |
{
|
440 |
case 'passthru': passthru($command, $err); break;
|
466 |
|
467 |
$mysqldump = $this->check_mysqldump();
|
468 |
|
469 |
+
if (is_array($mysqldump) && ($func = $this->check_sys())) {
|
470 |
$brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
|
471 |
|
472 |
foreach (glob($file_path . '/*.sql') as $filename) {
|
473 |
$command = $brace . $mysqldump['mysql'] . $brace . ' --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" ' . DB_NAME . ' < ' . $brace . $filename . $brace;
|
474 |
+
ob_start();
|
|
|
475 |
switch($func)
|
476 |
{
|
477 |
case 'passthru': passthru($command, $error); break;
|
596 |
//Check if passthru, system or exec functions exist
|
597 |
function check_sys()
|
598 |
{
|
599 |
+
|
600 |
+
if (function_exists('passthru'))
|
601 |
+
return 'passthru';
|
602 |
+
|
603 |
+
if (function_exists('system'))
|
|
|
|
|
|
|
|
|
|
|
604 |
return 'system';
|
605 |
+
|
606 |
+
if (function_exists('exec'))
|
|
|
|
|
|
|
607 |
return 'exec';
|
608 |
+
|
|
|
|
|
609 |
return false;
|
610 |
+
|
|
|
611 |
}
|
612 |
|
613 |
function check_zip()
|
core.class.php
CHANGED
@@ -21,8 +21,10 @@ class MMB_Core extends MMB_Helper
|
|
21 |
var $wp_instance;
|
22 |
var $post_instance;
|
23 |
var $stats_instance;
|
|
|
24 |
var $user_instance;
|
25 |
var $backup_instance;
|
|
|
26 |
|
27 |
|
28 |
function __construct()
|
@@ -39,6 +41,7 @@ class MMB_Core extends MMB_Helper
|
|
39 |
'type' => null
|
40 |
)
|
41 |
);
|
|
|
42 |
}
|
43 |
add_action('rightnow_end', array(
|
44 |
$this,
|
@@ -56,9 +59,24 @@ class MMB_Core extends MMB_Helper
|
|
56 |
$this,
|
57 |
'automatic_login'
|
58 |
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
/**
|
63 |
* Add an item into the Right Now Dashboard widget
|
64 |
* to inform that the blog can be managed remotely
|
@@ -176,7 +194,18 @@ class MMB_Core extends MMB_Helper
|
|
176 |
}
|
177 |
return $this->stats_instance;
|
178 |
}
|
179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
/**
|
181 |
* Gets an instance of stats class
|
182 |
*
|
@@ -189,6 +218,14 @@ class MMB_Core extends MMB_Helper
|
|
189 |
|
190 |
return $this->backup_instance;
|
191 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
|
193 |
/**
|
194 |
* Plugin install callback function
|
21 |
var $wp_instance;
|
22 |
var $post_instance;
|
23 |
var $stats_instance;
|
24 |
+
var $search_instance;
|
25 |
var $user_instance;
|
26 |
var $backup_instance;
|
27 |
+
var $installer_instance;
|
28 |
|
29 |
|
30 |
function __construct()
|
41 |
'type' => null
|
42 |
)
|
43 |
);
|
44 |
+
$this->save_options();
|
45 |
}
|
46 |
add_action('rightnow_end', array(
|
47 |
$this,
|
59 |
$this,
|
60 |
'automatic_login'
|
61 |
));
|
62 |
+
|
63 |
+
if (!get_option('_worker_public_key'))
|
64 |
+
add_action('admin_notices', array(
|
65 |
+
$this,
|
66 |
+
'admin_notice'
|
67 |
+
));
|
68 |
+
|
69 |
}
|
70 |
+
/**
|
71 |
+
* Add notice to admin dashboard for security reasons
|
72 |
+
*
|
73 |
+
*/
|
74 |
+
function admin_notice() {
|
75 |
+
echo '<div class="error" style="text-align: center;"><p style="color: red; font-size: 14px; font-weight: bold;">Attention !</p><p>
|
76 |
+
You activated the ManageWP worker plugin but have not yet added this site to your account. Please add the site to ManageWP now or deactivate the plugin. <a target="_blank" href="http://managewp.com/user-guide#security">More info</a>
|
77 |
+
</p></div>';
|
78 |
+
}
|
79 |
+
|
80 |
/**
|
81 |
* Add an item into the Right Now Dashboard widget
|
82 |
* to inform that the blog can be managed remotely
|
194 |
}
|
195 |
return $this->stats_instance;
|
196 |
}
|
197 |
+
/**
|
198 |
+
* Gets an instance of search class
|
199 |
+
*
|
200 |
+
*/
|
201 |
+
function get_search_instance()
|
202 |
+
{
|
203 |
+
if (!isset($this->search_instance)) {
|
204 |
+
$this->search_instance = new MMB_Search();
|
205 |
+
}
|
206 |
+
//return $this->search_instance;
|
207 |
+
return $this->search_instance;
|
208 |
+
}
|
209 |
/**
|
210 |
* Gets an instance of stats class
|
211 |
*
|
218 |
|
219 |
return $this->backup_instance;
|
220 |
}
|
221 |
+
|
222 |
+
function get_installer_instance()
|
223 |
+
{
|
224 |
+
if (!isset($this->installer_instance)) {
|
225 |
+
$this->installer_instance = new MMB_Installer();
|
226 |
+
}
|
227 |
+
return $this->installer_instance;
|
228 |
+
}
|
229 |
|
230 |
/**
|
231 |
* Plugin install callback function
|
helper.class.php
CHANGED
@@ -297,7 +297,7 @@ class MMB_Helper
|
|
297 |
} else {
|
298 |
$errors = array();
|
299 |
foreach ($error_object->error_data as $error_key => $error_string) {
|
300 |
-
$errors[] = str_replace('_', ' ', ucfirst($error_key)) . '
|
301 |
}
|
302 |
return implode('<br />', $errors);
|
303 |
}
|
297 |
} else {
|
298 |
$errors = array();
|
299 |
foreach ($error_object->error_data as $error_key => $error_string) {
|
300 |
+
$errors[] = str_replace('_', ' ', ucfirst($error_key)) . ': ' . $error_string;
|
301 |
}
|
302 |
return implode('<br />', $errors);
|
303 |
}
|
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 |
|
@@ -20,14 +20,30 @@ Author URI: http://www.prelovac.com
|
|
20 |
**************************************************************/
|
21 |
|
22 |
|
23 |
-
define('MMB_WORKER_VERSION', '3.8.
|
24 |
|
25 |
global $wpdb, $mmb_plugin_dir, $mmb_plugin_url;
|
26 |
|
27 |
$mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
|
28 |
$mmb_plugin_url = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
|
29 |
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
require_once("$mmb_plugin_dir/helper.class.php");
|
32 |
require_once("$mmb_plugin_dir/core.class.php");
|
33 |
require_once("$mmb_plugin_dir/plugin.class.php");
|
@@ -36,6 +52,15 @@ require_once("$mmb_plugin_dir/wp.class.php");
|
|
36 |
require_once("$mmb_plugin_dir/post.class.php");
|
37 |
require_once("$mmb_plugin_dir/stats.class.php");
|
38 |
require_once("$mmb_plugin_dir/backup.class.php");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
$mmb_core = new MMB_Core();
|
41 |
add_action('init', 'mmb_parse_request');
|
@@ -51,6 +76,8 @@ if (function_exists('register_deactivation_hook'))
|
|
51 |
$mmb_core,
|
52 |
'uninstall'
|
53 |
));
|
|
|
|
|
54 |
|
55 |
function mmb_parse_request()
|
56 |
{
|
@@ -59,12 +86,15 @@ function mmb_parse_request()
|
|
59 |
}
|
60 |
ob_start();
|
61 |
|
62 |
-
global $mmb_core;
|
63 |
-
|
64 |
-
$
|
|
|
|
|
65 |
|
66 |
if ($action) {
|
67 |
-
|
|
|
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') {
|
@@ -74,21 +104,6 @@ function mmb_parse_request()
|
|
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',
|
79 |
-
'get_stats' => 'mmb_stats_get',
|
80 |
-
'backup' => 'mmb_backup_now',
|
81 |
-
'restore' => 'mmb_restore_now',
|
82 |
-
'optimize_tables' => 'mmb_optimize_tables',
|
83 |
-
'check_wp_version' => 'mmb_wp_checkversion',
|
84 |
-
'create_post' => 'mmb_post_create',
|
85 |
-
'upgrade_plugins' => 'mmb_upgrade_plugins',
|
86 |
-
'wp_upgrade' => 'mmb_upgrade_wp',
|
87 |
-
'upgrade_themes' => 'mmb_themes_upgrade',
|
88 |
-
'upload_plugin_by_url' => 'mmb_plugin_upload_by_url',
|
89 |
-
'upload_theme_by_url' => 'mmb_theme_upload_by_url',
|
90 |
-
'update_worker' => 'mmb_update_worker_plugin'
|
91 |
-
);
|
92 |
if (array_key_exists($action, $mmb_actions) && function_exists($mmb_actions[$action]))
|
93 |
call_user_func($mmb_actions[$action], $params);
|
94 |
else
|
@@ -109,7 +124,7 @@ function mmb_response($response = false, $success = true)
|
|
109 |
$return = array();
|
110 |
|
111 |
if (empty($response))
|
112 |
-
$return['error'] = 'Empty response';
|
113 |
else if ($success)
|
114 |
$return['success'] = $response;
|
115 |
else
|
@@ -285,4 +300,32 @@ function mmb_update_worker_plugin($params)
|
|
285 |
global $mmb_core;
|
286 |
mmb_response($mmb_core->update_worker_plugin($params), true);
|
287 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
?>
|
4 |
Plugin URI: http://managewp.com/
|
5 |
Description: Manage all your blogs from one dashboard
|
6 |
Author: Prelovac Media
|
7 |
+
Version: 3.8.5
|
8 |
Author URI: http://www.prelovac.com
|
9 |
*/
|
10 |
|
20 |
**************************************************************/
|
21 |
|
22 |
|
23 |
+
define('MMB_WORKER_VERSION', '3.8.5');
|
24 |
|
25 |
global $wpdb, $mmb_plugin_dir, $mmb_plugin_url;
|
26 |
|
27 |
$mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
|
28 |
$mmb_plugin_url = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
|
29 |
|
30 |
+
$mmb_actions = array(
|
31 |
+
'remove_site' => 'mmb_remove_site',
|
32 |
+
'get_stats' => 'mmb_stats_get',
|
33 |
+
'backup' => 'mmb_backup_now',
|
34 |
+
'restore' => 'mmb_restore_now',
|
35 |
+
'optimize_tables' => 'mmb_optimize_tables',
|
36 |
+
'check_wp_version' => 'mmb_wp_checkversion',
|
37 |
+
'create_post' => 'mmb_post_create',
|
38 |
+
'upgrade_plugins' => 'mmb_upgrade_plugins',
|
39 |
+
'wp_upgrade' => 'mmb_upgrade_wp',
|
40 |
+
'upgrade_themes' => 'mmb_themes_upgrade',
|
41 |
+
'upload_plugin_by_url' => 'mmb_plugin_upload_by_url',
|
42 |
+
'upload_theme_by_url' => 'mmb_theme_upload_by_url',
|
43 |
+
'update_worker' => 'mmb_update_worker_plugin',
|
44 |
+
'install_addon' => 'mmb_install_addon'
|
45 |
+
);
|
46 |
+
|
47 |
require_once("$mmb_plugin_dir/helper.class.php");
|
48 |
require_once("$mmb_plugin_dir/core.class.php");
|
49 |
require_once("$mmb_plugin_dir/plugin.class.php");
|
52 |
require_once("$mmb_plugin_dir/post.class.php");
|
53 |
require_once("$mmb_plugin_dir/stats.class.php");
|
54 |
require_once("$mmb_plugin_dir/backup.class.php");
|
55 |
+
require_once("$mmb_plugin_dir/installer.class.php");
|
56 |
+
require_once("$mmb_plugin_dir/api.php");
|
57 |
+
|
58 |
+
|
59 |
+
require_once("$mmb_plugin_dir/plugins/search/search.php");
|
60 |
+
require_once("$mmb_plugin_dir/plugins/cleanup/cleanup.php");
|
61 |
+
|
62 |
+
//this is an exmaple plugin for extra_html element
|
63 |
+
//require_once("$mmb_plugin_dir/plugins/extra_html_example/extra_html_example.php");
|
64 |
|
65 |
$mmb_core = new MMB_Core();
|
66 |
add_action('init', 'mmb_parse_request');
|
76 |
$mmb_core,
|
77 |
'uninstall'
|
78 |
));
|
79 |
+
|
80 |
+
|
81 |
|
82 |
function mmb_parse_request()
|
83 |
{
|
86 |
}
|
87 |
ob_start();
|
88 |
|
89 |
+
global $mmb_core, $mmb_actions, $new_actions;
|
90 |
+
|
91 |
+
$data = base64_decode($HTTP_RAW_POST_DATA);
|
92 |
+
if ($data)
|
93 |
+
$num = @extract(unserialize($data));
|
94 |
|
95 |
if ($action) {
|
96 |
+
// mmb_response($mmb_actions, false);
|
97 |
+
if (!$mmb_core->check_if_user_exists($params['username']))
|
98 |
mmb_response('Username <b>' . $params['username'] . '</b> does not have administrator capabilities. Enter the correct username in the site options.', false);
|
99 |
|
100 |
if ($action == 'add_site') {
|
104 |
|
105 |
$auth = $mmb_core->authenticate_message($action . $id, $signature, $id);
|
106 |
if ($auth === true) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
if (array_key_exists($action, $mmb_actions) && function_exists($mmb_actions[$action]))
|
108 |
call_user_func($mmb_actions[$action], $params);
|
109 |
else
|
124 |
$return = array();
|
125 |
|
126 |
if (empty($response))
|
127 |
+
$return['error'] = 'Empty response.';
|
128 |
else if ($success)
|
129 |
$return['success'] = $response;
|
130 |
else
|
300 |
global $mmb_core;
|
301 |
mmb_response($mmb_core->update_worker_plugin($params), true);
|
302 |
}
|
303 |
+
|
304 |
+
function mmb_wp_checkversion($params)
|
305 |
+
{
|
306 |
+
include_once(ABSPATH . 'wp-includes/version.php');
|
307 |
+
global $wp_version,$mmb_core;
|
308 |
+
mmb_response($wp_version,true);
|
309 |
+
}
|
310 |
+
|
311 |
+
function mmb_search_posts_by_term($params)
|
312 |
+
{
|
313 |
+
|
314 |
+
global $mmb_core;
|
315 |
+
$return = $mmb_core->get_search_instance()->search_posts_by_term($params);
|
316 |
+
|
317 |
+
if($return){
|
318 |
+
mmb_response(serialize($return),true);
|
319 |
+
}else{
|
320 |
+
mmb_response('No posts for term',false);
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
function mmb_install_addon($params)
|
325 |
+
{
|
326 |
+
global $mmb_core;
|
327 |
+
$return = $mmb_core->get_installer_instance()->install_remote_file($params);
|
328 |
+
mmb_response($return,true);
|
329 |
+
|
330 |
+
}
|
331 |
?>
|
installer.class.php
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*************************************************************
|
3 |
+
*
|
4 |
+
* installer.class.php
|
5 |
+
*
|
6 |
+
* Upgrade WordPress
|
7 |
+
*
|
8 |
+
*
|
9 |
+
* Copyright (c) 2011 Prelovac Media
|
10 |
+
* www.prelovac.com
|
11 |
+
**************************************************************/
|
12 |
+
|
13 |
+
include_once(ABSPATH . 'wp-admin/includes/file.php');
|
14 |
+
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
15 |
+
include_once(ABSPATH . 'wp-admin/includes/theme.php');
|
16 |
+
include_once(ABSPATH . 'wp-admin/includes/misc.php');
|
17 |
+
include_once(ABSPATH . 'wp-admin/includes/template.php');
|
18 |
+
include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
|
19 |
+
if(!$wp_filesystem){
|
20 |
+
WP_Filesystem();
|
21 |
+
}
|
22 |
+
class MMB_Installer extends MMB_Core
|
23 |
+
{
|
24 |
+
function __construct()
|
25 |
+
{
|
26 |
+
@set_time_limit( 300 );
|
27 |
+
parent::__construct();
|
28 |
+
}
|
29 |
+
|
30 |
+
function mmb_maintenance_mode($enable = false, $maintenance_message = '') {
|
31 |
+
global $wp_filesystem;
|
32 |
+
|
33 |
+
$maintenance_message .= '<?php $upgrading = ' . time() . '; ?>';
|
34 |
+
|
35 |
+
$file = $wp_filesystem->abspath() . '.maintenance';
|
36 |
+
if($enable){
|
37 |
+
$wp_filesystem->delete($file);
|
38 |
+
$wp_filesystem->put_contents($file, $maintenance_message, FS_CHMOD_FILE);
|
39 |
+
}else {
|
40 |
+
$wp_filesystem->delete($file);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
function install_remote_file($params){
|
45 |
+
|
46 |
+
global $wp_filesystem;
|
47 |
+
extract($params);
|
48 |
+
|
49 |
+
if(!isset($package) || empty($package))
|
50 |
+
return array('error' => '<p>No files received. Internal error.</p>');
|
51 |
+
|
52 |
+
if(defined('WP_INSTALLING') && file_exists(ABSPATH . '.maintenance'))
|
53 |
+
return array('error' => '<p>Site under maintanace.</p>');;
|
54 |
+
|
55 |
+
$upgrader = new WP_Upgrader();
|
56 |
+
$destination = $type == 'themes' ? WP_CONTENT_DIR . '/themes' : WP_PLUGIN_DIR;
|
57 |
+
|
58 |
+
|
59 |
+
foreach($package as $package_url){
|
60 |
+
$key = basename($package_url);
|
61 |
+
$install_info[$key] = @$upgrader->run(array(
|
62 |
+
'package' => $package_url,
|
63 |
+
'destination' => $destination,
|
64 |
+
'clear_destination' => false, //Do not overwrite files.
|
65 |
+
'clear_working' => true,
|
66 |
+
'hook_extra' => array()
|
67 |
+
));
|
68 |
+
}
|
69 |
+
|
70 |
+
if($activate){
|
71 |
+
$all_plugins = get_plugins();
|
72 |
+
foreach($all_plugins as $plugin_slug => $plugin){
|
73 |
+
$plugin_dir = preg_split('/\//', $plugin_slug);
|
74 |
+
foreach($install_info as $key => $install){
|
75 |
+
if(!$install || is_wp_error($install))
|
76 |
+
continue;
|
77 |
+
|
78 |
+
if($install['destination_name'] == $plugin_dir[0]){
|
79 |
+
$install_info[$key]['activated'] = activate_plugin($plugin_slug, '', false);
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
83 |
+
}
|
84 |
+
return $install_info;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Upgrades WordPress locally
|
89 |
+
*
|
90 |
+
*/
|
91 |
+
function upgrade($params)
|
92 |
+
{
|
93 |
+
ob_start();
|
94 |
+
require_once(ABSPATH . 'wp-admin/includes/file.php');
|
95 |
+
require_once(ABSPATH . 'wp-admin/includes/misc.php');
|
96 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
|
97 |
+
|
98 |
+
if(!$wp_filesystem)
|
99 |
+
WP_Filesystem();
|
100 |
+
|
101 |
+
global $wp_version, $wp_filesystem;
|
102 |
+
$upgrader = new WP_Upgrader();
|
103 |
+
$updates = $this->mmb_get_transient('update_core');
|
104 |
+
$current = $updates->updates[0];
|
105 |
+
|
106 |
+
|
107 |
+
// Is an update available?
|
108 |
+
if (!isset($current->response) || $current->response == 'latest')
|
109 |
+
return array(
|
110 |
+
'upgraded' => ' has latest ' . $wp_version . ' WordPress version.'
|
111 |
+
);
|
112 |
+
|
113 |
+
$res = $upgrader->fs_connect(array(
|
114 |
+
ABSPATH,
|
115 |
+
WP_CONTENT_DIR
|
116 |
+
));
|
117 |
+
if (is_wp_error($res))
|
118 |
+
return array(
|
119 |
+
'error' => $this->mmb_get_error($res)
|
120 |
+
);
|
121 |
+
|
122 |
+
$wp_dir = trailingslashit($wp_filesystem->abspath());
|
123 |
+
|
124 |
+
$download = $upgrader->download_package($current->package);
|
125 |
+
if (is_wp_error($download))
|
126 |
+
return array(
|
127 |
+
'error' => $this->mmb_get_error($download)
|
128 |
+
);
|
129 |
+
|
130 |
+
$working_dir = $upgrader->unpack_package($download);
|
131 |
+
if (is_wp_error($working_dir))
|
132 |
+
return array(
|
133 |
+
'error' => $this->mmb_get_error($working_dir)
|
134 |
+
);
|
135 |
+
|
136 |
+
if (!$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true)) {
|
137 |
+
$wp_filesystem->delete($working_dir, true);
|
138 |
+
return array(
|
139 |
+
'error' => 'Unable to move update files.'
|
140 |
+
);
|
141 |
+
}
|
142 |
+
|
143 |
+
$wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
|
144 |
+
|
145 |
+
require(ABSPATH . 'wp-admin/includes/update-core.php');
|
146 |
+
ob_end_clean();
|
147 |
+
|
148 |
+
$update_core = update_core($working_dir, $wp_dir);
|
149 |
+
|
150 |
+
if (is_wp_error($update_core))
|
151 |
+
return array(
|
152 |
+
'error' => $this->mmb_get_error($update_core)
|
153 |
+
);
|
154 |
+
|
155 |
+
$this->mmb_delete_transient('update_core');
|
156 |
+
return array(
|
157 |
+
'upgraded' => ' upgraded sucessfully.'
|
158 |
+
);
|
159 |
+
}
|
160 |
+
|
161 |
+
}
|
162 |
+
?>
|
plugin.class.php
CHANGED
@@ -66,77 +66,6 @@ class MMB_Plugin extends MMB_Core
|
|
66 |
);
|
67 |
}
|
68 |
|
69 |
-
/**
|
70 |
-
* Uploads a plugin, given its package url
|
71 |
-
*
|
72 |
-
* @param mixed $args
|
73 |
-
*/
|
74 |
-
function upload_by_url($args)
|
75 |
-
{
|
76 |
-
//print_r($args);
|
77 |
-
$this->_escape($args);
|
78 |
-
$plugin_url = $args['url'];
|
79 |
-
$activate_plugin = $args['activate'];
|
80 |
-
|
81 |
-
if ($plugin_url) {
|
82 |
-
ob_start();
|
83 |
-
include_once(ABSPATH . 'wp-admin/includes/file.php');
|
84 |
-
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
85 |
-
include_once(ABSPATH . 'wp-admin/includes/misc.php');
|
86 |
-
include_once(ABSPATH . 'wp-admin/includes/template.php');
|
87 |
-
include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
|
88 |
-
|
89 |
-
$upgrader = new Plugin_Upgrader();
|
90 |
-
|
91 |
-
$result = $upgrader->run(array(
|
92 |
-
'package' => $plugin_url,
|
93 |
-
'destination' => WP_PLUGIN_DIR,
|
94 |
-
'clear_destination' => false, //Do not overwrite files.
|
95 |
-
'clear_working' => true,
|
96 |
-
'hook_extra' => array()
|
97 |
-
));
|
98 |
-
|
99 |
-
ob_end_clean();
|
100 |
-
|
101 |
-
|
102 |
-
if (is_wp_error($upgrader->skin->result) || !$upgrader->plugin_info()) {
|
103 |
-
return array(
|
104 |
-
'bool' => false,
|
105 |
-
'message' => 'Plugin was not installed.'
|
106 |
-
);
|
107 |
-
}
|
108 |
-
|
109 |
-
if ($activate_plugin) {
|
110 |
-
$success = activate_plugin($upgrader->plugin_info(), '', false);
|
111 |
-
|
112 |
-
if (!is_wp_error($success)) {
|
113 |
-
return array(
|
114 |
-
'bool' => true,
|
115 |
-
'message' => 'Plugin ' . $upgrader->result[destination_name] . ' successfully installed and activated '
|
116 |
-
);
|
117 |
-
}
|
118 |
-
return array(
|
119 |
-
'bool' => true,
|
120 |
-
'message' => 'Plugin ' . $upgrader->result[destination_name] . ' successfully installed '
|
121 |
-
);
|
122 |
-
} else {
|
123 |
-
return (!$result or is_wp_error($result)) ? array(
|
124 |
-
'bool' => false,
|
125 |
-
'message' => 'Upload failed.'
|
126 |
-
) : array(
|
127 |
-
'bool' => true,
|
128 |
-
'message' => 'Plugin ' . $upgrader->result[destination_name] . ' successfully installed '
|
129 |
-
);
|
130 |
-
}
|
131 |
-
|
132 |
-
} else
|
133 |
-
return array(
|
134 |
-
'bool' => false,
|
135 |
-
'message' => 'Missing plugin.'
|
136 |
-
);
|
137 |
-
|
138 |
-
}
|
139 |
-
|
140 |
function get_upgradable_plugins()
|
141 |
{
|
142 |
$current = $this->mmb_get_transient('update_plugins');
|
66 |
);
|
67 |
}
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
function get_upgradable_plugins()
|
70 |
{
|
71 |
$current = $this->mmb_get_transient('update_plugins');
|
plugins/cleanup/cleanup.php
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*************************************************************
|
3 |
+
*
|
4 |
+
*
|
5 |
+
*
|
6 |
+
* ManageWP Worker Plugin
|
7 |
+
*
|
8 |
+
*
|
9 |
+
* Copyright (c) 2011 Prelovac Media
|
10 |
+
* www.prelovac.com
|
11 |
+
**************************************************************/
|
12 |
+
|
13 |
+
add_filter('mmb_stats_filter', mmb_get_extended_info);
|
14 |
+
|
15 |
+
|
16 |
+
function mmb_get_extended_info($stats)
|
17 |
+
{
|
18 |
+
$stats['num_revisions'] = mmb_num_revisions();
|
19 |
+
$stats['overhead'] = mmb_get_overhead();
|
20 |
+
$stats['num_spam_comments'] = mmb_num_spam_comments();
|
21 |
+
return $stats;
|
22 |
+
}
|
23 |
+
|
24 |
+
/* Revisions */
|
25 |
+
|
26 |
+
mmb_add_action('cleanup_delete', 'cleanup_delete_worker');
|
27 |
+
|
28 |
+
function cleanup_delete_worker($params = array()){
|
29 |
+
global $mmb_core;
|
30 |
+
|
31 |
+
$params_array = explode('_', $params['actions']);
|
32 |
+
$return_array = array();
|
33 |
+
foreach ($params_array as $param){
|
34 |
+
switch ($param){
|
35 |
+
case 'revision' :
|
36 |
+
if(mmb_delete_all_revisions()){
|
37 |
+
$return_array['revision'] = 'Revisions deleted.';
|
38 |
+
}else{
|
39 |
+
$return_array['revision'] = 'Revisions not deleted.';
|
40 |
+
}
|
41 |
+
break;
|
42 |
+
case 'overhead' :
|
43 |
+
if(mmb_clear_overhead()){
|
44 |
+
$return_array['overhead'] = 'Overhead cleared.';
|
45 |
+
}else{
|
46 |
+
$return_array['overhead'] = 'Overhead not cleared.';
|
47 |
+
}
|
48 |
+
break;
|
49 |
+
case 'comment' :
|
50 |
+
if(mmb_delete_spam_comments()){
|
51 |
+
$return_array['comment'] = 'Comments deleted';
|
52 |
+
}else{
|
53 |
+
$return_array['comment'] = 'Comments not deleted';
|
54 |
+
}
|
55 |
+
break;
|
56 |
+
default:
|
57 |
+
break;
|
58 |
+
}
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
unset($params);
|
63 |
+
|
64 |
+
mmb_response($return_array, true);
|
65 |
+
}
|
66 |
+
|
67 |
+
function mmb_num_revisions() {
|
68 |
+
global $wpdb;
|
69 |
+
$sql = "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'revision'";
|
70 |
+
$num_revisions = $wpdb->get_var($wpdb->prepare($sql));
|
71 |
+
return $num_revisions;
|
72 |
+
}
|
73 |
+
|
74 |
+
function mmb_select_all_revisions() {
|
75 |
+
global $wpdb;
|
76 |
+
$sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'revision'";
|
77 |
+
$revisions = $wpdb->get_results($wpdb->prepare($sql));
|
78 |
+
return $revisions;
|
79 |
+
}
|
80 |
+
|
81 |
+
function mmb_delete_all_revisions() {
|
82 |
+
global $wpdb;
|
83 |
+
$sql = "DELETE a,b,c FROM $wpdb->posts a LEFT JOIN $wpdb->term_relationships b ON (a.ID = b.object_id) LEFT JOIN $wpdb->postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision'";
|
84 |
+
$revisions = $wpdb->query($wpdb->prepare($sql));
|
85 |
+
return $revisions;
|
86 |
+
}
|
87 |
+
|
88 |
+
|
89 |
+
|
90 |
+
/* Optimize */
|
91 |
+
|
92 |
+
function mmb_get_overhead()
|
93 |
+
{
|
94 |
+
global $wpdb, $mmb_core;
|
95 |
+
$tot_data = 0;
|
96 |
+
$tot_idx = 0;
|
97 |
+
$tot_all = 0;
|
98 |
+
$query = 'SHOW TABLE STATUS FROM '. DB_NAME;
|
99 |
+
$tables = $wpdb->get_results($query,ARRAY_A);
|
100 |
+
foreach($tables as $table)
|
101 |
+
{
|
102 |
+
$tot_data = $table['Data_length'];
|
103 |
+
$tot_idx = $table['Index_length'];
|
104 |
+
$total = $tot_data + $tot_idx;
|
105 |
+
$total = $total / 1024 ;
|
106 |
+
$total = round ($total,3);
|
107 |
+
$gain= $table['Data_free'];
|
108 |
+
$gain = $gain / 1024 ;
|
109 |
+
$total_gain += $gain;
|
110 |
+
$gain = round ($gain,3);
|
111 |
+
|
112 |
+
}
|
113 |
+
|
114 |
+
return round($total_gain,3);
|
115 |
+
}
|
116 |
+
|
117 |
+
function mmb_clear_overhead()
|
118 |
+
{
|
119 |
+
global $wpdb;
|
120 |
+
$tables = $wpdb->get_col("SHOW TABLES");
|
121 |
+
foreach ($tables as $table_name) {
|
122 |
+
$table_string .= $table_name . ",";
|
123 |
+
}
|
124 |
+
$table_string = substr($table_string,0,strlen($table_string)-1); //remove last ,
|
125 |
+
|
126 |
+
$table_string = rtrim($table_string);
|
127 |
+
|
128 |
+
$query = "OPTIMIZE TABLE $table_string";
|
129 |
+
|
130 |
+
$optimize = $wpdb->query($query);
|
131 |
+
return $optimize ? true : false;
|
132 |
+
}
|
133 |
+
|
134 |
+
|
135 |
+
|
136 |
+
/* Spam Comments */
|
137 |
+
|
138 |
+
function mmb_num_spam_comments()
|
139 |
+
{
|
140 |
+
global $wpdb;
|
141 |
+
$sql = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'spam'";
|
142 |
+
$num_spams = $wpdb->get_var($wpdb->prepare($sql));
|
143 |
+
return $num_spams;
|
144 |
+
}
|
145 |
+
|
146 |
+
function mmb_delete_spam_comments()
|
147 |
+
{
|
148 |
+
global $wpdb;
|
149 |
+
$sql = "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam'";
|
150 |
+
$spams = $wpdb->query($wpdb->prepare($sql));
|
151 |
+
return $sql;
|
152 |
+
}
|
153 |
+
|
154 |
+
|
155 |
+
function mmb_get_spam_comments() {
|
156 |
+
global $wpdb;
|
157 |
+
$sql = "SELECT * FROM $wpdb->comments as a LEFT JOIN $wpdb->commentmeta as b WHERE a.comment_ID = b.comment_id AND a.comment_approved = 'spam'";
|
158 |
+
$spams = $wpdb->get_results($wpdb->prepare($sql));
|
159 |
+
return $spams;
|
160 |
+
}
|
161 |
+
?>
|
plugins/extra_html_example/extra_html_example.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// add filter for the stats structure
|
4 |
+
add_filter('mmb_stats_filter', mmb_extra_html_example);
|
5 |
+
|
6 |
+
function mmb_extra_html_example($stats)
|
7 |
+
{
|
8 |
+
$count_posts = wp_count_posts();
|
9 |
+
|
10 |
+
$published_posts = $count_posts->publish;
|
11 |
+
|
12 |
+
// add 'extra_html' element. This is what gets displayed in the dashboard
|
13 |
+
$stats['extra_html'] = '<p>Hello from '.get_bloginfo('name').' with '.$published_posts.' published posts.</p>';
|
14 |
+
|
15 |
+
// return the whole array back
|
16 |
+
return $stats;
|
17 |
+
}
|
18 |
+
?>
|
plugins/search/search.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*************************************************************
|
3 |
+
*
|
4 |
+
* stats.class.php
|
5 |
+
*
|
6 |
+
* Various searches on worker
|
7 |
+
*
|
8 |
+
*
|
9 |
+
* Copyright (c) 2011 Prelovac Media
|
10 |
+
* www.prelovac.com
|
11 |
+
**************************************************************/
|
12 |
+
|
13 |
+
mmb_add_action('search_posts_by_term', 'search_posts_by_term');
|
14 |
+
|
15 |
+
function search_posts_by_term($params = false){
|
16 |
+
|
17 |
+
global $wpdb, $current_user;
|
18 |
+
|
19 |
+
|
20 |
+
$num_posts = 10;
|
21 |
+
$num_content_char = 30;
|
22 |
+
|
23 |
+
$term_orig = trim($params['search_term']);
|
24 |
+
$term_base= addslashes(trim($params['search_term']));
|
25 |
+
|
26 |
+
$query = "SELECT *
|
27 |
+
FROM $wpdb->posts
|
28 |
+
WHERE $wpdb->posts.post_status = 'publish'
|
29 |
+
AND ($wpdb->posts.post_title LIKE '%$term_base%'
|
30 |
+
OR $wpdb->posts.post_content LIKE '%$term_base%')
|
31 |
+
ORDER BY $wpdb->posts.post_modified DESC
|
32 |
+
LIMIT 0, $num_posts
|
33 |
+
";
|
34 |
+
|
35 |
+
$posts_array = $wpdb->get_results($query);
|
36 |
+
|
37 |
+
$ret_posts = array();
|
38 |
+
|
39 |
+
foreach($posts_array as $post){
|
40 |
+
//highlight searched term
|
41 |
+
|
42 |
+
if (substr_count(strtolower($post->post_title), strtolower($term_orig))){
|
43 |
+
$str_position_start = strpos(strtolower($post->post_title), strtolower($term_orig));
|
44 |
+
|
45 |
+
$post->post_title = substr($post->post_title, 0, $str_position_start).'<b>'.
|
46 |
+
substr($post->post_title, $str_position_start, strlen($term_orig)).'</b>'.
|
47 |
+
substr($post->post_title, $str_position_start + strlen($term_orig));
|
48 |
+
|
49 |
+
}
|
50 |
+
$post->post_content = html_entity_decode($post->post_content);
|
51 |
+
|
52 |
+
$post->post_content = strip_tags($post->post_content);
|
53 |
+
|
54 |
+
|
55 |
+
|
56 |
+
if (substr_count(strtolower($post->post_content), strtolower($term_orig))){
|
57 |
+
$str_position_start = strpos(strtolower($post->post_content), strtolower($term_orig));
|
58 |
+
|
59 |
+
$start = $str_position_start > $num_content_char ? $str_position_start - $num_content_char: 0;
|
60 |
+
$first_len = $str_position_start > $num_content_char? $num_content_char : $str_position_start;
|
61 |
+
|
62 |
+
$start_substring = $start>0 ? '...' : '';
|
63 |
+
$post->post_content = $start_substring . substr($post->post_content, $start, $first_len).'<b>'.
|
64 |
+
substr($post->post_content, $str_position_start, strlen($term_orig)).'</b>'.
|
65 |
+
substr($post->post_content, $str_position_start + strlen($term_orig), $num_content_char) . '...';
|
66 |
+
|
67 |
+
|
68 |
+
}else{
|
69 |
+
$post->post_content = substr($post->post_content,0, 50). '...';
|
70 |
+
}
|
71 |
+
|
72 |
+
$ret_posts[] = array(
|
73 |
+
'ID' => $post->ID
|
74 |
+
,'post_permalink' => get_permalink($post->ID)
|
75 |
+
,'post_date' => $post->post_date
|
76 |
+
,'post_title' => $post->post_title
|
77 |
+
,'post_content' => $post->post_content
|
78 |
+
,'post_modified' => $post->post_modified
|
79 |
+
,'comment_count' => $post->comment_count
|
80 |
+
|
81 |
+
|
82 |
+
);
|
83 |
+
}
|
84 |
+
mmb_response($ret_posts, true);
|
85 |
+
|
86 |
+
}
|
87 |
+
|
88 |
+
?>
|
readme.txt
CHANGED
@@ -27,6 +27,12 @@ Check out [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs")
|
|
27 |
|
28 |
== Changelog ==
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
= 3.8.4 =
|
31 |
* Fixed remote dashboard problems for sites with redirects
|
32 |
* Fixed IE7 issues in the dashboard
|
27 |
|
28 |
== Changelog ==
|
29 |
|
30 |
+
= 3.8.5 =
|
31 |
+
* Added seach websites feature
|
32 |
+
* Added improved dashboard information
|
33 |
+
* Added developer [API] (http://managewp.com/api "ManageWP API)
|
34 |
+
* Improved Migrate/Clone site feature
|
35 |
+
|
36 |
= 3.8.4 =
|
37 |
* Fixed remote dashboard problems for sites with redirects
|
38 |
* Fixed IE7 issues in the dashboard
|
stats.class.php
CHANGED
@@ -38,6 +38,7 @@ class MMB_Stats extends MMB_Core
|
|
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 |
|
@@ -128,7 +129,10 @@ class MMB_Stats extends MMB_Core
|
|
128 |
$stats['writable'] = false;
|
129 |
} else
|
130 |
$stats['writable'] = true;
|
131 |
-
|
|
|
|
|
|
|
132 |
}
|
133 |
|
134 |
function get_initial_stats()
|
@@ -194,7 +198,7 @@ class MMB_Stats extends MMB_Core
|
|
194 |
if (!$fix_count)
|
195 |
$user_hit_count[$date] += 1;
|
196 |
|
197 |
-
if (count($user_hit_count) >
|
198 |
$shifted = @array_shift($user_hit_count);
|
199 |
}
|
200 |
|
38 |
require_once(ABSPATH . '/wp-admin/includes/update.php');
|
39 |
|
40 |
$stats['worker_version'] = MMB_WORKER_VERSION;
|
41 |
+
$stats['wordpress_version'] = $wp_version;
|
42 |
|
43 |
$updates = $this->mmb_get_transient('update_core');
|
44 |
|
129 |
$stats['writable'] = false;
|
130 |
} else
|
131 |
$stats['writable'] = true;
|
132 |
+
|
133 |
+
$stats = apply_filters('mmb_stats_filter', $stats);
|
134 |
+
|
135 |
+
return $stats;
|
136 |
}
|
137 |
|
138 |
function get_initial_stats()
|
198 |
if (!$fix_count)
|
199 |
$user_hit_count[$date] += 1;
|
200 |
|
201 |
+
if (count($user_hit_count) > 14) {
|
202 |
$shifted = @array_shift($user_hit_count);
|
203 |
}
|
204 |
|
version
CHANGED
@@ -1 +1 @@
|
|
1 |
-
3.8.
|
1 |
+
3.8.5
|