142 lines
4.8 KiB
PHP
142 lines
4.8 KiB
PHP
<?php
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/search_helpers.php';
|
|
|
|
// Mapping inverse
|
|
$UGLY_TO_PRETTY = [
|
|
// racine
|
|
'/index.php' => '/',
|
|
'/detail_public.php' => '/specialistes',
|
|
'/connexion.php' => '/login',
|
|
'/choix_inscr.php' => '/choix-inscription',
|
|
'/inscription_client.php' => '/inscription-client',
|
|
'/inscription_praticien.php' => '/inscription-praticien',
|
|
'/mdp_oublie.php' => '/mot-de-passe-oublie',
|
|
'/avis_public.php' => '/avis',
|
|
|
|
// dossier client
|
|
'/public/client/informations.php' => '/profil',
|
|
'/public/client/modifier.php' => '/modifier-profil',
|
|
'/public/client/compte.php' => '/mon-compte',
|
|
'/public/client/list_praticien.php' => '/trouver-specialistes',
|
|
'/public/client/mes_favori.php' => '/mes-preferences',
|
|
'/public/client/detail_praticien.php' => '/specialiste',
|
|
'/public/client/avis.php' => '/donner-avis',
|
|
'/public/client/reserver_rdv.php' => '/reservation',
|
|
'/public/client/mes_rendez_vous.php' => '/mes-rendez-vous',
|
|
|
|
// dossier praticien
|
|
'/public/praticien/informations.php' => '/profil-pro',
|
|
'/public/praticien/modifier.php' => '/modifier-profil-pro',
|
|
'/public/praticien/compte.php' => '/mon-compte-pro',
|
|
'/public/praticien/disponibilites.php' => '/mes-creneaux',
|
|
'/public/praticien/disponibilites_date.php' => '/mes-creneaux-date',
|
|
'/public/praticien/rendez_vous.php' => '/mes-consultations',
|
|
'/public/praticien/rendez_vous_du_jour.php' => '/consultations-du-jour',
|
|
'/public/praticien/agenda.php' => '/agenda',
|
|
'/public/praticien/synchronisation.php' => '/connecter-agenda',
|
|
'/public/praticien/resiliation.php' => '/abonnement',
|
|
'/public/praticien/factures.php' => '/mes-factures',
|
|
];
|
|
|
|
$PRETTY_TO_UGLY = array_flip($UGLY_TO_PRETTY);
|
|
|
|
// Quel slug demandé ?
|
|
$slug = $_GET['slug'] ?? '';
|
|
$slug = '/' . trim($slug, '/');
|
|
|
|
// =========================
|
|
// Routes dynamiques recherche
|
|
// =========================
|
|
|
|
// /recherche
|
|
if ($slug === '/recherche') {
|
|
$targetRelative = '/result_search.php';
|
|
$targetAbsolute = $_SERVER['DOCUMENT_ROOT'] . $targetRelative;
|
|
|
|
define('ROUTED_PRETTY', true);
|
|
chdir(dirname($targetAbsolute));
|
|
require $targetAbsolute;
|
|
exit;
|
|
}
|
|
// /recherche/ville/{ville}
|
|
if (preg_match('#^/recherche/ville/([^/]+)$#', $slug, $m)) {
|
|
$_GET['ville'] = seo_unslug(rawurldecode($m[1]));
|
|
|
|
$targetRelative = '/result_search.php';
|
|
$targetAbsolute = $_SERVER['DOCUMENT_ROOT'] . $targetRelative;
|
|
|
|
define('ROUTED_PRETTY', true);
|
|
chdir(dirname($targetAbsolute));
|
|
require $targetAbsolute;
|
|
exit;
|
|
}
|
|
// /recherche/{specialite}
|
|
if (preg_match('#^/recherche/([^/]+)$#', $slug, $m)) {
|
|
$_GET['specialite'] = seo_unslug(rawurldecode($m[1]));
|
|
|
|
$targetRelative = '/result_search.php';
|
|
$targetAbsolute = $_SERVER['DOCUMENT_ROOT'] . $targetRelative;
|
|
|
|
define('ROUTED_PRETTY', true);
|
|
chdir(dirname($targetAbsolute));
|
|
require $targetAbsolute;
|
|
exit;
|
|
}
|
|
|
|
// /recherche/{specialite}/{ville}
|
|
if (preg_match('#^/recherche/([^/]+)/([^/]+)$#', $slug, $m)) {
|
|
$_GET['specialite'] = seo_unslug(rawurldecode($m[1]));
|
|
$_GET['ville'] = seo_unslug(rawurldecode($m[2]));
|
|
|
|
$targetRelative = '/result_search.php';
|
|
$targetAbsolute = $_SERVER['DOCUMENT_ROOT'] . $targetRelative;
|
|
|
|
define('ROUTED_PRETTY', true);
|
|
chdir(dirname($targetAbsolute));
|
|
require $targetAbsolute;
|
|
exit;
|
|
}
|
|
// /specialistes/{specialite}/{ville}/{nom-id}
|
|
if (preg_match('#^/specialistes/([^/]+)/([^/]+)/([^/]+)-([0-9]+)$#', $slug, $m)) {
|
|
$_GET['id'] = (int) $m[4];
|
|
|
|
$targetRelative = '/detail_public.php';
|
|
$targetAbsolute = $_SERVER['DOCUMENT_ROOT'] . $targetRelative;
|
|
|
|
define('ROUTED_PRETTY', true);
|
|
chdir(dirname($targetAbsolute));
|
|
require $targetAbsolute;
|
|
exit;
|
|
}
|
|
// /sitemap.xml
|
|
if ($slug === '/sitemap.xml') {
|
|
$targetRelative = '/sitemap_xml.php';
|
|
$targetAbsolute = $_SERVER['DOCUMENT_ROOT'] . $targetRelative;
|
|
|
|
define('ROUTED_PRETTY', true);
|
|
chdir(dirname($targetAbsolute));
|
|
require $targetAbsolute;
|
|
exit;
|
|
}
|
|
// =========================
|
|
// Routes fixes existantes
|
|
// =========================
|
|
if (! isset($PRETTY_TO_UGLY[$slug])) {
|
|
http_response_code(404);
|
|
echo 'Page non trouvée';
|
|
exit;
|
|
}
|
|
|
|
$targetRelative = $PRETTY_TO_UGLY[$slug];
|
|
$targetAbsolute = $_SERVER['DOCUMENT_ROOT'] . $targetRelative;
|
|
|
|
if (! is_file($targetAbsolute)) {
|
|
http_response_code(404);
|
|
echo 'Cible introuvable';
|
|
exit;
|
|
}
|
|
|
|
define('ROUTED_PRETTY', true);
|
|
chdir(dirname($targetAbsolute));
|
|
require $targetAbsolute;
|