Site Builder
Editing:
new-sitemap.php
writable 0666
<?php // --- SETTINGS --- $phDir = $_SERVER['DOCUMENT_ROOT'] . '/ph/'; $baseUrl = 'https://' . $_SERVER['HTTP_HOST']; // --- Build sitemap entries --- $urls = []; foreach (scandir($phDir) as $d) { if (!preg_match('/^\d{10}$/', $d)) continue; $dir = $phDir . $d; if (!is_dir($dir)) continue; // Prefer paid if (is_readable("$dir/business.json")) $json = "$dir/business.json"; elseif (is_readable("$dir/new-business.json")) $json = "$dir/new-business.json"; else continue; $mtime = filemtime($json); $urls[] = [ 'loc' => "$baseUrl/ph/$d/", 'lastmod' => date('Y-m-d', $mtime), 'priority' => is_readable("$dir/business.json") ? '1.0' : '0.5' ]; } // --- Generate XML --- $xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n"; foreach ($urls as $u) { $xml .= " <url>\n"; $xml .= " <loc>" . htmlspecialchars($u['loc']) . "</loc>\n"; $xml .= " <lastmod>{$u['lastmod']}</lastmod>\n"; $xml .= " <priority>{$u['priority']}</priority>\n"; $xml .= " </url>\n"; } $xml .= "</urlset>\n"; // --- Save to file --- $mapFile = __DIR__ . '/new-sitemap.xml'; file_put_contents($mapFile, $xml); // --- Output result --- header('Content-Type: text/html; charset=utf-8'); ?> <!DOCTYPE html> <html lang="en"> <head> <title>Sitemap Generated</title> <meta name="viewport" content="width=device-width,initial-scale=1"> <style> body{background:#f5f8fb;font-family:sans-serif;color:#234;text-align:center;margin:0;} .card{max-width:440px;margin:4em auto 0;background:#fff;border-radius:15px;box-shadow:0 2px 16px #dde3fa25;padding:2em 1.6em;} h1{color:#2757a5;} a{color:#3b54db;text-decoration:underline;} </style> </head> <body> <div class="card"> <h1>✅ Sitemap Created</h1> <p><b><?= count($urls) ?></b> business listings exported to <b>new-sitemap.xml</b>!</p> <p> <a href="new-sitemap.xml" target="_blank">View Sitemap XML</a><br> <span style="color:#888;font-size:.97em;">(Submit this URL to Google/Bing for fast indexing)</span> </p> <hr style="margin:2em 0 1em 0;"> <p style="color:#7686ad;font-size:.96em;"> Last updated: <?= date('Y-m-d H:i:s') ?><br> <span style="font-size:.95em;">Priority: <b>1.0</b> (premium/paid), <b>0.5</b> (free)</span> </p> </div> </body> </html>
Save changes
Create folder
writable 0777
Create
Cancel