1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
<?php $_TITLE = "Accueil"; require_once $_SERVER['DOCUMENT_ROOT'] . "/private/header.php"; ?>
<div class="container" style="text-align: center;">
<h1>Familine Généalogie</h1>
<p><i>La généalogie familiale simplifiée et accessible à tous</i></p>
<h2>Pour vous</h2>
<div class="list-group">
<a href="/me" class="list-group-item list-group-item-action">Consulter la généalogie à partir de vous</a>
</div>
<br>
<h2>Statistiques</h2>
<ul class="list-group">
<li class="list-group-item"><?= count($data); ?> personnes</li>
<li class="list-group-item">
<?php
/*
* MIT License
*
* Copyright (c) 2022- Minteck
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
$male = 0;
$female = 0;
foreach ($data as $id => $person) {
if (isset($person["sex"])) {
if ($person["sex"] === "F") {
$female++;
} else {
$male++;
}
}
}
$total = $male + $female;
echo(round(($female/$total) * 100, 2) . "% de femmes pour " . round(($male/$total) * 100, 2) . "% d'hommes");
?>
</li>
<li class="list-group-item"><?php
$uniqueNames = [];
foreach ($data as $person) {
if (!in_array($person["famname"], $uniqueNames)) {
$uniqueNames[] = $person["famname"];
}
}
echo(count($uniqueNames) . " noms de familles uniques")
?></li>
<li class="list-group-item"><?= round(filesize($_SERVER['DOCUMENT_ROOT'] . "/private/data/people.json") / 1024) ?> Ko de données</li>
<li class="list-group-item">
<?php
$numChildren = [];
foreach ($data as $person) {
if (isset($person["family"])) {
$numChildren[] = count($person["family"]["children"]);
}
}
echo(round(array_sum($numChildren)/count($numChildren), 2) . " enfants en moyenne par famille");
echo(" <span class='text-muted'>(statistiques calculées sur " . count($numChildren) . " familles)</span>");
?>
</li>
<li class="list-group-item">
<?php
$deathAge = [];
foreach ($data as $id => $person) {
if (isset($person["death"]["date"]["year"]) && isset($person["birth"]["date"]["year"])) {
$deathAge[$id] = $person["death"]["date"]["year"] - $person["birth"]["date"]["year"];
}
}
echo("Décès en moyenne à " . round(array_sum($deathAge)/count($deathAge), 2) . " ans");
echo(" <span class='text-muted'>(statistiques calculées sur " . count($deathAge) . " personnes)</span>");
?>
</li>
<li class="list-group-item">
<?php
$deathAge = [];
foreach ($data as $id => $person) {
if (isset($person["death"]["date"]["year"]) && isset($person["birth"]["date"]["year"])) {
$deathAge[$id] = $person["death"]["date"]["year"] - $person["birth"]["date"]["year"];
}
}
echo("Personne la plus vieille décédée à " . max($deathAge) . " ans");
echo(" (<a href='/person/?_=" . array_search(max($deathAge), $deathAge) . "'>" . $data[array_search(max($deathAge), $deathAge)]["famname"] . " " . $data[array_search(max($deathAge), $deathAge)]["surname"] . "</a>, †" . $data[array_search(max($deathAge), $deathAge)]["death"]["date"]["year"] . ")");
echo(" <span class='text-muted'>(statistiques calculées sur " . count($deathAge) . " personnes)</span>");
?>
</li>
<li class="list-group-item">
<?php
$deathAge = [];
foreach ($data as $id => $person) {
if (isset($person["death"]["date"]["year"]) && isset($person["birth"]["date"]["year"])) {
$deathAge[$id] = $person["death"]["date"]["year"] - $person["birth"]["date"]["year"];
}
}
echo("Personne la plus jeune décédée à " . min($deathAge) . " ans");
echo(" (<a href='/person/?_=" . array_search(min($deathAge), $deathAge) . "'>" . $data[array_search(min($deathAge), $deathAge)]["famname"] . " " . $data[array_search(min($deathAge), $deathAge)]["surname"] . "</a>, †" . $data[array_search(min($deathAge), $deathAge)]["death"]["date"]["year"] . ")");
echo(" <span class='text-muted'>(statistiques calculées sur " . count($deathAge) . " personnes)</span>");
?>
</li>
<li class="list-group-item">
<?php
$numChildren = [];
foreach ($data as $id => $person) {
if (isset($person["family"])) {
$numChildren[$id] = count($person["family"]["children"]);
}
}
echo("Famille la plus grande avec " . max($numChildren) . " enfants");
echo(" (<a href='/person/?_=" . array_search(max($numChildren), $numChildren) . "'>" . $data[array_search(max($numChildren), $numChildren)]["famname"] . " " . $data[array_search(max($numChildren), $numChildren)]["surname"] . "</a>)");
echo(" <span class='text-muted'>(statistiques calculées sur " . count($numChildren) . " familles)</span>");
?>
</li>
<li class="list-group-item">
<?php
$ageWhenMarried = [];
foreach ($data as $id => $person) {
if (isset($person["family"])) {
if (isset($person["family"]["marriage"]["date"]["year"]) && isset($person["birth"]["date"]["year"])) {
$ageWhenMarried[$id] = $person["family"]["marriage"]["date"]["year"] - $person["birth"]["date"]["year"];
}
}
}
echo("Mariage en moyenne à " . round(array_sum($ageWhenMarried)/count($ageWhenMarried), 2) . " ans");
echo(" <span class='text-muted'>(statistiques calculées sur " . count($ageWhenMarried) . " familles)</span>");
?>
</li>
<li class="list-group-item">
<?php
$ageWhenMarried = [];
foreach ($data as $id => $person) {
if (isset($person["family"])) {
if (isset($person["family"]["marriage"]["date"]["year"]) && isset($person["birth"]["date"]["year"])) {
$ageWhenMarried[$id] = $person["family"]["marriage"]["date"]["year"] - $person["birth"]["date"]["year"];
}
}
}
echo("Mariage le plus tard à " . max($ageWhenMarried) . " ans");
echo(" (<a href='/person/?_=" . array_search(max($ageWhenMarried), $ageWhenMarried) . "'>" . $data[array_search(max($ageWhenMarried), $ageWhenMarried)]["famname"] . " " . $data[array_search(max($ageWhenMarried), $ageWhenMarried)]["surname"] . "</a>)");
echo(" <span class='text-muted'>(statistiques calculées sur " . count($ageWhenMarried) . " familles)</span>");
?>
</li>
<li class="list-group-item">
<?php
$ageWhenMarried = [];
foreach ($data as $id => $person) {
if (isset($person["family"])) {
if (isset($person["family"]["marriage"]["date"]["year"]) && isset($person["birth"]["date"]["year"])) {
$ageWhenMarried[$id] = $person["family"]["marriage"]["date"]["year"] - $person["birth"]["date"]["year"];
}
}
}
echo("Mariage le plus tôt à " . min($ageWhenMarried) . " ans");
echo(" (<a href='/person/?_=" . array_search(min($ageWhenMarried), $ageWhenMarried) . "'>" . $data[array_search(min($ageWhenMarried), $ageWhenMarried)]["famname"] . " " . $data[array_search(min($ageWhenMarried), $ageWhenMarried)]["surname"] . "</a>)");
echo(" <span class='text-muted'>(statistiques calculées sur " . count($ageWhenMarried) . " familles)</span>");
?>
</li>
</ul>
<br>
<h2>Lancer une recherche</h2>
<div class="list-group">
<a href="/search/name" class="list-group-item list-group-item-action">Rechercher par prénom</a>
<a href="/search/lastname" class="list-group-item list-group-item-action">Rechercher par nom</a>
<a href="/search/birth" class="list-group-item list-group-item-action">Rechercher par date de naissance</a>
<a href="/search/death" class="list-group-item list-group-item-action">Rechercher par date de décès</a>
<a href="/search/marriage" class="list-group-item list-group-item-action">Rechercher par date de mariage</a>
<a href="/search/city" class="list-group-item list-group-item-action">Rechercher par ville</a>
<a href="/search/dept" class="list-group-item list-group-item-action">Rechercher par département</a>
<a href="/search/state" class="list-group-item list-group-item-action">Rechercher par région</a>
</div>
</div>
<br>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/private/footer.php"; ?>
|