Initial commit

mane
Mia Raindrops 3 months ago
commit e9002254c5
Signed by: Mia Raindrops
GPG Key ID: EFBDC68435A574B7

3
.gitignore vendored

@ -0,0 +1,3 @@
includes/data
includes/tokens
includes/email.json

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" autoUpload="Always" serverName="Minteck.org" remoteFilesAllowedToDisappearOnAutoupload="false">
<serverData>
<paths name="Minteck.org">
<serverdata>
<mappings>
<mapping deploy="/mnt/delta" local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
</serverData>
<option name="myAutoUpload" value="ALWAYS" />
</component>
</project>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="PROJECT_FILES" />
<option name="description" value="" />
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/delta.iml" filepath="$PROJECT_DIR$/.idea/delta.iml" />
</modules>
</component>
</project>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MessDetectorOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCSFixerOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCodeSnifferOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.1" />
<component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PsalmOptionsConfiguration">
<option name="transferred" value="true" />
</component>
</project>

@ -0,0 +1,85 @@
<?php
$id = array_values(array_filter(array_keys($_GET), function ($i) {
return str_starts_with($i, "/") && strlen($i) > 1;
}))[0] ?? null;
if (isset($id)) {
$id = substr($id, 1);
if (!preg_match("/[a-zA-Z0-6]/m", $id)) {
header("Location: /articles");
die();
}
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $id . ".json")) {
header("Location: /articles");
die();
}
$data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $id . ".json")), true);
$title_pre = $data["title"];
$title = "lang_articles_title";
} else {
$title = "lang_articles_title";
}
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/navigation.php";
if (!isset($id)):
?>
<div class="container">
<br><br>
<h1><?= l("lang_articles_title") ?></h1>
<?php
$articles = array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles"), function ($i) { return !str_starts_with($i, "."); });
usort($articles, function ($a, $b) {
return strcmp($a, $b);
});
?>
<div class="list-group">
<?php foreach ($articles as $person): $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $person)), true); ?>
<a href="/articles/<?= explode(".", $person)[0] ?>" class="list-group-item list-group-item-action"><?= $data["title"] ?></a>
<?php endforeach; ?>
</div>
<div style="margin-top:20px;"><a href="/request/?type=add"><?= l("lang_articles_create") ?></a></div>
<br><br>
</div>
<?php else: ?>
<div class="container">
<br><br>
<h1>
<span><?= $data["title"] ?></span>
<span style="float: right;"><a href="/request/?type=rename&id=<?= $id ?>" class="btn btn-outline-dark"><?= l("lang_articles_rename") ?></a> <a href="/edit/<?= $id ?>" class="btn btn-outline-dark"><?= l("lang_people_edit") ?></a></span>
</h1>
<div>
<div>
<?php if (isset($data["contents"]) && trim($data["contents"] !== "")): ?>
<div>
<?= $data["contents"] ?>
</div>
<?php else: ?>
<p class="text-muted"><?= l("lang_articles_empty") ?></p>
<?php endif; ?>
</div>
</div>
<br><br>
</div>
<?php endif; ?>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/footer.php"; ?>

@ -0,0 +1,150 @@
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $_USER; global $_PROFILE;
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php";
$self = false;
$id = array_values(array_filter(array_keys($_GET), function ($i) {
return str_starts_with($i, "/") && strlen($i) > 1;
}))[0] ?? null;
if (isset($id)) {
$id = substr($id, 1);
if (!preg_match("/[a-zA-Z0-6]/m", $id)) {
header("Location: /");
die();
}
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json") && !file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $id . ".json") && !file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json") && $id !== $_USER) {
header("Location: /");
die();
}
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json")) {
$data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json")), true);
$title_pre = $data["first_name"] . " " . $data["last_name"];
} else if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $id . ".json")) {
$data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $id . ".json")), true);
$title_pre = $data["title"];
} else if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")) {
$data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")), true);
$title_pre = $data["title"];
} else {
$self = true;
$data = $_PROFILE;
$title_pre = l("lang_profile_editor");
}
$title = "lang_edit_title";
} else {
header("Location: /");
die();
}
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/navigation.php";
if (!isset($_PROFILE["requests"][$id])):
?>
<form method="post" action="/_edit/save/?id=<?= $id ?>" id="main-form">
<div class="container">
<br><br>
<h1>
<?php if ($id !== $_USER): ?>
<span><?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json") ? $data["first_name"] . " " . $data["last_name"] : $data["title"] ?></span>
<span style="float: right;"><input id="form-btn" type="button" value="<?= l("lang_edit_save") ?>" class="btn btn-outline-primary" <?= $_PROFILE["blocked"] >= 2 ? "disabled" : "" ?>> <a href="/<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json") ? "people" : "articles" ?>/<?= $id ?>" class="btn btn-outline-dark"><?= l("lang_edit_cancel") ?></a></span>
<?php else: ?>
<span><?= $data["nick_name"] ?? $data["first_name"] . " " . $data["last_name"] ?><?php if (isset($data["nick_name"]) && trim($data["nick_name"]) !== ""): ?> <small><small><small>(<?= $data["first_name"] . " " . $data["last_name"] ?>)</small></small></small><?php endif; ?><?php if ($data["plus"]): ?> <small><small><small><small><small><small><span class="badge badge-plus rounded-pill" style="vertical-align: middle; margin-top: -5px;">PLUS</span></small></small></small></small></small></small><?php endif; ?></span>
<span style="float: right;"><input id="form-btn" type="button" value="<?= l($id === $_USER ? "lang_profile_save" : "lang_edit_save") ?>" class="btn btn-outline-primary" <?= $_PROFILE["blocked"] >= 1 ? "disabled" : "" ?>> <a href="/<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json") ? "people" : (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $id . ".json") ? "articles" : (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json") ? "gallery" : "profile")) ?>/<?= $id ?>" class="btn btn-outline-dark"><?= l("lang_edit_cancel") ?></a></span>
<?php endif; ?>
</span>
</h1>
<?php if ($self && $_PROFILE["blocked"] === 1): ?>
<div class="alert alert-danger"><p><?= l("lang_blocked_own") ?></p><?= l("lang_blocked_error") ?></div>
<?php elseif ($_PROFILE["blocked"] >= 2): ?>
<div class="alert alert-danger"><p><?= l("lang_blocked_edit") ?></p><?= l("lang_blocked_error") ?></div>
<?php else: ?>
<div>
<!--suppress HtmlFormInputWithoutLabel -->
<textarea name="contents" id="editor-box"><?php if (isset($data["contents"]) && trim($data["contents"] !== "")): ?><?= $data["contents"] ?><?php endif; ?></textarea>
</div>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/editor.php"; ?>
<script>
document.getElementById("form-btn").onclick = (event) => {
new bootstrap.Modal(document.getElementById("<?= $id !== $_USER ? "confirm" : "confirm2" ?>")).show()
}
</script>
<?php endif; ?>
<br><br>
</div>
<div class="modal fade" id="confirm">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><?= l("lang_edit_confirm_title") ?></h4>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<p><?= l("lang_edit_confirm_description") ?></p>
<p>
<?= l("lang_edit_confirm_summary") ?><br>
<!--suppress HtmlFormInputWithoutLabel -->
<textarea class="form-control" name="summary"></textarea>
</p>
<p><?= l("lang_edit_confirm_followup") ?></p>
<button class="btn btn-primary"><?= l("lang_edit_confirm_button") ?></button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="confirm2">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><?= l("lang_profile_confirm_title") ?></h4>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<p><?= l("lang_profile_confirm_description") ?></p>
<p><?= l("lang_profile_confirm_followup") ?></p>
<button class="btn btn-primary"><?= l("lang_edit_confirm_button") ?></button>
</div>
</div>
</div>
</div>
</form>
<?php else: ?>
<div class="container">
<br><br>
<h1>
<span><?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json") ? $data["first_name"] . " " . $data["last_name"] : $data["title"] ?></span>
<span style="float: right;"><input disabled id="form-btn" type="button" value="<?= l("lang_edit_save") ?>" class="btn btn-outline-primary"> <a href="/<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json") ? "people" : (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json") ? "gallery" : "articles") ?>/<?= $id ?>" class="btn btn-outline-dark"><?= l("lang_edit_cancel") ?></a></span>
</h1>
<div class="alert alert-warning">
<p><b><?= l("lang_edit_alert_title") ?></b></p>
<?php
$request = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $_PROFILE["requests"][$id] . ".json")), true);
?>
<p><?= str_replace("%1", timeAgo($request["date"]), l("lang_edit_alert_message")) ?></p>
<?= l("lang_edit_alert_contents") ?>
</div>
<?= $request["contents"] ?>
<br><br>
</div>
<?php endif; ?>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/footer.php"; ?>

@ -0,0 +1,79 @@
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php";
global $_PROFILE; global $_USER;
$id = $_GET['id'] ?? null;
$blockLevel = 2;
if (isset($id)) {
if (!preg_match("/[a-zA-Z0-6]/m", $id)) {
die();
}
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json") && !file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $id . ".json") && !file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json") && $id !== $_USER) {
die();
}
} else {
die();
}
if (isset($_PROFILE["requests"][$id])) {
header("Location: /edit/" . $id);
die();
}
$rid = uuid();
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json")) {
if ($_PROFILE["blocked"] >= $blockLevel) die();
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $rid . ".json", utf8_encode(json_encode([
"type" => "userpage",
"author" => $_USER,
"id" => $id,
"contents" => $_POST["contents"],
"summary" => $_POST["summary"],
"date" => date('c')
])));
} elseif (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $id . ".json")) {
if ($_PROFILE["blocked"] >= $blockLevel) die();
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $rid . ".json", utf8_encode(json_encode([
"type" => "article",
"author" => $_USER,
"id" => $id,
"contents" => $_POST["contents"],
"summary" => $_POST["summary"],
"date" => date('c')
])));
} elseif (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")) {
if ($_PROFILE["blocked"] >= $blockLevel) die();
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $rid . ".json", utf8_encode(json_encode([
"type" => "gallerymeta",
"author" => $_USER,
"id" => $id,
"contents" => $_POST["contents"],
"summary" => $_POST["summary"],
"date" => date('c')
])));
} else {
$blockLevel = 1;
if ($_PROFILE["blocked"] >= $blockLevel) die();
$_PROFILE["contents"] = $_POST["contents"];
}
if ($id === $_USER) {
saveProfile();
header("Location: /profile/" . $id);
} else {
$_PROFILE["requests"][$id] = $rid;
saveProfile();
header("Location: /edit/" . $id);
}

@ -0,0 +1,105 @@
<?php
$id = array_values(array_filter(array_keys($_GET), function ($i) {
return str_starts_with($i, "/") && strlen($i) > 1;
}))[0] ?? null;
if (isset($id)) {
$id = substr($id, 1);
if (!preg_match("/[a-zA-Z0-6]/m", $id)) {
header("Location: /gallery");
die();
}
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")) {
header("Location: /gallery");
die();
}
$data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")), true);
$title_pre = $data["title"];
$title = "lang_gallery_title";
} else {
$title = "lang_gallery_title";
}
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/navigation.php";
if (!isset($id)):
?>
<div class="container">
<br><br>
<h1><?= l("lang_gallery_title") ?></h1>
<?php
$articles = array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery"), function ($i) { return !str_starts_with($i, "."); });
usort($articles, function ($a, $b) {
return strcmp($a, $b);
});
?>
<div class="list-group">
<?php foreach ($articles as $person): $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $person)), true); ?>
<a href="/gallery/<?= explode(".", $person)[0] ?>" class="list-group-item list-group-item-action"><?= $data["title"] ?></a>
<?php endforeach; ?>
</div>
<div style="margin-top:20px;"><a href="/request/?type=addalbum"><?= l("lang_gallery_create") ?></a></div>
<br><br>
</div>
<?php else: ?>
<div class="container">
<br><br>
<h1>
<span><?= $data["title"] ?></span>
<span style="float: right;"><a href="/upload/<?= $id ?>" class="btn btn-outline-primary"><?= l("lang_gallery_upload") ?></a> <a href="/request/?type=rename&id=<?= $id ?>" class="btn btn-outline-dark"><?= l("lang_articles_rename") ?></a> <a href="/edit/<?= $id ?>" class="btn btn-outline-dark"><?= l("lang_people_edit") ?></a></span>
</h1>
<div>
<div>
<?php if (isset($data["images"]) && count($data["images"]) > 0): ?>
<?php if (isset($data["contents"]) && trim($data["contents"] !== "")): ?>
<p>
<?= $data["contents"] ?>
</p>
<?php endif; ?>
<div style="display: grid; grid-template-columns: repeat(3, 1fr); grid-gap: 20px;">
<div>
<?php $index = 1; foreach ($data["images"] as $image): if ($index % 3 === 1): ?>
<img title="<?= l("lang_gallery_uploader") . " " . resolveUser($image["author"]) . " " . timeAgo($image["date"]) ?>" src="/uploads/<?= $image["id"] ?>.jpg" style="width: 100%; margin-top: 20px; border-radius: 10px;" data-bs-toggle="tooltip">
<?php endif; $index++; endforeach; ?>
</div>
<div>
<?php $index = 1; foreach ($data["images"] as $image): if ($index % 3 === 2): ?>
<img title="<?= l("lang_gallery_uploader") . " " . resolveUser($image["author"]) . " " . timeAgo($image["date"]) ?>" src="/uploads/<?= $image["id"] ?>.jpg" style="width: 100%; margin-top: 20px; border-radius: 10px;" data-bs-toggle="tooltip">
<?php endif; $index++; endforeach; ?>
</div>
<div>
<?php $index = 1; foreach ($data["images"] as $image): if ($index % 3 === 0): ?>
<img title="<?= l("lang_gallery_uploader") . " " . resolveUser($image["author"]) . " " . timeAgo($image["date"]) ?>" src="/uploads/<?= $image["id"] ?>.jpg" style="width: 100%; margin-top: 20px; border-radius: 10px;" data-bs-toggle="tooltip">
<?php endif; $index++; endforeach; ?>
</div>
</div>
<?php else: ?>
<p class="text-muted"><?= l("lang_gallery_empty") ?></p>
<?php endif; ?>
</div>
</div>
<br><br>
</div>
<?php endif; ?>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/footer.php"; ?>

@ -0,0 +1,445 @@
<?php
$id = array_values(array_filter(array_keys($_GET), function ($i) {
return str_starts_with($i, "/") && strlen($i) > 1;
}))[0] ?? null;
if (isset($id)) {
$id = substr($id, 1);
if (!preg_match("/[a-zA-Z0-6]/m", $id)) {
header("Location: /people");
die();
}
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json")) {
header("Location: /people");
die();
}
$data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json")), true);
$title_pre = $data["first_name"] . " " . $data["last_name"];
$title = "lang_people_title";
} else {
$title = "lang_people_title";
}
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/navigation.php";
if (!isset($id)):
?>
<div class="container">
<br><br>
<h1><?= l("lang_people_title") ?></h1>
<?php
$people = array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people"), function ($i) { return !str_starts_with($i, "."); });
usort($people, function ($a, $b) {
return strcmp($a, $b);
});
?>
<div class="list-group">
<?php foreach ($people as $person): $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $person)), true); ?>
<a href="/people/<?= explode(".", $person)[0] ?>" class="list-group-item list-group-item-action"><?= $data["first_name"] . " " . $data["last_name"] ?></a>
<?php endforeach; ?>
</div>
<div style="margin-top:20px;"><a href="/request/?type=add"><?= l("lang_people_create") ?></a></div>
<br><br>
</div>
<?php else: ?>
<div class="container">
<br><br>
<h1>
<span><?= $data["first_name"] . " " . $data["last_name"] ?><?php if (isset($data["born"]) && trim($data["born"]) !== ""): ?> <small><small><small>(<?= $data["first_name"] . " " . $data["born"] ?>)</small></small></small><?php endif; ?></span>
<span style="float: right;"><a href="/edit/<?= $id ?>" class="btn btn-outline-dark"><?= l("lang_people_edit") ?></a></span>
</h1>
<div style="display: grid; grid-template-columns: 1fr 400px; grid-gap: 20px;">
<div>
<?php if (isset($data["contents"]) && trim($data["contents"] !== "")): ?>
<div>
<?= $data["contents"] ?>
</div>
<?php else: ?>
<p class="text-muted"><?= l("lang_people_empty") ?></p>
<?php endif; ?>
</div>
<div>
<div class="card">
<div class="card-body">
<h5 style="text-align: center;"><?= $data["first_name"] . " " . $data["last_name"] ?></h5>
<img src="<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/uploads/" . $id . ".jpg") ? "/uploads/" . $id . ".jpg" : "/icons/defaultpage.svg" ?>" style="width: 100%;">
<hr>
<div style="display: grid; grid-template-columns: 50% 50%; grid-column-gap: 10px; grid-row-gap: 5px;">
<?php if (isset($data["state"])): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_state") ?></b>
</div>
<div>
<?php if (isset($data["state"])) {
switch ($data["state"]) {
case 0:
echo("<span style='vertical-align: middle;' class='badge rounded-pill bg-black text-white'>" . l("lang_people_dead") . "</span>");
break;
case 1:
echo("<span style='vertical-align: middle;' class='badge rounded-pill bg-warning text-white'>" . l("lang_people_notborn") . "</span>");
break;
case 2:
echo("<span style='vertical-align: middle;' class='badge rounded-pill bg-success text-white'>" . l("lang_people_alive") . "</span>");
break;
}
} else {
echo("-");
} ?>
</div>
<?php endif; ?>
<?php if (isset($data["gender"])): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_gender") ?></b>
</div>
<div>
<?php if (isset($data["gender"])) {
switch ($data["gender"]) {
case "fem":
echo(l("lang_people_female"));
break;
case "male":
echo(l("lang_people_male"));
break;
case "other":
echo(l("lang_people_emby"));
break;
case "trans_fem":
echo(l("lang_people_transfemale"));
break;
case "trans_male":
echo(l("lang_people_transmale"));
break;
default:
echo("<span class='text-danger'>" . l("lang_people_invalid") . "</span>");
break;
}
} else {
echo("-");
} ?>
</div>
<?php endif; ?>
<?php if (isset($data["home"])): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_home") ?></b>
</div>
<div>
<?php if (isset($data["home"])): ?>
<?= implode("<br>", array_map(function ($i) { return trim($i); }, explode(",", $data["home"]))) ?>
<?php else: ?>-<?php endif; ?>
</div>
<?php endif; ?>
</div>
<hr>
<h6 style="text-align: center;"><?= l("lang_people_relations") ?></h6>
<?php if (isset($data["relations"]) && count($data["relations"]) > 0): ?>
<div>
<?php if (isset($data["relations"])): ?>
<div class="list-group">
<?php foreach ($data["relations"] as $relation): ?>
<a class="list-group-item list-group-item-action" href="/people/<?= $relation["id"] ?>">
<?php
$nid = $relation["id"];
$text = "<code class='text-danger'>" . $nid . "</code>";
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $nid . ".json")) {
$d = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $nid . ".json")), true);
$text = $d["first_name"] . " " . $d["last_name"];
}
echo($text);
?> (<?php
switch ($relation["type"]) {
case "parent":
echo(l("lang_people_parent"));
break;
case "grandparent":
echo(l("lang_people_greatparent"));
break;
case "child":
echo(l("lang_people_child"));
break;
case "bride":
echo(l("lang_people_partner"));
break;
case "sibling":
echo(l("lang_people_sibling"));
break;
default:
echo('<span class="text-danger">' . l("lang_people_invalid") . '</span>');
}
?>)
</a>
<?php endforeach; ?>
</div>
<?php else: ?>-<?php endif; ?>
</div>
<?php endif; ?>
<hr>
<h6 style="text-align: center;"><?= l("lang_people_civil") ?></h6>
<div style="display: grid; grid-template-columns: 50% 50%; grid-column-gap: 10px; grid-row-gap: 5px;">
<?php if (isset($data['birth']["date"])): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_birth") ?></b>
</div>
<div>
<?php if (isset($data["birth"]["date"])): ?>
<?php if (strtotime($data['birth']["date"]) !== false): ?>
<?= formatDate($data["birth"]["date"]) ?>
<?php else: ?><span class="text-danger"><?= l("lang_people_invalid") ?></span><?php endif; ?>
<?php else: ?>-<?php endif; ?><br>
<?php if (isset($data["birth"]["place"])): ?>
<?= $data["birth"]["place"] ?>
<?php else: ?>-<?php endif; ?>
</div>
<?php endif; ?>
<?php if (isset($data["death"]["date"])): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_death") ?></b>
</div>
<div>
<?php if (isset($data["death"]["date"])): ?>
<?php if (strtotime($data['death']["date"]) !== false): ?>
<?= formatDate($data["death"]["date"]) ?>
<?php else: ?><span class="text-danger"><?= l("lang_people_invalid") ?></span><?php endif; ?>
<?php else: ?>-<?php endif; ?><br>
<?php if (isset($data["death"]["place"])): ?>
<?= $data["death"]["place"] ?>
<?php else: ?>-<?php endif; ?>
</div>
<?php endif; ?>
<?php if (isset($data["marriage"]["date"])): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_marriage") ?></b>
</div>
<div>
<?php if (isset($data["marriage"]["date"])): ?>
<?php if (strtotime($data['marriage']["date"]) !== false): ?>
<?= formatDate($data["marriage"]["date"]) ?>
<?php else: ?><span class="text-danger"><?= l("lang_people_invalid") ?></span><?php endif; ?>
<?php else: ?>-<?php endif; ?><br>
<?php if (isset($data["marriage"]["place"])): ?>
<?= $data["marriage"]["place"] ?>
<?php else: ?>-<?php endif; ?>
</div>
<?php endif; ?>
</div>
<hr>
<h6 style="text-align: center;"><?= l("lang_people_studies") ?></h6>
<div style="display: grid; grid-template-columns: 50% 50%; grid-column-gap: 10px; grid-row-gap: 5px;">
<?php if (isset($data["schools"]) && count($data["schools"]) > 0): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_schools") ?></b>
</div>
<div>
<?php $index = 0; if (isset($data["schools"])): ?>
<?php foreach ($data["schools"] as $school): ?>
<?php foreach (explode(",", $school) as $part): ?>
<?= $part ?><br>
<?php endforeach; ?>
<?php if ($index < count($data["schools"]) - 1): ?><hr style="margin: 0.3rem 0;"><?php endif; ?>
<?php $index++; endforeach; ?>
<?php else: ?>-<?php endif; ?>
</div>
<?php endif; ?>
<?php if (isset($data["diplomas"]) && count($data["diplomas"]) > 0): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_diplomas") ?></b>
</div>
<div>
<?php if (isset($data["diplomas"])): ?>
<?= implode("<br>", $data["diplomas"]) ?>
<?php else: ?>-<?php endif; ?>
</div>
<?php endif; ?>
<?php if (isset($data["education"])): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_level") ?></b>
</div>
<div>
<?php if (isset($data["education"])): ?>
<?php
switch ($data["education"]) {
case "lhs":
echo(l("lang_people_lhs"));
break;
case "uhs":
echo(l("lang_people_uhs"));
break;
case "ps":
echo(l("lang_people_ps"));
break;
case "uni":
echo(l("lang_people_uni"));
break;
case "free":
echo(l("lang_people_freestudy"));
break;
default:
echo('<span class="text-danger">' . l("lang_people_invalid") . '</span>');
break;
}
?>
<?php else: ?>-<?php endif; ?>
</div>
<?php endif; ?>
</div>
<hr>
<h6 style="text-align: center;"><?= l("lang_people_jobs") ?></h6>
<div style="display: grid; grid-template-columns: 50% 50%; grid-column-gap: 10px; grid-row-gap: 5px;">
<?php if (isset($data["jobs"]["past"]) && count($data["jobs"]["past"]) > 0): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_previousjobs") ?></b>
</div>
<div>
<?php if (isset($data["jobs"]["past"])): ?>
<?= implode("<br>", $data["jobs"]["past"]) ?>
<?php else: ?>-<?php endif; ?>
</div>
<?php endif; ?>
<?php if (isset($data["jobs"]["current"])): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_currentjob") ?></b>
</div>
<div>
<?php if (isset($data["jobs"]["current"])): ?>
<?= $data["jobs"]["current"] ?>
<?php else: ?>-<?php endif; ?>
</div>
<?php endif; ?>
<?php if (isset($data["jobs"]["positions"])): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_position") ?></b>
</div>
<div>
<?php if (isset($data["jobs"]["position"])): ?>
<?= $data["jobs"]["position"] ?>
<?php else: ?>-<?php endif; ?>
</div>
<?php endif; ?>
<?php if (isset($data["jobs"]["place"])): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_workplace") ?></b>
</div>
<div>
<?php if (isset($data["jobs"]["place"])): ?>
<?= implode("<br>", array_map(function ($i) { return trim($i); }, explode(",", $data["jobs"]["place"]))) ?>
<?php else: ?>-<?php endif; ?>
</div>
<?php endif; ?>
<?php if (isset($data["jobs"]["next"])): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_nextjob") ?></b>
</div>
<div>
<?php if (isset($data["jobs"]["next"])): ?>
<?= $data["jobs"]["next"] ?>
<?php else: ?>-<?php endif; ?>
</div>
<?php endif; ?>
</div>
<hr>
<h6 style="text-align: center;"><?= l("lang_people_culture") ?></h6>
<div style="display: grid; grid-template-columns: 50% 50%; grid-column-gap: 10px; grid-row-gap: 5px;">
<?php if (isset($data["religion"])): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_religion") ?></b>
</div>
<div>
<?php if (isset($data["religion"])): ?>
<?= $data["religion"] ?>
<?php else: ?>-<?php endif; ?>
</div>
<?php endif; ?>
<?php if (isset($data["languages"]) && count($data["languages"]) > 0): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_languages") ?></b>
</div>
<div>
<?php if (isset($data["languages"])): ?>
<?= implode("<br>", array_map(function ($i) { return locale_get_display_language($i, l("lang__name")); }, $data["languages"])) ?>
<?php else: ?>-<?php endif; ?>
</div>
<?php endif; ?>
<?php if (isset($data["permits"]) && count($data["permits"]) > 0): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_permits") ?></b>
</div>
<div>
<?php if (isset($data["permits"])): ?>
<?= implode("<br>", $data["permits"]) ?>
<?php else: ?>-<?php endif; ?>
</div>
<?php endif; ?>
<?php if (isset($data["countries"]) && count($data["countries"]) > 0): ?>
<div style="text-align: right;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;vertical-align:middle;">
<b><?= l("lang_people_countries") ?></b>
</div>
<div>
<?php if (isset($data["countries"])): ?>
<?= implode("<br>", array_map(function ($i) { return locale_get_display_region("-" . strtoupper($i), l("lang__name")); }, $data["countries"])) ?>
<?php else: ?>-<?php endif; ?>
</div>
<?php endif; ?>
</div>
<hr>
<div style="text-align: center;">
<a href="<?php if (isset($data["delta"])) echo("/profile/" . $data["delta"]) ?>" class="btn btn-primary <?php if (!isset($data["delta"])) echo("disabled") ?>"><?= l("lang_people_delta") ?></a>
<a href="/request/?type=metaupdate&id=<?= $id ?>" class="btn btn-outline-secondary"><?= l("lang_people_update") ?></a>
</div>
</div>
</div>
</div>
</div>
<br><br>
</div>
<?php endif; ?>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/footer.php"; ?>

@ -0,0 +1,129 @@
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $_USER;
$id = array_values(array_filter(array_keys($_GET), function ($i) {
return str_starts_with($i, "/") && strlen($i) > 1;
}))[0] ?? null;
if (isset($id)) {
$id = substr($id, 1);
if (!preg_match("/[a-zA-Z0-6]/m", $id)) {
header("Location: /profile/$_USER");
die();
}
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $id . ".json")) {
header("Location: /profile/$_USER");
die();
}
$data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $id . ".json")), true);
$title_pre = $data["nick_name"] ?? $data["first_name"] . " " . $data["last_name"];
$title = "lang_profile_title";
} else {
header("Location: /profile/$_USER");
die();
}
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/navigation.php";
?>
<div class="container">
<br><br>
<h1>
<span><?= $data["nick_name"] ?? $data["first_name"] . " " . $data["last_name"] ?><?php if (isset($data["nick_name"]) && trim($data["nick_name"]) !== ""): ?> <small><small><small>(<?= $data["first_name"] . " " . $data["last_name"] ?>)</small></small></small><?php endif; ?><?php if ($data["plus"]): ?> <small><small><small><small><small><small><span class="badge badge-plus rounded-pill" style="vertical-align: middle; margin-top: -5px;">PLUS</span></small></small></small></small></small></small><?php endif; ?></span>
<span style="float: right;"><?php if ($id === $_USER): ?><a href="/edit/<?= $id ?>" class="btn btn-outline-dark"><?= l("lang_people_edit") ?></a><?php endif; ?>
<div class="dropdown" style="display: inline-block;">
<button type="button" class="btn btn-outline-dark dropdown-toggle" data-bs-toggle="dropdown"><?= l("lang_profile_options") ?></button>
<ul class="dropdown-menu">
<li><a class="dropdown-item <?= $id === $_USER ? "disabled" : "" ?>" href="/request/?type=userreport&id=<?= $id ?>">
<img src="/icons/report.svg" style="vertical-align: middle; width: 24px;<?= $id === $_USER ? "opacity:.5;" : "" ?>">
<span style="vertical-align: middle;"><?= l("lang_profile_report") ?></span>
</a></li>
<li><a class="dropdown-item" href="/request/?type=<?= $id === $_USER ? "profile" : "profileother" ?>&id=<?= $id ?>">
<img src="/icons/edit.svg" style="vertical-align: middle; width: 24px;">
<span style="vertical-align: middle;"><?= l("lang_profile_request") ?></span>
</a></li>
<li><a class="dropdown-item disabled" href="#">
<img src="/icons/gift.svg" style="vertical-align: middle; width: 24px;opacity: .5;">
<span style="vertical-align: middle;"><?= l("lang_profile_gift") ?></span>
</a></li>
</ul>
</div>
</span>
</h1>
<div style="margin-top: 20px; display: grid; grid-template-columns: repeat(2, 1fr); grid-column-gap: 20px;">
<div class="card">
<div class="card-body">
<table>
<tr>
<td><img alt="" src="/icons/time.svg" style="vertical-align: middle; width: 29px; padding-right: 5px;"></td>
<td><?= l("lang_profile_since") ?> <?= timeAgo($data["date"], false) ?></td>
</tr>
<tr>
<td><img alt="" src="/icons/clock.svg" style="vertical-align: middle; width: 29px; padding-right: 5px;"></td>
<td><?php if (isset($data["last_seen"])): ?><?= l("lang_profile_last") ?> <?= timeAgo($data["last_seen"], true, false, true) ?><?php else: ?><?= l("lang_profile_never") ?><?php endif; ?></td>
</tr>
<tr>
<td><img alt="" src="/icons/pending.svg" style="vertical-align: middle; width: 29px; padding-right: 5px;"></td>
<td><?= count($data["requests"]) === 0 ? l("lang_profile_pending3") : count($data["requests"]) ?> <?= l(count($data["requests"]) > 1 || count($data["requests"]) === 0 ? "lang_profile_pending2" : "lang_profile_pending1") ?></td>
</tr>
</table>
</div>
</div>
<div class="card">
<div class="card-body">
<div style="display: grid; grid-template-columns: 64px max-content; grid-gap: 10px;">
<div style="display: flex; align-items: center;">
<img src="<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/uploads/" . $id . ".jpg") ? "/uploads/" . $id . ".jpg" : "/icons/defaultuser.svg" ?>" style="width: 64px; height: 64px; border-radius: 100%;">
</div>
<table>
<tr>
<td><img alt="" src="/icons/age.svg" style="vertical-align: middle; width: 29px; padding-right: 5px;"></td>
<td><?php
if (isset($data["birth"])):
$bdate = strtotime($data["birth"]);
echo(timeAgo($bdate, false, true) . " " . l("lang_profile_old"));
?> (<?= l("lang_profile_birth") ?> <?= formatDate($data["birth"], false) ?>)<?php else: ?>-<?php endif; ?></td>
</tr>
<tr>
<?php
$email = $data["email"];
?>
<td><img alt="" src="/icons/email.svg" style="vertical-align: middle; width: 29px; padding-right: 5px;"></td>
<td><a href="mailto:<?= $email ?>"><?= $email ?></a></td>
</tr>
<tr>
<td><img alt="" src="/icons/phone.svg" style="vertical-align: middle; width: 29px; padding-right: 5px;"></td>
<td><?php if (isset($data["phone"]) && $data["phone"] !== ""): ?><a href="tel:<?= str_replace(" ", "", $data["phone"]) ?>"><?= $data["phone"] ?></a><?php else: ?>-<?php endif; ?></td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div style="margin-top: 20px;">
<?php if (isset($data["contents"]) && trim($data["contents"] !== "")): ?>
<div>
<?= $data["contents"] ?>
</div>
<?php else: ?>
<p class="text-muted"><?= l("lang_profile_empty") ?></p>
<?php endif; ?>
</div>
<br><br>
</div>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/footer.php"; ?>

@ -0,0 +1,122 @@
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $_USER; global $_PROFILE;
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php";
$id = array_values(array_filter(array_keys($_GET), function ($i) {
return str_starts_with($i, "/") && strlen($i) > 1;
}))[0] ?? null;
if (isset($id)) {
$id = substr($id, 1);
if (!preg_match("/[a-zA-Z0-6]/m", $id)) {
header("Location: /");
die();
}
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")) {
header("Location: /");
die();
}
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")) {
$data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")), true);
$title_pre = $data["title"];
} else {
header("Location: /");
die();
}
$title = "lang_upload_title";
} else {
header("Location: /");
die();
}
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/navigation.php";
?>
<form method="post" action="/_upload/save/?id=<?= $id ?>" id="main-form" enctype="multipart/form-data">
<div class="container">
<br><br>
<h1>
<?php if ($id !== $_USER): ?>
<span><?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json") ? $data["first_name"] . " " . $data["last_name"] : $data["title"] ?></span>
<span style="float: right;"><a href="/gallery/<?= $id ?>" class="btn btn-outline-dark"><?= l("lang_edit_cancel") ?></a></span>
<?php endif; ?>
</span>
</h1>
<?php if (isset($_GET["success"])): ?>
<div class="alert alert-success">
<strong><?= l("lang_upload_success_0") ?></strong><?= l("lang_upload_success_1") ?> <a href="/upload/<?= $id ?>"><?= l("lang_upload_success_2") ?></a>
</div>
<?php else: ?>
<?php if (isset($_GET['error'])): ?>
<div class="alert alert-danger">
<strong><?= l("lang_upload_error") ?></strong><?= l("lang_upload_errors_" . $_GET['error']) ?>
</div>
<?php endif; ?>
<div>
<p><?= l("lang_upload_select") ?></p>
<input type="file" name="file" style="width: 100%;">
<script>
window.onload = () => {
document.getElementsByName("file")[0].value = "";
}
document.getElementsByName("file")[0].onchange = () => {
if (document.getElementsByName("file")[0].files[0] && document.getElementsByName("file")[0].files[0].type.startsWith("image/")) {
document.getElementById("preview").src = URL.createObjectURL(document.getElementsByName("file")[0].files[0]);
document.getElementById("preview").onload = () => URL.revokeObjectURL(document.getElementById("preview").src);
document.getElementById("form-btn").classList.remove("disabled");
} else {
document.getElementById("preview").src = "/icons/defaultpage.svg";
document.getElementById("form-btn").classList.add("disabled");
}
}
</script>
</div>
<p>
<img src="/icons/defaultpage.svg" style="width: 100%; max-width: 300px; margin-top: 20px; border-radius: 10px;" id="preview">
</p>
<a id="form-btn" class="btn btn-primary disabled"><?= l("lang_upload_confirm") ?></a>
<script>
document.getElementById("form-btn").onclick = (event) => {
new bootstrap.Modal(document.getElementById("confirm")).show()
}
</script>
<?php endif; ?>
<br><br>
</div>
<div class="modal fade" id="confirm">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><?= l("lang_upload_dialog") ?></h4>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<p><?= l("lang_upload_notice") ?></p>
<p>
<?= l("lang_upload_summary") ?><br>
<!--suppress HtmlFormInputWithoutLabel -->
<textarea class="form-control" name="summary"></textarea>
</p>
<p><?= l("lang_upload_followup") ?></p>
<button class="btn btn-primary"><?= l("lang_edit_confirm_button") ?></button>
</div>
</div>
</div>
</div>
</form>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/footer.php"; ?>

@ -0,0 +1,72 @@
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php";
global $_PROFILE; global $_USER;
$id = $_GET['id'] ?? null;
$uuid = uuid();
header("Content-Type: text/plain");
var_dump($_POST, $_FILES["file"], $uuid);
if (!isset($_FILES["file"])) {
header("Location: /upload/$id&error=unreceived");
die();
}
if ($_FILES["file"]["error"] !== 0) {
header("Location: /upload/$id&error=internal");
die();
}
if ($_FILES["file"]["type"] !== "image/png" && $_FILES["file"]["type"] !== "image/jpeg" && $_FILES["file"]["type"] !== "image/webp" && $_FILES["file"]["type"] !== "image/gif" && $_FILES["file"]["type"] !== "image/bmp" && $_FILES["file"]["type"] !== "image/avif") {
header("Location: /upload/$id&error=type");
die();
}
$im = imagecreate(1, 1);
switch ($_FILES["file"]["type"]) {
case "image/png":
$im = imagecreatefrompng($_FILES["file"]["tmp_name"]);
break;
case "image/jpeg":
$im = imagecreatefromjpeg($_FILES["file"]["tmp_name"]);
break;
case "image/webp":
$im = imagecreatefromwebp($_FILES["file"]["tmp_name"]);
break;
case "image/gif":
$im = imagecreatefromgif($_FILES["file"]["tmp_name"]);
break;
case "image/bmp":
$im = imagecreatefrombmp($_FILES["file"]["tmp_name"]);
break;
case "image/avif":
$im = imagecreatefromavif($_FILES["file"]["tmp_name"]);
break;
}
imagejpeg($im, $_SERVER['DOCUMENT_ROOT'] . "/uploads/" . $uuid . ".jpg");
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $uuid . ".json", utf8_encode(json_encode([
"type" => "galleryupload",
"author" => $_USER,
"id" => $id,
"contents" => null,
"summary" => $_POST["summary"],
"date" => date('c')
])));
$_PROFILE["requests"][$id . ":" . $uuid] = $uuid;
saveProfile();
header("Location: /upload/$id&success");
die();

@ -0,0 +1,72 @@
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php";
$id = $_GET['id'] ?? null;
if (isset($id)) {
if (!preg_match("/[a-zA-Z0-6]/m", $id)) {
die();
}
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $id . ".json")) {
die();
}
} else {
die();
}
$request = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $id . ".json")), true);
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")) {
while (trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")) === "") {}
$profile = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")), true);
loadLang(json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/lang/" . $profile["language"] . ".json")), true), "lang");
$index = array_search($id, $profile["requests"]);
if ($index !== false) {
unset($profile["requests"][$index]);
}
$profile["alerts"][] = [
"title" => l("lang_notifications_approve_title"),
"message" => str_replace("%3", date('H:i', strtotime($request["date"])), str_replace("%2", formatDate($request["date"]), str_replace("%1", l("lang_request_types_" . $request["type"]), l("lang_notifications_approve_message")))),
"date" => date('c'),
"read" => false
];
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json", utf8_encode(json_encode($profile, JSON_PRETTY_PRINT)));
}
if ($request["type"] === "galleryupload" && !isset($_GET['mark'])) {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $request["id"] . ".json")) {
$gallery = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $request["id"] . ".json")), true);
$gallery["images"][] = [
"id" => $id,
"author" => $request["author"],
"date" => $request["date"]
];
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $request["id"] . ".json", utf8_encode(json_encode($gallery)));
}
}
if (($request["type"] === "gallerymeta" || $request["type"] === "article" || $request["type"] === "userpage") && !isset($_GET['mark'])) {
$file = "/";
if ($request["type"] === "gallerymeta") $file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $request["id"] . ".json";
if ($request["type"] === "article") $file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $request["id"] . ".json";
if ($request["type"] === "userpage") $file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $request["id"] . ".json";
$d = json_decode(utf8_decode(file_get_contents($file)), true);
$d["contents"] = $request["contents"];
file_put_contents($file, utf8_encode(json_encode($d)));
}
unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $id . ".json");
header("Location: /admin");
die();

@ -0,0 +1,94 @@
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php";
if (isset($_GET["skel"])) {
if (preg_match("/^[a-z]*$/m", $_GET["skel"]) === false || !file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/skels/" . $_GET["skel"] . ".json")) {
header("Location: /admin");
die();
}
$skel = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/skels/" . $_GET["skel"] . ".json"), true);
$title_pre = "Create a new object";
} else {
header("Location: /admin");
die();
}
$title = "Admin";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/navigation.php";
?>
<div class="container">
<br><br>
<h1>Create a new object</h1>
<?php if (isset($error)): ?>
<div class="alert alert-danger">
<b>Error: </b><?= $error ?>
</div>
<?php endif; ?>
<form action="/admin/create/save/?skel=<?= $_GET['skel'] ?>" method="post">
<p>
<textarea name="contents" style="width: 100%; max-height: 90vh; resize: none; outline: none; font-family: monospace;" rows="15"><?= $_POST["contents"] ?? json_encode($skel, JSON_PRETTY_PRINT) ?></textarea>
</p>
<p>
<details>
<summary><b>Documentation: <code>education</code> in the people skel</b></summary>
<ul>
<li>lhs: Lower high school (collège)</li>
<li>uhs: Upper high school (lycée)</li>
<li>ps: Primary school (maternelle/élémentaire)</li>
<li>uni: University level (études supérieures)</li>
<li>free: Other</li>
</ul>
</details>
<details>
<summary><b>Documentation: <code>state</code> in the people skel</b></summary>
<ul>
<li>0: deceased</li>
<li>1: in birth</li>
<li>2: alive</li>
</ul>
</details>
<details>
<summary><b>Documentation: <code>gender</code> in the people skel</b></summary>
<ul>
<li>fem</li>
<li>male</li>
<li>other (non binary)</li>
<li>trans_fem (MtF)</li>
<li>trans_male (FtM)</li>