new table service

This commit is contained in:
Bruno committed 2026-03-02 11:49:41 +01:00
1 parent 182997b3fb
commit d916632d1b
5 files changed
+180 -1

No files matched your search

+7
View File
@@ -54,6 +54,7 @@ $serviceGroups = array (
array (
0 => 'api_tester',
1 => 'weather_chart',
2 => 'tabellen',
),
),
);
@@ -149,6 +150,12 @@ $services = array (
'active' => true,
'adminOnly' => true,
),
'tabellen' =>
array (
'name' => 'Tabellen',
'active' => true,
'adminOnly' => false,
),
);
$linkGroups = array (
+1 -1
View File
@@ -28,7 +28,7 @@ function db_connect() {
]
];
$enviroment = 'live';
$enviroment = 'vpn';
$conn = new mysqli(
$servers[$enviroment]['hostaddr'],
+67
View File
@@ -1,5 +1,72 @@
<?php
function DatabaseCreateTable($table, $columnsDefinition) {
include_once 'DatabaseConnect.php';
$conn = db_connect();
$sql = "CREATE TABLE IF NOT EXISTS `$table` ($columnsDefinition)";
$stmt = $conn->prepare($sql);
if (!$stmt) {
die("Fehler beim Prepare: " . $conn->error);
}
if (!$stmt->execute()) {
die("Fehler beim Execute: " . $stmt->error);
}
return true;
}
function DatabaseShowTables() {
include_once 'DatabaseConnect.php';
$conn = db_connect();
$tablesResult = $conn->query("SHOW TABLES");
if (!$tablesResult) {
die("Fehler beim Laden der Tabellen: " . $conn->error);
}
$tables = [];
while ($tableRow = $tablesResult->fetch_array()) {
$tables[] = $tableRow[0];
}
return $tables;
}
function DatabaseShowTableStructure($table) {
include_once 'DatabaseConnect.php';
$conn = db_connect();
$stmt = $conn->prepare("SHOW COLUMNS FROM `$table`");
if (!$stmt) {
die("Fehler beim Prepare: " . $conn->error);
}
if (!$stmt->execute()) {
die("Fehler beim Execute: " . $stmt->error);
}
$result = $stmt->get_result();
$columns = [];
while ($column = $result->fetch_assoc()) {
$columns[] = [
"Field" => $column["Field"],
"Type" => $column["Type"],
"Null" => $column["Null"],
"Key" => $column["Key"],
"Default" => $column["Default"],
"Extra" => $column["Extra"]
];
}
return $columns;
}
function DatabaseShow($table, $columns = "*", $where = "", ...$values) {
include_once 'DatabaseConnect.php';
$conn = db_connect();
+57
View File
@@ -0,0 +1,57 @@
<?php
$tables = DatabaseShowTables();
$selectedTable = $_GET['table'] ?? null;
?>
<h2>Datenbank Struktur</h2>
<form method="GET">
<input type="hidden" name="service" value="tabellen">
<label for="table">Tabelle auswählen:</label>
<select name="table" id="table" onchange="this.form.submit()">
<option value="">-- Bitte wählen --</option>
<?php foreach ($tables as $table): ?>
<option value="<?= htmlspecialchars($table) ?>"
<?= ($selectedTable === $table) ? 'selected' : '' ?>>
<?= htmlspecialchars($table) ?>
</option>
<?php endforeach; ?>
</select>
</form>
<?php
if ($selectedTable && in_array($selectedTable, $tables)) {
$structure = DatabaseShowTableStructure($selectedTable);
echo "<h3>Struktur von: " . htmlspecialchars($selectedTable) . "</h3>";
echo "<div class='table-container'>";
echo "<table class='db-table'>";
echo "<tr>
<th>Field</th>
<th>Type</th>
<th>Null</th>
<th>Key</th>
<th>Default</th>
<th>Extra</th>
</tr>";
foreach ($structure as $column) {
echo "<tr>";
echo "<td>" . htmlspecialchars($column['Field']) . "</td>";
echo "<td>" . htmlspecialchars($column['Type']) . "</td>";
echo "<td>" . htmlspecialchars($column['Null']) . "</td>";
echo "<td>" . htmlspecialchars($column['Key']) . "</td>";
echo "<td>" . htmlspecialchars($column['Default']) . "</td>";
echo "<td>" . htmlspecialchars($column['Extra']) . "</td>";
echo "</tr>";
}
echo "</table>";
echo "</div>";
}
?>
+48
View File
@@ -954,4 +954,52 @@ body.dark-mode .info-key {
body.dark-mode .info-value {
color: #ccc;
}
/* ===== Datenbank Struktur Tabelle ===== */
.db-table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
table-layout: fixed; /* sorgt für feste Spaltenbreite */
}
.db-table thead {
background-color: var(--btn-bg);
color: var(--btn-text);
}
.db-table th,
.db-table td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid var(--card-border);
/* Wichtig für gleiche Größe */
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.db-table tr:hover {
background-color: rgba(0, 123, 255, 0.08);
}
/* Alternierende Zeilen */
.db-table tr:nth-child(even) {
background-color: var(--card-bg);
}
/* Dark Mode */
body.dark-mode .db-table thead {
background-color: #0056b3;
}
body.dark-mode .db-table tr:hover {
background-color: rgba(0, 123, 255, 0.15);
}
body.dark-mode .db-table tr:nth-child(even) {
background-color: #1e1e1e;
}