index.php 2.45 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
11
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
51
52
53
54
55
56
57
58
59
60
61
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?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);
}
?><!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;
}
textarea:invalid {
	background: url('instruction.png') 50% 10% no-repeat;
}
nav {
	display: table;
	background: #f8f8f8;
	border-bottom: 1px solid #e7e7e7;
}
footer > ol {
	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>

<main><textarea required autofocus name="mail"><?= htmlspecialchars($msgContent) ?></textarea></main>

<?php if (isset($dkimValidator)): ?>

	<footer>
		<ol>
		<?php foreach($dkimValidator->validate() as $sig): ?>

			<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; ?>

</form>