PluginProbe
ManageWP Worker / 3.9.16
ManageWP Worker v3.9.16
4.9.38 4.9.37 4.9.36 4.9.35 4.9.34 3.8.7 3.8.8 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.18 3.9.19 3.9.2 3.9.20 3.9.21 3.9.22 3.9.23 3.9.24 All 73 releases
worker / init.php

init.php in ManageWP Worker 3.9.16, at init.php

830 lines 23.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: ManageWP - Worker
4 Plugin URI: http://managewp.com/
5 Description: Manage all your blogs from one dashboard. Visit <a href="http://managewp.com">ManageWP.com</a> to sign up.
6 Author: Prelovac Media
7 Version: 3.9.16
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 if(!defined('MMB_WORKER_VERSION'))
23 define('MMB_WORKER_VERSION', '3.9.16');
24
25 if ( !defined('MMB_XFRAME_COOKIE')){
26 $siteurl = function_exists('get_site_option') ? get_site_option( 'siteurl' ) : get_option('siteurl');
27 define('MMB_XFRAME_COOKIE', $xframe = 'wordpress_'.md5($siteurl).'_xframe');
28 }
29 global $wpdb, $mmb_plugin_dir, $mmb_plugin_url, $wp_version, $mmb_filters, $_mmb_item_filter;
30 if (version_compare(PHP_VERSION, '5.0.0', '<')) // min version 5 supported
31 exit("<p>ManageWP Worker plugin requires PHP 5 or higher.</p>");
32
33
34 $mmb_wp_version = $wp_version;
35 $mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
36 $mmb_plugin_url = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
37
38 require_once("$mmb_plugin_dir/helper.class.php");
39 require_once("$mmb_plugin_dir/core.class.php");
40 require_once("$mmb_plugin_dir/post.class.php");
41 require_once("$mmb_plugin_dir/comment.class.php");
42 require_once("$mmb_plugin_dir/stats.class.php");
43 require_once("$mmb_plugin_dir/backup.class.php");
44 require_once("$mmb_plugin_dir/installer.class.php");
45 require_once("$mmb_plugin_dir/link.class.php");
46 require_once("$mmb_plugin_dir/user.class.php");
47 require_once("$mmb_plugin_dir/api.php");
48
49 require_once("$mmb_plugin_dir/plugins/search/search.php");
50 require_once("$mmb_plugin_dir/plugins/cleanup/cleanup.php");
51
52 require_once("$mmb_plugin_dir/widget.class.php");
53
54 if( !function_exists ( 'mmb_parse_request' )) {
55 function mmb_parse_request()
56 {
57
58 if (!isset($HTTP_RAW_POST_DATA)) {
59 $HTTP_RAW_POST_DATA = file_get_contents('php://input');
60 }
61 ob_start();
62
63 global $current_user, $mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache;
64 $data = base64_decode($HTTP_RAW_POST_DATA);
65 if ($data)
66 $num = @extract(unserialize($data));
67
68 if (isset($action)) {
69 $_wp_using_ext_object_cache = false;
70 @set_time_limit(600);
71
72 if (!$mmb_core->check_if_user_exists($params['username']))
73 mmb_response('Username <b>' . $params['username'] . '</b> does not have administrator capabilities. Enter the correct username in the site options.', false);
74
75 if ($action == 'add_site') {
76 mmb_add_site($params);
77 mmb_response('You should never see this.', false);
78 }
79
80 $auth = $mmb_core->authenticate_message($action . $id, $signature, $id);
81 if ($auth === true) {
82
83 if(isset($params['username']) && !is_user_logged_in()){
84 $user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : get_userdatabylogin( $params['username'] );
85 wp_set_current_user($user->ID);
86 }
87
88 /* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
89 if( strlen(trim($wp_db_version)) && !defined('ACX_PLUGIN_DIR') ){
90 if ( get_option('db_version') != $wp_db_version ) {
91 /* in multisite network, please update database manualy */
92 if (empty($wpmu_version) || (function_exists('is_multisite') && !is_multisite())){
93 if( ! function_exists('wp_upgrade'))
94 include_once(ABSPATH.'wp-admin/includes/upgrade.php');
95
96 ob_clean();
97 @wp_upgrade();
98 @do_action('after_db_upgrade');
99 ob_end_clean();
100 }
101 }
102 }
103
104 if(isset($params['secure'])){
105 if($decrypted = $mmb_core->_secure_data($params['secure'])){
106 $decrypted = maybe_unserialize($decrypted);
107 if(is_array($decrypted)){
108 foreach($decrypted as $key => $val){
109 if(!is_numeric($key))
110 $params[$key] = $val;
111 }
112 unset($params['secure']);
113 } else $params['secure'] = $decrypted;
114 }
115 }
116
117 if( !$mmb_core->register_action_params( $action, $params ) ){
118 global $_mmb_plugin_actions;
119 $_mmb_plugin_actions[$action] = $params;
120 }
121
122
123 } else {
124 mmb_response($auth['error'], false);
125 }
126 } else {
127 MMB_Stats::set_hit_count();
128 }
129 ob_end_clean();
130 }
131 }
132 /* Main response function */
133 if( !function_exists ( 'mmb_response' )) {
134
135 function mmb_response($response = false, $success = true)
136 {
137 $return = array();
138
139 if ((is_array($response) && empty($response)) || (!is_array($response) && strlen($response) == 0))
140 $return['error'] = 'Empty response.';
141 else if ($success)
142 $return['success'] = $response;
143 else
144 $return['error'] = $response;
145
146 if( !headers_sent() ){
147 header('HTTP/1.0 200 OK');
148 header('Content-Type: text/plain');
149 }
150 exit("<MWPHEADER>" . base64_encode(serialize($return))."<ENDMWPHEADER>");
151 }
152 }
153
154
155
156 if( !function_exists ( 'mmb_add_site' )) {
157 function mmb_add_site($params)
158 {
159 global $mmb_core;
160 $num = extract($params);
161
162 if ($num) {
163 if (!get_option('_action_message_id') && !get_option('_worker_public_key')) {
164 $public_key = base64_decode($public_key);
165
166 if (function_exists('openssl_verify')) {
167 $verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
168 if ($verify == 1) {
169 $mmb_core->set_master_public_key($public_key);
170 $mmb_core->set_worker_message_id($id);
171 $mmb_core->get_stats_instance();
172 if(is_array($notifications) && !empty($notifications)){
173 $mmb_core->stats_instance->set_notifications($notifications);
174 }
175 if(is_array($brand) && !empty($brand)){
176 update_option('mwp_worker_brand',$brand);
177 }
178
179 mmb_response($mmb_core->stats_instance->get_initial_stats(), true);
180 } else if ($verify == 0) {
181 mmb_response('Invalid message signature. Please contact us if you see this message often.', false);
182 } else {
183 mmb_response('Command not successful. Please try again.', false);
184 }
185 } else {
186 if (!get_option('_worker_nossl_key')) {
187 srand();
188
189 $random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
190
191 $mmb_core->set_random_signature($random_key);
192 $mmb_core->set_worker_message_id($id);
193 $mmb_core->set_master_public_key($public_key);
194 $mmb_core->get_stats_instance();
195 if(is_array($notifications) && !empty($notifications)){
196 $mmb_core->stats_instance->set_notifications($notifications);
197 }
198
199 if(is_array($brand) && !empty($brand)){
200 update_option('mwp_worker_brand',$brand);
201 }
202
203 mmb_response($mmb_core->stats_instance->get_initial_stats(), true);
204 } else
205 mmb_response('Please deactivate & activate ManageWP Worker plugin on your site, then re-add the site to your dashboard.', false);
206 }
207 } else {
208 mmb_response('Please deactivate & activate ManageWP Worker plugin on your site and re-add the site to your dashboard.', false);
209 }
210 } else {
211 mmb_response('Invalid parameters received. Please try again.', false);
212 }
213 }
214 }
215
216 if( !function_exists ( 'mmb_remove_site' )) {
217 function mmb_remove_site($params)
218 {
219 extract($params);
220 global $mmb_core;
221 $mmb_core->uninstall( $deactivate );
222
223 include_once(ABSPATH . 'wp-admin/includes/plugin.php');
224 $plugin_slug = basename(dirname(__FILE__)) . '/' . basename(__FILE__);
225
226 if ($deactivate) {
227 deactivate_plugins($plugin_slug, true);
228 }
229
230 if (!is_plugin_active($plugin_slug))
231 mmb_response(array(
232 'deactivated' => 'Site removed successfully. <br /><br />ManageWP Worker plugin successfully deactivated.'
233 ), true);
234 else
235 mmb_response(array(
236 'removed_data' => 'Site removed successfully. <br /><br /><b>ManageWP Worker plugin was not deactivated.</b>'
237 ), true);
238
239 }
240 }
241 if( !function_exists ( 'mmb_stats_get' )) {
242 function mmb_stats_get($params)
243 {
244 global $mmb_core;
245 $mmb_core->get_stats_instance();
246 mmb_response($mmb_core->stats_instance->get($params), true);
247 }
248 }
249
250 if( !function_exists ( 'mmb_worker_header' )) {
251 function mmb_worker_header()
252 { global $mmb_core, $current_user;
253
254 if(!headers_sent()){
255 if(isset($current_user->ID))
256 $expiration = time() + apply_filters('auth_cookie_expiration', 10800, $current_user->ID, false);
257 else
258 $expiration = time() + 10800;
259
260 setcookie(MMB_XFRAME_COOKIE, md5(MMB_XFRAME_COOKIE), $expiration, COOKIEPATH, COOKIE_DOMAIN, false, true);
261 $_COOKIE[MMB_XFRAME_COOKIE] = md5(MMB_XFRAME_COOKIE);
262 }
263 }
264 }
265
266 if( !function_exists ( 'mmb_pre_init_stats' )) {
267 function mmb_pre_init_stats( $params )
268 {
269 global $mmb_core;
270 $mmb_core->get_stats_instance();
271 return $mmb_core->stats_instance->pre_init_stats($params);
272 }
273 }
274
275 //post
276 if( !function_exists ( 'mmb_post_create' )) {
277 function mmb_post_create($params)
278 {
279 global $mmb_core;
280 $mmb_core->get_post_instance();
281 $return = $mmb_core->post_instance->create($params);
282 if (is_int($return))
283 mmb_response($return, true);
284 else{
285 if(isset($return['error'])){
286 mmb_response($return['error'], false);
287 } else {
288 mmb_response($return, false);
289 }
290 }
291 }
292 }
293
294 if( !function_exists ( 'mmb_change_post_status' )) {
295 function mmb_change_post_status($params)
296 {
297 global $mmb_core;
298 $mmb_core->get_post_instance();
299 $return = $mmb_core->post_instance->change_status($params);
300 //mmb_response($return, true);
301
302 }
303 }
304
305 //comments
306 if( !function_exists ( 'mmb_change_comment_status' )) {
307 function mmb_change_comment_status($params)
308 {
309 global $mmb_core;
310 $mmb_core->get_comment_instance();
311 $return = $mmb_core->comment_instance->change_status($params);
312 //mmb_response($return, true);
313 if ($return){
314 $mmb_core->get_stats_instance();
315 mmb_response($mmb_core->stats_instance->get_comments_stats($params), true);
316 }else
317 mmb_response('Comment not updated', false);
318 }
319
320 }
321 if( !function_exists ( 'mmb_comment_stats_get' )) {
322 function mmb_comment_stats_get($params)
323 {
324 global $mmb_core;
325 $mmb_core->get_stats_instance();
326 mmb_response($mmb_core->stats_instance->get_comments_stats($params), true);
327 }
328 }
329
330 if( !function_exists ( 'mmb_backup_now' )) {
331 //backup
332 function mmb_backup_now($params)
333 {
334 global $mmb_core;
335
336 $mmb_core->get_backup_instance();
337 $return = $mmb_core->backup_instance->backup($params);
338
339 if (is_array($return) && array_key_exists('error', $return))
340 mmb_response($return['error'], false);
341 else {
342 mmb_response($return, true);
343 }
344 }
345 }
346
347 if( !function_exists ( 'mmb_run_task_now' )) {
348 function mmb_run_task_now($params)
349 {
350 global $mmb_core;
351 $mmb_core->get_backup_instance();
352 $return = $mmb_core->backup_instance->task_now($params['task_name']);
353 if (is_array($return) && array_key_exists('error', $return))
354 mmb_response($return['error'], false);
355 else {
356 mmb_response($return, true);
357 }
358 }
359 }
360
361 if( !function_exists ( 'mmb_email_backup' )) {
362 function mmb_email_backup($params)
363 {
364 global $mmb_core;
365 $mmb_core->get_backup_instance();
366 $return = $mmb_core->backup_instance->email_backup($params);
367
368 if (is_array($return) && array_key_exists('error', $return))
369 mmb_response($return['error'], false);
370 else {
371 mmb_response($return, true);
372 }
373 }
374 }
375
376 if( !function_exists ( 'mmb_check_backup_compat' )) {
377 function mmb_check_backup_compat($params)
378 {
379 global $mmb_core;
380 $mmb_core->get_backup_instance();
381 $return = $mmb_core->backup_instance->check_backup_compat($params);
382
383 if (is_array($return) && array_key_exists('error', $return))
384 mmb_response($return['error'], false);
385 else {
386 mmb_response($return, true);
387 }
388 }
389 }
390
391 if( !function_exists ( 'mmb_get_backup_req' )) {
392 function mmb_get_backup_req( $params )
393 {
394 global $mmb_core;
395 $mmb_core->get_stats_instance();
396 $return = $mmb_core->stats_instance->get_backup_req($params);
397
398 mmb_response($return, true);
399 }
400 }
401
402 if( !function_exists ( 'mmb_scheduled_backup' )) {
403 function mmb_scheduled_backup($params)
404 {
405 global $mmb_core;
406 $mmb_core->get_backup_instance();
407 $return = $mmb_core->backup_instance->set_backup_task($params);
408 mmb_response($return, $return);
409 }
410 }
411
412 if( !function_exists ( 'mmm_delete_backup' )) {
413 function mmm_delete_backup($params)
414 {
415 global $mmb_core;
416 $mmb_core->get_backup_instance();
417 $return = $mmb_core->backup_instance->delete_backup($params);
418 mmb_response($return, $return);
419 }
420 }
421
422 if( !function_exists ( 'mmb_optimize_tables' )) {
423 function mmb_optimize_tables($params)
424 {
425 global $mmb_core;
426 $mmb_core->get_backup_instance();
427 $return = $mmb_core->backup_instance->optimize_tables();
428 if ($return)
429 mmb_response($return, true);
430 else
431 mmb_response(false, false);
432 }
433 }
434 if( !function_exists ( 'mmb_restore_now' )) {
435 function mmb_restore_now($params)
436 {
437 global $mmb_core;
438 $mmb_core->get_backup_instance();
439 $return = $mmb_core->backup_instance->restore($params);
440 if (is_array($return) && array_key_exists('error', $return))
441 mmb_response($return['error'], false);
442 else
443 mmb_response($return, true);
444
445 }
446 }
447
448 if( !function_exists ( 'mmb_remote_backup_now' )) {
449 function mmb_remote_backup_now($params)
450 {
451 global $mmb_core;
452 $backup_instance = $mmb_core->get_backup_instance();
453 $return = $mmb_core->backup_instance->remote_backup_now($params);
454 if (is_array($return) && array_key_exists('error', $return))
455 mmb_response($return['error'], false);
456 else
457 mmb_response($return, true);
458 }
459 }
460
461
462 if( !function_exists ( 'mmb_clean_orphan_backups' )) {
463 function mmb_clean_orphan_backups()
464 {
465 global $mmb_core;
466 $backup_instance = $mmb_core->get_backup_instance();
467 $return = $mmb_core->backup_instance->cleanup();
468 if(is_array($return))
469 mmb_response($return, true);
470 else
471 mmb_response($return, false);
472 }
473 }
474
475 if( !function_exists ( 'mmb_update_worker_plugin' )) {
476 function mmb_update_worker_plugin($params)
477 {
478 global $mmb_core;
479 mmb_response($mmb_core->update_worker_plugin($params), true);
480 }
481 }
482
483 if( !function_exists ( 'mmb_wp_checkversion' )) {
484 function mmb_wp_checkversion($params)
485 {
486 include_once(ABSPATH . 'wp-includes/version.php');
487 global $mmb_wp_version, $mmb_core;
488 mmb_response($mmb_wp_version, true);
489 }
490 }
491 if( !function_exists ( 'mmb_search_posts_by_term' )) {
492 function mmb_search_posts_by_term($params)
493 {
494 global $mmb_core;
495 $mmb_core->get_search_instance();
496
497 $search_type = trim($params['search_type']);
498 $search_term = strtolower(trim($params['search_term']));
499
500 switch ($search_type){
501 case 'page_post':
502 $return = $mmb_core->search_instance->search_posts_by_term($params);
503 if($return){
504 $return = serialize($return);
505 mmb_response($return, true);
506 }else{
507 mmb_response('No posts found', false);
508 }
509 break;
510
511 case 'plugin':
512 $plugins = get_option('active_plugins');
513
514 $have_plugin = false;
515 foreach ($plugins as $plugin) {
516 if(strpos($plugin, $search_term)>-1){
517 $have_plugin = true;
518 }
519 }
520 if($have_plugin){
521 mmb_response(serialize($plugin), true);
522 }else{
523 mmb_response(false, false);
524 }
525 break;
526 case 'theme':
527 $theme = strtolower(get_option('template'));
528 if(strpos($theme, $search_term)>-1){
529 mmb_response($theme, true);
530 }else{
531 mmb_response(false, false);
532 }
533 break;
534 default: mmb_response(false, false);
535 }
536 $return = $mmb_core->search_instance->search_posts_by_term($params);
537
538
539
540 if ($return_if_true) {
541 mmb_response($return_value, true);
542 } else {
543 mmb_response($return_if_false, false);
544 }
545 }
546 }
547
548 if( !function_exists ( 'mmb_install_addon' )) {
549 function mmb_install_addon($params)
550 {
551 global $mmb_core;
552 $mmb_core->get_installer_instance();
553 $return = $mmb_core->installer_instance->install_remote_file($params);
554 mmb_response($return, true);
555
556 }
557 }
558
559 if( !function_exists ( 'mmb_do_upgrade' )) {
560 function mmb_do_upgrade($params)
561 {
562 global $mmb_core, $mmb_upgrading;
563 $mmb_core->get_installer_instance();
564 $return = $mmb_core->installer_instance->do_upgrade($params);
565 mmb_response($return, true);
566
567 }
568 }
569 if( !function_exists ( 'mmb_add_link' )) {
570 function mmb_add_link($params)
571 {
572 global $mmb_core;
573 $mmb_core->get_link_instance();
574 $return = $mmb_core->link_instance->add_link($params);
575 if (is_array($return) && array_key_exists('error', $return))
576
577 mmb_response($return['error'], false);
578 else {
579 mmb_response($return, true);
580 }
581
582 }
583 }
584
585 if( !function_exists ( 'mmb_add_user' )) {
586 function mmb_add_user($params)
587 {
588 global $mmb_core;
589 $mmb_core->get_user_instance();
590 $return = $mmb_core->user_instance->add_user($params);
591 if (is_array($return) && array_key_exists('error', $return))
592
593 mmb_response($return['error'], false);
594 else {
595 mmb_response($return, true);
596 }
597
598 }
599 }
600
601 if( !function_exists ('mmb_get_users')) {
602 function mmb_get_users($params)
603 {
604 global $mmb_core;
605 $mmb_core->get_user_instance();
606 $return = $mmb_core->user_instance->get_users($params);
607 if (is_array($return) && array_key_exists('error', $return))
608 mmb_response($return['error'], false);
609 else {
610 mmb_response($return, true);
611 }
612 }
613 }
614
615 if( !function_exists ('mmb_edit_users')) {
616 function mmb_edit_users($params)
617 {
618 global $mmb_core;
619 $mmb_core->get_user_instance();
620 $return = $mmb_core->user_instance->edit_users($params);
621 mmb_response($return, true);
622 }
623 }
624
625 if( !function_exists ( 'mmb_iframe_plugins_fix' )) {
626 function mmb_iframe_plugins_fix($update_actions)
627 {
628 foreach($update_actions as $key => $action)
629 {
630 $update_actions[$key] = str_replace('target="_parent"','',$action);
631 }
632
633 return $update_actions;
634
635 }
636 }
637 if( !function_exists ( 'mmb_execute_php_code' )) {
638 function mmb_execute_php_code($params)
639 {
640 ob_start();
641 eval($params['code']);
642 $return = ob_get_flush();
643 mmb_response(print_r($return, true), true);
644 }
645 }
646
647 if( !function_exists ( 'mmb_set_notifications' )) {
648 function mmb_set_notifications($params)
649 {
650 global $mmb_core;
651 $mmb_core->get_stats_instance();
652 $return = $mmb_core->stats_instance->set_notifications($params);
653 if (is_array($return) && array_key_exists('error', $return))
654 mmb_response($return['error'], false);
655 else {
656 mmb_response($return, true);
657 }
658
659 }
660 }
661
662 if( !function_exists ( 'mmb_set_alerts' )) {
663 function mmb_set_alerts($params)
664 {
665 global $mmb_core;
666 $mmb_core->get_stats_instance();
667 $return = $mmb_core->stats_instance->set_alerts($params);
668 mmb_response(true, true);
669 }
670
671 }
672
673 if(!function_exists('mmb_more_reccurences')){
674 //Backup Tasks
675 add_filter('cron_schedules', 'mmb_more_reccurences');
676 function mmb_more_reccurences($schedules) {
677 $schedules['halfminute'] = array('interval' => 30, 'display' => 'Once in a half minute');
678 $schedules['minutely'] = array('interval' => 60, 'display' => 'Once in a minute');
679 $schedules['fiveminutes'] = array('interval' => 300, 'display' => 'Once every five minutes');
680 $schedules['tenminutes'] = array('interval' => 600, 'display' => 'Once every ten minutes');
681
682 return $schedules;
683 }
684 }
685
686 add_action('mwp_backup_tasks', 'mwp_check_backup_tasks');
687
688 if( !function_exists('mwp_check_backup_tasks') ){
689 function mwp_check_backup_tasks() {
690 global $mmb_core, $_wp_using_ext_object_cache;
691 $_wp_using_ext_object_cache = false;
692
693 $mmb_core->get_backup_instance();
694 $mmb_core->backup_instance->check_backup_tasks();
695 }
696 }
697
698 if (!wp_next_scheduled('mwp_notifications')) {
699 wp_schedule_event( time(), 'twicedaily', 'mwp_notifications' );
700 }
701 add_action('mwp_notifications', 'mwp_check_notifications');
702
703
704
705 if( !function_exists('mwp_check_notifications') ){
706 function mwp_check_notifications() {
707 global $mmb_core, $_wp_using_ext_object_cache;
708 $_wp_using_ext_object_cache = false;
709
710 $mmb_core->get_stats_instance();
711 $mmb_core->stats_instance->check_notifications();
712 }
713 }
714
715
716 if( !function_exists('mmb_get_plugins_themes') ){
717 function mmb_get_plugins_themes($params) {
718 global $mmb_core;
719 $mmb_core->get_installer_instance();
720 $return = $mmb_core->installer_instance->get($params);
721 mmb_response($return, true);
722 }
723 }
724
725 if( !function_exists('mmb_edit_plugins_themes') ){
726 function mmb_edit_plugins_themes($params) {
727 global $mmb_core;
728 $mmb_core->get_installer_instance();
729 $return = $mmb_core->installer_instance->edit($params);
730 mmb_response($return, true);
731 }
732 }
733
734 if( !function_exists('mmb_worker_brand')){
735 function mmb_worker_brand($params) {
736 update_option("mwp_worker_brand",$params['brand']);
737 mmb_response(true, true);
738 }
739 }
740
741 if( !function_exists('mmb_maintenance_mode')){
742 function mmb_maintenance_mode( $params ) {
743 global $wp_object_cache;
744
745 $default = get_option('mwp_maintenace_mode');
746 $params = empty($default) ? $params : array_merge($default, $params);
747 update_option("mwp_maintenace_mode", $params);
748
749 if(!empty($wp_object_cache))
750 @$wp_object_cache->flush();
751 mmb_response(true, true);
752 }
753 }
754
755 if( !function_exists('mmb_plugin_actions') ){
756 function mmb_plugin_actions() {
757 global $mmb_actions, $mmb_core;
758
759 if(!empty($mmb_actions)){
760 global $_mmb_plugin_actions;
761 if(!empty($_mmb_plugin_actions)){
762 $failed = array();
763 foreach($_mmb_plugin_actions as $action => $params){
764 if(isset($mmb_actions[$action]))
765 call_user_func($mmb_actions[$action], $params);
766 else
767 $failed[] = $action;
768 }
769 if(!empty($failed)){
770 $f = implode(', ', $failed);
771 $s = count($f) > 1 ? 'Actions "' . $f . '" do' : 'Action "' . $f . '" does';
772 mmb_response($s.' not exist. Please update your Worker plugin.', false);
773 }
774
775 }
776 }
777
778 global $pagenow, $current_user, $mmode;
779 if( !is_admin() && !in_array($pagenow, array( 'wp-login.php' ))){
780 $mmode = get_option('mwp_maintenace_mode');
781 if( !empty($mmode) ){
782 if(isset($mmode['active']) && $mmode['active'] == true){
783 if(isset($current_user->data) && !empty($current_user->data) && isset($mmode['hidecaps']) && !empty($mmode['hidecaps'])){
784 $usercaps = array();
785 if(isset($current_user->caps) && !empty($current_user->caps)){
786 $usercaps = $current_user->caps;
787 }
788 foreach($mmode['hidecaps'] as $cap => $hide){
789 if(!$hide)
790 continue;
791
792 foreach($usercaps as $ucap => $val){
793 if($ucap == $cap){
794 ob_end_clean();
795 ob_end_flush();
796 die($mmode['template']);
797 }
798 }
799 }
800 } else
801 die($mmode['template']);
802 }
803 }
804 }
805 }
806 }
807
808 $mmb_core = new MMB_Core();
809
810 if(isset($_GET['auto_login']))
811 $mmb_core->automatic_login();
812
813 if (function_exists('register_activation_hook'))
814 register_activation_hook( __FILE__ , array( $mmb_core, 'install' ));
815
816 if (function_exists('register_deactivation_hook'))
817 register_deactivation_hook(__FILE__, array( $mmb_core, 'uninstall' ));
818
819 if (function_exists('add_action'))
820 add_action('init', 'mmb_plugin_actions', 99999);
821
822 if (function_exists('add_filter'))
823 add_filter('install_plugin_complete_actions','mmb_iframe_plugins_fix');
824
825 if( isset($_COOKIE[MMB_XFRAME_COOKIE]) ){
826 remove_action( 'admin_init', 'send_frame_options_header');
827 remove_action( 'login_init', 'send_frame_options_header');
828 }
829
830 ?>