From d2c1ccb8cb9a01df20462e2a5d56d9a171af9eb9 Mon Sep 17 00:00:00 2001 From: Fedaya Date: Sat, 15 Mar 2025 14:01:11 +0100 Subject: [PATCH] Temp, pour changement de branche --- config.inc.php | 8 ++++++++ ingest.php | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 config.inc.php create mode 100644 ingest.php diff --git a/config.inc.php b/config.inc.php new file mode 100644 index 0000000..35c31f4 --- /dev/null +++ b/config.inc.php @@ -0,0 +1,8 @@ + +querySingle("SELECT last FROM last_check"); +if ($last_check ===null || date_add(new DateTime($last_check), DateInterval::createFromDateString('1 hour')) < new DateTime()) { + $json = file_get_contents($json_address); + if ($json !== false) { + $decoded = json_decode($json, true); + foreach($decoded['features'] as $value) { + if(in_array($value['properties']['insee'], $villes_ALM)) { + $ville = $base->querySingle("SELECT * FROM Villes WHERE code_INSEE=".$value['properties']['insee'].";", true); + if ($ville == array()) { + $base->query("INSERT INTO Villes VALUES (".$value['properties']['insee'].", \"".$value['properties']['name']."\");"); + } + $base->query("INSERT INTO chiffres VALUES(\"".$decoded['date']."\", ".$value['properties']['insee'].", ".$value['properties']['contributions'].");"); + } + } + $base->query("DELETE FROM last_check;"); + $base->query("INSERT INTO last_check VALUES ('".$decoded['date']."');"); + $last_check = $decoded['date']; + http_response_code(200); + ?>{ "status": "updated"}{"status": "error in getting geojson file"}{"status": "doesn't need update"}