Compare commits

...

11 Commits

Author SHA1 Message Date
Grisu
484cf11c07 added pass mark 2022-12-05 12:44:39 +01:00
Grisu
2e77ac243b added compression for download and ensure utf-8 encoding 2022-12-04 23:04:29 +01:00
42d3f01176 Merge pull request 'added csv download' (#9) from dev into main
Reviewed-on: #9
2022-12-04 21:49:55 +00:00
Grisu
c4d62ac658 added csv download 2022-12-04 22:34:01 +01:00
Grisu
c1ffddfdb2 as admin you now can't delete your own account 2022-09-22 18:09:50 +02:00
dc4d28cd91 Merge pull request 'dev' (#4) from dev into main
Reviewed-on: #4
2022-09-22 15:42:36 +00:00
Grisu
3598769c04 added warning when wrong password is entered 2022-09-22 17:38:02 +02:00
Grisu
cfc9c96a17 updated database schema 2022-09-22 14:19:38 +02:00
Grisu
bb118e169e fixed typo 2022-09-18 21:12:35 +02:00
458e0cbad9 Merge pull request 'changed the total score to a station ranking on the homepage' (#3) from dev into main
Reviewed-on: #3
2022-09-18 17:34:05 +00:00
ca6549280f Merge pull request 'Adding close button to the edit and add pages' (#2) from dev into main
Reviewed-on: #2
2022-09-18 17:11:41 +00:00
11 changed files with 133 additions and 13 deletions

View File

@@ -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">

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -6,8 +6,11 @@
if($_SERVER['REQUEST_METHOD'] == "POST") {
try {
$stmt = $con->prepare("DELETE FROM users WHERE id = :id");
$stmt->execute(['id' => $_POST['id']]);
$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);
}

View 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);
}
?>

View File

@@ -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">

View File

@@ -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>

View File

@@ -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">

View File

@@ -529,4 +529,16 @@ function get_result_team_station($con, $s_id, $m_id) {
} catch( PDOException $e) {
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);
}
}

View File

@@ -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);
}
}

View File

@@ -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