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