Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
tiborepcek authored Oct 13, 2021
1 parent cbf0d84 commit 2565017
Show file tree
Hide file tree
Showing 27 changed files with 4,430 additions and 0 deletions.
10 changes: 10 additions & 0 deletions 1_stiahni_nazov_kvizu.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@echo off
chcp 65001
curl -o kviz.include https://tiborepcek.com/kviz-demo/kviz.include
set /p kviz=<kviz.include
echo.
echo Názov aktuálne zvoleného kvízu je: %kviz%
echo.
echo Po stlačení ľubovoľného tlačidla sa skript ukončí.
echo.
pause > nul
10 changes: 10 additions & 0 deletions 2_stiahni_odpovede.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@echo off
chcp 65001
echo Stiahne aktuálne odpovede. Potrebuje program curl.
echo.
set /p kviz=<kviz.include
curl -o odpovede-%kviz%.csv https://tiborepcek.com/kviz-demo/odpovede-%kviz%.csv
echo.
echo Po stlačení ľubovoľného tlačidla sa skript ukončí.
echo.
pause > nul
74 changes: 74 additions & 0 deletions hrac.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,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>
';
}
?>
Binary file added hymna.mp3
Binary file not shown.
38 changes: 38 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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();
endif;

$kviz = file_get_contents("./kviz.include");
?>

<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Cache-Control" content="no-store" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="expires" content="mon, 27 sep 2010 14:30:00 GMT" />
<link rel="stylesheet" type="text/css" href="style.css">
<title>Kvíz <?php echo str_replace("_", " ", ucfirst($kviz)) ?> - úvod</title>
</head>

<body>
<h1>Zadaj meno a e-mail a ťukni na tlačidlo HRAŤ.</h1>
<div class="centrovane">
<form action="hrac.php" method="get" autocomplete="on">
<input type="text" name="meno" size="20" maxlength="20" placeholder="Meno hráča kvízu <?php echo str_replace("_", " ", ucfirst($kviz)) ?>" required />
<input type="email" name="email" size="20" placeholder="E-mail hráča kvízu <?php echo str_replace("_", " ", ucfirst($kviz)) ?>" required />
<input type="hidden" name="otazka" value="1" />
<input type="submit" value="HRAŤ" />
</form>
</div>
<p class="centrovane"><?php include('phpqrcode.php'); QRcode::png('https://' . $_SERVER["HTTP_HOST"] . dirname($_SERVER['PHP_SELF']), 'url.png', QR_ECLEVEL_L, 10); ?><img src="url.png" alt="URL"></p>
<p class="centrovane"><?php echo $_SERVER["HTTP_HOST"] . dirname($_SERVER['PHP_SELF']) ?></p>
<p class="centrovane"><?php echo "(".str_replace("_", " ", ucfirst($kviz)).")" ?></p>
</body>
</html>
1 change: 1 addition & 0 deletions kviz.include
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
demo
124 changes: 124 additions & 0 deletions moderator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?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();
}
include("ochrana.php");
$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)) ?> - moderátor</title>
</head>

<body>
<?php
zobraz($_GET['otazka']);

function zobraz($otazka) {
global $kviz, $otazok_spolu, $subor_otazok, $subor_otazok_riadok;
$dalsia_otazka = $otazka + 1;
$predosla_otazka = $otazka - 1;
echo "<h1>";
if ($otazka > 1) {
echo ' <a href="?otazka=' . $predosla_otazka . '">&lt;</a> ';
}
echo "Kvíz " . str_replace("_", " ", ucfirst($kviz)) . ", otázka " . $otazka . " / ". $otazok_spolu;
if ($dalsia_otazka <= $otazok_spolu) {
echo ' <a href="?otazka=' . $dalsia_otazka . '">&gt;</a>';
}
echo "</h1>
";
$subor_otazok_riadok_cast = explode("\t", $subor_otazok_riadok[$predosla_otazka]);
echo '<div class="stlpce">
<div class="vlavo">
<h2 class="otazka">' . $subor_otazok_riadok_cast[0] . '</h2>
';
if ($otazka == $otazok_spolu) {
echo '<h3 class="dolezite centrovane">Toto je posledná otázka kvízu. Počkajte na výsledky, ktoré oznámi moderátor.</h3>
';
echo '<h4 class="centrovane"><a href="?otazka=1">Späť na prvú otázku</a></h4>
';
}
echo '</div><!-- koniec časti vlavo -->
<div class="vpravo">
';
echo '<div class="odpovede">
';
echo '<h3 id="odpovedA"><span class="pismenoOtazky">A</span> ' . $subor_otazok_riadok_cast[1] . '</h3>
';
echo '<h3 id="odpovedB"><span class="pismenoOtazky">B</span> ' . $subor_otazok_riadok_cast[2] . '</h3>
';
echo '<h3 id="odpovedC"><span class="pismenoOtazky">C</span> ' . $subor_otazok_riadok_cast[3] . '</h3>
';
echo '<h3 id="odpovedD"><span class="pismenoOtazky">D</span> ' . $subor_otazok_riadok_cast[4] . '</h3>
';
if (file_exists("otazka".$otazka.".blok") or file_exists("kviz.blok")) {
echo "<h3 class=\"dolezite\">Táto otázka je zablokovaná.</h3>
";
echo '<div><form action="odblokuj_otazku.php" method="post">
';
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="Odblokovať otázku" />
';
echo '</form>
</div><!-- koniec časti odblokuj_otazku -->
';
echo '<div><form action="odblokuj_vsetky_otazky.php" method="post">
';
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="Odblokovať všetky otázky" />
';
echo '</form>
</div><!-- koniec časti odblokuj_vsetky_otazky -->
';
}
else {
echo '<div><form action="zablokuj_otazku.php" method="post">
';
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="Zablokovať otázku" />
';
echo '</form>
</div><!-- koniec časti zablokuj_otazku -->
';
}
echo "<div><button type=\"button\"
onclick=\"document.getElementById('odpoved" . trim($subor_otazok_riadok_cast[5]) . "').style.backgroundColor = 'green'\">
Označiť správnu odpoveď</button></div><!-- koniec časti oznacit_spravnu_odpoved -->
";
echo "</div><!-- koniec časti odpovede -->
";
echo "</div><!-- koniec časti vpravo -->
</div><!-- koniec časti stlpce -->
";
}
?>

</body>
</html>
37 changes: 37 additions & 0 deletions nahraj_subor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Cache-Control" content="no-store" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="expires" content="mon, 27 sep 2010 14:30:00 GMT" />
<link rel="stylesheet" type="text/css" href="style.css">
<title>Nahrávanie súboru</title>
</head>

<body>
<h1>Nahrávanie súboru</h1>
<?php
$uploadDirectory = '';
if(isset($_FILES['subor'])){
$allowedExtensions = array(
'png', 'jpg', 'mp3', 'mp4', 'tsv', 'html'
);
$file = $_FILES['subor'];
$name = $file['name'];
$extension = pathinfo($name, PATHINFO_EXTENSION);
$extension = strtolower($extension);
if(!in_array($extension, $allowedExtensions)){
echo '<p class="dolezite centrovane">Koncovka súboru <strong>' . $extension . '</strong> nie je povolená.</p>';
} else{
$tmpLocation = $file['tmp_name'];
$newLocation = $uploadDirectory . $name;
$move = move_uploaded_file($tmpLocation, $newLocation);
echo '<p class="centrovane">Súbor <strong>' . $name . '</strong> bol práve nahratý.</p>';
}
}
?>
<p class="centrovane"><a href="sprava.php">Späť na správu kvízov</a></p>
</body>
</html>
Loading

0 comments on commit 2565017

Please sign in to comment.