| Current Path : /home/h/a/p/happyrenas/myreco.online/old/ |
Linux webd005.cluster105.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 |
| Current File : /home/h/a/p/happyrenas/myreco.online/old/fiche1.php |
<?
include("configuration.php");
include("includes/fonctions.php");
$country_code="FR";
$trad = chargerTraductions($country_code);
// ➤ Extraction de la ville et du code pays
$parts = explode(',', ($_GET["ville_pays"]));
$ville_clean = trim($parts[0]);
$pays_clean = strtoupper(trim($parts[1] ?? ''));
// ➤ Vérifier si cache déjà existant :
$requete_cache="
SELECT resultat_json, compteur
FROM ville_recherche_cache
WHERE ville = '" . $db->escape($ville_clean) . "'
AND pays = '" . $db->escape($pays_clean) . "'
";
$cache = $db->get_row($requete_cache);
$cache="";
if ($cache) {
$miseencache=1;
// Mise à jour du compteur
$db->query("
UPDATE ville_recherche_cache
SET compteur = compteur + 1, last_search = NOW()
WHERE ville = '" . $db->escape($ville_clean) . "'
AND pays = '" . $db->escape($pays_clean) . "'
");
$tableau_liste = json_decode($cache->resultat_json, true);
} else {
$miseencache=0;
// ➤ Sinon
$tableau_liste = rechercherHebergementsProches($_GET['ville_pays'], $db);
//echo "<pre>";
//print_r($tableau_liste);
//echo "</pre>";
//exit;
// Enregistrement dans le cache
$db->query("
INSERT INTO ville_recherche_cache (ville, pays, resultat_json)
VALUES (
'" . $db->escape($ville_clean) . "',
'" . $db->escape($pays_clean) . "',
'" . $db->escape(json_encode($tableau_liste, JSON_UNESCAPED_UNICODE)) . "'
)
ON DUPLICATE KEY UPDATE
resultat_json = VALUES(resultat_json),
compteur = compteur + 1,
last_search = NOW()
");
}
// ➤ Gestion de la langue
if (isset($_GET['langue']) && in_array(strtoupper($_GET['langue']), $langues)) {
$_SESSION['langue'] = strtoupper($_GET['langue']);
}
if (isset($_SESSION['langue']) && in_array($_SESSION['langue'], $langues)) {
$langue = $_SESSION['langue'];
} else {
$country_code = strtoupper($pays_clean ?? 'FR');
$langue = in_array($country_code, $langues) ? $country_code : 'FR';
$_SESSION['langue'] = $langue; // On l'enregistre aussi
}
$trad = chargerTraductions($langue);
?>
<html class="no-js" lang="<?echo $country_code;?>">
<head>
<?include("includes/google_head.php");?>
<meta charset="utf-8">
<title>MyReco.Online</title>
<meta name="description" content="">
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="https://www.myreco.online/img/icone.png" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="stylesheet" href="css/custom.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script src="https://cdn.jsdelivr.net/npm/flatpickr/dist/l10n/fr.js"></script>
<script type="text/javascript" src="js/custom.js"></script>
<style>
@media (max-width: 575.98px) {
.btn-km {
padding: .15rem .35rem; /* plus serré */
font-size: .75rem; /* plus petit */
line-height: 1.2;
}
}
.awesomplete ul {
background-color: #fff;
border: 1px solid #6B757D;
border-radius: 4px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.awesomplete li {
padding: 8px 12px;
color: #6B757D;
font-weight: 500;
}
.awesomplete li[aria-selected="true"] {
background: #e1dbd5;
}
.sticky-box {
position: sticky;
top: 0;
height: 100vh; /* toute la hauteur de la fenêtre */
background: #f8f9fa; /* optionnel */
padding: 0; /* pas de padding sinon ça réduit l’espace pour la carte */
}
#map {
width: 100%;
height: 100%; /* occupe tout l’espace de .sticky-box */
}
.awesomplete ul {
background-color: #fff;
border: 1px solid #6B757D;
border-radius: 4px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.awesomplete li {
padding: 8px 12px;
color: #6B757D;
font-weight: 500;
}
.awesomplete li[aria-selected="true"] {
background: #e1dbd5;
}
.awesomplete {
display: block; /* occupe toute la largeur */
width: 100% !important;
}
.awesomplete > input {
width: 100% !important;
}
</style>
</head>
<body>
<div id="halt_loader_overlay"></div>
<div id="halt_loader" class=""><i class="fa fa-spinner fa-spin"></i> <?echo $trad['Chargement des informations, merci de patienter'] ?? '⚠️';?></div>
<div id="halt_initialisation" class=""><i class="fa fa-spinner fa-spin"></i> <?echo $trad['Premiere initialisation merci de patienter'] ?? '⚠️';?></div>
<?
include("includes/google_body.php");?>
<!-- NAVBAR -->
<nav class="navbar navbar-light bg-light fixed-top shadow-sm">
<div class="container-fluid px-2 px-md-3">
<div class="d-flex w-100 flex-column flex-md-row align-items-stretch align-items-md-center justify-content-md-between">
<!-- Logo -->
<div class="d-flex align-items-center mb-2 mb-md-0 mr-md-2">
<img src="img/logo_myreco.png" alt="Logo" class="d-none d-md-block" style="height: 40px;">
<img src="img/logo_myreco.png" alt="Logo Mobile" class="d-md-none" style="height: 15px;">
</div>
<!-- Formulaire -->
<div class="d-flex align-items-stretch flex-grow-1 w-100">
<form method="get" action="fiche1.php" id="rechercheForm" class="w-100">
<!-- Champ ville : toujours visible -->
<div class="position-relative w-100">
<input
type="text"
name="ville_pays"
id="ville_pays"
class="text-info awesomplete form-control form-control-sm w-100 pr-4 mb-1"
placeholder="Ville"
autocomplete="off"
value="<?= htmlspecialchars($_GET['ville_pays'] ?? '') ?>"
>
<!-- Clear bouton (×) -->
<span id="clear_ville"
style="position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
cursor: pointer; color: #6b757d; display: none; font-size: 1.2em; line-height: 1;">
×
</span>
</div>
<!-- Bloc avancé : caché sur mobile, visible desktop -->
<div id="recherche-avancee"
class="d-none d-md-flex flex-column flex-md-row align-items-md-center w-100 mt-2 mt-md-0">
<input
type="text"
id="date_arrivee"
name="date_arrivee"
class="form-control form-control-sm mb-2 mb-md-0"
placeholder="Date d’arrivée"
value="<?= htmlspecialchars($_GET['date_arrivee'] ?? '') ?>"
>
<input
type="text"
id="date_depart"
name="date_depart"
class="form-control form-control-sm mb-2 mb-md-0 ml-md-1"
placeholder="Date de départ"
value="<?= htmlspecialchars($_GET['date_depart'] ?? '') ?>"
>
<button
type="submit"
id="btn_rechercher"
class="btn btn-sm btn-success mb-2 mb-md-0 ml-md-1"
>
Rechercher
</button>
<!-- Bouton Annuler (mobile uniquement) -->
<button type="button" id="btn_annuler"
class="btn btn-sm btn-outline-secondary d-md-none"
style="width:100%; margin-top:4px;">
Annuler
</button>
<!-- Dropdown langue -->
<div class="dropdown mb-2 mb-md-0 ml-md-1">
<button class="btn btn-sm btn-outline-secondary dropdown-toggle d-flex align-items-center"
type="button" id="dropdownLangue" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img src="img/flag/ico/<?php echo strtolower($langue ?? 'fr'); ?>.png" alt="flag"
style="height: 16px; width: auto; margin-right: 5px;">
<?php echo strtoupper($langue ?? 'FR'); ?>
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownLangue">
<?php foreach ($langues as $l): ?>
<?php $url = "fiche.php?token=$token&query=$query&categorie=$categorie&$mrx_variable&langue=$l"; ?>
<a class="dropdown-item d-flex align-items-center" href="<?= $url ?>">
<img src="img/flag/ico/<?= strtolower($l) ?>.png" alt="<?= $l ?>"
style="height: 16px; width: auto; margin-right: 8px;">
<?= $l ?>
</a>
<?php endforeach; ?>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</nav>
<!-- (Optionnel) espace sous la navbar fixe -->
<style>
body { padding-top: 64px; }
@media (min-width: 768px) { body { padding-top: 72px; } }
</style>
<div class="mt-3 mb-3"> </div>
<?
?>
<div class="row">
<div class="col-12 col-md-6">
<div class="container mycards">
<div class="row">
<?//echo "<pre>";print_r($tableau_liste);echo"</pre>";?>
<?php
foreach ($tableau_liste as $lieu) {
$numero++;
if (!$lieu['photo_locale']) {
$resultat = verifierOuRecupererPhoto($lieu['token'], "heb");
$hebergement_photo ='img/hebergement.png';
if ($resultat['url']) {
$photo_locale=$resultat['url'];
$db->query("UPDATE heb SET photo_locale = '".$photo_locale."' where token='".$token."'");
}
}
?>
<div class="col-sm-6 py-2 mb-2">
<div class="card h-100">
<div id="demo<?echo $lieu['id'];?>" class="carousel slide" data-interval="999999999" data-touch="true" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active"><img src="../<?echo $lieu['photo_locale'];?>"></div>
</div>
<p class="basdroite" style="position:absolute;margin-left:0;border:0px;"><span style="background-color:#34DA66!important;font-size:0.9rem;color:#ffffff!important;" class="badge"><i class="far fa-heart "></i> <?echo $lieu['compteur_like'];?></span></p>
</div>
<p style="position:absolute;margin-left:0;border:0px;"><span style="background-color:#6B757D!important;font-size:1.5rem;color:#ffffff!important;" class="badge"><?echo $numero;?></span></p>
<div class="description card-body text-center">
<h3 class="card-title"><?echo $lieu['name'];?></h3>
<h4 class="card-subtitle"><span style="font-size:16px;"><?echo $lieu['postal_code'];?></span> <?echo $lieu['city'];?></h4>
<p><?echo $trad['A'] ?? '⚠️';?> <?echo $lieu['distance'];?> km</p>
<?if ($lieu['lien_reservation']) {?><p><a target="_blank" href='<?echo $lieu['lien_reservation'];?>'><span style="padding:6px;important!font-size:.8rem;" class="badge badge-info"><?echo $trad['Réserver'] ?? '⚠️';?></span></a></p><?}?>
<p>
<?
if (strlen($lieu['dernier_avis'])>100){
echo mb_substr($lieu['dernier_avis'],0,101);?>
<span class="collapse" id="more<?echo $lieu['id'];?>"><?echo mb_substr($lieu['dernier_avis'],101);?></span>
<span><a href="#more<?echo $lieu['id'];?>" data-toggle="collapse">... <i class="fa fa-caret-down"></i></a></span>
<?} else {
echo $lieu['dernier_avis'];
}
?>
</p><p></p>
</div>
<div style="padding-left:4!important;padding-right:4!important;" class="card-footer card-p">
<div class="row">
<div class="col-12 text-center mt-1">
<button type="button" id="btn_annuler"
class="btn btn-sm btn-outline-secondary"
style="width:100%; margin-top:4px;">
Contacter l'hôte
</button>
</div>
</div>
</div>
</div>
</div>
<!----------
🔁 MODALE 🔁
------------>
<div class="modal fade" id="form<?echo $lieu['id'];?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header border-bottom-0">
<h5 class="modal-title" id="exampleModalLabel"><?echo $trad['Votre avis'] ?? '⚠️';?><br></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<form method="post" action="fiche.php">
<input type="hidden" name="name" value="<?echo $name;?>">
<input type="hidden" name="token_fiche_visite" value="<?echo $liste->token;?>">
<input type="hidden" name="token" value="<?echo $token;?>">
<input type="hidden" name="query" value="<?echo $query;?>">
<input type="hidden" name="categorie" value="<?echo $categorie;?>">
<?php
for ($i = 1; $i <= 15; $i++) {
$varName = 'mrx' . $i;
$value = isset($$varName) ? $$varName : ''; // sécurité si jamais une variable manque
echo '<input type="hidden" name="' . $varName . '" value="' . htmlspecialchars($value) . '">' . "\n";
}
?>
<div class="modal-body">
<div class="form-group">
<textarea class="form-control" id="avis" name="avis" rows="6" placeholder="<?echo $trad['Laissez un petit commentaire positif'] ?? '⚠️';?>"></textarea>
</div>
</div>
<div class="modal-footer border-top-0 d-flex justify-content-center">
<button type="submit" class="btn btn-success"><?echo $trad['Je signale'] ?? '⚠️';?></button>
<h6 class="modal-title" id="exampleModalLabel"><br><?echo $trad['Les prochains clients de cet hébergement'] ?? '⚠️';?></h5>
</div>
</form>
</div>
</div>
</div>
<!----------
🔁 MODALE 🔁
------------>
<?
}
?>
</div>
</div>
</div>
<!-- Colonne droite -->
<div class="col-6 d-none d-md-block">
<div class="sticky-box">
<div id="map" style="height: 800px;margin-top:120px; margin-bottom: 30px;"></div>
</div>
</div>
</div>
<div class="mt-3 mb-3"> </div>
<nav class="navbar fixed-bottom navbar-light bg-light">
<div class="container d-flex justify-content-between align-items-center">
<a class="btn btn-secondary btn-km text-white <?if ($categorie=="a_voir") {?> active<?}?>" onclick="showLoader();" href="fiche.php?token=<?echo $token;?>&categorie=a_voir"><?echo $trad['A voir'] ?? '⚠️';?></a>
<a class="btn btn-secondary btn-km text-white <?if ($categorie=="restaurant") {?> active<?}?>" onclick="showLoader();" href="fiche.php?token=<?echo $token;?>&categorie=restaurant"><?echo $trad['Restaurant'] ?? '⚠️';?></a>
<a class="btn btn-secondary btn-km text-white <?if ($categorie=="ludique") {?> active<?}?>" onclick="showLoader();" href="fiche.php?token=<?echo $token;?>&categorie=ludique"><?echo $trad['Ludique'] ?? '⚠️';?></a>
<a class="btn btn-secondary btn-km text-white <?if ($categorie=="soiree") {?> active<?}?>" onclick="showLoader();" href="fiche.php?token=<?echo $token;?>&categorie=soiree"><?echo $trad['En soirée'] ?? '⚠️';?></a>
<a class="mt-3 btn btn-block btn-secondary text-white <?if ($categorie=="reco") {?> active<?}?>" href="fiche.php?token=<?echo $token;?>&categorie=reco"><?echo $trad['Les recos du proprio'] ?? '⚠️';?></a>
</div>
</nav>
<script type="text/javascript" src="js/notify.js"></script>
<!-- Leaflet -->
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
<!-- CSS Awesomplete -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/awesomplete/1.1.5/awesomplete.css" />
<!-- JS Awesomplete -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/awesomplete/1.1.5/awesomplete.min.js"></script>
<?php
$points = [];
foreach ($tableau_liste as $lieu) {
//$fiche = $db->get_row("SELECT * FROM heb WHERE id = " . intval($lieu['id']));
$points[] = [
'nom' => $lieu['name'],
'ville' => $lieu['ville'],
'tarif' => $lieu['tarif_nuit'],
'lat' => floatval($lieu['latitude']),
'lon' => floatval($lieu['longitude']),
'id' => $lieu['id']
];
}
?>
<script>
const hebPoints = <?= json_encode($points); ?>;
</script>
<script>
document.addEventListener("DOMContentLoaded", function () {
var villeInput = document.getElementById("ville_pays");
var clearVille = document.getElementById("clear_ville");
var blocAvance = document.getElementById("recherche-avancee");
// Affiche le bloc avancé au focus sur mobile
function showAdvancedIfMobile() {
if (window.innerWidth < 768) {
// Passe de d-none à d-flex (colonne sur mobile)
blocAvance.classList.remove("d-none");
blocAvance.classList.add("d-flex");
}
}
villeInput.addEventListener("focus", showAdvancedIfMobile);
// Bouton clear (×)
function toggleClear() {
clearVille.style.display = villeInput.value ? "block" : "none";
}
toggleClear();
villeInput.addEventListener("input", toggleClear);
clearVille.addEventListener("click", function () {
villeInput.value = "";
toggleClear();
villeInput.focus();
});
var btnAnnuler = document.getElementById("btn_annuler");
if (btnAnnuler) {
btnAnnuler.addEventListener("click", function () {
blocAvance.classList.remove("d-flex");
blocAvance.classList.add("d-none");
});
}
if (!hebPoints.length) return;
const map = L.map('map').setView([hebPoints[0].lat, hebPoints[0].lon], 8);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap',
maxZoom: 18,
}).addTo(map);
const bounds = L.latLngBounds();
hebPoints.forEach(p => {
const marker = L.marker([p.lat, p.lon]).addTo(map);
marker.bindPopup(`
<strong>${p.nom}</strong><br>
${p.ville}<br>
${p.tarif}€/nuit<br>
<a href='contacter.php?heb_id=${p.id}' class='btn btn-sm btn-link'>Contacter</a>
`);
// Étend les bounds avec ce point
bounds.extend([p.lat, p.lon]);
});
// Ajuste la carte pour englober tous les points
map.fitBounds(bounds);
});
$(document).ready( function(){
// Initialisation des deux champs
const dateArrivee = flatpickr("#date_arrivee", {
dateFormat: "d-m-Y",
locale: "fr",
onChange: function(selectedDates, dateStr, instance) {
// Met à jour la date min du champ départ
dateDepart.set("minDate", dateStr);
}
});
const dateDepart = flatpickr("#date_depart", {
dateFormat: "d-m-Y",
locale: "fr"
});
const input = document.getElementById("ville_pays");
const clearBtn = document.getElementById("clear_ville");
let lastPrefix = "";
let lastList = [];
let awesomplete = new Awesomplete(input, {
minChars: 3,
maxItems: 20,
autoFirst: true
});
// Si le champ est prérempli (ex : via GET), afficher la croix et précharger les suggestions
const initialVal = input.value.trim();
if (initialVal.length >= 2) {
clearBtn.style.display = "inline";
const prefix = initialVal.substring(0, 2).toLowerCase();
fetch("includes/data/villes_prefix/villes_" + prefix + ".json")
.then(res => res.ok ? res.json() : [])
.then(data => {
lastPrefix = prefix;
lastList = data;
// Prépare les suggestions en filtrant le JSON local
awesomplete.list = filterSuggestions(data, initialVal);
})
.catch(() => {
awesomplete.list = [];
});
}
input.addEventListener("input", function () {
const term = input.value.trim();
clearBtn.style.display = term.length ? "inline" : "none";
if (term.length >= 2) {
const prefix = term.substring(0, 2).toLowerCase();
if (prefix !== lastPrefix) {
// Nouveau préfixe → charger nouveau fichier JSON
fetch("includes/data/villes_prefix/villes_" + prefix + ".json")
.then(res => {
if (!res.ok) throw new Error("Fichier non trouvé");
return res.json();
})
.then(data => {
lastPrefix = prefix;
lastList = data;
awesomplete.list = filterSuggestions(data, term);
})
.catch(() => {
awesomplete.list = [];
});
} else {
// Même préfixe → filtrer localement
awesomplete.list = filterSuggestions(lastList, term);
}
} else {
awesomplete.list = [];
}
});
// Filtrage des suggestions
function filterSuggestions(list, term) {
const lc = term.toLowerCase();
return list.filter(item => item.toLowerCase().includes(lc)).slice(0, 40);
}
// Affiche suggestions précédentes au focus
input.addEventListener("focus", function () {
if (lastList.length && input.value.trim().length >= 2) {
awesomplete.list = filterSuggestions(lastList, input.value.trim());
}
});
// Action lors de la sélection
input.addEventListener("awesomplete-selectcomplete", function () {
console.log("Ville sélectionnée :", input.value);
setTimeout(() => dateArrivee.open(), 100);
});
// Bouton de reset
clearBtn.addEventListener("click", function () {
input.value = "";
input.focus();
clearBtn.style.display = "none";
awesomplete.list = [];
});
<?php if ($miseencache==0): ?>
if (typeof showLoaderInitialisation === 'function') {
//showLoaderInitialisation();
} else {
console.warn('⚠️ showLoaderInitialisation() non défini.');
}
<?php endif; ?>
$("#btn_rechercher").on("click", function() {
showLoader();
});
});
</script>
</body>
</html>