Exemplo n.º 1
0
/**
 * Generate the HTML code for the firewall clear cache panel.
 *
 * @param  string $nonce Identifier of the HTTP request for CSRF protection
 * @return string        The parsed-content of the firewall clear cache panel.
 */
function sucuriscan_firewall_clearcache($nonce)
{
    $params = array();
    if ($nonce) {
        // Flush the cache of the site(s) associated with the API key.
        if (SucuriScanRequest::post(':clear_cache') == 1) {
            $response = SucuriScanAPI::clearCloudproxyCache();
            if ($response) {
                if (isset($response->messages[0])) {
                    // Clear W3 Total Cache if it is installed.
                    if (function_exists('w3tc_flush_all')) {
                        w3tc_flush_all();
                    }
                    SucuriScanInterface::info($response->messages[0]);
                } else {
                    SucuriScanInterface::error('Could not clear the cache of your site, try later again.');
                }
            } else {
                SucuriScanInterface::error('CloudProxy is not enabled on your site, or your API key is invalid.');
            }
        }
    }
    return SucuriScanTemplate::getSection('firewall-clearcache', $params);
}