ManageWP Worker - Version 3.8.7

Version Description

  • Fixed 408 error when adding sites
  • Added support for IDN domains
  • Fixed bug with WordPress updates
  • Added comment moderation to the dashboard
  • Added quick links for sites (menu appears on hover)
Download this release

Release Info

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

Code changes from version 3.8.2 to 3.8.7

Screenshot-1.png DELETED
Binary file
Screenshot-2.png DELETED
Binary file
Screenshot-3.png DELETED
Binary file
api.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ {
14
+ if (!$action || !$callback)
15
+ return false;
16
+
17
+ global $mmb_actions;
18
+ mmb_function_exists($callback);
19
+
20
+ if (isset($mmb_actions[$action]))
21
+ wp_die('Cannot redeclare ManageWP action "' . $action . '".');
22
+
23
+ $mmb_actions[$action] = $callback;
24
+ }
25
+
26
+ function mmb_function_exists($callback)
27
+ {
28
+ global $mwp_core;
29
+ if (count($callback) === 2) {
30
+ if (!method_exists($callback[0], $callback[1]))
31
+ wp_die($mwp_core->mwp_dashboard_widget('Information', '', '<p>Class ' . get_class($callback[0]) . ' does not contain <b>"' . $callback[1] . '"</b> function</p>', '', '50%'));
32
+ } else {
33
+ if (!function_exists($callback))
34
+ wp_die($mwp_core->mwp_dashboard_widget('Information', '', '<p>Function <b>"' . $callback . '"</b> does not exists.</p>', '', '50%'));
35
+ }
36
+ }
37
+
38
+ ?>
backup.class.php CHANGED
@@ -20,7 +20,10 @@ 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();
26
  }
@@ -42,11 +45,14 @@ class MMB_Backup extends MMB_Core
42
  $file_path = $upload_dir['basedir'] . $file;
43
 
44
  if (!file_exists($file_path)) {
45
- mkdir($file_path, 0755, true);
 
 
 
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 +63,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')
@@ -70,9 +76,9 @@ class MMB_Backup extends MMB_Core
70
  }
71
  }
72
 
73
- require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
74
 
75
- // Get previous backup in tmp
76
  $worker_options = get_option('mmb-worker');
77
  $tmp_file = $upload_dir['basedir'] . '/' . basename($worker_options['backups'][$type]['path']);
78
 
@@ -80,6 +86,7 @@ class MMB_Backup extends MMB_Core
80
  @unlink($worker_options['backups'][$type]['path']);
81
  }
82
 
 
83
  $site_name = $this->remove_http(get_bloginfo('url'));
84
  $site_name = str_replace(array(
85
  "_",
@@ -97,10 +104,22 @@ class MMB_Backup extends MMB_Core
97
  if (trim($what) == 'full') {
98
  $htaccess_path = ABSPATH . ".htaccess";
99
  $wp_config_path = ABSPATH . "wp-config.php";
100
- if ($this->check_zip()) {
101
  $command = "zip $backup_file -j $content_backup[path] -j $db_backup[path] -j $htaccess_path -j $wp_config_path";
102
  ob_start();
103
- passthru($command, $err);
 
 
 
 
 
 
 
 
 
 
 
 
104
  ob_get_clean();
105
  } else {
106
  $result = $archive->add($content_backup['path'], PCLZIP_OPT_REMOVE_ALL_PATH);
@@ -111,25 +130,27 @@ class MMB_Backup extends MMB_Core
111
  }
112
 
113
  } elseif (trim($what) == 'db') {
114
- if ($this->check_zip()) {
115
  $command = "zip $backup_file -j $db_backup[path]";
116
  ob_start();
117
- passthru($command, $err);
 
 
 
 
 
 
 
 
 
 
 
 
118
  ob_get_clean();
119
  } else {
120
  $result = $archive->add($db_backup['path'], PCLZIP_OPT_REMOVE_ALL_PATH);
121
  $err = !$result;
122
  }
123
- } elseif (trim($what) == 'content') {
124
- if ($this->check_zip()) {
125
- $command = "zip $backup_file -j $content_backup[path]";
126
- ob_start();
127
- passthru($command, $err);
128
- ob_get_clean();
129
- } else {
130
- $result = $archive->add($content_backup['path'], PCLZIP_OPT_REMOVE_ALL_PATH);
131
- $err = !$result;
132
- }
133
  }
134
 
135
  if ($err) {
@@ -137,7 +158,7 @@ class MMB_Backup extends MMB_Core
137
  @unlink($tmp_file);
138
  }
139
  return array(
140
- 'error' => 'Backup failed.'
141
  );
142
  }
143
 
@@ -155,7 +176,7 @@ class MMB_Backup extends MMB_Core
155
  $worker_options['backups'][$type]['url'] = $backup_url;
156
  update_option('mmb-worker', $worker_options);
157
 
158
-
159
  return $worker_options['backups'][$type]['url'];
160
  }
161
 
@@ -165,11 +186,23 @@ class MMB_Backup extends MMB_Core
165
  $sec_string = md5('mmb-worker');
166
  $file = '/' . $sec_string . '/backups/wp-content_' . date('Y-m-d') . '.zip';
167
  $file_path = $upload_dir['basedir'] . $file;
168
- if ($this->check_zip()) {
169
  chdir(WP_CONTENT_DIR);
170
  $command = "zip -r $file_path 'plugins/' 'themes/' 'uploads/' -x 'uploads/" . $sec_string . "/*'";
171
  ob_start();
172
- passthru($command, $err);
 
 
 
 
 
 
 
 
 
 
 
 
173
  ob_get_clean();
174
  if (!$err || $err == 18) {
175
  $file_url = $upload_dir['baseurl'] . $file;
@@ -187,8 +220,8 @@ class MMB_Backup extends MMB_Core
187
  $result = $archive->add(WP_CONTENT_DIR . '/plugins', PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR);
188
  $result = $archive->add(WP_CONTENT_DIR . '/themes', PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR);
189
  $result = $archive->add(WP_CONTENT_DIR . '/uploads', PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR);
190
- // $this->_log($archive);
191
- $result = $archive->delete(PCLZIP_OPT_BY_NAME, 'uploads/' . $sec_string . '/');
192
  if ($result) {
193
  $file_url = $upload_dir['baseurl'] . $file;
194
  return array(
@@ -205,11 +238,7 @@ class MMB_Backup extends MMB_Core
205
  function backup_db($type)
206
  {
207
  $mysqldump_exists = $this->check_mysqldump();
208
-
209
-
210
- if (is_array($mysqldump_exists)) {
211
- // $this->_log('backup dump');
212
-
213
  $result = $this->backup_db_dump($type, $mysqldump_exists);
214
 
215
  } else {
@@ -230,9 +259,22 @@ class MMB_Backup extends MMB_Core
230
  $file_url = $upload_dir['baseurl'] . '/' . DB_NAME . '.sql';
231
 
232
  $command = $brace . $paths['mysqldump'] . $brace . ' --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" --add-drop-table --skip-lock-tables "' . DB_NAME . '" > ' . $brace . $file . $brace;
233
-
234
-
235
- passthru($command, $error);
 
 
 
 
 
 
 
 
 
 
 
 
 
236
 
237
  if ($error) {
238
  $result = $this->backup_db_php($type);
@@ -331,7 +373,8 @@ class MMB_Backup extends MMB_Core
331
  // If manual backup - get backup file from master, if not - get backup file from worker
332
  if ($type != 'weekly' && $type != 'daily') {
333
  // Download backup file from master
334
- $tmp_file = $this->mmb_download_url($type, $upload_dir['basedir'] . '/restore' . md5(time()) . '.tmp');
 
335
  $backup_file = $backup_path . "/" . basename($type);
336
  if (rename($tmp_file, $backup_file)) {
337
  @unlink($tmp_file);
@@ -346,13 +389,31 @@ class MMB_Backup extends MMB_Core
346
 
347
 
348
  if ($backup_file) {
349
- if ($this->check_unzip()) {
350
- mkdir($file_path);
 
 
 
 
351
  chdir($file_path);
352
  $command = "unzip -o $backup_file";
353
  ob_start();
354
- passthru($command, $err);
 
 
 
 
 
 
 
 
 
 
 
 
 
355
  ob_get_clean();
 
356
  } else {
357
  require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
358
  $archive = new PclZip($backup_file);
@@ -360,7 +421,6 @@ class MMB_Backup extends MMB_Core
360
  $err = !$extracted;
361
  }
362
 
363
-
364
  if ($err) {
365
  return array(
366
  'error' => 'Error extracting backup file.'
@@ -377,9 +437,7 @@ class MMB_Backup extends MMB_Core
377
  }
378
  }
379
 
380
-
381
-
382
- if (trim($what) == 'full' || trim($what) == 'content') {
383
  if (!$this->restore_wpcontent($type, $file_path)) {
384
  return array(
385
  'error' => 'Error restoring wp-content.'
@@ -387,7 +445,11 @@ class MMB_Backup extends MMB_Core
387
  }
388
  }
389
 
390
- $this->_deleteTempDir($file_path);
 
 
 
 
391
  }
392
 
393
  return true;
@@ -399,12 +461,24 @@ class MMB_Backup extends MMB_Core
399
  $content_file = glob($file_path . "/*.zip");
400
  $wp_config_file = glob($file_path . "/wp-config.php");
401
  $htaccess_file = glob($file_path . "/.htaccess");
402
- if ($this->check_unzip()) {
403
  chdir(WP_CONTENT_DIR);
404
  $con_file = $content_file[0];
405
  $command = "unzip -o $con_file";
406
  ob_start();
407
- passthru($command, $err);
 
 
 
 
 
 
 
 
 
 
 
 
408
  ob_get_clean();
409
  } else {
410
  $archive = new PclZip($content_file[0]);
@@ -412,11 +486,8 @@ class MMB_Backup extends MMB_Core
412
  $err = !$restore_content;
413
  }
414
 
415
- if (!rename($wp_config_file[0], ABSPATH . "wp-config.php"))
416
- $err = 1;
417
- if (!rename($htaccess_file[0], ABSPATH . ".htaccess"))
418
- $err = 1;
419
-
420
  @unlink($wp_config_file[0]);
421
  @unlink($htaccess_file[0]);
422
 
@@ -432,13 +503,26 @@ class MMB_Backup extends MMB_Core
432
 
433
  $mysqldump = $this->check_mysqldump();
434
 
435
- if (is_array($mysqldump)) {
436
  $brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
437
 
438
  foreach (glob($file_path . '/*.sql') as $filename) {
439
  $command = $brace . $mysqldump['mysql'] . $brace . ' --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" ' . DB_NAME . ' < ' . $brace . $filename . $brace;
440
- passthru($command, $error);
441
-
 
 
 
 
 
 
 
 
 
 
 
 
 
442
  break;
443
  }
444
 
@@ -501,23 +585,17 @@ class MMB_Backup extends MMB_Core
501
  }
502
  }
503
 
504
-
505
- function get_backup_details($args)
506
  {
507
- $this->_escape($args);
508
- $username = $args[0];
509
- $type = $args[2];
510
- if (trim($type) == '') {
511
- return false;
512
- }
513
-
514
- $worker_options = get_option('mmb-worker');
515
- $backup_file = $worker_options['backups'][$type]['url'];
516
 
517
- if (!$backup_file)
518
- return FALSE;
519
- else
520
- return $backup_file;
 
 
521
  }
522
 
523
  ### Function: Auto Detect MYSQL and MYSQL Dump Paths
@@ -555,23 +633,23 @@ class MMB_Backup extends MMB_Core
555
  return false;
556
  }
557
 
558
- $stats_function_disabled = 0;
559
- // TODO: if none of these exists return with an appropriate error. else fallback passthru to whatever is available
560
- if (!function_exists('passthru')) {
561
- $stats_function_disabled++;
562
- }
563
- if (!function_exists('system')) {
564
- $stats_function_disabled++;
565
- }
566
- if (!function_exists('exec')) {
567
- $stats_function_disabled++;
568
- }
569
 
570
- if ($stats_function_disabled == 3) {
571
- return false;
572
- }
 
 
 
 
573
 
574
- return $paths;
575
  }
576
 
577
  function check_zip()
@@ -586,33 +664,5 @@ class MMB_Backup extends MMB_Core
586
  return $zip ? true : false;
587
  }
588
 
589
-
590
- function mmb_download_url($url, $file_name)
591
- {
592
- $destination = fopen($file_name, 'wb');
593
- $source = @fopen($url, "r");
594
-
595
- while ($a = fread($source, 1024)) {
596
- $ret = fwrite($destination, $a);
597
- }
598
-
599
- fclose($source);
600
- fclose($destination);
601
- return $file_name;
602
- }
603
-
604
- function optimize_tables()
605
- {
606
- global $wpdb;
607
- $tables = $wpdb->get_col("SHOW TABLES");
608
-
609
- foreach ($tables as $table_name) {
610
- $table_string .= $table_name . ",";
611
- }
612
- $table_string = rtrim($table_string);
613
- $optimize = $wpdb->query("OPTIMIZE TABLE $table_string");
614
- return true;
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
+ if (!mkdir($file_path, 0755, true))
24
+ return array(
25
+ 'error' => 'Permission denied, make sure you have write permission to wp-content folder.'
26
+ );
27
  }
28
  parent::__construct();
29
  }
45
  $file_path = $upload_dir['basedir'] . $file;
46
 
47
  if (!file_exists($file_path)) {
48
+ if (!mkdir($file_path, 0755, true))
49
+ return array(
50
+ 'error' => 'Permission denied, make sure you have write permission to wp-content folder.'
51
+ );
52
  }
53
 
54
+ if (trim($what) == 'full') {
55
+ //take wp-content backup
56
  $content_backup = $this->backup_wpcontent($type);
57
  if (!$content_backup) {
58
  @unlink($content_backup['path']);
63
  }
64
 
65
  if (trim($what) == 'full' || trim($what) == 'db') {
66
+ //take database backup
67
  $db_backup = $this->backup_db($type);
68
  if (!$db_backup) {
69
  if (trim($what) == 'full')
76
  }
77
  }
78
 
79
+ include_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
80
 
81
+ // Get previous backup in tmp
82
  $worker_options = get_option('mmb-worker');
83
  $tmp_file = $upload_dir['basedir'] . '/' . basename($worker_options['backups'][$type]['path']);
84
 
86
  @unlink($worker_options['backups'][$type]['path']);
87
  }
88
 
89
+ //Prepare .zip file name
90
  $site_name = $this->remove_http(get_bloginfo('url'));
91
  $site_name = str_replace(array(
92
  "_",
104
  if (trim($what) == 'full') {
105
  $htaccess_path = ABSPATH . ".htaccess";
106
  $wp_config_path = ABSPATH . "wp-config.php";
107
+ if ($this->check_zip() && ($func = $this->check_sys())) {
108
  $command = "zip $backup_file -j $content_backup[path] -j $db_backup[path] -j $htaccess_path -j $wp_config_path";
109
  ob_start();
110
+ switch ($func) {
111
+ case 'passthru':
112
+ passthru($command, $err);
113
+ break;
114
+ case 'exec':
115
+ exec($command);
116
+ break;
117
+ case 'system':
118
+ system($command);
119
+ break;
120
+ default:
121
+ break;
122
+ }
123
  ob_get_clean();
124
  } else {
125
  $result = $archive->add($content_backup['path'], PCLZIP_OPT_REMOVE_ALL_PATH);
130
  }
131
 
132
  } elseif (trim($what) == 'db') {
133
+ if ($this->check_zip() && ($func = $this->check_sys())) {
134
  $command = "zip $backup_file -j $db_backup[path]";
135
  ob_start();
136
+ switch ($func) {
137
+ case 'passthru':
138
+ passthru($command, $err);
139
+ break;
140
+ case 'exec':
141
+ exec($command);
142
+ break;
143
+ case 'system':
144
+ system($command);
145
+ break;
146
+ default:
147
+ break;
148
+ }
149
  ob_get_clean();
150
  } else {
151
  $result = $archive->add($db_backup['path'], PCLZIP_OPT_REMOVE_ALL_PATH);
152
  $err = !$result;
153
  }
 
 
 
 
 
 
 
 
 
 
154
  }
155
 
156
  if ($err) {
158
  @unlink($tmp_file);
159
  }
160
  return array(
161
+ 'error' => 'Backup failed. Cannot create backup zip file.'
162
  );
163
  }
164
 
176
  $worker_options['backups'][$type]['url'] = $backup_url;
177
  update_option('mmb-worker', $worker_options);
178
 
179
+ //Everything went fine, return backup url to master
180
  return $worker_options['backups'][$type]['url'];
181
  }
182
 
186
  $sec_string = md5('mmb-worker');
187
  $file = '/' . $sec_string . '/backups/wp-content_' . date('Y-m-d') . '.zip';
188
  $file_path = $upload_dir['basedir'] . $file;
189
+ if ($this->check_zip() && ($func = $this->check_sys())) {
190
  chdir(WP_CONTENT_DIR);
191
  $command = "zip -r $file_path 'plugins/' 'themes/' 'uploads/' -x 'uploads/" . $sec_string . "/*'";
192
  ob_start();
193
+ switch ($func) {
194
+ case 'passthru':
195
+ passthru($command, $err);
196
+ break;
197
+ case 'exec':
198
+ exec($command);
199
+ break;
200
+ case 'system':
201
+ system($command);
202
+ break;
203
+ default:
204
+ break;
205
+ }
206
  ob_get_clean();
207
  if (!$err || $err == 18) {
208
  $file_url = $upload_dir['baseurl'] . $file;
220
  $result = $archive->add(WP_CONTENT_DIR . '/plugins', PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR);
221
  $result = $archive->add(WP_CONTENT_DIR . '/themes', PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR);
222
  $result = $archive->add(WP_CONTENT_DIR . '/uploads', PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR);
223
+
224
+ $result = $archive->delete(PCLZIP_OPT_BY_NAME, 'uploads/' . $sec_string . '/');
225
  if ($result) {
226
  $file_url = $upload_dir['baseurl'] . $file;
227
  return array(
238
  function backup_db($type)
239
  {
240
  $mysqldump_exists = $this->check_mysqldump();
241
+ if (is_array($mysqldump_exists) && $this->check_sys()) {
 
 
 
 
242
  $result = $this->backup_db_dump($type, $mysqldump_exists);
243
 
244
  } else {
259
  $file_url = $upload_dir['baseurl'] . '/' . DB_NAME . '.sql';
260
 
261
  $command = $brace . $paths['mysqldump'] . $brace . ' --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" --add-drop-table --skip-lock-tables "' . DB_NAME . '" > ' . $brace . $file . $brace;
262
+ ob_start();
263
+ $func = $this->check_sys();
264
+ switch ($func) {
265
+ case 'passthru':
266
+ passthru($command, $error);
267
+ break;
268
+ case 'exec':
269
+ exec($command);
270
+ break;
271
+ case 'system':
272
+ system($command);
273
+ break;
274
+ default:
275
+ break;
276
+ }
277
+ ob_get_clean();
278
 
279
  if ($error) {
280
  $result = $this->backup_db_php($type);
373
  // If manual backup - get backup file from master, if not - get backup file from worker
374
  if ($type != 'weekly' && $type != 'daily') {
375
  // Download backup file from master
376
+ include_once(ABSPATH . 'wp-admin/includes/file.php');
377
+ $tmp_file = download_url($type);
378
  $backup_file = $backup_path . "/" . basename($type);
379
  if (rename($tmp_file, $backup_file)) {
380
  @unlink($tmp_file);
389
 
390
 
391
  if ($backup_file) {
392
+ if ($this->check_unzip() && ($func = $this->check_sys())) {
393
+ if (!mkdir($file_path))
394
+ return array(
395
+ 'error' => 'Failed to create restore folder.'
396
+ );
397
+
398
  chdir($file_path);
399
  $command = "unzip -o $backup_file";
400
  ob_start();
401
+
402
+ switch ($func) {
403
+ case 'passthru':
404
+ passthru($command, $err);
405
+ break;
406
+ case 'exec':
407
+ exec($command);
408
+ break;
409
+ case 'system':
410
+ system($command);
411
+ break;
412
+ default:
413
+ break;
414
+ }
415
  ob_get_clean();
416
+
417
  } else {
418
  require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
419
  $archive = new PclZip($backup_file);
421
  $err = !$extracted;
422
  }
423
 
 
424
  if ($err) {
425
  return array(
426
  'error' => 'Error extracting backup file.'
437
  }
438
  }
439
 
440
+ if (trim($what) == 'full') {
 
 
441
  if (!$this->restore_wpcontent($type, $file_path)) {
442
  return array(
443
  'error' => 'Error restoring wp-content.'
445
  }
446
  }
447
 
448
+ $this->delete_temp_dir($file_path);
449
+ } else {
450
+ return array(
451
+ 'error' => 'Error restoring. Cannot find backup file.'
452
+ );
453
  }
454
 
455
  return true;
461
  $content_file = glob($file_path . "/*.zip");
462
  $wp_config_file = glob($file_path . "/wp-config.php");
463
  $htaccess_file = glob($file_path . "/.htaccess");
464
+ if ($this->check_unzip() && ($func = $this->check_sys())) {
465
  chdir(WP_CONTENT_DIR);
466
  $con_file = $content_file[0];
467
  $command = "unzip -o $con_file";
468
  ob_start();
469
+ switch ($func) {
470
+ case 'passthru':
471
+ passthru($command, $err);
472
+ break;
473
+ case 'exec':
474
+ exec($command);
475
+ break;
476
+ case 'system':
477
+ system($command);
478
+ break;
479
+ default:
480
+ break;
481
+ }
482
  ob_get_clean();
483
  } else {
484
  $archive = new PclZip($content_file[0]);
486
  $err = !$restore_content;
487
  }
488
 
489
+ @rename($wp_config_file[0], ABSPATH . "wp-config.php");
490
+ @rename($htaccess_file[0], ABSPATH . ".htaccess");
 
 
 
491
  @unlink($wp_config_file[0]);
492
  @unlink($htaccess_file[0]);
493
 
503
 
504
  $mysqldump = $this->check_mysqldump();
505
 
506
+ if (is_array($mysqldump) && ($func = $this->check_sys())) {
507
  $brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
508
 
509
  foreach (glob($file_path . '/*.sql') as $filename) {
510
  $command = $brace . $mysqldump['mysql'] . $brace . ' --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" ' . DB_NAME . ' < ' . $brace . $filename . $brace;
511
+ ob_start();
512
+ switch ($func) {
513
+ case 'passthru':
514
+ passthru($command, $error);
515
+ break;
516
+ case 'exec':
517
+ exec($command);
518
+ break;
519
+ case 'system':
520
+ system($command);
521
+ break;
522
+ default:
523
+ break;
524
+ }
525
+ ob_get_clean();
526
  break;
527
  }
528
 
585
  }
586
  }
587
 
588
+ function optimize_tables()
 
589
  {
590
+ global $wpdb;
591
+ $tables = $wpdb->get_col("SHOW TABLES");
 
 
 
 
 
 
 
592
 
593
+ foreach ($tables as $table_name) {
594
+ $table_string .= $table_name . ",";
595
+ }
596
+ $table_string = rtrim($table_string);
597
+ $optimize = $wpdb->query("OPTIMIZE TABLE $table_string");
598
+ return $optimize ? true : false;
599
  }
600
 
601
  ### Function: Auto Detect MYSQL and MYSQL Dump Paths
633
  return false;
634
  }
635
 
636
+ return $paths;
637
+ }
638
+
639
+ //Check if passthru, system or exec functions exist
640
+ function check_sys()
641
+ {
642
+ if (function_exists('passthru'))
643
+ return 'passthru';
 
 
 
644
 
645
+ if (function_exists('system'))
646
+ return 'system';
647
+
648
+ if (function_exists('exec'))
649
+ return 'exec';
650
+
651
+ return false;
652
 
 
653
  }
654
 
655
  function check_zip()
664
  return $zip ? true : false;
665
  }
666
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
667
  }
668
+ ?>
comment.class.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*************************************************************
3
+ *
4
+ * post.class.php
5
+ *
6
+ * Create remote post
7
+ *
8
+ *
9
+ * Copyright (c) 2011 Prelovac Media
10
+ * www.prelovac.com
11
+ **************************************************************/
12
+
13
+ class MMB_Comment extends MMB_Core
14
+ {
15
+ function __construct()
16
+ {
17
+ parent::__construct();
18
+ }
19
+
20
+ function change_status($args)
21
+ {
22
+
23
+ global $wpdb;
24
+ $comment_id = $args['comment_id'];
25
+ $status = $args['status'];
26
+
27
+ if ( 'approve' == $status )
28
+ $status_sql = '1';
29
+ elseif ( 'unapprove' == $status )
30
+ $status_sql = '0';
31
+ elseif ( 'spam' == $status )
32
+ $status_sql = 'spam';
33
+ elseif ( 'trash' == $status )
34
+ $status_sql = 'trash';
35
+ $sql = "update ".$wpdb->prefix."comments set comment_approved = '$status_sql' where comment_id = '$comment_id'";
36
+ $success = $wpdb->query($sql);
37
+
38
+
39
+ return $success;
40
+ }
41
+
42
+ }
43
+ ?>
core.class.php CHANGED
@@ -1,5 +1,14 @@
1
  <?php
2
-
 
 
 
 
 
 
 
 
 
3
  class MMB_Core extends MMB_Helper
4
  {
5
  var $name;
@@ -12,35 +21,68 @@ class MMB_Core extends MMB_Helper
12
  var $wp_instance;
13
  var $post_instance;
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 +91,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 +104,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 +117,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 +131,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 +144,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 +172,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 +185,180 @@ 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' => 'ManageWP Worker could not been upgraded.');
262
- }
263
- else{
264
- return array('success' => 'ManageWP 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;
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()
31
+ {
32
  global $mmb_plugin_dir;
33
+
34
+ $this->name = 'Manage Multiple Blogs';
35
+ $this->slug = 'manage-multiple-blogs';
36
  $this->settings = get_option($this->slug);
37
+ if (!$this->settings) {
 
38
  $this->settings = array(
39
+ 'blogs' => array(),
40
+ 'current_blog' => array(
41
+ 'type' => null
42
+ )
43
  );
44
+ $this->save_options();
45
  }
46
+ add_action('rightnow_end', array(
47
+ $this,
48
+ 'add_right_now_info'
49
+ ));
50
+ add_action('wp_footer', array(
51
+ 'MMB_Stats',
52
+ 'set_hit_count'
53
+ ));
54
+ register_activation_hook($mmb_plugin_dir . '/init.php', array(
55
+ $this,
56
+ 'install'
57
+ ));
58
+ add_action('init', array(
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
+ {
76
+ echo '<div class="error" style="text-align: center;"><p style="color: red; font-size: 14px; font-weight: bold;">Attention !</p><p>
77
+ 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>
78
+ </p></div>';
79
+ }
80
 
81
  /**
82
+ * Add an item into the Right Now Dashboard widget
83
+ * to inform that the blog can be managed remotely
84
+ *
85
+ */
86
  function add_right_now_info()
87
  {
88
  echo '<div class="mmb-slave-info">
91
  }
92
 
93
  /**
94
+ * Gets an instance of the Comment class
95
+ *
96
+ */
97
  function get_comment_instance()
98
  {
99
+ if (!isset($this->comment_instance)) {
 
100
  $this->comment_instance = new MMB_Comment();
101
  }
102
 
104
  }
105
 
106
  /**
107
+ * Gets an instance of the Plugin class
108
+ *
109
+ */
110
  function get_plugin_instance()
111
  {
112
+ if (!isset($this->plugin_instance)) {
 
113
  $this->plugin_instance = new MMB_Plugin();
114
  }
115
 
117
  }
118
 
119
  /**
120
+ * Gets an instance of the Theme class
121
+ *
122
+ */
123
  function get_theme_instance()
124
  {
125
+ if (!isset($this->theme_instance)) {
 
126
  $this->theme_instance = new MMB_Theme();
127
  }
128
 
131
 
132
 
133
  /**
134
+ * Gets an instance of MMB_Post class
135
+ *
136
+ */
137
  function get_post_instance()
138
  {
139
+ if (!isset($this->post_instance)) {
 
140
  $this->post_instance = new MMB_Post();
141
  }
142
 
144
  }
145
 
146
  /**
147
+ * Gets an instance of Blogroll class
148
+ *
149
+ */
150
  function get_blogroll_instance()
151
  {
152
+ if (!isset($this->blogroll_instance)) {
 
153
  $this->blogroll_instance = new MMB_Blogroll();
154
  }
155
 
156
  return $this->blogroll_instance;
157
  }
158
+
159
+
160
 
161
  /**
162
+ * Gets an instance of the WP class
163
+ *
164
+ */
165
  function get_wp_instance()
166
  {
167
+ if (!isset($this->wp_instance)) {
 
168
  $this->wp_instance = new MMB_WP();
169
  }
170
 
172
  }
173
 
174
  /**
175
+ * Gets an instance of User
176
+ *
177
+ */
178
  function get_user_instance()
179
  {
180
+ if (!isset($this->user_instance)) {
 
181
  $this->user_instance = new MMB_User();
182
  }
183
 
185
  }
186
 
187
  /**
188
+ * Gets an instance of stats class
189
+ *
190
+ */
191
  function get_stats_instance()
192
  {
193
+ if (!isset($this->stats_instance)) {
 
194
  $this->stats_instance = new MMB_Stats();
195
  }
196
  return $this->stats_instance;
197
  }
 
198
  /**
199
+ * Gets an instance of search class
200
+ *
201
+ */
202
+ function get_search_instance()
203
+ {
204
+ if (!isset($this->search_instance)) {
205
+ $this->search_instance = new MMB_Search();
206
+ }
207
+ //return $this->search_instance;
208
+ return $this->search_instance;
209
+ }
210
+ /**
211
+ * Gets an instance of stats class
212
+ *
213
+ */
214
  function get_backup_instance()
215
  {
216
+ if (!isset($this->backup_instance)) {
 
217
  $this->backup_instance = new MMB_Backup();
218
  }
219
+
220
  return $this->backup_instance;
221
  }
222
 
223
+ function get_installer_instance()
224
+ {
225
+ if (!isset($this->installer_instance)) {
226
+ $this->installer_instance = new MMB_Installer();
227
+ }
228
+ return $this->installer_instance;
229
+ }
230
+
231
  /**
232
+ * Plugin install callback function
233
+ * Check PHP version
234
+ */
235
  function install()
236
+ {
237
+
238
+ // delete plugin options, just in case
239
+ delete_option('_worker_nossl_key');
240
+ delete_option('_worker_public_key');
241
+ delete_option('_action_message_id');
242
+
243
  }
244
 
245
  /**
246
+ * Saves the (modified) options into the database
247
+ *
248
+ */
249
+ function save_options()
250
  {
251
+ if (get_option($this->slug)) {
 
252
  update_option($this->slug, $this->settings);
253
+ } else {
 
 
254
  add_option($this->slug, $this->settings);
255
  }
256
  }
257
 
258
  /**
259
+ * Deletes options for communication with master
260
+ *
261
+ */
262
+ function uninstall()
263
+ {
264
+ delete_option('_worker_nossl_key');
265
+ delete_option('_worker_public_key');
266
+ delete_option('_action_message_id');
267
+ }
268
+
269
  /**
270
+ * Constructs a url (for ajax purpose)
271
+ *
272
+ * @param mixed $base_page
273
+ */
274
+ function construct_url($params = array(), $base_page = 'index.php')
275
  {
276
  $url = "$base_page?_wpnonce=" . wp_create_nonce($this->slug);
277
+ foreach ($params as $key => $value) {
 
278
  $url .= "&$key=$value";
279
  }
280
 
281
  return $url;
282
  }
283
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
  /**
285
+ * Worker update
286
+ *
287
+ */
288
+ function update_worker_plugin($params)
289
+ {
290
+ extract($params);
291
+ if ($download_url) {
292
+ include_once ABSPATH . 'wp-admin/includes/file.php';
293
+ include_once ABSPATH . 'wp-admin/includes/misc.php';
294
+ include_once ABSPATH . 'wp-admin/includes/template.php';
295
+ include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
296
+
297
+ if ((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && (get_filesystem_method(array(), false) != 'direct')) {
298
+ return array(
299
+ 'error' => 'Failed, please <a target="_blank" href="http://managewp.com/user-guide#ftp">add FTP details for automatic upgrades.</a></a>'
300
+ );
301
+ }
302
+
303
+ ob_start();
304
+ @unlink(dirname(__FILE__));
305
+ $upgrader = new Plugin_Upgrader();
306
+ $result = $upgrader->run(array(
307
+ 'package' => $download_url,
308
+ 'destination' => WP_PLUGIN_DIR,
309
+ 'clear_destination' => true,
310
+ 'clear_working' => true,
311
+ 'hook_extra' => array(
312
+ 'plugin' => 'worker/init.php'
313
+ )
314
+ ));
315
+ ob_end_clean();
316
+ if (is_wp_error($result) || !$result) {
317
+ return array(
318
+ 'error' => 'ManageWP Worker could not been upgraded.'
319
+ );
320
+ } else {
321
+ return array(
322
+ 'success' => 'ManageWP Worker plugin successfully upgraded.'
323
+ );
324
+ }
325
+ }
326
+ return array(
327
+ 'error' => 'Bad download path for worker installation file.'
328
+ );
329
+ }
330
+
331
+ /**
332
+ * Automatically logs in when called from Master
333
+ *
334
+ */
335
+ function automatic_login()
336
+ {
337
+ $where = ($_GET['mwp_goto']);
338
+
339
+ if (!is_user_logged_in() && $_GET['auto_login']) {
340
+ $signature = base64_decode($_GET['signature']);
341
+ $message_id = trim($_GET['message_id']);
342
+ $username = $_GET['username'];
343
+
344
+ $auth = $this->authenticate_message($where . $message_id, $signature, $message_id);
345
+ if ($auth === true) {
346
+ $user = get_user_by('login', $username);
347
+ $user_id = $user->ID;
348
+ wp_set_current_user($user_id, $username);
349
+ wp_set_auth_cookie($user_id);
350
+ do_action('wp_login', $username);
351
+ } else {
352
+ wp_die($auth['error']);
353
+ }
354
+ }
355
+
356
+ if ($_GET['auto_login']) {
357
+ wp_redirect(get_bloginfo('url') . "/wp-admin/" . $where);
358
+ exit();
359
+ }
360
+ }
361
+
362
+
363
+ }
364
+ ?>
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
@@ -32,30 +32,6 @@ class MMB_Helper
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,34 +51,11 @@ 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
  *
104
  */
105
- function _init_filesystem()
106
  {
107
  global $wp_filesystem;
108
 
@@ -124,72 +77,56 @@ 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;
155
  }
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)
177
- {
178
- //do nothing
179
- if (!ob_get_level())
180
- ob_start(array(
181
- $this,
182
- 'mmb_null_op_buffer'
183
- ));
184
- return '';
185
  }
186
 
187
- function _deleteTempDir($directory)
188
  {
189
  if (substr($directory, -1) == "/") {
190
  $directory = substr($directory, 0, -1);
191
  }
192
- // $this->_log($directory);
193
  if (!file_exists($directory) || !is_dir($directory)) {
194
  return false;
195
  } elseif (!is_readable($directory)) {
@@ -202,7 +139,7 @@ class MMB_Helper
202
  $path = $directory . "/" . $contents;
203
 
204
  if (is_dir($path)) {
205
- $this->_deleteTempDir($path);
206
  } else {
207
  unlink($path);
208
  }
@@ -214,15 +151,7 @@ class MMB_Helper
214
  }
215
  }
216
 
217
- function _is_ftp_writable_mmb()
218
- {
219
- if (defined('FTP_PASS')) {
220
- return true;
221
- } else
222
- return false;
223
- }
224
-
225
- function _set_worker_message_id($message_id = false)
226
  {
227
  if ($message_id) {
228
  add_option('_action_message_id', $message_id) or update_option('_action_message_id', $message_id);
@@ -231,12 +160,12 @@ class MMB_Helper
231
  return false;
232
  }
233
 
234
- function _get_worker_message_id()
235
  {
236
  return (int) get_option('_action_message_id');
237
  }
238
 
239
- function _set_master_public_key($public_key = false)
240
  {
241
  if ($public_key && !get_option('_worker_public_key')) {
242
  add_option('_worker_public_key', base64_encode($public_key));
@@ -245,35 +174,32 @@ class MMB_Helper
245
  return false;
246
  }
247
 
248
- function _get_master_public_key()
249
  {
250
  if (!get_option('_worker_public_key'))
251
  return false;
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
- if ($random_key && !get_option('_worker_nossl_key')){
269
- add_option('_worker_nossl_key', base64_encode($random_key));
270
- return true;
271
- }
272
- return false;
273
- }
274
-
275
 
276
- function _authenticate_message($data = false, $signature = false, $message_id = false)
 
 
 
 
 
 
 
 
 
 
277
  {
278
  if (!$data && !$signature) {
279
  return array(
@@ -281,51 +207,53 @@ class MMB_Helper
281
  );
282
  }
283
 
284
- $current_message = $this->_get_worker_message_id();
285
 
286
  if ((int) $current_message > (int) $message_id)
287
  return array(
288
  'error' => 'Invalid message recieved. You can try to reinstall worker plugin and re-add the site to your account.'
289
  );
290
 
291
- $pl_key = $this->_get_master_public_key();
292
  if (!$pl_key) {
293
  return array(
294
  'error' => 'Authentication failed (public key). You can try to reinstall worker plugin and re-add the site to your account.'
295
  );
296
  }
297
-
298
- if( function_exists( 'openssl_verify' ) && !$this->_get_random_signature()){
299
- $verify = openssl_verify($data, $signature, $pl_key);
300
- if ($verify == 1) {
301
- $message_id = $this->_set_worker_message_id($message_id);
302
- return true;
303
- } else if ($verify == 0) {
304
- return array(
305
- 'error' => 'Invalid message signature. You can try to reinstall worker plugin and re-add the site to your account.'
306
- );
307
- } else {
308
- return array(
309
- 'error' => 'Command not successful! Please try again.'
310
- );
311
- }
312
- } else if ($this->_get_random_signature()) {
313
- if(md5($data.$this->_get_random_signature()) == $signature ){
314
- $message_id = $this->_set_worker_message_id($message_id);
315
- return true;
316
- }
317
- return array(
318
  'error' => 'Invalid message signature. You can try to reinstall the worker plugin and then re-add the site to your dashboard.'
319
  );
320
- }
321
- // no rand key - deleted in get_stat maybe
322
- else return array(
323
- 'error' => 'Invalid message signature, try reinstalling worker plugin and re-adding the site to your dashboard.'
324
- );
325
- }
 
326
 
327
- function _check_if_user_exists($username = false)
328
  {
 
329
  if ($username) {
330
  require_once(ABSPATH . WPINC . '/registration.php');
331
  include_once(ABSPATH . 'wp-includes/pluggable.php');
@@ -333,12 +261,12 @@ class MMB_Helper
333
  if (username_exists($username) == null) {
334
  return false;
335
  }
336
- $user = get_userdatabylogin($username);
337
- if ($user->wp_user_level == 10 || isset($user->wp_capabilities['administrator'])) {
338
  define('MMB_USER_CAPABILITIES', $user->wp_user_level);
339
- return true;
340
  }
341
- return false;
342
  }
343
  return false;
344
  }
@@ -355,26 +283,26 @@ class MMB_Helper
355
 
356
  function remove_http($url = '')
357
  {
358
- if ($url == 'http://' OR $url == 'https://') {
359
  return $url;
360
  }
361
- return preg_replace('/^(http|https)\:\/\/(www.)?/i', '', $url);
362
-
 
 
 
 
 
 
 
 
 
 
 
 
 
363
  }
364
-
365
- function mmb_get_error($error_object){
366
- if(!is_wp_error($error_object)){
367
- return $error_object != '' ? $error_object : ' error occured.';
368
- }
369
- else {
370
- $errors = array();
371
- foreach($error_object->error_data as $error_key => $error_string){
372
- $errors[] = str_replace('_', ' ', ucfirst($error_key)).' - '.$error_string;
373
- }
374
- return implode('<br />', $errors);
375
- }
376
- }
377
-
378
 
379
  }
380
  ?>
3
  *
4
  * helper.class.php
5
  *
6
+ * Utility functions
7
  *
8
  *
9
  * Copyright (c) 2011 Prelovac Media
32
  fclose($handle);
33
  }
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  function _escape(&$array)
36
  {
37
  global $wpdb;
51
  }
52
  }
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  /**
55
  * Initializes the file system
56
  *
57
  */
58
+ function init_filesystem()
59
  {
60
  global $wp_filesystem;
61
 
77
  * @return mixed
78
  */
79
  function mmb_get_transient($option_name)
80
+ {
81
+ if (trim($option_name) == '') {
82
  return FALSE;
83
  }
84
 
85
+ global $mmb_wp_version, $_wp_using_ext_object_cache;
86
 
87
+ if (version_compare($mmb_wp_version, '2.8.0', '<')) {
88
+ return get_option($option_name);
89
+ } else if (version_compare($mmb_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;
106
  }
107
 
108
+ global $mmb_wp_version;
109
 
110
+ if (version_compare($mmb_wp_version, '2.8.0', '<')) {
111
+ delete_option($option_name);
112
+ } else if (version_compare($mmb_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 delete_temp_dir($directory)
126
  {
127
  if (substr($directory, -1) == "/") {
128
  $directory = substr($directory, 0, -1);
129
  }
 
130
  if (!file_exists($directory) || !is_dir($directory)) {
131
  return false;
132
  } elseif (!is_readable($directory)) {
139
  $path = $directory . "/" . $contents;
140
 
141
  if (is_dir($path)) {
142
+ $this->delete_temp_dir($path);
143
  } else {
144
  unlink($path);
145
  }
151
  }
152
  }
153
 
154
+ function set_worker_message_id($message_id = false)
 
 
 
 
 
 
 
 
155
  {
156
  if ($message_id) {
157
  add_option('_action_message_id', $message_id) or update_option('_action_message_id', $message_id);
160
  return false;
161
  }
162
 
163
+ function get_worker_message_id()
164
  {
165
  return (int) get_option('_action_message_id');
166
  }
167
 
168
+ function set_master_public_key($public_key = false)
169
  {
170
  if ($public_key && !get_option('_worker_public_key')) {
171
  add_option('_worker_public_key', base64_encode($public_key));
174
  return false;
175
  }
176
 
177
+ function get_master_public_key()
178
  {
179
  if (!get_option('_worker_public_key'))
180
  return false;
181
  return base64_decode(get_option('_worker_public_key'));
182
  }
183
 
184
+
185
+ function get_random_signature()
186
+ {
187
+ if (!get_option('_worker_nossl_key'))
 
 
 
 
188
  return false;
189
  return base64_decode(get_option('_worker_nossl_key'));
190
+ }
 
 
 
 
 
 
 
 
 
191
 
192
+ function set_random_signature($random_key = false)
193
+ {
194
+ if ($random_key && !get_option('_worker_nossl_key')) {
195
+ add_option('_worker_nossl_key', base64_encode($random_key));
196
+ return true;
197
+ }
198
+ return false;
199
+ }
200
+
201
+
202
+ function authenticate_message($data = false, $signature = false, $message_id = false)
203
  {
204
  if (!$data && !$signature) {
205
  return array(
207
  );
208
  }
209
 
210
+ $current_message = $this->get_worker_message_id();
211
 
212
  if ((int) $current_message > (int) $message_id)
213
  return array(
214
  'error' => 'Invalid message recieved. You can try to reinstall worker plugin and re-add the site to your account.'
215
  );
216
 
217
+ $pl_key = $this->get_master_public_key();
218
  if (!$pl_key) {
219
  return array(
220
  'error' => 'Authentication failed (public key). You can try to reinstall worker plugin and re-add the site to your account.'
221
  );
222
  }
223
+
224
+ if (function_exists('openssl_verify') && !$this->get_random_signature()) {
225
+ $verify = openssl_verify($data, $signature, $pl_key);
226
+ if ($verify == 1) {
227
+ $message_id = $this->set_worker_message_id($message_id);
228
+ return true;
229
+ } else if ($verify == 0) {
230
+ return array(
231
+ 'error' => 'Invalid message signature. You can try to reinstall worker plugin and re-add the site to your account.'
232
+ );
233
+ } else {
234
+ return array(
235
+ 'error' => 'Command not successful! Please try again.'
236
+ );
237
+ }
238
+ } else if ($this->get_random_signature()) {
239
+ if (md5($data . $this->get_random_signature()) == $signature) {
240
+ $message_id = $this->set_worker_message_id($message_id);
241
+ return true;
242
+ }
243
+ return array(
244
  'error' => 'Invalid message signature. You can try to reinstall the worker plugin and then re-add the site to your dashboard.'
245
  );
246
+ }
247
+ // no rand key - deleted in get_stat maybe
248
+ else
249
+ return array(
250
+ 'error' => 'Invalid message signature, try reinstalling worker plugin and re-adding the site to your dashboard.'
251
+ );
252
+ }
253
 
254
+ function check_if_user_exists($username = false)
255
  {
256
+ global $wpdb;
257
  if ($username) {
258
  require_once(ABSPATH . WPINC . '/registration.php');
259
  include_once(ABSPATH . 'wp-includes/pluggable.php');
261
  if (username_exists($username) == null) {
262
  return false;
263
  }
264
+ $user = (array) get_userdatabylogin($username);
265
+ if ($user[$wpdb->prefix . 'user_level'] == 10 || isset($user[$wpdb->prefix . 'capabilities']['administrator'])) {
266
  define('MMB_USER_CAPABILITIES', $user->wp_user_level);
267
+ return true;
268
  }
269
+ return false;
270
  }
271
  return false;
272
  }
283
 
284
  function remove_http($url = '')
285
  {
286
+ if ($url == 'http://' OR $url == 'https://') {
287
  return $url;
288
  }
289
+ return preg_replace('/^(http|https)\:\/\/(www.)?/i', '', $url);
290
+
291
+ }
292
+
293
+ function mmb_get_error($error_object)
294
+ {
295
+ if (!is_wp_error($error_object)) {
296
+ return $error_object != '' ? $error_object : ' error occured.';
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
+ }
304
  }
305
+
 
 
 
 
 
 
 
 
 
 
 
 
 
306
 
307
  }
308
  ?>
index.html ADDED
File without changes
init.php CHANGED
@@ -4,91 +4,118 @@ 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.2
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.2');
17
 
18
  global $wpdb, $mmb_plugin_dir, $mmb_plugin_url;
19
 
 
 
 
 
 
 
20
  $mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
21
  $mmb_plugin_url = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
22
 
23
- require_once(ABSPATH . 'wp-includes/class-IXR.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  require_once("$mmb_plugin_dir/helper.class.php");
25
  require_once("$mmb_plugin_dir/core.class.php");
26
- require_once("$mmb_plugin_dir/plugin.class.php");
27
- 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
  {
45
  if (!isset($HTTP_RAW_POST_DATA)) {
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',
68
- 'backup' => 'mmb_backup_now',
69
- 'restore' => 'mmb_restore_now',
70
- 'optimize_tables' => 'mmb_optimize_tables',
71
- 'check_wp_version' => 'mmb_wp_checkversion',
72
- 'create_post' => 'mmb_post_create',
73
- 'upgrade_plugins' => 'mmb_upgrade_plugins',
74
- 'wp_upgrade' => 'mmb_upgrade_wp',
75
- 'upgrade_themes' => 'mmb_themes_upgrade',
76
- 'upload_plugin_by_url' => 'mmb_plugin_upload_by_url',
77
- 'upload_theme_by_url' => 'mmb_theme_upload_by_url',
78
- 'update_worker' => 'mmb_update_worker_plugin'
79
- );
80
  if (array_key_exists($action, $mmb_actions) && function_exists($mmb_actions[$action]))
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
 
@@ -99,14 +126,14 @@ function mmb_response($response = false, $success = true)
99
  $return = array();
100
 
101
  if (empty($response))
102
- $return['error'] = 'Empty response';
103
  else if ($success)
104
  $return['success'] = $response;
105
  else
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,35 +141,35 @@ 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. Please contact us if you see this message often.', false);
131
- } else {
132
- mmb_response('Command not successful. Please try again.', false);
133
- }
134
- } else{
135
- if ( !get_option('_worker_nossl_key')) {
136
- srand();
137
- $random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
138
-
139
- $mmb_core->_set_random_signature($random_key);
140
- $mmb_core->_set_worker_message_id($id);
141
- $mmb_core->_set_master_public_key($public_key);
142
- mmb_response($mmb_core->get_stats_instance()->get_initial_stats(), true);
143
- }
144
- else mmb_response('Please deactivate & activate ManageWP Worker plugin on your site, then re-add the site to your dashboard.', false);
145
- }
146
  } else {
147
  mmb_response('Please deactivate & activate ManageWP Worker plugin on your site and re-add the site to your dashboard.', false);
148
  }
@@ -152,72 +179,34 @@ function mmb_add_site($params)
152
  }
153
 
154
  function mmb_remove_site($params)
155
- {
156
- extract($params);
157
  global $mmb_core;
158
  $mmb_core->uninstall();
159
-
160
- include_once(ABSPATH . 'wp-admin/includes/plugin.php');
161
- $plugin_slug = basename(dirname(__FILE__)).'/'.basename(__FILE__);
162
-
163
- if($deactivate){
164
- deactivate_plugins($plugin_slug, true);
165
- }
166
-
167
- if(!is_plugin_active($plugin_slug))
168
- mmb_response(array('deactivated' => 'Site removed successfully. <br /><br />ManageWP Worker plugin successfully deactivated.'), true);
169
- else
170
- mmb_response(array('removed_data' => 'Site removed successfully. <br /><br /><b>ManageWP Worker plugin was not deactivated.</b>'), true);
171
 
172
- }
173
-
174
-
175
- function mmb_stats_get($params)
176
- {
177
- global $mmb_core;
178
- mmb_response($mmb_core->get_stats_instance()->get($params), true);
179
- }
180
-
181
-
182
- //Plugins
183
-
184
- function mmb_upgrade_plugins($params)
185
- {
186
- global $mmb_core;
187
- mmb_response($mmb_core->get_plugin_instance()->upgrade_all($params), true);
188
- }
189
-
190
- function mmb_plugin_upload_by_url($params)
191
- {
192
- global $mmb_core;
193
- $return = $mmb_core->get_plugin_instance()->upload_by_url($params);
194
-
195
 
196
- mmb_response($return['message'],$return['bool'] );
 
 
 
 
 
 
 
 
 
 
 
197
 
198
  }
199
 
200
- //Themes
201
- function mmb_theme_upload_by_url($params)
202
- {
203
- global $mmb_core;
204
- $return = $mmb_core->get_theme_instance()->upload_theme_by_url($params);
205
- mmb_response($return['message'],$return['bool'] );
206
- }
207
-
208
- function mmb_themes_upgrade($params)
209
- {
210
- global $mmb_core;
211
- mmb_response($mmb_core->get_theme_instance()->upgrade_all($params), true);
212
- }
213
-
214
-
215
- //wp
216
 
217
- function mmb_upgrade_wp($params)
218
  {
219
  global $mmb_core;
220
- mmb_response($mmb_core->get_wp_instance()->upgrade());
221
  }
222
 
223
  //post
@@ -231,19 +220,36 @@ function mmb_post_create($params)
231
  mmb_response($return, false);
232
  }
233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  //backup
235
  function mmb_backup_now($params)
236
  {
237
  global $mmb_core;
 
238
  $return = $mmb_core->get_backup_instance()->backup($params);
239
 
240
  if (is_array($return) && array_key_exists('error', $return))
241
  mmb_response($return['error'], false);
242
  else {
243
- $mmb_core->_log($return);
244
  mmb_response($return, true);
245
  }
246
-
247
  }
248
 
249
  function mmb_optimize_tables($params)
@@ -272,4 +278,38 @@ function mmb_update_worker_plugin($params)
272
  global $mmb_core;
273
  mmb_response($mmb_core->update_worker_plugin($params), true);
274
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  ?>
4
  Plugin URI: http://managewp.com/
5
  Description: Manage all your blogs from one dashboard
6
  Author: Prelovac Media
7
+ Version: 3.8.7
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
 
23
+ define('MMB_WORKER_VERSION', '3.8.7');
24
 
25
  global $wpdb, $mmb_plugin_dir, $mmb_plugin_url;
26
 
27
+ if (version_compare(PHP_VERSION, '5.0.0', '<')) // min version 5 supported
28
+ exit("<p>ManageWP Worker plugin requires PHP 5 or higher.</p>");
29
+
30
+ global $wp_version;
31
+
32
+ $mmb_wp_version = $wp_version;
33
  $mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
34
  $mmb_plugin_url = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
35
 
36
+ $mmb_actions = array(
37
+ 'remove_site' => 'mmb_remove_site',
38
+ 'get_stats' => 'mmb_stats_get',
39
+ 'backup' => 'mmb_backup_now',
40
+ 'restore' => 'mmb_restore_now',
41
+ 'optimize_tables' => 'mmb_optimize_tables',
42
+ 'check_wp_version' => 'mmb_wp_checkversion',
43
+ 'create_post' => 'mmb_post_create',
44
+ 'update_worker' => 'mmb_update_worker_plugin',
45
+ 'change_comment_status' => 'mmb_change_comment_status',
46
+ 'get_comment_stats' => 'mmb_comment_stats_get',
47
+ 'install_addon' => 'mmb_install_addon',
48
+ 'do_upgrade' => 'mmb_do_upgrade'
49
+ );
50
+
51
  require_once("$mmb_plugin_dir/helper.class.php");
52
  require_once("$mmb_plugin_dir/core.class.php");
 
 
 
53
  require_once("$mmb_plugin_dir/post.class.php");
54
+ require_once("$mmb_plugin_dir/comment.class.php");
55
  require_once("$mmb_plugin_dir/stats.class.php");
 
56
  require_once("$mmb_plugin_dir/backup.class.php");
57
+ require_once("$mmb_plugin_dir/installer.class.php");
58
+ require_once("$mmb_plugin_dir/api.php");
59
+
60
+
61
+ require_once("$mmb_plugin_dir/plugins/search/search.php");
62
+ require_once("$mmb_plugin_dir/plugins/cleanup/cleanup.php");
63
+
64
+ //this is an exmaple plugin for extra_html element
65
+ //require_once("$mmb_plugin_dir/plugins/extra_html_example/extra_html_example.php");
66
 
67
  $mmb_core = new MMB_Core();
68
+ add_action('init', 'mmb_parse_request');
69
 
70
  if (function_exists('register_activation_hook'))
71
+ register_activation_hook(__FILE__, array(
72
+ $mmb_core,
73
+ 'install'
74
+ ));
75
 
76
  if (function_exists('register_deactivation_hook'))
77
+ register_deactivation_hook(__FILE__, array(
78
+ $mmb_core,
79
+ 'uninstall'
80
+ ));
81
+
82
+
83
 
84
+ function mmb_parse_request()
85
  {
86
  if (!isset($HTTP_RAW_POST_DATA)) {
87
  $HTTP_RAW_POST_DATA = file_get_contents('php://input');
88
  }
89
  ob_start();
90
+
91
+ global $mmb_core, $mmb_actions, $new_actions;
92
+
93
  $data = base64_decode($HTTP_RAW_POST_DATA);
94
+ if ($data)
95
+ $num = @extract(unserialize($data));
96
 
97
  if ($action) {
98
+ // mmb_response($mmb_actions, false);
99
+ if (!$mmb_core->check_if_user_exists($params['username']))
100
+ mmb_response('Username <b>' . $params['username'] . '</b> does not have administrator capabilities. Enter the correct username in the site options.', false);
101
 
102
+ if ($action == 'add_site') {
103
+ mmb_add_site($params);
104
+ mmb_response('You should never see this.', false);
105
  }
106
 
107
+ $auth = $mmb_core->authenticate_message($action . $id, $signature, $id);
108
+ if ($auth === true) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  if (array_key_exists($action, $mmb_actions) && function_exists($mmb_actions[$action]))
110
  call_user_func($mmb_actions[$action], $params);
111
  else
112
  mmb_response('Action "' . $action . '" does not exist.', false);
113
+ } else {
 
 
114
  mmb_response($auth['error'], false);
115
  }
116
  }
117
+
118
+
119
  ob_end_clean();
120
  }
121
 
126
  $return = array();
127
 
128
  if (empty($response))
129
+ $return['error'] = 'Empty response.';
130
  else if ($success)
131
  $return['success'] = $response;
132
  else
133
  $return['error'] = $response;
134
 
135
  header('Content-Type: text/plain');
136
+ exit(PHP_EOL . base64_encode(serialize($return)));
137
  }
138
 
139
  function mmb_add_site($params)
141
  global $mmb_core;
142
 
143
  $num = extract($params);
144
+
145
  if ($num) {
146
+ if (!get_option('_action_message_id') && !get_option('_worker_public_key')) {
147
+ $public_key = base64_decode($public_key);
148
+
149
+ if (function_exists('openssl_verify')) {
150
+ $verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
151
+ if ($verify == 1) {
152
+ $mmb_core->set_master_public_key($public_key);
153
+ $mmb_core->set_worker_message_id($id);
154
+
155
+ mmb_response($mmb_core->get_stats_instance()->get_initial_stats(), true);
156
+ } else if ($verify == 0) {
157
+ mmb_response('Invalid message signature. Please contact us if you see this message often.', false);
158
+ } else {
159
+ mmb_response('Command not successful. Please try again.', false);
160
+ }
161
+ } else {
162
+ if (!get_option('_worker_nossl_key')) {
163
+ srand();
164
+ $random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
165
+
166
+ $mmb_core->set_random_signature($random_key);
167
+ $mmb_core->set_worker_message_id($id);
168
+ $mmb_core->set_master_public_key($public_key);
169
+ mmb_response($mmb_core->get_stats_instance()->get_initial_stats(), true);
170
+ } else
171
+ mmb_response('Please deactivate & activate ManageWP Worker plugin on your site, then re-add the site to your dashboard.', false);
172
+ }
173
  } else {
174
  mmb_response('Please deactivate & activate ManageWP Worker plugin on your site and re-add the site to your dashboard.', false);
175
  }
179
  }
180
 
181
  function mmb_remove_site($params)
182
+ {
183
+ extract($params);
184
  global $mmb_core;
185
  $mmb_core->uninstall();
 
 
 
 
 
 
 
 
 
 
 
 
186
 
187
+ include_once(ABSPATH . 'wp-admin/includes/plugin.php');
188
+ $plugin_slug = basename(dirname(__FILE__)) . '/' . basename(__FILE__);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
 
190
+ if ($deactivate) {
191
+ deactivate_plugins($plugin_slug, true);
192
+ }
193
+
194
+ if (!is_plugin_active($plugin_slug))
195
+ mmb_response(array(
196
+ 'deactivated' => 'Site removed successfully. <br /><br />ManageWP Worker plugin successfully deactivated.'
197
+ ), true);
198
+ else
199
+ mmb_response(array(
200
+ 'removed_data' => 'Site removed successfully. <br /><br /><b>ManageWP Worker plugin was not deactivated.</b>'
201
+ ), true);
202
 
203
  }
204
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
 
206
+ function mmb_stats_get($params)
207
  {
208
  global $mmb_core;
209
+ mmb_response($mmb_core->get_stats_instance()->get($params), true);
210
  }
211
 
212
  //post
220
  mmb_response($return, false);
221
  }
222
 
223
+ //comments
224
+ function mmb_change_comment_status($params)
225
+ {
226
+
227
+ global $mmb_core;
228
+ $return = $mmb_core->get_comment_instance()->change_status($params);
229
+ //mmb_response($return, true);
230
+ if ($return)
231
+ mmb_response($mmb_core->get_stats_instance()->get_comments_stats($params), true);
232
+ else
233
+ mmb_response('Comment not updated', false);
234
+ }
235
+ function mmb_comment_stats_get($params)
236
+ {
237
+ global $mmb_core;
238
+ mmb_response($mmb_core->get_stats_instance()->get_comments_stats($params), true);
239
+ }
240
+
241
  //backup
242
  function mmb_backup_now($params)
243
  {
244
  global $mmb_core;
245
+
246
  $return = $mmb_core->get_backup_instance()->backup($params);
247
 
248
  if (is_array($return) && array_key_exists('error', $return))
249
  mmb_response($return['error'], false);
250
  else {
 
251
  mmb_response($return, true);
252
  }
 
253
  }
254
 
255
  function mmb_optimize_tables($params)
278
  global $mmb_core;
279
  mmb_response($mmb_core->update_worker_plugin($params), true);
280
  }
281
+
282
+ function mmb_wp_checkversion($params)
283
+ {
284
+ include_once(ABSPATH . 'wp-includes/version.php');
285
+ global $mmb_wp_version, $mmb_core;
286
+ mmb_response($mmb_wp_version, true);
287
+ }
288
+
289
+ function mmb_search_posts_by_term($params)
290
+ {
291
+ global $mmb_core;
292
+ $return = $mmb_core->get_search_instance()->search_posts_by_term($params);
293
+
294
+ if ($return) {
295
+ mmb_response(serialize($return), true);
296
+ } else {
297
+ mmb_response('No posts for term', false);
298
+ }
299
+ }
300
+
301
+ function mmb_install_addon($params)
302
+ {
303
+ global $mmb_core;
304
+ $return = $mmb_core->get_installer_instance()->install_remote_file($params);
305
+ mmb_response($return, true);
306
+
307
+ }
308
+ function mmb_do_upgrade($params)
309
+ {
310
+ global $mmb_core, $mmb_upgrading;
311
+ $return = $mmb_core->get_installer_instance()->do_upgrade($params);
312
+ mmb_response($return, true);
313
+
314
+ }
315
  ?>
installer.class.php ADDED
@@ -0,0 +1,319 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ class MMB_Installer extends MMB_Core
14
+ {
15
+ function __construct()
16
+ {
17
+ @set_time_limit(300);
18
+ parent::__construct();
19
+ include_once(ABSPATH . 'wp-admin/includes/file.php');
20
+ include_once(ABSPATH . 'wp-admin/includes/plugin.php');
21
+ include_once(ABSPATH . 'wp-admin/includes/theme.php');
22
+ include_once(ABSPATH . 'wp-admin/includes/misc.php');
23
+ include_once(ABSPATH . 'wp-admin/includes/template.php');
24
+ include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
25
+
26
+ global $wp_filesystem;
27
+ if (!$wp_filesystem)
28
+ WP_Filesystem();
29
+
30
+ }
31
+
32
+ function mmb_maintenance_mode($enable = false, $maintenance_message = '')
33
+ {
34
+ global $wp_filesystem;
35
+
36
+ $maintenance_message .= '<?php $upgrading = ' . time() . '; ?>';
37
+
38
+ $file = $wp_filesystem->abspath() . '.maintenance';
39
+ if ($enable) {
40
+ $wp_filesystem->delete($file);
41
+ $wp_filesystem->put_contents($file, $maintenance_message, FS_CHMOD_FILE);
42
+ } else {
43
+ $wp_filesystem->delete($file);
44
+ }
45
+ }
46
+
47
+ function install_remote_file($params)
48
+ {
49
+ global $wp_filesystem;
50
+ extract($params);
51
+
52
+ if (!isset($package) || empty($package))
53
+ return array(
54
+ 'error' => '<p>No files received. Internal error.</p>'
55
+ );
56
+
57
+ if (defined('WP_INSTALLING') && file_exists(ABSPATH . '.maintenance'))
58
+ return array(
59
+ 'error' => '<p>Site under maintanace.</p>'
60
+ );
61
+ ;
62
+
63
+ $upgrader = new WP_Upgrader();
64
+ $destination = $type == 'themes' ? WP_CONTENT_DIR . '/themes' : WP_PLUGIN_DIR;
65
+
66
+
67
+ foreach ($package as $package_url) {
68
+ $key = basename($package_url);
69
+ $install_info[$key] = @$upgrader->run(array(
70
+ 'package' => $package_url,
71
+ 'destination' => $destination,
72
+ 'clear_destination' => false, //Do not overwrite files.
73
+ 'clear_working' => true,
74
+ 'hook_extra' => array()
75
+ ));
76
+ }
77
+
78
+ if ($activate) {
79
+ $all_plugins = get_plugins();
80
+ foreach ($all_plugins as $plugin_slug => $plugin) {
81
+ $plugin_dir = preg_split('/\//', $plugin_slug);
82
+ foreach ($install_info as $key => $install) {
83
+ if (!$install || is_wp_error($install))
84
+ continue;
85
+
86
+ if ($install['destination_name'] == $plugin_dir[0]) {
87
+ $install_info[$key]['activated'] = activate_plugin($plugin_slug, '', false);
88
+ }
89
+ }
90
+ }
91
+ }
92
+ ob_clean();
93
+ return $install_info;
94
+ }
95
+
96
+ function do_upgrade($params = null){
97
+
98
+ if($params == null || empty($params))
99
+ return array('failed' => 'No upgrades passed.');
100
+
101
+ if ((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && (get_filesystem_method(array(), false) != 'direct')) {
102
+ return array(
103
+ 'error' => 'Failed, please <a target="_blank" href="http://managewp.com/user-guide#ftp">add FTP details</a></a>'
104
+ );
105
+ }
106
+ $params = isset($params['upgrades_all']) ? $params['upgrades_all'] : $params;
107
+
108
+ $core_upgrade = isset($params['wp_upgrade']) ? $params['wp_upgrade'] : array();
109
+ $upgrade_plugins = isset($params['upgrade_plugins']) ? $params['upgrade_plugins'] : array();
110
+ $upgrade_themes = isset($params['upgrade_themes']) ? $params['upgrade_themes'] : array();
111
+
112
+ $upgrades = array();
113
+ if(!empty($core_upgrade)){
114
+ $upgrades['core'] = $this->upgrade_core($core_upgrade);
115
+ }
116
+ if(!empty($upgrade_plugins)){
117
+ $plugin_files = array();
118
+ foreach($upgrade_plugins as $plugin){
119
+ $plugin_files[] = $plugin->file;
120
+ }
121
+
122
+ $upgrades['plugins'] = $this->upgrade_plugins($plugin_files);
123
+ $this->mmb_maintenance_mode(false);
124
+ }
125
+
126
+ if(!empty($upgrade_themes)){
127
+ $theme_temps = array();
128
+ foreach($upgrade_themes as $theme){
129
+ $theme_temps[] = $theme['theme_tmp'];
130
+ }
131
+
132
+ $upgrades['themes'] = $this->upgrade_themes($theme_temps);
133
+ $this->mmb_maintenance_mode(false);
134
+ }
135
+ ob_clean();
136
+ return $upgrades;
137
+ }
138
+
139
+ /**
140
+ * Upgrades WordPress locally
141
+ *
142
+ */
143
+ function upgrade_core($current)
144
+ {
145
+ ob_start();
146
+ global $mmb_wp_version, $wp_filesystem;
147
+ $upgrader = new WP_Upgrader();
148
+
149
+ // Is an update available?
150
+ if (!isset($current->response) || $current->response == 'latest')
151
+ return array(
152
+ 'upgraded' => ' Upgraded successfully.'
153
+ );
154
+
155
+ $res = $upgrader->fs_connect(array(
156
+ ABSPATH,
157
+ WP_CONTENT_DIR
158
+ ));
159
+ if (is_wp_error($res))
160
+ return array(
161
+ 'error' => $this->mmb_get_error($res)
162
+ );
163
+
164
+ $wp_dir = trailingslashit($wp_filesystem->abspath());
165
+
166
+ $download = $upgrader->download_package($current->package);
167
+ if (is_wp_error($download))
168
+ return array(
169
+ 'error' => $this->mmb_get_error($download)
170
+ );
171
+
172
+ $working_dir = $upgrader->unpack_package($download);
173
+ if (is_wp_error($working_dir))
174
+ return array(
175
+ 'error' => $this->mmb_get_error($working_dir)
176
+ );
177
+
178
+ if (!$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true)) {
179
+ $wp_filesystem->delete($working_dir, true);
180
+ return array(
181
+ 'error' => 'Unable to move update files.'
182
+ );
183
+ }
184
+
185
+ $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
186
+
187
+ require(ABSPATH . 'wp-admin/includes/update-core.php');
188
+
189
+
190
+ $update_core = update_core($working_dir, $wp_dir);
191
+ ob_end_clean();
192
+
193
+ if (is_wp_error($update_core))
194
+ return array(
195
+ 'error' => $this->mmb_get_error($update_core)
196
+ );
197
+ ob_end_flush();
198
+ return array(
199
+ 'upgraded' => ' Upgraded successfully.'
200
+ );
201
+ }
202
+
203
+
204
+ function upgrade_plugins($plugins = false){
205
+ if(!$plugins || empty($plugins))
206
+ return array(
207
+ 'error' => 'No plugin files for upgrade.'
208
+ );
209
+
210
+ if (class_exists('Plugin_Upgrader') && class_exists('Bulk_Plugin_Upgrader_Skin')) {
211
+ $upgrader = new Plugin_Upgrader(new Bulk_Plugin_Upgrader_Skin(compact('nonce', 'url')));
212
+ $result = $upgrader->bulk_upgrade($plugins);
213
+ ob_end_clean();
214
+ if (!empty($result)) {
215
+ foreach ($result as $plugin_slug => $plugin_info) {
216
+ $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_slug);
217
+ if (!$plugin_info || is_wp_error($plugin_info)) {
218
+ $return .= '<code title="Please upgrade manually">' . $data['Name'] . '</code> was not upgraded.<br />';
219
+ } else {
220
+ $return .= '<code>' . $data['Name'] . '</code> successfully upgraded.<br />';
221
+ }
222
+ }
223
+ ob_end_clean();
224
+ return array(
225
+ 'upgraded' => $return
226
+ );
227
+ }
228
+ else
229
+ return array(
230
+ 'error' => 'Upgrade failed.'
231
+ );
232
+ } else {
233
+ ob_end_clean();
234
+ return array(
235
+ 'error' => 'WordPress update required first'
236
+ );
237
+ }
238
+ }
239
+
240
+ function upgrade_themes($themes = false){
241
+ if(!$themes || empty($themes))
242
+ return array(
243
+ 'error' => 'No theme files for upgrade.'
244
+ );
245
+
246
+ if (class_exists('Theme_Upgrader') && class_exists('Bulk_Theme_Upgrader_Skin')) {
247
+ $upgrader = new Theme_Upgrader(new Bulk_Theme_Upgrader_Skin(compact('title', 'nonce', 'url', 'theme')));
248
+
249
+ $result = $upgrader->bulk_upgrade($themes);
250
+
251
+ $results = array();
252
+ if (!empty($result)) {
253
+ foreach ($result as $theme_tmp => $info) {
254
+ if (is_wp_error($info) || !$info) {
255
+ $results[$theme_tmp] = '<code title="Please upgrade manually">' . $theme_tmp . '</code> was not upgraded.<br />';
256
+ } else {
257
+ $results[$theme_tmp] = '<code>' . $theme_tmp . '</code> succesfully upgraded.<br />';
258
+ }
259
+ }
260
+ return array(
261
+ 'upgraded' => implode('', $results)
262
+ );
263
+ } else
264
+ return array(
265
+ 'error' => 'Upgrade failed.'
266
+ );
267
+ } else {
268
+ ob_end_clean();
269
+ return array(
270
+ 'error' => 'WordPress update required first'
271
+ );
272
+ }
273
+ }
274
+
275
+ function get_upgradable_plugins()
276
+ {
277
+ $current = $this->mmb_get_transient('update_plugins');
278
+ $upgradable_plugins = array();
279
+ if (!empty($current->response)) {
280
+ foreach ($current->response as $plugin_path => $plugin_data) {
281
+ if (!function_exists('get_plugin_data'))
282
+ include_once ABSPATH . 'wp-admin/includes/plugin.php';
283
+ $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_path);
284
+
285
+ $current->response[$plugin_path]->name = $data['Name'];
286
+ $current->response[$plugin_path]->old_version = $data['Version'];
287
+ $current->response[$plugin_path]->file = $plugin_path;
288
+ $upgradable_plugins[] = $current->response[$plugin_path];
289
+ }
290
+ return $upgradable_plugins;
291
+ } else
292
+ return array();
293
+
294
+ }
295
+
296
+ function get_upgradable_themes()
297
+ {
298
+ $all_themes = get_themes();
299
+ $upgrade_themes = array();
300
+
301
+ $current = $this->mmb_get_transient('update_themes');
302
+ foreach ((array) $all_themes as $theme_template => $theme_data) {
303
+ if (!empty($current->response)) {
304
+ foreach ($current->response as $current_themes => $theme) {
305
+ if ($theme_data['Template'] == $current_themes) {
306
+ $current->response[$current_themes]['name'] = $theme_data['Name'];
307
+ $current->response[$current_themes]['old_version'] = $theme_data['Version'];
308
+ $current->response[$current_themes]['theme_tmp'] = $theme_data['Template'];
309
+ $upgrade_themes[] = $current->response[$current_themes];
310
+ continue;
311
+ }
312
+ }
313
+ }
314
+ }
315
+
316
+ return $upgrade_themes;
317
+ }
318
+ }
319
+ ?>
plugin.class.php DELETED
@@ -1,131 +0,0 @@
1
- <?php
2
-
3
- class MMB_Plugin extends MMB_Core
4
- {
5
- var $worker_maitanance_mode = false;
6
- function __construct()
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');
31
- include_once(ABSPATH . 'wp-admin/includes/plugin.php');
32
- require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
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
60
- */
61
- function upload_by_url($args)
62
- {
63
- //print_r($args);
64
- $this->_escape($args);
65
- $plugin_url = $args['url'];
66
- $activate_plugin = $args['activate'];
67
-
68
- if ($plugin_url) {
69
- ob_start();
70
- include_once(ABSPATH . 'wp-admin/includes/file.php');
71
- include_once(ABSPATH . 'wp-admin/includes/plugin.php');
72
- include_once(ABSPATH . 'wp-admin/includes/misc.php');
73
- include_once(ABSPATH . 'wp-admin/includes/template.php');
74
- include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
75
-
76
- $upgrader = new Plugin_Upgrader();
77
-
78
- $result = $upgrader->run(array(
79
- 'package' => $plugin_url,
80
- 'destination' => WP_PLUGIN_DIR,
81
- 'clear_destination' => false, //Do not overwrite files.
82
- 'clear_working' => true,
83
- 'hook_extra' => array()
84
- ));
85
-
86
- ob_end_clean();
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
-
130
- }
131
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
plugins/cleanup/cleanup.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*************************************************************
3
+ *
4
+ *
5
+ *
6
+ * ManageWP Worker Plugin addon - Cleanup
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
+ {
30
+ global $mmb_core;
31
+
32
+ $params_array = explode('_', $params['actions']);
33
+ $return_array = array();
34
+ foreach ($params_array as $param) {
35
+ switch ($param) {
36
+ case 'revision':
37
+ if (mmb_delete_all_revisions()) {
38
+ $return_array['revision'] = 'Revisions deleted.';
39
+ } else {
40
+ $return_array['revision'] = 'Revisions not deleted.';
41
+ }
42
+ break;
43
+ case 'overhead':
44
+ if (mmb_clear_overhead()) {
45
+ $return_array['overhead'] = 'Overhead cleared.';
46
+ } else {
47
+ $return_array['overhead'] = 'Overhead not cleared.';
48
+ }
49
+ break;
50
+ case 'comment':
51
+ if (mmb_delete_spam_comments()) {
52
+ $return_array['comment'] = 'Comments deleted';
53
+ } else {
54
+ $return_array['comment'] = 'Comments not deleted';
55
+ }
56
+ break;
57
+ default:
58
+ break;
59
+ }
60
+
61
+ }
62
+
63
+ unset($params);
64
+
65
+ mmb_response($return_array, true);
66
+ }
67
+
68
+ function mmb_num_revisions()
69
+ {
70
+ global $wpdb;
71
+ $sql = "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'revision'";
72
+ $num_revisions = $wpdb->get_var($wpdb->prepare($sql));
73
+ return $num_revisions;
74
+ }
75
+
76
+ function mmb_select_all_revisions()
77
+ {
78
+ global $wpdb;
79
+ $sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'revision'";
80
+ $revisions = $wpdb->get_results($wpdb->prepare($sql));
81
+ return $revisions;
82
+ }
83
+
84
+ function mmb_delete_all_revisions()
85
+ {
86
+ global $wpdb;
87
+ $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'";
88
+ $revisions = $wpdb->query($wpdb->prepare($sql));
89
+ return $revisions;
90
+ }
91
+
92
+
93
+
94
+ /* Optimize */
95
+
96
+ function mmb_get_overhead()
97
+ {
98
+ global $wpdb, $mmb_core;
99
+ $tot_data = 0;
100
+ $tot_idx = 0;
101
+ $tot_all = 0;
102
+ $query = 'SHOW TABLE STATUS FROM ' . DB_NAME;
103
+ $tables = $wpdb->get_results($query, ARRAY_A);
104
+ foreach ($tables as $table) {
105
+ $tot_data = $table['Data_length'];
106
+ $tot_idx = $table['Index_length'];
107
+ $total = $tot_data + $tot_idx;
108
+ $total = $total / 1024;
109
+ $total = round($total, 3);
110
+ $gain = $table['Data_free'];
111
+ $gain = $gain / 1024;
112
+ $total_gain += $gain;
113
+ $gain = round($gain, 3);
114
+
115
+ }
116
+
117
+ return round($total_gain, 3);
118
+ }
119
+
120
+ function mmb_clear_overhead()
121
+ {
122
+ global $wpdb;
123
+ $tables = $wpdb->get_col("SHOW TABLES");
124
+ foreach ($tables as $table_name) {
125
+ $table_string .= $table_name . ",";
126
+ }
127
+ $table_string = substr($table_string, 0, strlen($table_string) - 1); //remove last ,
128
+
129
+ $table_string = rtrim($table_string);
130
+
131
+ $query = "OPTIMIZE TABLE $table_string";
132
+
133
+ $optimize = $wpdb->query($query);
134
+ return $optimize ? true : false;
135
+ }
136
+
137
+
138
+
139
+ /* Spam Comments */
140
+
141
+ function mmb_num_spam_comments()
142
+ {
143
+ global $wpdb;
144
+ $sql = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'spam'";
145
+ $num_spams = $wpdb->get_var($wpdb->prepare($sql));
146
+ return $num_spams;
147
+ }
148
+
149
+ function mmb_delete_spam_comments()
150
+ {
151
+ global $wpdb;
152
+ $sql = "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam'";
153
+ $spams = $wpdb->query($wpdb->prepare($sql));
154
+ return $sql;
155
+ }
156
+
157
+
158
+ function mmb_get_spam_comments()
159
+ {
160
+ global $wpdb;
161
+ $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'";
162
+ $spams = $wpdb->get_results($wpdb->prepare($sql));
163
+ return $spams;
164
+ }
165
+ ?>
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,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>' . substr($post->post_title, $str_position_start, strlen($term_orig)) . '</b>' . substr($post->post_title, $str_position_start + strlen($term_orig));
46
+
47
+ }
48
+ $post->post_content = html_entity_decode($post->post_content);
49
+
50
+ $post->post_content = strip_tags($post->post_content);
51
+
52
+
53
+
54
+ if (substr_count(strtolower($post->post_content), strtolower($term_orig))) {
55
+ $str_position_start = strpos(strtolower($post->post_content), strtolower($term_orig));
56
+
57
+ $start = $str_position_start > $num_content_char ? $str_position_start - $num_content_char : 0;
58
+ $first_len = $str_position_start > $num_content_char ? $num_content_char : $str_position_start;
59
+
60
+ $start_substring = $start > 0 ? '...' : '';
61
+ $post->post_content = $start_substring . substr($post->post_content, $start, $first_len) . '<b>' . substr($post->post_content, $str_position_start, strlen($term_orig)) . '</b>' . substr($post->post_content, $str_position_start + strlen($term_orig), $num_content_char) . '...';
62
+
63
+
64
+ } else {
65
+ $post->post_content = substr($post->post_content, 0, 50) . '...';
66
+ }
67
+
68
+ $ret_posts[] = array(
69
+ 'ID' => $post->ID,
70
+ 'post_permalink' => get_permalink($post->ID),
71
+ 'post_date' => $post->post_date,
72
+ 'post_title' => $post->post_title,
73
+ 'post_content' => $post->post_content,
74
+ 'post_modified' => $post->post_modified,
75
+ 'comment_count' => $post->comment_count
76
+
77
+
78
+ );
79
+ }
80
+ mmb_response($ret_posts, true);
81
+
82
+ }
83
+
84
+ ?>
post.class.php CHANGED
@@ -28,6 +28,7 @@ class MMB_Post extends MMB_Core
28
 
29
  include_once ABSPATH . 'wp-admin/includes/taxonomy.php';
30
  include_once ABSPATH . 'wp-admin/includes/image.php';
 
31
 
32
  $post_struct = $args['post_data'];
33
 
@@ -41,7 +42,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(
@@ -120,10 +121,7 @@ class MMB_Post extends MMB_Core
120
  $no_thumb = $get_url[4];
121
  }
122
  $file_name = basename($no_thumb);
123
-
124
- //$tmp_file = $upload['path'].'/tempfile.tmp';
125
- $tmp_file = $this->mmb_download_url($no_thumb, $upload['path'] . '/tempfile'.md5(time()).'.tmp');
126
- //$tmp_file = download_url($no_thumb);
127
 
128
  $attach_upload['url'] = $upload['url'] . '/' . $file_name;
129
  $attach_upload['path'] = $upload['path'] . '/' . $file_name;
@@ -206,13 +204,8 @@ class MMB_Post extends MMB_Core
206
  }
207
  if (count($post_atta_img)) {
208
  foreach ($post_atta_img as $img) {
209
- $file_name = basename($img['src']);
210
-
211
-
212
- $tmp_file = $this->mmb_download_url($img['src'], $upload['path'] . '/tempfile.tmp');
213
-
214
- //$tmp_file = download_url($img['src']);
215
-
216
  $attach_upload['url'] = $upload['url'] . '/' . $file_name;
217
  $attach_upload['path'] = $upload['path'] . '/' . $file_name;
218
  $renamed = @rename($tmp_file, $attach_upload['path']);
@@ -274,8 +267,7 @@ class MMB_Post extends MMB_Core
274
  // featured image
275
  if ($post_featured_img != '') {
276
  $file_name = basename($post_featured_img);
277
- //$tmp_file = download_url($post_featured_img);
278
- $tmp_file = $this->mmb_download_url($no_thumb, $upload['path'] . '/tempfile_feat.tmp');
279
  $attach_upload['url'] = $upload['url'] . '/' . $file_name;
280
  $attach_upload['path'] = $upload['path'] . '/' . $file_name;
281
  $renamed = @rename($tmp_file, $attach_upload['path']);
@@ -325,26 +317,8 @@ 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
- /**
336
- * Aleternate function for WordPress download_url()
337
- */
338
- function mmb_download_url($url, $file_name)
339
- {
340
- $destination = fopen($file_name, 'wb');
341
- $source = @fopen($url, "r");
342
- while ($a = fread($source, 1024)) {
343
- $ret = fwrite($destination, $a);
344
- }
345
- fclose($source);
346
- fclose($destination);
347
- return $file_name;
348
- }
349
  }
350
  ?>
28
 
29
  include_once ABSPATH . 'wp-admin/includes/taxonomy.php';
30
  include_once ABSPATH . 'wp-admin/includes/image.php';
31
+ include_once ABSPATH . 'wp-admin/includes/file.php';
32
 
33
  $post_struct = $args['post_data'];
34
 
42
 
43
  $upload = wp_upload_dir();
44
 
45
+ // create dynamic url RegExp
46
  $mwp_base_url = parse_url($post_upload_dir['url']);
47
  $mwp_regexp_url = $mwp_base_url['host'] . $mwp_base_url['path'];
48
  $rep = array(
121
  $no_thumb = $get_url[4];
122
  }
123
  $file_name = basename($no_thumb);
124
+ $tmp_file = download_url($no_thumb);
 
 
 
125
 
126
  $attach_upload['url'] = $upload['url'] . '/' . $file_name;
127
  $attach_upload['path'] = $upload['path'] . '/' . $file_name;
204
  }
205
  if (count($post_atta_img)) {
206
  foreach ($post_atta_img as $img) {
207
+ $file_name = basename($img['src']);
208
+ $tmp_file = download_url($img['src']);
 
 
 
 
 
209
  $attach_upload['url'] = $upload['url'] . '/' . $file_name;
210
  $attach_upload['path'] = $upload['path'] . '/' . $file_name;
211
  $renamed = @rename($tmp_file, $attach_upload['path']);
267
  // featured image
268
  if ($post_featured_img != '') {
269
  $file_name = basename($post_featured_img);
270
+ $tmp_file = download_url($post_featured_img);
 
271
  $attach_upload['url'] = $upload['url'] . '/' . $file_name;
272
  $attach_upload['path'] = $upload['path'] . '/' . $file_name;
273
  $renamed = @rename($tmp_file, $attach_upload['path']);
317
  update_post_meta($post_id, $meta_key, $value[0]);
318
  }
319
  }
 
 
320
  return $post_id;
 
 
321
  }
322
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  }
324
  ?>
readme.txt CHANGED
@@ -1,68 +1,99 @@
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 upgrades of WordPress, plugin and themes across all your sites
17
- * Access admin of any site from one dashboard
18
- * Publish posts in bulk to multiple sites at once
19
- * Upload themes and plugins in bulk to multiple sites at once
20
- * Automatic backups of your sites
21
- * Clone one site to another
22
- * Much, much more...
23
-
24
- Check out [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs")
25
-
26
- == Changelog ==
27
-
28
- = 3.8.2 =
29
- * New interface
30
- * SSL security protocol
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
+ * Secure! No passwords for sites required, uses OpenSSL encrypted protocol
18
+ * One click upgrades of WordPress, plugin and themes across all your sites
19
+ * One click to access administration dashboard for any site
20
+ * Bulk publish posts to multiple sites at once
21
+ * Bulk upload themes and plugins to multiple sites at once
22
+ * Automatic backups of your sites
23
+ * Clone one site to another
24
+ * Much, much more...
25
+
26
+ Check out [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs")
27
+
28
+ API for developers available at [ManageWP.com/API](http://managewp.com/api "ManageWP API")
29
+
30
+ == Changelog ==
31
+
32
+ = 3.8.7 =
33
+ * Fixed 408 error when adding sites
34
+ * Added support for IDN domains
35
+ * Fixed bug with WordPress updates
36
+ * Added comment moderation to the dashboard
37
+ * Added quick links for sites (menu appears on hover)
38
+
39
+
40
+ = 3.8.6 =
41
+ * Added seach websites feature
42
+ * Enhanced dashboard actions (spam comments, post revisions, table overhead)
43
+ * Added developer [API] (http://managewp.com/api "ManageWP API")
44
+ * Improved Migrate/Clone site feature
45
+
46
+ = 3.8.4 =
47
+ * Fixed remote dashboard problems for sites with redirects
48
+ * Fixed IE7 issues in the dashboard
49
+
50
+ = 3.8.3 =
51
+ * Fixed problem with capabilities
52
+
53
+ = 3.8.2 =
54
+ * New interface
55
+ * SSL security protocol
56
+ * No passwords required
57
+ * Improved clone/backup
58
+
59
+
60
+ = 3.6.3 =
61
+ * Initial public release
62
+
63
+ == Installation ==
64
+
65
+ 1. Upload the plugin folder to your /wp-content/plugins/ folder
66
+ 2. Go to the Plugins page and activate ManageWP Worker
67
+ 3. Visit [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs"), sign up and add your site
68
+
69
+ Alternately
70
+
71
+ 1. Visit [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs"), sign up and add your site
72
+ 2. ManageWP will warn you the worker plugin is not installed and offer a link for quick installation
73
+
74
+ == Screenshots ==
75
+
76
+ 1. ManageWP dashboard with available upgrades, site statistics and management functions
77
+
78
+
79
+
80
+ == License ==
81
+
82
+ This file is part of ManageWP Worker.
83
+
84
+ 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.
85
+
86
+ 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.
87
+
88
+ You should have received a copy of the GNU General Public License along with ManageWP Worker. If not, see <http://www.gnu.org/licenses/>.
89
+
90
+
91
+ == Frequently Asked Questions ==
92
+
93
+ = I have problems adding my site =
94
+
95
+ 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").
96
+
97
+ = I have problems installing new plugins or upgrading WordPress through ManageWP =
98
+
99
+ 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()
@@ -13,28 +25,30 @@ class MMB_Stats extends MMB_Core
13
 
14
  function get($params)
15
  {
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);
@@ -44,53 +58,41 @@ class MMB_Stats extends MMB_Core
44
  }
45
  $stats['hit_counter'] = get_option('user_hit_count');
46
 
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);
75
- unset($recent->post_category);
76
- unset($recent->post_date_gmt);
77
- unset($recent->post_excerpt);
78
- unset($recent->post_status);
79
- unset($recent->comment_status);
80
- unset($recent->ping_status);
81
- unset($recent->post_password);
82
- unset($recent->post_name);
83
- unset($recent->to_ping);
84
- unset($recent->pinged);
85
- unset($recent->post_modified_gmt);
86
- unset($recent->post_content_filtered);
87
- unset($recent->post_parent);
88
- unset($recent->guid);
89
- unset($recent->menu_order);
90
- unset($recent->post_type);
91
- unset($recent->post_mime_type);
92
- unset($recent->filter);
93
- unset($recent->featured);
94
  $recent_posts[] = $recent;
95
  }
96
  $stats['posts'] = $recent_posts;
@@ -110,14 +112,38 @@ class MMB_Stats extends MMB_Core
110
  $stats['draft_count'] = count($drafts);
111
  $stats['drafts'] = $drafts;
112
 
113
-
114
- if ((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && !is_writable(WP_CONTENT_DIR)) {
 
 
115
  $stats['writable'] = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
117
- else $stats['writable'] = true;
 
 
 
 
 
 
 
 
 
118
  return $stats;
119
  }
120
-
121
  function get_initial_stats()
122
  {
123
  global $mmb_plugin_dir;
@@ -125,30 +151,30 @@ class MMB_Stats extends MMB_Core
125
  $stats = array();
126
 
127
  $stats['email'] = get_option('admin_email');
128
- $stats['no_openssl'] = $this->_get_random_signature();
129
  $stats['content_path'] = WP_CONTENT_DIR;
130
  $stats['worker_path'] = $mmb_plugin_dir;
131
  $stats['worker_version'] = MMB_WORKER_VERSION;
132
  $stats['site_title'] = get_bloginfo('name');
133
  $stats['site_tagline'] = get_bloginfo('description');
 
134
 
135
-
136
- if ((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && !is_writable(WP_CONTENT_DIR)) {
 
 
 
137
  $stats['writable'] = false;
138
- }
139
- else $stats['writable'] = true;
140
 
141
  return $stats;
142
  }
143
-
144
-
145
-
146
-
147
-
148
  function set_hit_count($fix_count = false)
149
  {
150
-
151
- if ($fix_count || (!is_admin() && !MMB_Stats::detect_bots() )) {
152
  $date = date('Y-m-d');
153
  $user_hit_count = get_option('user_hit_count');
154
  if (!$user_hit_count) {
@@ -157,18 +183,17 @@ class MMB_Stats extends MMB_Core
157
  } else {
158
  $dated_keys = array_keys($user_hit_count);
159
  $last_visit_date = $dated_keys[count($dated_keys) - 1];
160
-
161
  $days = intval((strtotime($date) - strtotime($last_visit_date)) / 60 / 60 / 24);
162
 
163
- if ($days > 1) {
164
-
165
  $date_to_add = date('Y-m-d', strtotime($last_visit_date));
166
 
167
  for ($i = 1; $i < $days; $i++) {
168
  if (count($user_hit_count) > 14) {
169
  $shifted = @array_shift($user_hit_count);
170
  }
171
-
172
  $next_key = strtotime('+1 day', strtotime($date_to_add));
173
  if ($next_key == $date) {
174
  break;
@@ -176,7 +201,7 @@ class MMB_Stats extends MMB_Core
176
  $user_hit_count[$next_key] = 0;
177
  }
178
  }
179
-
180
  }
181
 
182
  if (!isset($user_hit_count[$date])) {
@@ -185,11 +210,11 @@ class MMB_Stats extends MMB_Core
185
  if (!$fix_count)
186
  $user_hit_count[$date] += 1;
187
 
188
- if (count($user_hit_count) > 7) {
189
  $shifted = @array_shift($user_hit_count);
190
  }
191
 
192
- update_option('user_hit_count', $user_hit_count);
193
 
194
  }
195
  }
@@ -211,7 +236,7 @@ class MMB_Stats extends MMB_Core
211
  }
212
 
213
  function detect_bots()
214
- {
215
  $agent = $_SERVER['HTTP_USER_AGENT'];
216
 
217
  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()
25
 
26
  function get($params)
27
  {
28
+ global $mmb_wp_version, $mmb_plugin_dir;
29
  $stats = array();
30
 
31
+ //define constants
32
+ $num_pending_comments = 1000;
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
+ $stats['worker_version'] = MMB_WORKER_VERSION;
41
+ $stats['wordpress_version'] = $mmb_wp_version;
42
+
43
  $updates = $this->mmb_get_transient('update_core');
44
+
45
+ if ($updates->updates[0]->response == 'development' || version_compare($mmb_wp_version, $updates->updates[0]->current, '<')) {
46
+ $updates->updates[0]->current_version = $mmb_wp_version;
47
+ $stats['core_updates'] = $updates->updates[0];
48
+ } else
49
+ $stats['core_updates'] = false;
50
+
51
+ $mmb_user_hits = get_option('user_hit_count');
52
  if (is_array($mmb_user_hits)) {
53
  end($mmb_user_hits);
54
  $last_key_date = key($mmb_user_hits);
58
  }
59
  $stats['hit_counter'] = get_option('user_hit_count');
60
 
 
 
61
 
62
+ $stats['upgradable_themes'] = $this->get_installer_instance()->get_upgradable_themes();
63
+ $stats['upgradable_plugins'] = $this->get_installer_instance()->get_upgradable_plugins();
64
+
65
+ $pending_comments = get_comments('status=hold&number=' . $num_pending_comments);
66
  foreach ($pending_comments as &$comment) {
67
  $commented_post = get_post($comment->comment_post_ID);
68
  $comment->post_title = $commented_post->post_title;
69
  }
70
+ $stats['comments']['pending'] = $pending_comments;
71
+
72
+
73
+ $approved_comments = get_comments('status=approve&number=' . $num_approved_comments);
74
  foreach ($approved_comments as &$comment) {
75
  $commented_post = get_post($comment->comment_post_ID);
76
  $comment->post_title = $commented_post->post_title;
77
  }
 
 
 
78
  $stats['comments']['approved'] = $approved_comments;
79
+
80
 
81
  $all_posts = get_posts('post_status=publish&numberposts=3&orderby=modified&order=desc');
82
  $stats['publish_count'] = count($all_posts);
83
  $recent_posts = array();
84
+
85
+ foreach ($all_posts as $id => $recent_post) {
86
+ $recent = new stdClass();
87
+ $recent->post_permalink = get_permalink($recent->ID);
88
+ $recent->ID = $recent_post->ID;
89
+ $recent->post_date = $recent_post->post_date;
90
+ $recent->post_title = $recent_post->post_title;
91
+ $recent->post_modified = $recent_post->post_modified;
92
+ $recent->comment_count = $recent_post->comment_count;
93
+ $recent->post_permalink = $recent_post->post_permalink;
94
+
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  $recent_posts[] = $recent;
97
  }
98
  $stats['posts'] = $recent_posts;
112
  $stats['draft_count'] = count($drafts);
113
  $stats['drafts'] = $drafts;
114
 
115
+ if (!function_exists('get_filesystem_method'))
116
+ include_once(ABSPATH . 'wp-admin/includes/file.php');
117
+
118
+ if ((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && (get_filesystem_method(array(), false) != 'direct')) {
119
  $stats['writable'] = false;
120
+ } else
121
+ $stats['writable'] = true;
122
+
123
+ $stats = apply_filters('mmb_stats_filter', $stats);
124
+
125
+ return $stats;
126
+ }
127
+ function get_comments_stats(){
128
+ $num_pending_comments = 3;
129
+ $num_approved_comments = 3;
130
+ $pending_comments = get_comments('status=hold&number=' . $num_pending_comments);
131
+ foreach ($pending_comments as &$comment) {
132
+ $commented_post = get_post($comment->comment_post_ID);
133
+ $comment->post_title = $commented_post->post_title;
134
  }
135
+ $stats['comments']['pending'] = $pending_comments;
136
+
137
+
138
+ $approved_comments = get_comments('status=approve&number=' . $num_approved_comments);
139
+ foreach ($approved_comments as &$comment) {
140
+ $commented_post = get_post($comment->comment_post_ID);
141
+ $comment->post_title = $commented_post->post_title;
142
+ }
143
+ $stats['comments']['approved'] = $approved_comments;
144
+
145
  return $stats;
146
  }
 
147
  function get_initial_stats()
148
  {
149
  global $mmb_plugin_dir;
151
  $stats = array();
152
 
153
  $stats['email'] = get_option('admin_email');
154
+ $stats['no_openssl'] = $this->get_random_signature();
155
  $stats['content_path'] = WP_CONTENT_DIR;
156
  $stats['worker_path'] = $mmb_plugin_dir;
157
  $stats['worker_version'] = MMB_WORKER_VERSION;
158
  $stats['site_title'] = get_bloginfo('name');
159
  $stats['site_tagline'] = get_bloginfo('description');
160
+ $stats['site_url'] = get_bloginfo('home');
161
 
162
+
163
+ if (!function_exists('get_filesystem_method'))
164
+ include_once(ABSPATH . 'wp-admin/includes/file.php');
165
+
166
+ if ((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && (get_filesystem_method(array(), false) != 'direct')) {
167
  $stats['writable'] = false;
168
+ } else
169
+ $stats['writable'] = true;
170
 
171
  return $stats;
172
  }
173
+
174
+
 
 
 
175
  function set_hit_count($fix_count = false)
176
  {
177
+ if ($fix_count || (!is_admin() && !MMB_Stats::detect_bots())) {
 
178
  $date = date('Y-m-d');
179
  $user_hit_count = get_option('user_hit_count');
180
  if (!$user_hit_count) {
183
  } else {
184
  $dated_keys = array_keys($user_hit_count);
185
  $last_visit_date = $dated_keys[count($dated_keys) - 1];
186
+
187
  $days = intval((strtotime($date) - strtotime($last_visit_date)) / 60 / 60 / 24);
188
 
189
+ if ($days > 1) {
 
190
  $date_to_add = date('Y-m-d', strtotime($last_visit_date));
191
 
192
  for ($i = 1; $i < $days; $i++) {
193
  if (count($user_hit_count) > 14) {
194
  $shifted = @array_shift($user_hit_count);
195
  }
196
+
197
  $next_key = strtotime('+1 day', strtotime($date_to_add));
198
  if ($next_key == $date) {
199
  break;
201
  $user_hit_count[$next_key] = 0;
202
  }
203
  }
204
+
205
  }
206
 
207
  if (!isset($user_hit_count[$date])) {
210
  if (!$fix_count)
211
  $user_hit_count[$date] += 1;
212
 
213
+ if (count($user_hit_count) > 14) {
214
  $shifted = @array_shift($user_hit_count);
215
  }
216
 
217
+ update_option('user_hit_count', $user_hit_count);
218
 
219
  }
220
  }
236
  }
237
 
238
  function detect_bots()
239
+ {
240
  $agent = $_SERVER['HTTP_USER_AGENT'];
241
 
242
  if ($agent == '')
theme.class.php DELETED
@@ -1,99 +0,0 @@
1
- <?php
2
-
3
- class MMB_Theme extends MMB_Core
4
- {
5
- function __construct()
6
- {
7
- parent::__construct();
8
- }
9
-
10
-
11
- function upload_theme_by_url($args){
12
-
13
- $this->_escape($args);
14
- $url = $args['url'];
15
-
16
- //return (print_r($args, true));
17
- ob_start();
18
- include_once(ABSPATH . 'wp-admin/includes/file.php');
19
- include_once(ABSPATH . 'wp-admin/includes/theme.php');
20
- include_once(ABSPATH . 'wp-admin/includes/misc.php');
21
- include_once(ABSPATH . 'wp-admin/includes/template.php');
22
- include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
23
- $upgrader = new Theme_Upgrader();
24
- $result = $upgrader->install($url);
25
-
26
- ob_end_clean();
27
-
28
- if(is_wp_error($upgrader->skin->result) || !$upgrader->skin->result){
29
- $error = 'Failed to upload theme. Check your URL.' ;
30
- return array('bool' => false, 'message' => $error) ;
31
-
32
- }else {
33
- $theme = $upgrader->theme_info();
34
- return array('bool' => true, 'message' => 'Theme '.$upgrader->result[destination_name].' successfully installed ');
35
-
36
- }
37
-
38
- }
39
-
40
- function upgrade_all($params){
41
-
42
- $upgradable_themes = $this->_get_upgradable_themes();
43
-
44
- $ready_for_upgrade = array();
45
- if(!empty($upgradable_themes)){
46
- foreach($upgradable_themes as $upgrade ){
47
- $ready_for_upgrade[] = $upgrade['theme_tmp'];
48
- }
49
- }
50
- if(!empty($ready_for_upgrade)){
51
- include_once(ABSPATH . 'wp-admin/includes/file.php');
52
- include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
53
- $upgrader = new Theme_Upgrader(new Bulk_Theme_Upgrader_Skin( compact('title', 'nonce', 'url', 'theme') ));
54
-
55
- $result = $upgrader->bulk_upgrade($ready_for_upgrade);
56
-
57
- $results = array();
58
- if(!empty($result)){
59
- foreach($result as $theme_tmp => $info){
60
- if(is_wp_error($info) || !$info){
61
- $results[$theme_tmp] = '<code title="Please upgrade manually">'.$theme_tmp.'</code> was not upgraded.<br />';
62
- }
63
- else {
64
- $results[$theme_tmp] = '<code>'.$theme_tmp.'</code> succesfully upgraded.<br />';
65
- }
66
- }
67
- return array('upgraded' => implode('', $results));
68
- }
69
- else return array('error' => 'Could not initialize upgrader.');
70
-
71
- }else {
72
- return array('error' => 'No themes available for upgrade.');
73
- }
74
- }
75
-
76
- function _get_upgradable_themes(){
77
-
78
- $all_themes = get_themes();
79
- $upgrade_themes = array();
80
-
81
- $current = $this->mmb_get_transient('update_themes');
82
- foreach ((array)$all_themes as $theme_template => $theme_data){
83
- if(!empty($current->response)){
84
- foreach ($current->response as $current_themes => $theme){
85
- if ($theme_data['Template'] == $current_themes)
86
- {
87
- $current->response[$current_themes]['name'] = $theme_data['Name'];
88
- $current->response[$current_themes]['old_version'] = $theme_data['Version'];
89
- $current->response[$current_themes]['theme_tmp'] = $theme_data['Template'];
90
- $upgrade_themes[] = $current->response[$current_themes];
91
- continue;
92
- }
93
- }
94
- }
95
- }
96
-
97
- return $upgrade_themes;
98
- }
99
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.2
1
+ 3.8.7
wp.class.php DELETED
@@ -1,91 +0,0 @@
1
- <?php
2
-
3
- class MMB_WP 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 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
- }