GRAYBYTE WORDPRESS FILE MANAGER4374

Server IP : 198.54.121.189 / Your IP : 216.73.216.140
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /home/giriqfky/chahida.co.in/wp-content/plugins/sucuri-scanner/src/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/giriqfky/chahida.co.in/wp-content/plugins/sucuri-scanner/src//cachecontrol.lib.php
<?php
/**
 * Code related to the cache control headers settings.
 *
 * PHP version 5
 *
 * @category   Library
 * @package    Sucuri
 * @subpackage SucuriScanner
 * @author     Daniel Cid <dcid@sucuri.net>
 * @copyright  2010-2018 Sucuri Inc.
 * @license    https://www.gnu.org/licenses/gpl-2.0.txt GPL2
 * @link       https://wordpress.org/plugins/sucuri-scanner
 */

if (!defined('SUCURISCAN_INIT') || SUCURISCAN_INIT !== true) {
    if (!headers_sent()) {
        /* Report invalid access if possible. */
        header('HTTP/1.1 403 Forbidden');
    }
    exit(1);
}

/**
 * Cache-Control library.
 *
 * We use this library to set the cache control headers based on the user's
 * settings. The cache control headers are used to control how the browser
 * and proxies cache the content of the website.
 *
 * Please enable site caching on your WAF to use these settings.
 *
 * Please note that this is an advanced feature, and we took some inspiration
 * from another WordPress plugin called "cache-control", which hasn't been updated
 * in a long time. We've made some improvements and added some new features,
 * but we still want to give credit to the original author.
 *
 * @category   Library
 * @package    Sucuri
 * @subpackage SucuriScanner
 * @author     Daniel Cid <dcid@sucuri.net>
 * @copyright  2010-2018 Sucuri Inc.
 * @license    https://www.gnu.org/licenses/gpl-2.0.txt GPL2
 * @link       https://wordpress.org/plugins/sucuri-scanner
 */
class SucuriScanCacheHeaders extends SucuriScan
{
    protected function getCacheControlStaleFactor($factor, $maxAge)
    {
        if (is_paged() && is_int($factor) && $factor > 0) {
            $multiplier = get_query_var('paged') - 1;

            if ($multiplier > 0) {
                $factoredMaxAge = $factor * $multiplier;

                if ($factoredMaxAge >= ($maxAge * 10)) {
                    return $maxAge * 10;
                }

                return $factoredMaxAge;
            }
        }

        return 0;
    }

    protected function getFuturePostMaxTime($maxTimeFuture)
    {
        $futurePostQuery = new WP_Query(array(
            'post_status' => 'future',
            'posts_per_page' => 1,
            'orderby' => 'date',
            'order' => 'ASC',
            'ignore_sticky_posts' => 1
        ));

        if ($futurePostQuery->have_posts()) {
            $localNowTime = intval(current_time('timestamp', 0));

            while ($futurePostQuery->have_posts()) {
                $futurePostQuery->the_post();
                $localFutureTime = get_the_time('U');

                if (($localNowTime + $maxTimeFuture) > $localFutureTime) {
                    $maxTimeFuture = $localFutureTime - $localNowTime + rand(2, 32);
                }
            }

            wp_reset_postdata();
        }

        return $maxTimeFuture;
    }

    protected function getCacheDirectives($maxAge, $sMaxAge, $staleError, $staleRevalidate)
    {
        $directive = "";

        if (!empty($maxAge) && is_int($maxAge) && $maxAge > 0) {
            $directive = "max-age=$maxAge";
        }

        if (!empty($sMaxAge) && is_int($sMaxAge) && $sMaxAge > 0 && $sMaxAge != $maxAge) {
            if ($directive != "") {
                $directive = "public";
            }
            $directive .= ", s-maxage=$sMaxAge";
        }

        // Append RFC 5861 headers only if the request is cacheable
        if ($directive != "") {
            if (!empty($staleError) && is_int($staleError) && $staleError > 0) {
                $directive .= ", stale-if-error=$staleError";
            }

            if (!empty($staleRevalidate) && is_int($staleRevalidate) && $staleRevalidate > 0) {
                $directive .= ", stale-while-revalidate=$staleRevalidate";
            }

            $directive = apply_filters('cache_control_cache_directive', $directive);

            return $directive;
        }

        // Request isn't cacheable
        return "no-cache, no-store, must-revalidate";
    }

    protected function getCacheDirectiveFromOption($optionName)
    {
        $cacheOptions = SucuriScanOption::getOption(':headers_cache_control_options');

        $option = $cacheOptions[$optionName];

        $maxAge = intval($option['max_age']);
        $sMaxAge = intval($option['s_maxage']);
        $staleError = intval($option['stale_if_error']);
        $staleRevalidate = intval($option['stale_while_revalidate']);

        // Dynamically shorten caching time when a scheduled post is imminent
        if (!in_array($optionName, array('attachment_pages', 'dates', 'pages', 'singles', '404_not_found'))) {
            $maxAge = $this->getFuturePostMaxTime($maxAge);
            $sMaxAge = $this->getFuturePostMaxTime($sMaxAge);
        }

        if (is_paged() && isset($option['paged'])) {
            $pageFactor = intval(get_option('cache_control_' . $option['id'] . '_paged', $option['paged']));
            $maxAge += $this->getCacheControlStaleFactor($pageFactor, $maxAge);
            $sMaxAge += $this->getCacheControlStaleFactor($pageFactor, $sMaxAge);
        }

        if ($optionName == 'singles') {
            $dateNow = new DateTime();
            $dateModified = new DateTime(get_the_modified_date('c'));

            $lastComment = get_comments(array(
                'post_id' => get_the_ID(),
                'number' => 1,
                'include_unapproved' => 1,
                'orderby' => 'comment_date'
            ));

            if ($lastComment != null) {
                $lastCommentDate = new DateTime($lastComment[0]->comment_date);
                $dateModified = max(array($dateModified, $lastCommentDate));
            }

            $dateDiff = $dateNow->diff($dateModified);
            $monthsStale = $dateDiff->m + ($dateDiff->y * 12);

            if ($monthsStale > 0) {
                $maxAge = intval($maxAge * (($monthsStale + 12) / 12));
                $sMaxAge = intval($sMaxAge * (($monthsStale + 12) / 12));
            }
        }

        return $this->getCacheDirectives($maxAge, $sMaxAge, $staleError, $staleRevalidate);
    }

    protected function isNoCacheable()
    {
        global $wp_query;

        $nonCacheable = is_preview() || is_user_logged_in() || is_trackback() || is_admin();

        // Requires post password, and post has been unlocked.
        if (!$nonCacheable && isset($wp_query->posts) && count($wp_query->posts) >= 1 &&
            !empty($wp_query->posts[0]->post_password) && !post_password_required()) {
            $nonCacheable = true;
        } elseif (!$nonCacheable && function_exists('is_woocommerce')) {
            $nonCacheable = is_cart() || is_checkout() || is_account_page();
        }

        return $nonCacheable;
    }

    protected function isWooCommerceInstalled()
    {
        return in_array('woocommerce/woocommerce.php',
            apply_filters('active_plugins', get_option('active_plugins')));
    }

    protected function selectCacheDirective()
    {
        if ($this->isNoCacheable()) {
            return $this->getCacheDirectives(false, false, false, false);
        } elseif (is_feed()) {
            return $this->getCacheDirectiveFromOption('feeds');
        } elseif (is_front_page() && !is_paged()) {
            return $this->getCacheDirectiveFromOption('front_page');
        } elseif (is_single()) {
			if ($this->isWooCommerceInstalled() && function_exists('is_product') && is_product()) {
				return $this->getCacheDirectiveFromOption('woocommerce_products');
			}

            return $this->getCacheDirectiveFromOption('posts');
        } elseif (is_page()) {
            return $this->getCacheDirectiveFromOption('pages');
        } elseif (is_home()) {
            return $this->getCacheDirectiveFromOption('main_index');
        } elseif (is_category()) {
            return $this->getCacheDirectiveFromOption('categories');
        } elseif (is_tag()) {
            return $this->getCacheDirectiveFromOption('tags');
        } elseif (is_author()) {
            return $this->getCacheDirectiveFromOption('authors');
        } elseif (is_attachment()) {
            return $this->getCacheDirectiveFromOption('attachment_pages');
        } elseif (is_search()) {
            return $this->getCacheDirectiveFromOption('search_results');
        } elseif (is_404()) {
            return $this->getCacheDirectiveFromOption('404_not_found');
        } elseif (is_date()) {
            if ((is_year() && strcmp(get_the_time('Y'), date('Y')) < 0) ||
                (is_month() && strcmp(get_the_time('Y-m'), date('Y-m')) < 0) ||
                ((is_day() || is_time()) && strcmp(get_the_time('Y-m-d'), date('Y-m-d')) < 0)) {
                return $this->getCacheDirectiveFromOption('dates');
            } else {
                return $this->getCacheDirectiveFromOption('home');
            }
        }

	    if ($this->isWooCommerceInstalled() && function_exists('is_product_category') && is_product_category()) {
		    return $this->getCacheDirectiveFromOption('woocommerce_categories');
	    }

        return $this->getCacheDirectives(false, false, false, false);
    }

    protected function mergeHttpHeader($directives)
    {
        if (!empty($directives)) {
            header("Cache-Control: $directives", true);
        }
    }

    public function setCacheHeaders()
    {
        if (headers_sent()) {
            // Headers are already sent; nothing to do here.
            return;
        }

        $header = $this->selectCacheDirective();
        $this->mergeHttpHeader($header);
    }
}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 10 2025 04:32:19
giriqfky / giriqfky
0755
.htaccess
0.41 KB
July 10 2025 04:32:19
giriqfky / giriqfky
0644
api.lib.php
52.461 KB
April 28 2025 20:34:18
giriqfky / giriqfky
0644
auditlogs.lib.php
13.951 KB
April 28 2025 20:34:18
giriqfky / giriqfky
0644
base.lib.php
27.88 KB
February 12 2025 21:16:24
giriqfky / giriqfky
0644
cache.lib.php
16.152 KB
June 08 2022 20:57:14
giriqfky / giriqfky
0644
cachecontrol.lib.php
9.314 KB
February 12 2025 21:16:24
giriqfky / giriqfky
0644
cli.lib.php
4.798 KB
December 12 2018 04:56:40
giriqfky / giriqfky
0644
command.lib.php
6.192 KB
July 03 2018 22:25:46
giriqfky / giriqfky
0644
cors.lib.php
7.196 KB
January 22 2025 20:27:10
giriqfky / giriqfky
0644
cron.lib.php
1.805 KB
July 01 2022 20:48:54
giriqfky / giriqfky
0644
csp.lib.php
10.026 KB
January 22 2025 20:27:10
giriqfky / giriqfky
0644
event.lib.php
32.171 KB
April 17 2025 21:30:12
giriqfky / giriqfky
0644
fileinfo.lib.php
14.978 KB
February 21 2019 02:10:38
giriqfky / giriqfky
0644
firewall.lib.php
25.744 KB
August 05 2022 12:37:34
giriqfky / giriqfky
0644
fsscanner.lib.php
4.199 KB
May 22 2018 23:44:42
giriqfky / giriqfky
0644
globals.php
8.83 KB
April 28 2025 20:34:18
giriqfky / giriqfky
0644
hardening.lib.php
18.502 KB
February 12 2025 21:16:24
giriqfky / giriqfky
0644
hook.lib.php
38.228 KB
September 08 2022 20:53:50
giriqfky / giriqfky
0644
index.html
0.037 KB
June 26 2017 22:22:12
giriqfky / giriqfky
0644
installer-skin-legacy.lib.php
1.579 KB
July 26 2021 23:24:36
giriqfky / giriqfky
0644
installer-skin.lib.php
2.352 KB
July 26 2021 23:24:36
giriqfky / giriqfky
0644
integrity.lib.php
28.869 KB
August 26 2024 16:29:56
giriqfky / giriqfky
0644
interface.lib.php
12.518 KB
April 28 2025 20:34:18
giriqfky / giriqfky
0644
lastlogins-failed.php
14.315 KB
November 26 2019 03:09:50
giriqfky / giriqfky
0644
lastlogins-loggedin.php
7.799 KB
March 21 2024 02:14:38
giriqfky / giriqfky
0644
lastlogins.php
16.158 KB
December 14 2023 02:41:56
giriqfky / giriqfky
0644
mail.lib.php
9.767 KB
August 15 2024 20:16:00
giriqfky / giriqfky
0644
option.lib.php
47.315 KB
January 22 2025 20:27:10
giriqfky / giriqfky
0644
pagehandler.php
11.151 KB
April 28 2025 20:34:18
giriqfky / giriqfky
0644
request.lib.php
4.396 KB
March 17 2021 19:20:08
giriqfky / giriqfky
0644
settings-alerts.php
26.935 KB
August 15 2024 20:16:00
giriqfky / giriqfky
0644
settings-apiservice.php
6.386 KB
April 13 2023 15:12:38
giriqfky / giriqfky
0644
settings-general.php
22.646 KB
April 12 2023 12:24:48
giriqfky / giriqfky
0644
settings-hardening.php
35.405 KB
April 28 2025 20:34:18
giriqfky / giriqfky
0644
settings-headers.php
16.343 KB
April 28 2025 20:34:18
giriqfky / giriqfky
0644
settings-integrity.php
5.374 KB
February 21 2019 02:10:38
giriqfky / giriqfky
0644
settings-posthack.php
21.594 KB
April 28 2025 20:34:18
giriqfky / giriqfky
0644
settings-scanner.php
9.694 KB
February 18 2020 01:58:10
giriqfky / giriqfky
0644
settings-webinfo.php
5.546 KB
November 26 2019 03:09:50
giriqfky / giriqfky
0644
settings.php
0.925 KB
May 22 2018 23:44:42
giriqfky / giriqfky
0644
sitecheck.lib.php
19.209 KB
December 12 2022 20:45:18
giriqfky / giriqfky
0644
strings.php
49.83 KB
January 22 2025 20:27:10
giriqfky / giriqfky
0644
template.lib.php
18.983 KB
April 28 2025 20:34:18
giriqfky / giriqfky
0644
vulnerability.lib.php
4.748 KB
April 28 2025 20:34:18
giriqfky / giriqfky
0644
wordpress-recommendations.lib.php
10.9 KB
November 26 2019 03:09:50
giriqfky / giriqfky
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF