Example #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();
    $params = 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::getSitecheckResults($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>' . SucuriScan::escape($clean_domain) . '</code>' . ' was not scanned: ' . SucuriScan::escape($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();
        $params = sucuriscan_sitecheck_scanner_results($scan_results, $params);
        $params = sucuriscan_sitecheck_website_details($scan_results, $params);
        $params = sucuriscan_sitecheck_website_links($scan_results, $params);
        $params = sucuriscan_sitecheck_blacklist_status($scan_results, $params);
        $params = sucuriscan_sitecheck_modified_files($scan_results, $params);
        if (isset($scan_results['MALWARE']['WARN']) || isset($scan_results['BLACKLIST']['WARN'])) {
            $params['SignupButtonVisibility'] = 'visible';
        }
    }
    return $params;
}