index.php 2.5 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
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
}
?><!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">
<style type="text/css">
html {
	font-family: 'colfaxLight', 'Arial', sans-serif;
}
html,
body,
form {
	margin: 0;
	width: 100%;
	height: 100%;
}
form {
	display: table;
}
form > * {
	display: table-row;
}
form > * > * {
	display: table-cell;
	padding: .2em 1em;
}
main {
	height: 100%;
}
textarea {
	width: 100%;
	height: 100%;
	box-sizing: border-box;
	border: none;
	box-shadow: none;
	outline: none;
	resize: none;
	background: #fff;
	padding: 0 1em;
Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
51
	font-family: monospace;
Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
52
53
54
55
56
57
58
59
60
}
textarea:invalid {
	background: url('instruction.png') 50% 10% no-repeat;
}
nav {
	display: table;
	background: #f8f8f8;
	border-bottom: 1px solid #e7e7e7;
}
Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
61
footer > * {
Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
	padding-left: 2em;
	background: #f8f8f8;
	border-top: 1px solid #e7e7e7;
}
nav > * {
	display: table-cell;
}
nav #logo > img {
	display: block;
}
nav h1 {
	white-space: nowrap;
	padding-left: 1em;
	vertical-align: middle;
	color: #6a5f58;
}
nav ul {
	vertical-align: middle;
}
nav ul > li {
	display: inline;
}
nav button,
nav a {
	color: #666464;
	background: none;
	border: none;
	font-size: 1em;
	padding: 0 1em;
	text-decoration: none;
	cursor: pointer;
}
.permfail {
	color: red;
}
.pass {
	color: green;
}

</style>

<form method="post">
	<header>
		<nav>
			<div id="logo">
				<img src="https://eduroam.no/bower_components/uninett-theme/images/UNINETT_logo.svg" alt="UNINETT logo">
			</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
117
<?php if (isset($signatures)): ?>
Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
118
119
120

	<footer>
		<ol>
Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
121
		<?php foreach($signatures as $sig): ?>
Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
122
123
124
125
126
127
128
129
130
131
132
133
134
135

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

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

			</ul></li>
		<?php endforeach; ?>

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

Jørn Åne de Jong's avatar
Jørn Åne de Jong committed
136
137
<main><textarea required autofocus name="mail"><?= htmlspecialchars($msgContent) ?></textarea></main>

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