public function import_settings()
 {
     $file_url = base64_decode($_POST['file_url']);
     $temporary_file = "";
     try {
         include_once ABSPATH . 'wp-admin/includes/file.php';
         //Contains download_url
         $temporary_file = download_url($file_url);
         if (is_wp_error($temporary_file)) {
             throw new Exception('Error: ' . $temporary_file->get_error_message());
         } else {
             if ($this->import_seo_settings($temporary_file)) {
                 $information['success'] = true;
             } else {
                 throw new Exception(__('Settings could not be imported:', 'wordpress-seo'));
             }
         }
     } catch (Exception $e) {
         $information['error'] = $e->getMessage();
     }
     if (file_exists($temporary_file)) {
         unlink($temporary_file);
     }
     MainWPHelper::write($information);
 }
 public function action()
 {
     $information = array();
     if (function_exists('mainwp_wp_stream_query') && class_exists('MainWP_WP_Stream')) {
         self::$mainwpChildReports = true;
     } else {
         if (function_exists('wp_stream_query') && class_exists('WP_Stream')) {
             self::$mainwpChildReports = false;
         } else {
             $information['error'] = 'NO_STREAM';
             MainWPHelper::write($information);
         }
     }
     if (isset($_POST['mwp_action'])) {
         switch ($_POST['mwp_action']) {
             case "save_sucuri_stream":
                 $information = $this->save_sucuri_stream();
                 break;
             case "save_backup_stream":
                 $information = $this->save_backup_stream();
                 break;
             case "get_stream":
                 $information = $this->get_stream();
                 break;
             case "set_showhide":
                 $information = $this->set_showhide();
                 break;
         }
     }
     MainWPHelper::write($information);
 }
 public function action()
 {
     $information = array();
     switch ($_POST['action']) {
         case 'update_branding':
             $information = $this->update_branding();
             break;
     }
     MainWPHelper::write($information);
 }
 public function action()
 {
     $information = array();
     if (!class_exists('WooCommerce')) {
         $information['error'] = 'NO_WOOCOMMERCE';
         MainWPHelper::write($information);
     }
     $is_ver220 = $this->is_version_220();
     if (isset($_POST['mwp_action'])) {
         switch ($_POST['mwp_action']) {
             case "sync_data":
                 $information = !$is_ver220 ? $this->sync_data() : $this->sync_data_two();
                 break;
             case "report_data":
                 $information = !$is_ver220 ? $this->report_data() : $this->report_data_two();
                 break;
         }
     }
     MainWPHelper::write($information);
 }
 public function action()
 {
     $information = array();
     if (!defined('GPI_ACTIVE')) {
         $information['error'] = 'NO_GOOGLEPAGESPEED';
         MainWPHelper::write($information);
     }
     if (isset($_POST['mwp_action'])) {
         switch ($_POST['mwp_action']) {
             case "save_settings":
                 $information = $this->save_settings();
                 break;
             case "set_showhide":
                 $information = $this->set_showhide();
                 break;
             case "sync_data":
                 $information = $this->sync_data();
                 break;
         }
     }
     MainWPHelper::write($information);
 }
 public function action()
 {
     $information = array();
     if (!defined('BLC_ACTIVE') || !function_exists('blc_init')) {
         $information['error'] = 'NO_BROKENLINKSCHECKER';
         MainWPHelper::write($information);
     }
     blc_init();
     if (isset($_POST['mwp_action'])) {
         switch ($_POST['mwp_action']) {
             case "set_showhide":
                 $information = $this->set_showhide();
                 break;
             case "sync_data":
                 $information = $this->sync_data();
                 break;
             case "edit_link":
                 $information = $this->edit_link();
                 break;
             case "unlink":
                 $information = $this->unlink();
                 break;
             case "set_dismiss":
                 $information = $this->set_link_dismissed();
                 break;
             case "discard":
                 $information = $this->discard();
                 break;
             case "save_settings":
                 $information = $this->save_settings();
                 break;
             case "force_recheck":
                 $information = $this->force_recheck();
                 break;
         }
     }
     MainWPHelper::write($information);
 }
 public function action()
 {
     $information = array();
     if (!class_exists('ITSEC_Core')) {
         $information['error'] = 'NO_ITHEME_SECURITY';
         MainWPHelper::write($information);
     }
     if (isset($_POST['mwp_action'])) {
         switch ($_POST['mwp_action']) {
             case "set_showhide":
                 $information = $this->set_showhide();
                 break;
             case "save_settings":
                 $information = $this->save_settings();
                 break;
             case "whitelist":
                 $information = $this->whitelist();
                 break;
             case "whitelist_release":
                 $information = $this->whitelist_release();
                 break;
             case "backup_db":
                 $information = $this->backup_db();
                 break;
             case "admin_user":
                 $information = $this->admin_user();
                 break;
                 //                case "content_dir":
                 //                    $information = $this->process_directory();
                 //                break;
             //                case "content_dir":
             //                    $information = $this->process_directory();
             //                break;
             case "database_prefix":
                 $information = $this->process_database_prefix();
                 break;
             case "api_key":
                 $information = $this->api_key();
                 break;
             case "reset_api_key":
                 $information = $this->reset_api_key();
                 break;
             case "malware_scan":
                 $information = $this->malware_scan();
                 break;
             case "malware_get_scan_results":
                 $information = $this->malware_get_scan_results();
                 break;
             case "clear_all_logs":
                 $information = $this->purge_logs();
                 break;
             case "file_check":
                 $information = $this->file_check();
                 break;
             case "release_lockout":
                 $information = $this->release_lockout();
                 break;
         }
     }
     MainWPHelper::write($information);
 }
 static function error($error)
 {
     $information['error'] = $error;
     MainWPHelper::write($information);
 }
 function check_schedule()
 {
     $schedule_id = isset($_POST['schedule_id']) && !empty($_POST['schedule_id']) ? $_POST['schedule_id'] : "";
     if (empty($schedule_id)) {
         $information = array('error' => 'Empty schedule id');
         MainWPHelper::write($information);
     } else {
         $schedule_id = sanitize_text_field(urldecode($schedule_id));
         HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
         if (!HM\BackUpWordPress\Schedules::get_instance()->get_schedule($schedule_id)) {
             $information = array('result' => 'NOTFOUND');
             MainWPHelper::write($information);
         }
     }
     return $schedule_id;
 }
 public function action()
 {
     $information = array();
     if (!self::isActivated()) {
         $information['error'] = 'NO_WPROCKET';
         MainWPHelper::write($information);
     }
     if (isset($_POST['mwp_action'])) {
         MainWPHelper::update_option('mainwp_wprocket_ext_enabled', "Y");
         switch ($_POST['mwp_action']) {
             case "set_showhide":
                 $information = $this->set_showhide();
                 break;
             case "purge_cloudflare":
                 $information = $this->purge_cloudflare();
                 break;
             case "purge_all":
                 $information = $this->purge_cache_all();
                 break;
             case "preload_cache":
                 $information = $this->preload_cache();
                 break;
             case "save_settings":
                 $information = $this->save_settings();
                 break;
         }
     }
     MainWPHelper::write($information);
 }
 public function action()
 {
     if (!$this->is_backwpup_installed) {
         MainWPHelper::write(array('error' => __('Please install BackWPup plugin on child website', $this->plugin_translate)));
         return;
     }
     error_reporting(0);
     function mainwp_backwpup_handle_fatal_error()
     {
         $error = error_get_last();
         if (isset($error['type']) && $error['type'] == E_ERROR && isset($error['message'])) {
             die('<mainwp>' . base64_encode(serialize(array('error' => 'MainWPChild fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file']))) . '</mainwp>');
         } else {
             if (!empty(MainWPChildBackWPup::$information)) {
                 die('<mainwp>' . base64_encode(serialize(MainWPChildBackWPup::$information)) . '</mainwp>');
             } else {
                 die('<mainwp>' . base64_encode(array('error' => 'Missing information array inside fatal_error')) . '</mainwp>');
             }
         }
     }
     register_shutdown_function("mainwp_backwpup_handle_fatal_error");
     $information = array();
     if (!isset($_POST['action'])) {
         $information = array('error' => __('Missing action.', $this->plugin_translate));
     } else {
         switch ($_POST['action']) {
             case 'backwpup_update_settings':
                 $information = $this->update_settings();
                 break;
             case 'backwpup_insert_or_update_jobs':
                 $information = $this->insert_or_update_jobs();
                 break;
             case 'backwpup_insert_or_update_jobs_global':
                 $information = $this->insert_or_update_jobs_global();
                 break;
             case 'backwpup_get_child_tables':
                 $information = $this->get_child_tables();
                 break;
             case 'backwpup_get_job_files':
                 $information = $this->get_job_files();
                 break;
             case 'backwpup_destination_email_check_email':
                 $information = $this->destination_email_check_email();
                 break;
             case 'backwpup_backup_now':
                 $information = $this->backup_now();
                 break;
             case 'backwpup_ajax_working':
                 $information = $this->ajax_working();
                 break;
             case 'backwpup_backup_abort':
                 $information = $this->backup_abort();
                 break;
             case 'backwpup_tables':
                 $information = $this->tables();
                 break;
             case 'backwpup_view_log':
                 $information = $this->view_log();
                 break;
             case 'backwpup_delete_log':
                 $information = $this->delete_log();
                 break;
             case 'backwpup_delete_job':
                 $information = $this->delete_job();
                 break;
             case 'backwpup_delete_backup':
                 $information = $this->delete_backup();
                 break;
             case 'backwpup_information':
                 $information = $this->information();
                 break;
             case 'backwpup_wizard_system_scan':
                 $information = $this->wizard_system_scan();
                 break;
             case 'backwpup_is_pro':
                 $information = array('is_pro' => $this->is_backwpup_pro);
                 break;
             case 'backwpup_show_hide':
                 $information = $this->show_hide();
                 break;
             default:
                 $information = array('error' => __('Wrong action.', $this->plugin_translate));
         }
     }
     MainWPChildBackWPup::$information = $information;
     exit;
 }
 function update_values()
 {
     $uniId = isset($_POST['uniqueId']) ? $_POST['uniqueId'] : "";
     MainWPHelper::update_option('mainwp_child_uniqueId', $uniId);
     MainWPHelper::write(array('result' => 'ok'));
 }
 function settings_tools()
 {
     if (isset($_POST['action'])) {
         switch ($_POST['action']) {
             case 'force_destroy_sessions':
                 if (get_current_user_id() == 0) {
                     MainWPHelper::write(array('error' => __('Cannot get user_id', 'mainwp-child')));
                 }
                 wp_destroy_all_sessions();
                 $sessions = wp_get_all_sessions();
                 if (empty($sessions)) {
                     MainWPHelper::write(array('success' => 1));
                 } else {
                     MainWPHelper::write(array('error' => __('Cannot destroy sessions', 'mainwp-child')));
                 }
                 break;
             default:
                 MainWPHelper::write(array('error' => __('Invalid action', 'mainwp-child')));
         }
     } else {
         MainWPHelper::write(array('error' => __('Missing action', 'mainwp-child')));
     }
 }
 public function action()
 {
     $information = array();
     if (!self::isActivatedUpdraftplus()) {
         $information['error'] = 'NO_UPDRAFTPLUS';
         MainWPHelper::write($information);
     }
     global $updraftplus;
     if (empty($updraftplus) && class_exists('UpdraftPlus')) {
         $updraftplus = new UpdraftPlus();
     }
     if (empty($updraftplus)) {
         $information['error'] = 'Error empty object';
         MainWPHelper::write($information);
     }
     if (isset($_POST['mwp_action'])) {
         if (get_option('mainwp_updraftplus_ext_enabled') !== 'Y') {
             MainWPHelper::update_option('mainwp_updraftplus_ext_enabled', "Y", 'yes');
         }
         switch ($_POST['mwp_action']) {
             case "set_showhide":
                 $information = $this->set_showhide();
                 break;
             case "save_settings":
                 $information = $this->save_settings();
                 break;
             case "addons_connect":
                 $information = $this->addons_connect();
                 break;
             case "backup_now":
                 $information = $this->backup_now();
                 break;
             case "activejobs_list":
                 $information = $this->activejobs_list();
                 break;
             case "diskspaceused":
                 $information = $this->diskspaceused();
                 break;
             case "last_backup_html":
                 $information = $this->last_backup_html();
                 break;
             case "reload_data":
                 $information = $this->get_updraft_data();
                 break;
             case "next_scheduled_backups":
                 $information = $this->next_scheduled_backups();
                 break;
                 //                case "rebuildBackupHistory":
                 //                    $information = $this->rebuildBackupHistory();
                 //                break;
             //                case "rebuildBackupHistory":
             //                    $information = $this->rebuildBackupHistory();
             //                break;
             case "forcescheduledresumption":
                 $information = $this->forceScheduledResumption();
                 break;
             case "fetch_updraft_log":
                 $information = $this->fetch_updraft_log();
                 break;
             case "activejobs_delete":
                 $information = $this->activejobs_delete();
                 break;
             case "historystatus":
                 $information = $this->historystatus();
                 break;
             case "deleteset":
                 $information = $this->deleteset();
                 break;
             case "updraft_download_backup":
                 $information = $this->updraft_download_backup();
                 break;
             case "restore_alldownloaded":
                 $information = $this->restore_alldownloaded();
                 break;
             case "restorebackup":
                 $information = $this->restoreBackup();
                 break;
             case "extradbtestconnection":
                 $information = $this->extradb_testconnection();
                 break;
             case "delete_old_dirs":
                 $information = $this->delete_old_dirs_go();
                 break;
         }
     }
     MainWPHelper::write($information);
 }
 public function action()
 {
     $information = array();
     if (!class_exists('wordfence') || !class_exists('wfScanEngine')) {
         $information['error'] = 'NO_WORDFENCE';
         MainWPHelper::write($information);
     }
     if (isset($_POST['mwp_action'])) {
         switch ($_POST['mwp_action']) {
             case "start_scan":
                 $information = $this->start_scan();
                 break;
             case "set_showhide":
                 $information = $this->set_showhide();
                 break;
             case "get_log":
                 $information = $this->get_log();
                 break;
             case "update_log":
                 $information = $this->update_log();
                 break;
             case "get_summary":
                 $information = $this->get_summary();
                 break;
             case "load_issues":
                 $information = $this->load_issues();
                 break;
             case "update_all_issues":
                 $information = $this->update_all_issues();
                 break;
             case "update_issues_status":
                 $information = $this->update_issues_status();
                 break;
             case "delete_issues":
                 $information = $this->delete_issues();
                 break;
             case "bulk_operation":
                 $information = $this->bulk_operation();
                 break;
             case "delete_file":
                 $information = $this->delete_file();
                 break;
             case "restore_file":
                 $information = $this->restore_file();
                 break;
             case "save_setting":
                 $information = $this->save_setting();
                 break;
             case "ticker":
                 $information = $this->ticker();
                 break;
             case "reverse_lookup":
                 $information = $this->reverse_lookup();
                 break;
             case "update_live_traffic":
                 $information = $this->update_live_traffic();
                 break;
             case "block_ip":
                 $information = $this->block_ip();
                 break;
             case "unblock_ip":
                 $information = $this->unblock_ip();
                 break;
             case "load_static_panel":
                 $information = $this->load_static_panel();
                 break;
             case "downgrade_license":
                 $information = $this->downgrade_license();
                 break;
         }
     }
     MainWPHelper::write($information);
 }