diff --git a/.gitignore b/.gitignore index 670fb59..524ab40 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -*.db -WEBROOT/sitemap.xml -WEBROOT/sitemap.xml +*.db +WEBROOT/sitemap.xml +WEBROOT/sitemap.xml diff --git a/WEBROOT/controller/DataController.php b/WEBROOT/controller/DataController.php index fa7a151..d87f75a 100644 --- a/WEBROOT/controller/DataController.php +++ b/WEBROOT/controller/DataController.php @@ -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) { diff --git a/WEBROOT/controller/DatabaseConnect.php b/WEBROOT/controller/DatabaseConnect.php index 40c3150..b247e28 100644 --- a/WEBROOT/controller/DatabaseConnect.php +++ b/WEBROOT/controller/DatabaseConnect.php @@ -1,7 +1,7 @@ '10.233.1.244', diff --git a/WEBROOT/controller/DatabaseController.php b/WEBROOT/controller/DatabaseController.php index faac626..6f19ae5 100644 --- a/WEBROOT/controller/DatabaseController.php +++ b/WEBROOT/controller/DatabaseController.php @@ -1,115 +1,115 @@ -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 - * ); +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 + * ); */ \ No newline at end of file diff --git a/WEBROOT/index.php b/WEBROOT/index.php index 4cfe526..9c73134 100644 --- a/WEBROOT/index.php +++ b/WEBROOT/index.php @@ -1,31 +1,31 @@ -getClientIP(); -$whitelist = $data->getWhitelistedIPs(); - -if (in_array($clientIP, $whitelist)) { - - $cookie->SetCookie("USER", "1", 60); - - print_r($data->ShowAllData()); - echo 'Main Dashboard'; - -} else { - - $cookie->SetCookie("USER", "0", 60); - - header("Location: /controller/RoutesController.php?website=/services/Dashboards/MainDashboard.php"); - exit; -} - -$allData = (new getSpecificData())->getAllData(); -ConsoleLog($allData); +getClientIP(); +$whitelist = $data->getWhitelistedIPs(); + +if (in_array($clientIP, $whitelist)) { + + $cookie->SetCookie("USER", "1", 60); + + print_r($data->ShowAllData()); + echo 'Main Dashboard'; + +} else { + + $cookie->SetCookie("USER", "0", 60); + + header("Location: /controller/RoutesController.php?website=/services/Dashboards/MainDashboard.php"); + exit; +} + +$allData = (new getSpecificData())->getAllData(); +ConsoleLog($allData); logging(); \ No newline at end of file diff --git a/WEBROOT/services/overtime_corrections.json b/WEBROOT/services/overtime_corrections.json index a3ce3d9..039925a 100644 --- a/WEBROOT/services/overtime_corrections.json +++ b/WEBROOT/services/overtime_corrections.json @@ -1,5 +1,5 @@ -{ - "plus": 0, - "minus": 960, - "total": -960 -} +{ + "plus": 0, + "minus": 960, + "total": -960 +} diff --git a/WEBROOT/services/test.php b/WEBROOT/services/test.php index 04ca329..17093fc 100644 --- a/WEBROOT/services/test.php +++ b/WEBROOT/services/test.php @@ -1,47 +1,47 @@ -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 '
'; - print_r($data); - echo ''; -} else { - header("Location: /controller/RoutesController.php?website=/static/access_denied.php"); +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 '
'; + print_r($data); + echo ''; +} else { + header("Location: /controller/RoutesController.php?website=/static/access_denied.php"); } \ No newline at end of file