Erant-OldApp/public/api/index.php

38 lines
945 B
PHP

<?php
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/cors.php';
cors();
$router = new \Bramus\Router\Router();
$router->setBasePath('/api');
use Medoo\Medoo;
header('Content-Type: application/json; charset=utf-8');
function env($key) {
global $_ENV;
return array_key_exists($key, $_ENV) ? $_ENV[$key] : null;
}
$database = new Medoo([
'type' => 'mysql',
'host' => "db.db030.webglobe.com",
'database' => "mysql122279",
'username' => "mysql85033",
'password' => "troglodyt"
]);
$data = json_decode(file_get_contents("php://input"), true);
$router->post('/game/details', function() use($database, $data) {
$fn = require __DIR__ . '/routes/game/details.php';
$response = $fn($data, getallheaders(), $database);
$response["status"] = array_key_exists("status", $response) ? $response["status"] : 200;
http_response_code($response["status"]);
echo json_encode($response["data"]);
});
$router->run();