From 1df1ff6f074528a4ad6d4015c794a1555c1c942f Mon Sep 17 00:00:00 2001 From: Maksymilian Jopek Date: Mon, 3 Apr 2023 22:12:41 +0200 Subject: Polishing up Add all files to repo Add sql database Correct urls Add PHP code to repo Update README.md with instructions how to start Move from yarn to pnpm Fix all issues with starting Fix possibility of player changing their dice roll with refreshing the game --- public/php/dbCredentials.php | 4 ++++ public/php/fia.php | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 public/php/dbCredentials.php create mode 100644 public/php/fia.php (limited to 'public/php') diff --git a/public/php/dbCredentials.php b/public/php/dbCredentials.php new file mode 100644 index 0000000..87bbfd5 --- /dev/null +++ b/public/php/dbCredentials.php @@ -0,0 +1,4 @@ +apiKey === $apiKey) { + $http = isset($_SERVER["HTTPS"]) ? "https" : "http"; + header("Access-Control-Allow-Origin: $http://localhost:8000"); + $pdo = new PDO("mysql:dbname=ClientApps;host=localhost;charset=utf8mb4", $dbUser, $dbPassword); + $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); + $stmt = $pdo->prepare($req->query); + try { + $params = []; + foreach ($req->params as $v) { + if(is_string($v)) + array_push($params, $v); + else + array_push($params, json_encode($v)); + } + $stmt->execute($params); + } catch (PDOException $e) { + echo "ERROR!!!"; + var_dump($req); + var_dump($stmt); + throw $e; + } + echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC)); + http_response_code(200); +} else { + echo "Wrong username or password!"; + http_response_code(401); +} -- cgit v1.3.1