Initial Commit

This commit is contained in:
„Lupus
2026-01-31 17:26:25 +00:00
commit 6be71e29f7
54 changed files with 66318 additions and 0 deletions

96
statistics/foody.css Normal file
View File

@@ -0,0 +1,96 @@
.main-nav {
display: flex;
background: #bee817;
color: white;
border-radius: 3px;
padding: 1em;
font-family: sans-serif;
}
.main-nav > ul {
list-style-type: none;
padding: 0;
margin: 0;
display: flex;
flex: 3;
}
.main-nav li {
margin-right: 1em;
}
.main-nav > form {
display: flex;
justify-content: flex-end;
flex: 1;
}
.main-nav input {
flex: 1;
}
.main-nav button {
background: white;
border: 0;
border-radius: 1em;
color: orangered;
padding: 0 1em;
margin-left: 0.3em;
}
.button {
background-color: #bee817;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 15px;
margin: 4px 2px;
cursor: pointer;
border-radius: 12px;
}
@media screen and (max-width: 575px) {
.main-nav {
flex-direction: column;
}
.main-nav ul {
flex-direction: row; /* Change this to 'column' to stack the links */
margin-bottom: 1em;
}
}
.item1 {
grid-area: header;
}
.item2 {
grid-area: main;
}
.item3 {
grid-area: footer;
}
.grid-container {
display: grid;
grid-template-areas:
"header header header header header header"
"main main main main main main"
"footer footer footer footer footer footer";
gap: 1px;
background-color: #bee817;
padding: 10px;
}
.grid-container > div {
background-color: rgba(255, 255, 255, 0.8);
text-align: center;
padding: 20px 0;
font-size: 20px;
}
table {
width: 100%;
border: 1px solid black;
border-collapse: collapse;
}
th,
td {
border: 1px solid black;
border-collapse: collapse;
text-align: center;
}

199
statistics/index.php Normal file
View File

@@ -0,0 +1,199 @@
<?php
session_start();
if (isset($_SESSION['id']) && isset($_SESSION['user_name'])) {
?>
<?php
// Below is optional, remove if you have already connected to your database.
include_once "../src/PHP/connection3.php";
if ($result = $mysqli->query('SELECT * FROM foody_main')) { ?>
<!DOCTYPE html>
<html>
<head>
<title>Foody-Infos</title>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="foody.css" />
</head>
<body>
<div class="grid-container">
<div class="item1">
<nav class="main-nav">
<ul>
<li><a href="../home.php">Kalender</a></li>
<li><a href="./meallist.php">Essenübersicht</a></li>
</ul>
<form>
<input type="search" placeholder="Search" />
<button>Go</button>
</form>
</nav>
</div>
<div class="item2">
<table>
<tbody>
<tr>
<td>&nbsp;</td>
<td>&lt;Last&gt;</td>
<td>&nbsp;</td>
<td colspan="2">
Juni 2022
</td>
<td>&nbsp;</td>
<td>&lt;Next&gt;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>KW</td>
<td>Montag&nbsp;</td>
<td>Dienstag</td>
<td>Mittwoch</td>
<td>Donnerstag</td>
<td>Freitag</td>
<td>Samstrag</td>
<td>Sonntag</td>
</tr>
<tr>
<td rowspan="2">22</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td rowspan="2">23</td>
<td>&nbsp;6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td rowspan="2">24</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td rowspan="2">25</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td>25</td>
<td>26</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td rowspan="2">26</td>
<td>27</td>
<td>28</td>
<td>29</td>
<td>30</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
</div>
<div class="item3">Footer</div>
</div>
</body>
<script>
// Funktion zum Logout nach einer bestimmten Zeit
function delayedLogout() {
// Setze den Timeout auf 5 Minuten (300000 Millisekunden)
var timeout = 300000; // 5 Minuten in Millisekunden
// Timeout-Funktion zum Ausführen des Logouts
var logoutTimeout;
function startLogoutTimer() {
logoutTimeout = setTimeout(logout, timeout);
}
function resetLogoutTimer() {
clearTimeout(logoutTimeout); // Timer zurücksetzen
startLogoutTimer(); // Timer neu starten
}
function logout() {
// Weiterleitung auf die logout.php-Seite
window.location.href = "../logout.php";
}
// Starte den Timer beim Laden der Seite
startLogoutTimer();
// Reagiere auf Benutzerinteraktionen
document.addEventListener("click", resetLogoutTimer);
//document.addEventListener("mousemove", resetLogoutTimer);
document.addEventListener("keypress", resetLogoutTimer);
}
// Starte den Timer beim Laden der Seite
window.onload = delayedLogout;
</script>
</html>
<?php $result->free();} ?>
<?php
} else {
header("Location: ../index.php");
exit();
}
?>

180
statistics/meallist.php Normal file
View File

@@ -0,0 +1,180 @@
<?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors', 'On');
if (isset($_SESSION['id']) && isset($_SESSION['user_name'])) {
?>
<?php
// Below is optional, remove if you have already connected to your database.
include_once "../src/PHP/connection3.php";
// For extra protection these are the columns of which the user can sort by (in your database table).
$columns = [
'mealname',
'mealadditive',
'mealsupplement1',
'mealsupplement2',
'mealsupplement3',
];
// Only get the column if it exists in the above columns array, if it doesn't exist the database table will be sorted by the first item in the columns array.
$column =
isset($_GET['column']) && in_array($_GET['column'], $columns)
? $_GET['column']
: $columns[0];
// Get the sort order for the column, ascending or descending, default is ascending.
$sort_order =
isset($_GET['order']) && strtolower($_GET['order']) == 'desc'
? 'DESC'
: 'ASC';
// Get the result...
if (
$result = $mysqli->query(
'SELECT COUNT(*) AS anzahl, mealname, mealadditive, mealsupplement1, mealsupplement2, mealsupplement3, mealdate FROM foody_main GROUP BY ' .
$column .
' ORDER BY ' .
$column . ' ' .
$sort_order
/* 'SELECT COUNT(*) AS anzahl, mealname, mealadditive, mealsupplement1, mealsupplement2, mealsupplement3, mealdate FROM foody_main GROUP BY ' .
$column .
' ' .
$sort_order*/
)
) {
// Some variables we need for the table.
$up_or_down = str_replace(['ASC', 'DESC'], ['up', 'down'], $sort_order);
$asc_or_desc = $sort_order == 'ASC' ? 'desc' : 'asc';
$add_class = ' class="highlight"';
?>
<!DOCTYPE html>
<html>
<head>
<title>Foody-Infos</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Example</title>
<link rel="stylesheet" type="text/css" href="foody.css" />
</head>
<body>
<div class="grid-container">
<div class="item1">
<nav class="main-nav">
<ul>
<li><a href="../home.php">Kalender</a></li>
<li><a href="meallist.php">Essenübersicht</a></li>
</ul>
<form>
<input type="search" placeholder="Search" />
<button>Go</button>
</form>
</nav>
</div>
<div class="item2">
<table id="foody_main" cellspacing="1">
<thead>
<tr>
<th><button class="button" id="button_anzahl"><a href="meallist.php?column=anzahl&order=<?php echo $asc_or_desc; ?>">Häufigkeit<i class="fas fa-sort<?php echo $column ==
'anzahl'
? '-' . $up_or_down
: ''; ?>"></i></a></button></th>
<th><button class="button"><a href="meallist.php?column=mealname&order=<?php echo $asc_or_desc; ?>">Essen<i class="fas fa-sort<?php echo $column ==
'mealname'
? '-' . $up_or_down
: ''; ?>"></i></a></button></th>
<th><button class="button"><a href="meallist.php?column=mealadditive&order=<?php echo $asc_or_desc; ?>">Gerichtzusatz<i class="fas fa-sort<?php echo $column ==
'mealadditive'
? '-' . $up_or_down
: ''; ?>"></i></a></button></th>
<th><button class="button"><a href="meallist.php?column=mealsupplement1&order=<?php echo $asc_or_desc; ?>">Beilage-1<i class="fas fa-sort<?php echo $column ==
'mealsupplement1'
? '-' . $up_or_down
: ''; ?>"></i></a></button></th>
<th><button class="button"><a href="meallist.php?column=mealsupplement2&order=<?php echo $asc_or_desc; ?>">Beilage-2<i class="fas fa-sort<?php echo $column ==
'mealsupplement2'
? '-' . $up_or_down
: ''; ?>"></i></a></button></th>
<th><button class="button"><a href="meallist.php?column=mealsupplement3&order=<?php echo $asc_or_desc; ?>">Beilage-3<i class="fas fa-sort<?php echo $column ==
'mealsupplement3'
? '-' . $up_or_down
: ''; ?>"></i></a></button></th>
</tr>
</thead>
<tbody>
<?php while ($row = $result->fetch_assoc()): ?>
<tr>
<td<?php echo $column == 'anzahl'
? $add_class
: ''; ?>><?php echo $row['anzahl']; ?></td>
<td<?php echo $column == 'mealname'
? $add_class
: ''; ?>><?php echo $row['mealname']; ?></td>
<td<?php echo $column == 'mealadditive'
? $add_class
: ''; ?>><?php echo $row['mealadditive']; ?></td>
<td<?php echo $column == 'mealsupplement1'
? $add_class
: ''; ?>><?php echo $row['mealsupplement1']; ?></td>
<td<?php echo $column == 'mealsupplement2'
? $add_class
: ''; ?>><?php echo $row['mealsupplement2']; ?></td>
<td<?php echo $column == 'mealsupplement3'
? $add_class
: ''; ?>><?php echo $row['mealsupplement3']; ?></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
<div class="item3">Footer</div>
</div>
</body>
<script>
// Funktion zum Logout nach einer bestimmten Zeit
function delayedLogout() {
// Setze den Timeout auf 5 Minuten (300000 Millisekunden)
var timeout = 300000; // 5 Minuten in Millisekunden
// Timeout-Funktion zum Ausführen des Logouts
var logoutTimeout;
function startLogoutTimer() {
logoutTimeout = setTimeout(logout, timeout);
}
function resetLogoutTimer() {
clearTimeout(logoutTimeout); // Timer zurücksetzen
startLogoutTimer(); // Timer neu starten
}
function logout() {
// Weiterleitung auf die logout.php-Seite
window.location.href = "logout.php";
}
// Starte den Timer beim Laden der Seite
startLogoutTimer();
// Reagiere auf Benutzerinteraktionen
document.addEventListener("click", resetLogoutTimer);
//document.addEventListener("mousemove", resetLogoutTimer);
document.addEventListener("keypress", resetLogoutTimer);
}
// Starte den Timer beim Laden der Seite
window.onload = delayedLogout;
</script>
</html>
<?php $result->free();
}
?>
<?php
} else {
header("Location: ../index.php");
exit();
}
?>