Compare commits
11 Commits
e62be84d35
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
484cf11c07 | ||
|
|
2e77ac243b | ||
| 42d3f01176 | |||
|
|
c4d62ac658 | ||
|
|
c1ffddfdb2 | ||
| dc4d28cd91 | |||
|
|
3598769c04 | ||
|
|
cfc9c96a17 | ||
|
|
bb118e169e | ||
| 458e0cbad9 | |||
| ca6549280f |
@@ -49,7 +49,7 @@
|
||||
<body>
|
||||
<div class="center">
|
||||
<div class="headline">
|
||||
<h2>Ergebniss eintragen</h2>
|
||||
<h2>Ergebnis eintragen</h2>
|
||||
</div>
|
||||
<div class="form_div">
|
||||
<form action="" method="post">
|
||||
|
||||
@@ -101,3 +101,12 @@ input[type="submit"]:hover{
|
||||
border-color: #2691d9;
|
||||
transition: .5s;
|
||||
}
|
||||
|
||||
.warnings {
|
||||
outline: none;
|
||||
margin-top: 0px;
|
||||
margin-bottom: 10px;
|
||||
background-color: #ff8080;
|
||||
border-radius: 4px;
|
||||
padding: 4px;
|
||||
}
|
||||
@@ -217,6 +217,14 @@ div.headline h2{
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
#icon-download {
|
||||
position:absolute;
|
||||
top: 6px;
|
||||
left: 5px;
|
||||
pointer-events: none;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.input-table{
|
||||
padding-left: 2px;
|
||||
padding-right: 2px;
|
||||
|
||||
@@ -6,8 +6,11 @@
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
try {
|
||||
$selected_user_id = get_id_user_by_user_id($con, $_SESSION['user_id']);
|
||||
if($selected_user_id != $_POST['id']) {
|
||||
$stmt = $con->prepare("DELETE FROM users WHERE id = :id");
|
||||
$stmt->execute(['id' => $_POST['id']]);
|
||||
}
|
||||
} catch(PDOException $e) {
|
||||
handle_pdo_exception($e);
|
||||
}
|
||||
|
||||
36
app/public/download_table.php
Normal file
36
app/public/download_table.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
include("../scripts/connection.php");
|
||||
include("../scripts/functions.php");
|
||||
$user_data = check_admin($con);
|
||||
|
||||
if(isset($_GET['table'])) {
|
||||
$table = $_GET['table'];
|
||||
}
|
||||
|
||||
ob_start('ob_gzhandler'); #compressing data which is sent to the browser, the browser will decompress the data automatically
|
||||
header('Content-type: text/csv; charset="UTF-8" ');
|
||||
header('Content-Disposition: attachment; filename="table.csv" ');
|
||||
|
||||
function download_table($stmt) {
|
||||
$output = fopen('php://output', 'w');
|
||||
$header = true;
|
||||
while ($row = $stmt->fetch()) {
|
||||
if ($header) {
|
||||
fputcsv($output, array_keys($row));
|
||||
$header = false;
|
||||
}
|
||||
fputcsv($output, $row);
|
||||
}
|
||||
fclose($output);
|
||||
}
|
||||
|
||||
if($table == "total-score") {
|
||||
$total_score = get_total_score($con);
|
||||
download_table($total_score);
|
||||
} else {
|
||||
$station = get_station($con, $table);
|
||||
download_table($station);
|
||||
}
|
||||
?>
|
||||
@@ -49,7 +49,7 @@
|
||||
<body>
|
||||
<div class="center">
|
||||
<div class="headline">
|
||||
<h2>Ergebniss bearbeiten</h2>
|
||||
<h2>Ergebnis bearbeiten</h2>
|
||||
</div>
|
||||
<div class="form_div">
|
||||
<form method="post">
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
session_start();
|
||||
include("../scripts/connection.php");
|
||||
include("../scripts/functions.php");
|
||||
$password_wrong = false;
|
||||
$wrong_data = false;
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] == "POST"){
|
||||
$user_name = sanitize_input($_POST['user_name']);
|
||||
@@ -21,14 +23,14 @@
|
||||
}
|
||||
die;
|
||||
} else {
|
||||
echo "Benutzername oder Passwort stimmen nicht";
|
||||
$password_wrong = true;
|
||||
}
|
||||
} else {
|
||||
echo "Benutzername oder Passwort stimmen nicht";
|
||||
$password_wrong = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
echo "Gib bitte gültige Daten ein!";
|
||||
$wrong_data = true;
|
||||
}
|
||||
}
|
||||
$con = null;
|
||||
@@ -57,6 +59,21 @@
|
||||
<span></span>
|
||||
<label>Passwort</label>
|
||||
</div>
|
||||
<?php
|
||||
if ($password_wrong == true) {
|
||||
echo "
|
||||
<div class=\"warnings\" id=\"wrong_user_name\">
|
||||
<label for=\"warnings\">Benutzername oder <br>Passwort stimmen nicht!</label>
|
||||
</div>";
|
||||
}
|
||||
|
||||
if ($wrong_data == true) {
|
||||
echo "
|
||||
<div class=\"warnings\" id=\"wrong_data\">
|
||||
<label for=\"warnings\">Gib bitte gültige Daten ein!</label>
|
||||
</div>";
|
||||
}
|
||||
?>
|
||||
<input class="button" id="button" type="submit" value="Login"><br><br>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -74,6 +74,16 @@
|
||||
</form>
|
||||
</div>\n";
|
||||
}
|
||||
|
||||
if($user_data['user_group'] == 'admin') {
|
||||
echo "<div class=\"btn-div\">
|
||||
<form action=\"download_table.php\" method=\"get\">
|
||||
<span class=\"gg-software-download icon\" id=\"icon-download\"></span>
|
||||
<input type=\"hidden\" name=\"table\" value=\"$session\">
|
||||
<input type=\"submit\" value=\"\">
|
||||
</form>
|
||||
</div>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="table-div">
|
||||
|
||||
@@ -530,3 +530,15 @@ function get_result_team_station($con, $s_id, $m_id) {
|
||||
handle_pdo_exception($e);
|
||||
}
|
||||
}
|
||||
|
||||
function get_id_user_by_user_id($con, $user_id) {
|
||||
try {
|
||||
$stmt = $con->prepare("SELECT * FROM users WHERE user_id = ?");
|
||||
$stmt->bindParam(1, $user_id, PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
$stmt->setFetchMode(PDO::FETCH_ASSOC);
|
||||
return $stmt->fetch()['id'];
|
||||
} catch( PDOException $e) {
|
||||
handle_pdo_exception($e);
|
||||
}
|
||||
}
|
||||
@@ -235,6 +235,9 @@ function update_points($con, $s_id) {
|
||||
$factor = $results[0]['erg']/ 15.0;
|
||||
foreach($results as $row) {
|
||||
$points = round($row['erg']/$factor);
|
||||
if ($points == 0 && $row['erg'] != 0) {
|
||||
$points = 1;
|
||||
}
|
||||
change_points($con, $row['m_id'], $s_id, $points);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
-- MariaDB dump 10.19 Distrib 10.8.3-MariaDB, for Linux (x86_64)
|
||||
-- MariaDB dump 10.19 Distrib 10.9.2-MariaDB, for Linux (x86_64)
|
||||
--
|
||||
-- Host: localhost Database: ksp
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 10.7.3-MariaDB-1:10.7.3+maria~focal
|
||||
-- Server version 10.9.2-MariaDB-1:10.9.2+maria~ubu2204
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
@@ -15,6 +15,26 @@
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
--
|
||||
-- Table structure for table `Ergebnisse`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `Ergebnisse`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `Ergebnisse` (
|
||||
`erg_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`s_id` tinyint(3) unsigned DEFAULT NULL,
|
||||
`m_id` tinyint(3) unsigned DEFAULT NULL,
|
||||
`erg` smallint(5) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (`erg_id`),
|
||||
KEY `s_id` (`s_id`),
|
||||
KEY `m_id` (`m_id`),
|
||||
CONSTRAINT `Ergebnisse_ibfk_1` FOREIGN KEY (`s_id`) REFERENCES `Station` (`s_id`),
|
||||
CONSTRAINT `Ergebnisse_ibfk_2` FOREIGN KEY (`m_id`) REFERENCES `Mannschaft` (`m_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `Mannschaft`
|
||||
--
|
||||
@@ -27,7 +47,7 @@ CREATE TABLE `Mannschaft` (
|
||||
`name` tinytext DEFAULT NULL,
|
||||
`feuerwehr` tinytext DEFAULT NULL,
|
||||
PRIMARY KEY (`m_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
@@ -60,8 +80,10 @@ CREATE TABLE `Station` (
|
||||
`s_id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` tinytext DEFAULT NULL,
|
||||
`standort` text DEFAULT NULL,
|
||||
`gewertet` tinyint(1) DEFAULT 1,
|
||||
`direkte_punkte` tinyint(1) DEFAULT 1,
|
||||
PRIMARY KEY (`s_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
@@ -85,7 +107,7 @@ CREATE TABLE `users` (
|
||||
UNIQUE KEY `user_name` (`user_name`),
|
||||
KEY `s_id` (`s_id`),
|
||||
CONSTRAINT `users_ibfk_1` FOREIGN KEY (`s_id`) REFERENCES `Station` (`s_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
@@ -97,4 +119,4 @@ CREATE TABLE `users` (
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2022-06-19 22:58:36
|
||||
-- Dump completed on 2022-09-22 14:19:05
|
||||
|
||||
Reference in New Issue
Block a user