index.php 1.63 KB
Newer Older
Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
1
2
3
4
5
6
7
8
9
10
<?php
require dirname(__DIR__) . implode(DIRECTORY_SEPARATOR, ['', 'vendor', 'autoload.php']);
$msgContent = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
	if (!isset($_POST['mail']) || empty($_POST['mail'])) {
		header('Location: /');
		exit;
	}
	$msgContent = $_POST['mail'];
	$dkimValidator = new DKIM_Verify($msgContent);
Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
11
	$signatures = $dkimValidator->validate();
Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
12
13
14
15
16
}
?><!DOCTYPE html>
<meta http-equiv="Content-Type" value="text/html;charset=utf-8">
<title>DKIM validator</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
Jørn Åne's avatar
Jørn Åne committed
17
<link rel="stylesheet" href="style.css" type="text/css">
Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
18
19
20
21
22

<form method="post">
	<header>
		<nav>
			<div id="logo">
Jørn Åne's avatar
Jørn Åne committed
23
				<a href="https://www.uninett.no/"><img src="https://eduroam.no/bower_components/uninett-theme/images/UNINETT_logo.svg" alt="UNINETT logo"></a>
Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
24
25
26
27
28
29
30
31
32
			</div>
			<h1>DKIM validator</h1>
			<ul style="width: 100%">
				<li><button type="submit">Validate</button></li>
				<a href="/">Reset</a>
			</ul>
		</nav>
	</header>

Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
33
<?php if (isset($signatures)): ?>
Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
34
35
36

	<footer>
		<ol>
37
38
39
		<?php if (empty($signatures)): ?>
			<li value="0">No signatures found</a>
		<?php else: ?>
Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
40
		<?php foreach($signatures as $sig): ?>
Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
41
42
43
44
45
46
47
48
49

			<li><ul>
			<?php foreach($sig as $result): ?>

				<li class="<?= htmlspecialchars($result['status']) ?>"><?= htmlspecialchars($result['reason']) ?></li>
			<?php endforeach; ?>

			</ul></li>
		<?php endforeach; ?>
50
		<?php endif; ?>
Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
51
52
53
54
55

		</ol>
	</footer>
<?php endif; ?>

Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
56
<main><textarea required autofocus name="mail" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"><?= htmlspecialchars($msgContent) ?></textarea></main>
Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
57

Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
58
</form>