forked from amah/kummerkasten-php
89 lines
3.2 KiB
PHP
89 lines
3.2 KiB
PHP
<!DOCTYPE html>
|
|
|
|
<?php
|
|
$lang = $_GET["lang"] ?? ($lang = "de");
|
|
if ($lang !== "de" && $lang !== "en") {
|
|
http_response_code(302);
|
|
$url = "?" . http_build_query(["lang" => "en", "redirect_lang" => $lang]);
|
|
header("Location: $url");
|
|
|
|
echo "<p>The language <code>" . htmlspecialchars($lang) . "</code> is not currently supported.</p>";
|
|
echo "<p>You should have been redirected to the english version of this page. If not, click <a href=\"$url\">here</a></p>";
|
|
|
|
die();
|
|
}
|
|
$text = json_decode(file_get_contents("languages/$lang.json"), true);
|
|
$title = $text["title"];
|
|
$about = $text["about"];
|
|
$subject_placeholder = $text["subject_placeholder"];
|
|
$message_placeholder = $text["message_placeholder"];
|
|
$send_button = $text["send_button"];
|
|
$go_back = $text["go_back"];
|
|
|
|
$recipient = $text["recipient"];
|
|
|
|
if (isset($_POST["submit"])) {
|
|
$subject = mb_encode_mimeheader(
|
|
"[Kummerkasten] " . $_POST["subject"],
|
|
"UTF-8",
|
|
"Q"
|
|
);
|
|
$message = wordwrap($_POST["message"], 77, " \r\n"); // see rfc5322 section-2.1.1
|
|
|
|
$headers = [
|
|
"Content-Transfer-Encoding" => "binary",
|
|
"Content-Type" => 'text/plain; charset="UTF-8"; format="flowed"',
|
|
];
|
|
|
|
if (mail($recipient, $subject, $message, $headers)) {
|
|
header("Location: success.php?lang=$lang");
|
|
} else {
|
|
header("Location: failed.php?lang=$lang");
|
|
}
|
|
die();
|
|
}
|
|
?>
|
|
<html lang="<?php echo $lang; ?>">
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
|
|
<title id="page_title"><?php echo $title; ?></title>
|
|
<link rel="shortcut icon" href="favicon.svg" />
|
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
|
<link rel="stylesheet" href="index.css">
|
|
</head>
|
|
|
|
<body>
|
|
<header class="header">
|
|
<nav class="header-inner">
|
|
<div class="header-top">
|
|
<a class="header-element" href="https://fs-informatik.uni-kiel.de/">
|
|
<img src="logo.svg">
|
|
</a>
|
|
<a class="header-element" href="https://www.fs-informatik.uni-kiel.de/kummerkasten/">
|
|
<h1 id="title"><?php echo $title; ?></h1>
|
|
</a>
|
|
</div>
|
|
</nav>
|
|
</header>
|
|
<?php if (isset($_GET["redirect_lang"])) { ?>
|
|
<div class="infobox warn">
|
|
<p> The language <code><?php echo htmlspecialchars($_GET["redirect_lang"]); ?></code> is not supported. You have been redirected to the english language suggestion box. </p>
|
|
</div>
|
|
<?php } ?>
|
|
<div id="about" class="infobox"><?php echo $about; ?></div>
|
|
<form action="<?php echo $_SERVER["PHP_SELF"] .
|
|
"?" .
|
|
http_build_query($_GET); ?>" method="post" accept-charset="UTF-8">
|
|
<input type="text" id="subject" name="subject" placeholder="<?php echo $subject_placeholder; ?>"></input>
|
|
<textarea id="message" name="message" placeholder="<?php echo $message_placeholder; ?>" rows="15"></textarea>
|
|
<button class="btn btn-primary" type="submit" name="submit"><?php echo $send_button; ?></button>
|
|
</form>
|
|
<p>
|
|
<a href="https://www.fs-informatik.uni-kiel.de/" id="go_back"
|
|
class="link-button"><?php echo $go_back; ?></a>
|
|
</p>
|
|
</body>
|
|
|
|
</html>
|