Exemplo n.º 1
0
/**
 * Outputs JSON of all installed themes, plugins, and the wordpress version number
 *
 * Responds to a bruteprotect api call of 'bp_scan'
 *
 * @package Bruteprotect
 * @since 2.0
 */
// if we aren't cleared to track versions, bail
$privacy_opt_in = get_site_option('brute_privacy_opt_in');
if (!isset($privacy_opt_in['remote_monitoring'])) {
    $response = array('error' => true, 'message' => 'This site is not authorized for version tracking. Settings: ' . serialize($privacy_opt_in));
    echo json_encode($response);
    exit;
}
// if the nonce doesn't check out, bail
if (!verify_bp_nonce($bruteprotect_host, $_POST)) {
    $response = array('error' => true, 'message' => 'Could not verify nonce');
    echo json_encode($response);
    exit;
}
$user_can_update = false;
if (!empty($_POST['wp_user'])) {
    $user_can_update = user_can($_POST['wp_user'], 'update_plugins');
}
wp_update_plugins();
wp_update_themes();
$response = array('plugins' => bruteprotect_get_plugins(), 'themes' => bruteprotect_get_themes(), 'wp_version' => get_bloginfo('version'), 'core_update' => brute_protect_get_core_update(), 'user_can_update' => $user_can_update);
echo json_encode($response);
exit;
if (isset($_POST['brute_action']) && $_POST['brute_action'] == 'general_update' && current_user_can('manage_options')) {
    global $wordpress_success;
    // save dashboard widget settings
    if (isset($_POST['brute_dashboard_widget_hide'])) {
        update_site_option('brute_dashboard_widget_hide', $_POST['brute_dashboard_widget_hide']);
    }
    // save dashboard widget settings
    if (isset($_POST['brute_dashboard_widget_admin_only'])) {
        update_site_option('brute_dashboard_widget_admin_only', $_POST['brute_dashboard_widget_admin_only']);
    }
    $wordpress_success = 'Your WordPress settings were saved.';
}
if (isset($_POST['brute_action']) && $_POST['brute_action'] == 'register_and_link') {
    global $register_error, $linking_success, $current_user;
    $action = 'register_and_link';
    $core_update = brute_protect_get_core_update();
    $plugin_updates = bruteprotect_get_out_of_date_plugins();
    $theme_updates = bruteprotect_get_out_of_date_themes();
    $additional_data = array('first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'email' => $_POST['email'], 'company' => $_POST['company'], 'password' => $_POST['password'], 'remote_id' => strval($current_user->ID), 'core_update' => $core_update, 'plugin_updates' => strval(count($plugin_updates)), 'theme_updates' => strval(count($theme_updates)));
    $sign = true;
    $response = $this->brute_call($action, $additional_data, $sign);
    if (isset($response['link_key'])) {
        update_user_meta($current_user->ID, 'bruteprotect_user_linked', $response['link_key']);
        update_site_option('bruteprotect_user_linked', '1');
        $linking_success = $response['message'];
    } else {
        $register_error = $response['message'];
    }
}
if (isset($_POST['brute_action']) && $_POST['brute_action'] == 'update_brute_whitelist') {
    global $whitelist_success;