initial commit
This commit is contained in:
55
-inc/footer.php
Normal file
55
-inc/footer.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<footer class="footer bg-dark text-white py-4 px-3 px-md-0">
|
||||
<div class="container">
|
||||
<div class="row d-flex flex-row justify-content-between align-items-center">
|
||||
<a href="https://www.facebook.com/Posilovna-Tj-Olympia-Zl%C3%ADn-Bure%C5%A1ov-199000300263655">
|
||||
<img src="<?php echo $webpath; ?>-img/facebook.svg" alt="Facebook" class="fb-logo">
|
||||
</a>
|
||||
<?php
|
||||
if (isset($_SESSION['userrole'])) {
|
||||
if ($_SESSION['userrole'] != 'Cvičenec') {
|
||||
echo '<a class="text-white" href="' . $webpath . 'admin/index.php">Administrace</a>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<span class="text-right">TJ Olympia © 2020</span>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<span class="mx-auto text-center">Souhlasím s využítím pro potřeby výuky na KITTV PEDF UK. @David_Zálešák</span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<?php echo (isset($_SESSION['userid'])) ? '' : '<script src="https://captcheck.netsyms.com/captcheck.min.js"></script>' ?>
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('[data-toggle="popover"]').popover();
|
||||
<?php
|
||||
if (isset($loginerror)) {
|
||||
echo "$('#login').modal('show');";
|
||||
}
|
||||
if (isset($registererror)) {
|
||||
echo "$('#register').modal('show');";
|
||||
}
|
||||
if (isset($adderror)) {
|
||||
echo "$('#add').modal('show');";
|
||||
}
|
||||
if (isset($_GET["list"])) {
|
||||
echo "$('#userList').modal('show');";
|
||||
}
|
||||
if (isset($_GET["edit"])) {
|
||||
echo "$('#edit').modal('show');";
|
||||
}
|
||||
if (isset($_GET["edituser"])) {
|
||||
echo "$('#editUser').modal('show');";
|
||||
}
|
||||
?>
|
||||
//$('#staticBackdrop').modal('show');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
481
-inc/function-admin.php
Normal file
481
-inc/function-admin.php
Normal file
@@ -0,0 +1,481 @@
|
||||
<?php
|
||||
|
||||
$servername = "127.0.0.1";
|
||||
$username = "...";
|
||||
$password = "...";
|
||||
$dbname = "...";
|
||||
|
||||
// Create connection
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
// Check connection
|
||||
if ($conn->connect_error) {
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
$mysqlerror = NULL;
|
||||
$adderror = NULL;
|
||||
$editerror = NULL;
|
||||
|
||||
function remove_accents($string)
|
||||
{
|
||||
if (!preg_match('/[\x80-\xff]/', $string))
|
||||
return $string;
|
||||
|
||||
$chars = array(
|
||||
// Decompositions for Latin-1 Supplement
|
||||
chr(195) . chr(128) => 'A', chr(195) . chr(129) => 'A',
|
||||
chr(195) . chr(130) => 'A', chr(195) . chr(131) => 'A',
|
||||
chr(195) . chr(132) => 'A', chr(195) . chr(133) => 'A',
|
||||
chr(195) . chr(135) => 'C', chr(195) . chr(136) => 'E',
|
||||
chr(195) . chr(137) => 'E', chr(195) . chr(138) => 'E',
|
||||
chr(195) . chr(139) => 'E', chr(195) . chr(140) => 'I',
|
||||
chr(195) . chr(141) => 'I', chr(195) . chr(142) => 'I',
|
||||
chr(195) . chr(143) => 'I', chr(195) . chr(145) => 'N',
|
||||
chr(195) . chr(146) => 'O', chr(195) . chr(147) => 'O',
|
||||
chr(195) . chr(148) => 'O', chr(195) . chr(149) => 'O',
|
||||
chr(195) . chr(150) => 'O', chr(195) . chr(153) => 'U',
|
||||
chr(195) . chr(154) => 'U', chr(195) . chr(155) => 'U',
|
||||
chr(195) . chr(156) => 'U', chr(195) . chr(157) => 'Y',
|
||||
chr(195) . chr(159) => 's', chr(195) . chr(160) => 'a',
|
||||
chr(195) . chr(161) => 'a', chr(195) . chr(162) => 'a',
|
||||
chr(195) . chr(163) => 'a', chr(195) . chr(164) => 'a',
|
||||
chr(195) . chr(165) => 'a', chr(195) . chr(167) => 'c',
|
||||
chr(195) . chr(168) => 'e', chr(195) . chr(169) => 'e',
|
||||
chr(195) . chr(170) => 'e', chr(195) . chr(171) => 'e',
|
||||
chr(195) . chr(172) => 'i', chr(195) . chr(173) => 'i',
|
||||
chr(195) . chr(174) => 'i', chr(195) . chr(175) => 'i',
|
||||
chr(195) . chr(177) => 'n', chr(195) . chr(178) => 'o',
|
||||
chr(195) . chr(179) => 'o', chr(195) . chr(180) => 'o',
|
||||
chr(195) . chr(181) => 'o', chr(195) . chr(182) => 'o',
|
||||
chr(195) . chr(182) => 'o', chr(195) . chr(185) => 'u',
|
||||
chr(195) . chr(186) => 'u', chr(195) . chr(187) => 'u',
|
||||
chr(195) . chr(188) => 'u', chr(195) . chr(189) => 'y',
|
||||
chr(195) . chr(191) => 'y',
|
||||
// Decompositions for Latin Extended-A
|
||||
chr(196) . chr(128) => 'A', chr(196) . chr(129) => 'a',
|
||||
chr(196) . chr(130) => 'A', chr(196) . chr(131) => 'a',
|
||||
chr(196) . chr(132) => 'A', chr(196) . chr(133) => 'a',
|
||||
chr(196) . chr(134) => 'C', chr(196) . chr(135) => 'c',
|
||||
chr(196) . chr(136) => 'C', chr(196) . chr(137) => 'c',
|
||||
chr(196) . chr(138) => 'C', chr(196) . chr(139) => 'c',
|
||||
chr(196) . chr(140) => 'C', chr(196) . chr(141) => 'c',
|
||||
chr(196) . chr(142) => 'D', chr(196) . chr(143) => 'd',
|
||||
chr(196) . chr(144) => 'D', chr(196) . chr(145) => 'd',
|
||||
chr(196) . chr(146) => 'E', chr(196) . chr(147) => 'e',
|
||||
chr(196) . chr(148) => 'E', chr(196) . chr(149) => 'e',
|
||||
chr(196) . chr(150) => 'E', chr(196) . chr(151) => 'e',
|
||||
chr(196) . chr(152) => 'E', chr(196) . chr(153) => 'e',
|
||||
chr(196) . chr(154) => 'E', chr(196) . chr(155) => 'e',
|
||||
chr(196) . chr(156) => 'G', chr(196) . chr(157) => 'g',
|
||||
chr(196) . chr(158) => 'G', chr(196) . chr(159) => 'g',
|
||||
chr(196) . chr(160) => 'G', chr(196) . chr(161) => 'g',
|
||||
chr(196) . chr(162) => 'G', chr(196) . chr(163) => 'g',
|
||||
chr(196) . chr(164) => 'H', chr(196) . chr(165) => 'h',
|
||||
chr(196) . chr(166) => 'H', chr(196) . chr(167) => 'h',
|
||||
chr(196) . chr(168) => 'I', chr(196) . chr(169) => 'i',
|
||||
chr(196) . chr(170) => 'I', chr(196) . chr(171) => 'i',
|
||||
chr(196) . chr(172) => 'I', chr(196) . chr(173) => 'i',
|
||||
chr(196) . chr(174) => 'I', chr(196) . chr(175) => 'i',
|
||||
chr(196) . chr(176) => 'I', chr(196) . chr(177) => 'i',
|
||||
chr(196) . chr(178) => 'IJ', chr(196) . chr(179) => 'ij',
|
||||
chr(196) . chr(180) => 'J', chr(196) . chr(181) => 'j',
|
||||
chr(196) . chr(182) => 'K', chr(196) . chr(183) => 'k',
|
||||
chr(196) . chr(184) => 'k', chr(196) . chr(185) => 'L',
|
||||
chr(196) . chr(186) => 'l', chr(196) . chr(187) => 'L',
|
||||
chr(196) . chr(188) => 'l', chr(196) . chr(189) => 'L',
|
||||
chr(196) . chr(190) => 'l', chr(196) . chr(191) => 'L',
|
||||
chr(197) . chr(128) => 'l', chr(197) . chr(129) => 'L',
|
||||
chr(197) . chr(130) => 'l', chr(197) . chr(131) => 'N',
|
||||
chr(197) . chr(132) => 'n', chr(197) . chr(133) => 'N',
|
||||
chr(197) . chr(134) => 'n', chr(197) . chr(135) => 'N',
|
||||
chr(197) . chr(136) => 'n', chr(197) . chr(137) => 'N',
|
||||
chr(197) . chr(138) => 'n', chr(197) . chr(139) => 'N',
|
||||
chr(197) . chr(140) => 'O', chr(197) . chr(141) => 'o',
|
||||
chr(197) . chr(142) => 'O', chr(197) . chr(143) => 'o',
|
||||
chr(197) . chr(144) => 'O', chr(197) . chr(145) => 'o',
|
||||
chr(197) . chr(146) => 'OE', chr(197) . chr(147) => 'oe',
|
||||
chr(197) . chr(148) => 'R', chr(197) . chr(149) => 'r',
|
||||
chr(197) . chr(150) => 'R', chr(197) . chr(151) => 'r',
|
||||
chr(197) . chr(152) => 'R', chr(197) . chr(153) => 'r',
|
||||
chr(197) . chr(154) => 'S', chr(197) . chr(155) => 's',
|
||||
chr(197) . chr(156) => 'S', chr(197) . chr(157) => 's',
|
||||
chr(197) . chr(158) => 'S', chr(197) . chr(159) => 's',
|
||||
chr(197) . chr(160) => 'S', chr(197) . chr(161) => 's',
|
||||
chr(197) . chr(162) => 'T', chr(197) . chr(163) => 't',
|
||||
chr(197) . chr(164) => 'T', chr(197) . chr(165) => 't',
|
||||
chr(197) . chr(166) => 'T', chr(197) . chr(167) => 't',
|
||||
chr(197) . chr(168) => 'U', chr(197) . chr(169) => 'u',
|
||||
chr(197) . chr(170) => 'U', chr(197) . chr(171) => 'u',
|
||||
chr(197) . chr(172) => 'U', chr(197) . chr(173) => 'u',
|
||||
chr(197) . chr(174) => 'U', chr(197) . chr(175) => 'u',
|
||||
chr(197) . chr(176) => 'U', chr(197) . chr(177) => 'u',
|
||||
chr(197) . chr(178) => 'U', chr(197) . chr(179) => 'u',
|
||||
chr(197) . chr(180) => 'W', chr(197) . chr(181) => 'w',
|
||||
chr(197) . chr(182) => 'Y', chr(197) . chr(183) => 'y',
|
||||
chr(197) . chr(184) => 'Y', chr(197) . chr(185) => 'Z',
|
||||
chr(197) . chr(186) => 'z', chr(197) . chr(187) => 'Z',
|
||||
chr(197) . chr(188) => 'z', chr(197) . chr(189) => 'Z',
|
||||
chr(197) . chr(190) => 'z', chr(197) . chr(191) => 's'
|
||||
);
|
||||
|
||||
$string = strtr($string, $chars);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
function vypisTreninku()
|
||||
{
|
||||
global $conn;
|
||||
$sql = "SELECT id, datum, kapacita, jmeno FROM trenink_trenink ORDER BY datum ASC;";
|
||||
$result = $conn->query($sql);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
// output data of each row
|
||||
$dateus = array("/^1/", "/^2/", "/^3/", "/^4/", "/^5/", "/^6/", "/^7/");
|
||||
$datecz = array("Po", "Út", "St", "Čt", "Pa", "So", "Ne");
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$sql1 = "select * from trenink_zapsan where trenink=" . $row["id"] . ";";
|
||||
$result1 = $conn->query($sql1);
|
||||
echo '<tr>';
|
||||
echo '<td><b>' . $row["jmeno"] . '</b><br>' . preg_replace($dateus, $datecz, date("N j.&\\nb\sp;n. Y \o\d&\\nb\sp;H:i", strtotime($row["datum"]))) . '</td>';
|
||||
echo '<td>' . $result1->num_rows . '/' . $row["kapacita"] . '</td>';
|
||||
echo '<td>';
|
||||
echo '<a role="button" href="?edit=' . $row["id"] . '" class="btn btn-outline-secondary btn-block">Upravit</a>';
|
||||
echo '<a role="button" href="?list=' . $row["id"] . '" class="btn btn-info btn-block">Seznam</a>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
} else {
|
||||
echo '<tr><td colspan="3">';
|
||||
echo "Žádné Tréninky";
|
||||
echo '</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
function addTrenink($nazev, $datum, $kapacita, $obrazek, $popis, $treneri)
|
||||
{
|
||||
global $adderror;
|
||||
global $mysqlerror;
|
||||
if (empty($nazev) || empty($datum) || empty($kapacita) || empty($obrazek) || empty($popis)) {
|
||||
$adderror = "Vyplňte všechna pole.";
|
||||
} else {
|
||||
$check = getimagesize($obrazek);
|
||||
if ($check !== false) {
|
||||
global $conn;
|
||||
$obrazek = addslashes(file_get_contents($obrazek));
|
||||
$sql = "INSERT INTO `trenink_trenink` (`id`, `datum`, `kapacita`, `jmeno`, `popis`, `obrazek`) VALUES (NULL, '" . date("Y-m-d H:i:s", strtotime($datum)) . "', '$kapacita', '$nazev', '$popis', '{$obrazek}');";
|
||||
if ($conn->query($sql) === FALSE) {
|
||||
$mysqlerror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
|
||||
$treninkId = $conn->insert_id;
|
||||
$sql = "INSERT INTO `trenink_trenuje` (`trener`, `trenink`) VALUES ";
|
||||
for ($i = 0; $i < count($treneri); $i++) {
|
||||
$sql .= "('" . $treneri["$i"] . "', '$treninkId')";
|
||||
if (count($treneri) != 1 && $i != count($treneri) - 1) {
|
||||
$sql .= ", ";
|
||||
}
|
||||
}
|
||||
$sql .= ";";
|
||||
if ($conn->query($sql) === FALSE) {
|
||||
$mysqlerror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
} else {
|
||||
$adderror = "Soubor musí být obrázek.";
|
||||
}
|
||||
}
|
||||
}
|
||||
function vypisTreneru()
|
||||
{
|
||||
global $conn;
|
||||
$sql = "SELECT id, jmeno, prijmeni FROM trenink_user WHERE `role`=2;";
|
||||
$result = $conn->query($sql);
|
||||
if ($result->num_rows > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
echo '<option value="' . $row['id'] . '">' . $row['jmeno'] . ' ' . $row['prijmeni'] . '</option>';
|
||||
}
|
||||
} else {
|
||||
echo '<option selected>Žádní trenéři</option>';
|
||||
}
|
||||
}
|
||||
function editVypisTreneru($trenink)
|
||||
{
|
||||
global $conn;
|
||||
$sql = "SELECT u.id, u.jmeno, u.prijmeni FROM trenink_trenuje t INNER JOIN trenink_user u ON t.trener=u.id WHERE t.trenink=$trenink;";
|
||||
$result = $conn->query($sql);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$sql = "SELECT id, jmeno, prijmeni FROM trenink_user WHERE `role`=2 AND id NOT IN(";
|
||||
$count = $result->num_rows - 1;
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$sql .= $row['id'];
|
||||
if ($count) {
|
||||
$sql .= ", ";
|
||||
$count--;
|
||||
}
|
||||
echo '<option value="' . $row['id'] . '" selected>' . $row['jmeno'] . ' ' . $row['prijmeni'] . '</option>';
|
||||
}
|
||||
$sql .= ");";
|
||||
$result = $conn->query($sql);
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
echo '<option value="' . $row['id'] . '">' . $row['jmeno'] . ' ' . $row['prijmeni'] . '</option>';
|
||||
}
|
||||
} else {
|
||||
vypisTreneru();
|
||||
}
|
||||
}
|
||||
function vypisPrihlasenych($trenink)
|
||||
{
|
||||
global $conn;
|
||||
$sql = "SELECT u.id, u.jmeno, u.prijmeni, u.overeni FROM trenink_zapsan z INNER JOIN trenink_user u ON u.id=z.client WHERE z.trenink=$trenink";
|
||||
$result = $conn->query($sql);
|
||||
if ($result->num_rows > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
if ($row['overeni'] > 1) {
|
||||
echo '<tr class="table-success">';
|
||||
} elseif ($row['overeni'] > 0) {
|
||||
echo '<tr class="table-warning">';
|
||||
} else {
|
||||
echo '<tr class="align-middle">';
|
||||
}
|
||||
|
||||
echo '<td>' . $row['prijmeni'] . ' ' . $row['jmeno'] . '</td>';
|
||||
echo '<td><a class="btn btn-outline-danger float-right" href="?list=' . $trenink . '&odepsat=' . $row['id'] . '" role="button">Odepsat</a>
|
||||
</td>';
|
||||
|
||||
echo '</tr>';
|
||||
}
|
||||
} else {
|
||||
echo '<tr><td colspan="2">Nikdo není přihlášen.</td></tr>';
|
||||
}
|
||||
}
|
||||
function odepsat($client, $trenink)
|
||||
{
|
||||
global $conn;
|
||||
global $mysqlerror;
|
||||
$sql = "DELETE FROM `trenink_zapsan` WHERE `trenink_zapsan`.`client` = " . $client . " AND `trenink_zapsan`.`trenink` = $trenink;";
|
||||
if ($conn->query($sql) === FALSE) {
|
||||
$mysqlerror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
}
|
||||
function editForm($trenink)
|
||||
{
|
||||
global $conn;
|
||||
global $editerror;
|
||||
$sql = "SELECT * FROM trenink_trenink WHERE `id`=$trenink;";
|
||||
$result = $conn->query($sql);
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
echo '<form class="was-validated" id="editForm" action="' . $_SERVER['PHP_SELF'] . '" method="post" enctype="multipart/form-data">';
|
||||
echo '<div class="form-group">';
|
||||
echo '<label for="nazev">Název:</label>';
|
||||
echo '<input type="text" name="nazev" class="form-control" id="nazev" value="' . $row['jmeno'] . '" required>';
|
||||
echo '<input type="hidden" id="id" name="id" value="' . $row['id'] . '">';
|
||||
echo '</div>';
|
||||
echo '<div class="form-group">';
|
||||
echo '<label for="datum">Datum:</label>';
|
||||
echo '<input type="datetime-local" name="datum" class="form-control" id="datum" value="' . strftime('%Y-%m-%dT%H:%M:%S', strtotime($row['datum'])) . '" required>';
|
||||
echo '</div>';
|
||||
echo '<div class="form-group">';
|
||||
echo '<label for="kapacita">Kapacita:</label>';
|
||||
echo '<input type="number" name="kapacita" class="form-control" id="kapacita" value="' . $row['kapacita'] . '" required>';
|
||||
echo '</div>';
|
||||
echo '<div class="form-group">';
|
||||
echo '<label for="kapacita">Trénují:</label>';
|
||||
echo '<select class="custom-select" name="treneri[]" multiple required>';
|
||||
editVypisTreneru($_GET['edit']);
|
||||
echo '</select>';
|
||||
echo '</div>';
|
||||
echo '<div class="form-group">';
|
||||
echo '<label for="popis">Popis:</label>';
|
||||
echo '<div class="custom-file mb-3">';
|
||||
echo '<input type="file" class="custom-file-input" name="obrazekEdit" id="obrazekEdit" accept="image/*">';
|
||||
echo '<label class="custom-file-label" for="obrazekEdit">Vyberte obrázek...</label>';
|
||||
echo '</div>';
|
||||
echo '<textarea class="form-control" name="popis" id="popis" placeholder="Popis tréninku..."required>' . $row['popis'] . '</textarea>';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
}
|
||||
}
|
||||
function editTrenink($id, $nazev, $datum, $kapacita, $obrazek, $popis, $treneri)
|
||||
{
|
||||
global $mysqlerror;
|
||||
if (empty($nazev) || empty($datum) || empty($kapacita) || empty($popis)) {
|
||||
$mysqlerror = "Vyplňte všechna pole.";
|
||||
} else {
|
||||
global $conn;
|
||||
$check = (empty($obrazek)) ? '' : getimagesize($obrazek);
|
||||
if (!empty($obrazek) && $check !== false) {
|
||||
$obrazek = addslashes(file_get_contents($obrazek));
|
||||
$sql = "UPDATE `trenink_trenink` SET `datum` = '" . date("Y-m-d H:i:s", strtotime($datum)) . "', `kapacita` = '$kapacita', `jmeno` = '$nazev', `popis` = '$popis', `obrazek` = '$obrazek' WHERE `trenink_trenink`.`id` = $id; ;";
|
||||
} else {
|
||||
$sql = "UPDATE `trenink_trenink` SET `datum` = '" . date("Y-m-d H:i:s", strtotime($datum)) . "', `kapacita` = '$kapacita', `jmeno` = '$nazev', `popis` = '$popis' WHERE `trenink_trenink`.`id` = $id; ;";
|
||||
}
|
||||
if ($conn->query($sql) === FALSE) {
|
||||
$mysqlerror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM `trenink_trenuje` WHERE `trenink_trenuje`.`trenink` = $id; ";
|
||||
if ($conn->query($sql) === FALSE) {
|
||||
$mysqlerror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `trenink_trenuje` (`trener`, `trenink`) VALUES ";
|
||||
for ($i = 0; $i < count($treneri); $i++) {
|
||||
$sql .= "('" . $treneri["$i"] . "', '$id')";
|
||||
if (count($treneri) != 1 && $i != count($treneri) - 1) {
|
||||
$sql .= ", ";
|
||||
}
|
||||
}
|
||||
$sql .= ";";
|
||||
if ($conn->query($sql) === FALSE) {
|
||||
$mysqlerror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
}
|
||||
}
|
||||
function delete($trenink)
|
||||
{
|
||||
global $conn;
|
||||
global $mysqlerror;
|
||||
$sql = "DELETE FROM `trenink_zapsan` WHERE `trenink_zapsan`.`trenink` = $trenink;";
|
||||
if ($conn->query($sql) === FALSE) {
|
||||
$mysqlerror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
$sql = "DELETE FROM `trenink_trenuje` WHERE `trenink_trenuje`.`trenink` = $trenink;";
|
||||
if ($conn->query($sql) === FALSE) {
|
||||
$mysqlerror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
$sql = "DELETE FROM `trenink_trenink` WHERE `trenink_trenink`.`id` = $trenink;";
|
||||
if ($conn->query($sql) === FALSE) {
|
||||
$mysqlerror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
}
|
||||
function vypisUzivatelu()
|
||||
{
|
||||
global $conn;
|
||||
$sql = "SELECT id, jmeno, prijmeni, overeni FROM trenink_user;";
|
||||
$result = $conn->query($sql);
|
||||
if ($result->num_rows > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
if ($row['overeni'] > 1) {
|
||||
echo '<tr class="table-success">';
|
||||
} elseif ($row['overeni'] > 0) {
|
||||
echo '<tr class="table-secondary">';
|
||||
} else {
|
||||
echo '<tr class="table-warning">';
|
||||
}
|
||||
echo '<td>' . $row['prijmeni'] . ' ' . $row['jmeno'] . '</td>';
|
||||
echo '<td>';
|
||||
echo '<a role="button" href="?edituser=' . $row['id'] . '" class="btn btn-secondary btn-block">Upravit</a>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
} else {
|
||||
echo '<tr><td colspan="2">Žádní uživatelé.</td></tr>';
|
||||
}
|
||||
}
|
||||
function editFormUser($user)
|
||||
{
|
||||
global $conn;
|
||||
global $editerror;
|
||||
$sql = "SELECT * FROM trenink_user WHERE `id`=$user;";
|
||||
$result = $conn->query($sql);
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
echo '<form class="was-validated" id="editFormUser" action="' . $_SERVER['PHP_SELF'] . '" method="post" enctype="multipart/form-data">';
|
||||
echo '<div class="form-group">';
|
||||
echo '<label for="jmeno">Jméno:</label>';
|
||||
echo '<input type="text" name="jmeno" class="form-control" value="' . $row['jmeno'] . '" id="jmeno" required>';
|
||||
echo '<input type="hidden" name="id" value="' . $row['id'] . '">';
|
||||
echo '</div>';
|
||||
echo '<div class="form-group">';
|
||||
echo '<label for="prijmeni">Příjmení:</label>';
|
||||
echo '<input type="text" name="prijmeni" class="form-control" value="' . $row['prijmeni'] . '" id="prijmeni" required>';
|
||||
echo '</div>';
|
||||
echo '<div class="form-group">';
|
||||
echo '<label for="email">E-mail:</label>';
|
||||
echo '<input type="email" name="email" class="form-control" value="' . $row['email'] . '" id="email" required>';
|
||||
echo '</div>';
|
||||
echo '<div class="form-group">';
|
||||
echo '<label for="funkce">Funkce:</label>';
|
||||
echo '<select class="custom-select" id="funkce" name="funkce">';
|
||||
echo '<option value="1" '.($row['role'] == "Cvičenec" ? 'selected':'').'>Cvičenec</option>';
|
||||
echo '<option value="2" ' . ($row['role'] == "Trenér" ? 'selected' : '') . '>Trenér</option>';
|
||||
echo '<option value="3" ' . ($row['role'] == "Admin" ? 'selected' : '') . '>Admin</option>';
|
||||
echo '</select>';
|
||||
echo '</div>';
|
||||
echo '<div class="form-group">';
|
||||
if ($row['overeni'] < 2) {
|
||||
echo '<button type="submit" class="btn btn-success btn-block" name="submit" value="overit" form="editFormUser">Ověřit</button>';
|
||||
} else {
|
||||
echo '<button type="submit" class="btn btn-outline-warning btn-block" name="submit" value="zrusitOvereni" form="editFormUser">Zrušit ověření</button>';
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
}
|
||||
}
|
||||
function editUser($id, $jmeno, $prijmeni, $email, $funkce){
|
||||
global $mysqlerror;
|
||||
if (empty($id) || empty($jmeno) || empty($prijmeni) || empty($email) || empty($funkce)) {
|
||||
$mysqlerror = "Vyplňte všechna pole.";
|
||||
} else {
|
||||
global $conn;
|
||||
$sql = "UPDATE `trenink_user` SET `email` = '$email', `role` = '$funkce', `jmeno` = '$jmeno', `prijmeni` = '$prijmeni' WHERE `trenink_user`.`id` = $id;";
|
||||
|
||||
if ($conn->query($sql) === FALSE) {
|
||||
$mysqlerror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
}
|
||||
}
|
||||
function overit($id){
|
||||
global $mysqlerror;
|
||||
if (empty($id)) {
|
||||
$mysqlerror = "Vyplňte všechna pole.";
|
||||
} else {
|
||||
global $conn;
|
||||
$sql = "UPDATE `trenink_user` SET `overeni` = `overeni` + 2 WHERE `trenink_user`.`id` = $id;";
|
||||
|
||||
if ($conn->query($sql) === FALSE) {
|
||||
$mysqlerror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
}
|
||||
}
|
||||
function zrusitOvereni($id) {
|
||||
global $mysqlerror;
|
||||
if (empty($id)) {
|
||||
$mysqlerror = "Vyplňte všechna pole.";
|
||||
} else {
|
||||
global $conn;
|
||||
$sql = "UPDATE `trenink_user` SET `overeni` = `overeni` - 2 WHERE `trenink_user`.`id` = $id;";
|
||||
|
||||
if ($conn->query($sql) === FALSE) {
|
||||
$mysqlerror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
}
|
||||
}
|
||||
function deleteUser($id)
|
||||
{
|
||||
global $mysqlerror;
|
||||
if (empty($id)) {
|
||||
$mysqlerror = "Vyplňte všechna pole.";
|
||||
} else {
|
||||
global $conn;
|
||||
$sql = "DELETE FROM `trenink_trenuje` WHERE `trenink_trenuje`.`trener` = $id";
|
||||
|
||||
if ($conn->query($sql) === FALSE) {
|
||||
$mysqlerror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM `trenink_zapsan` WHERE `trenink_zapsan`.`client` = $id";
|
||||
|
||||
if ($conn->query($sql) === FALSE) {
|
||||
$mysqlerror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM `trenink_user` WHERE `trenink_user`.`id` = $id";
|
||||
|
||||
if ($conn->query($sql) === FALSE) {
|
||||
$mysqlerror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
}
|
||||
}
|
||||
322
-inc/function.php
Normal file
322
-inc/function.php
Normal file
@@ -0,0 +1,322 @@
|
||||
<?php
|
||||
|
||||
$servername = "127.0.0.1";
|
||||
$username = "...";
|
||||
$password = "...";
|
||||
$dbname = "...";
|
||||
|
||||
// Create connection
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
// Check connection
|
||||
if ($conn->connect_error) {
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
$loginerror = NULL;
|
||||
$mysqlerror = NULL;
|
||||
$registererror = NULL;
|
||||
|
||||
|
||||
function remove_accents($string)
|
||||
{
|
||||
if (!preg_match('/[\x80-\xff]/', $string))
|
||||
return $string;
|
||||
|
||||
$chars = array(
|
||||
// Decompositions for Latin-1 Supplement
|
||||
chr(195) . chr(128) => 'A', chr(195) . chr(129) => 'A',
|
||||
chr(195) . chr(130) => 'A', chr(195) . chr(131) => 'A',
|
||||
chr(195) . chr(132) => 'A', chr(195) . chr(133) => 'A',
|
||||
chr(195) . chr(135) => 'C', chr(195) . chr(136) => 'E',
|
||||
chr(195) . chr(137) => 'E', chr(195) . chr(138) => 'E',
|
||||
chr(195) . chr(139) => 'E', chr(195) . chr(140) => 'I',
|
||||
chr(195) . chr(141) => 'I', chr(195) . chr(142) => 'I',
|
||||
chr(195) . chr(143) => 'I', chr(195) . chr(145) => 'N',
|
||||
chr(195) . chr(146) => 'O', chr(195) . chr(147) => 'O',
|
||||
chr(195) . chr(148) => 'O', chr(195) . chr(149) => 'O',
|
||||
chr(195) . chr(150) => 'O', chr(195) . chr(153) => 'U',
|
||||
chr(195) . chr(154) => 'U', chr(195) . chr(155) => 'U',
|
||||
chr(195) . chr(156) => 'U', chr(195) . chr(157) => 'Y',
|
||||
chr(195) . chr(159) => 's', chr(195) . chr(160) => 'a',
|
||||
chr(195) . chr(161) => 'a', chr(195) . chr(162) => 'a',
|
||||
chr(195) . chr(163) => 'a', chr(195) . chr(164) => 'a',
|
||||
chr(195) . chr(165) => 'a', chr(195) . chr(167) => 'c',
|
||||
chr(195) . chr(168) => 'e', chr(195) . chr(169) => 'e',
|
||||
chr(195) . chr(170) => 'e', chr(195) . chr(171) => 'e',
|
||||
chr(195) . chr(172) => 'i', chr(195) . chr(173) => 'i',
|
||||
chr(195) . chr(174) => 'i', chr(195) . chr(175) => 'i',
|
||||
chr(195) . chr(177) => 'n', chr(195) . chr(178) => 'o',
|
||||
chr(195) . chr(179) => 'o', chr(195) . chr(180) => 'o',
|
||||
chr(195) . chr(181) => 'o', chr(195) . chr(182) => 'o',
|
||||
chr(195) . chr(182) => 'o', chr(195) . chr(185) => 'u',
|
||||
chr(195) . chr(186) => 'u', chr(195) . chr(187) => 'u',
|
||||
chr(195) . chr(188) => 'u', chr(195) . chr(189) => 'y',
|
||||
chr(195) . chr(191) => 'y',
|
||||
// Decompositions for Latin Extended-A
|
||||
chr(196) . chr(128) => 'A', chr(196) . chr(129) => 'a',
|
||||
chr(196) . chr(130) => 'A', chr(196) . chr(131) => 'a',
|
||||
chr(196) . chr(132) => 'A', chr(196) . chr(133) => 'a',
|
||||
chr(196) . chr(134) => 'C', chr(196) . chr(135) => 'c',
|
||||
chr(196) . chr(136) => 'C', chr(196) . chr(137) => 'c',
|
||||
chr(196) . chr(138) => 'C', chr(196) . chr(139) => 'c',
|
||||
chr(196) . chr(140) => 'C', chr(196) . chr(141) => 'c',
|
||||
chr(196) . chr(142) => 'D', chr(196) . chr(143) => 'd',
|
||||
chr(196) . chr(144) => 'D', chr(196) . chr(145) => 'd',
|
||||
chr(196) . chr(146) => 'E', chr(196) . chr(147) => 'e',
|
||||
chr(196) . chr(148) => 'E', chr(196) . chr(149) => 'e',
|
||||
chr(196) . chr(150) => 'E', chr(196) . chr(151) => 'e',
|
||||
chr(196) . chr(152) => 'E', chr(196) . chr(153) => 'e',
|
||||
chr(196) . chr(154) => 'E', chr(196) . chr(155) => 'e',
|
||||
chr(196) . chr(156) => 'G', chr(196) . chr(157) => 'g',
|
||||
chr(196) . chr(158) => 'G', chr(196) . chr(159) => 'g',
|
||||
chr(196) . chr(160) => 'G', chr(196) . chr(161) => 'g',
|
||||
chr(196) . chr(162) => 'G', chr(196) . chr(163) => 'g',
|
||||
chr(196) . chr(164) => 'H', chr(196) . chr(165) => 'h',
|
||||
chr(196) . chr(166) => 'H', chr(196) . chr(167) => 'h',
|
||||
chr(196) . chr(168) => 'I', chr(196) . chr(169) => 'i',
|
||||
chr(196) . chr(170) => 'I', chr(196) . chr(171) => 'i',
|
||||
chr(196) . chr(172) => 'I', chr(196) . chr(173) => 'i',
|
||||
chr(196) . chr(174) => 'I', chr(196) . chr(175) => 'i',
|
||||
chr(196) . chr(176) => 'I', chr(196) . chr(177) => 'i',
|
||||
chr(196) . chr(178) => 'IJ', chr(196) . chr(179) => 'ij',
|
||||
chr(196) . chr(180) => 'J', chr(196) . chr(181) => 'j',
|
||||
chr(196) . chr(182) => 'K', chr(196) . chr(183) => 'k',
|
||||
chr(196) . chr(184) => 'k', chr(196) . chr(185) => 'L',
|
||||
chr(196) . chr(186) => 'l', chr(196) . chr(187) => 'L',
|
||||
chr(196) . chr(188) => 'l', chr(196) . chr(189) => 'L',
|
||||
chr(196) . chr(190) => 'l', chr(196) . chr(191) => 'L',
|
||||
chr(197) . chr(128) => 'l', chr(197) . chr(129) => 'L',
|
||||
chr(197) . chr(130) => 'l', chr(197) . chr(131) => 'N',
|
||||
chr(197) . chr(132) => 'n', chr(197) . chr(133) => 'N',
|
||||
chr(197) . chr(134) => 'n', chr(197) . chr(135) => 'N',
|
||||
chr(197) . chr(136) => 'n', chr(197) . chr(137) => 'N',
|
||||
chr(197) . chr(138) => 'n', chr(197) . chr(139) => 'N',
|
||||
chr(197) . chr(140) => 'O', chr(197) . chr(141) => 'o',
|
||||
chr(197) . chr(142) => 'O', chr(197) . chr(143) => 'o',
|
||||
chr(197) . chr(144) => 'O', chr(197) . chr(145) => 'o',
|
||||
chr(197) . chr(146) => 'OE', chr(197) . chr(147) => 'oe',
|
||||
chr(197) . chr(148) => 'R', chr(197) . chr(149) => 'r',
|
||||
chr(197) . chr(150) => 'R', chr(197) . chr(151) => 'r',
|
||||
chr(197) . chr(152) => 'R', chr(197) . chr(153) => 'r',
|
||||
chr(197) . chr(154) => 'S', chr(197) . chr(155) => 's',
|
||||
chr(197) . chr(156) => 'S', chr(197) . chr(157) => 's',
|
||||
chr(197) . chr(158) => 'S', chr(197) . chr(159) => 's',
|
||||
chr(197) . chr(160) => 'S', chr(197) . chr(161) => 's',
|
||||
chr(197) . chr(162) => 'T', chr(197) . chr(163) => 't',
|
||||
chr(197) . chr(164) => 'T', chr(197) . chr(165) => 't',
|
||||
chr(197) . chr(166) => 'T', chr(197) . chr(167) => 't',
|
||||
chr(197) . chr(168) => 'U', chr(197) . chr(169) => 'u',
|
||||
chr(197) . chr(170) => 'U', chr(197) . chr(171) => 'u',
|
||||
chr(197) . chr(172) => 'U', chr(197) . chr(173) => 'u',
|
||||
chr(197) . chr(174) => 'U', chr(197) . chr(175) => 'u',
|
||||
chr(197) . chr(176) => 'U', chr(197) . chr(177) => 'u',
|
||||
chr(197) . chr(178) => 'U', chr(197) . chr(179) => 'u',
|
||||
chr(197) . chr(180) => 'W', chr(197) . chr(181) => 'w',
|
||||
chr(197) . chr(182) => 'Y', chr(197) . chr(183) => 'y',
|
||||
chr(197) . chr(184) => 'Y', chr(197) . chr(185) => 'Z',
|
||||
chr(197) . chr(186) => 'z', chr(197) . chr(187) => 'Z',
|
||||
chr(197) . chr(188) => 'z', chr(197) . chr(189) => 'Z',
|
||||
chr(197) . chr(190) => 'z', chr(197) . chr(191) => 's'
|
||||
);
|
||||
|
||||
$string = strtr($string, $chars);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
function vypisTreninku()
|
||||
{
|
||||
global $conn;
|
||||
$sql = "SELECT id, datum, kapacita, jmeno, popis, obrazek FROM trenink_trenink ORDER BY datum ASC";
|
||||
$result = $conn->query($sql);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
// output data of each row
|
||||
$dateus = array("/^1/", "/^2/", "/^3/", "/^4/", "/^5/", "/^6/", "/^7/");
|
||||
$datecz = array("Po", "Út", "St", "Čt", "Pa", "So", "Ne");
|
||||
|
||||
echo '<div class="card-columns">';
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$sql1 = "select jmeno, prijmeni from trenink_trenuje t INNER JOIN trenink_user u ON t.trener=u.id WHERE t.trenink=" . $row["id"] . ";";
|
||||
$result1 = $conn->query($sql1);
|
||||
$sql2 = "select * from trenink_zapsan where trenink=" . $row["id"] . ";";
|
||||
$result2 = $conn->query($sql2);
|
||||
$row2 = $result2->fetch_row();
|
||||
if (isset($_SESSION["userid"])) {
|
||||
$sql3 = "select * from trenink_zapsan where trenink=" . $row["id"] . " and client=" . $_SESSION["userid"] . ";";
|
||||
$result3 = $conn->query($sql3);
|
||||
}
|
||||
echo '<div class="card">';
|
||||
echo '<img class="card-img-top" src="data:image/jpeg;base64,' . base64_encode($row['obrazek']) . '" alt="Card image cap">';
|
||||
echo '<div class="card-body">';
|
||||
echo '<div class="container">';
|
||||
echo '<div class="row">';
|
||||
echo '<div class="col">';
|
||||
echo '<h2 class="card-title">' . $row["jmeno"] . '</h2>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '<div class="row">';
|
||||
echo '<div class="col">';
|
||||
echo '<span class="datum"><strong>' . preg_replace($dateus, $datecz, date("N j.&\\nb\sp;n. Y \o\d&\\nb\sp;H:i", strtotime($row["datum"]))) . '</strong></span>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '<div class="row">';
|
||||
echo '<div class="col">';
|
||||
echo '<strong class="text-muted">Trénují: </strong>';
|
||||
if ($result1->num_rows > 0) {
|
||||
$count = $result1->num_rows - 1;
|
||||
while ($row1 = $result1->fetch_assoc()) {
|
||||
echo '<a href="onas.php#' . remove_accents($row1["prijmeni"]) . '">' . $row1["jmeno"] . ' ' . $row1["prijmeni"] . '</a>';
|
||||
if ($count) {
|
||||
echo ", ";
|
||||
$count--;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "Nikdo netrénuje.";
|
||||
}
|
||||
echo '';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '<div class="row">';
|
||||
echo '<div class="col">';
|
||||
echo '<p class="card-text">' . $row["popis"] . '</p>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '<div class="row align-items-center mt-3">';
|
||||
echo '<div class="col">';
|
||||
if (isset($_SESSION["userid"])) {
|
||||
if ($row["kapacita"] <= $result2->num_rows) {
|
||||
echo '<a class="btn btn-danger disabled" href="#" role="button">Plno</a>';
|
||||
} elseif ($result3->num_rows) {
|
||||
echo '<a class="btn btn-outline-danger" href="?odepsat=' . $row["id"] . '" role="button">Odepsat se</a>';
|
||||
} else {
|
||||
echo '<a class="btn btn-success" href="?zapsat=' . $row["id"] . '" role="button">Zapsat se</a>';
|
||||
}
|
||||
} else {
|
||||
echo '<div class="btn-group p-0" role="group" aria-label="Basic example" data-toggle="popover" data-placement="bottom" data-content="Pro zapsání se musíte přihlásit.">';
|
||||
echo '<a class="btn btn-success disabled" href="#" role="button">Zapsat se</a>';
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
echo '<div class="col-">';
|
||||
if (100 / $row["kapacita"] * $result2->num_rows > 85) {
|
||||
$fontColor = "text-danger";
|
||||
} else if (100 / $row["kapacita"] * $result2->num_rows > 65) {
|
||||
$fontColor = "text-warning";
|
||||
} else {
|
||||
$fontColor = "text-primary";
|
||||
}
|
||||
echo '<span class="align-bottom ' . $fontColor . ' kapacita">' . $result2->num_rows . '/' . $row["kapacita"] . '</span>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<div class="alert alert-info w-100" role="alert">';
|
||||
echo "Momentálně nemáme žádné tréninky.";
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
function registrace($jmeno, $prijmeni, $email, $passwd, $passwdr)
|
||||
{
|
||||
global $registererror;
|
||||
if (empty($jmeno) || empty($prijmeni) || empty($email) || empty($passwd) || empty($passwdr)) {
|
||||
$registererror = "Vyplňte všechna pole.";
|
||||
} else {
|
||||
if($passwd == $passwdr){
|
||||
$url = 'http://captcheck.netsyms.com/api.php';
|
||||
$data = [
|
||||
'session_id' => $_POST['captcheck_session_code'],
|
||||
'answer_id' => isset($_POST['captcheck_selected_answer']) ? $_POST['captcheck_selected_answer'] : NULL,
|
||||
'action' => "verify"
|
||||
];
|
||||
$options = [
|
||||
'http' => [
|
||||
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
||||
'method' => 'POST',
|
||||
'content' => http_build_query($data)
|
||||
]
|
||||
];
|
||||
$context = stream_context_create($options);
|
||||
$result = file_get_contents($url, false, $context);
|
||||
$resp = json_decode($result, TRUE);
|
||||
if (!$resp['result']) {
|
||||
// Replace with error-handling code
|
||||
$registererror = "Chyba ověření.";
|
||||
|
||||
} else {
|
||||
global $conn;
|
||||
|
||||
$sql = "INSERT INTO `trenink_user` (`id`, `email`, `passwd`, `role`, `jmeno`, `prijmeni`, `overeni`) VALUES (NULL, '$email', '". crypt($passwd, '$6$rounds=5000$wretgbgsdfbuikitffdhsa$')."', 1, '$jmeno', '$prijmeni', 0);";
|
||||
|
||||
if ($conn->query($sql) === FALSE) {
|
||||
if ($conn->errno == 1062) {
|
||||
$registererror = "Tento email je již registrován.";
|
||||
} else {
|
||||
$registererror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
}
|
||||
|
||||
prihlaseni($email, $passwd);
|
||||
}
|
||||
} else {
|
||||
$registererror = "Hesla jsou rozdílná.";
|
||||
}
|
||||
}
|
||||
}
|
||||
function prihlaseni($email, $passwd)
|
||||
{
|
||||
global $loginerror;
|
||||
if (empty($email) || empty($passwd)) {
|
||||
$loginerror = "Vyplňte email i heslo.";
|
||||
} else {
|
||||
global $conn;
|
||||
$sql = "SELECT id, jmeno, prijmeni, `role`, email, passwd FROM trenink_user WHERE email LIKE '" . $email . "';";
|
||||
$result = $conn->query($sql);
|
||||
$row = $result->fetch_assoc();
|
||||
|
||||
if (empty($row)) {
|
||||
$loginerror = "Tento email není zaregistrován.";
|
||||
} elseif (crypt($passwd, '$6$rounds=5000$wretgbgsdfbuikitffdhsa$') == $row['passwd']) {
|
||||
// Set session variables
|
||||
$_SESSION["userid"] = $row['id'];
|
||||
$_SESSION["userjmeno"] = $row['jmeno'];
|
||||
$_SESSION["userprijmeni"] = $row['prijmeni'];
|
||||
$_SESSION["userrole"] = $row['role'];
|
||||
} else {
|
||||
$loginerror = "Špatné heslo.";
|
||||
}
|
||||
}
|
||||
}
|
||||
function logout()
|
||||
{
|
||||
// remove all session variables
|
||||
session_unset();
|
||||
|
||||
// destroy the session
|
||||
session_destroy();
|
||||
}
|
||||
function zapsat($trenink)
|
||||
{
|
||||
global $conn;
|
||||
global $mysqlerror;
|
||||
$sql = "INSERT INTO `trenink_zapsan` (`client`, `trenink`) VALUES ('" . $_SESSION["userid"] . "', '$trenink');";
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
} else {
|
||||
$mysqlerror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
}
|
||||
function odepsat($trenink)
|
||||
{
|
||||
global $conn;
|
||||
global $mysqlerror;
|
||||
$sql = "DELETE FROM `trenink_zapsan` WHERE `trenink_zapsan`.`client` = " . $_SESSION["userid"] . " AND `trenink_zapsan`.`trenink` = $trenink;";
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
} else {
|
||||
$mysqlerror = "Error: " . $sql . "<br>" . $conn->error;
|
||||
}
|
||||
}
|
||||
14
-inc/header.php
Normal file
14
-inc/header.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
// Start the session
|
||||
session_start();
|
||||
$webpath = preg_replace('/(admin\/|)[a-zA-Z0-9_-]+\.\S+$/', '', $_SERVER['PHP_SELF']);;
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>TJ Olympia - Tréninky</title>
|
||||
<link rel="stylesheet" href="<?php echo $webpath; ?>-inc/style.css">
|
||||
222
-inc/menu-admin.php
Normal file
222
-inc/menu-admin.php
Normal file
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
if (isset($_SESSION['userrole'])) {
|
||||
if ($_SESSION['userrole'] != "Admin" && $_SESSION['userrole'] != "Trenér") {
|
||||
header('Location: ../index.php');
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
header('Location: ../index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
include_once("../-inc/function-admin.php");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
if ($_POST['submit'] == 'add') {
|
||||
addTrenink($_POST['nazev'], $_POST['datum'], $_POST['kapacita'], $_FILES['obrazek']["tmp_name"], $_POST['popis'], $_POST['treneri']);
|
||||
}
|
||||
if ($_POST['submit'] == 'edit') {
|
||||
editTrenink($_POST['id'], $_POST['nazev'], $_POST['datum'], $_POST['kapacita'], $_FILES['obrazekEdit']["tmp_name"], $_POST['popis'], $_POST['treneri']);
|
||||
}
|
||||
if ($_POST['submit'] == 'delete') {
|
||||
delete($_POST['id']);
|
||||
}
|
||||
if ($_POST['submit'] == 'editUser') {
|
||||
editUser($_POST['id'], $_POST['jmeno'], $_POST['prijmeni'], $_POST['email'], $_POST['funkce']);
|
||||
}
|
||||
if ($_POST['submit'] == 'overit') {
|
||||
overit($_POST['id']);
|
||||
}
|
||||
if ($_POST['submit'] == 'zrusitOvereni') {
|
||||
zrusitOvereni($_POST['id']);
|
||||
}
|
||||
if ($_POST['submit'] == 'deleteUser') {
|
||||
deleteUser($_POST['id']);
|
||||
}
|
||||
}
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
|
||||
|
||||
if (isset($_GET['odepsat'])) {
|
||||
odepsat($_GET['odepsat'], $_GET['list']);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="d-flex flex-column flex-md-row align-items-center p-3 px-md-4 bg-white border-bottom box-shadow">
|
||||
<h5 class="my-0 mr-md-auto font-weight-normal">
|
||||
<img src="../-img/header_logo.png" alt="Logo">
|
||||
<span class="text-success">TJ</span> OLYMPIA <span class="section">/ administrace</span>
|
||||
</h5>
|
||||
<nav class="my-2 my-md-0 mr-md-3">
|
||||
<a class="p-2 text-dark" href="index.php">Tréninky</a>
|
||||
<a class="p-2 text-dark" href="uzivatele.php">Uživatelé</a>
|
||||
</nav>
|
||||
<div class="mt-3 mt-md-0">
|
||||
<a class="btn btn-success float-left mr-1" href="../index.php" role="button">Zpět</a>
|
||||
<a class="btn btn-outline-success float-left ml-1" href="../index.php?logout" role="button">Odhlásit se</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if (isset($mysqlerror)) {
|
||||
echo '<div class="alert alert-danger" role="alert">';
|
||||
echo $mysqlerror;
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Modal Add -->
|
||||
<div class="modal fade" id="add" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-scrollable">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="loginLabel">Přidat trénink</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php
|
||||
if (isset($adderror)) {
|
||||
echo '<div class="alert alert-danger" role="alert">';
|
||||
echo $adderror;
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="modal-body">
|
||||
<form class="was-validated" id="addForm" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
<label for="nazev">Název:</label>
|
||||
<input type="text" name="nazev" class="form-control" id="nazev" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="datum">Datum:</label>
|
||||
<input type="datetime-local" name="datum" class="form-control" id="datum" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="kapacita">Kapacita:</label>
|
||||
<input type="number" name="kapacita" class="form-control" id="kapacita" value="30" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="kapacita">Trénují:</label>
|
||||
<select class="custom-select" name="treneri[]" multiple required>
|
||||
<?php vypisTreneru(); ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="popis">Popis:</label>
|
||||
<div class="custom-file mb-3">
|
||||
<input type="file" class="custom-file-input" name="obrazek" id="obrazek" accept="image/*" required>
|
||||
<label class="custom-file-label" for="obrazek">Vyberte obrázek...</label>
|
||||
</div>
|
||||
<textarea class="form-control" name="popis" id="popis" placeholder="Popis tréninku..." required></textarea>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Zavřít</button>
|
||||
<button type="submit" class="btn btn-success" name="submit" value="add" form="addForm">Přidat</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal seznam přihlášených -->
|
||||
<div class="modal fade" id="userList" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-scrollable">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="loginLabel">Přihlášení na trénink</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body px-0 px-md-3">
|
||||
<table class="table table-striped table-hover">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th scope="col">Jméno</th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if (isset($_GET['list'])) {
|
||||
vypisPrihlasenych($_GET['list']);
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Zavřít</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal uprava -->
|
||||
<div class="modal fade" id="edit" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-scrollable">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="loginLabel">Přidat trénink</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php
|
||||
if (isset($editerror)) {
|
||||
echo '<div class="alert alert-danger" role="alert">';
|
||||
echo $editerror;
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="modal-body">
|
||||
<?php
|
||||
if (isset($_GET['edit'])) {
|
||||
editForm($_GET['edit']);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-outline-danger mr-auto" name="submit" value="delete" form="editForm">Odstranit</button>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Zavřít</button>
|
||||
<button type="submit" class="btn btn-success" name="submit" value="edit" form="editForm">Přidat</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal uprava uživatele -->
|
||||
<div class="modal fade" id="editUser" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-scrollable">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="loginLabel">Úprava účtu</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal-body">
|
||||
<?php
|
||||
if (isset($_GET['edituser'])) {
|
||||
editFormUser($_GET['edituser']);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-outline-danger mr-auto" name="submit" value="deleteUser" form="editFormUser">Odstranit</button>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Zavřít</button>
|
||||
<button type="submit" class="btn btn-success" name="submit" value="editUser" form="editFormUser">Upravit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
162
-inc/menu.php
Normal file
162
-inc/menu.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
include_once("-inc/function.php");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
if ($_POST['submit'] == 'login') {
|
||||
prihlaseni($_POST['email'], $_POST['passwd']);
|
||||
}
|
||||
if ($_POST['submit'] == 'register') {
|
||||
registrace($_POST['jmeno'], $_POST['prijmeni'], $_POST['email'], $_POST['passwd'], $_POST['passwdr'],);
|
||||
}
|
||||
}
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
|
||||
if (isset($_GET['logout'])) {
|
||||
logout();
|
||||
}
|
||||
if (isset($_GET['zapsat'])) {
|
||||
zapsat($_GET['zapsat']);
|
||||
}
|
||||
if (isset($_GET['odepsat'])) {
|
||||
odepsat($_GET['odepsat']);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="d-flex flex-column flex-md-row align-items-center p-3 px-md-4 bg-white border-bottom box-shadow">
|
||||
<h5 class="my-0 mr-md-auto font-weight-normal">
|
||||
<img src="-img/header_logo.png" alt="Logo">
|
||||
<span class="text-success">TJ</span> OLYMPIA
|
||||
</h5>
|
||||
<nav class="my-2 my-md-0 mr-md-3">
|
||||
<a class="p-2 text-dark" href="index.php">Tréninky</a>
|
||||
<a class="p-2 text-dark" href="onas.php">O nás</a>
|
||||
<a class="p-2 text-dark" href="kontakty.php">Kontakt</a>
|
||||
</nav>
|
||||
<div class="mt-3 mt-md-0 row align-items-center">
|
||||
<?php
|
||||
if (isset($_SESSION["userid"])) {
|
||||
echo '<span class="mx-3">' . $_SESSION["userjmeno"] . ' ' . $_SESSION["userprijmeni"] . '</span>';
|
||||
echo '<a class="btn btn-outline-success float-left ml-1" href="?logout" role="button">Odhlásit se</a>';
|
||||
} else {
|
||||
echo '<button class="btn btn-success float-left mr-1" type="button" data-toggle="modal" data-target="#login">Prihlásit se</button>';
|
||||
echo '<button class="btn btn-outline-success float-left ml-1" type="button" data-toggle="modal" data-target="#register">Registrovat se</button>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if (isset($mysqlerror)) {
|
||||
echo '<div class="alert alert-danger" role="alert">';
|
||||
echo $mysqlerror;
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Modal Login -->
|
||||
<div class="modal fade" id="login" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="loginLabel">Přihlášení</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php
|
||||
if (isset($loginerror)) {
|
||||
echo '<div class="alert alert-danger" role="alert">';
|
||||
echo $loginerror;
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">E-mail:</label>
|
||||
<input type="email" name="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="exampleInputPassword1">Heslo:</label>
|
||||
<input type="password" name="passwd" class="form-control" id="exampleInputPassword1">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<span class="mr-auto">Zapomenuté heslo</span>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Zavřít</button>
|
||||
<button type="submit" class="btn btn-success" name="submit" value="login">Přihlásit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Register -->
|
||||
<div class="modal fade" id="register" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="registerLabel">Registrace</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php
|
||||
if (isset($registererror)) {
|
||||
echo '<div class="alert alert-danger" role="alert">';
|
||||
echo $registererror;
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="jmeno">Jméno:</label>
|
||||
<input type="text" class="form-control" name="jmeno" id="jmeno">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="prijmeni">Příjmení:</label>
|
||||
<input type="text" class="form-control" name="prijmeni" id="prijmeni">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">E-mail:</label>
|
||||
<input type="email" class="form-control" name="email" id="email">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="passwd">Heslo:</label>
|
||||
<input type="password" name="passwd" class="form-control" id="passwd">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="passwdr">Heslo znovu:</label>
|
||||
<input type="password" name="passwdr" class="form-control" id="passwdr">
|
||||
</div>
|
||||
<div class="captcheck_container"></div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Zavřít</button>
|
||||
<button type="submit" class="btn btn-success" name="submit" value="register">Registrovat</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Neni produkční verze -->
|
||||
<div class="modal fade" id="staticBackdrop" data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="staticBackdropLabel">Upozornění</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="alert alert-danger mb-0" role="alert">
|
||||
Toto není produkční verze!!!
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal">Rozumím</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
7931
-inc/style.css
Normal file
7931
-inc/style.css
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user