function save_settings()
 {
     global $itsec_globals;
     if (!class_exists('ITSEC_Lib')) {
         require trailingslashit($itsec_globals['plugin_dir']) . 'core/class-itsec-lib.php';
     }
     MainWPHelper::update_option('mainwp_ithemes_ext_enabled', "Y", 'yes');
     $settings = unserialize(base64_decode($_POST['settings']));
     $updated = false;
     $rewrites_changed = false;
     if (isset($settings['itsec_global'])) {
         //            $old_settings = get_site_option( 'itsec_global' );
         //            // keep current value
         //            $settings['itsec_global']['log_location'] = $old_settings['log_location'];
         if (update_site_option('itsec_global', $settings['itsec_global'])) {
             if (isset($settings['itsec_global']['write_files']) && $settings['itsec_global']['write_files'] === true) {
                 add_site_option('itsec_rewrites_changed', true);
                 $rewrites_changed = true;
             }
             $updated = true;
         }
     }
     if (isset($settings['itsec_away_mode'])) {
         if (update_site_option('itsec_away_mode', $settings['itsec_away_mode'])) {
             $updated = true;
         }
     }
     if (isset($settings['itsec_backup'])) {
         $backup = get_site_option('itsec_backup');
         if ($backup !== false && isset($backup['last_run'])) {
             $settings['itsec_backup']['last_run'] = $backup['last_run'];
         } else {
             unset($settings['itsec_backup']['last_run']);
         }
         if (update_site_option('itsec_backup', $settings['itsec_backup'])) {
             $updated = true;
         }
     }
     if (isset($settings['itsec_ban_users'])) {
         $old_settings = get_site_option('itsec_ban_users');
         if (update_site_option('itsec_ban_users', $settings['itsec_ban_users'])) {
             $input = $settings['itsec_ban_users'];
             if ($input['host_list'] !== $old_settings['host_list'] || $input['enabled'] !== $old_settings['enabled'] || $input['default'] !== $old_settings['default'] || $input['agent_list'] !== $old_settings['agent_list']) {
                 if (!$rewrites_changed) {
                     add_site_option('itsec_rewrites_changed', true);
                 }
             }
             $updated = true;
         }
     }
     if (isset($settings['itsec_brute_force'])) {
         if (update_site_option('itsec_brute_force', $settings['itsec_brute_force'])) {
             $updated = true;
         }
     }
     if (isset($settings['itsec_file_change'])) {
         $file_change = get_site_option('itsec_file_change');
         if ($file_change !== false && isset($file_change['last_run'])) {
             $settings['itsec_file_change']['last_run'] = $file_change['last_run'];
         } else {
             unset($settings['itsec_file_change']['last_run']);
         }
         if ($file_change !== false && isset($file_change['last_chunk'])) {
             $settings['itsec_file_change']['last_chunk'] = $file_change['last_chunk'];
         } else {
             unset($settings['itsec_file_change']['last_chunk']);
         }
         if (update_site_option('itsec_file_change', $settings['itsec_file_change'])) {
             $updated = true;
         }
     }
     if (isset($settings['itsec_four_oh_four'])) {
         if (update_site_option('itsec_four_oh_four', $settings['itsec_four_oh_four'])) {
             $updated = true;
         }
     }
     if (isset($settings['itsec_hide_backend'])) {
         $old_settings = get_site_option('itsec_hide_backend');
         if (update_site_option('itsec_hide_backend', $settings['itsec_hide_backend'])) {
             $input = $settings['itsec_hide_backend'];
             if ($input['slug'] !== $old_settings['slug'] || $input['register'] !== $old_settings['register'] || $input['enabled'] !== $old_settings['enabled']) {
                 if (!$rewrites_changed) {
                     add_site_option('itsec_rewrites_changed', true);
                 }
             }
             if ($input['slug'] != $old_settings['slug'] && $input['enabled'] === true) {
                 add_site_option('itsec_hide_backend_new_slug', $input['slug']);
             }
             $updated = true;
         }
     }
     if (isset($settings['itsec_ipcheck'])) {
         if (update_site_option('itsec_ipcheck', $settings['itsec_ipcheck'])) {
             $updated = true;
         }
     }
     if (isset($settings['itsec_malware'])) {
         if (update_site_option('itsec_malware', $settings['itsec_malware'])) {
             $updated = true;
         }
     }
     if (isset($settings['itsec_ssl'])) {
         if (update_site_option('itsec_ssl', $settings['itsec_ssl'])) {
             $updated = true;
         }
     }
     if (isset($settings['itsec_strong_passwords'])) {
         if (update_site_option('itsec_strong_passwords', $settings['itsec_strong_passwords'])) {
             $updated = true;
         }
     }
     if (isset($settings['itsec_tweaks'])) {
         $old_settings = get_site_option('itsec_tweaks');
         $is_safe = ITSEC_Lib::safe_jquery_version() === true;
         $raw_version = get_site_option('itsec_jquery_version');
         if ($is_safe !== true && $raw_version !== false) {
             $enable_set_safe_jquery = true;
         }
         if (!$enable_set_safe_jquery) {
             $settings['itsec_tweaks']['safe_jquery'] = 0;
         }
         if (update_site_option('itsec_tweaks', $settings['itsec_tweaks'])) {
             if ($input['protect_files'] !== $old_settings['protect_files'] || $input['directory_browsing'] !== $old_settings['directory_browsing'] || $input['request_methods'] !== $old_settings['request_methods'] || $input['suspicious_query_strings'] !== $old_settings['suspicious_query_strings'] || $input['non_english_characters'] !== $old_settings['non_english_characters'] || $input['comment_spam'] !== $old_settings['comment_spam'] || $input['disable_xmlrpc'] !== $old_settings['disable_xmlrpc'] || $input['uploads_php'] !== $old_settings['uploads_php']) {
                 if (!$rewrites_changed) {
                     add_site_option('itsec_rewrites_changed', true);
                 }
             }
             $updated = true;
         }
     }
     $site_status = array('username_admin_exists' => username_exists('admin') ? 1 : 0, 'user_id1_exists' => ITSEC_Lib::user_id_exists(1) ? 1 : 0, 'backup' => $this->backup_status(), 'permalink_structure' => get_option('permalink_structure'), 'is_multisite' => is_multisite() ? 1 : 0, 'users_can_register' => get_site_option('users_can_register') ? 1 : 0, 'force_ssl_login' => defined('FORCE_SSL_LOGIN') && FORCE_SSL_LOGIN === true ? 1 : 0, 'force_ssl_admin' => defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN === true ? 1 : 0, 'server_nginx' => ITSEC_Lib::get_server() == 'nginx' ? 1 : 0, 'lockouts_host' => $this->get_lockouts('host', true), 'lockouts_user' => $this->get_lockouts('user', true), 'lockouts_username' => $this->get_lockouts('username', true));
     $out = array();
     if ($updated) {
         $out['result'] = 'success';
     } else {
         $out['result'] = 'noupdate';
     }
     $out['site_status'] = $site_status;
     return $out;
 }
 public function readConfigurationFile()
 {
     $configContents = $this->getConfigContents();
     if ($configContents === FALSE) {
         throw new Exception(__('Cant read configuration file from backup', 'mainwp-child'));
     }
     $this->config = unserialize(base64_decode($configContents));
     if (isset($this->config['plugins'])) {
         MainWPHelper::update_option('mainwp_temp_clone_plugins', $this->config['plugins']);
     }
     if (isset($this->config['themes'])) {
         MainWPHelper::update_option('mainwp_temp_clone_themes', $this->config['themes']);
     }
 }
    public static function showWarnings()
    {
        if (stristr($_SERVER["REQUEST_URI"], 'MainWPChildServerInformation')) {
            return;
        }
        $conflicts = self::getConflicts();
        $warnings = self::getWarnings();
        $dismissWarnings = get_option('mainwp_child_dismiss_warnings');
        if (!is_array($dismissWarnings)) {
            $dismissWarnings = array();
        }
        if (isset($dismissWarnings['warnings']) && $dismissWarnings['warnings'] >= $warnings) {
            $warnings = 0;
        }
        if (isset($dismissWarnings['conflicts']) && MainWPHelper::containsAll($dismissWarnings['conflicts'], $conflicts)) {
            $conflicts = array();
        }
        if ($warnings == 0 && count($conflicts) == 0) {
            return;
        }
        if ($warnings > 0) {
            $dismissWarnings['warnings'] = 0;
        }
        if (count($conflicts) > 0) {
            $dismissWarnings['conflicts'] = array();
        }
        MainWPHelper::update_option('mainwp_child_dismiss_warnings', $dismissWarnings);
        $itheme_ext_activated = get_option('mainwp_ithemes_ext_activated') == 'Y' ? true : false;
        if ($itheme_ext_activated) {
            foreach ($conflicts as $key => $cf) {
                if ($cf === "iThemes Security") {
                    unset($conflicts[$key]);
                }
            }
            if ($warnings == 0 && count($conflicts) == 0) {
                return;
            }
        }
        ?>
    <script language="javascript">
        dismiss_warnings = function(pElement, pAction) {
            var table = jQuery(pElement.parents('table')[0]);
            pElement.parents('tr')[0].remove();
            if (table.find('tr').length == 0)
            {
                jQuery('#mainwp-child_server_warnings').hide();
            }

            var data = {
                action:'mainwp-child_dismiss_warnings',
                what: pAction
            };

            jQuery.ajax({
                type:"POST",
                url: ajaxurl,
                data: data,
                success: function(resp) { },
                error: function() { },
                dataType: 'json'});

            return false;
        };
        jQuery(document).on('click', '#mainwp-child-connect-warning-dismiss', function() { return dismiss_warnings(jQuery(this), 'warning'); });
        jQuery(document).on('click', '#mainwp-child-all-pages-warning-dismiss', function() { return dismiss_warnings(jQuery(this), 'conflict'); });
    </script>
    <style type="text/css">
    .mainwp-child_info-box-red-warning {
    background-color: rgba(187, 114, 57, 0.2) !important;
    border-bottom: 4px solid #bb7239 !important;
    border-top: 1px solid #bb7239 !important;
    border-left: 1px solid #bb7239 !important;
    border-right: 1px solid #bb7239 !important;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    border-radius: 3px;
    margin: 1em 0 !important;

    background-image: url('<?php 
        echo plugins_url('images/mainwp-icon-orange.png', dirname(__FILE__));
        ?>
') !important;
    background-position: 1.5em 50% !important;
    background-repeat: no-repeat !important;
    background-size: 30px !important;
    }
    .mainwp-child_info-box-red-warning table {
        background-color: rgba(187, 114, 57, 0) !important;
        border: 0px;
        padding-left: 4.5em;
        background-position: 1.5em 50% !important;
        background-repeat: no-repeat !important;
        background-size: 30px !important;
    }
     </style>

        <div class="updated mainwp-child_info-box-red-warning" id="mainwp-child_server_warnings">
            <table id="mainwp-table" class="wp-list-table widefat" cellspacing="0">
                    <tbody id="the-sites-list" class="list:sites">
            <?php 
        $warning = '';
        if ($warnings > 0) {
            $warning .= '<tr><td colspan="2">This site may not connect to your dashboard or may have other issues. Check your <a href="admin.php?page=MainWPChildServerInformation">MainWP Server Information page</a> to review and <a href="http://docs.mainwp.com/child-site-issues/">check here for more information on possible fixes</a></td><td style="text-align: right;"><a href="#" id="mainwp-child-connect-warning-dismiss">Dismiss</a></td></tr>';
        }
        if (count($conflicts) > 0) {
            $warning .= '<tr><td colspan="2">';
            if (count($conflicts) == 1) {
                $warning .= '"' . $conflicts[0] . '" is';
            } else {
                $warning .= '"' . join('", "', $conflicts) . '" are';
            }
            $warning .= ' installed on this site. This is known to have a potential conflict with MainWP functions. <a href="http://docs.mainwp.com/known-plugin-conflicts/">Please click this link for possible solutions</a></td><td style="text-align: right;"><a href="#" id="mainwp-child-all-pages-warning-dismiss">Dismiss</a></td></tr>';
        }
        echo $warning;
        ?>
                </tbody>
            </table>
          </div>
              <?php 
    }
 function save_settings()
 {
     MainWPHelper::update_option('mainwp_pagespeed_ext_enabled', "Y", 'yes');
     $current_values = get_option('gpagespeedi_options');
     if (is_array($current_values) && $current_values['last_run_finished'] == false) {
         return array('result' => 'RUNNING');
     }
     $settings = $_POST['settings'];
     $settings = unserialize(base64_decode($settings));
     if (is_array($settings)) {
         if (isset($settings['api_key']) && !empty($settings['api_key'])) {
             $current_values['google_developer_key'] = $settings['api_key'];
         }
         if (isset($settings['response_language'])) {
             $current_values['response_language'] = $settings['response_language'];
         }
         if (isset($_POST['strategy'])) {
             $current_values['strategy'] = $_POST['strategy'];
         }
         if (isset($settings['max_execution_time'])) {
             $current_values['max_execution_time'] = $settings['max_execution_time'];
         }
         if (isset($settings['delay_time'])) {
             $current_values['sleep_time'] = $settings['delay_time'];
         }
         if (isset($settings['log_exception'])) {
             $current_values['log_api_errors'] = $settings['log_exception'] ? true : false;
         }
         if (isset($settings['scan_technical'])) {
             $current_values['scan_method'] = $settings['scan_technical'];
         }
         if (isset($settings['report_expiration'])) {
             $current_values['recheck_interval'] = $settings['report_expiration'];
         }
         if (isset($settings['check_report'])) {
             if (is_array($settings['check_report'])) {
                 $current_values['check_pages'] = in_array('page', $settings['check_report']) ? true : false;
                 $current_values['check_posts'] = in_array('post', $settings['check_report']) ? true : false;
                 $current_values['check_categories'] = in_array('category', $settings['check_report']) ? true : false;
             } else {
                 $current_values['check_pages'] = $current_values['check_posts'] = $current_values['check_categories'] = false;
             }
         }
         if (isset($settings['delete_data']) && !empty($settings['delete_data'])) {
             $this->delete_data($settings['delete_data']);
         }
         if (update_option('gpagespeedi_options', $current_values)) {
             $information['result'] = 'SUCCESS';
         } else {
             $information['result'] = 'NOTCHANGE';
         }
     }
     $strategy = $current_values['strategy'];
     $result = $this->sync_data($strategy);
     $information['data'] = $result['data'];
     return $information;
 }
 function set_showhide()
 {
     MainWPHelper::update_option('mainwp_creport_ext_branding_enabled', "Y", 'yes');
     $hide = isset($_POST['showhide']) && $_POST['showhide'] === "hide" ? 'hide' : "";
     MainWPHelper::update_option('mainwp_creport_branding_stream_hide', $hide);
     $information['result'] = 'SUCCESS';
     return $information;
 }
 function set_showhide()
 {
     MainWPHelper::update_option('mainwp_linkschecker_ext_enabled', "Y", 'yes');
     $hide = isset($_POST['showhide']) && $_POST['showhide'] === "hide" ? 'hide' : "";
     MainWPHelper::update_option('mainwp_linkschecker_hide_plugin', $hide);
     $information['result'] = 'SUCCESS';
     return $information;
 }
 function set_showhide()
 {
     MainWPHelper::update_option('mainwp_backupwordpress_ext_enabled', "Y");
     $hide = isset($_POST['showhide']) && $_POST['showhide'] === "hide" ? 'hide' : "";
     MainWPHelper::update_option('mainwp_backupwordpress_hide_plugin', $hide);
     $information['result'] = 'SUCCESS';
     return $information;
 }
 protected function show_hide()
 {
     MainWPHelper::update_option('mainwp_backwpup_ext_enabled', "Y");
     $hide = isset($_POST['show_hide']) && $_POST['show_hide'] == "1" ? 'hide' : "";
     MainWPHelper::update_option('mainwp_backwpup_hide_plugin', $hide);
     return array('success' => 1);
 }
 function set_showhide()
 {
     $hide = isset($_POST['showhide']) && $_POST['showhide'] === "hide" ? 'hide' : "";
     MainWPHelper::update_option('mainwp_wprocket_hide_plugin', $hide);
     $information['result'] = 'SUCCESS';
     return $information;
 }
 public function sendClick()
 {
     $url = $this->server . 'admin-ajax.php';
     $clickData = get_option('mainwp_child_click_data');
     $key = get_option('mainwp_child_pubkey');
     if (!is_array($clickData)) {
         return false;
     }
     // send 1000 record per time to fix memory bug
     $sendNow = array();
     if (count($clickData) > 1000) {
         for ($i = 0; $i < 1000; $i++) {
             $sendNow[$i] = $clickData[$i];
         }
     } else {
         $sendNow = $clickData;
     }
     $timestamp = time();
     $signature = $this->createSignature($key, $timestamp, $sendNow);
     $params = array('headers' => array('Referer' => site_url()), 'body' => array('timestamp' => $timestamp, 'signature' => $signature, 'data' => base64_encode(serialize($sendNow)), 'action' => 'heatmapSendClick'));
     if (strpos($url, "https://") === 0) {
         $params['sslverify'] = FALSE;
     }
     $request = wp_remote_post($url, $params);
     if (is_array($request) && intval($request['body']) > 0) {
         if (count($clickData) > 1000) {
             $saveData = array();
             for ($i = 1000; $i < count($clickData); $i++) {
                 $saveData[$i] = $clickData[$i];
             }
             MainWPHelper::update_option('mainwp_child_click_data', $saveData);
         } else {
             delete_option('mainwp_child_click_data');
         }
     }
 }
예제 #11
0
 public static function cloneBackupExtract()
 {
     try {
         MainWPHelper::endSession();
         $file = isset($_POST['f']) ? $_POST['f'] : $_POST['file'];
         $testFull = false;
         if ($file == '') {
             $dirs = MainWPHelper::getMainWPDir('backup', false);
             $backupdir = $dirs[0];
             $files = glob($backupdir . 'download-*');
             $archiveFile = false;
             foreach ($files as $file) {
                 if (MainWPHelper::isArchive($file, 'download-')) {
                     $archiveFile = $file;
                     break;
                 }
             }
             if ($archiveFile === false) {
                 throw new Exception(__('No download file found', 'mainwp-child'));
             }
             $file = $archiveFile;
         } else {
             if (file_exists($file)) {
                 $testFull = true;
             } else {
                 $file = ABSPATH . $file;
                 if (!file_exists($file)) {
                     throw new Exception(__('Backup file not found', 'mainwp-child'));
                 }
                 $testFull = true;
             }
         }
         //return size in kb
         $cloneInstall = new MainWPCloneInstall($file);
         //todo: RS: refactor to get those plugins after install (after .18 release)
         $cloneInstall->readConfigurationFile();
         $plugins = get_option('mainwp_temp_clone_plugins');
         $themes = get_option('mainwp_temp_clone_themes');
         if ($testFull) {
             $cloneInstall->testDownload();
         }
         $cloneInstall->removeConfigFile();
         $cloneInstall->extractBackup();
         $pubkey = get_option('mainwp_child_pubkey');
         $uniqueId = get_option('mainwp_child_uniqueId');
         $server = get_option('mainwp_child_server');
         $nonce = get_option('mainwp_child_nonce');
         $nossl = get_option('mainwp_child_nossl');
         $nossl_key = get_option('mainwp_child_nossl_key');
         $sitesToClone = get_option('mainwp_child_clone_sites');
         $cloneInstall->install();
         $cloneInstall->updateWPConfig();
         //            $cloneInstall->update_option('mainwp_child_pubkey', $pubkey);
         //            $cloneInstall->update_option('mainwp_child_uniqueId', $uniqueId);
         //            $cloneInstall->update_option('mainwp_child_server', $server);
         //            $cloneInstall->update_option('mainwp_child_nonce', $nonce);
         //            $cloneInstall->update_option('mainwp_child_nossl', $nossl);
         //            $cloneInstall->update_option('mainwp_child_nossl_key', $nossl_key);
         //            $cloneInstall->update_option('mainwp_child_clone_sites', $sitesToClone);
         //            $cloneInstall->update_option('mainwp_child_clone_permalink', true);
         MainWPHelper::update_option('mainwp_child_pubkey', $pubkey, 'yes');
         MainWPHelper::update_option('mainwp_child_uniqueId', $uniqueId);
         MainWPHelper::update_option('mainwp_child_server', $server);
         MainWPHelper::update_option('mainwp_child_nonce', $nonce);
         MainWPHelper::update_option('mainwp_child_nossl', $nossl, 'yes');
         MainWPHelper::update_option('mainwp_child_nossl_key', $nossl_key);
         MainWPHelper::update_option('mainwp_child_clone_sites', $sitesToClone);
         if (!MainWPHelper::startsWith(basename($file), 'download-backup-')) {
             MainWPHelper::update_option('mainwp_child_restore_permalink', true, 'yes');
         } else {
             MainWPHelper::update_option('mainwp_child_clone_permalink', true, 'yes');
         }
         $cloneInstall->clean();
         if ($plugins !== false) {
             $out = array();
             if (is_array($plugins)) {
                 $dir = WP_CONTENT_DIR . '/plugins/';
                 $fh = @opendir($dir);
                 while ($entry = @readdir($fh)) {
                     if (!is_dir($dir . $entry)) {
                         continue;
                     }
                     if ($entry == '.' || $entry == '..') {
                         continue;
                     }
                     if (!in_array($entry, $plugins)) {
                         MainWPHelper::delete_dir($dir . $entry);
                     }
                 }
                 @closedir($fh);
             }
             delete_option('mainwp_temp_clone_plugins');
         }
         if ($themes !== false) {
             $out = array();
             if (is_array($themes)) {
                 $dir = WP_CONTENT_DIR . '/themes/';
                 $fh = @opendir($dir);
                 while ($entry = @readdir($fh)) {
                     if (!is_dir($dir . $entry)) {
                         continue;
                     }
                     if ($entry == '.' || $entry == '..') {
                         continue;
                     }
                     if (!in_array($entry, $themes)) {
                         MainWPHelper::delete_dir($dir . $entry);
                     }
                 }
                 @closedir($fh);
             }
             delete_option('mainwp_temp_clone_themes');
         }
         $output = array('result' => 'ok');
         //todo: remove old tables if other prefix?
         wp_logout();
         wp_set_current_user(0);
     } catch (Exception $e) {
         $output = array('error' => $e->getMessage());
     }
     //return size in kb
     die(json_encode($output));
 }
예제 #12
0
 function update_values()
 {
     $uniId = isset($_POST['uniqueId']) ? $_POST['uniqueId'] : "";
     MainWPHelper::update_option('mainwp_child_uniqueId', $uniId);
     MainWPHelper::write(array('result' => 'ok'));
 }
 public function update_branding()
 {
     $information = array();
     $settings = unserialize(base64_decode($_POST['settings']));
     if (!is_array($settings)) {
         return $information;
     }
     $current_extra_setting = $this->settings['extra_settings'];
     MainWPHelper::update_option('mainwp_branding_ext_enabled', "Y", 'yes');
     $header = array('name' => $settings['child_plugin_name'], 'description' => $settings['child_plugin_desc'], 'author' => $settings['child_plugin_author'], 'authoruri' => $settings['child_plugin_author_uri'], 'pluginuri' => $settings['child_plugin_uri']);
     MainWPHelper::update_option('mainwp_branding_preserve_branding', $settings['child_preserve_branding']);
     MainWPHelper::update_option('mainwp_branding_plugin_header', $header, 'yes');
     MainWPHelper::update_option('mainwp_branding_support_email', $settings['child_support_email']);
     MainWPHelper::update_option('mainwp_branding_support_message', $settings['child_support_message']);
     MainWPHelper::update_option('mainwp_branding_remove_restore', $settings['child_remove_restore']);
     MainWPHelper::update_option('mainwp_branding_remove_setting', $settings['child_remove_setting']);
     MainWPHelper::update_option('mainwp_branding_remove_server_info', $settings['child_remove_server_info']);
     MainWPHelper::update_option('mainwp_branding_remove_wp_tools', $settings['child_remove_wp_tools']);
     MainWPHelper::update_option('mainwp_branding_remove_wp_setting', $settings['child_remove_wp_setting']);
     MainWPHelper::update_option('mainwp_branding_remove_permalink', $settings['child_remove_permalink']);
     MainWPHelper::update_option('mainwp_branding_button_contact_label', $settings['child_button_contact_label'], 'yes');
     MainWPHelper::update_option('mainwp_branding_send_email_message', $settings['child_send_email_message']);
     MainWPHelper::update_option('mainwp_branding_message_return_sender', $settings['child_message_return_sender']);
     MainWPHelper::update_option('mainwp_branding_submit_button_title', $settings['child_submit_button_title']);
     if (isset($settings['child_disable_wp_branding']) && ($settings['child_disable_wp_branding'] === "Y" || $settings['child_disable_wp_branding'] === "N")) {
         MainWPHelper::update_option('mainwp_branding_disable_wp_branding', $settings['child_disable_wp_branding']);
     }
     $extra_setting = array('show_button_in' => $settings['child_show_support_button_in'], 'global_footer' => $settings['child_global_footer'], 'dashboard_footer' => $settings['child_dashboard_footer'], 'remove_widget_welcome' => $settings['child_remove_widget_welcome'], 'remove_widget_glance' => $settings['child_remove_widget_glance'], 'remove_widget_activity' => $settings['child_remove_widget_activity'], 'remove_widget_quick' => $settings['child_remove_widget_quick'], 'remove_widget_news' => $settings['child_remove_widget_news'], 'site_generator' => $settings['child_site_generator'], 'generator_link' => $settings['child_generator_link'], 'admin_css' => $settings['child_admin_css'], 'login_css' => $settings['child_login_css'], 'texts_replace' => $settings['child_texts_replace'], 'hide_nag' => $settings['child_hide_nag'], 'hide_screen_opts' => $settings['child_hide_screen_opts'], 'hide_help_box' => $settings['child_hide_help_box'], 'hide_metabox_post_excerpt' => $settings['child_hide_metabox_post_excerpt'], 'hide_metabox_post_slug' => $settings['child_hide_metabox_post_slug'], 'hide_metabox_post_tags' => $settings['child_hide_metabox_post_tags'], 'hide_metabox_post_author' => $settings['child_hide_metabox_post_author'], 'hide_metabox_post_comments' => $settings['child_hide_metabox_post_comments'], 'hide_metabox_post_revisions' => $settings['child_hide_metabox_post_revisions'], 'hide_metabox_post_discussion' => $settings['child_hide_metabox_post_discussion'], 'hide_metabox_post_categories' => $settings['child_hide_metabox_post_categories'], 'hide_metabox_post_custom_fields' => $settings['child_hide_metabox_post_custom_fields'], 'hide_metabox_post_trackbacks' => $settings['child_hide_metabox_post_trackbacks'], 'hide_metabox_page_custom_fields' => $settings['child_hide_metabox_page_custom_fields'], 'hide_metabox_page_author' => $settings['child_hide_metabox_page_author'], 'hide_metabox_page_discussion' => $settings['child_hide_metabox_page_discussion'], 'hide_metabox_page_revisions' => $settings['child_hide_metabox_page_revisions'], 'hide_metabox_page_attributes' => $settings['child_hide_metabox_page_attributes'], 'hide_metabox_page_slug' => $settings['child_hide_metabox_page_slug']);
     if (isset($settings['child_login_image_url'])) {
         if (empty($settings['child_login_image_url'])) {
             $extra_setting['login_image'] = array();
         } else {
             try {
                 $upload = $this->uploadImage($settings['child_login_image_url']);
                 //Upload image to WP
                 if ($upload != null) {
                     $extra_setting['login_image'] = array("path" => $upload["path"], "url" => $upload["url"]);
                     if (isset($current_extra_setting['login_image']['path'])) {
                         $old_file = $current_extra_setting['login_image']['path'];
                         if (!empty($old_file) && file_exists($old_file)) {
                             @unlink($old_file);
                         }
                     }
                 }
             } catch (Exception $e) {
                 $information['error']['login_image'] = $e->getMessage();
             }
         }
     } else {
         if (isset($current_extra_setting['login_image'])) {
             $extra_setting['login_image'] = $current_extra_setting['login_image'];
         }
     }
     if (isset($settings['child_favico_image_url'])) {
         if (empty($settings['child_favico_image_url'])) {
             $extra_setting['favico_image'] = array();
         } else {
             try {
                 $upload = $this->uploadImage($settings['child_favico_image_url']);
                 //Upload image to WP
                 if ($upload != null) {
                     $extra_setting['favico_image'] = array("path" => $upload["path"], "url" => $upload["url"]);
                     if (isset($current_extra_setting['favico_image']['path'])) {
                         $old_file = $current_extra_setting['favico_image']['path'];
                         if (!empty($old_file) && file_exists($old_file)) {
                             @unlink($old_file);
                         }
                     }
                 }
             } catch (Exception $e) {
                 $information['error']['favico_image'] = $e->getMessage();
             }
         }
     } else {
         if (isset($current_extra_setting['favico_image'])) {
             $extra_setting['favico_image'] = $current_extra_setting['favico_image'];
         }
     }
     MainWPHelper::update_option('mainwp_branding_extra_settings', $extra_setting, 'yes');
     if ($settings['child_plugin_hide']) {
         MainWPHelper::update_option('mainwp_branding_child_hide', 'T');
     } else {
         MainWPHelper::update_option('mainwp_branding_child_hide', '');
     }
     if ($settings['child_show_support_button'] && !empty($settings['child_support_email'])) {
         MainWPHelper::update_option('mainwp_branding_show_support', 'T');
     } else {
         MainWPHelper::update_option('mainwp_branding_show_support', '');
     }
     if ($settings['child_disable_change']) {
         MainWPHelper::update_option('mainwp_branding_disable_change', 'T');
     } else {
         MainWPHelper::update_option('mainwp_branding_disable_change', '');
     }
     $information['result'] = 'SUCCESS';
     return $information;
 }
 function save_setting()
 {
     MainWPHelper::update_option('mainwp_wordfence_ext_enabled', "Y", 'yes');
     $settings = unserialize(base64_decode($_POST['settings']));
     if (is_array($settings) && count($settings) > 0) {
         $result = array();
         $reload = '';
         $opts = $settings;
         $validUsers = array();
         $invalidUsers = array();
         foreach (explode(',', $opts['liveTraf_ignoreUsers']) as $val) {
             $val = trim($val);
             if (strlen($val) > 0) {
                 if (get_user_by('login', $val)) {
                     $validUsers[] = $val;
                 } else {
                     $invalidUsers[] = $val;
                 }
             }
         }
         if (sizeof($invalidUsers) > 0) {
             // return array('errorMsg' => "The following users you selected to ignore in live traffic reports are not valid on this system: " . htmlentities(implode(', ', $invalidUsers)) );
             $result['invalid_users'] = htmlentities(implode(', ', $invalidUsers));
         }
         if (sizeof($validUsers) > 0) {
             $opts['liveTraf_ignoreUsers'] = implode(',', $validUsers);
         } else {
             $opts['liveTraf_ignoreUsers'] = '';
         }
         if (!$opts['other_WFNet']) {
             $wfdb = new wfDB();
             global $wpdb;
             $p = $wpdb->base_prefix;
             $wfdb->queryWrite("delete from {$p}" . "wfBlocks where wfsn=1 and permanent=0");
         }
         $regenerateHtaccess = false;
         if (wfConfig::get('bannedURLs', false) != $opts['bannedURLs']) {
             $regenerateHtaccess = true;
         }
         foreach ($opts as $key => $val) {
             if (in_array($key, self::$options_filter)) {
                 if ($key != 'apiKey') {
                     //Don't save API key yet
                     wfConfig::set($key, $val);
                 }
             }
         }
         if ($regenerateHtaccess) {
             wfCache::addHtaccessCode('add');
         }
         if ($opts['autoUpdate'] == '1') {
             wfConfig::enableAutoUpdate();
         } else {
             if ($opts['autoUpdate'] == '0') {
                 wfConfig::disableAutoUpdate();
             }
         }
         $sch = isset($opts['scheduleScan']) ? $opts['scheduleScan'] : "";
         if ($sch != get_option('mainwp_child_wordfence_cron_time')) {
             update_option('mainwp_child_wordfence_cron_time', $sch);
             $sched = wp_next_scheduled('mainwp_child_wordfence_cron_scan');
             if ($sched != false) {
                 wp_unschedule_event($sched, 'mainwp_child_wordfence_cron_scan');
             }
         }
         $result['cacheType'] = wfConfig::get('cacheType');
         $result['paidKeyMsg'] = false;
         $apiKey = trim($_POST['apiKey']);
         if (!$apiKey) {
             //Empty API key (after trim above), then try to get one.
             $api = new wfAPI('', wfUtils::getWPVersion());
             try {
                 $keyData = $api->call('get_anon_api_key');
                 if ($keyData['ok'] && $keyData['apiKey']) {
                     wfConfig::set('apiKey', $keyData['apiKey']);
                     wfConfig::set('isPaid', 0);
                     $result['apiKey'] = $keyData['apiKey'];
                     $result['isPaid'] = 0;
                     $reload = 'reload';
                 } else {
                     throw new Exception("We could not understand the Wordfence server's response because it did not contain an 'ok' and 'apiKey' element.");
                 }
             } catch (Exception $e) {
                 $result['error'] = "Your options have been saved, but we encountered a problem. You left your API key blank, so we tried to get you a free API key from the Wordfence servers. However we encountered a problem fetching the free key: " . htmlentities($e->getMessage());
                 return $result;
             }
         } else {
             if ($apiKey != wfConfig::get('apiKey')) {
                 $api = new wfAPI($apiKey, wfUtils::getWPVersion());
                 try {
                     $res = $api->call('check_api_key', array(), array());
                     if ($res['ok'] && isset($res['isPaid'])) {
                         wfConfig::set('apiKey', $apiKey);
                         wfConfig::set('isPaid', $res['isPaid']);
                         //res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools.
                         $result['apiKey'] = $apiKey;
                         $result['isPaid'] = $res['isPaid'];
                         if ($res['isPaid']) {
                             $result['paidKeyMsg'] = true;
                         }
                         $reload = 'reload';
                     } else {
                         throw new Exception("We could not understand the Wordfence API server reply when updating your API key.");
                     }
                 } catch (Exception $e) {
                     $result['error'] = "Your options have been saved. However we noticed you changed your API key and we tried to verify it with the Wordfence servers and received an error: " . htmlentities($e->getMessage());
                     return $result;
                 }
             } else {
                 try {
                     $api = new wfAPI($apiKey, wfUtils::getWPVersion());
                     $res = $api->call('ping_api_key', array(), array());
                 } catch (Exception $e) {
                     $result['error'] = "Your options have been saved. However we noticed you do not change your API key and we tried to verify it with the Wordfence servers and received an error: " . htmlentities($e->getMessage());
                     return $result;
                 }
             }
         }
         $result['ok'] = 1;
         $result['reload'] = $reload;
         return $result;
     }
 }