/**
 * Retrieve the information for the available updates.
 *
 * @return string HTML code for a table with the updates information.
 */
function sucuriscan_posthack_updates_content($send_email = false)
{
    if (!function_exists('wp_update_plugins') || !function_exists('get_plugin_updates') || !function_exists('wp_update_themes') || !function_exists('get_theme_updates')) {
        return false;
    }
    $response = '';
    $result = wp_update_plugins();
    $updates = get_plugin_updates();
    if (is_array($updates) && !empty($updates)) {
        $counter = 0;
        foreach ($updates as $data) {
            $css_class = $counter % 2 == 0 ? '' : 'alternate';
            $params = array('Update.CssClass' => $css_class, 'Update.IconType' => 'plugins', 'Update.Extension' => SucuriScan::excerpt($data->Name, 35), 'Update.Version' => $data->Version, 'Update.NewVersion' => 'Unknown', 'Update.TestedWith' => 'Unknown', 'Update.ArchiveUrl' => 'Unknown', 'Update.MarketUrl' => 'Unknown');
            if (property_exists($data->update, 'new_version')) {
                $params['Update.NewVersion'] = $data->update->new_version;
            }
            if (property_exists($data->update, 'tested')) {
                $params['Update.TestedWith'] = "WordPress " . $data->update->tested;
            }
            if (property_exists($data->update, 'package')) {
                $params['Update.ArchiveUrl'] = $data->update->package;
            }
            if (property_exists($data->update, 'url')) {
                $params['Update.MarketUrl'] = $data->update->url;
            }
            $response .= SucuriScanTemplate::getSnippet('posthack-updates', $params);
            $counter++;
        }
    }
    // Check for available theme updates.
    $result = wp_update_themes();
    $updates = get_theme_updates();
    if (is_array($updates) && !empty($updates)) {
        $counter = 0;
        foreach ($updates as $data) {
            $css_class = $counter % 2 == 0 ? '' : 'alternate';
            $response .= SucuriScanTemplate::getSnippet('posthack-updates', array('Update.CssClass' => $css_class, 'Update.IconType' => 'appearance', 'Update.Extension' => SucuriScan::excerpt($data->Name, 35), 'Update.Version' => $data->Version, 'Update.NewVersion' => $data->update['new_version'], 'Update.TestedWith' => 'Newest WordPress', 'Update.ArchiveUrl' => $data->update['package'], 'Update.MarketUrl' => $data->update['url']));
            $counter++;
        }
    }
    if (!is_string($response) || empty($response)) {
        return false;
    }
    // Send an email notification with the affected files.
    if ($send_email === true) {
        $params = array('AvailableUpdates.Content' => $response);
        $content = SucuriScanTemplate::getSection('posthack-updates-notification', $params);
        $sent = SucuriScanEvent::notify_event('available_updates', $content);
        return $sent;
    }
    return $response;
}
Beispiel #2
0
/**
 * Process the Ajax request to retrieve the plugins metadata.
 *
 * @return string HTML code for a table with the plugins metadata.
 */
function sucuriscan_posthack_plugins_ajax()
{
    if (SucuriScanRequest::post('form_action') == 'get_plugins_data') {
        $all_plugins = SucuriScanAPI::get_plugins();
        $response = '';
        $counter = 0;
        foreach ($all_plugins as $plugin_path => $plugin_data) {
            $css_class = $counter % 2 == 0 ? '' : 'alternate';
            $plugin_type_class = $plugin_data['PluginType'] == 'free' ? 'primary' : 'warning';
            $input_disabled = $plugin_data['PluginType'] == 'free' ? '' : 'disabled="disabled"';
            $plugin_status = $plugin_data['IsPluginActive'] ? 'active' : 'not active';
            $plugin_status_class = $plugin_data['IsPluginActive'] ? 'success' : 'default';
            $response .= SucuriScanTemplate::get_snippet('posthack-resetplugins', array('ResetPlugin.CssClass' => $css_class, 'ResetPlugin.Disabled' => $input_disabled, 'ResetPlugin.PluginPath' => SucuriScan::escape($plugin_path), 'ResetPlugin.Plugin' => SucuriScan::excerpt($plugin_data['Name'], 35), 'ResetPlugin.Version' => $plugin_data['Version'], 'ResetPlugin.Type' => $plugin_data['PluginType'], 'ResetPlugin.TypeClass' => $plugin_type_class, 'ResetPlugin.Status' => $plugin_status, 'ResetPlugin.StatusClass' => $plugin_status_class));
            $counter += 1;
        }
        print $response;
        exit(0);
    }
}
Beispiel #3
0
/**
 * Reset all the FREE plugins, even if they are not activated.
 *
 * @param  boolean $process_form Whether a form was submitted or not.
 * @return void
 */
function sucuriscan_posthack_plugins($process_form = false)
{
    $template_variables = array('ResetPlugin.PluginList' => '', 'ResetPlugin.CacheLifeTime' => 'unknown');
    if (defined('SUCURISCAN_GET_PLUGINS_LIFETIME')) {
        $template_variables['ResetPlugin.CacheLifeTime'] = SUCURISCAN_GET_PLUGINS_LIFETIME;
    }
    sucuriscan_posthack_reinstall_plugins($process_form);
    $all_plugins = SucuriScanAPI::get_plugins();
    $counter = 0;
    foreach ($all_plugins as $plugin_path => $plugin_data) {
        $css_class = $counter % 2 == 0 ? '' : 'alternate';
        $plugin_type_class = $plugin_data['PluginType'] == 'free' ? 'primary' : 'warning';
        $input_disabled = $plugin_data['PluginType'] == 'free' ? '' : 'disabled="disabled"';
        $plugin_status = $plugin_data['IsPluginActive'] ? 'active' : 'not active';
        $plugin_status_class = $plugin_data['IsPluginActive'] ? 'success' : 'default';
        $template_variables['ResetPlugin.PluginList'] .= SucuriScanTemplate::get_snippet('posthack-resetplugins', array('ResetPlugin.CssClass' => $css_class, 'ResetPlugin.Disabled' => $input_disabled, 'ResetPlugin.PluginPath' => SucuriScan::escape($plugin_path), 'ResetPlugin.Plugin' => SucuriScan::excerpt($plugin_data['Name'], 35), 'ResetPlugin.Version' => $plugin_data['Version'], 'ResetPlugin.Type' => $plugin_data['PluginType'], 'ResetPlugin.TypeClass' => $plugin_type_class, 'ResetPlugin.Status' => $plugin_status, 'ResetPlugin.StatusClass' => $plugin_status_class));
        $counter += 1;
    }
    return SucuriScanTemplate::get_section('posthack-resetplugins', $template_variables);
}