ManageWP Worker - Version 3.8.2

Version Description

  • New interface
  • SSL security protocol
  • many more
Download this release

Release Info

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

Code changes from version 3.8.6 to 3.8.2

Screenshot-1.png ADDED
Binary file
Screenshot-2.png ADDED
Binary file
Screenshot-3.png ADDED
Binary file
api.php DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
- /*************************************************************
3
- *
4
- * api.php
5
- *
6
- * ManageWP addons api
7
- *
8
- * Copyright (c) 2011 Prelovac Media
9
- * www.prelovac.com
10
- **************************************************************/
11
-
12
- function mmb_add_action($action = false, $callback = false){
13
- if(!$action || !$callback)
14
- return false;
15
-
16
- global $mmb_actions;
17
- mmb_function_exists($callback);
18
-
19
- if(isset($mmb_actions[$action]))
20
- wp_die('Cannot redeclare ManageWP action "'.$action.'".');
21
-
22
- $mmb_actions[$action] = $callback;
23
- }
24
-
25
- function mmb_function_exists($callback){
26
- global $mwp_core;
27
- if(count($callback) === 2){
28
- if( !method_exists ( $callback[0], $callback[1] ) )
29
- wp_die($mwp_core->mwp_dashboard_widget('Information', '', '<p>Class '.get_class($callback[0]).' does not contain <b>"'.$callback[1].'"</b> function</p>', '', '50%'));
30
- }else {
31
- if( !function_exists( $callback ))
32
- wp_die($mwp_core->mwp_dashboard_widget('Information', '', '<p>Function <b>"'.$callback.'"</b> does not exists.</p>', '', '50%'));
33
- }
34
- }
35
-
36
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
backup.class.php CHANGED
@@ -20,8 +20,7 @@ class MMB_Backup extends MMB_Core
20
  $file_path = $upload_dir['basedir'] . $file;
21
  file_put_contents($file_path . '/index.php', '');
22
  if (!file_exists($file_path)) {
23
- if(!mkdir($file_path, 0755, true))
24
- return array('error' => 'Failed to create backup folder.');
25
  }
26
  parent::__construct();
27
  }
@@ -43,12 +42,11 @@ class MMB_Backup extends MMB_Core
43
  $file_path = $upload_dir['basedir'] . $file;
44
 
45
  if (!file_exists($file_path)) {
46
- if(!mkdir($file_path, 0755, true))
47
- return array('error' => 'Failed to create backup folder.');
48
  }
49
 
50
- if (trim($what) == 'full') {
51
- //take wp-content backup
52
  $content_backup = $this->backup_wpcontent($type);
53
  if (!$content_backup) {
54
  @unlink($content_backup['path']);
@@ -59,7 +57,7 @@ class MMB_Backup extends MMB_Core
59
  }
60
 
61
  if (trim($what) == 'full' || trim($what) == 'db') {
62
- //take database backup
63
  $db_backup = $this->backup_db($type);
64
  if (!$db_backup) {
65
  if (trim($what) == 'full')
@@ -72,9 +70,9 @@ class MMB_Backup extends MMB_Core
72
  }
73
  }
74
 
75
- include_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
76
 
77
- // Get previous backup in tmp
78
  $worker_options = get_option('mmb-worker');
79
  $tmp_file = $upload_dir['basedir'] . '/' . basename($worker_options['backups'][$type]['path']);
80
 
@@ -82,7 +80,6 @@ class MMB_Backup extends MMB_Core
82
  @unlink($worker_options['backups'][$type]['path']);
83
  }
84
 
85
- //Prepare .zip file name
86
  $site_name = $this->remove_http(get_bloginfo('url'));
87
  $site_name = str_replace(array(
88
  "_",
@@ -100,16 +97,10 @@ class MMB_Backup extends MMB_Core
100
  if (trim($what) == 'full') {
101
  $htaccess_path = ABSPATH . ".htaccess";
102
  $wp_config_path = ABSPATH . "wp-config.php";
103
- if ($this->check_zip() && ($func = $this->check_sys())) {
104
  $command = "zip $backup_file -j $content_backup[path] -j $db_backup[path] -j $htaccess_path -j $wp_config_path";
105
- ob_start();
106
- switch($func)
107
- {
108
- case 'passthru': passthru($command, $err); break;
109
- case 'exec': exec($command); break;
110
- case 'system': system($command); break;
111
- default: break;
112
- }
113
  ob_get_clean();
114
  } else {
115
  $result = $archive->add($content_backup['path'], PCLZIP_OPT_REMOVE_ALL_PATH);
@@ -120,21 +111,25 @@ class MMB_Backup extends MMB_Core
120
  }
121
 
122
  } elseif (trim($what) == 'db') {
123
- if ($this->check_zip() && ($func = $this->check_sys())) {
124
  $command = "zip $backup_file -j $db_backup[path]";
125
- ob_start();
126
- switch($func)
127
- {
128
- case 'passthru': passthru($command, $err); break;
129
- case 'exec': exec($command); break;
130
- case 'system': system($command); break;
131
- default: break;
132
- }
133
  ob_get_clean();
134
  } else {
135
  $result = $archive->add($db_backup['path'], PCLZIP_OPT_REMOVE_ALL_PATH);
136
  $err = !$result;
137
  }
 
 
 
 
 
 
 
 
 
 
138
  }
139
 
140
  if ($err) {
@@ -142,7 +137,7 @@ class MMB_Backup extends MMB_Core
142
  @unlink($tmp_file);
143
  }
144
  return array(
145
- 'error' => 'Backup failed. Cannot create backup zip file.'
146
  );
147
  }
148
 
@@ -160,7 +155,7 @@ class MMB_Backup extends MMB_Core
160
  $worker_options['backups'][$type]['url'] = $backup_url;
161
  update_option('mmb-worker', $worker_options);
162
 
163
- //Everything went fine, return backup url to master
164
  return $worker_options['backups'][$type]['url'];
165
  }
166
 
@@ -170,17 +165,11 @@ class MMB_Backup extends MMB_Core
170
  $sec_string = md5('mmb-worker');
171
  $file = '/' . $sec_string . '/backups/wp-content_' . date('Y-m-d') . '.zip';
172
  $file_path = $upload_dir['basedir'] . $file;
173
- if ($this->check_zip() && ($func = $this->check_sys())) {
174
  chdir(WP_CONTENT_DIR);
175
  $command = "zip -r $file_path 'plugins/' 'themes/' 'uploads/' -x 'uploads/" . $sec_string . "/*'";
176
- ob_start();
177
- switch($func)
178
- {
179
- case 'passthru': passthru($command, $err); break;
180
- case 'exec': exec($command); break;
181
- case 'system': system($command); break;
182
- default: break;
183
- }
184
  ob_get_clean();
185
  if (!$err || $err == 18) {
186
  $file_url = $upload_dir['baseurl'] . $file;
@@ -198,7 +187,7 @@ class MMB_Backup extends MMB_Core
198
  $result = $archive->add(WP_CONTENT_DIR . '/plugins', PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR);
199
  $result = $archive->add(WP_CONTENT_DIR . '/themes', PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR);
200
  $result = $archive->add(WP_CONTENT_DIR . '/uploads', PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR);
201
-
202
  $result = $archive->delete(PCLZIP_OPT_BY_NAME, 'uploads/' . $sec_string . '/');
203
  if ($result) {
204
  $file_url = $upload_dir['baseurl'] . $file;
@@ -216,8 +205,11 @@ class MMB_Backup extends MMB_Core
216
  function backup_db($type)
217
  {
218
  $mysqldump_exists = $this->check_mysqldump();
219
- if (is_array($mysqldump_exists) && $this->check_sys()) {
220
-
 
 
 
221
  $result = $this->backup_db_dump($type, $mysqldump_exists);
222
 
223
  } else {
@@ -238,16 +230,9 @@ class MMB_Backup extends MMB_Core
238
  $file_url = $upload_dir['baseurl'] . '/' . DB_NAME . '.sql';
239
 
240
  $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;
241
- ob_start();
242
- $func = $this->check_sys();
243
- switch($func)
244
- {
245
- case 'passthru': passthru($command, $error); break;
246
- case 'exec': exec($command); break;
247
- case 'system': system($command); break;
248
- default: break;
249
- }
250
- ob_get_clean();
251
 
252
  if ($error) {
253
  $result = $this->backup_db_php($type);
@@ -346,8 +331,7 @@ class MMB_Backup extends MMB_Core
346
  // If manual backup - get backup file from master, if not - get backup file from worker
347
  if ($type != 'weekly' && $type != 'daily') {
348
  // Download backup file from master
349
- include_once(ABSPATH . 'wp-admin/includes/file.php');
350
- $tmp_file = download_url($type);
351
  $backup_file = $backup_path . "/" . basename($type);
352
  if (rename($tmp_file, $backup_file)) {
353
  @unlink($tmp_file);
@@ -362,24 +346,13 @@ class MMB_Backup extends MMB_Core
362
 
363
 
364
  if ($backup_file) {
365
- if ($this->check_unzip() && ($func = $this->check_sys())) {
366
-
367
- if(!mkdir($file_path))
368
- return array('error' => 'Failed to create restore folder.');
369
-
370
  chdir($file_path);
371
  $command = "unzip -o $backup_file";
372
  ob_start();
373
-
374
- switch($func)
375
- {
376
- case 'passthru': passthru($command, $err); break;
377
- case 'exec': exec($command); break;
378
- case 'system': system($command); break;
379
- default: break;
380
- }
381
- ob_get_clean();
382
-
383
  } else {
384
  require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
385
  $archive = new PclZip($backup_file);
@@ -387,6 +360,7 @@ class MMB_Backup extends MMB_Core
387
  $err = !$extracted;
388
  }
389
 
 
390
  if ($err) {
391
  return array(
392
  'error' => 'Error extracting backup file.'
@@ -403,7 +377,9 @@ class MMB_Backup extends MMB_Core
403
  }
404
  }
405
 
406
- if (trim($what) == 'full') {
 
 
407
  if (!$this->restore_wpcontent($type, $file_path)) {
408
  return array(
409
  'error' => 'Error restoring wp-content.'
@@ -411,13 +387,7 @@ class MMB_Backup extends MMB_Core
411
  }
412
  }
413
 
414
- $this->delete_temp_dir($file_path);
415
- }
416
- else
417
- {
418
- return array(
419
- 'error' => 'Error restoring. Cannot find backup file.'
420
- );
421
  }
422
 
423
  return true;
@@ -429,31 +399,27 @@ class MMB_Backup extends MMB_Core
429
  $content_file = glob($file_path . "/*.zip");
430
  $wp_config_file = glob($file_path . "/wp-config.php");
431
  $htaccess_file = glob($file_path . "/.htaccess");
432
- if ($this->check_unzip() && ($func = $this->check_sys())) {
433
-
434
  chdir(WP_CONTENT_DIR);
435
  $con_file = $content_file[0];
436
  $command = "unzip -o $con_file";
437
- ob_start();
438
- switch($func)
439
- {
440
- case 'passthru': passthru($command, $err); break;
441
- case 'exec': exec($command); break;
442
- case 'system': system($command); break;
443
- default: break;
444
- }
445
- ob_get_clean();
446
  } else {
447
  $archive = new PclZip($content_file[0]);
448
  $restore_content = $archive->extract(PCLZIP_OPT_PATH, WP_CONTENT_DIR, PCLZIP_OPT_REPLACE_NEWER);
449
  $err = !$restore_content;
450
  }
451
 
452
- @rename($wp_config_file[0], ABSPATH . "wp-config.php");
453
- @rename($htaccess_file[0], ABSPATH . ".htaccess");
 
 
 
454
  @unlink($wp_config_file[0]);
455
  @unlink($htaccess_file[0]);
456
-
457
  if ($err)
458
  return false;
459
  else
@@ -466,20 +432,13 @@ class MMB_Backup extends MMB_Core
466
 
467
  $mysqldump = $this->check_mysqldump();
468
 
469
- if (is_array($mysqldump) && ($func = $this->check_sys())) {
470
  $brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
471
 
472
  foreach (glob($file_path . '/*.sql') as $filename) {
473
  $command = $brace . $mysqldump['mysql'] . $brace . ' --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" ' . DB_NAME . ' < ' . $brace . $filename . $brace;
474
- ob_start();
475
- switch($func)
476
- {
477
- case 'passthru': passthru($command, $error); break;
478
- case 'exec': exec($command); break;
479
- case 'system': system($command); break;
480
- default: break;
481
- }
482
- ob_get_clean();
483
  break;
484
  }
485
 
@@ -542,17 +501,23 @@ class MMB_Backup extends MMB_Core
542
  }
543
  }
544
 
545
- function optimize_tables()
 
546
  {
547
- global $wpdb;
548
- $tables = $wpdb->get_col("SHOW TABLES");
549
-
550
- foreach ($tables as $table_name) {
551
- $table_string .= $table_name . ",";
552
  }
553
- $table_string = rtrim($table_string);
554
- $optimize = $wpdb->query("OPTIMIZE TABLE $table_string");
555
- return $optimize ? true : false;
 
 
 
 
 
556
  }
557
 
558
  ### Function: Auto Detect MYSQL and MYSQL Dump Paths
@@ -590,28 +555,27 @@ class MMB_Backup extends MMB_Core
590
  return false;
591
  }
592
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
593
  return $paths;
594
  }
595
 
596
- //Check if passthru, system or exec functions exist
597
- function check_sys()
598
- {
599
-
600
- if (function_exists('passthru'))
601
- return 'passthru';
602
-
603
- if (function_exists('system'))
604
- return 'system';
605
-
606
- if (function_exists('exec'))
607
- return 'exec';
608
-
609
- return false;
610
-
611
- }
612
-
613
  function check_zip()
614
- {
615
  $zip = @exec('which zip');
616
  return $zip ? true : false;
617
  }
@@ -622,5 +586,33 @@ class MMB_Backup extends MMB_Core
622
  return $zip ? true : false;
623
  }
624
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
625
  }
626
- ?>
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
  $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
  }
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
  }
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
  @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
  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
  }
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
  @unlink($tmp_file);
138
  }
139
  return array(
140
+ 'error' => 'Backup failed.'
141
  );
142
  }
143
 
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
  $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
  $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;
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
  $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
  // 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
 
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
  $err = !$extracted;
361
  }
362
 
363
+
364
  if ($err) {
365
  return array(
366
  'error' => 'Error extracting backup file.'
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
  }
388
  }
389
 
390
+ $this->_deleteTempDir($file_path);
 
 
 
 
 
 
391
  }
392
 
393
  return true;
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]);
411
  $restore_content = $archive->extract(PCLZIP_OPT_PATH, WP_CONTENT_DIR, PCLZIP_OPT_REPLACE_NEWER);
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
+
423
  if ($err)
424
  return false;
425
  else
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
  }
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
  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()
578
+ {
579
  $zip = @exec('which zip');
580
  return $zip ? true : false;
581
  }
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
+ ?>
core.class.php CHANGED
@@ -1,14 +1,5 @@
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,67 +12,35 @@ class MMB_Core extends MMB_Helper
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
- echo '<div class="error" style="text-align: center;"><p style="color: red; font-size: 14px; font-weight: bold;">Attention !</p><p>
76
- You activated the ManageWP worker plugin but have not yet added this site to your account. Please add the site to ManageWP now or deactivate the plugin. <a target="_blank" href="http://managewp.com/user-guide#security">More info</a>
77
- </p></div>';
78
- }
79
-
80
  /**
81
- * Add an item into the Right Now Dashboard widget
82
- * to inform that the blog can be managed remotely
83
- *
84
- */
85
  function add_right_now_info()
86
  {
87
  echo '<div class="mmb-slave-info">
@@ -90,12 +49,13 @@ class MMB_Core extends MMB_Helper
90
  }
91
 
92
  /**
93
- * Gets an instance of the Comment class
94
- *
95
- */
96
  function get_comment_instance()
97
  {
98
- if (!isset($this->comment_instance)) {
 
99
  $this->comment_instance = new MMB_Comment();
100
  }
101
 
@@ -103,12 +63,13 @@ class MMB_Core extends MMB_Helper
103
  }
104
 
105
  /**
106
- * Gets an instance of the Plugin class
107
- *
108
- */
109
  function get_plugin_instance()
110
  {
111
- if (!isset($this->plugin_instance)) {
 
112
  $this->plugin_instance = new MMB_Plugin();
113
  }
114
 
@@ -116,12 +77,13 @@ class MMB_Core extends MMB_Helper
116
  }
117
 
118
  /**
119
- * Gets an instance of the Theme class
120
- *
121
- */
122
  function get_theme_instance()
123
  {
124
- if (!isset($this->theme_instance)) {
 
125
  $this->theme_instance = new MMB_Theme();
126
  }
127
 
@@ -130,12 +92,13 @@ class MMB_Core extends MMB_Helper
130
 
131
 
132
  /**
133
- * Gets an instance of MMB_Post class
134
- *
135
- */
136
  function get_post_instance()
137
  {
138
- if (!isset($this->post_instance)) {
 
139
  $this->post_instance = new MMB_Post();
140
  }
141
 
@@ -143,27 +106,29 @@ class MMB_Core extends MMB_Helper
143
  }
144
 
145
  /**
146
- * Gets an instance of Blogroll class
147
- *
148
- */
149
  function get_blogroll_instance()
150
  {
151
- if (!isset($this->blogroll_instance)) {
 
152
  $this->blogroll_instance = new MMB_Blogroll();
153
  }
154
 
155
  return $this->blogroll_instance;
156
  }
157
-
158
-
159
 
160
  /**
161
- * Gets an instance of the WP class
162
- *
163
- */
164
  function get_wp_instance()
165
  {
166
- if (!isset($this->wp_instance)) {
 
167
  $this->wp_instance = new MMB_WP();
168
  }
169
 
@@ -171,12 +136,13 @@ class MMB_Core extends MMB_Helper
171
  }
172
 
173
  /**
174
- * Gets an instance of User
175
- *
176
- */
177
  function get_user_instance()
178
  {
179
- if (!isset($this->user_instance)) {
 
180
  $this->user_instance = new MMB_User();
181
  }
182
 
@@ -184,183 +150,155 @@ class MMB_Core extends MMB_Helper
184
  }
185
 
186
  /**
187
- * Gets an instance of stats class
188
- *
189
- */
190
  function get_stats_instance()
191
  {
192
- if (!isset($this->stats_instance)) {
 
193
  $this->stats_instance = new MMB_Stats();
194
  }
195
  return $this->stats_instance;
196
  }
 
197
  /**
198
- * Gets an instance of search class
199
- *
200
- */
201
- function get_search_instance()
202
- {
203
- if (!isset($this->search_instance)) {
204
- $this->search_instance = new MMB_Search();
205
- }
206
- //return $this->search_instance;
207
- return $this->search_instance;
208
- }
209
- /**
210
- * Gets an instance of stats class
211
- *
212
- */
213
  function get_backup_instance()
214
  {
215
- if (!isset($this->backup_instance)) {
 
216
  $this->backup_instance = new MMB_Backup();
217
  }
218
-
219
  return $this->backup_instance;
220
  }
221
-
222
- function get_installer_instance()
223
- {
224
- if (!isset($this->installer_instance)) {
225
- $this->installer_instance = new MMB_Installer();
226
- }
227
- return $this->installer_instance;
228
- }
229
 
230
  /**
231
- * Plugin install callback function
232
- * Check PHP version
233
- */
234
  function install()
235
- {
236
- if (PHP_VERSION < 5) // min version 5 supported
237
- exit("<p>Plugin could not be activated. Your PHP version must be 5.0 or higher.</p>");
238
-
239
- // delete plugin options, just in case
240
- delete_option('_worker_nossl_key');
241
- delete_option('_worker_public_key');
242
- delete_option('_action_message_id');
243
-
244
  }
245
 
246
  /**
247
- * Saves the (modified) options into the database
248
- *
249
- */
250
- function save_options()
251
  {
252
- if (get_option($this->slug)) {
 
253
  update_option($this->slug, $this->settings);
254
- } else {
 
 
255
  add_option($this->slug, $this->settings);
256
  }
257
  }
258
 
259
  /**
260
- * Deletes options for communication with master
261
- *
262
- */
263
- function uninstall()
264
- {
265
- delete_option('_worker_nossl_key');
266
- delete_option('_worker_public_key');
267
- delete_option('_action_message_id');
268
- }
269
-
270
  /**
271
- * Constructs a url (for ajax purpose)
272
- *
273
- * @param mixed $base_page
274
- */
275
- function construct_url($params = array(), $base_page = 'index.php')
276
  {
277
  $url = "$base_page?_wpnonce=" . wp_create_nonce($this->slug);
278
- foreach ($params as $key => $value) {
 
279
  $url .= "&$key=$value";
280
  }
281
 
282
  return $url;
283
  }
284
-
285
- /**
286
- * Worker update
287
- *
288
- */
289
- function update_worker_plugin($params)
290
- {
291
- extract($params);
292
- if ($download_url) {
293
- include_once ABSPATH . 'wp-admin/includes/file.php';
294
- include_once ABSPATH . 'wp-admin/includes/misc.php';
295
- include_once ABSPATH . 'wp-admin/includes/template.php';
296
- include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
297
-
298
- if ((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && (get_filesystem_method(array(), false) != 'direct'))
299
- {
300
- return array(
301
- 'error' => 'Failed, please <a target="_blank" href="http://managewp.com/user-guide#ftp">add FTP details for automatic upgrades.</a></a>'
302
- );
303
- }
304
-
305
- ob_start();
306
- @unlink(dirname(__FILE__));
307
- $upgrader = new Plugin_Upgrader();
308
- $result = $upgrader->run(array(
309
- 'package' => $download_url,
310
- 'destination' => WP_PLUGIN_DIR,
311
- 'clear_destination' => true,
312
- 'clear_working' => true,
313
- 'hook_extra' => array(
314
- 'plugin' => 'worker/init.php'
315
- )
316
- ));
317
- ob_end_clean();
318
- if (is_wp_error($result) || !$result) {
319
- return array(
320
- 'error' => 'ManageWP Worker could not been upgraded.'
321
- );
322
- } else {
323
- return array(
324
- 'success' => 'ManageWP Worker plugin successfully upgraded.'
325
- );
326
- }
327
- }
328
- return array(
329
- 'error' => 'Bad download path for worker installation file.'
330
- );
331
- }
332
-
333
  /**
334
- * Automatically logs in when called from Master
335
- *
336
- */
337
- function automatic_login()
338
- {
339
- $where = ($_GET['mwp_goto']);
340
-
341
- if (!is_user_logged_in() && $_GET['auto_login']) {
342
- $signature = base64_decode($_GET['signature']);
343
- $message_id = trim($_GET['message_id']);
344
- $username = $_GET['username'];
345
-
346
- $auth = $this->authenticate_message($where . $message_id, $signature, $message_id);
347
- if ($auth === true) {
348
- $user = get_user_by('login', $username);
349
- $user_id = $user->ID;
350
- wp_set_current_user($user_id, $username);
351
- wp_set_auth_cookie($user_id);
352
- do_action('wp_login', $username);
353
- } else {
354
- wp_die($auth['error']);
355
- }
356
- }
357
-
358
- if ($_GET['auto_login']) {
359
- wp_redirect(get_bloginfo('url') . "/wp-admin/" . $where);
360
- exit();
361
- }
362
- }
363
-
364
-
365
- }
366
- ?>
 
1
  <?php
2
+
 
 
 
 
 
 
 
 
 
3
  class MMB_Core extends MMB_Helper
4
  {
5
  var $name;
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
  }
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
  }
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
  }
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
 
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
  }
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
  }
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
  }
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
+ }
helper.class.php CHANGED
@@ -3,7 +3,7 @@
3
  *
4
  * helper.class.php
5
  *
6
- * Utility functions
7
  *
8
  *
9
  * Copyright (c) 2011 Prelovac Media
@@ -31,7 +31,31 @@ class MMB_Helper
31
  fwrite($handle, $mixed . PHP_EOL);
32
  fclose($handle);
33
  }
34
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  function _escape(&$array)
36
  {
37
  global $wpdb;
@@ -51,11 +75,34 @@ class MMB_Helper
51
  }
52
  }
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  /**
55
  * Initializes the file system
56
  *
57
  */
58
- function init_filesystem()
59
  {
60
  global $wp_filesystem;
61
 
@@ -77,29 +124,31 @@ class MMB_Helper
77
  * @return mixed
78
  */
79
  function mmb_get_transient($option_name)
80
- {
81
- if (trim($option_name) == '') {
82
  return FALSE;
83
  }
84
 
85
  global $wp_version, $_wp_using_ext_object_cache;
86
 
87
- if (version_compare($wp_version, '2.8.0', '<')) {
88
- return get_option($option_name);
89
- } else if (version_compare($wp_version, '3.0.0', '<')) {
90
- if (get_transient($option_name))
91
- return get_transient($option_name);
92
- else
93
- return get_option('_transient_' . $option_name);
94
- } else {
95
- if (get_site_transient($option_name))
96
- return get_site_transient($option_name);
97
- else
98
- return get_option('_site_transient_' . $option_name);
99
  }
100
- }
101
-
102
- function mmb_delete_transient($option_name)
 
 
 
 
 
 
 
 
 
 
 
 
103
  {
104
  if (trim($option_name) == '') {
105
  return FALSE;
@@ -107,26 +156,40 @@ class MMB_Helper
107
 
108
  global $wp_version;
109
 
110
- if (version_compare($wp_version, '2.8.0', '<')) {
111
- delete_option($option_name);
112
- } else if (version_compare($wp_version, '3.0.0', '<')) {
113
- if (delete_transient($option_name))
114
- delete_transient($option_name);
115
- else
116
- delete_option('_transient_' . $option_name);
117
- } else {
118
- if (delete_site_transient($option_name))
119
- delete_site_transient($option_name);
120
- else
121
- delete_option('_site_transient_' . $option_name);
122
  }
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
124
-
125
- function 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,7 +202,7 @@ class MMB_Helper
139
  $path = $directory . "/" . $contents;
140
 
141
  if (is_dir($path)) {
142
- $this->delete_temp_dir($path);
143
  } else {
144
  unlink($path);
145
  }
@@ -151,7 +214,15 @@ class MMB_Helper
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,12 +231,12 @@ class MMB_Helper
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,32 +245,35 @@ class MMB_Helper
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,53 +281,51 @@ class MMB_Helper
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,12 +333,12 @@ class MMB_Helper
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,26 +355,26 @@ class MMB_Helper
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
  ?>
3
  *
4
  * helper.class.php
5
  *
6
+ * Various utility functions
7
  *
8
  *
9
  * Copyright (c) 2011 Prelovac Media
31
  fwrite($handle, $mixed . PHP_EOL);
32
  fclose($handle);
33
  }
34
+
35
+ /**
36
+ * Strips WP disallowed HTML and PHP tags from a string
37
+ *
38
+ * @param mixed $str
39
+ * @return string
40
+ */
41
+ function _strip_tags($str)
42
+ {
43
+ return strip_tags($str, '<address><a><abbr><acronym><area><b><big><blockquote><br><caption><cite><class><code><col><del><dd><div><dl><dt><em><font><h1><h2><h3><h4><h5><h6><hr><i><img><ins><kbd><li><map><ol><p><pre><q><s><span><strike><strong><sub><sup><table><tbody><td><tfoot><tr><tt><ul><var>');
44
+ }
45
+
46
+ /**
47
+ * Filters a WordPress content (being comments, pages, posts etc)
48
+ *
49
+ * @param mixed $str
50
+ * @return string
51
+ */
52
+ function _filter_content($str)
53
+ {
54
+ return nl2br($this->_strip_tags($str));
55
+ }
56
+
57
+
58
+
59
  function _escape(&$array)
60
  {
61
  global $wpdb;
75
  }
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
  * @return mixed
125
  */
126
  function mmb_get_transient($option_name)
127
+ {
128
+ if (trim($option_name) == '') {
129
  return FALSE;
130
  }
131
 
132
  global $wp_version, $_wp_using_ext_object_cache;
133
 
134
+ if (version_compare($wp_version, '2.8.0', '<')){
135
+ return get_option($option_name);
 
 
 
 
 
 
 
 
 
 
136
  }
137
+ else if (version_compare($wp_version, '3.0.0', '<')){
138
+ if(get_transient($option_name))
139
+ return get_transient($option_name);
140
+ else
141
+ return get_option('_transient_'.$option_name);
142
+ }
143
+ else {
144
+ if(get_site_transient($option_name))
145
+ return get_site_transient($option_name);
146
+ else
147
+ return get_option('_site_transient_'.$option_name);
148
+ }
149
+ }
150
+
151
+ function mmb_delete_transient($option_name)
152
  {
153
  if (trim($option_name) == '') {
154
  return FALSE;
156
 
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
  $path = $directory . "/" . $contents;
203
 
204
  if (is_dir($path)) {
205
+ $this->_deleteTempDir($path);
206
  } else {
207
  unlink($path);
208
  }
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
  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
  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
  );
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
  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
 
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
  ?>
index.html DELETED
File without changes
init.php CHANGED
@@ -4,46 +4,23 @@ 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.6
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.6');
24
 
25
  global $wpdb, $mmb_plugin_dir, $mmb_plugin_url;
26
 
27
  $mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
28
  $mmb_plugin_url = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
29
 
30
- $mmb_actions = array(
31
- 'remove_site' => 'mmb_remove_site',
32
- 'get_stats' => 'mmb_stats_get',
33
- 'backup' => 'mmb_backup_now',
34
- 'restore' => 'mmb_restore_now',
35
- 'optimize_tables' => 'mmb_optimize_tables',
36
- 'check_wp_version' => 'mmb_wp_checkversion',
37
- 'create_post' => 'mmb_post_create',
38
- 'upgrade_plugins' => 'mmb_upgrade_plugins',
39
- 'wp_upgrade' => 'mmb_upgrade_wp',
40
- 'upgrade_themes' => 'mmb_themes_upgrade',
41
- 'upload_plugin_by_url' => 'mmb_plugin_upload_by_url',
42
- 'upload_theme_by_url' => 'mmb_theme_upload_by_url',
43
- 'update_worker' => 'mmb_update_worker_plugin',
44
- 'install_addon' => 'mmb_install_addon'
45
- );
46
-
47
  require_once("$mmb_plugin_dir/helper.class.php");
48
  require_once("$mmb_plugin_dir/core.class.php");
49
  require_once("$mmb_plugin_dir/plugin.class.php");
@@ -51,69 +28,67 @@ require_once("$mmb_plugin_dir/theme.class.php");
51
  require_once("$mmb_plugin_dir/wp.class.php");
52
  require_once("$mmb_plugin_dir/post.class.php");
53
  require_once("$mmb_plugin_dir/stats.class.php");
 
54
  require_once("$mmb_plugin_dir/backup.class.php");
55
- require_once("$mmb_plugin_dir/installer.class.php");
56
- require_once("$mmb_plugin_dir/api.php");
57
-
58
-
59
- require_once("$mmb_plugin_dir/plugins/search/search.php");
60
- require_once("$mmb_plugin_dir/plugins/cleanup/cleanup.php");
61
-
62
- //this is an exmaple plugin for extra_html element
63
- //require_once("$mmb_plugin_dir/plugins/extra_html_example/extra_html_example.php");
64
 
65
  $mmb_core = new MMB_Core();
66
- add_action('init', 'mmb_parse_request');
67
 
68
  if (function_exists('register_activation_hook'))
69
- register_activation_hook(__FILE__, array(
70
- $mmb_core,
71
- 'install'
72
- ));
73
 
74
  if (function_exists('register_deactivation_hook'))
75
- register_deactivation_hook(__FILE__, array(
76
- $mmb_core,
77
- 'uninstall'
78
- ));
79
-
80
-
81
 
82
- function mmb_parse_request()
83
  {
84
  if (!isset($HTTP_RAW_POST_DATA)) {
85
  $HTTP_RAW_POST_DATA = file_get_contents('php://input');
86
  }
87
  ob_start();
88
-
89
- global $mmb_core, $mmb_actions, $new_actions;
90
-
91
- $data = base64_decode($HTTP_RAW_POST_DATA);
92
- if ($data)
93
- $num = @extract(unserialize($data));
94
 
95
  if ($action) {
96
- // mmb_response($mmb_actions, false);
97
- if (!$mmb_core->check_if_user_exists($params['username']))
98
- mmb_response('Username <b>' . $params['username'] . '</b> does not have administrator capabilities. Enter the correct username in the site options.', false);
99
 
100
- if ($action == 'add_site') {
101
- mmb_add_site($params);
102
- mmb_response('You should never see this.', false);
103
  }
104
 
105
- $auth = $mmb_core->authenticate_message($action . $id, $signature, $id);
106
- if ($auth === true) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  if (array_key_exists($action, $mmb_actions) && function_exists($mmb_actions[$action]))
108
  call_user_func($mmb_actions[$action], $params);
109
  else
110
  mmb_response('Action "' . $action . '" does not exist.', false);
111
- } else {
 
 
112
  mmb_response($auth['error'], false);
113
  }
114
  }
115
-
116
-
117
  ob_end_clean();
118
  }
119
 
@@ -124,14 +99,14 @@ function mmb_response($response = false, $success = true)
124
  $return = array();
125
 
126
  if (empty($response))
127
- $return['error'] = 'Empty response.';
128
  else if ($success)
129
  $return['success'] = $response;
130
  else
131
  $return['error'] = $response;
132
 
133
  header('Content-Type: text/plain');
134
- exit(PHP_EOL . base64_encode(serialize($return)));
135
  }
136
 
137
  function mmb_add_site($params)
@@ -139,35 +114,35 @@ function mmb_add_site($params)
139
  global $mmb_core;
140
 
141
  $num = extract($params);
142
-
143
  if ($num) {
144
- if (!get_option('_action_message_id') && !get_option('_worker_public_key')) {
145
- $public_key = base64_decode($public_key);
146
-
147
- if (function_exists('openssl_verify')) {
148
- $verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
149
- if ($verify == 1) {
150
- $mmb_core->set_master_public_key($public_key);
151
- $mmb_core->set_worker_message_id( $id);
152
-
153
- mmb_response($mmb_core->get_stats_instance()->get_initial_stats(), true);
154
- } else if ($verify == 0) {
155
- mmb_response('Invalid message signature. Please contact us if you see this message often.', false);
156
- } else {
157
- mmb_response('Command not successful. Please try again.', false);
158
- }
159
- } else {
160
- if (!get_option('_worker_nossl_key')) {
161
- srand();
162
- $random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
163
-
164
- $mmb_core->set_random_signature($random_key);
165
- $mmb_core->set_worker_message_id( $id);
166
- $mmb_core->set_master_public_key($public_key);
167
- mmb_response($mmb_core->get_stats_instance()->get_initial_stats(), true);
168
- } else
169
- mmb_response('Please deactivate & activate ManageWP Worker plugin on your site, then re-add the site to your dashboard.', false);
170
- }
171
  } else {
172
  mmb_response('Please deactivate & activate ManageWP Worker plugin on your site and re-add the site to your dashboard.', false);
173
  }
@@ -177,34 +152,30 @@ function mmb_add_site($params)
177
  }
178
 
179
  function mmb_remove_site($params)
180
- {
181
- extract($params);
182
  global $mmb_core;
183
  $mmb_core->uninstall();
184
-
185
- include_once(ABSPATH . 'wp-admin/includes/plugin.php');
186
- $plugin_slug = basename(dirname(__FILE__)) . '/' . basename(__FILE__);
187
-
188
- if ($deactivate) {
189
- deactivate_plugins($plugin_slug, true);
190
- }
191
-
192
- if (!is_plugin_active($plugin_slug))
193
- mmb_response(array(
194
- 'deactivated' => 'Site removed successfully. <br /><br />ManageWP Worker plugin successfully deactivated.'
195
- ), true);
196
- else
197
- mmb_response(array(
198
- 'removed_data' => 'Site removed successfully. <br /><br /><b>ManageWP Worker plugin was not deactivated.</b>'
199
- ), true);
200
 
201
  }
202
 
203
 
204
  function mmb_stats_get($params)
205
- {
206
- global $mmb_core;
207
- mmb_response($mmb_core->get_stats_instance()->get($params), true);
208
  }
209
 
210
 
@@ -220,9 +191,9 @@ function mmb_plugin_upload_by_url($params)
220
  {
221
  global $mmb_core;
222
  $return = $mmb_core->get_plugin_instance()->upload_by_url($params);
 
223
 
224
-
225
- mmb_response($return['message'], $return['bool']);
226
 
227
  }
228
 
@@ -231,7 +202,7 @@ function mmb_theme_upload_by_url($params)
231
  {
232
  global $mmb_core;
233
  $return = $mmb_core->get_theme_instance()->upload_theme_by_url($params);
234
- mmb_response($return['message'], $return['bool']);
235
  }
236
 
237
  function mmb_themes_upgrade($params)
@@ -246,7 +217,7 @@ function mmb_themes_upgrade($params)
246
  function mmb_upgrade_wp($params)
247
  {
248
  global $mmb_core;
249
- mmb_response($mmb_core->get_wp_instance()->upgrade());
250
  }
251
 
252
  //post
@@ -264,14 +235,15 @@ function mmb_post_create($params)
264
  function mmb_backup_now($params)
265
  {
266
  global $mmb_core;
267
-
268
  $return = $mmb_core->get_backup_instance()->backup($params);
269
 
270
  if (is_array($return) && array_key_exists('error', $return))
271
  mmb_response($return['error'], false);
272
  else {
 
273
  mmb_response($return, true);
274
- }
 
275
  }
276
 
277
  function mmb_optimize_tables($params)
@@ -300,32 +272,4 @@ function mmb_update_worker_plugin($params)
300
  global $mmb_core;
301
  mmb_response($mmb_core->update_worker_plugin($params), true);
302
  }
303
-
304
- function mmb_wp_checkversion($params)
305
- {
306
- include_once(ABSPATH . 'wp-includes/version.php');
307
- global $wp_version,$mmb_core;
308
- mmb_response($wp_version,true);
309
- }
310
-
311
- function mmb_search_posts_by_term($params)
312
- {
313
-
314
- global $mmb_core;
315
- $return = $mmb_core->get_search_instance()->search_posts_by_term($params);
316
-
317
- if($return){
318
- mmb_response(serialize($return),true);
319
- }else{
320
- mmb_response('No posts for term',false);
321
- }
322
- }
323
-
324
- function mmb_install_addon($params)
325
- {
326
- global $mmb_core;
327
- $return = $mmb_core->get_installer_instance()->install_remote_file($params);
328
- mmb_response($return,true);
329
-
330
- }
331
  ?>
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");
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
  $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
  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
  }
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
 
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
 
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)
217
  function mmb_upgrade_wp($params)
218
  {
219
  global $mmb_core;
220
+ mmb_response($mmb_core->get_wp_instance()->upgrade());
221
  }
222
 
223
  //post
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
  global $mmb_core;
273
  mmb_response($mmb_core->update_worker_plugin($params), true);
274
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  ?>
installer.class.php DELETED
@@ -1,162 +0,0 @@
1
- <?php
2
- /*************************************************************
3
- *
4
- * installer.class.php
5
- *
6
- * Upgrade WordPress
7
- *
8
- *
9
- * Copyright (c) 2011 Prelovac Media
10
- * www.prelovac.com
11
- **************************************************************/
12
-
13
- include_once(ABSPATH . 'wp-admin/includes/file.php');
14
- include_once(ABSPATH . 'wp-admin/includes/plugin.php');
15
- include_once(ABSPATH . 'wp-admin/includes/theme.php');
16
- include_once(ABSPATH . 'wp-admin/includes/misc.php');
17
- include_once(ABSPATH . 'wp-admin/includes/template.php');
18
- include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
19
- if(!$wp_filesystem){
20
- WP_Filesystem();
21
- }
22
- class MMB_Installer extends MMB_Core
23
- {
24
- function __construct()
25
- {
26
- @set_time_limit( 300 );
27
- parent::__construct();
28
- }
29
-
30
- function mmb_maintenance_mode($enable = false, $maintenance_message = '') {
31
- global $wp_filesystem;
32
-
33
- $maintenance_message .= '<?php $upgrading = ' . time() . '; ?>';
34
-
35
- $file = $wp_filesystem->abspath() . '.maintenance';
36
- if($enable){
37
- $wp_filesystem->delete($file);
38
- $wp_filesystem->put_contents($file, $maintenance_message, FS_CHMOD_FILE);
39
- }else {
40
- $wp_filesystem->delete($file);
41
- }
42
- }
43
-
44
- function install_remote_file($params){
45
-
46
- global $wp_filesystem;
47
- extract($params);
48
-
49
- if(!isset($package) || empty($package))
50
- return array('error' => '<p>No files received. Internal error.</p>');
51
-
52
- if(defined('WP_INSTALLING') && file_exists(ABSPATH . '.maintenance'))
53
- return array('error' => '<p>Site under maintanace.</p>');;
54
-
55
- $upgrader = new WP_Upgrader();
56
- $destination = $type == 'themes' ? WP_CONTENT_DIR . '/themes' : WP_PLUGIN_DIR;
57
-
58
-
59
- foreach($package as $package_url){
60
- $key = basename($package_url);
61
- $install_info[$key] = @$upgrader->run(array(
62
- 'package' => $package_url,
63
- 'destination' => $destination,
64
- 'clear_destination' => false, //Do not overwrite files.
65
- 'clear_working' => true,
66
- 'hook_extra' => array()
67
- ));
68
- }
69
-
70
- if($activate){
71
- $all_plugins = get_plugins();
72
- foreach($all_plugins as $plugin_slug => $plugin){
73
- $plugin_dir = preg_split('/\//', $plugin_slug);
74
- foreach($install_info as $key => $install){
75
- if(!$install || is_wp_error($install))
76
- continue;
77
-
78
- if($install['destination_name'] == $plugin_dir[0]){
79
- $install_info[$key]['activated'] = activate_plugin($plugin_slug, '', false);
80
- }
81
- }
82
- }
83
- }
84
- return $install_info;
85
- }
86
-
87
- /**
88
- * Upgrades WordPress locally
89
- *
90
- */
91
- function upgrade($params)
92
- {
93
- ob_start();
94
- require_once(ABSPATH . 'wp-admin/includes/file.php');
95
- require_once(ABSPATH . 'wp-admin/includes/misc.php');
96
- require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
97
-
98
- if(!$wp_filesystem)
99
- WP_Filesystem();
100
-
101
- global $wp_version, $wp_filesystem;
102
- $upgrader = new WP_Upgrader();
103
- $updates = $this->mmb_get_transient('update_core');
104
- $current = $updates->updates[0];
105
-
106
-
107
- // Is an update available?
108
- if (!isset($current->response) || $current->response == 'latest')
109
- return array(
110
- 'upgraded' => ' has latest ' . $wp_version . ' WordPress version.'
111
- );
112
-
113
- $res = $upgrader->fs_connect(array(
114
- ABSPATH,
115
- WP_CONTENT_DIR
116
- ));
117
- if (is_wp_error($res))
118
- return array(
119
- 'error' => $this->mmb_get_error($res)
120
- );
121
-
122
- $wp_dir = trailingslashit($wp_filesystem->abspath());
123
-
124
- $download = $upgrader->download_package($current->package);
125
- if (is_wp_error($download))
126
- return array(
127
- 'error' => $this->mmb_get_error($download)
128
- );
129
-
130
- $working_dir = $upgrader->unpack_package($download);
131
- if (is_wp_error($working_dir))
132
- return array(
133
- 'error' => $this->mmb_get_error($working_dir)
134
- );
135
-
136
- if (!$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true)) {
137
- $wp_filesystem->delete($working_dir, true);
138
- return array(
139
- 'error' => 'Unable to move update files.'
140
- );
141
- }
142
-
143
- $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
144
-
145
- require(ABSPATH . 'wp-admin/includes/update-core.php');
146
- ob_end_clean();
147
-
148
- $update_core = update_core($working_dir, $wp_dir);
149
-
150
- if (is_wp_error($update_core))
151
- return array(
152
- 'error' => $this->mmb_get_error($update_core)
153
- );
154
-
155
- $this->mmb_delete_transient('update_core');
156
- return array(
157
- 'upgraded' => ' upgraded sucessfully.'
158
- );
159
- }
160
-
161
- }
162
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
plugin.class.php CHANGED
@@ -1,14 +1,5 @@
1
  <?php
2
- /*************************************************************
3
- *
4
- * plugin.class.php
5
- *
6
- * Upgrade Plugins
7
- *
8
- *
9
- * Copyright (c) 2011 Prelovac Media
10
- * www.prelovac.com
11
- **************************************************************/
12
  class MMB_Plugin extends MMB_Core
13
  {
14
  var $worker_maitanance_mode = false;
@@ -16,83 +7,123 @@ class MMB_Plugin extends MMB_Core
16
  {
17
  parent::__construct();
18
  }
19
-
 
20
  /**
21
  * Upgrades all upgradable plugins on this blog
22
  *
23
  * @param mixed $args
24
  */
25
  function upgrade_all($params)
26
- {
27
- include_once(ABSPATH . 'wp-admin/includes/file.php');
28
-
29
- if ((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && (get_filesystem_method(array(), false) != 'direct'))
30
- {
31
- return array(
32
- 'error' => 'Failed, please <a target="_blank" href="http://managewp.com/user-guide#ftp">add FTP details</a></a>'
33
- );
34
- }
35
-
36
-
37
- $upgradable_plugins = $this->get_upgradable_plugins();
38
-
39
- $ready_for_upgrade = array();
40
- if (!empty($upgradable_plugins)) {
41
- foreach ($upgradable_plugins as $upgrade) {
42
- $ready_for_upgrade[] = $upgrade->file;
43
- }
44
- }
45
- $return = '';
46
  if (!empty($ready_for_upgrade)) {
47
- ob_start();
 
48
  include_once(ABSPATH . 'wp-admin/includes/plugin.php');
49
  require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
50
  if (class_exists('Plugin_Upgrader')) {
51
  $upgrader = new Plugin_Upgrader(new Bulk_Plugin_Upgrader_Skin(compact('nonce', 'url')));
52
  $result = $upgrader->bulk_upgrade($ready_for_upgrade);
53
- ob_end_clean();
54
  foreach ($result as $plugin_slug => $plugin_info) {
55
- $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_slug);
56
- if (!$plugin_info || is_wp_error($plugin_info)) {
57
- $return .= '<code title="Please upgrade manually">' . $data['Name'] . '</code> was not upgraded.<br />';
58
- } else {
59
- $return .= '<code>' . $data['Name'] . '</code> successfully upgraded.<br />';
60
- }
61
  }
62
- ob_end_clean();
63
- return array(
64
- 'upgraded' => $return
65
- );
66
- } else {
67
- ob_end_clean();
68
- return array(
69
- 'error' => 'Could not initialize upgrader.'
70
- );
71
  }
 
 
 
 
72
  }
73
- return array(
74
- 'error' => 'No plugins to upgrade at the moment'
75
- );
76
  }
77
 
78
- function get_upgradable_plugins()
 
 
 
 
 
79
  {
80
- $current = $this->mmb_get_transient('update_plugins');
81
- $upgradable_plugins = array();
82
- if (!empty($current->response)) {
83
- foreach ($current->response as $plugin_path => $plugin_data) {
84
- if (!function_exists('get_plugin_data'))
85
- include_once ABSPATH . 'wp-admin/includes/plugin.php';
86
- $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_path);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
- $current->response[$plugin_path]->name = $data['Name'];
89
- $current->response[$plugin_path]->old_version = $data['Version'];
90
- $current->response[$plugin_path]->file = $plugin_path;
91
- $upgradable_plugins[] = $current->response[$plugin_path];
 
 
92
  }
93
- return $upgradable_plugins;
94
  } else
95
- return array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
  }
98
 
1
  <?php
2
+
 
 
 
 
 
 
 
 
 
3
  class MMB_Plugin extends MMB_Core
4
  {
5
  var $worker_maitanance_mode = false;
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
 
plugins/cleanup/cleanup.php DELETED
@@ -1,161 +0,0 @@
1
- <?php
2
- /*************************************************************
3
- *
4
- *
5
- *
6
- * ManageWP Worker Plugin
7
- *
8
- *
9
- * Copyright (c) 2011 Prelovac Media
10
- * www.prelovac.com
11
- **************************************************************/
12
-
13
- add_filter('mmb_stats_filter', mmb_get_extended_info);
14
-
15
-
16
- function mmb_get_extended_info($stats)
17
- {
18
- $stats['num_revisions'] = mmb_num_revisions();
19
- $stats['overhead'] = mmb_get_overhead();
20
- $stats['num_spam_comments'] = mmb_num_spam_comments();
21
- return $stats;
22
- }
23
-
24
- /* Revisions */
25
-
26
- mmb_add_action('cleanup_delete', 'cleanup_delete_worker');
27
-
28
- function cleanup_delete_worker($params = array()){
29
- global $mmb_core;
30
-
31
- $params_array = explode('_', $params['actions']);
32
- $return_array = array();
33
- foreach ($params_array as $param){
34
- switch ($param){
35
- case 'revision' :
36
- if(mmb_delete_all_revisions()){
37
- $return_array['revision'] = 'Revisions deleted.';
38
- }else{
39
- $return_array['revision'] = 'Revisions not deleted.';
40
- }
41
- break;
42
- case 'overhead' :
43
- if(mmb_clear_overhead()){
44
- $return_array['overhead'] = 'Overhead cleared.';
45
- }else{
46
- $return_array['overhead'] = 'Overhead not cleared.';
47
- }
48
- break;
49
- case 'comment' :
50
- if(mmb_delete_spam_comments()){
51
- $return_array['comment'] = 'Comments deleted';
52
- }else{
53
- $return_array['comment'] = 'Comments not deleted';
54
- }
55
- break;
56
- default:
57
- break;
58
- }
59
-
60
- }
61
-
62
- unset($params);
63
-
64
- mmb_response($return_array, true);
65
- }
66
-
67
- function mmb_num_revisions() {
68
- global $wpdb;
69
- $sql = "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'revision'";
70
- $num_revisions = $wpdb->get_var($wpdb->prepare($sql));
71
- return $num_revisions;
72
- }
73
-
74
- function mmb_select_all_revisions() {
75
- global $wpdb;
76
- $sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'revision'";
77
- $revisions = $wpdb->get_results($wpdb->prepare($sql));
78
- return $revisions;
79
- }
80
-
81
- function mmb_delete_all_revisions() {
82
- global $wpdb;
83
- $sql = "DELETE a,b,c FROM $wpdb->posts a LEFT JOIN $wpdb->term_relationships b ON (a.ID = b.object_id) LEFT JOIN $wpdb->postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision'";
84
- $revisions = $wpdb->query($wpdb->prepare($sql));
85
- return $revisions;
86
- }
87
-
88
-
89
-
90
- /* Optimize */
91
-
92
- function mmb_get_overhead()
93
- {
94
- global $wpdb, $mmb_core;
95
- $tot_data = 0;
96
- $tot_idx = 0;
97
- $tot_all = 0;
98
- $query = 'SHOW TABLE STATUS FROM '. DB_NAME;
99
- $tables = $wpdb->get_results($query,ARRAY_A);
100
- foreach($tables as $table)
101
- {
102
- $tot_data = $table['Data_length'];
103
- $tot_idx = $table['Index_length'];
104
- $total = $tot_data + $tot_idx;
105
- $total = $total / 1024 ;
106
- $total = round ($total,3);
107
- $gain= $table['Data_free'];
108
- $gain = $gain / 1024 ;
109
- $total_gain += $gain;
110
- $gain = round ($gain,3);
111
-
112
- }
113
-
114
- return round($total_gain,3);
115
- }
116
-
117
- function mmb_clear_overhead()
118
- {
119
- global $wpdb;
120
- $tables = $wpdb->get_col("SHOW TABLES");
121
- foreach ($tables as $table_name) {
122
- $table_string .= $table_name . ",";
123
- }
124
- $table_string = substr($table_string,0,strlen($table_string)-1); //remove last ,
125
-
126
- $table_string = rtrim($table_string);
127
-
128
- $query = "OPTIMIZE TABLE $table_string";
129
-
130
- $optimize = $wpdb->query($query);
131
- return $optimize ? true : false;
132
- }
133
-
134
-
135
-
136
- /* Spam Comments */
137
-
138
- function mmb_num_spam_comments()
139
- {
140
- global $wpdb;
141
- $sql = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'spam'";
142
- $num_spams = $wpdb->get_var($wpdb->prepare($sql));
143
- return $num_spams;
144
- }
145
-
146
- function mmb_delete_spam_comments()
147
- {
148
- global $wpdb;
149
- $sql = "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam'";
150
- $spams = $wpdb->query($wpdb->prepare($sql));
151
- return $sql;
152
- }
153
-
154
-
155
- function mmb_get_spam_comments() {
156
- global $wpdb;
157
- $sql = "SELECT * FROM $wpdb->comments as a LEFT JOIN $wpdb->commentmeta as b WHERE a.comment_ID = b.comment_id AND a.comment_approved = 'spam'";
158
- $spams = $wpdb->get_results($wpdb->prepare($sql));
159
- return $spams;
160
- }
161
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
plugins/extra_html_example/extra_html_example.php DELETED
@@ -1,18 +0,0 @@
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 DELETED
@@ -1,88 +0,0 @@
1
- <?php
2
- /*************************************************************
3
- *
4
- * stats.class.php
5
- *
6
- * Various searches on worker
7
- *
8
- *
9
- * Copyright (c) 2011 Prelovac Media
10
- * www.prelovac.com
11
- **************************************************************/
12
-
13
- mmb_add_action('search_posts_by_term', 'search_posts_by_term');
14
-
15
- function search_posts_by_term($params = false){
16
-
17
- global $wpdb, $current_user;
18
-
19
-
20
- $num_posts = 10;
21
- $num_content_char = 30;
22
-
23
- $term_orig = trim($params['search_term']);
24
- $term_base= addslashes(trim($params['search_term']));
25
-
26
- $query = "SELECT *
27
- FROM $wpdb->posts
28
- WHERE $wpdb->posts.post_status = 'publish'
29
- AND ($wpdb->posts.post_title LIKE '%$term_base%'
30
- OR $wpdb->posts.post_content LIKE '%$term_base%')
31
- ORDER BY $wpdb->posts.post_modified DESC
32
- LIMIT 0, $num_posts
33
- ";
34
-
35
- $posts_array = $wpdb->get_results($query);
36
-
37
- $ret_posts = array();
38
-
39
- foreach($posts_array as $post){
40
- //highlight searched term
41
-
42
- if (substr_count(strtolower($post->post_title), strtolower($term_orig))){
43
- $str_position_start = strpos(strtolower($post->post_title), strtolower($term_orig));
44
-
45
- $post->post_title = substr($post->post_title, 0, $str_position_start).'<b>'.
46
- substr($post->post_title, $str_position_start, strlen($term_orig)).'</b>'.
47
- substr($post->post_title, $str_position_start + strlen($term_orig));
48
-
49
- }
50
- $post->post_content = html_entity_decode($post->post_content);
51
-
52
- $post->post_content = strip_tags($post->post_content);
53
-
54
-
55
-
56
- if (substr_count(strtolower($post->post_content), strtolower($term_orig))){
57
- $str_position_start = strpos(strtolower($post->post_content), strtolower($term_orig));
58
-
59
- $start = $str_position_start > $num_content_char ? $str_position_start - $num_content_char: 0;
60
- $first_len = $str_position_start > $num_content_char? $num_content_char : $str_position_start;
61
-
62
- $start_substring = $start>0 ? '...' : '';
63
- $post->post_content = $start_substring . substr($post->post_content, $start, $first_len).'<b>'.
64
- substr($post->post_content, $str_position_start, strlen($term_orig)).'</b>'.
65
- substr($post->post_content, $str_position_start + strlen($term_orig), $num_content_char) . '...';
66
-
67
-
68
- }else{
69
- $post->post_content = substr($post->post_content,0, 50). '...';
70
- }
71
-
72
- $ret_posts[] = array(
73
- 'ID' => $post->ID
74
- ,'post_permalink' => get_permalink($post->ID)
75
- ,'post_date' => $post->post_date
76
- ,'post_title' => $post->post_title
77
- ,'post_content' => $post->post_content
78
- ,'post_modified' => $post->post_modified
79
- ,'comment_count' => $post->comment_count
80
-
81
-
82
- );
83
- }
84
- mmb_response($ret_posts, true);
85
-
86
- }
87
-
88
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
post.class.php CHANGED
@@ -28,7 +28,6 @@ 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
- include_once ABSPATH . 'wp-admin/includes/file.php';
32
 
33
  $post_struct = $args['post_data'];
34
 
@@ -42,7 +41,7 @@ class MMB_Post extends MMB_Core
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,7 +120,10 @@ class MMB_Post extends MMB_Core
121
  $no_thumb = $get_url[4];
122
  }
123
  $file_name = basename($no_thumb);
124
- $tmp_file = download_url($no_thumb);
 
 
 
125
 
126
  $attach_upload['url'] = $upload['url'] . '/' . $file_name;
127
  $attach_upload['path'] = $upload['path'] . '/' . $file_name;
@@ -205,7 +207,12 @@ class MMB_Post extends MMB_Core
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,7 +274,8 @@ class MMB_Post extends MMB_Core
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,8 +325,26 @@ class MMB_Post extends MMB_Core
317
  update_post_meta($post_id, $meta_key, $value[0]);
318
  }
319
  }
320
- return $post_id;
 
 
 
 
321
  }
322
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  }
324
  ?>
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
 
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
  $no_thumb = $get_url[4];
121
  }
122
  $file_name = basename($no_thumb);
123
+
124
+ //$tmp_file = $upload['path'].'/tempfile.tmp';
125
+ $tmp_file = $this->mmb_download_url($no_thumb, $upload['path'] . '/tempfile'.md5(time()).'.tmp');
126
+ //$tmp_file = download_url($no_thumb);
127
 
128
  $attach_upload['url'] = $upload['url'] . '/' . $file_name;
129
  $attach_upload['path'] = $upload['path'] . '/' . $file_name;
207
  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
  // 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
  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
  ?>
readme.txt CHANGED
@@ -1,91 +1,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.6 =
33
- * Added seach websites feature
34
- * Enhanced dashboard actions (spam comments, post revisions, table overhead)
35
- * Added developer [API] (http://managewp.com/api "ManageWP API")
36
- * Improved Migrate/Clone site feature
37
-
38
- = 3.8.4 =
39
- * Fixed remote dashboard problems for sites with redirects
40
- * Fixed IE7 issues in the dashboard
41
-
42
- = 3.8.3 =
43
- * Fixed problem with capabilities
44
-
45
- = 3.8.2 =
46
- * New interface
47
- * SSL security protocol
48
- * No passwords required
49
- * Improved clone/backup
50
-
51
-
52
- = 3.6.3 =
53
- * Initial public release
54
-
55
- == Installation ==
56
-
57
- 1. Upload the plugin folder to your /wp-content/plugins/ folder
58
- 2. Go to the Plugins page and activate ManageWP Worker
59
- 3. Visit [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs"), sign up and add your site
60
-
61
- Alternately
62
-
63
- 1. Visit [ManageWP.com](http://managewp.com/ "Manage Multiple Blogs"), sign up and add your site
64
- 2. ManageWP will warn you the worker plugin is not installed and offer a link for quick installation
65
-
66
- == Screenshots ==
67
-
68
- 1. ManageWP dashboard with available upgrades, site statistics and management functions
69
-
70
-
71
-
72
- == License ==
73
-
74
- This file is part of ManageWP Worker.
75
-
76
- 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.
77
-
78
- 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.
79
-
80
- You should have received a copy of the GNU General Public License along with ManageWP Worker. If not, see <http://www.gnu.org/licenses/>.
81
-
82
-
83
- == Frequently Asked Questions ==
84
-
85
- = I have problems adding my site =
86
-
87
- 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").
88
-
89
- = I have problems installing new plugins or upgrading WordPress through ManageWP =
90
-
91
- 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.
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
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
screenshot-1.png DELETED
Binary file
stats.class.php CHANGED
@@ -1,16 +1,4 @@
1
  <?php
2
- /*************************************************************
3
- *
4
- * stats.class.php
5
- *
6
- * Get Site Stats
7
- *
8
- *
9
- * Copyright (c) 2011 Prelovac Media
10
- * www.prelovac.com
11
- **************************************************************/
12
-
13
-
14
  class MMB_Stats extends MMB_Core
15
  {
16
  function __construct()
@@ -28,27 +16,25 @@ class MMB_Stats extends MMB_Core
28
  global $wp_version, $mmb_plugin_dir;
29
  $stats = array();
30
 
31
- //define constants
32
- $num_pending_comments = 3;
33
  $num_approved_comments = 3;
34
- $num_spam_comments = 0;
35
- $num_draft_comments = 0;
36
- $num_trash_comments = 0;
37
 
38
  require_once(ABSPATH . '/wp-admin/includes/update.php');
39
-
40
- $stats['worker_version'] = MMB_WORKER_VERSION;
41
- $stats['wordpress_version'] = $wp_version;
42
 
43
  $updates = $this->mmb_get_transient('update_core');
44
-
45
- if ($updates->updates[0]->response == 'development' || version_compare($wp_version, $updates->updates[0]->current, '<')) {
46
- $updates->updates[0]->current_version = $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,31 +44,31 @@ class MMB_Stats extends MMB_Core
58
  }
59
  $stats['hit_counter'] = get_option('user_hit_count');
60
 
 
 
61
 
62
- $stats['upgradable_themes'] = $this->get_theme_instance()->get_upgradable_themes();
63
- $stats['upgradable_plugins'] = $this->get_plugin_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) {
 
86
  $recent->post_permalink = get_permalink($recent->ID);
87
  unset($recent->post_content);
88
  unset($recent->post_author);
@@ -127,12 +113,9 @@ class MMB_Stats extends MMB_Core
127
 
128
  if ((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && !is_writable(WP_CONTENT_DIR)) {
129
  $stats['writable'] = false;
130
- } else
131
- $stats['writable'] = true;
132
-
133
- $stats = apply_filters('mmb_stats_filter', $stats);
134
-
135
- return $stats;
136
  }
137
 
138
  function get_initial_stats()
@@ -142,27 +125,30 @@ class MMB_Stats extends MMB_Core
142
  $stats = array();
143
 
144
  $stats['email'] = get_option('admin_email');
145
- $stats['no_openssl'] = $this->get_random_signature();
146
  $stats['content_path'] = WP_CONTENT_DIR;
147
  $stats['worker_path'] = $mmb_plugin_dir;
148
  $stats['worker_version'] = MMB_WORKER_VERSION;
149
  $stats['site_title'] = get_bloginfo('name');
150
  $stats['site_tagline'] = get_bloginfo('description');
151
- $stats['site_url'] = get_bloginfo('home');
152
-
153
 
 
154
  if ((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && !is_writable(WP_CONTENT_DIR)) {
155
  $stats['writable'] = false;
156
- } else
157
- $stats['writable'] = true;
158
 
159
  return $stats;
160
  }
161
-
162
-
 
 
 
163
  function set_hit_count($fix_count = false)
164
  {
165
- if ($fix_count || (!is_admin() && !MMB_Stats::detect_bots())) {
 
166
  $date = date('Y-m-d');
167
  $user_hit_count = get_option('user_hit_count');
168
  if (!$user_hit_count) {
@@ -171,17 +157,18 @@ class MMB_Stats extends MMB_Core
171
  } else {
172
  $dated_keys = array_keys($user_hit_count);
173
  $last_visit_date = $dated_keys[count($dated_keys) - 1];
174
-
175
  $days = intval((strtotime($date) - strtotime($last_visit_date)) / 60 / 60 / 24);
176
 
177
- if ($days > 1) {
 
178
  $date_to_add = date('Y-m-d', strtotime($last_visit_date));
179
 
180
  for ($i = 1; $i < $days; $i++) {
181
  if (count($user_hit_count) > 14) {
182
  $shifted = @array_shift($user_hit_count);
183
  }
184
-
185
  $next_key = strtotime('+1 day', strtotime($date_to_add));
186
  if ($next_key == $date) {
187
  break;
@@ -189,7 +176,7 @@ class MMB_Stats extends MMB_Core
189
  $user_hit_count[$next_key] = 0;
190
  }
191
  }
192
-
193
  }
194
 
195
  if (!isset($user_hit_count[$date])) {
@@ -198,11 +185,11 @@ class MMB_Stats extends MMB_Core
198
  if (!$fix_count)
199
  $user_hit_count[$date] += 1;
200
 
201
- if (count($user_hit_count) > 14) {
202
  $shifted = @array_shift($user_hit_count);
203
  }
204
 
205
- update_option('user_hit_count', $user_hit_count);
206
 
207
  }
208
  }
@@ -224,7 +211,7 @@ class MMB_Stats extends MMB_Core
224
  }
225
 
226
  function detect_bots()
227
- {
228
  $agent = $_SERVER['HTTP_USER_AGENT'];
229
 
230
  if ($agent == '')
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
2
  class MMB_Stats extends MMB_Core
3
  {
4
  function __construct()
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
  }
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);
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()
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
  } 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
  $user_hit_count[$next_key] = 0;
177
  }
178
  }
179
+
180
  }
181
 
182
  if (!isset($user_hit_count[$date])) {
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
  }
212
 
213
  function detect_bots()
214
+ {
215
  $agent = $_SERVER['HTTP_USER_AGENT'];
216
 
217
  if ($agent == '')
theme.class.php CHANGED
@@ -10,7 +10,8 @@ class MMB_Theme extends MMB_Core
10
 
11
  function upload_theme_by_url($args){
12
 
13
- $url = $args['url'];
 
14
 
15
  //return (print_r($args, true));
16
  ob_start();
@@ -37,16 +38,8 @@ class MMB_Theme extends MMB_Core
37
  }
38
 
39
  function upgrade_all($params){
40
- include_once(ABSPATH . 'wp-admin/includes/file.php');
41
 
42
- if ((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && (get_filesystem_method(array(), false) != 'direct'))
43
- {
44
- return array(
45
- 'error' => 'Failed, please <a target="_blank" href="http://managewp.com/user-guide#ftp">add FTP details</a></a>'
46
- );
47
- }
48
-
49
- $upgradable_themes = $this->get_upgradable_themes();
50
 
51
  $ready_for_upgrade = array();
52
  if(!empty($upgradable_themes)){
@@ -55,7 +48,7 @@ class MMB_Theme extends MMB_Core
55
  }
56
  }
57
  if(!empty($ready_for_upgrade)){
58
-
59
  include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
60
  $upgrader = new Theme_Upgrader(new Bulk_Theme_Upgrader_Skin( compact('title', 'nonce', 'url', 'theme') ));
61
 
@@ -80,7 +73,7 @@ class MMB_Theme extends MMB_Core
80
  }
81
  }
82
 
83
- function get_upgradable_themes(){
84
 
85
  $all_themes = get_themes();
86
  $upgrade_themes = array();
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();
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)){
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
 
73
  }
74
  }
75
 
76
+ function _get_upgradable_themes(){
77
 
78
  $all_themes = get_themes();
79
  $upgrade_themes = array();
user.class.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.6
1
+ 3.8.2
wp.class.php CHANGED
@@ -1,100 +1,91 @@
1
  <?php
2
- /*************************************************************
3
- *
4
- * wp.class.php
5
- *
6
- * Upgrade WordPress
7
- *
8
- *
9
- * Copyright (c) 2011 Prelovac Media
10
- * www.prelovac.com
11
- **************************************************************/
12
  class MMB_WP extends MMB_Core
13
  {
14
  function __construct()
15
  {
16
  parent::__construct();
17
  }
18
-
19
- /**
20
- * Upgrades WordPress locally
21
- *
22
- */
23
- function upgrade($params)
24
  {
25
- ob_start();
26
- require_once(ABSPATH . 'wp-admin/includes/file.php');
27
- require_once(ABSPATH . 'wp-admin/includes/misc.php');
28
- require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
29
-
30
- if ((!defined('FTP_HOST') || !defined('FTP_USER') || !defined('FTP_PASS')) && (get_filesystem_method(array(), false) != 'direct'))
31
- {
32
- return array(
33
- 'error' => 'Failed, please <a target="_blank" href="http://managewp.com/user-guide#ftp">add FTP details</a></a>'
34
- );
35
- }
36
-
37
-
38
- WP_Filesystem();
39
- global $wp_version, $wp_filesystem;
40
- $upgrader = new WP_Upgrader();
41
- $updates = $this->mmb_get_transient('update_core');
42
- $current = $updates->updates[0];
43
-
44
-
45
- // Is an update available?
46
- if (!isset($current->response) || $current->response == 'latest')
47
- return array(
48
- 'upgraded' => ' has latest ' . $wp_version . ' WordPress version.'
49
- );
50
-
51
- $res = $upgrader->fs_connect(array(
52
- ABSPATH,
53
- WP_CONTENT_DIR
54
- ));
55
- if (is_wp_error($res))
56
- return array(
57
- 'error' => $this->mmb_get_error($res)
58
- );
59
-
60
- $wp_dir = trailingslashit($wp_filesystem->abspath());
61
-
62
- $download = $upgrader->download_package($current->package);
63
- if (is_wp_error($download))
64
  return array(
65
- 'error' => $this->mmb_get_error($download)
 
66
  );
67
-
68
- $working_dir = $upgrader->unpack_package($download);
69
- if (is_wp_error($working_dir))
70
- return array(
71
- 'error' => $this->mmb_get_error($working_dir)
72
- );
73
-
74
- if (!$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true)) {
75
- $wp_filesystem->delete($working_dir, true);
76
- return array(
77
- 'error' => 'Unable to move update files.'
78
  );
79
  }
80
-
81
- $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
82
-
83
- require(ABSPATH . 'wp-admin/includes/update-core.php');
84
- ob_end_clean();
85
-
86
- $update_core = update_core($working_dir, $wp_dir);
87
-
88
- if (is_wp_error($update_core))
89
- return array(
90
- 'error' => $this->mmb_get_error($update_core)
91
- );
92
-
93
- $this->mmb_delete_transient('update_core');
94
- return array(
95
- 'upgraded' => ' upgraded sucessfully.'
96
- );
97
  }
98
-
99
- }
100
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }