154 lines
4.0 KiB
PHP
154 lines
4.0 KiB
PHP
<?php
|
|
declare (strict_types = 1);
|
|
|
|
require_once __DIR__ . '/../includes/bootstrap_global.php';
|
|
require_once __DIR__ . '/includes/search_helpers.php';
|
|
|
|
header('Content-Type: application/xml; charset=UTF-8');
|
|
|
|
function xml_escape(string $s): string
|
|
{
|
|
return htmlspecialchars($s, ENT_QUOTES | ENT_XML1, 'UTF-8');
|
|
}
|
|
|
|
$base = 'https://uslugi.fr';
|
|
|
|
// =========================
|
|
// Pages fixes utiles
|
|
// =========================
|
|
$urls = [
|
|
[
|
|
'loc' => $base . '/',
|
|
'changefreq' => 'weekly',
|
|
'priority' => '1.0',
|
|
'lastmod' => date('Y-m-d'),
|
|
],
|
|
[
|
|
'loc' => $base . '/faq.php',
|
|
'changefreq' => 'weekly',
|
|
'priority' => '0.8',
|
|
'lastmod' => date('Y-m-d'),
|
|
],
|
|
[
|
|
'loc' => $base . '/about.php',
|
|
'changefreq' => 'monthly',
|
|
'priority' => '0.6',
|
|
'lastmod' => date('Y-m-d'),
|
|
],
|
|
[
|
|
'loc' => $base . '/how-it-work.php',
|
|
'changefreq' => 'monthly',
|
|
'priority' => '0.6',
|
|
'lastmod' => date('Y-m-d'),
|
|
],
|
|
[
|
|
'loc' => $base . '/contact.php',
|
|
'changefreq' => 'monthly',
|
|
'priority' => '0.6',
|
|
'lastmod' => date('Y-m-d'),
|
|
],
|
|
];
|
|
|
|
// =========================
|
|
// Pages catégories SEO
|
|
// =========================
|
|
$categorySlugs = [
|
|
'avocat',
|
|
'consultant',
|
|
'medecin',
|
|
'psychologue',
|
|
'professeur',
|
|
'comptable',
|
|
'traducteur',
|
|
'notaire',
|
|
'guide',
|
|
'agent-immobilier',
|
|
'autres-specialistes',
|
|
];
|
|
|
|
foreach ($categorySlugs as $slug) {
|
|
$urls[] = [
|
|
'loc' => $base . '/recherche/' . $slug . '/',
|
|
'changefreq' => 'daily',
|
|
'priority' => '0.9',
|
|
'lastmod' => date('Y-m-d'),
|
|
];
|
|
}
|
|
|
|
// =========================
|
|
// Profils spécialistes actifs
|
|
// =========================
|
|
$sql = "
|
|
SELECT id, prenom, nom, ville, specialite, updated_at
|
|
FROM praticien
|
|
WHERE date_expiration IS NOT NULL
|
|
AND date_expiration >= DATE_SUB(NOW(), INTERVAL 14 DAY)
|
|
";
|
|
$stmt = $pdo->query($sql);
|
|
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
foreach ($rows as $p) {
|
|
$specSlug = 'specialiste';
|
|
|
|
if (! empty($p['specialite'])) {
|
|
$specDb = mb_strtolower(trim((string) $p['specialite']), 'UTF-8');
|
|
|
|
foreach (seo_spec_map() as $slug => $cfg) {
|
|
$dbVal = mb_strtolower(trim((string) ($cfg['db'] ?? '')), 'UTF-8');
|
|
|
|
if ($dbVal === $specDb || ($dbVal !== '' && mb_stripos($specDb, $dbVal, 0, 'UTF-8') === 0)) {
|
|
$specSlug = $slug;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
$citySlug = ! empty($p['ville']) ? seo_city_slug_from_input((string) $p['ville']) : 'france';
|
|
|
|
$nameSlug = seo_slug(trim((string) ($p['prenom'] ?? '') . ' ' . (string) ($p['nom'] ?? '')));
|
|
if ($nameSlug === '') {
|
|
$nameSlug = 'profil';
|
|
}
|
|
|
|
$loc = $base . '/specialistes/'
|
|
. rawurlencode($specSlug) . '/'
|
|
. rawurlencode($citySlug) . '/'
|
|
. rawurlencode($nameSlug . '-' . (int) $p['id']) . '/';
|
|
|
|
$lastmod = date('Y-m-d');
|
|
if (! empty($p['updated_at'])) {
|
|
$ts = strtotime((string) $p['updated_at']);
|
|
if ($ts) {
|
|
$lastmod = date('Y-m-d', $ts);
|
|
}
|
|
}
|
|
|
|
$urls[] = [
|
|
'loc' => $loc,
|
|
'changefreq' => 'weekly',
|
|
'priority' => '0.8',
|
|
'lastmod' => $lastmod,
|
|
];
|
|
}
|
|
|
|
// =========================
|
|
// Sortie XML
|
|
// =========================
|
|
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
|
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
|
|
|
|
foreach ($urls as $url) {
|
|
echo " <url>\n";
|
|
echo ' <loc>' . xml_escape($url['loc']) . "</loc>\n";
|
|
|
|
if (! empty($url['lastmod'])) {
|
|
echo ' <lastmod>' . xml_escape($url['lastmod']) . "</lastmod>\n";
|
|
}
|
|
|
|
echo ' <changefreq>' . xml_escape($url['changefreq']) . "</changefreq>\n";
|
|
echo ' <priority>' . xml_escape($url['priority']) . "</priority>\n";
|
|
echo " </url>\n";
|
|
}
|
|
|
|
echo '</urlset>';
|