-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
80 lines (67 loc) · 2.39 KB
/
index.php
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
<?php
require 'Person.php';
require 'Storage.php';
$name_du = isset($_GET['du']) ? filter_var($_GET['du'], FILTER_SANITIZE_STRING) : '';
$name_schatzi = isset($_GET['schatzi']) ? filter_var($_GET['schatzi'], FILTER_SANITIZE_STRING) : '';
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<title>Liebes-Orakel</title>
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Petit+Formal+Script">
<link rel="stylesheet" href="style.css">
</head>
<body class="hearty-bg">
<header class="header lovebox">
<h1>Finde die wahre Liebe</h1>
<strong>Gib den Namen deines Schatzes ein und erfahre, ob ihr für einander bestimmt seid.</strong>
</header>
<form class="form lovebox" action="index.php" method="GET">
<input type="text" name="du" placeholder="Dein Name" value="<?= $name_du ?>">
<input type="text" name="schatzi" placeholder="Schatzis Name" value="<?= $name_schatzi ?>">
<button type="submit">♥</button>
</form>
<?php
if ($name_du && $name_schatzi):
$du = new Person($name_du);
$schatzi = new Person($name_schatzi);
$score = $du->compareTo($schatzi);
$statement = $du->getStatementFor($schatzi);
?>
<div class="result lovebox">
<p class="statement">Ihr passt zu</p>
<p class="score"><?= $score ?>%</p>
<p class="statement">zusammen.</p>
<p class="statement"><?= $statement ?></p>
</div>
<?php endif ?>
<div class="archive lovebox">
<h2>Archive</h2>
<ul class="archive-list">
<?php
$storage = new Storage();
if (isset($score)) {
$storage->addEntry(array($name_du, $name_schatzi, $score));
}
$archive = $storage->getArchive();
if (!sizeof($archive)) {
echo '<p>Derzeit gibt es keine Einträge. Sei der erste!</p>';
}
else {
foreach ($archive as $entry) {
echo
"<li>
<small>" . date('j. M', strtotime($entry['timestamp'])) . "</small>
<strong> ${entry['name1']} ♥ ${entry['name2']} </strong> zu ${entry['score']}%
</li>";
}
}
?>
</ul>
</div>
<footer class="footer lovebox">
<p>Wir übernehmen keine Haftung für gebrochene Herzen.</p>
</footer>
</body>
</html>