-
Notifications
You must be signed in to change notification settings - Fork 0
/
hrac.php
74 lines (69 loc) · 3.38 KB
/
hrac.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
<?php
if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "off"){
$redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $redirect);
exit();
}
$kviz = file_get_contents("./kviz.include");
$otazky = "otazky-".$kviz.".tsv";
$otazok_spolu = count(file($otazky));
$subor_otazok = file_get_contents($otazky, true);
$subor_otazok_riadok = explode("\n", $subor_otazok);
?>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Kvíz <?php echo str_replace("_", " ", ucfirst($kviz)) ?> - hráč</title>
</head>
<body>
<?php
$meno = $_GET['meno'];
$email = $_GET['email'];
$otazka = $_GET['otazka'];
$dalsia_otazka = $otazka + 1;
zobraz($otazka);
function zobraz($otazka) {
global $kviz, $meno, $email, $otazok_spolu, $subor_otazok, $subor_otazok_riadok, $dalsia_otazka;
if (file_exists("otazka".$otazka.".blok") or file_exists("kviz.blok")) {
echo '<h1 class="dolezite">Kvíz ' . str_replace("_", " ", ucfirst($kviz)) . ', hráč ' . $meno . ', e-mail ' . $email . ', otázka ' . $otazka . ' - táto otázka je zablokovaná.</h1>
';
echo "<h2><a href=\"?meno=" . $meno . "&email=". $email . "&otazka=". $dalsia_otazka ."\">Prejsť na ďalšiu otázku</a></h2>
";
echo "</body>
";
echo "</html>
";
die();
}
$dalsia_otazka = $otazka + 1;
$predosla_otazka = $otazka - 1;
echo "<h1>Otázka " . $otazka . " / ". $otazok_spolu . "</h1>
";
$subor_otazok_riadok_cast = explode("\t", $subor_otazok_riadok[$predosla_otazka]);
echo '<div class="centrovane"><form action="zapis_odpoved.php" method="post">
';
echo ' <input type="hidden" name="meno" value="' . $meno . '" />
';
echo ' <input type="hidden" name="email" value="' . $email . '" />
';
echo ' <input type="hidden" name="kviz" value="' . $kviz . '" />
';
echo ' <input type="hidden" name="otazka" value="' . $otazka . '" />
';
echo ' <input type="hidden" name="otazokSpolu" value="' . $otazok_spolu . '" />
';
echo ' <input type="submit" name="odpoved" value="A" />
';
echo ' <input type="submit" name="odpoved" value="B" />
';
echo ' <input type="submit" name="odpoved" value="C" />
';
echo ' <input type="submit" name="odpoved" value="D" />
';
echo '</form><p>Kvíz: '.str_replace("_", " ", ucfirst($kviz)).'<br />Hráč: '.$meno.'<br />E-mail: '.$email.'</p></div>
';
}
?>