Fix possible performance issue with options

This commit is contained in:
ruben- 2015-05-13 21:27:52 +02:00
parent 3ea9774704
commit 47735ac811
13 changed files with 152 additions and 108 deletions

View file

@ -12,7 +12,7 @@ include_once(ABSPATH . '/wp-admin/includes/plugin.php');
class MainWPChild
{
private $version = '2.0.14';
private $update_version = '1.0';
private $update_version = '1.2';
private $callableFunctions = array(
'stats' => 'getSiteStats',
@ -111,7 +111,7 @@ class MainWPChild
$this->run_saved_snippets();
if (!get_option('mainwp_child_pubkey'))
MainWPHelper::update_option('mainwp_child_branding_disconnected', 'yes');
MainWPHelper::update_option('mainwp_child_branding_disconnected', 'yes', 'yes');
$branding_robust = true;
$cancelled_branding = (get_option('mainwp_child_branding_disconnected') === 'yes') && !get_option('mainwp_branding_preserve_branding');
@ -134,14 +134,44 @@ class MainWPChild
if ($update_version === false)
{
$options = array('mainwp_child_legacy', 'mainwp_child_auth', 'mainwp_child_uniqueId', 'mainwp_child_onetime_htaccess', 'mainwp_child_htaccess_set', 'mainwp_child_fix_htaccess', 'mainwp_child_pubkey', 'mainwp_child_server', 'mainwp_child_nonce', 'mainwp_child_nossl', 'mainwp_child_nossl_key', 'mainwp_child_remove_wp_version', 'mainwp_child_remove_rsd', 'mainwp_child_remove_wlw', 'mainwp_child_remove_core_updates', 'mainwp_child_remove_plugin_updates', 'mainwp_child_remove_theme_updates', 'mainwp_child_remove_php_reporting', 'mainwp_child_remove_scripts_version', 'mainwp_child_remove_styles_version', 'mainwp_child_remove_readme', 'heatMapEnabled', 'mainwp_child_clone_sites', 'mainwp_child_pluginDir', 'mainwp_premium_updates', 'mainwp_child_activated_once', 'mainwp_maintenance_opt_alert_404', 'mainwp_maintenance_opt_alert_404_email', 'mainwp_ext_code_snippets', 'mainwp_ext_snippets_enabled', 'mainwp_temp_clone_plugins', 'mainwp_temp_clone_themes', 'mainwp_child_click_data', 'mainwp_child_clone_from_server_last_folder', 'mainwp_child_clone_permalink', 'mainwp_child_restore_permalink', 'mainwp_keyword_links_htaccess_set', 'mainwp_kwl_options', 'mainwp_kwl_keyword_links', 'mainwp_kwl_click_statistic_data', 'mainwp_kwl_statistic_data_', 'mainwp_kwl_enable_statistic', 'mainwpKeywordLinks', 'mainwp_branding_ext_enabled', 'mainwp_branding_plugin_header', 'mainwp_branding_support_email', 'mainwp_branding_support_message', 'mainwp_branding_remove_restore', 'mainwp_branding_remove_setting', 'mainwp_branding_remove_wp_tools', 'mainwp_branding_remove_wp_setting', 'mainwp_branding_remove_permalink', 'mainwp_branding_button_contact_label', 'mainwp_branding_send_email_message', 'mainwp_branding_message_return_sender', 'mainwp_branding_submit_button_title', 'mainwp_branding_disable_wp_branding', 'mainwp_branding_extra_settings', 'mainwp_branding_child_hide', 'mainwp_branding_show_support', 'mainwp_branding_disable_change');
$options = array('mainwp_child_legacy', 'mainwp_child_auth', 'mainwp_branding_ext_enabled', 'mainwp_child_uniqueId', 'mainwp_child_onetime_htaccess', 'mainwp_child_htaccess_set', 'mainwp_child_fix_htaccess', 'mainwp_child_pubkey', 'mainwp_child_server', 'mainwp_child_nonce', 'mainwp_child_nossl', 'mainwp_child_nossl_key', 'mainwp_child_remove_wp_version', 'mainwp_child_remove_rsd', 'mainwp_child_remove_wlw', 'mainwp_child_remove_core_updates', 'mainwp_child_remove_plugin_updates', 'mainwp_child_remove_theme_updates', 'mainwp_child_remove_php_reporting', 'mainwp_child_remove_scripts_version', 'mainwp_child_remove_styles_version', 'mainwp_child_remove_readme', 'heatMapEnabled', 'mainwp_child_clone_sites', 'mainwp_child_pluginDir', 'mainwp_premium_updates', 'mainwp_child_activated_once', 'mainwp_maintenance_opt_alert_404', 'mainwp_maintenance_opt_alert_404_email', 'mainwp_ext_code_snippets', 'mainwp_ext_snippets_enabled', 'mainwp_temp_clone_plugins', 'mainwp_temp_clone_themes', 'mainwp_child_click_data', 'mainwp_child_clone_from_server_last_folder', 'mainwp_child_clone_permalink', 'mainwp_child_restore_permalink', 'mainwp_keyword_links_htaccess_set', 'mainwp_kwl_options', 'mainwp_kwl_keyword_links', 'mainwp_kwl_click_statistic_data', 'mainwp_kwl_statistic_data_', 'mainwp_kwl_enable_statistic', 'mainwpKeywordLinks', 'mainwp_branding_ext_enabled', 'mainwp_branding_plugin_header', 'mainwp_branding_support_email', 'mainwp_branding_support_message', 'mainwp_branding_remove_restore', 'mainwp_branding_remove_setting', 'mainwp_branding_remove_wp_tools', 'mainwp_branding_remove_wp_setting', 'mainwp_branding_remove_permalink', 'mainwp_branding_button_contact_label', 'mainwp_branding_send_email_message', 'mainwp_branding_message_return_sender', 'mainwp_branding_submit_button_title', 'mainwp_branding_disable_wp_branding', 'mainwp_branding_extra_settings', 'mainwp_branding_child_hide', 'mainwp_branding_show_support', 'mainwp_branding_disable_change');
foreach ($options as $option)
{
MainWPHelper::fix_option($option);
}
}
else if (($update_version === false) || ($update_version == '1.0') || ($update_version == '1.1'))
{
$options = array('mainwp_child_pubkey', 'mainwp_child_branding_disconnected', 'mainwp_branding_plugin_header', 'mainwp_child_update_version', 'mainwp_child_auth', 'mainwp_child_clone_permalink', 'mainwp_child_restore_permalink', 'mainwp_ext_snippets_enabled', 'mainwp_child_fix_htaccess', 'mainwp_child_pluginDir', 'mainwp_child_htaccess_set', 'heatMapEnabled', 'heatMapsIndividualOverrideSetting', 'heatMapExtensionLoaded', 'heatMapsIndividualDisable', 'mainwp_child_nossl', 'mainwp_updraftplus_ext_enabled', 'mainwpKeywordLinks', 'mainwp_keyword_links_htaccess_set', 'mainwp_branding_button_contact_label', 'mainwp_branding_extra_settings', 'mainwp_branding_ext_enabled', 'mainwp_creport_ext_branding_enabled', 'mainwp_pagespeed_ext_enabled', 'mainwp_linkschecker_ext_enabled', 'mainwp_wordfence_ext_enabled', 'mainwp_ithemes_ext_enabled', 'mainwp_maintenance_opt_alert_404');
foreach ($options as $option)
{
MainWPHelper::fix_option($option, 'yes');
}
MainWPHelper::update_option('mainwp_child_update_version', $this->update_version);
if (!is_array(get_option('mainwp_security')))
{
$securityOptions = array('wp_version' => 'mainwp_child_remove_wp_version',
'rsd' => 'mainwp_child_remove_rsd',
'wlw' => 'mainwp_child_remove_wlw',
'core_updates' => 'mainwp_child_remove_core_updates',
'plugin_updates' => 'mainwp_child_remove_plugin_updates',
'theme_updates' => 'mainwp_child_remove_theme_updates',
'php_reporting' => 'mainwp_child_remove_php_reporting',
'scripts_version' => 'mainwp_child_remove_scripts_version',
'styles_version' => 'mainwp_child_remove_styles_version',
'readme' => 'mainwp_child_remove_readme');
$security = array();
foreach ($securityOptions as $option => $old)
{
$value = get_option($old);
$security[$option] = ($value == 'T');
}
MainWPHelper::update_option('mainwp_security', $security, 'yes');
}
}
MainWPHelper::update_option('mainwp_child_update_version', $this->update_version, 'yes');
}
public function admin_notice()
@ -190,7 +220,7 @@ class MainWPChild
while (isset($auths[$newI])) unset($auths[$newI++]);
$auths[$this->maxHistory] = md5(MainWPHelper::randString(14));
$auths['last'] = time();
MainWPHelper::update_option('mainwp_child_auth', $auths);
MainWPHelper::update_option('mainwp_child_auth', $auths, 'yes');
}
}
@ -441,7 +471,7 @@ class MainWPChild
MainWPHelper::update_option('mainwp_child_onetime_htaccess', true);
}
}
MainWPHelper::update_option('mainwp_child_htaccess_set', 'yes');
MainWPHelper::update_option('mainwp_child_htaccess_set', 'yes', 'yes');
}
else if ($hard)
{
@ -594,7 +624,7 @@ class MainWPChild
include_once(ABSPATH . '/wp-admin/includes/misc.php');
$wp_rewrite->flush_rules();
MainWPHelper::update_option('mainwp_child_fix_htaccess', 'yes');
MainWPHelper::update_option('mainwp_child_fix_htaccess', 'yes', 'yes');
}
$this->update_htaccess();
@ -1359,7 +1389,7 @@ class MainWPChild
MainWPHelper::error(__('Invalid request','mainwp-child'));
}
MainWPHelper::update_option('mainwp_child_branding_disconnected', 'yes');
MainWPHelper::update_option('mainwp_child_branding_disconnected', 'yes', 'yes');
//Already added - can't readd. Deactivate plugin..
if (get_option('mainwp_child_pubkey'))
@ -1392,16 +1422,16 @@ class MainWPChild
}
}
MainWPHelper::update_option('mainwp_child_pubkey', base64_encode($_POST['pubkey'])); //Save the public key
MainWPHelper::update_option('mainwp_child_pubkey', base64_encode($_POST['pubkey']), 'yes'); //Save the public key
MainWPHelper::update_option('mainwp_child_server', $_POST['server']); //Save the public key
MainWPHelper::update_option('mainwp_child_nonce', 0); //Save the nonce
MainWPHelper::update_option('mainwp_child_nossl', ($_POST['pubkey'] == '-1' || !function_exists('openssl_verify') ? 1 : 0));
MainWPHelper::update_option('mainwp_child_nossl', ($_POST['pubkey'] == '-1' || !function_exists('openssl_verify') ? 1 : 0), 'yes');
$information['nossl'] = ($_POST['pubkey'] == '-1' || !function_exists('openssl_verify') ? 1 : 0);
$nossl_key = uniqid('', true);
MainWPHelper::update_option('mainwp_child_nossl_key', $nossl_key);
MainWPHelper::update_option('mainwp_child_nossl_key', $nossl_key, 'yes');
$information['nosslkey'] = $nossl_key;
MainWPHelper::update_option('mainwp_child_branding_disconnected', '');
MainWPHelper::update_option('mainwp_child_branding_disconnected', '', 'yes');
$information['register'] = 'OK';
$information['uniqueId'] = get_option('mainwp_child_uniqueId', '');
@ -2066,6 +2096,9 @@ class MainWPChild
}
$information = array();
$security = get_option('mainwp_security');
if (!is_array($security)) $security = array();
if ($_POST['feature'] == 'all' || $_POST['feature'] == 'listing')
{
MainWPSecurity::prevent_listing();
@ -2074,43 +2107,43 @@ class MainWPChild
if ($_POST['feature'] == 'all' || $_POST['feature'] == 'wp_version')
{
MainWPHelper::update_option('mainwp_child_remove_wp_version', 'T');
MainWPSecurity::remove_wp_version();
$security['wp_version'] = true;
MainWPSecurity::remove_wp_version(true);
$information['wp_version'] = (!MainWPSecurity::remove_wp_version_ok() ? 'N' : 'Y');
}
if ($_POST['feature'] == 'all' || $_POST['feature'] == 'rsd')
{
MainWPHelper::update_option('mainwp_child_remove_rsd', 'T');
MainWPSecurity::remove_rsd();
$security['rsd'] = true;
MainWPSecurity::remove_rsd(true);
$information['rsd'] = (!MainWPSecurity::remove_rsd_ok() ? 'N' : 'Y');
}
if ($_POST['feature'] == 'all' || $_POST['feature'] == 'wlw')
{
MainWPHelper::update_option('mainwp_child_remove_wlw', 'T');
MainWPSecurity::remove_wlw();
$security['wlw'] = true;
MainWPSecurity::remove_wlw(true);
$information['wlw'] = (!MainWPSecurity::remove_wlw_ok() ? 'N' : 'Y');
}
// if ($_POST['feature'] == 'all' || $_POST['feature'] == 'core_updates')
// {
// update_option('mainwp_child_remove_core_updates', 'T');
// MainWPSecurity::remove_core_update();
// $security['core_updates'] = true;
// MainWPSecurity::remove_core_update(true);
// $information['core_updates'] = (!MainWPSecurity::remove_core_update_ok() ? 'N' : 'Y');
// }
// if ($_POST['feature'] == 'all' || $_POST['feature'] == 'plugin_updates')
// {
// update_option('mainwp_child_remove_plugin_updates', 'T');
// MainWPSecurity::remove_plugin_update();
// $security['plugin_updates'] = true;
// MainWPSecurity::remove_plugin_update(true);
// $information['plugin_updates'] = (!MainWPSecurity::remove_plugin_update_ok() ? 'N' : 'Y');
// }
// if ($_POST['feature'] == 'all' || $_POST['feature'] == 'theme_updates')
// {
// update_option('mainwp_child_remove_theme_updates', 'T');
// MainWPSecurity::remove_theme_update();
// $security['theme_updates'] = true;
// MainWPSecurity::remove_theme_update(true);
// $information['theme_updates'] = (!MainWPSecurity::remove_theme_update_ok() ? 'N' : 'Y');
// }
@ -2132,17 +2165,17 @@ class MainWPChild
if ($_POST['feature'] == 'all' || $_POST['feature'] == 'php_reporting')
{
MainWPHelper::update_option('mainwp_child_remove_php_reporting', 'T');
MainWPSecurity::remove_php_reporting();
$security['php_reporting'] = true;
MainWPSecurity::remove_php_reporting(true);
$information['php_reporting'] = (!MainWPSecurity::remove_php_reporting_ok() ? 'N' : 'Y');
}
if ($_POST['feature'] == 'all' || $_POST['feature'] == 'versions')
{
MainWPHelper::update_option('mainwp_child_remove_scripts_version', 'T');
MainWPHelper::update_option('mainwp_child_remove_styles_version', 'T');
MainWPSecurity::remove_scripts_version();
MainWPSecurity::remove_styles_version();
$security['scripts_version'] = true;
$security['styles_version'] = true;
MainWPSecurity::remove_scripts_version(true);
MainWPSecurity::remove_styles_version(true);
$information['versions'] = (!MainWPSecurity::remove_scripts_version_ok() || !MainWPSecurity::remove_styles_version_ok()
? 'N' : 'Y');
}
@ -2154,11 +2187,13 @@ class MainWPChild
if ($_POST['feature'] == 'all' || $_POST['feature'] == 'readme')
{
MainWPHelper::update_option('mainwp_child_remove_readme', 'T');
MainWPSecurity::remove_readme();
$security['readme'] = true;
MainWPSecurity::remove_readme(true);
$information['readme'] = (MainWPSecurity::remove_readme_ok() ? 'Y' : 'N');
}
MainWPHelper::update_option('mainwp_security', $security, 'yes');
if ($sync)
{
$information['sync'] = $this->getSiteStats(array(), false);
@ -2176,43 +2211,47 @@ class MainWPChild
$sync = true;
}
$security = get_option('mainwp_security');
if ($_POST['feature'] == 'all' || $_POST['feature'] == 'wp_version')
{
MainWPHelper::update_option('mainwp_child_remove_wp_version', 'F');
$security['wp_version'] = false;
$information['wp_version'] = 'N';
}
if ($_POST['feature'] == 'all' || $_POST['feature'] == 'rsd')
{
MainWPHelper::update_option('mainwp_child_remove_rsd', 'F');
$security['rsd'] = false;
$information['rsd'] = 'N';
}
if ($_POST['feature'] == 'all' || $_POST['feature'] == 'wlw')
{
MainWPHelper::update_option('mainwp_child_remove_wlw', 'F');
$security['wlw'] = false;
$information['wlw'] = 'N';
}
if ($_POST['feature'] == 'all' || $_POST['feature'] == 'php_reporting')
{
MainWPHelper::update_option('mainwp_child_remove_php_reporting', 'F');
$security['php_reporting'] = false;
$information['php_reporting'] = 'N';
}
if ($_POST['feature'] == 'all' || $_POST['feature'] == 'versions')
{
MainWPHelper::update_option('mainwp_child_remove_scripts_version', 'F');
MainWPHelper::update_option('mainwp_child_remove_styles_version', 'F');
$security['scripts_version'] = false;
$security['styles_version'] = false;
$information['versions'] = 'N';
}
if ($_POST['feature'] == 'all' || $_POST['feature'] == 'readme')
{
MainWPHelper::update_option('mainwp_child_remove_readme', 'F');
$security['readme'] = false;
$information['readme'] = MainWPSecurity::remove_readme_ok();
}
MainWPHelper::update_option('mainwp_security', $security, 'yes');
if ($sync)
{
$information['sync'] = $this->getSiteStats(array(), false);
@ -2257,13 +2296,13 @@ class MainWPChild
if ($_POST['heatMap'] == '1')
{
if (get_option('heatMapEnabled') != '1') $update_htaccess = true;
MainWPHelper::update_option('heatMapEnabled', '1');
MainWPHelper::update_option('heatMapExtensionLoaded', 'yes');
MainWPHelper::update_option('heatMapEnabled', '1', 'yes');
MainWPHelper::update_option('heatMapExtensionLoaded', 'yes', 'yes');
}
else
{
if (get_option('heatMapEnabled') != '0') $update_htaccess = true;
MainWPHelper::update_option('heatMapEnabled', '0');
MainWPHelper::update_option('heatMapEnabled', '0', 'yes');
}
}
@ -2284,13 +2323,13 @@ class MainWPChild
{
if (get_option('mainwp_child_pluginDir') != $_POST['pluginDir'])
{
MainWPHelper::update_option('mainwp_child_pluginDir', $_POST['pluginDir']);
MainWPHelper::update_option('mainwp_child_pluginDir', $_POST['pluginDir'], 'yes');
$update_htaccess = true;
}
}
else if (get_option('mainwp_child_pluginDir') != false)
{
delete_option('mainwp_child_pluginDir');
MainWPHelper::update_option('mainwp_child_pluginDir', false, 'yes');
$update_htaccess = true;
}
@ -2307,7 +2346,7 @@ class MainWPChild
if ($exit) $this->updateExternalSettings();
MainWPHelper::update_option('mainwp_child_branding_disconnected', '');
MainWPHelper::update_option('mainwp_child_branding_disconnected', '', 'yes');
$information['version'] = $this->version;
$information['wpversion'] = $wp_version;
@ -3511,7 +3550,7 @@ class MainWPChild
function deactivation()
{
$to_delete = array('mainwp_child_pubkey', 'mainwp_child_nonce', 'mainwp_child_nossl', 'mainwp_child_nossl_key', 'mainwp_child_remove_styles_version', 'mainwp_child_remove_scripts_version', 'mainwp_child_remove_php_reporting', 'mainwp_child_remove_theme_updates', 'mainwp_child_remove_plugin_updates', 'mainwp_child_remove_core_updates', 'mainwp_child_remove_wlw', 'mainwp_child_remove_rsd', 'mainwp_child_remove_wp_version', 'mainwp_child_server');
$to_delete = array('mainwp_child_pubkey', 'mainwp_child_nonce', 'mainwp_child_nossl', 'mainwp_child_nossl_key', 'mainwp_security', 'mainwp_child_server');
$to_delete[] = 'mainwp_ext_snippets_enabled';
$to_delete[] = 'mainwp_ext_code_snippets';
@ -3686,14 +3725,14 @@ class MainWPChild
if (isset($_POST['enable_alert']) && $_POST['enable_alert'] == 1)
{
MainWPHelper::update_option('mainwp_maintenance_opt_alert_404', 1);
MainWPHelper::update_option('mainwp_maintenance_opt_alert_404', 1, 'yes');
} else {
delete_option('mainwp_maintenance_opt_alert_404');
}
if (isset($_POST['email']) && !empty($_POST['email']))
{
MainWPHelper::update_option('mainwp_maintenance_opt_alert_404_email', $_POST['email']);
MainWPHelper::update_option('mainwp_maintenance_opt_alert_404_email', $_POST['email'], 'yes');
} else {
delete_option('mainwp_maintenance_opt_alert_404_email');
}
@ -3922,7 +3961,7 @@ class MainWPChild
$information['status'] = 'SUCCESS';
}
}
MainWPHelper::update_option('mainwp_ext_snippets_enabled', true);
MainWPHelper::update_option('mainwp_ext_snippets_enabled', true, 'yes');
} else if ($action === 'delete_snippet') {
$type = $_POST['type'];
$slug = $_POST['slug'];
@ -4060,8 +4099,8 @@ class MainWPChild
$need_update = false;
}
if ($need_update) {
MainWPHelper::update_option('heatMapsIndividualOverrideSetting', $override);
MainWPHelper::update_option('heatMapsIndividualDisable', $disable);
MainWPHelper::update_option('heatMapsIndividualOverrideSetting', $override, 'yes');
MainWPHelper::update_option('heatMapsIndividualDisable', $disable, 'yes');
$this->update_htaccess(true);
}
MainWPHelper::write(array('result' => 'success'));

View file

@ -100,14 +100,14 @@ class MainWPChildBranding
if (!is_array($settings))
return $information;
$current_extra_setting = $this->settings['extra_settings'];
MainWPHelper::update_option('mainwp_branding_ext_enabled', "Y");
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);
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']);
@ -116,7 +116,7 @@ class MainWPChildBranding
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']);
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']);
@ -211,7 +211,7 @@ class MainWPChildBranding
}
MainWPHelper::update_option('mainwp_branding_extra_settings', $extra_setting);
MainWPHelper::update_option('mainwp_branding_extra_settings', $extra_setting, 'yes');
if ($settings['child_plugin_hide'])
{

View file

@ -88,7 +88,7 @@ class MainWPChildIThemesSecurity
}
function set_showhide() {
MainWPHelper::update_option('mainwp_ithemes_ext_enabled', "Y");
MainWPHelper::update_option('mainwp_ithemes_ext_enabled', "Y", 'yes');
$hide = isset($_POST['showhide']) && ($_POST['showhide'] === "hide") ? 'hide' : "";
MainWPHelper::update_option('mainwp_ithemes_hide_plugin', $hide);
$information['result'] = 'SUCCESS';
@ -132,7 +132,7 @@ class MainWPChildIThemesSecurity
require( trailingslashit( $itsec_globals['plugin_dir'] ) . 'core/class-itsec-lib.php' );
}
MainWPHelper::update_option('mainwp_ithemes_ext_enabled', "Y");
MainWPHelper::update_option('mainwp_ithemes_ext_enabled', "Y", 'yes');
$settings = unserialize(base64_decode($_POST['settings']));
$updated = false;
$rewrites_changed = false;

View file

@ -162,7 +162,7 @@ class MainWPChildLinksChecker
function set_showhide() {
MainWPHelper::update_option('mainwp_linkschecker_ext_enabled', "Y");
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';

View file

@ -76,7 +76,7 @@ class MainWPChildPagespeed
$recheck = false;
$count++;
}
update_option("mainwp_child_pagespeed_count_checking", $count);
update_option('mainwp_child_pagespeed_count_checking', $count);
$worker_args = array(
array(), false, $recheck
@ -119,7 +119,7 @@ class MainWPChildPagespeed
function set_showhide() {
MainWPHelper::update_option('mainwp_pagespeed_ext_enabled', "Y");
MainWPHelper::update_option('mainwp_pagespeed_ext_enabled', "Y", 'yes');
$hide = isset($_POST['showhide']) && ($_POST['showhide'] === "hide") ? 'hide' : "";
MainWPHelper::update_option('mainwp_pagespeed_hide_plugin', $hide);
$information['result'] = 'SUCCESS';
@ -127,7 +127,7 @@ class MainWPChildPagespeed
}
function save_settings() {
MainWPHelper::update_option('mainwp_pagespeed_ext_enabled', "Y");
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');

View file

@ -91,7 +91,7 @@ class MainWPChildUpdraftplusBackups
}
function set_showhide() {
MainWPHelper::update_option('mainwp_updraftplus_ext_enabled', "Y");
MainWPHelper::update_option('mainwp_updraftplus_ext_enabled', "Y", 'yes');
$hide = isset($_POST['showhide']) && ($_POST['showhide'] === "hide") ? 'hide' : "";
MainWPHelper::update_option('mainwp_updraftplus_hide_plugin', $hide);
$information['result'] = 'SUCCESS';
@ -174,7 +174,7 @@ class MainWPChildUpdraftplusBackups
function save_settings() {
MainWPHelper::update_option('mainwp_updraftplus_ext_enabled', "Y");
MainWPHelper::update_option('mainwp_updraftplus_ext_enabled', "Y", 'yes');
$settings = unserialize(base64_decode($_POST['settings']));
$keys = $this->get_settings_keys();

View file

@ -208,7 +208,7 @@ class MainWPChildWordfence
}
function set_showhide() {
MainWPHelper::update_option('mainwp_wordfence_ext_enabled', "Y");
MainWPHelper::update_option('mainwp_wordfence_ext_enabled', "Y", 'yes');
$hide = isset($_POST['showhide']) && ($_POST['showhide'] === "hide") ? 'hide' : "";
MainWPHelper::update_option('mainwp_wordfence_hide_plugin', $hide);
$information['result'] = 'SUCCESS';
@ -503,7 +503,7 @@ class MainWPChildWordfence
}
function save_setting() {
MainWPHelper::update_option('mainwp_wordfence_ext_enabled', "Y");
MainWPHelper::update_option('mainwp_wordfence_ext_enabled', "Y", 'yes');
$settings = unserialize(base64_decode($_POST['settings']));
if (is_array($settings) && count($settings) > 0) {
$result = array();

View file

@ -678,7 +678,7 @@ class MainWPClientReport
}
function set_showhide() {
MainWPHelper::update_option('mainwp_creport_ext_branding_enabled', "Y");
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';

View file

@ -1281,20 +1281,20 @@ Author URI: http://dd32.id.au/
// $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);
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);
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);
MainWPHelper::update_option('mainwp_child_restore_permalink', true, 'yes');
}
else
{
MainWPHelper::update_option('mainwp_child_clone_permalink', true);
MainWPHelper::update_option('mainwp_child_clone_permalink', true, 'yes');
}
$cloneInstall->clean();

View file

@ -828,9 +828,9 @@ class MainWPHelper
<br>';
}
static function update_option($option_name, $option_value)
static function update_option($option_name, $option_value, $autoload = 'no')
{
$success = add_option($option_name, $option_value, '', 'no');
$success = add_option($option_name, $option_value, '', $autoload);
if (!$success)
{
@ -840,15 +840,15 @@ class MainWPHelper
return $success;
}
static function fix_option($option_name)
static function fix_option($option_name, $autoload = 'no')
{
global $wpdb;
if ( 'yes' == $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = '" . $option_name . "'" ) )
if ( $autoload != $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = '" . $option_name . "'" ) )
{
$option_value = get_option( $option_name );
delete_option( $option_name );
add_option( $option_name, $option_value, null, 'no' );
add_option( $option_name, $option_value, null, $autoload );
}
}

View file

@ -120,7 +120,7 @@ class MainWPKeywordLinks
$rules = explode("\n", '');
insert_with_markers($htaccess_file, 'MainWP Keyword Links Extension', $rules);
}
MainWPHelper::update_option('mainwp_keyword_links_htaccess_set', '');
MainWPHelper::update_option('mainwp_keyword_links_htaccess_set', '', 'yes');
}
public function do_update_htaccess($force_clear = false) {
@ -146,13 +146,12 @@ class MainWPKeywordLinks
$rules = explode("\n", $rules);
insert_with_markers($htaccess_file, 'MainWP Keyword Links Extension', $rules);
}
MainWPHelper::update_option('mainwp_keyword_links_htaccess_set', 'yes');
MainWPHelper::update_option('mainwp_keyword_links_htaccess_set', 'yes', 'yes');
return true;
} else {
self::clear_htaccess();
return true;
}
return false;
}
@ -840,7 +839,7 @@ class MainWPKeywordLinks
$this->update_htaccess_for_change_cloak_links($link);
}
}
MainWPHelper::update_option('mainwpKeywordLinks', 1); // enable extension functions
MainWPHelper::update_option('mainwpKeywordLinks', 1, 'yes'); // enable extension functions
return $return;
}
@ -879,7 +878,7 @@ class MainWPKeywordLinks
'enable_post_type' => $_POST['enable_post_type'],
'enable_post_type_link' => $_POST['enable_post_type_link']
);
MainWPHelper::update_option('mainwpKeywordLinks', 1); // enable extension functions
MainWPHelper::update_option('mainwpKeywordLinks', 1, 'yes'); // enable extension functions
if (MainWPHelper::update_option('mainwp_kwl_options', $this->config)) {
$return['status'] = 'SUCCESS';
}

View file

@ -62,15 +62,21 @@ class MainWPSecurity
}
}
public static function get_security_option($option)
{
$security = get_option('mainwp_security');
return !empty($security) && isset($security[$option]) && ($security[$option] === true);
}
//Removed wp-version
public static function remove_wp_version_ok()
{
return !(has_action('wp_head', 'wp_generator') || has_filter('wp_head', 'wp_generator'));
}
public static function remove_wp_version()
public static function remove_wp_version($force = false)
{
if (get_option('mainwp_child_remove_wp_version') == 'T')
if ($force || self::get_security_option('wp_version'))
{
remove_action('wp_head', 'wp_generator');
remove_filter('wp_head', 'wp_generator');
@ -83,9 +89,9 @@ class MainWPSecurity
return (!has_action('wp_head', 'rsd_link'));
}
public static function remove_rsd()
public static function remove_rsd($force = false)
{
if (get_option('mainwp_child_remove_rsd') == 'T')
if ($force || self::get_security_option('rsd'))
{
remove_action('wp_head', 'rsd_link');
}
@ -97,9 +103,9 @@ class MainWPSecurity
return (!has_action('wp_head', 'wlwmanifest_link'));
}
public static function remove_wlw()
public static function remove_wlw($force = false)
{
if (get_option('mainwp_child_remove_wlw') == 'T')
if ($force || self::get_security_option('wlw'))
{
remove_action('wp_head', 'wlwmanifest_link');
}
@ -108,12 +114,12 @@ class MainWPSecurity
//Removed core update information for non-admins
// public static function remove_core_update_ok()
// {
// return (get_option('mainwp_child_remove_core_updates') == 'T');
// return self::get_security_option('core_updates');
// }
// public static function remove_core_update()
// public static function remove_core_update($force = false)
// {
// if (get_option('mainwp_child_remove_core_updates') == 'T')
// if ($force || self::get_security_option('core_updates'))
// {
// if (!current_user_can('update_plugins'))
// {
@ -133,12 +139,12 @@ class MainWPSecurity
//Removed plugin-update information for non-admins
// public static function remove_plugin_update_ok()
// {
// return (get_option('mainwp_child_remove_plugin_updates') == 'T');
// return self:get_security_option('plugin_updates');
// }
// public static function remove_plugin_update()
// public static function remove_plugin_update($force = false)
// {
// if (get_option('mainwp_child_remove_plugin_updates') == 'T')
// if ($force || self::get_security_option('plugin_updates'))
// {
// if (!current_user_can('update_plugins'))
// {
@ -161,12 +167,12 @@ class MainWPSecurity
//Removed theme-update information for non-admins
// public static function remove_theme_update_ok()
// {
// return (get_option('mainwp_child_remove_theme_updates') == 'T');
// return self::get_security_option('theme_updates');
// }
// public static function remove_theme_update()
// public static function remove_theme_update($force = false)
// {
// if (get_option('mainwp_child_remove_theme_updates') == 'T')
// if ($force || self::get_security_option('theme_updates'))
// {
// if (!current_user_can('edit_themes'))
// {
@ -251,9 +257,9 @@ class MainWPSecurity
return !(((ini_get('display_errors') != 0) && (ini_get('display_errors') != 'off')) || ((ini_get('display_startup_errors') != 0) && (ini_get('display_startup_errors') != 'off')));
}
public static function remove_php_reporting()
public static function remove_php_reporting($force)
{
if (get_option('mainwp_child_remove_php_reporting') == 'T')
if ($force || self::get_security_option('php_reporting'))
{
@error_reporting(0);
@ini_set('display_errors', 'off');
@ -264,7 +270,7 @@ class MainWPSecurity
//Removed version information for scripts/stylesheets
public static function remove_scripts_version_ok()
{
return (get_option('mainwp_child_remove_scripts_version') == 'T');
return self::get_security_option('scripts_version');
// global $wp_scripts;
// if (!is_a($wp_scripts, 'WP_Scripts'))
@ -283,7 +289,7 @@ class MainWPSecurity
public static function remove_script_versions($src)
{
if (get_option('mainwp_child_remove_scripts_version') == 'T')
if (self::get_security_option('scripts_version'))
{
if (strpos($src, '?ver='))
$src = esc_url_raw(remove_query_arg('ver', $src));
@ -295,7 +301,7 @@ class MainWPSecurity
public static function remove_theme_versions($src)
{
if (get_option('mainwp_child_remove_styles_version') == 'T')
if (self::get_security_option('styles_version') == 'T')
{
if (strpos($src, '?ver='))
$src = esc_url_raw(remove_query_arg('ver', $src));
@ -305,9 +311,9 @@ class MainWPSecurity
return $src;
}
public static function remove_scripts_version()
public static function remove_scripts_version($force = false)
{
if (get_option('mainwp_child_remove_scripts_version') == 'T')
if ($force || self::get_security_option('scripts_version'))
{
global $wp_scripts;
if (!is_a($wp_scripts, 'WP_Scripts'))
@ -318,9 +324,9 @@ class MainWPSecurity
}
}
public static function remove_readme()
public static function remove_readme($force = false)
{
if (get_option('mainwp_child_remove_readme') == 'T')
if ($force || self::get_security_option('readme'))
{
if (@file_exists(ABSPATH . 'readme.html'))
{
@ -341,7 +347,7 @@ class MainWPSecurity
public static function remove_styles_version_ok()
{
return (get_option('mainwp_child_remove_styles_version') == 'T');
return self::get_security_option('styles_version');
// global $wp_styles;
// if (!is_a($wp_styles, 'WP_Styles'))
@ -359,9 +365,9 @@ class MainWPSecurity
// return true;
}
public static function remove_styles_version()
public static function remove_styles_version($force = true)
{
if (get_option('mainwp_child_remove_styles_version') == 'T')
if ($force || self::get_security_option('styles_version'))
{
global $wp_styles;
if (!is_a($wp_styles, 'WP_Styles'))

View file

@ -5,7 +5,7 @@
Description: Child Plugin for MainWP. The plugin is used so the installed blog can be securely managed remotely by your network. Plugin documentation and options can be found here http://docs.mainwp.com
Author: MainWP
Author URI: http://mainwp.com
Version: 2.0.14
Version: 2.0.15-alpha
*/
header('X-Frame-Options: ALLOWALL');
//header('X-Frame-Options: GOFORIT');