Пример #1
0
/**
 * Display the result of site scan made through SiteCheck.
 *
 * @param  array $scan_results Array with information of the scanning.
 * @return array               Array with psuedo-variables to build the template.
 */
function sucuriscan_sitecheck_info($scan_results = array())
{
    $clean_domain = SucuriScan::get_domain();
    $template_variables = array('ScannedDomainName' => $clean_domain, 'ScannerResults.CssClass' => '', 'ScannerResults.Content' => '', 'WebsiteDetails.CssClass' => '', 'WebsiteDetails.Content' => '', 'BlacklistStatus.CssClass' => '', 'BlacklistStatus.Content' => '', 'WebsiteLinks.CssClass' => '', 'WebsiteLinks.Content' => '', 'ModifiedFiles.CssClass' => '', 'ModifiedFiles.Content' => '', 'SignupButtonVisibility' => 'hidden');
    // If the results are not cached, then request a new scan and store in cache.
    if ($scan_results === false) {
        $scan_results = SucuriScanAPI::get_sitecheck_results($clean_domain);
        // Check for error messages in the request's response.
        if (is_string($scan_results)) {
            if (preg_match('/^ERROR:(.*)/', $scan_results, $error_m)) {
                SucuriScanInterface::error('The site <code>' . $clean_domain . '</code> was not scanned: ' . $error_m[1]);
            } else {
                SucuriScanInterface::error('SiteCheck error: ' . $scan_results);
            }
        } else {
            $cache = new SucuriScanCache('sitecheck');
            $results_were_cached = $cache->add('scan_results', $scan_results);
            if (!$results_were_cached) {
                SucuriScanInterface::error('Could not cache the malware scan results.');
            }
        }
    }
    if (is_array($scan_results) && !empty($scan_results)) {
        // Increase the malware scan counter.
        $sitecheck_counter = (int) SucuriScanOption::get_option(':sitecheck_counter');
        SucuriScanOption::update_option(':sitecheck_counter', $sitecheck_counter + 1);
        add_thickbox();
        $template_variables = sucuriscan_sitecheck_scanner_results($scan_results, $template_variables);
        $template_variables = sucuriscan_sitecheck_website_details($scan_results, $template_variables);
        $template_variables = sucuriscan_sitecheck_website_links($scan_results, $template_variables);
        $template_variables = sucuriscan_sitecheck_blacklist_status($scan_results, $template_variables);
        $template_variables = sucuriscan_sitecheck_modified_files($scan_results, $template_variables);
        if (isset($scan_results['MALWARE']['WARN']) || isset($scan_results['BLACKLIST']['WARN'])) {
            $template_variables['SignupButtonVisibility'] = 'visible';
        }
    }
    return $template_variables;
}