web - refactor core modules, harden authorization, simplify endpoints
This commit is contained in:
@@ -4,6 +4,36 @@
|
||||
|
||||
// Initialisierung
|
||||
require_once $_SERVER['DOCUMENT_ROOT'].'/intranet_repo/general_files/initialise.php';
|
||||
require_once __DIR__ . '/util/seelsorge_helpers.php';
|
||||
|
||||
$seelsorgeCsrfToken = seelsorge_csrf_token();
|
||||
$activeTab = ($_GET['tab'] ?? '') === 'visit' ? 'visit' : 'calendar';
|
||||
$visitFormError = $_SESSION['seelsorge_visit_form_error'] ?? null;
|
||||
unset($_SESSION['seelsorge_visit_form_error']);
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['visit_command'])) {
|
||||
$isVisitSave = $_POST['visit_command'] === 'save';
|
||||
$submittedVisitForm = $isVisitSave ? array_diff_key($_POST, ['visit_command' => true, 'csrf_token' => true]) : null;
|
||||
|
||||
try {
|
||||
seelsorge_verify_csrf($_POST);
|
||||
seelsorge_process_visit_command($pdo, $_POST, (int) $_SESSION['user_id']);
|
||||
} catch (InvalidArgumentException | RuntimeException $e) {
|
||||
$_SESSION['seelsorge_visit_form_error'] = [
|
||||
'message' => $e->getMessage(),
|
||||
'form' => $submittedVisitForm,
|
||||
];
|
||||
} catch (Throwable $e) {
|
||||
error_log('Seelsorge visit command failed: ' . $e->getMessage());
|
||||
$_SESSION['seelsorge_visit_form_error'] = [
|
||||
'message' => 'Aktion fehlgeschlagen.',
|
||||
'form' => $submittedVisitForm,
|
||||
];
|
||||
}
|
||||
|
||||
header('Location: /intranet_repo/projects/seelsorge/seelsorge.php?tab=visit', true, 303);
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de" dir="ltr">
|
||||
@@ -27,15 +57,15 @@
|
||||
|
||||
<div class="content" id="fullsize">
|
||||
<div class="content-tab-bar" id="seelsorge-tabs">
|
||||
<div class="content-tab-bar__item active" data-target="content_calendar">Kalendarium</div>
|
||||
<div class="content-tab-bar__item" data-target="content_visit">Besuchsstellen</div>
|
||||
<div class="content-tab-bar__item<?= $activeTab === 'calendar' ? ' active' : '' ?>" data-target="content_calendar">Kalendarium</div>
|
||||
<div class="content-tab-bar__item<?= $activeTab === 'visit' ? ' active' : '' ?>" data-target="content_visit">Besuchsstellen</div>
|
||||
</div>
|
||||
<div class="content_seelsorge active" id="content_calendar">
|
||||
<div class="content_seelsorge<?= $activeTab === 'calendar' ? ' active' : '' ?>" id="content_calendar">
|
||||
<?php // Kalendarium:
|
||||
include 'content/calendar.php'; ?>
|
||||
</div>
|
||||
|
||||
<div class="content_seelsorge" id="content_visit">
|
||||
<div class="content_seelsorge<?= $activeTab === 'visit' ? ' active' : '' ?>" id="content_visit">
|
||||
|
||||
<?php // Besuchsstellen:
|
||||
include 'content/visit.php'; ?>
|
||||
@@ -61,6 +91,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include __DIR__ . '/content/profile.php'; ?>
|
||||
|
||||
<script type="application/json" id="seelsorge-config"><?= json_encode([
|
||||
'csrfToken' => $seelsorgeCsrfToken,
|
||||
], JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT) ?></script>
|
||||
|
||||
<?php require_once $_SERVER['DOCUMENT_ROOT'].'/intranet_repo/projects/_central/php/footer.php'; ?>
|
||||
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user