@ -6,13 +6,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/navigation.php";
global $_PROFILE; global $_USER;
function showPage($item) { ?>
< a href = "/ <? = $item [ "_type" ] ?> / <? = $item [ "_id" ] ?> " class = "list-group-item list-group-item-action" >
< p style = "margin-bottom: 10px;" >< img class = "icon" src = "/icons/ <? = $item [ "_type" ] ?> .svg" style = "margin-right:5px;" >< span style = "vertical-align: middle;" >< b > <? = getNameFromId ( $item [ "_id" ]) ?> </ b > <? = l ( "lang_home_update" ) ?> < b > <? = timeAgo ( $item [ "update" ]) ?> </ b ></ span ></ p > <? = trim ( strip_tags ( $item [ "contents" ])) !== "" ? substr ( trim ( strip_tags ( $item [ "contents" ])), 0 , 150 ) . ( strlen ( trim ( strip_tags ( $item [ "contents" ]))) > 150 ? "…" : "" ) : "-" ?>
< / a >
<?php } ?>
?>
< div class = "container" >
< br > < br >
@ -41,120 +35,53 @@ function showPage($item) { ?>
< b > Vous utilisez une version expérimentale de Delta.< / b > Attendez-vous à rencontrer des bugs et autres problèmes importants. Dans tous les cas, vous pouvez < a href = "/support" > contacter le support technique< / a > pour les signaler.
< / div >
<?php
$birthdays = array_values(array_filter(array_map(function ($i) {
$r = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/$i")), true);
$r["_id"] = substr($i, 0, -5);
return $r;
}, array_values(array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles"), function ($i) { return str_ends_with($i, ".json"); }))), function ($i) {
return hasProfileSetting("birth", true, $i) & & substr($i["birth"], 5) === date('m-d');
}));
?>
<?php if ( count ( $birthdays ) > 0 ) : ?>
< div class = "alert alert-primary" >
< img class = "icon" src = "/icons/age-home.svg" >< span style = "vertical-align: middle; margin-left: 5px;" > <? = str_replace ( "%1" , enumerate ( array_map ( function ( $i ) {
return str_replace("%1", "< a href = '/profile/" . $i["_id"] . "' > " . ($i["nick_name"] ?? $i["first_name"]) . "< / a > ", l("lang_home_name"));
}, $birthdays), l("lang_home_and")), l("lang_home_birthday")) ?>< / span >
< / div >
<?php else : ?>
< div class = "alert alert-secondary" >
< img class = "icon" src = "/icons/events.svg" >< span style = "vertical-align: middle; margin-left: 5px;" > <? = str_replace ( "%1" , formatDate ( time ()), l ( "lang_home_date" )) ?> </ span >
< / div >
<?php endif ; ?>
<?php $results = array_values ( array_filter ( search ( $_PROFILE [ "first_name" ] . " " . $_PROFILE [ "last_name" ], true , true ), function ( $i ) use ( $_PROFILE ) { return str_ends_with ( $i [ "value" ][ "name" ], " " . $_PROFILE [ "last_name" ]); })); if ( count ( $results )) : ?>
< h3 style = "margin-bottom: 15px; margin-top: 30px;" > <? = l ( "lang_home_family" ) ?> </ h3 >
< div class = "list-group" >
<?php $index = 0 ; foreach ( $results as $entry ) : if ( $index <= 4 ) : ?>
< a href = " <? = $entry [ "value" ][ "url" ] ?> " class = "list-group-item-action list-group-item" >
< p style = "margin-bottom:.5rem;" >
< img class = "icon" src = "/icons/ <? = $entry [ "value" ][ "type" ] ?> .svg" style = "margin-right:5px;" >< b style = "vertical-align: middle;" > <? = $entry [ "value" ][ "name" ] ?> </ b >
< / p >
< span > <? = trim ( $entry [ "value" ][ "extract" ]) !== "" ? substr ( trim ( $entry [ "value" ][ "extract" ]), 0 , 150 ) . ( strlen ( trim ( $entry [ "value" ][ "extract" ])) > 150 ? "…" : "" ) : $entry [ "value" ][ "name" ] ?> </ span >
< / a >
<?php $index ++ ; endif ; endforeach ; ?>
< / div >
<?php endif ; ?>
<?php if ( file_exists ( $_SERVER [ 'DOCUMENT_ROOT' ] . "/includes/data/history/" . $_USER . ".json" )) :
$history = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $_USER . ".json")), true);
< div id = "homepage-content" > < / div >
if (count(array_keys($history)) > 0):
uasort($history, function ($a, $b) { return $b - $a; });
$top = array_keys($history)[rand(0, count($history) >= 3 ? 2 : count($history) - 1)];
$topName = getNameFromId($top);
if (count(search($topName, true)) > 0):
?>
< h3 style = "margin-bottom: 15px; margin-top: 30px;" > <? = str_replace ( "%1" , $topName , l ( "lang_home_because" )) ?> </ h3 >
< div class = "list-group" >
<?php $index = 0 ; foreach ( search ( $topName , true ) as $entry ) : if ( $index <= 4 ) : ?>
< a href = " <? = $entry [ "value" ][ "url" ] ?> " class = "list-group-item-action list-group-item" >
< p style = "margin-bottom:.5rem;" >
< img class = "icon" src = "/icons/ <? = $entry [ "value" ][ "type" ] ?> .svg" style = "margin-right:5px;" >< b style = "vertical-align: middle;" > <? = $entry [ "value" ][ "name" ] ?> </ b >
< / p >
< span > <? = trim ( $entry [ "value" ][ "extract" ]) !== "" ? substr ( trim ( $entry [ "value" ][ "extract" ]), 0 , 150 ) . ( strlen ( trim ( $entry [ "value" ][ "extract" ])) > 150 ? "…" : "" ) : $entry [ "value" ][ "name" ] ?> </ span >
< / a >
<?php $index ++ ; endif ; endforeach ; ?>
< div style = "display: flex; align-items: center; justify-content: center; margin-top: 30px;" id = "homepage-loader" >
< svg class = "spinner" width = "32px" height = "32px" viewBox = "0 0 66 66" xmlns = "http://www.w3.org/2000/svg" >
< circle class = "path" fill = "none" stroke-width = "6" stroke-linecap = "round" cx = "33" cy = "33" r = "30" > < / circle >
< / svg >
< / div >
<?php endif ; endif ; endif ; ?>
< h3 style = "margin-bottom: 15px; margin-top: 30px;" > <? = l ( "lang_home_recent" ) ?> </ h3 >
< div class = "list-group" >
<?php
$list = [];
foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles"), function ($i) { return !str_starts_with($i, "."); }) as $id) {
$data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/$id")), true);
$id = substr($id, 0, -5);
$data["_type"] = "articles";
$data["_id"] = $id;
$list[$id] = $data;
}
foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery"), function ($i) { return !str_starts_with($i, "."); }) as $id) {
$data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/$id")), true);
$id = substr($id, 0, -5);
$data["_type"] = "gallery";
$data["_id"] = $id;
$list[$id] = $data;
}
foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people"), function ($i) { return !str_starts_with($i, "."); }) as $id) {
$data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/$id")), true);
$id = substr($id, 0, -5);
$data["_type"] = "people";
$data["_id"] = $id;
< br > < br > < br >
$list[$id] = $data;
< script >
window.list = [
"birthday.php",
"family.php",
"history.php",
"recent.php"
];
function nextItem() {
let item = list[0];
try {
window.fetch("/home/" + item).then((res) => {
res.text().then((data) => {
document.getElementById("homepage-content").innerHTML += data;
list.shift();
if (list.length > 0) {
nextItem();
} else {
document.getElementById("homepage-loader").style.display = "none";
}
});
})
} catch (e) {
list.shift();
if (list.length > 0) {
nextItem();
} else {
document.getElementById("homepage-loader").style.display = "none";
}
}
}
uasort($list, function ($a, $b) {
return strtotime($a["update"]) - strtotime($b["update"]);
window.addEventListener("load", () => {
nextItem( );
});
$list = array_reverse($list);
$index = 0; foreach ($list as $item): if ($index < = 4): ?>
<?php showPage ( $item ); ?>
<?php $index ++ ; endif ; endforeach ; ?>
< / div >
< br > < br > < br >
< / script >
< / div >
<?php require_once $_SERVER [ 'DOCUMENT_ROOT' ] . "/includes/footer.php" ; ?>