aboutsummaryrefslogtreecommitdiff
path: root/search/state/data.json
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-04-12 11:47:01 +0200
committerMinteck <contact@minteck.org>2022-04-12 11:47:01 +0200
commit41556be35cba41643d18f27c4c9ba264dde6a186 (patch)
tree57db148e2e83408e6bc105015f000240e1e4638f /search/state/data.json
parent696f2b8888aaa2a1c0f8edba13dcf2238d7c83f4 (diff)
downloadgenealogy-trunk.tar.gz
genealogy-trunk.tar.bz2
genealogy-trunk.zip
CommitHEADtrunk
Diffstat (limited to 'search/state/data.json')
-rw-r--r--search/state/data.json/index.php76
1 files changed, 38 insertions, 38 deletions
diff --git a/search/state/data.json/index.php b/search/state/data.json/index.php
index 6445118..e0bad67 100644
--- a/search/state/data.json/index.php
+++ b/search/state/data.json/index.php
@@ -1,39 +1,39 @@
-<?php
-
-require_once $_SERVER['DOCUMENT_ROOT'] . "/../session.php";
-
-/** @var string $_FULLNAME
- * @var string $_USER
- * @var array $_PROFILE
- * @var array $_CONFIG
- */
-
-$data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/private/data/people.json"), true);
-
-header("Content-Type: application/json");
-
-$arr = [];
-$names = [];
-$counts = [];
-
-foreach ($data as $id => $person) {
- if (isset($person["birth"]["place"]) && isset($person["birth"]["place"]["state"])) {
- if (isset($counts[$person["birth"]["place"]["state"]])) {
- $counts[$person["birth"]["place"]["state"]]++;
- } else {
- $counts[$person["birth"]["place"]["state"]] = 1;
- }
- if (!in_array($person["birth"]["place"]["state"], $names)) {
- $names[] = $person["birth"]["place"]["state"];
- }
- }
-}
-
-foreach ($names as $name) {
- $arr[] = [
- 'name' => $name,
- 'occurrences' => $counts[$name] . " personne" . ($counts[$name] > 1 ? "s" : "")
- ];
-}
-
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/../session.php";
+
+/** @var string $_FULLNAME
+ * @var string $_USER
+ * @var array $_PROFILE
+ * @var array $_CONFIG
+ */
+
+$data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/private/data/people.json"), true);
+
+header("Content-Type: application/json");
+
+$arr = [];
+$names = [];
+$counts = [];
+
+foreach ($data as $id => $person) {
+ if (isset($person["birth"]["place"]) && isset($person["birth"]["place"]["state"])) {
+ if (isset($counts[$person["birth"]["place"]["state"]])) {
+ $counts[$person["birth"]["place"]["state"]]++;
+ } else {
+ $counts[$person["birth"]["place"]["state"]] = 1;
+ }
+ if (!in_array($person["birth"]["place"]["state"], $names)) {
+ $names[] = $person["birth"]["place"]["state"];
+ }
+ }
+}
+
+foreach ($names as $name) {
+ $arr[] = [
+ 'name' => $name,
+ 'occurrences' => $counts[$name] . " personne" . ($counts[$name] > 1 ? "s" : "")
+ ];
+}
+
echo(json_encode($arr)); \ No newline at end of file