Exemplo n.º 1
0
 function iwp_mmb_parse_request()
 {
     global $HTTP_RAW_POST_DATA, $iwp_mmb_activities_log;
     $HTTP_RAW_POST_DATA_LOCAL = NULL;
     $HTTP_RAW_POST_DATA_LOCAL = file_get_contents('php://input');
     if (empty($HTTP_RAW_POST_DATA_LOCAL)) {
         if (isset($HTTP_RAW_POST_DATA)) {
             $HTTP_RAW_POST_DATA_LOCAL = $HTTP_RAW_POST_DATA;
         }
     }
     ob_start();
     global $current_user, $iwp_mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache;
     $data = base64_decode($HTTP_RAW_POST_DATA_LOCAL);
     if ($data) {
         //$num = @extract(unserialize($data));
         $unserialized_data = @unserialize($data);
         if (isset($unserialized_data['params'])) {
             $unserialized_data['params'] = iwp_mmb_filter_params($unserialized_data['params']);
         }
         $iwp_action = $unserialized_data['iwp_action'];
         $params = $unserialized_data['params'];
         $id = $unserialized_data['id'];
         $signature = $unserialized_data['signature'];
         if (isset($unserialized_data['is_save_activity_log'])) {
             $is_save_activity_log = $unserialized_data['is_save_activity_log'];
         }
         $GLOBALS['activities_log_datetime'] = $unserialized_data['activities_log_datetime'];
     }
     if (isset($iwp_action)) {
         if (!defined('IWP_AUTHORISED_CALL')) {
             define('IWP_AUTHORISED_CALL', 1);
         }
         if (function_exists('register_shutdown_function')) {
             register_shutdown_function("iwp_mmb_shutdown");
         }
         $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'] = microtime(1);
         error_reporting(E_ALL ^ E_NOTICE);
         @ini_set("display_errors", 1);
         iwp_mmb_backup_db_changes();
         run_hash_change_process();
         $action = $iwp_action;
         $_wp_using_ext_object_cache = false;
         @set_time_limit(600);
         if (!$iwp_mmb_core->check_if_user_exists($params['username'])) {
             iwp_mmb_response(array('error' => 'Username <b>' . $params['username'] . '</b> does not have administrative access. Enter the correct username in the site options.', 'error_code' => 'username_does_not_have_administrative_access'), false);
         }
         if ($action == 'add_site') {
             $params['is_save_activity_log'] = $is_save_activity_log;
             iwp_mmb_add_site($params);
             iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
         }
         if ($action == 'readd_site') {
             $params['id'] = $id;
             $params['signature'] = $signature;
             $params['is_save_activity_log'] = $is_save_activity_log;
             iwp_mmb_readd_site($params);
             iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
         }
         $auth = $iwp_mmb_core->authenticate_message($action . $id, $signature, $id);
         if ($auth === true) {
             if ($action == 'maintain_site') {
                 iwp_mmb_maintain_site($params);
                 iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
             }
             @ignore_user_abort(true);
             $GLOBALS['IWP_CLIENT_HISTORY_ID'] = $id;
             if (isset($params['username']) && !is_user_logged_in()) {
                 $user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : get_userdatabylogin($params['username']);
                 wp_set_current_user($user->ID);
                 //For WPE or Reload Data
                 //if(@getenv('IS_WPE') || $iwp_action == 'get_stats')
                 $SET_14_DAYS_VALIDITY = true;
                 wp_set_auth_cookie($user->ID, $SET_14_DAYS_VALIDITY);
             }
             if ($action == 'get_cookie') {
                 iwp_mmb_response(true, true);
             }
             /* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
             if (strlen(trim($wp_db_version)) && !defined('ACX_PLUGIN_DIR')) {
                 if (get_option('db_version') != $wp_db_version) {
                     /* in multisite network, please update database manualy */
                     if (empty($wpmu_version) || function_exists('is_multisite') && !is_multisite()) {
                         if (!function_exists('wp_upgrade')) {
                             include_once ABSPATH . 'wp-admin/includes/upgrade.php';
                         }
                         ob_clean();
                         @wp_upgrade();
                         @do_action('after_db_upgrade');
                         ob_end_clean();
                     }
                 }
             }
             if (isset($params['secure'])) {
                 if ($decrypted = $iwp_mmb_core->_secure_data($params['secure'])) {
                     $decrypted = maybe_unserialize($decrypted);
                     if (is_array($decrypted)) {
                         foreach ($decrypted as $key => $val) {
                             if (!is_numeric($key)) {
                                 $params[$key] = $val;
                             }
                         }
                         unset($params['secure']);
                     } else {
                         $params['secure'] = $decrypted;
                     }
                 } elseif (isset($params['secure']['account_info'])) {
                     $params['account_info'] = $params['secure']['account_info'];
                 }
             }
             if (!$iwp_mmb_core->register_action_params($action, $params)) {
                 global $_iwp_mmb_plugin_actions;
                 $_iwp_mmb_plugin_actions[$action] = $params;
             }
             $iwp_mmb_activities_log->iwp_mmb_update_is_save_activity_log($is_save_activity_log);
             $iwp_mmb_activities_log->iwp_mmb_save_options_for_activity_log('parse_request');
         } else {
             iwp_mmb_response($auth, false);
         }
     } else {
         //IWP_MMB_Stats::set_hit_count();
         // $GLOBALS['HTTP_RAW_POST_DATA'] =  $HTTP_RAW_POST_DATA_LOCAL;
         $HTTP_RAW_POST_DATA = $HTTP_RAW_POST_DATA_LOCAL;
     }
     ob_end_clean();
 }
 function clone_restore_options($clone_restore_options)
 {
     global $wpdb;
     $table = $GLOBALS['table_prefix'] . 'iwp_backup_status';
     $wpdb->query("SHOW TABLES LIKE '" . $table . "'");
     if ($wpdb->num_rows == 1) {
         $delete = $wpdb->query("DROP TABLE '" . $table . "' ");
     }
     iwp_mmb_backup_db_changes();
     if (!empty($clone_restore_options['iwp_client_backup_tasks'])) {
         $this->insertBackupStatusContens($clone_restore_options['iwp_client_backup_tasks']);
     }
     return true;
 }