-
Notifications
You must be signed in to change notification settings - Fork 0
/
antworten.php
49 lines (43 loc) · 1.31 KB
/
antworten.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
<?php
/**
* Drei-Quiz-Fragen
* von Andre Trecksel
*/
/*
* Inhaltstyp auf JSON setzen
*/
header('Content-Type: application/json');
// header('Content-Type: text/plain'); // fürs Debuggen
/*
*
*/
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$antw = array(
// 'post' => $_POST, // fürs Debuggen
'korrekt' => false
);
if (isset($_POST['html'])) { // Frage 1
// $antw['antworten'] = array(0, 0, 1);
if ($_POST['html'] == 'c') {
$antw['korrekt'] = true;
}
} else if (isset($_POST['css-a']) || isset($_POST['css-b']) || isset($_POST['css-c'])) { // Frage 2
// $antw['antworten'] = array(1, 0, 1);
if (isset($_POST['css-a']) && isset($_POST['css-c']) && !isset($_POST['css-b'])) {
$antw['korrekt'] = true;
}
} else if (isset($_POST['php'])) { // Frage 3
// $antw['php-antwort-original'] = $_POST['php']; // fürs Debuggen
$php_antwort_gefiltert = filter_input(INPUT_POST, 'php', FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK | FILTER_FLAG_ENCODE_HIGH);
// $antw['php-antwort-filtered'] = $php_antwort_gefiltert; // fürs Debuggen
if ($php_antwort_gefiltert == 'echo') {
$antw['korrekt'] = true;
}
}
echo json_encode($antw);
//
} else {
//
echo '{"korrekt":false,"error":1}';
//
}