diff --git a/app/public/add_entry.php b/app/public/add_entry.php index ab71ca8..176c395 100644 --- a/app/public/add_entry.php +++ b/app/public/add_entry.php @@ -20,7 +20,7 @@ die; } - echo file_get_contents("heder_footer/header.php"); + include("header_footer/header.php"); ?> diff --git a/app/public/add_station.php b/app/public/add_station.php index 6aff5df..a5b9fc2 100644 --- a/app/public/add_station.php +++ b/app/public/add_station.php @@ -10,7 +10,7 @@ die; } - echo file_get_contents("header_footer/header.php"); + include("header_footer/header.php"); ?> diff --git a/app/public/add_team.php b/app/public/add_team.php index 02f6460..dd5628f 100644 --- a/app/public/add_team.php +++ b/app/public/add_team.php @@ -10,7 +10,7 @@ die; } - echo file_get_contents("header_footer/header.php"); + include("header_footer/header.php"); ?> diff --git a/app/public/add_user.php b/app/public/add_user.php new file mode 100644 index 0000000..f78e02a --- /dev/null +++ b/app/public/add_user.php @@ -0,0 +1,60 @@ + + + +
+

Benutzer hinzufügen

+
+
+
+ +
+ +
+ +
+ + +
+ +
+
+ + + \ No newline at end of file diff --git a/app/public/header_footer/header.php b/app/public/header_footer/header.php index 631c05e..0d18442 100644 --- a/app/public/header_footer/header.php +++ b/app/public/header_footer/header.php @@ -19,6 +19,13 @@ Mannschaftsverwaltung Stationen Statistik + Benutzerverwaltung"; + } + } + ?> \ No newline at end of file diff --git a/app/public/index.php b/app/public/index.php index 383001f..0e0a75e 100644 --- a/app/public/index.php +++ b/app/public/index.php @@ -5,7 +5,7 @@ $user_data = check_login($con); - echo file_get_contents("header_footer/header.php"); + include("header_footer/header.php"); ?> diff --git a/app/public/manage_user.php b/app/public/manage_user.php new file mode 100644 index 0000000..81a34a5 --- /dev/null +++ b/app/public/manage_user.php @@ -0,0 +1,39 @@ + + + +
+

Benutzerverwaltung

+
+
+
+ +
+
+
+ + + + + + + + + + +
NameBenutzergruppe
+
+ + + \ No newline at end of file diff --git a/app/public/mannschaft.php b/app/public/mannschaft.php index 469008a..a781a92 100644 --- a/app/public/mannschaft.php +++ b/app/public/mannschaft.php @@ -5,7 +5,7 @@ include("../scripts/functions.php"); $user_data = check_login($con); - echo file_get_contents("header_footer/header.php"); + include("header_footer/header.php"); ?> diff --git a/app/public/stationen.php b/app/public/stationen.php index 317e2a1..6616925 100644 --- a/app/public/stationen.php +++ b/app/public/stationen.php @@ -5,7 +5,7 @@ include("../scripts/functions.php"); $user_data = check_login($con); - echo file_get_contents("header_footer/header.php"); + include("header_footer/header.php"); ?> diff --git a/app/public/statistik.php b/app/public/statistik.php index f1fca56..f5b0a18 100644 --- a/app/public/statistik.php +++ b/app/public/statistik.php @@ -15,7 +15,7 @@ $session = $_SESSION['select-statistics']; } - echo file_get_contents("header_footer/header.php"); + include("header_footer/header.php"); ?> @@ -32,7 +32,7 @@
diff --git a/app/scripts/database_queries.php b/app/scripts/database_queries.php index eff71ca..f7cfdf9 100644 --- a/app/scripts/database_queries.php +++ b/app/scripts/database_queries.php @@ -171,6 +171,7 @@ function get_fire_departments($con) { try { $stmt = $con->prepare("SELECT DISTINCT feuerwehr FROM Mannschaft"); $stmt->execute(); + $stmt->setFetchMode(PDO::FETCH_ASSOC); return $stmt; } catch(PDOException $e) { handle_pdo_exception($e); @@ -186,4 +187,30 @@ function write_team($con, $team_name, $fire_department) { } catch(PDOEXCEPTION $e) { handle_pdo_exception($e); } +} + +function get_users($con) { + try { + $stmt = $con->prepare("SELECT user_name, user_group FROM users"); + $stmt->execute(); + $stmt->setFetchMode(PDO::FETCH_ASSOC); + return $stmt; + } catch(PDOException $e) { + handle_pdo_exception($e); + } +} + +function write_user($con, $user_name, $user_id, $phash, $salt, $user_group, $s_id) { + try { + $stmt = $con->prepare("INSERT INTO users (user_id, password, user_name, salt, user_group, s_id) VALUES (?, ?, ?, ?, ?, ?)"); + $stmt->bindParam(1, $user_id, PDO::PARAM_STR); + $stmt->bindParam(2, $phash, PDO::PARAM_STR); + $stmt->bindParam(3, $user_name, PDO::PARAM_STR); + $stmt->bindParam(4, $salt, PDO::PARAM_STR); + $stmt->bindParam(5, $user_group, PDO::PARAM_STR); + $stmt->bindParam(6, $s_id, PDO::PARAM_INT); + $stmt->execute(); + } catch(PDOException $e) { + handle_pdo_exception($e); + } } \ No newline at end of file diff --git a/app/scripts/functions.php b/app/scripts/functions.php index c064337..2c0da52 100644 --- a/app/scripts/functions.php +++ b/app/scripts/functions.php @@ -72,14 +72,16 @@ function load_total_score($con) { echo "\n"; } -function load_options_stations($con, $session) { +function load_options_stations($con, $session, $stats) { $stmt = get_stations_all($con); if ($session == "total-score"){ $total_score_selected = " selected"; } else { $total_score_selected = ""; } - echo ""; + if($stats) { + echo ""; + } foreach($stmt->fetchAll() as $option) { if($session == $option['s_id']){ $station_selected = " selected"; @@ -124,4 +126,26 @@ function load_fire_departments($con) { foreach($stmt->fetchAll() as $option) { echo "\n"; } +} + +function check_admin($con) { + $user_data = check_login($con); + if($user_data['user_group'] == "admin") { + return $user_data; + } else { + unset($_SESSION['user_id']); + unset($_SESSION['user_group']); + header("Location: login.php"); + die; + } +} + +function load_users($con) { + $stmt = get_users($con); + foreach($stmt->fetchAll() as $row) { + echo "\n"; + echo "" . $row['user_name'] . "\n"; + echo "" . $row['user_group'] . "\n"; + echo "\n"; + } } \ No newline at end of file