Example #1
0
/**
 * Display the page with a temporary message explaining the action that will be
 * performed once the hidden form is submitted to retrieve the scanning results
 * from the public SiteCheck API.
 *
 * @return void
 */
function sucuriscan_scanner_page()
{
    SucuriScanInterface::check_permissions();
    $template_variables = array();
    $cache = new SucuriScanCache('sitecheck');
    $scan_results = $cache->get('scan_results', SUCURISCAN_SITECHECK_LIFETIME, 'array');
    $report_results = (bool) ($scan_results && !empty($scan_results));
    if (SucuriScanInterface::check_nonce() && SucuriScanRequest::post(':malware_scan', '1')) {
        $report_results = true;
    }
    if ($report_results === true) {
        $template_name = 'malwarescan-results';
        $template_variables = sucuriscan_sitecheck_info($scan_results);
        $template_variables['PageTitle'] = 'Malware Scan';
        $template_variables['PageStyleClass'] = 'scanner-results';
    } else {
        $template_name = 'malwarescan';
        $template_variables['PageTitle'] = 'Malware Scan';
        $template_variables['PageStyleClass'] = 'scanner-loading';
    }
    echo SucuriScanTemplate::get_template($template_name, $template_variables);
}
/**
 * Display the page with a temporary message explaining the action that will be
 * performed once the hidden form is submitted to retrieve the scanning results
 * from the public SiteCheck API.
 *
 * @return void
 */
function sucuriscan_scanner_page()
{
    SucuriScanInterface::check_permissions();
    $params = array();
    $cache = new SucuriScanCache('sitecheck');
    $scan_results = $cache->get('scan_results', SUCURISCAN_SITECHECK_LIFETIME, 'array');
    $report_results = (bool) ($scan_results && !empty($scan_results));
    $nonce = SucuriScanInterface::check_nonce();
    // Retrieve SiteCheck scan results if user submits the form.
    if ($nonce && SucuriScanRequest::post(':malware_scan')) {
        $report_results = true;
    }
    /**
     * Retrieve SiteCheck results from custom domain.
     *
     * To facilitate the debugging of the code we will allow the existence of a
     * GET parameter that will force the plugin to scan a specific website
     * instead of the website where the plugin is running. Since this will be a
     * semi-hidden feature we can bypass some actions like the recycling of the
     * data returned by a previous scan.
     *
     * Usage: Add "&s=TLD" where TLD is a WordPress or non-WordPress website.
     */
    if ($nonce && SucuriScanRequest::get('s')) {
        $info = $cache->getDatastoreInfo();
        $report_results = true;
        $scan_results = false;
        @unlink($info['fpath']);
    }
    if ($report_results === true) {
        $template_name = 'malwarescan-results';
        $params = sucuriscan_sitecheck_info($scan_results);
        $params['PageTitle'] = 'Malware Scan';
        $params['PageStyleClass'] = 'scanner-results';
    } else {
        $template_name = 'malwarescan';
        $params['PageTitle'] = 'Malware Scan';
        $params['PageStyleClass'] = 'scanner-loading';
    }
    echo SucuriScanTemplate::getTemplate($template_name, $params);
}