ManageWP Worker - Version 3.8.3

Version Description

  • Fixed problem with capabilities
Download this release

Release Info

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

Code changes from version 3.8.1 to 3.8.3

Files changed (16) hide show
  1. Screenshot-1.png +0 -0
  2. Screenshot-2.png +0 -0
  3. Screenshot-3.png +0 -0
  4. backup.class.php +5 -4
  5. core.class.php +188 -171
  6. helper.class.php +99 -152
  7. index.html +0 -0
  8. init.php +86 -55
  9. plugin.class.php +81 -50
  10. post.class.php +3 -7
  11. readme.txt +78 -68
  12. screenshot-1.png +0 -0
  13. stats.class.php +48 -50
  14. user.class.php +0 -34
  15. version +1 -1
  16. wp.class.php +97 -70
Screenshot-1.png DELETED
Binary file
Screenshot-2.png DELETED
Binary file
Screenshot-3.png DELETED
Binary file
backup.class.php CHANGED
@@ -20,6 +20,7 @@ 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
  mkdir($file_path, 0755, true);
24
  }
25
  parent::__construct();
@@ -46,7 +47,7 @@ class MMB_Backup extends MMB_Core
46
  }
47
 
48
  if (trim($what) == 'full' || trim($what) == 'content') {
49
- //take wp-conetnt backup
50
  $content_backup = $this->backup_wpcontent($type);
51
  if (!$content_backup) {
52
  @unlink($content_backup['path']);
@@ -57,7 +58,7 @@ class MMB_Backup extends MMB_Core
57
  }
58
 
59
  if (trim($what) == 'full' || trim($what) == 'db') {
60
- //take batabase backup
61
  $db_backup = $this->backup_db($type);
62
  if (!$db_backup) {
63
  if (trim($what) == 'full')
@@ -556,7 +557,7 @@ class MMB_Backup extends MMB_Core
556
  }
557
 
558
  $stats_function_disabled = 0;
559
-
560
  if (!function_exists('passthru')) {
561
  $stats_function_disabled++;
562
  }
@@ -615,4 +616,4 @@ class MMB_Backup extends MMB_Core
615
  }
616
 
617
  }
618
- ?>
20
  $file_path = $upload_dir['basedir'] . $file;
21
  file_put_contents($file_path . '/index.php', '');
22
  if (!file_exists($file_path)) {
23
+ // TODO: return error on failure
24
  mkdir($file_path, 0755, true);
25
  }
26
  parent::__construct();
47
  }
48
 
49
  if (trim($what) == 'full' || trim($what) == 'content') {
50
+ //take wp-content backup
51
  $content_backup = $this->backup_wpcontent($type);
52
  if (!$content_backup) {
53
  @unlink($content_backup['path']);
58
  }
59
 
60
  if (trim($what) == 'full' || trim($what) == 'db') {
61
+ //take database backup
62
  $db_backup = $this->backup_db($type);
63
  if (!$db_backup) {
64
  if (trim($what) == 'full')
557
  }
558
 
559
  $stats_function_disabled = 0;
560
+ // TODO: if none of these exists return with an appropriate error. else fallback passthru to whatever is available
561
  if (!function_exists('passthru')) {
562
  $stats_function_disabled++;
563
  }
616
  }
617
 
618
  }
619
+ ?>
core.class.php CHANGED
@@ -1,5 +1,14 @@
1
  <?php
2
-
 
 
 
 
 
 
 
 
 
3
  class MMB_Core extends MMB_Helper
4
  {
5
  var $name;
@@ -14,33 +23,47 @@ class MMB_Core extends MMB_Helper
14
  var $stats_instance;
15
  var $user_instance;
16
  var $backup_instance;
17
-
18
 
19
- function __construct(){
 
 
20
  global $mmb_plugin_dir;
21
-
22
- $this->name = 'Manage Multiple Blogs';
23
- $this->slug = 'manage-multiple-blogs';
24
  $this->settings = get_option($this->slug);
25
- if (!$this->settings)
26
- {
27
  $this->settings = array(
28
- 'blogs' => array(),
29
- 'current_blog' => array('type' => null)
 
 
30
  );
31
  }
32
- add_action('rightnow_end', array($this, 'add_right_now_info'));
33
- add_action('wp_footer', array('MMB_Stats', 'set_hit_count'));
34
- register_activation_hook($mmb_plugin_dir.'/init.php', array($this, 'install'));
35
- add_action('init', array($this, 'automatic_login'));
36
- }
37
-
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  /**
40
- * Add an item into the Right Now Dashboard widget
41
- * to inform that the blog can be managed remotely
42
- *
43
- */
44
  function add_right_now_info()
45
  {
46
  echo '<div class="mmb-slave-info">
@@ -49,13 +72,12 @@ class MMB_Core extends MMB_Helper
49
  }
50
 
51
  /**
52
- * Gets an instance of the Comment class
53
- *
54
- */
55
  function get_comment_instance()
56
  {
57
- if (!isset($this->comment_instance))
58
- {
59
  $this->comment_instance = new MMB_Comment();
60
  }
61
 
@@ -63,13 +85,12 @@ class MMB_Core extends MMB_Helper
63
  }
64
 
65
  /**
66
- * Gets an instance of the Plugin class
67
- *
68
- */
69
  function get_plugin_instance()
70
  {
71
- if (!isset($this->plugin_instance))
72
- {
73
  $this->plugin_instance = new MMB_Plugin();
74
  }
75
 
@@ -77,13 +98,12 @@ class MMB_Core extends MMB_Helper
77
  }
78
 
79
  /**
80
- * Gets an instance of the Theme class
81
- *
82
- */
83
  function get_theme_instance()
84
  {
85
- if (!isset($this->theme_instance))
86
- {
87
  $this->theme_instance = new MMB_Theme();
88
  }
89
 
@@ -92,13 +112,12 @@ class MMB_Core extends MMB_Helper
92
 
93
 
94
  /**
95
- * Gets an instance of MMB_Post class
96
- *
97
- */
98
  function get_post_instance()
99
  {
100
- if (!isset($this->post_instance))
101
- {
102
  $this->post_instance = new MMB_Post();
103
  }
104
 
@@ -106,29 +125,27 @@ class MMB_Core extends MMB_Helper
106
  }
107
 
108
  /**
109
- * Gets an instance of Blogroll class
110
- *
111
- */
112
  function get_blogroll_instance()
113
  {
114
- if (!isset($this->blogroll_instance))
115
- {
116
  $this->blogroll_instance = new MMB_Blogroll();
117
  }
118
 
119
  return $this->blogroll_instance;
120
  }
121
-
122
-
123
 
124
  /**
125
- * Gets an instance of the WP class
126
- *
127
- */
128
  function get_wp_instance()
129
  {
130
- if (!isset($this->wp_instance))
131
- {
132
  $this->wp_instance = new MMB_WP();
133
  }
134
 
@@ -136,13 +153,12 @@ class MMB_Core extends MMB_Helper
136
  }
137
 
138
  /**
139
- * Gets an instance of User
140
- *
141
- */
142
  function get_user_instance()
143
  {
144
- if (!isset($this->user_instance))
145
- {
146
  $this->user_instance = new MMB_User();
147
  }
148
 
@@ -150,155 +166,156 @@ class MMB_Core extends MMB_Helper
150
  }
151
 
152
  /**
153
- * Gets an instance of stats class
154
- *
155
- */
156
  function get_stats_instance()
157
  {
158
- if (!isset($this->stats_instance))
159
- {
160
  $this->stats_instance = new MMB_Stats();
161
  }
162
  return $this->stats_instance;
163
  }
164
 
165
  /**
166
- * Gets an instance of stats class
167
- *
168
- */
169
  function get_backup_instance()
170
  {
171
- if (!isset($this->backup_instance))
172
- {
173
  $this->backup_instance = new MMB_Backup();
174
  }
175
-
176
  return $this->backup_instance;
177
  }
178
 
179
  /**
180
- * Plugin install callback function
181
- * Check PHP version
182
- */
183
  function install()
184
- {
185
- delete_option('_worker_nossl_key');
186
- delete_option('_worker_public_key');
187
- delete_option('_action_message_id');
188
- if(PHP_VERSION < 5)
189
- exit("<p>Plugin could not be activated. Your PHP version must be 5.0 or higher.</p>");
 
 
 
190
  }
191
 
192
  /**
193
- * Saves the (modified) options into the database
194
- *
195
- */
196
  function _save_options()
197
  {
198
- if (get_option($this->slug))
199
- {
200
  update_option($this->slug, $this->settings);
201
- }
202
- else
203
- {
204
  add_option($this->slug, $this->settings);
205
  }
206
  }
207
 
208
  /**
209
- * Deletes options for communication with master
210
- *
211
- */
212
- function uninstall(){
213
- delete_option('_worker_nossl_key');
214
- delete_option('_worker_public_key');
215
- delete_option('_action_message_id');
216
- }
217
-
 
218
  /**
219
- * Constructs a url (for ajax purpose)
220
- *
221
- * @param mixed $base_page
222
- */
223
  function _construct_url($params = array(), $base_page = 'index.php')
224
  {
225
  $url = "$base_page?_wpnonce=" . wp_create_nonce($this->slug);
226
- foreach ($params as $key => $value)
227
- {
228
  $url .= "&$key=$value";
229
  }
230
 
231
  return $url;
232
  }
233
-
234
- /**
235
- * Worker update
236
- *
237
- */
238
- function update_worker_plugin($params) {
239
-
240
- extract($params);
241
- if($download_url){
242
-
243
- include_once(ABSPATH . 'wp-admin/includes/file.php');
244
- include_once ABSPATH . 'wp-admin/includes/misc.php';
245
- include_once ABSPATH . 'wp-admin/includes/template.php';
246
- include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
247
-
248
- ob_start();
249
- @unlink(dirname(__FILE__));
250
- $upgrader = new Plugin_Upgrader();
251
- $result = $upgrader->run(array(
252
- 'package' => $download_url,
253
- 'destination' => WP_PLUGIN_DIR,
254
- 'clear_destination' => true,
255
- 'clear_working' => true,
256
- 'hook_extra' => array(
257
- 'plugin' => 'worker/init.php'
258
- )));
259
- ob_end_clean();
260
- if(is_wp_error($result) || !$result){
261
- return array('error' => 'Manage WP Worker could not been upgraded.');
262
- }
263
- else{
264
- return array('success' => 'Manage WP Worker plugin successfully upgraded.');
265
- }
266
- }
267
- return array('error' => 'Bad download path for worker installation file.');
268
- }
269
-
 
 
 
 
 
270
  /**
271
- * Automatically logs in when called from Master
272
- *
273
- */
274
- function automatic_login(){
275
-
276
-
277
- $where = ($_GET['mwp_goto']);
278
- if (!is_user_logged_in() && $_GET['auto_login']) {
279
- $signature = base64_decode($_GET['signature']);
280
- $message_id = trim($_GET['message_id']);
281
- $username = $_GET['username'];
282
-
283
- $auth = $this->_authenticate_message($where.$message_id, $signature, $message_id);
284
- if($auth === true){
285
- $user = get_user_by('login', $username);
286
- $user_id = $user->ID;
287
- wp_set_current_user($user_id, $username);
288
- wp_set_auth_cookie( $user_id );
289
- do_action('wp_login', $username);
290
- }
291
- else
292
- {
293
- wp_die($auth['error']);
294
- }
295
- }
296
-
297
- if($_GET['auto_login']){
298
- wp_redirect(get_bloginfo('url')."/wp-admin/".$where);
299
- exit();
300
- }
301
- }
302
-
303
-
304
- }
1
  <?php
2
+ /*************************************************************
3
+ *
4
+ * core.class.php
5
+ *
6
+ * Upgrade Plugins
7
+ *
8
+ *
9
+ * Copyright (c) 2011 Prelovac Media
10
+ * www.prelovac.com
11
+ **************************************************************/
12
  class MMB_Core extends MMB_Helper
13
  {
14
  var $name;
23
  var $stats_instance;
24
  var $user_instance;
25
  var $backup_instance;
 
26
 
27
+
28
+ function __construct()
29
+ {
30
  global $mmb_plugin_dir;
31
+
32
+ $this->name = 'Manage Multiple Blogs';
33
+ $this->slug = 'manage-multiple-blogs';
34
  $this->settings = get_option($this->slug);
35
+ if (!$this->settings) {
 
36
  $this->settings = array(
37
+ 'blogs' => array(),
38
+ 'current_blog' => array(
39
+ 'type' => null
40
+ )
41
  );
42
  }
43
+ add_action('rightnow_end', array(
44
+ $this,
45
+ 'add_right_now_info'
46
+ ));
47
+ add_action('wp_footer', array(
48
+ 'MMB_Stats',
49
+ 'set_hit_count'
50
+ ));
51
+ register_activation_hook($mmb_plugin_dir . '/init.php', array(
52
+ $this,
53
+ 'install'
54
+ ));
55
+ add_action('init', array(
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
65
+ *
66
+ */
67
  function add_right_now_info()
68
  {
69
  echo '<div class="mmb-slave-info">
72
  }
73
 
74
  /**
75
+ * Gets an instance of the Comment class
76
+ *
77
+ */
78
  function get_comment_instance()
79
  {
80
+ if (!isset($this->comment_instance)) {
 
81
  $this->comment_instance = new MMB_Comment();
82
  }
83
 
85
  }
86
 
87
  /**
88
+ * Gets an instance of the Plugin class
89
+ *
90
+ */
91
  function get_plugin_instance()
92
  {
93
+ if (!isset($this->plugin_instance)) {
 
94
  $this->plugin_instance = new MMB_Plugin();
95
  }
96
 
98
  }
99
 
100
  /**
101
+ * Gets an instance of the Theme class
102
+ *
103
+ */
104
  function get_theme_instance()
105
  {
106
+ if (!isset($this->theme_instance)) {
 
107
  $this->theme_instance = new MMB_Theme();
108
  }
109
 
112
 
113
 
114
  /**
115
+ * Gets an instance of MMB_Post class
116
+ *
117
+ */
118
  function get_post_instance()
119
  {
120
+ if (!isset($this->post_instance)) {
 
121
  $this->post_instance = new MMB_Post();
122
  }
123
 
125
  }
126
 
127
  /**
128
+ * Gets an instance of Blogroll class
129
+ *
130
+ */
131
  function get_blogroll_instance()
132
  {
133
+ if (!isset($this->blogroll_instance)) {
 
134
  $this->blogroll_instance = new MMB_Blogroll();
135
  }
136
 
137
  return $this->blogroll_instance;
138
  }
139
+
140
+
141
 
142
  /**
143
+ * Gets an instance of the WP class
144
+ *
145
+ */
146
  function get_wp_instance()
147
  {
148
+ if (!isset($this->wp_instance)) {
 
149
  $this->wp_instance = new MMB_WP();
150
  }
151
 
153
  }
154
 
155
  /**
156
+ * Gets an instance of User
157
+ *
158
+ */
159
  function get_user_instance()
160
  {
161
+ if (!isset($this->user_instance)) {
 
162
  $this->user_instance = new MMB_User();
163
  }
164
 
166
  }
167
 
168
  /**
169
+ * Gets an instance of stats class
170
+ *
171
+ */
172
  function get_stats_instance()
173
  {
174
+ if (!isset($this->stats_instance)) {
 
175
  $this->stats_instance = new MMB_Stats();
176
  }
177
  return $this->stats_instance;
178
  }
179
 
180
  /**
181
+ * Gets an instance of stats class
182
+ *
183
+ */
184
  function get_backup_instance()
185
  {
186
+ if (!isset($this->backup_instance)) {
 
187
  $this->backup_instance = new MMB_Backup();
188
  }
189
+
190
  return $this->backup_instance;
191
  }
192
 
193
  /**
194
+ * Plugin install callback function
195
+ * Check PHP version
196
+ */
197
  function install()
198
+ {
199
+ if (PHP_VERSION < 5) // min version 5 supported
200
+ exit("<p>Plugin could not be activated. Your PHP version must be 5.0 or higher.</p>");
201
+
202
+ // delete plugin options, just in case
203
+ delete_option('_worker_nossl_key');
204
+ delete_option('_worker_public_key');
205
+ delete_option('_action_message_id');
206
+
207
  }
208
 
209
  /**
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);
217
+ } else {
 
 
218
  add_option($this->slug, $this->settings);
219
  }
220
  }
221
 
222
  /**
223
+ * Deletes options for communication with master
224
+ *
225
+ */
226
+ function uninstall()
227
+ {
228
+ delete_option('_worker_nossl_key');
229
+ delete_option('_worker_public_key');
230
+ delete_option('_action_message_id');
231
+ }
232
+
233
  /**
234
+ * Constructs a url (for ajax purpose)
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) {
 
242
  $url .= "&$key=$value";
243
  }
244
 
245
  return $url;
246
  }
247
+
248
+ /**
249
+ * Worker update
250
+ *
251
+ */
252
+ function update_worker_plugin($params)
253
+ {
254
+ extract($params);
255
+ if ($download_url) {
256
+ include_once ABSPATH . 'wp-admin/includes/file.php';
257
+ include_once ABSPATH . 'wp-admin/includes/misc.php';
258
+ include_once ABSPATH . 'wp-admin/includes/template.php';
259
+ include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
260
+
261
+ ob_start();
262
+ @unlink(dirname(__FILE__));
263
+ $upgrader = new Plugin_Upgrader();
264
+ $result = $upgrader->run(array(
265
+ 'package' => $download_url,
266
+ 'destination' => WP_PLUGIN_DIR,
267
+ 'clear_destination' => true,
268
+ 'clear_working' => true,
269
+ 'hook_extra' => array(
270
+ 'plugin' => 'worker/init.php'
271
+ )
272
+ ));
273
+ ob_end_clean();
274
+ if (is_wp_error($result) || !$result) {
275
+ return array(
276
+ 'error' => 'ManageWP Worker could not been upgraded.'
277
+ );
278
+ } else {
279
+ return array(
280
+ 'success' => 'ManageWP Worker plugin successfully upgraded.'
281
+ );
282
+ }
283
+ }
284
+ return array(
285
+ 'error' => 'Bad download path for worker installation file.'
286
+ );
287
+ }
288
+
289
  /**
290
+ * Automatically logs in when called from Master
291
+ *
292
+ */
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->_authenticate_message($where . $message_id, $signature, $message_id);
302
+ if ($auth === true) {
303
+ $user = get_user_by('login', $username);
304
+ $user_id = $user->ID;
305
+ wp_set_current_user($user_id, $username);
306
+ wp_set_auth_cookie($user_id);
307
+ do_action('wp_login', $username);
308
+ } else {
309
+ wp_die($auth['error']);
310
+ }
311
+ }
312
+
313
+ if ($_GET['auto_login']) {
314
+ wp_redirect(get_bloginfo('url') . "/wp-admin/" . $where);
315
+ exit();
316
+ }
317
+ }
318
+
319
+
320
+ }
321
+ ?>
 
 
helper.class.php CHANGED
@@ -3,7 +3,7 @@
3
  *
4
  * helper.class.php
5
  *
6
- * Various utility functions
7
  *
8
  *
9
  * Copyright (c) 2011 Prelovac Media
@@ -31,31 +31,7 @@ class MMB_Helper
31
  fwrite($handle, $mixed . PHP_EOL);
32
  fclose($handle);
33
  }
34
-
35
- /**
36
- * Strips WP disallowed HTML and PHP tags from a string
37
- *
38
- * @param mixed $str
39
- * @return string
40
- */
41
- function _strip_tags($str)
42
- {
43
- return strip_tags($str, '<address><a><abbr><acronym><area><b><big><blockquote><br><caption><cite><class><code><col><del><dd><div><dl><dt><em><font><h1><h2><h3><h4><h5><h6><hr><i><img><ins><kbd><li><map><ol><p><pre><q><s><span><strike><strong><sub><sup><table><tbody><td><tfoot><tr><tt><ul><var>');
44
- }
45
-
46
- /**
47
- * Filters a WordPress content (being comments, pages, posts etc)
48
- *
49
- * @param mixed $str
50
- * @return string
51
- */
52
- function _filter_content($str)
53
- {
54
- return nl2br($this->_strip_tags($str));
55
- }
56
-
57
-
58
-
59
  function _escape(&$array)
60
  {
61
  global $wpdb;
@@ -75,29 +51,6 @@ class MMB_Helper
75
  }
76
  }
77
 
78
- function _base64_encode($str)
79
- {
80
- // a plus sign can break the encoded string
81
- // if sent via URL
82
- return str_replace('+', '|', base64_encode($str));
83
- }
84
-
85
- function _base64_decode($str)
86
- {
87
- return base64_decode(str_replace('|', '+', $str));
88
- }
89
-
90
- function _print_r($arr)
91
- {
92
- if (is_string($arr))
93
- $arr = array(
94
- $arr
95
- );
96
- echo '<pre>';
97
- print_r($arr);
98
- echo '</pre>';
99
- }
100
-
101
  /**
102
  * Initializes the file system
103
  *
@@ -124,31 +77,29 @@ class MMB_Helper
124
  * @return mixed
125
  */
126
  function mmb_get_transient($option_name)
127
- {
128
- if (trim($option_name) == '') {
129
  return FALSE;
130
  }
131
 
132
  global $wp_version, $_wp_using_ext_object_cache;
133
 
134
- if (version_compare($wp_version, '2.8.0', '<')){
135
- return get_option($option_name);
136
- }
137
- else if (version_compare($wp_version, '3.0.0', '<')){
138
- if(get_transient($option_name))
139
- return get_transient($option_name);
140
- else
141
- return get_option('_transient_'.$option_name);
142
- }
143
- else {
144
- if(get_site_transient($option_name))
145
- return get_site_transient($option_name);
146
- else
147
- return get_option('_site_transient_'.$option_name);
148
  }
149
- }
150
-
151
- function mmb_delete_transient($option_name)
152
  {
153
  if (trim($option_name) == '') {
154
  return FALSE;
@@ -156,21 +107,19 @@ class MMB_Helper
156
 
157
  global $wp_version;
158
 
159
- if (version_compare($wp_version, '2.8.0', '<')){
160
- delete_option($option_name);
 
 
 
 
 
 
 
 
 
 
161
  }
162
- else if (version_compare($wp_version, '3.0.0', '<')){
163
- if(delete_transient($option_name))
164
- delete_transient($option_name);
165
- else
166
- delete_option('_transient_'.$option_name);
167
- }
168
- else {
169
- if(delete_site_transient($option_name))
170
- delete_site_transient($option_name);
171
- else
172
- delete_option('_site_transient_'.$option_name);
173
- }
174
  }
175
 
176
  function mmb_null_op_buffer($buffer)
@@ -252,29 +201,31 @@ class MMB_Helper
252
  return base64_decode(get_option('_worker_public_key'));
253
  }
254
 
255
- function _get_master_referer(){
256
- if (!get_option('_master_referer'))
 
257
  return false;
258
  return base64_decode(get_option('_master_referer'));
259
- }
260
-
261
- function _get_random_signature(){
262
- if (!get_option('_worker_nossl_key'))
 
263
  return false;
264
  return base64_decode(get_option('_worker_nossl_key'));
265
- }
266
-
267
- function _set_random_signature($random_key = false){
268
-
269
- if ($random_key && !get_option('_worker_nossl_key')){
270
- add_option('_worker_nossl_key', base64_encode($random_key));
271
- return true;
272
- }
273
- return false;
274
- }
275
-
276
 
277
- function _authenticate_message($data = false, $signature = false, $message_id = false)
 
 
 
 
 
 
 
 
 
 
278
  {
279
  if (!$data && !$signature) {
280
  return array(
@@ -286,55 +237,58 @@ class MMB_Helper
286
 
287
  if ((int) $current_message > (int) $message_id)
288
  return array(
289
- 'error' => 'Invalid message recieved. Please try again.'
290
  );
291
 
292
  $pl_key = $this->_get_master_public_key();
293
  if (!$pl_key) {
294
  return array(
295
- 'error' => 'Authentication failed (public key).'
296
  );
297
  }
298
-
299
- if( function_exists( 'openssl_verify' ) && !$this->_get_random_signature()){
300
- $verify = openssl_verify($data, $signature, $pl_key);
301
- if ($verify == 1) {
302
- $message_id = $this->_set_worker_message_id($message_id);
303
- return true;
304
- } else if ($verify == 0) {
305
- return array(
306
- 'error' => 'Invalid message signature (site is probably managed by another account?)'
307
- );
308
- } else {
309
- return array(
310
- 'error' => 'Command not successful! Please try again.'
311
- );
312
- }
313
  } else if ($this->_get_random_signature()) {
314
- if(md5($data.$this->_get_random_signature()) == $signature ){
315
- $message_id = $this->_set_worker_message_id($message_id);
316
- return true;
317
- }
318
- return array(
319
- 'error' => 'Invalid message signature. Please try again or re-add the site to your account.'
 
 
 
 
 
 
320
  );
321
- }
322
- // no rand key - deleted in get_stat maybe
323
- else return array(
324
- 'error' => 'Invalid message signature, try re-adding the site to your account.)'
325
- );
326
- }
327
 
328
  function _check_if_user_exists($username = false)
329
  {
 
330
  if ($username) {
331
  require_once(ABSPATH . WPINC . '/registration.php');
 
332
 
333
  if (username_exists($username) == null) {
334
  return false;
335
  }
336
- $user = get_userdatabylogin($username);
337
- if ($user->wp_user_level == 10) {
338
  define('MMB_USER_CAPABILITIES', $user->wp_user_level);
339
  return true;
340
  }
@@ -358,30 +312,23 @@ class MMB_Helper
358
  if ($url == 'http://' OR $url == 'https://') {
359
  return $url;
360
  }
361
- $matches = substr($url, 0, 7);
362
- if ($matches == 'http://') {
363
- $url = substr($url, 7);
 
 
 
 
 
364
  } else {
365
- $matches = substr($url, 0, 8);
366
- if ($matches == 'https://')
367
- $url = substr($url, 8);
 
 
368
  }
369
- return $url;
370
  }
371
-
372
- function mmb_get_error($error_object){
373
- if(!is_wp_error($error_object)){
374
- return $error_object != '' ? $error_object : ' error occured.';
375
- }
376
- else {
377
- $errors = array();
378
- foreach($error_object->error_data as $error_key => $error_string){
379
- $errors[] = str_replace('_', ' ', ucfirst($error_key)).' - '.$error_string;
380
- }
381
- return implode('<br />', $errors);
382
- }
383
- }
384
-
385
 
386
  }
387
  ?>
3
  *
4
  * helper.class.php
5
  *
6
+ * Utility functions
7
  *
8
  *
9
  * Copyright (c) 2011 Prelovac Media
31
  fwrite($handle, $mixed . PHP_EOL);
32
  fclose($handle);
33
  }
34
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  function _escape(&$array)
36
  {
37
  global $wpdb;
51
  }
52
  }
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  /**
55
  * Initializes the file system
56
  *
77
  * @return mixed
78
  */
79
  function mmb_get_transient($option_name)
80
+ {
81
+ if (trim($option_name) == '') {
82
  return FALSE;
83
  }
84
 
85
  global $wp_version, $_wp_using_ext_object_cache;
86
 
87
+ if (version_compare($wp_version, '2.8.0', '<')) {
88
+ return get_option($option_name);
89
+ } else if (version_compare($wp_version, '3.0.0', '<')) {
90
+ if (get_transient($option_name))
91
+ return get_transient($option_name);
92
+ else
93
+ return get_option('_transient_' . $option_name);
94
+ } else {
95
+ if (get_site_transient($option_name))
96
+ return get_site_transient($option_name);
97
+ else
98
+ return get_option('_site_transient_' . $option_name);
 
 
99
  }
100
+ }
101
+
102
+ function mmb_delete_transient($option_name)
103
  {
104
  if (trim($option_name) == '') {
105
  return FALSE;
107
 
108
  global $wp_version;
109
 
110
+ if (version_compare($wp_version, '2.8.0', '<')) {
111
+ delete_option($option_name);
112
+ } else if (version_compare($wp_version, '3.0.0', '<')) {
113
+ if (delete_transient($option_name))
114
+ delete_transient($option_name);
115
+ else
116
+ delete_option('_transient_' . $option_name);
117
+ } else {
118
+ if (delete_site_transient($option_name))
119
+ delete_site_transient($option_name);
120
+ else
121
+ delete_option('_site_transient_' . $option_name);
122
  }
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
124
 
125
  function mmb_null_op_buffer($buffer)
201
  return base64_decode(get_option('_worker_public_key'));
202
  }
203
 
204
+ function _get_master_referer()
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 _set_random_signature($random_key = false)
219
+ {
220
+ if ($random_key && !get_option('_worker_nossl_key')) {
221
+ add_option('_worker_nossl_key', base64_encode($random_key));
222
+ return true;
223
+ }
224
+ return false;
225
+ }
226
+
227
+
228
+ function _authenticate_message($data = false, $signature = false, $message_id = false)
229
  {
230
  if (!$data && !$signature) {
231
  return array(
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->_get_master_public_key();
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->_get_random_signature()) {
251
+ $verify = openssl_verify($data, $signature, $pl_key);
252
+ if ($verify == 1) {
253
+ $message_id = $this->_set_worker_message_id($message_id);
254
+ return true;
255
+ } else if ($verify == 0) {
256
+ return array(
257
+ 'error' => 'Invalid message signature. You can try to reinstall worker plugin and re-add the site to your account.'
258
+ );
259
+ } else {
260
+ return array(
261
+ 'error' => 'Command not successful! Please try again.'
262
+ );
263
+ }
264
  } else if ($this->_get_random_signature()) {
265
+ if (md5($data . $this->_get_random_signature()) == $signature) {
266
+ $message_id = $this->_set_worker_message_id($message_id);
267
+ return true;
268
+ }
269
+ return array(
270
+ 'error' => 'Invalid message signature. You can try to reinstall the worker plugin and then re-add the site to your dashboard.'
271
+ );
272
+ }
273
+ // no rand key - deleted in get_stat maybe
274
+ else
275
+ return array(
276
+ 'error' => 'Invalid message signature, try reinstalling worker plugin and re-adding the site to your dashboard.'
277
  );
278
+ }
 
 
 
 
 
279
 
280
  function _check_if_user_exists($username = false)
281
  {
282
+ global $wpdb;
283
  if ($username) {
284
  require_once(ABSPATH . WPINC . '/registration.php');
285
+ include_once(ABSPATH . 'wp-includes/pluggable.php');
286
 
287
  if (username_exists($username) == null) {
288
  return false;
289
  }
290
+ $user = (array)get_userdatabylogin($username);
291
+ if ($user[$wpdb->prefix.'user_level'] == 10 || isset($user[$wpdb->prefix.'capabilities']['administrator'])) {
292
  define('MMB_USER_CAPABILITIES', $user->wp_user_level);
293
  return true;
294
  }
312
  if ($url == 'http://' OR $url == 'https://') {
313
  return $url;
314
  }
315
+ return preg_replace('/^(http|https)\:\/\/(www.)?/i', '', $url);
316
+
317
+ }
318
+
319
+ function mmb_get_error($error_object)
320
+ {
321
+ if (!is_wp_error($error_object)) {
322
+ return $error_object != '' ? $error_object : ' error occured.';
323
  } else {
324
+ $errors = array();
325
+ foreach ($error_object->error_data as $error_key => $error_string) {
326
+ $errors[] = str_replace('_', ' ', ucfirst($error_key)) . ' - ' . $error_string;
327
+ }
328
+ return implode('<br />', $errors);
329
  }
 
330
  }
331
+
 
 
 
 
 
 
 
 
 
 
 
 
 
332
 
333
  }
334
  ?>
index.html ADDED
File without changes
init.php CHANGED
@@ -4,16 +4,27 @@ 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.1
8
  Author URI: http://www.prelovac.com
9
  */
10
 
 
 
 
 
 
 
 
 
 
 
 
11
  // PHP warnings can break our XML stuffs
12
  if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
13
  error_reporting(E_ERROR);
14
  }
15
 
16
- define('MMB_WORKER_VERSION', '3.8.1');
17
 
18
  global $wpdb, $mmb_plugin_dir, $mmb_plugin_url;
19
 
@@ -28,17 +39,22 @@ require_once("$mmb_plugin_dir/theme.class.php");
28
  require_once("$mmb_plugin_dir/wp.class.php");
29
  require_once("$mmb_plugin_dir/post.class.php");
30
  require_once("$mmb_plugin_dir/stats.class.php");
31
- require_once("$mmb_plugin_dir/user.class.php");
32
  require_once("$mmb_plugin_dir/backup.class.php");
33
 
34
  $mmb_core = new MMB_Core();
35
  add_action('init', '_mmb_parse_request');
36
 
37
  if (function_exists('register_activation_hook'))
38
- register_activation_hook(__FILE__, array($mmb_core, 'install'));
 
 
 
39
 
40
  if (function_exists('register_deactivation_hook'))
41
- register_deactivation_hook(__FILE__, array($mmb_core, 'uninstall'));
 
 
 
42
 
43
  function _mmb_parse_request()
44
  {
@@ -46,22 +62,22 @@ function _mmb_parse_request()
46
  $HTTP_RAW_POST_DATA = file_get_contents('php://input');
47
  }
48
  ob_start();
49
-
50
  global $mmb_core;
51
  $data = base64_decode($HTTP_RAW_POST_DATA);
52
  $num = extract(unserialize($data));
53
 
54
  if ($action) {
55
  if (!$mmb_core->_check_if_user_exists($params['username']))
56
- mmb_response('Username <b>'.$params['username'].'</b> does not have administrator capabilities. Enter the correct username in the site options.', false);
57
 
58
- if ($action == 'add_site') {
59
- mmb_add_site($params);
60
- mmb_response('You should never see this.', false);
61
  }
62
 
63
  $auth = $mmb_core->_authenticate_message($action . $id, $signature, $id);
64
- if ($auth === true) {
65
  $mmb_actions = array(
66
  'remove_site' => 'mmb_remove_site',
67
  'get_stats' => 'mmb_stats_get',
@@ -81,14 +97,12 @@ function _mmb_parse_request()
81
  call_user_func($mmb_actions[$action], $params);
82
  else
83
  mmb_response('Action "' . $action . '" does not exist.', false);
84
- } else if(array_key_exists('openssl_activated', $auth)){
85
- mmb_response($auth, true);
86
- } else {
87
  mmb_response($auth['error'], false);
88
  }
89
  }
90
-
91
-
92
  ob_end_clean();
93
  }
94
 
@@ -106,7 +120,7 @@ function mmb_response($response = false, $success = true)
106
  $return['error'] = $response;
107
 
108
  header('Content-Type: text/plain');
109
- exit(PHP_EOL.base64_encode(serialize($return)));
110
  }
111
 
112
  function mmb_add_site($params)
@@ -114,55 +128,72 @@ function mmb_add_site($params)
114
  global $mmb_core;
115
 
116
  $num = extract($params);
117
-
118
  if ($num) {
119
- if ( !get_option('_action_message_id') && !get_option('_worker_public_key')) {
120
- $public_key = base64_decode($public_key) ;
121
-
122
- if ( function_exists('openssl_verify') ) {
123
- $verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
124
- if ($verify == 1) {
125
- $mmb_core->_set_master_public_key($public_key);
126
- $mmb_core->_set_worker_message_id($id);
127
-
128
- mmb_response($mmb_core->get_stats_instance()->get_initial_stats(), true);
129
- } else if ($verify == 0) {
130
- mmb_response('Invalid message signature (site is probably managed by another account?)', false);
131
- } else {
132
- mmb_response('Command not successful. Please try again.', false);
133
- }
134
- } else{
135
- if ( !get_option('_worker_nossl_key')) {
136
- $random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
137
-
138
- $mmb_core->_set_random_signature($random_key);
139
- $mmb_core->_set_worker_message_id($id);
140
- $mmb_core->_set_master_public_key($public_key);
141
-
142
- mmb_response($mmb_core->get_stats_instance()->get_initial_stats(), true);
143
- }
144
- else mmb_response('Site seems to be already managed by another ManageWP account. Either remove the site from that account, or deactivate & activate the ManageWP Worker plugin to reset.', false);
145
- }
146
  } else {
147
- mmb_response('Site seems to be already managed by another ManageWP account. Either remove the site from that account, or deactivate & activate the ManageWP Worker plugin to reset.', false);
148
  }
149
  } else {
150
  mmb_response('Invalid parameters received. Please try again.', false);
151
  }
152
  }
153
 
154
- function mmb_remove_site()
155
  {
 
156
  global $mmb_core;
157
  $mmb_core->uninstall();
158
- mmb_response('ManageWP Worker data successfully removed.', true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  }
160
 
161
 
162
  function mmb_stats_get($params)
163
- {
164
- global $mmb_core;
165
- mmb_response($mmb_core->get_stats_instance()->get($params), true);
166
  }
167
 
168
 
@@ -178,9 +209,9 @@ function mmb_plugin_upload_by_url($params)
178
  {
179
  global $mmb_core;
180
  $return = $mmb_core->get_plugin_instance()->upload_by_url($params);
181
-
182
 
183
- mmb_response($return['message'],$return['bool'] );
 
184
 
185
  }
186
 
@@ -189,7 +220,7 @@ function mmb_theme_upload_by_url($params)
189
  {
190
  global $mmb_core;
191
  $return = $mmb_core->get_theme_instance()->upload_theme_by_url($params);
192
- mmb_response($return['message'],$return['bool'] );
193
  }
194
 
195
  function mmb_themes_upgrade($params)
@@ -204,7 +235,7 @@ function mmb_themes_upgrade($params)
204
  function mmb_upgrade_wp($params)
205
  {
206
  global $mmb_core;
207
- mmb_response($mmb_core->get_wp_instance()->upgrade());
208
  }
209
 
210
  //post
4
  Plugin URI: http://managewp.com/
5
  Description: Manage all your blogs from one dashboard
6
  Author: Prelovac Media
7
+ Version: 3.8.3
8
  Author URI: http://www.prelovac.com
9
  */
10
 
11
+ /*************************************************************
12
+ *
13
+ * init.php
14
+ *
15
+ * Initialize the communication with master
16
+ *
17
+ *
18
+ * Copyright (c) 2011 Prelovac Media
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.3');
28
 
29
  global $wpdb, $mmb_plugin_dir, $mmb_plugin_url;
30
 
39
  require_once("$mmb_plugin_dir/wp.class.php");
40
  require_once("$mmb_plugin_dir/post.class.php");
41
  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', '_mmb_parse_request');
46
 
47
  if (function_exists('register_activation_hook'))
48
+ register_activation_hook(__FILE__, array(
49
+ $mmb_core,
50
+ 'install'
51
+ ));
52
 
53
  if (function_exists('register_deactivation_hook'))
54
+ register_deactivation_hook(__FILE__, array(
55
+ $mmb_core,
56
+ 'uninstall'
57
+ ));
58
 
59
  function _mmb_parse_request()
60
  {
62
  $HTTP_RAW_POST_DATA = file_get_contents('php://input');
63
  }
64
  ob_start();
65
+
66
  global $mmb_core;
67
  $data = base64_decode($HTTP_RAW_POST_DATA);
68
  $num = extract(unserialize($data));
69
 
70
  if ($action) {
71
  if (!$mmb_core->_check_if_user_exists($params['username']))
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') {
75
+ mmb_add_site($params);
76
+ mmb_response('You should never see this.', false);
77
  }
78
 
79
  $auth = $mmb_core->_authenticate_message($action . $id, $signature, $id);
80
+ if ($auth === true) {
81
  $mmb_actions = array(
82
  'remove_site' => 'mmb_remove_site',
83
  'get_stats' => 'mmb_stats_get',
97
  call_user_func($mmb_actions[$action], $params);
98
  else
99
  mmb_response('Action "' . $action . '" does not exist.', false);
100
+ } else {
 
 
101
  mmb_response($auth['error'], false);
102
  }
103
  }
104
+
105
+
106
  ob_end_clean();
107
  }
108
 
120
  $return['error'] = $response;
121
 
122
  header('Content-Type: text/plain');
123
+ exit(PHP_EOL . base64_encode(serialize($return)));
124
  }
125
 
126
  function mmb_add_site($params)
128
  global $mmb_core;
129
 
130
  $num = extract($params);
131
+
132
  if ($num) {
133
+ if (!get_option('_action_message_id') && !get_option('_worker_public_key')) {
134
+ $public_key = base64_decode($public_key);
135
+
136
+ if (function_exists('openssl_verify')) {
137
+ $verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
138
+ if ($verify == 1) {
139
+ $mmb_core->_set_master_public_key($public_key);
140
+ $mmb_core->_set_worker_message_id($id);
141
+
142
+ mmb_response($mmb_core->get_stats_instance()->get_initial_stats(), true);
143
+ } else if ($verify == 0) {
144
+ mmb_response('Invalid message signature. Please contact us if you see this message often.', false);
145
+ } else {
146
+ mmb_response('Command not successful. Please try again.', false);
147
+ }
148
+ } else {
149
+ if (!get_option('_worker_nossl_key')) {
150
+ srand();
151
+ $random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
152
+
153
+ $mmb_core->_set_random_signature($random_key);
154
+ $mmb_core->_set_worker_message_id($id);
155
+ $mmb_core->_set_master_public_key($public_key);
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);
159
+ }
160
  } else {
161
+ mmb_response('Please deactivate & activate ManageWP Worker plugin on your site and re-add the site to your dashboard.', false);
162
  }
163
  } else {
164
  mmb_response('Invalid parameters received. Please try again.', false);
165
  }
166
  }
167
 
168
+ function mmb_remove_site($params)
169
  {
170
+ extract($params);
171
  global $mmb_core;
172
  $mmb_core->uninstall();
173
+
174
+ include_once(ABSPATH . 'wp-admin/includes/plugin.php');
175
+ $plugin_slug = basename(dirname(__FILE__)) . '/' . basename(__FILE__);
176
+
177
+ if ($deactivate) {
178
+ deactivate_plugins($plugin_slug, true);
179
+ }
180
+
181
+ if (!is_plugin_active($plugin_slug))
182
+ mmb_response(array(
183
+ 'deactivated' => 'Site removed successfully. <br /><br />ManageWP Worker plugin successfully deactivated.'
184
+ ), true);
185
+ else
186
+ mmb_response(array(
187
+ 'removed_data' => 'Site removed successfully. <br /><br /><b>ManageWP Worker plugin was not deactivated.</b>'
188
+ ), true);
189
+
190
  }
191
 
192
 
193
  function mmb_stats_get($params)
194
+ {
195
+ global $mmb_core;
196
+ mmb_response($mmb_core->get_stats_instance()->get($params), true);
197
  }
198
 
199
 
209
  {
210
  global $mmb_core;
211
  $return = $mmb_core->get_plugin_instance()->upload_by_url($params);
 
212
 
213
+
214
+ mmb_response($return['message'], $return['bool']);
215
 
216
  }
217
 
220
  {
221
  global $mmb_core;
222
  $return = $mmb_core->get_theme_instance()->upload_theme_by_url($params);
223
+ mmb_response($return['message'], $return['bool']);
224
  }
225
 
226
  function mmb_themes_upgrade($params)
235
  function mmb_upgrade_wp($params)
236
  {
237
  global $mmb_core;
238
+ mmb_response($mmb_core->get_wp_instance()->upgrade());
239
  }
240
 
241
  //post
plugin.class.php CHANGED
@@ -1,5 +1,14 @@
1
  <?php
2
-
 
 
 
 
 
 
 
 
 
3
  class MMB_Plugin extends MMB_Core
4
  {
5
  var $worker_maitanance_mode = false;
@@ -7,24 +16,23 @@ class MMB_Plugin extends MMB_Core
7
  {
8
  parent::__construct();
9
  }
10
-
11
-
12
  /**
13
  * Upgrades all upgradable plugins on this blog
14
  *
15
  * @param mixed $args
16
  */
17
  function upgrade_all($params)
18
- {
19
- $upgradable_plugins = $this->_get_upgradable_plugins();
20
-
21
- $ready_for_upgrade =array();
22
- if(!empty($upgradable_plugins)){
23
- foreach($upgradable_plugins as $upgrade ){
24
- $ready_for_upgrade[] = $upgrade->file;
25
- }
26
- }
27
- $return = '';
28
  if (!empty($ready_for_upgrade)) {
29
  ob_start();
30
  include_once(ABSPATH . 'wp-admin/includes/file.php');
@@ -33,27 +41,32 @@ class MMB_Plugin extends MMB_Core
33
  if (class_exists('Plugin_Upgrader')) {
34
  $upgrader = new Plugin_Upgrader(new Bulk_Plugin_Upgrader_Skin(compact('nonce', 'url')));
35
  $result = $upgrader->bulk_upgrade($ready_for_upgrade);
36
- ob_end_clean();
37
  foreach ($result as $plugin_slug => $plugin_info) {
38
- $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_slug);
39
- if(!$plugin_info || is_wp_error($plugin_info)){
40
- $return .= '<code title="Please upgrade manually">' . $data['Name'] . '</code> was not upgraded.<br />';
41
- }else{
42
- $return .= '<code>' . $data['Name'] . '</code> successfully upgraded.<br />';
43
- }
44
  }
45
- ob_end_clean();
46
- return array('upgraded' => $return);
 
 
 
 
 
 
 
47
  }
48
- else {
49
- ob_end_clean();
50
- return array('error' => 'Could not initialize upgrader.');
51
- }
52
  }
53
- return array('error' => 'No plugins to upgrade at the moment');
 
 
54
  }
55
 
56
- /**
57
  * Uploads a plugin, given its package url
58
  *
59
  * @param mixed $args
@@ -87,43 +100,61 @@ class MMB_Plugin extends MMB_Core
87
 
88
 
89
  if (is_wp_error($upgrader->skin->result) || !$upgrader->plugin_info()) {
90
- return array('bool' => false, 'message' => 'Plugin was not installed.');
 
 
 
91
  }
92
-
93
  if ($activate_plugin) {
94
  $success = activate_plugin($upgrader->plugin_info(), '', false);
95
 
96
  if (!is_wp_error($success)) {
97
- return array('bool' => true, 'message' => 'Plugin '.$upgrader->result[destination_name].' successfully installed and activated ');
 
 
 
98
  }
99
- return array('bool' => true, 'message' => 'Plugin '.$upgrader->result[destination_name].' successfully installed ');
 
 
 
100
  } else {
101
- return (!$result or is_wp_error($result)) ? array('bool' => false, 'message' => 'Upload failed.') : array('bool' => true, 'message' => 'Plugin '.$upgrader->result[destination_name].' successfully installed ');
 
 
 
 
 
 
102
  }
103
 
104
  } else
105
- return array('bool' => false, 'message' => 'Missing plugin.');
 
 
 
106
 
107
  }
108
 
109
  function _get_upgradable_plugins()
110
  {
111
- $current = $this->mmb_get_transient('update_plugins');
112
- $upgradable_plugins = array();
113
- if(!empty($current->response)){
114
- foreach ($current->response as $plugin_path => $plugin_data) {
115
- if (!function_exists('get_plugin_data'))
116
- include_once ABSPATH . 'wp-admin/includes/plugin.php';
117
- $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_path);
118
-
119
- $current->response[$plugin_path]->name = $data['Name'];
120
- $current->response[$plugin_path]->old_version = $data['Version'];
121
- $current->response[$plugin_path]->file = $plugin_path;
122
- $upgradable_plugins[] = $current->response[$plugin_path];
123
- }
124
- return $upgradable_plugins;
125
- }
126
- else return array();
127
 
128
  }
129
 
1
  <?php
2
+ /*************************************************************
3
+ *
4
+ * plugin.class.php
5
+ *
6
+ * Upgrade Plugins
7
+ *
8
+ *
9
+ * Copyright (c) 2011 Prelovac Media
10
+ * www.prelovac.com
11
+ **************************************************************/
12
  class MMB_Plugin extends MMB_Core
13
  {
14
  var $worker_maitanance_mode = false;
16
  {
17
  parent::__construct();
18
  }
19
+
 
20
  /**
21
  * Upgrades all upgradable plugins on this blog
22
  *
23
  * @param mixed $args
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)) {
31
+ foreach ($upgradable_plugins as $upgrade) {
32
+ $ready_for_upgrade[] = $upgrade->file;
33
+ }
34
+ }
35
+ $return = '';
36
  if (!empty($ready_for_upgrade)) {
37
  ob_start();
38
  include_once(ABSPATH . 'wp-admin/includes/file.php');
41
  if (class_exists('Plugin_Upgrader')) {
42
  $upgrader = new Plugin_Upgrader(new Bulk_Plugin_Upgrader_Skin(compact('nonce', 'url')));
43
  $result = $upgrader->bulk_upgrade($ready_for_upgrade);
44
+ ob_end_clean();
45
  foreach ($result as $plugin_slug => $plugin_info) {
46
+ $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_slug);
47
+ if (!$plugin_info || is_wp_error($plugin_info)) {
48
+ $return .= '<code title="Please upgrade manually">' . $data['Name'] . '</code> was not upgraded.<br />';
49
+ } else {
50
+ $return .= '<code>' . $data['Name'] . '</code> successfully upgraded.<br />';
51
+ }
52
  }
53
+ ob_end_clean();
54
+ return array(
55
+ 'upgraded' => $return
56
+ );
57
+ } else {
58
+ ob_end_clean();
59
+ return array(
60
+ 'error' => 'Could not initialize upgrader.'
61
+ );
62
  }
 
 
 
 
63
  }
64
+ return array(
65
+ 'error' => 'No plugins to upgrade at the moment'
66
+ );
67
  }
68
 
69
+ /**
70
  * Uploads a plugin, given its package url
71
  *
72
  * @param mixed $args
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');
143
+ $upgradable_plugins = array();
144
+ if (!empty($current->response)) {
145
+ foreach ($current->response as $plugin_path => $plugin_data) {
146
+ if (!function_exists('get_plugin_data'))
147
+ include_once ABSPATH . 'wp-admin/includes/plugin.php';
148
+ $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_path);
149
+
150
+ $current->response[$plugin_path]->name = $data['Name'];
151
+ $current->response[$plugin_path]->old_version = $data['Version'];
152
+ $current->response[$plugin_path]->file = $plugin_path;
153
+ $upgradable_plugins[] = $current->response[$plugin_path];
154
+ }
155
+ return $upgradable_plugins;
156
+ } else
157
+ return array();
158
 
159
  }
160
 
post.class.php CHANGED
@@ -41,7 +41,7 @@ class MMB_Post extends MMB_Core
41
 
42
  $upload = wp_upload_dir();
43
 
44
- // create dynamic url RegExp
45
  $mwp_base_url = parse_url($post_upload_dir['url']);
46
  $mwp_regexp_url = $mwp_base_url['host'] . $mwp_base_url['path'];
47
  $rep = array(
@@ -122,7 +122,7 @@ class MMB_Post extends MMB_Core
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;
@@ -325,11 +325,7 @@ class MMB_Post extends MMB_Core
325
  update_post_meta($post_id, $meta_key, $value[0]);
326
  }
327
  }
328
-
329
-
330
- return $post_id;
331
-
332
-
333
  }
334
 
335
  /**
41
 
42
  $upload = wp_upload_dir();
43
 
44
+ // create dynamic url RegExp
45
  $mwp_base_url = parse_url($post_upload_dir['url']);
46
  $mwp_regexp_url = $mwp_base_url['host'] . $mwp_base_url['path'];
47
  $rep = array(
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;
325
  update_post_meta($post_id, $meta_key, $value[0]);
326
  }
327
  }
328
+ return $post_id;
 
 
 
 
329
  }
330
 
331
  /**
readme.txt CHANGED
@@ -1,68 +1,78 @@
1
- === ManageWP Worker ===
2
- Contributors: freediver
3
- Donate link: https://www.networkforgood.org/donation/MakeDonation.aspx?ORGID2=520781390
4
- Tags: managewp, managewp worker, admin, manage blogs, multi blog manager, manage multiple blogs
5
- Requires at least: 3.0
6
- Tested up to: 3.1
7
- Stable tag: trunk
8
-
9
- ManageWP Worker plugin allows you to remotely manage your blogs from one dashboard.
10
-
11
- == Description ==
12
-
13
- ManageWP is a revolutionary plugin that allows you to manage multiple WordPress blogs from one dashboard.
14
-
15
- Features:
16
- - One click WordPress, plugin and themes upgrades across all sites
17
- - Access admin of any site without leaving the dasboard
18
- - Publish posts to multiple sites at once
19
- - Add links to blogroll and add new user to multiple sites
20
- - Automatic backups of your sites
21
- - Clone one site to another
22
- - Many, many more...
23
-
24
- Check out [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs")
25
-
26
- == Changelog ==
27
-
28
- = 3.8.1 =
29
- * New interface
30
- * SSL security protocl
31
- * many more
32
-
33
-
34
- = 3.6.3 =
35
- * Initial public release
36
-
37
- == Installation ==
38
-
39
- 1. Upload the whole plugin folder to your /wp-content/plugins/ folder.
40
- 2. Go to the Plugins page and activate the plugin.
41
- 3. Visit [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs"), sign up and add your blogs
42
-
43
-
44
- == Screenshots ==
45
-
46
- 1. Global dashboard with quick upgrades
47
- 2. Manage every blog with statistics
48
- 3. ManageWP.com
49
-
50
-
51
-
52
- == License ==
53
-
54
- This file is part of ManageWP Worker.
55
-
56
- ManageWP Worker is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
57
-
58
- ManageWP Worker is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
59
-
60
- You should have received a copy of the GNU General Public License along with ManageWP Worker. If not, see <http://www.gnu.org/licenses/>.
61
-
62
-
63
- == Frequently Asked Questions ==
64
-
65
- = I have problems installing new plugins =
66
-
67
- ManageWP Worker currently relies on file permissions set up correctly on your server, in order to write files to your plugin folder. Some servers require ftp login details to write the files and Plugin Central will support this option in the future.
68
-
 
 
 
 
 
 
 
 
 
 
1
+ === ManageWP Worker ===
2
+ Contributors: freediver
3
+ Donate link: https://www.networkforgood.org/donation/MakeDonation.aspx?ORGID2=520781390
4
+ Tags: managewp, managewp worker, admin, manage blogs, multi blog manager, manage multiple blogs, remote blog management
5
+ Requires at least: 3.0
6
+ Tested up to: 3.1
7
+ Stable tag: trunk
8
+
9
+ ManageWP Worker plugin allows you to remotely manage your blogs from one dashboard.
10
+
11
+ == Description ==
12
+
13
+ ManageWP is a revolutionary plugin that allows you to manage multiple WordPress blogs from one dashboard.
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
20
+ * Bulk upload themes and plugins to multiple sites at once
21
+ * Automatic backups of your sites
22
+ * Clone one site to another
23
+ * Much, much more...
24
+
25
+ Check out [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs")
26
+
27
+ == Changelog ==
28
+
29
+ = 3.8.3 =
30
+ * Fixed problem with capabilities
31
+
32
+ = 3.8.2 =
33
+ * New interface
34
+ * SSL security protocol
35
+ * No passwords required
36
+ * Improved clone/backup
37
+
38
+
39
+ = 3.6.3 =
40
+ * Initial public release
41
+
42
+ == Installation ==
43
+
44
+ 1. Upload the plugin folder to your /wp-content/plugins/ folder
45
+ 2. Go to the Plugins page and activate ManageWP Worker
46
+ 3. Visit [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs"), sign up and add your site
47
+
48
+ Alternately
49
+
50
+ 1. Visit [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs"), sign up and add your site
51
+ 2. ManageWP willw arn you the worker plugin is not install and offer a link for quick installation
52
+
53
+ == Screenshots ==
54
+
55
+ 1. ManageWP dashboard with available upgrades, site statistics and management functions
56
+
57
+
58
+
59
+ == License ==
60
+
61
+ This file is part of ManageWP Worker.
62
+
63
+ ManageWP Worker is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
64
+
65
+ ManageWP Worker is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
66
+
67
+ You should have received a copy of the GNU General Public License along with ManageWP Worker. If not, see <http://www.gnu.org/licenses/>.
68
+
69
+
70
+ == Frequently Asked Questions ==
71
+
72
+ = I have problems adding my site =
73
+
74
+ Make sure you use the latest version of the worker plugin on the site you are trying to add. If you do, sometimes deactivating and activating it again will help. If you still have problems, [contact us](http://managewp.com/contact "ManageWP Contact").
75
+
76
+ = I have problems installing new plugins or upgrading WordPress through ManageWP =
77
+
78
+ ManageWP Worker relies on properly set file permissions on your server. See the [user guide](http://managewp.com/user-guide#ftp "ManageWP user guide") for more tips.
screenshot-1.png ADDED
Binary file
stats.class.php CHANGED
@@ -1,4 +1,16 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
2
  class MMB_Stats extends MMB_Core
3
  {
4
  function __construct()
@@ -16,25 +28,25 @@ class MMB_Stats extends MMB_Core
16
  global $wp_version, $mmb_plugin_dir;
17
  $stats = array();
18
 
19
- //define constants
20
- $num_pending_comments = 3;
21
  $num_approved_comments = 3;
22
- $num_spam_comments = 0;
23
- $num_draft_comments = 0;
24
- $num_trash_comments = 0;
25
 
26
  require_once(ABSPATH . '/wp-admin/includes/update.php');
27
-
28
-
29
  $updates = $this->mmb_get_transient('update_core');
30
-
31
- if($updates->updates[0]->response == 'development' || version_compare($wp_version, $updates->updates[0]->current, '<')){
32
- $updates->updates[0]->current_version = $wp_version;
33
- $stats['core_udates'] = $updates->updates[0];
34
- }else
35
- $stats['core_udates'] = false;
36
-
37
- $mmb_user_hits = get_option('user_hit_count');
38
  if (is_array($mmb_user_hits)) {
39
  end($mmb_user_hits);
40
  $last_key_date = key($mmb_user_hits);
@@ -47,28 +59,27 @@ class MMB_Stats extends MMB_Core
47
  $stats['upgradable_themes'] = $this->get_theme_instance()->_get_upgradable_themes();
48
  $stats['upgradable_plugins'] = $this->get_plugin_instance()->_get_upgradable_plugins();
49
 
50
- $pending_comments = get_comments('status=hold&number='.$num_pending_comments);
51
  foreach ($pending_comments as &$comment) {
52
  $commented_post = get_post($comment->comment_post_ID);
53
  $comment->post_title = $commented_post->post_title;
54
  }
55
- $approved_comments = get_comments('status=approve&number='.$num_approved_comments);
 
 
 
56
  foreach ($approved_comments as &$comment) {
57
  $commented_post = get_post($comment->comment_post_ID);
58
  $comment->post_title = $commented_post->post_title;
59
  }
60
-
61
-
62
- $stats['comments']['pending'] = $pending_comments;
63
  $stats['comments']['approved'] = $approved_comments;
64
-
65
 
66
  $all_posts = get_posts('post_status=publish&numberposts=3&orderby=modified&order=desc');
67
  $stats['publish_count'] = count($all_posts);
68
  $recent_posts = array();
69
-
70
  foreach ($all_posts as $id => $recent) {
71
-
72
  $recent->post_permalink = get_permalink($recent->ID);
73
  unset($recent->post_content);
74
  unset($recent->post_author);
@@ -111,18 +122,10 @@ class MMB_Stats extends MMB_Core
111
  $stats['drafts'] = $drafts;
112
 
113
 
114
- if( function_exists( 'openssl_verify' ) ){
115
- $stats['no_openssl'] = $this->_get_random_signature();
116
- }
117
- else {
118
- delete_option('_worker_nossl_key');
119
- $stats['no_openssl'] = false;
120
- }
121
-
122
  if ((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && !is_writable(WP_CONTENT_DIR)) {
123
  $stats['writable'] = false;
124
- }
125
- else $stats['writable'] = true;
126
  return $stats;
127
  }
128
 
@@ -140,23 +143,19 @@ class MMB_Stats extends MMB_Core
140
  $stats['site_title'] = get_bloginfo('name');
141
  $stats['site_tagline'] = get_bloginfo('description');
142
 
143
-
144
  if ((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && !is_writable(WP_CONTENT_DIR)) {
145
  $stats['writable'] = false;
146
- }
147
- else $stats['writable'] = true;
148
 
149
  return $stats;
150
  }
151
-
152
-
153
-
154
-
155
-
156
  function set_hit_count($fix_count = false)
157
  {
158
-
159
- if ($fix_count || (!is_admin() && !MMB_Stats::detect_bots() )) {
160
  $date = date('Y-m-d');
161
  $user_hit_count = get_option('user_hit_count');
162
  if (!$user_hit_count) {
@@ -165,18 +164,17 @@ class MMB_Stats extends MMB_Core
165
  } else {
166
  $dated_keys = array_keys($user_hit_count);
167
  $last_visit_date = $dated_keys[count($dated_keys) - 1];
168
-
169
  $days = intval((strtotime($date) - strtotime($last_visit_date)) / 60 / 60 / 24);
170
 
171
- if ($days > 1) {
172
-
173
  $date_to_add = date('Y-m-d', strtotime($last_visit_date));
174
 
175
  for ($i = 1; $i < $days; $i++) {
176
  if (count($user_hit_count) > 14) {
177
  $shifted = @array_shift($user_hit_count);
178
  }
179
-
180
  $next_key = strtotime('+1 day', strtotime($date_to_add));
181
  if ($next_key == $date) {
182
  break;
@@ -184,7 +182,7 @@ class MMB_Stats extends MMB_Core
184
  $user_hit_count[$next_key] = 0;
185
  }
186
  }
187
-
188
  }
189
 
190
  if (!isset($user_hit_count[$date])) {
@@ -197,7 +195,7 @@ class MMB_Stats extends MMB_Core
197
  $shifted = @array_shift($user_hit_count);
198
  }
199
 
200
- update_option('user_hit_count', $user_hit_count);
201
 
202
  }
203
  }
@@ -219,7 +217,7 @@ class MMB_Stats extends MMB_Core
219
  }
220
 
221
  function detect_bots()
222
- {
223
  $agent = $_SERVER['HTTP_USER_AGENT'];
224
 
225
  if ($agent == '')
1
  <?php
2
+ /*************************************************************
3
+ *
4
+ * stats.class.php
5
+ *
6
+ * Get Site Stats
7
+ *
8
+ *
9
+ * Copyright (c) 2011 Prelovac Media
10
+ * www.prelovac.com
11
+ **************************************************************/
12
+
13
+
14
  class MMB_Stats extends MMB_Core
15
  {
16
  function __construct()
28
  global $wp_version, $mmb_plugin_dir;
29
  $stats = array();
30
 
31
+ //define constants
32
+ $num_pending_comments = 3;
33
  $num_approved_comments = 3;
34
+ $num_spam_comments = 0;
35
+ $num_draft_comments = 0;
36
+ $num_trash_comments = 0;
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, '<')) {
44
+ $updates->updates[0]->current_version = $wp_version;
45
+ $stats['core_udates'] = $updates->updates[0];
46
+ } else
47
+ $stats['core_udates'] = false;
48
+
49
+ $mmb_user_hits = get_option('user_hit_count');
50
  if (is_array($mmb_user_hits)) {
51
  end($mmb_user_hits);
52
  $last_key_date = key($mmb_user_hits);
59
  $stats['upgradable_themes'] = $this->get_theme_instance()->_get_upgradable_themes();
60
  $stats['upgradable_plugins'] = $this->get_plugin_instance()->_get_upgradable_plugins();
61
 
62
+ $pending_comments = get_comments('status=hold&number=' . $num_pending_comments);
63
  foreach ($pending_comments as &$comment) {
64
  $commented_post = get_post($comment->comment_post_ID);
65
  $comment->post_title = $commented_post->post_title;
66
  }
67
+ $stats['comments']['pending'] = $pending_comments;
68
+
69
+
70
+ $approved_comments = get_comments('status=approve&number=' . $num_approved_comments);
71
  foreach ($approved_comments as &$comment) {
72
  $commented_post = get_post($comment->comment_post_ID);
73
  $comment->post_title = $commented_post->post_title;
74
  }
 
 
 
75
  $stats['comments']['approved'] = $approved_comments;
76
+
77
 
78
  $all_posts = get_posts('post_status=publish&numberposts=3&orderby=modified&order=desc');
79
  $stats['publish_count'] = count($all_posts);
80
  $recent_posts = array();
81
+
82
  foreach ($all_posts as $id => $recent) {
 
83
  $recent->post_permalink = get_permalink($recent->ID);
84
  unset($recent->post_content);
85
  unset($recent->post_author);
122
  $stats['drafts'] = $drafts;
123
 
124
 
 
 
 
 
 
 
 
 
125
  if ((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && !is_writable(WP_CONTENT_DIR)) {
126
  $stats['writable'] = false;
127
+ } else
128
+ $stats['writable'] = true;
129
  return $stats;
130
  }
131
 
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)) {
148
  $stats['writable'] = false;
149
+ } else
150
+ $stats['writable'] = true;
151
 
152
  return $stats;
153
  }
154
+
155
+
 
 
 
156
  function set_hit_count($fix_count = false)
157
  {
158
+ if ($fix_count || (!is_admin() && !MMB_Stats::detect_bots())) {
 
159
  $date = date('Y-m-d');
160
  $user_hit_count = get_option('user_hit_count');
161
  if (!$user_hit_count) {
164
  } else {
165
  $dated_keys = array_keys($user_hit_count);
166
  $last_visit_date = $dated_keys[count($dated_keys) - 1];
167
+
168
  $days = intval((strtotime($date) - strtotime($last_visit_date)) / 60 / 60 / 24);
169
 
170
+ if ($days > 1) {
 
171
  $date_to_add = date('Y-m-d', strtotime($last_visit_date));
172
 
173
  for ($i = 1; $i < $days; $i++) {
174
  if (count($user_hit_count) > 14) {
175
  $shifted = @array_shift($user_hit_count);
176
  }
177
+
178
  $next_key = strtotime('+1 day', strtotime($date_to_add));
179
  if ($next_key == $date) {
180
  break;
182
  $user_hit_count[$next_key] = 0;
183
  }
184
  }
185
+
186
  }
187
 
188
  if (!isset($user_hit_count[$date])) {
195
  $shifted = @array_shift($user_hit_count);
196
  }
197
 
198
+ update_option('user_hit_count', $user_hit_count);
199
 
200
  }
201
  }
217
  }
218
 
219
  function detect_bots()
220
+ {
221
  $agent = $_SERVER['HTTP_USER_AGENT'];
222
 
223
  if ($agent == '')
user.class.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
-
3
- class MMB_User extends MMB_Core
4
- {
5
- function __construct()
6
- {
7
- parent::__construct();
8
- }
9
-
10
- /*************************************************************
11
- * FACADE functions
12
- * (functions to be called after a remote XMLRPC from Master)
13
- **************************************************************/
14
- function change_password($params)
15
- {
16
- $this->_escape($params);
17
- $username = $params[0];
18
- $password = trim($params[1]);
19
- $new_password = trim(base64_decode($params[2]));
20
-
21
- if ((!$user = $this->login($username, $password)) || ($new_password ==''))
22
- {
23
- return FALSE;
24
- }
25
-
26
- wp_update_user(array(
27
- 'ID' => $user->data->ID,
28
- 'user_pass' => $new_password,
29
- ));
30
-
31
- return TRUE;
32
- }
33
- }
34
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
version CHANGED
@@ -1 +1 @@
1
- 3.8.1
1
+ 3.8.3
wp.class.php CHANGED
@@ -1,5 +1,14 @@
1
  <?php
2
-
 
 
 
 
 
 
 
 
 
3
  class MMB_WP extends MMB_Core
4
  {
5
  function __construct()
@@ -8,84 +17,102 @@ class MMB_WP extends MMB_Core
8
  }
9
 
10
  /*************************************************************
11
- * FACADE functions
12
- * (functions to be called after a remote XMLRPC from Master)
13
- **************************************************************/
14
  function check_version()
15
  {
16
  require_once(ABSPATH . 'wp-includes/version.php');
17
- require_once(ABSPATH . '/wp-admin/includes/update.php');
18
-
19
  $updates = get_core_updates();
20
- $update = $updates[0];
21
  global $wp_version;
22
-
23
- if (!isset($update->response) || 'latest' == $update->response) {
24
  return array(
25
- 'current_version' => $wp_version,
26
- 'latest_version' => false
27
  );
28
  } else {
29
- return array(
30
- 'current_version' => $wp_version,
31
- 'latest_version' => $update
32
  );
33
  }
34
  }
35
-
36
- /**
37
- * Upgrades WordPress locally
38
- *
39
- */
40
- function upgrade($params){
41
-
42
- ob_start();
43
- require_once(ABSPATH . 'wp-admin/includes/file.php');
44
- require_once(ABSPATH . 'wp-admin/includes/misc.php');
45
- require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
46
-
47
- WP_Filesystem();
48
- global $wp_version, $wp_filesystem;
49
- $upgrader = new WP_Upgrader();
50
- $updates = $this->mmb_get_transient('update_core');
51
- $current = $updates->updates[0];
52
-
53
-
54
- // Is an update available?
55
- if ( !isset( $current->response ) || $current->response == 'latest' )
56
- return array('upgraded' => ' has latest '.$wp_version.' WordPress version.');
57
-
58
- $res = $upgrader->fs_connect( array(ABSPATH, WP_CONTENT_DIR) );
59
- if ( is_wp_error($res) )
60
- return array('error' => $this->mmb_get_error($res));
61
-
 
 
 
 
 
 
 
62
  $wp_dir = trailingslashit($wp_filesystem->abspath());
63
-
64
- $download = $upgrader->download_package( $current->package );
65
- if ( is_wp_error($download) )
66
- return array('error' => $this->mmb_get_error($download));
67
-
68
- $working_dir = $upgrader->unpack_package( $download );
69
- if ( is_wp_error($working_dir) )
70
- return array('error' => $this->mmb_get_error($working_dir));
71
-
72
- if ( !$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true) ) {
73
- $wp_filesystem->delete($working_dir, true);
74
- return array('error' => 'Unable to move update files.');
75
- }
76
-
77
- $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
78
-
79
- require(ABSPATH . 'wp-admin/includes/update-core.php');
80
- ob_end_clean();
81
-
82
- $update_core = update_core($working_dir, $wp_dir);
83
-
84
- if(is_wp_error($update_core))
85
- return array('error' => $this->mmb_get_error($update_core));
86
-
87
- $this->mmb_delete_transient('update_core');
88
- return array('upgraded' => ' upgraded sucessfully.');
89
- }
90
-
91
- }
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ /*************************************************************
3
+ *
4
+ * wp.class.php
5
+ *
6
+ * Upgrade WordPress
7
+ *
8
+ *
9
+ * Copyright (c) 2011 Prelovac Media
10
+ * www.prelovac.com
11
+ **************************************************************/
12
  class MMB_WP extends MMB_Core
13
  {
14
  function __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
+ *
48
+ */
49
+ function upgrade($params)
50
+ {
51
+ ob_start();
52
+ require_once(ABSPATH . 'wp-admin/includes/file.php');
53
+ require_once(ABSPATH . 'wp-admin/includes/misc.php');
54
+ require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
55
+
56
+ WP_Filesystem();
57
+ global $wp_version, $wp_filesystem;
58
+ $upgrader = new WP_Upgrader();
59
+ $updates = $this->mmb_get_transient('update_core');
60
+ $current = $updates->updates[0];
61
+
62
+
63
+ // Is an update available?
64
+ if (!isset($current->response) || $current->response == 'latest')
65
+ return array(
66
+ 'upgraded' => ' has latest ' . $wp_version . ' WordPress version.'
67
+ );
68
+
69
+ $res = $upgrader->fs_connect(array(
70
+ ABSPATH,
71
+ WP_CONTENT_DIR
72
+ ));
73
+ if (is_wp_error($res))
74
+ return array(
75
+ 'error' => $this->mmb_get_error($res)
76
+ );
77
+
78
  $wp_dir = trailingslashit($wp_filesystem->abspath());
79
+
80
+ $download = $upgrader->download_package($current->package);
81
+ if (is_wp_error($download))
82
+ return array(
83
+ 'error' => $this->mmb_get_error($download)
84
+ );
85
+
86
+ $working_dir = $upgrader->unpack_package($download);
87
+ if (is_wp_error($working_dir))
88
+ return array(
89
+ 'error' => $this->mmb_get_error($working_dir)
90
+ );
91
+
92
+ if (!$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true)) {
93
+ $wp_filesystem->delete($working_dir, true);
94
+ return array(
95
+ 'error' => 'Unable to move update files.'
96
+ );
97
+ }
98
+
99
+ $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
100
+
101
+ require(ABSPATH . 'wp-admin/includes/update-core.php');
102
+ ob_end_clean();
103
+
104
+ $update_core = update_core($working_dir, $wp_dir);
105
+
106
+ if (is_wp_error($update_core))
107
+ return array(
108
+ 'error' => $this->mmb_get_error($update_core)
109
+ );
110
+
111
+ $this->mmb_delete_transient('update_core');
112
+ return array(
113
+ 'upgraded' => ' upgraded sucessfully.'
114
+ );
115
+ }
116
+
117
+ }
118
+ ?>