true, CURLOPT_TIMEOUT => 8, CURLOPT_HTTPHEADER => [ 'apikey: ' . $anon, 'Authorization: Bearer ' . $anon, 'Accept: application/json', ], ]); $body = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($code !== 200 || !$body) return []; $data = json_decode($body, true); return is_array($data) ? $data : []; } function sync_post_page($root, $renderOrigin, $slug, $updatedAt) { if (!preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/', $slug)) return false; $dir = $root . '/blog/' . $slug; $file = $dir . '/index.html'; $sourceChanged = $updatedAt ? strtotime($updatedAt) : time(); if (is_file($file) && filemtime($file) >= $sourceChanged) return true; $ch = curl_init($renderOrigin . '/blog/' . rawurlencode($slug)); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 3, CURLOPT_TIMEOUT => 25, CURLOPT_HTTPHEADER => ['Accept: text/html'], CURLOPT_USERAGENT => 'ImmoGeneration-Plesk-Sitemap/1.0', ]); $html = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); curl_close($ch); if ($code !== 200 || !is_string($html) || stripos((string) $type, 'text/html') === false || stripos($html, ' 'weekly', 'priority' => '0.7']; $entries[] = ['loc' => "$BASE/mieten/$o", 'changefreq' => 'weekly', 'priority' => '0.7']; } foreach ($SERVICES as $s) { $entries[] = ['loc' => "$BASE/dienstleistungen/$s", 'changefreq' => 'weekly', 'priority' => '0.7']; } $posts = fetch_posts($SUPABASE_URL, $SUPABASE_ANON); foreach ($posts as $post) { $slug = $post['slug'] ?? null; if (!$slug) continue; sync_post_page(__DIR__, $RENDER_ORIGIN, $slug, $post['updated_at'] ?? $post['published_at'] ?? null); $lastmod = $post['updated_at'] ?? $post['published_at'] ?? null; $lastmod = $lastmod ? substr($lastmod, 0, 10) : null; $entries[] = [ 'loc' => "$BASE/blog/" . rawurlencode($slug), 'lastmod' => $lastmod, 'changefreq' => 'monthly', 'priority' => '0.6', ]; } echo '' . "\n"; echo '' . "\n"; foreach ($entries as $e) { echo " \n"; echo " " . htmlspecialchars($e['loc'], ENT_XML1) . "\n"; if (!empty($e['lastmod'])) echo " " . $e['lastmod'] . "\n"; if (!empty($e['changefreq'])) echo " " . $e['changefreq'] . "\n"; if (!empty($e['priority'])) echo " " . $e['priority'] . "\n"; echo " \n"; } echo '' . "\n";