WIP: bring participo back - consistent use of bootstrap - formatting -
phpstan level 0 error free - fixes for kyu subpage - move mams into participo framework - remove legacy `lib/db.php` usage - add attributer admin function - add newsposter - fixing apiKey creation
This commit is contained in:
52
homepage/participo/api/bootstrap.php
Normal file
52
homepage/participo/api/bootstrap.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
require_once "config.php";
|
||||
|
||||
if (!isset($HOME)) {
|
||||
die("Missing HOME config!");
|
||||
}
|
||||
|
||||
$CONFIG = json_decode(
|
||||
json: file_get_contents(filename: join("/", [$HOME, ".local/config.json"])),
|
||||
associative: true,
|
||||
);
|
||||
|
||||
$SECRETS = json_decode(
|
||||
json: file_get_contents(
|
||||
filename: join("/", [$HOME, "/.local/secrets.json"]),
|
||||
),
|
||||
associative: true,
|
||||
);
|
||||
|
||||
setlocale(LC_ALL, "de_DE@euro", "de_DE", "de", "ge");
|
||||
$BASE_PATH = join("/", [$HOME, $CONFIG["cwsvJudo"]["http"]["serve_dir"]]);
|
||||
set_include_path(
|
||||
implode(PATH_SEPARATOR, [
|
||||
get_include_path(),
|
||||
$BASE_PATH,
|
||||
join("/", [$BASE_PATH, "ressourcen"]),
|
||||
join("/", [$BASE_PATH, "ressourcen", "phpLib"]),
|
||||
join("/", [$HOME, "libs", "php"]),
|
||||
"../lib/",
|
||||
]),
|
||||
);
|
||||
|
||||
function authorize()
|
||||
{
|
||||
var_dump($_SERVER);
|
||||
if (array_key_exists("HTTP_AUTHORIZATION", $_SERVER)) {
|
||||
if (!empty($_SERVER["HTTP_AUTHORIZATION"])) {
|
||||
$auth = explode(" ", $_SERVER["HTTP_AUTHORIZATION"]);
|
||||
if ($auth[0] = "Basic") {
|
||||
$allowKey = ApiKey::loadFromDb($auth[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!($allowKey ?? false) || !$allowKey->isValidFor("api")) {
|
||||
die(
|
||||
json_encode([
|
||||
"success" => false,
|
||||
"reason" => "apiKey not sufficient or no api key provided",
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user