fix: Controller update mit CRUD

This commit is contained in:
hydrax committed 2026-01-05 10:13:57 +01:00
1 parent 57503b2c6d
commit d573146f84
7 files changed
+208 -208

No files matched your search

+3 -3
View File
@@ -1,3 +1,3 @@
*.db
WEBROOT/sitemap.xml
WEBROOT/sitemap.xml
*.db
WEBROOT/sitemap.xml
WEBROOT/sitemap.xml
+9 -9
View File
@@ -88,17 +88,17 @@ class getSpecificData {
}
function getWhitelistedIPs() {
$conn = db_connect();
$ips="SELECT `IP-ADDRESSE` FROM Whitelisted";
$results = $conn->query($ips);
include_once 'DatabaseController.php';
$data = DatabaseShow(
"Whitelisted",
"`IP-ADDRESSE`"
);
$WhitelistedIPs = [];
if ($results && $results->num_rows > 0) {
while ($row = $results->fetch_assoc()) {
$WhitelistedIPs[] = $row['IP-ADDRESSE'];
}
$results = [];
foreach ($data as $row) {
$results[] =$row['IP-ADDRESSE'];
}
return $WhitelistedIPs;
return $results;
}
function getServerNode($ServerIP) {
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
function db_connect() {
$local = false;
$local = true;
$servers = [
'remote' => '10.233.1.244',
+114 -114
View File
@@ -1,115 +1,115 @@
<?php
function DatabaseShow($table, $columns = "*", $where = "", ...$values) {
include_once 'DatabaseConnect.php';
$conn = db_connect();
$sql = "SELECT $columns FROM `$table`";
if (!empty($where)) {
$sql .= " WHERE $where";
}
$stmt = $conn->prepare($sql);
if (!$stmt) {
die("Fehler beim Prepare: " . $conn->error);
}
if (!$stmt->execute($values)) {
die("Fehler beim Execute: " . $stmt->error);
}
$result = $stmt->get_result();
return $result->fetch_all(MYSQLI_ASSOC);
}
function DatabaseInsert($table, $columns, ...$values) {
include_once 'DatabaseConnect.php';
$conn = db_connect();
$placeholders = rtrim(str_repeat("?,", count($values)), ",");
$sql = "INSERT INTO `$table` ($columns) VALUES ($placeholders)";
$stmt = $conn->prepare($sql);
if (!$stmt) {
die("Fehler beim Prepare: " . $conn->error);
}
if (!$stmt->execute($values)) {
die("Fehler beim Execute: " . $stmt->error);
}
return true;
}
function DatabaseDelete($table, $where, ...$values) {
include_once 'DatabaseConnect.php';
$conn = db_connect();
$sql = "DELETE FROM `$table` WHERE $where";
$stmt = $conn->prepare($sql);
if (!$stmt) {
die("Fehler beim Prepare: " . $conn->error);
}
if (!$stmt->execute($values)) {
die("Fehler beim Execute: " . $stmt->error);
}
return true;
}
function DatabaseUpdate($table, $set, $where, ...$values) {
include_once 'DatabaseConnect.php';
$conn = db_connect();
$sql = "UPDATE `$table` SET $set WHERE $where";
$stmt = $conn->prepare($sql);
if (!$stmt) {
die("Fehler beim Prepare: " . $conn->error);
}
if (!$stmt->execute($values)) {
die("Fehler beim Execute: " . $stmt->error);
}
return true;
}
/**
* Use Cases:
*
* DatabaseShow(
* "tabelle",
* "spaltenname1, spaltenname2, spaltenname3"
* );
*
* DatabaseShow("tabelle");
*
* DatabaseInsert(
* "tabelle",
* "spaltenname1, spaltenname2, spaltenname3",
* $var1,
* $var2,
* $var3
* );
*
* DatabaseDelete(
* "tabelle",
* "spalte = ?",
* $var1 // wert für spalte
* );
*
* DatabaseUpdate(
* "tabelle",
* "username = ?, email = ?",
* "id = ?",
* "NeuerName",
* "neu@mail.de",
* $var1 // wert für id
* );
<?php
function DatabaseShow($table, $columns = "*", $where = "", ...$values) {
include_once 'DatabaseConnect.php';
$conn = db_connect();
$sql = "SELECT $columns FROM `$table`";
if (!empty($where)) {
$sql .= " WHERE $where";
}
$stmt = $conn->prepare($sql);
if (!$stmt) {
die("Fehler beim Prepare: " . $conn->error);
}
if (!$stmt->execute($values)) {
die("Fehler beim Execute: " . $stmt->error);
}
$result = $stmt->get_result();
return $result->fetch_all(MYSQLI_ASSOC);
}
function DatabaseInsert($table, $columns, ...$values) {
include_once 'DatabaseConnect.php';
$conn = db_connect();
$placeholders = rtrim(str_repeat("?,", count($values)), ",");
$sql = "INSERT INTO `$table` ($columns) VALUES ($placeholders)";
$stmt = $conn->prepare($sql);
if (!$stmt) {
die("Fehler beim Prepare: " . $conn->error);
}
if (!$stmt->execute($values)) {
die("Fehler beim Execute: " . $stmt->error);
}
return true;
}
function DatabaseDelete($table, $where, ...$values) {
include_once 'DatabaseConnect.php';
$conn = db_connect();
$sql = "DELETE FROM `$table` WHERE $where";
$stmt = $conn->prepare($sql);
if (!$stmt) {
die("Fehler beim Prepare: " . $conn->error);
}
if (!$stmt->execute($values)) {
die("Fehler beim Execute: " . $stmt->error);
}
return true;
}
function DatabaseUpdate($table, $set, $where, ...$values) {
include_once 'DatabaseConnect.php';
$conn = db_connect();
$sql = "UPDATE `$table` SET $set WHERE $where";
$stmt = $conn->prepare($sql);
if (!$stmt) {
die("Fehler beim Prepare: " . $conn->error);
}
if (!$stmt->execute($values)) {
die("Fehler beim Execute: " . $stmt->error);
}
return true;
}
/**
* Use Cases:
*
* DatabaseShow(
* "tabelle",
* "spaltenname1, spaltenname2, spaltenname3"
* );
*
* DatabaseShow("tabelle");
*
* DatabaseInsert(
* "tabelle",
* "spaltenname1, spaltenname2, spaltenname3",
* $var1,
* $var2,
* $var3
* );
*
* DatabaseDelete(
* "tabelle",
* "spalte = ?",
* $var1 // wert für spalte
* );
*
* DatabaseUpdate(
* "tabelle",
* "username = ?, email = ?",
* "id = ?",
* "NeuerName",
* "neu@mail.de",
* $var1 // wert für id
* );
*/
+30 -30
View File
@@ -1,31 +1,31 @@
<?php
include_once 'controller/CookieController.php';
include_once 'controller/LogController.php';
include_once 'controller/DataController.php';
include_once 'controller/DatabaseConnect.php';
include_once 'moduls/ConsoleLog.php';
$data = new getSpecificData();
$cookie = new cookieController();
$clientIP = $data->getClientIP();
$whitelist = $data->getWhitelistedIPs();
if (in_array($clientIP, $whitelist)) {
$cookie->SetCookie("USER", "1", 60);
print_r($data->ShowAllData());
echo '<a href="/controller/RoutesController.php?website=/services/Dashboards/MainDashboard.php">Main Dashboard</a>';
} else {
$cookie->SetCookie("USER", "0", 60);
header("Location: /controller/RoutesController.php?website=/services/Dashboards/MainDashboard.php");
exit;
}
$allData = (new getSpecificData())->getAllData();
ConsoleLog($allData);
<?php
include_once 'controller/CookieController.php';
include_once 'controller/LogController.php';
include_once 'controller/DataController.php';
include_once 'controller/DatabaseConnect.php';
include_once 'moduls/ConsoleLog.php';
$data = new getSpecificData();
$cookie = new cookieController();
$clientIP = $data->getClientIP();
$whitelist = $data->getWhitelistedIPs();
if (in_array($clientIP, $whitelist)) {
$cookie->SetCookie("USER", "1", 60);
print_r($data->ShowAllData());
echo '<a href="/controller/RoutesController.php?website=/services/Dashboards/MainDashboard.php">Main Dashboard</a>';
} else {
$cookie->SetCookie("USER", "0", 60);
header("Location: /controller/RoutesController.php?website=/services/Dashboards/MainDashboard.php");
exit;
}
$allData = (new getSpecificData())->getAllData();
ConsoleLog($allData);
logging();
+5 -5
View File
@@ -1,5 +1,5 @@
{
"plus": 0,
"minus": 960,
"total": -960
}
{
"plus": 0,
"minus": 960,
"total": -960
}
+46 -46
View File
@@ -1,47 +1,47 @@
<?php
include_once '../controller/DatabaseController.php';
include_once '../controller/DatabaseConnect.php';
include_once '../controller/DataController.php';
include_once '../moduls/ConsoleLog.php';
$data = new getSpecificData();
$clientIP = $data->getClientIP();
$whitelist = $data->getWhitelistedIPs();
ConsoleLog($whitelist);
if (in_array($clientIP, $whitelist)) {
// DatabaseDelete(
// "Whitelisted",
// "id = ?",
// 5 // wert für spalte
// );
// DatabaseUpdate(
// "Whitelisted",
// "Grund = ?",
// "id = ?",
// "Localhost IP", // wert für Grund
// 3 // wert für id
// );
// DatabaseInsert(
// "Whitelisted",
// "`IP-ADDRESSE`, GRUND, STATUS",
// "80.153.174.251",
// "DEVELOPER",
// "true"
// );
$data = DatabaseShow(
"Whitelisted",
"id, `IP-ADDRESSE`, GRUND, STATUS"
);
echo '<pre>';
print_r($data);
echo '</pre>';
} else {
header("Location: /controller/RoutesController.php?website=/static/access_denied.php");
<?php
include_once '../controller/DatabaseController.php';
include_once '../controller/DatabaseConnect.php';
include_once '../controller/DataController.php';
include_once '../moduls/ConsoleLog.php';
$data = new getSpecificData();
$clientIP = $data->getClientIP();
$whitelist = $data->getWhitelistedIPs();
ConsoleLog($whitelist);
if (in_array($clientIP, $whitelist)) {
// DatabaseDelete(
// "Whitelisted",
// "id = ?",
// 5 // wert für spalte
// );
// DatabaseUpdate(
// "Whitelisted",
// "Grund = ?",
// "id = ?",
// "Localhost IP", // wert für Grund
// 3 // wert für id
// );
// DatabaseInsert(
// "Whitelisted",
// "`IP-ADDRESSE`, GRUND, STATUS",
// "80.153.174.251",
// "DEVELOPER",
// "true"
// );
$data = DatabaseShow(
"Whitelisted",
"id, `IP-ADDRESSE`, GRUND, STATUS"
);
echo '<pre>';
print_r($data);
echo '</pre>';
} else {
header("Location: /controller/RoutesController.php?website=/static/access_denied.php");
}