| Server IP : 104.21.25.182 / Your IP : 216.73.217.83 Web Server : Apache System : Linux server.rehabsharif.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64 User : nobi37te ( 1003) PHP Version : 8.2.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/nobi37te/public_html/wp-content/plugins/nitropack/classes/Integration/Server/ |
Upload File : |
<?php
namespace NitroPack\Integration\Server;
// We need this to control Cloudflare in addition to any other proxy potentially provided by the origin host company
class Cloudflare {
const STAGE = "very_early";
public static function detect() {
return (!empty($_SERVER["HTTP_CF_CONNECTING_IP"]) && $_SERVER["HTTP_CF_CONNECTING_IP"] != "0.0.0.0")
|| !empty($_SERVER["HTTP_CF_RAY"])
|| !empty($_SERVER["HTTP_CF_IPCOUNTRY"]);
}
public static function isCacheEnabled() {
$siteConfig = get_nitropack()->getSiteConfig();
if ($siteConfig && !empty($siteConfig["hosting"]) && $siteConfig["hosting"] == "rocketnet") {
return self::detect();
}
return self::detect() && !empty($_SERVER["HTTP_SEC_CH_UA_MOBILE"]);
}
public function init($stage) {
if (self::detect()) {
nitropack_header("Accept-CH: Sec-CH-UA-Mobile");
if (self::isCacheEnabled()) {
add_action('nitropack_cacheable_cache_headers', [$this, 'allowProxyCache'], PHP_INT_MAX-1);
add_action('nitropack_cachehit_cache_headers', [$this, 'allowProxyCache'], PHP_INT_MAX-1);
} else {
add_action('nitropack_cacheable_cache_headers', [$this, 'preventProxyCache'], PHP_INT_MAX-1);
add_action('nitropack_cachehit_cache_headers', [$this, 'preventProxyCache'], PHP_INT_MAX-1);
}
}
}
public function allowProxyCache() {
$siteConfig = get_nitropack()->getSiteConfig();
if ($siteConfig && !empty($siteConfig["hosting"]) && $siteConfig["hosting"] == "rocketnet") {
nitropack_header( "Cloudflare-CDN-Cache-Control: public, max-age=0, s-maxage=300, stale-while-revalidate=3600" );
} else if ($siteConfig && !empty($siteConfig["isApoActive"])) {
nitropack_header("Cloudflare-CDN-Cache-Control: public, max-age=0, s-maxage=3600, stale-while-revalidate=3600");
} else {
nitropack_header("Vary: sec-ch-ua-mobile");
nitropack_header("Cloudflare-CDN-Cache-Control: public, max-age=0, s-maxage=15, stale-while-revalidate=3600");
}
}
public function preventProxyCache() {
nitropack_header("Cloudflare-CDN-Cache-Control: no-cache");
}
}