10 Commits

Author SHA1 Message Date
64b6aa2716 sql funzt 2024-01-18 10:21:52 +01:00
34ae68bfdc zweiter Stand 2024-01-18 10:16:56 +01:00
1f2789eead Tagesplan first Stand 2024-01-18 10:12:14 +01:00
bbb5ebcbac faxxen 2024-01-18 10:02:29 +01:00
e730377103 MyFirstAnmeldeFunktion 2024-01-18 09:31:09 +01:00
add9a27630 Fehlermeldungen 2024-01-17 10:58:49 +01:00
1357e21155 ??? 2024-01-17 10:21:14 +01:00
d4a67f0a30 Merge branch 'Testing' of https://git.bib.de/Subway-Surfers/VPR_Schnittstelle into Testing 2024-01-17 10:21:04 +01:00
2b14563643 nextId 2024-01-15 09:39:19 +01:00
9c82aec3c5 nextId 2024-01-15 08:58:24 +01:00
5 changed files with 161 additions and 65 deletions

View File

@@ -36,6 +36,21 @@ class BenutzerController
return json_encode($data);
}
public function nextId()
{
$result = $this->db->nextId();
return json_encode($result);
}
public function anmeldeVersuch()
{
$result = $this->db->anmeldeVersuch();
return json_encode($result);
}
}
?>

View File

@@ -33,5 +33,11 @@ class TagesplanController
$result = $this->db->deleteTagesplan($id);
return json_encode($result);
}
public function getGerichteOnTag()
{
$result = $this->db->getGerichteOnTag();
return json_encode($result);
}
}
?>

View File

@@ -86,6 +86,7 @@ class BenutzerModel extends Database
$stmt = $pdo->prepare($sql);
$stmt->execute($params);
} catch (\PDOException $e) {
echo "Faulty Sql? " . $sql;
return false;
}
@@ -94,7 +95,54 @@ class BenutzerModel extends Database
return $result;
}
public function nextId()
{
$pdo = $this->linkDB();
$sql = "SELECT `auto_increment` FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'Benutzerkonto'; ";
try {
$stmt = $pdo->prepare($sql);
$stmt->execute();
} catch (\PDOException $e) {
echo "Faulty Sql? " . $sql;
return false;
}
$result = $stmt->fetchALL(\PDO::FETCH_ASSOC);
return $result;
}
public function anmeldeVersuch()
{
$pdo = $this->linkDB();
$params = array();
$params[":Benutzername"] = $_GET["Benutzername"];
$params[":passwort"] = $_GET["passwort"];
$sql = "SELECT * FROM Benutzerkonto WHERE name = :Benutzername AND passwort = :passwort";
try {
$stmt = $pdo->prepare($sql);
$stmt->execute($params);
} catch (\PDOException $e) {
return false;
}
$result = $stmt->fetchALL(\PDO::FETCH_ASSOC);
if (count($result) > 0)
return true;
else
return false;
}
}
?>

View File

@@ -65,5 +65,28 @@ class TagesplanModel extends Database
return false;
}
}
public function getGerichteOnTag()
{
$pdo = $this->linkDB();
$datum = $_GET["datum"];
$sql = "SELECT Gericht.id, Gericht.name, Gericht.preis, Gericht.beschreibung FROM Gericht LEFT JOIN GibtsAm ON Gericht.id = GibtsAm.gid LEFT JOIN Tagesplan ON GibtsAm.tid = Tagesplan.id WHERE Tagesplan.datum = '$datum'";
try {
$stmt = $pdo->prepare($sql);
$stmt->execute();
} catch (\PDOException $e) {
echo $sql . " This do be faulty";
return false;
}
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
return $result;
}
}
?>

View File

@@ -1,4 +1,4 @@
<?php
<?php
/*
Dieses Skript analysiert die URL und generiert daraus die passenden Controller-Aufrufe
@@ -14,72 +14,76 @@
file_get_contents('php://input') die übergebenen json-Strings (für PUT/POST-Requests)
*/
spl_autoload_register(function ($className) {
if (substr($className, 0, 4) !== 'ppb\\') { return; }
$fileName = __DIR__.'/'.str_replace('\\', DIRECTORY_SEPARATOR, substr($className, 4)).'.php';
if (file_exists($fileName)) { include $fileName; }
});
$endpoint = explode('/', trim($_SERVER['PATH_INFO'],'/'));
$data = json_decode(file_get_contents('php://input'), true);
$controllerName = $endpoint[0];
$endpoint2 = isset($endpoint[1]) ? $endpoint[1] : false;
$id = false;
$alias = false;
if ($endpoint2) {
if (preg_match('/^[0-9]+$/', $endpoint2)) {
$id = $endpoint2;
} else {
$alias = $endpoint2;
}
spl_autoload_register(function ($className) {
if (substr($className, 0, 4) !== 'ppb\\') {
return;
}
$controllerClassName = 'ppb\\Controller\\'.ucfirst($controllerName). 'Controller';
if ($_SERVER['REQUEST_METHOD'] == "DELETE") {
$methodName = "delete" . ucfirst($controllerName);
} else if ($_SERVER['REQUEST_METHOD'] == "PUT") {
$methodName = "update" . ucfirst($controllerName);
} else if ($_SERVER['REQUEST_METHOD'] == "POST") {
$methodName = "write" . ucfirst($controllerName);
} else if ($_SERVER['REQUEST_METHOD'] == "GET") {
if ($alias) {
$methodName = $alias;
} else {
$methodName = "get" . ucfirst($controllerName);
}
$fileName = __DIR__ . '/' . str_replace('\\', DIRECTORY_SEPARATOR, substr($className, 4)) . '.php';
if (file_exists($fileName)) {
include $fileName;
}
if (method_exists($controllerClassName, $methodName)) {
header('Content-Type: application/json');
$controller = new $controllerClassName();
//GET
if ($_SERVER['REQUEST_METHOD'] == "GET") {
echo $controller->$methodName($id);
} else
//POST
if ($_SERVER['REQUEST_METHOD'] == "POST"){
echo $controller->$methodName($data);
} else
//DELETE
if ($_SERVER['REQUEST_METHOD'] == "DELETE"){
echo $controller->$methodName($id);
} else
//PUT
{
echo $controller->$methodName($id, $data);
}
});
$endpoint = explode('/', trim($_SERVER['PATH_INFO'], '/'));
$data = json_decode(file_get_contents('php://input'), true);
$controllerName = $endpoint[0];
$endpoint2 = isset($endpoint[1]) ? $endpoint[1] : false;
$id = false;
$alias = false;
if ($endpoint2) {
if (preg_match('/^[0-9]+$/', $endpoint2)) {
$id = $endpoint2;
} else {
//http_response_code(404);
new \ppb\Library\Msg(true, 'Page not found: '.$controllerClassName.'::'.$methodName);
$alias = $endpoint2;
}
}
$controllerClassName = 'ppb\\Controller\\' . ucfirst($controllerName) . 'Controller';
if ($_SERVER['REQUEST_METHOD'] == "DELETE") {
$methodName = "delete" . ucfirst($controllerName);
} else if ($_SERVER['REQUEST_METHOD'] == "PUT") {
$methodName = "update" . ucfirst($controllerName);
} else if ($_SERVER['REQUEST_METHOD'] == "POST") {
$methodName = "write" . ucfirst($controllerName);
} else if ($_SERVER['REQUEST_METHOD'] == "GET") {
if ($alias) {
$methodName = $alias;
} else {
$methodName = "get" . ucfirst($controllerName);
}
}
if (method_exists($controllerClassName, $methodName)) {
header('Content-Type: application/json');
$controller = new $controllerClassName();
//GET
if ($_SERVER['REQUEST_METHOD'] == "GET") {
echo $controller->$methodName($id);
} else
//POST
if ($_SERVER['REQUEST_METHOD'] == "POST") {
echo $controller->$methodName($data);
} else
//DELETE
if ($_SERVER['REQUEST_METHOD'] == "DELETE") {
echo $controller->$methodName($id);
} else
//PUT
{
echo $controller->$methodName($id, $data);
}
} else {
//http_response_code(404);
new \ppb\Library\Msg(true, 'Page not found: ' . $controllerClassName . '::' . $methodName);
}
?>