예제 #1
0
function rs_wpss_jscripts_403_fix()
{
    /***
     * Check jscripts.php for 403/404/500 errors and fix by switching plugin into Compatibility Mode
     * Added 1.9.1
     ***/
    if (TRUE === WPSS_COMPAT_MODE || defined('WPSS_SOFT_COMPAT_MODE')) {
        return array('blocked' => FALSE, 'compat_mode' => TRUE);
    }
    $blocked = $compat_mode = FALSE;
    $url = WPSS_PLUGIN_JS_URL . '/jscripts.php';
    $status = rs_wpss_get_http_status($url);
    if ($status == '403' || $status == '404' || $status == '500') {
        $blocked = TRUE;
        $compat_mode = rs_wpss_modify_advanced('WPSS_COMPAT_MODE', 'FALSE', 'TRUE');
    }
    $status = compact('blocked', 'compat_mode');
    return $status;
}
function rs_wpss_jscripts_403_fix()
{
    /**
     * Check jscripts.php for 403/404/500 errors and fix by switching plugin into Compatibility Mode
     * Added 1.9.1
     * Also check for Surrogates: Varnish, CloudFlare (Rocket Loader), etc. - Added 1.9.7
     */
    if (TRUE === WPSS_COMPAT_MODE || defined('WPSS_SOFT_COMPAT_MODE')) {
        return array('blocked' => FALSE, 'compat_mode' => TRUE, 'surrogate' => FALSE);
    }
    $blocked = $compat_mode = $surrogate = FALSE;
    $url = WPSS_PLUGIN_JS_URL . '/jscripts.php';
    $hdr_data = rs_wpss_get_http_status($url);
    extract($hdr_data);
    $surros = array('X-Proxy-Cache', 'X-Cache', 'Server: cloudflare-nginx', 'CF-RAY: ', 'Via: 1.1 varnish', 'X-Varnish: ', 'X-Varnish-Cache: ', 'Incap-Client-IP: ', 'X-Amz-Cf-Id: ');
    /* Response Headers to flag */
    foreach ($headers as $i => $hdr) {
        $hdr = rs_wpss_casetrans('lower', $hdr);
        foreach ($surros as $i => $surro) {
            $surro = rs_wpss_casetrans('lower', $surro);
            if (strpos($hdr, $surro) === 0) {
                $surrogate = TRUE;
                break 2;
            }
        }
    }
    $web_host = rs_wpss_get_web_host();
    if ($web_host === 'WP Engine' || $web_host === 'SiteGround' || $web_host === 'Bluehost') {
        $surrogate = TRUE;
    }
    if ('403' == $status || '404' == $status || '500' == $status) {
        $blocked = TRUE;
    }
    if (TRUE === $blocked || TRUE === $surrogate) {
        $compat_mode = rs_wpss_modify_advanced('WPSS_COMPAT_MODE', 'FALSE', 'TRUE');
    }
    $status = compact('blocked', 'compat_mode', 'surrogate');
    return $status;
}