| Current Path : /home/h/a/p/happyrenas/myreco.online/includes/ |
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/includes/fonctions_administrateur.php |
<?
/*******************************
* đ SELECTEUR ACTIF/NON ACTIF
******************************/
function genererFichiersAutocompleteVilles($table = 'heb_villes', $colVille = 'city', $colPays = 'country_code', $destination = __DIR__ . "/data/villes_prefix/") {
global $db;
$prefixes = [];
// †Récupération des villes/pays
$resultats = $db->get_results("
SELECT DISTINCT $colVille AS city, $colPays AS country_code
FROM $table
WHERE $colVille IS NOT NULL AND $colPays IS NOT NULL
");
foreach ($resultats as $r) {
$city = trim($r->city);
$cc = strtoupper(trim($r->country_code));
if (!$city || !$cc) continue;
$label = $city . ', ' . $cc;
$prefix = strtolower(substr($city, 0, 2));
if (!preg_match('/^[a-z]{2}$/', $prefix)) continue;
$prefixes[$prefix][] = $label;
}
// †Création du répertoire si besoin
if (!file_exists($destination)) {
mkdir($destination, 0777, true);
}
// †Ăcriture des fichiers JSON par prĂ©fixe
$nbFichiers = 0;
foreach ($prefixes as $prefix => $liste) {
$unique = array_unique($liste);
sort($unique, SORT_STRING | SORT_FLAG_CASE);
$json = json_encode($unique, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
file_put_contents($destination . "villes_{$prefix}.json", $json);
$nbFichiers++;
}
echo "â
Génération terminée : $nbFichiers fichiers créés dans $destination";
}
?>