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:
marko
2025-11-07 10:37:25 +01:00
parent 672eaccfc9
commit f28fa7b51b
96 changed files with 6152 additions and 6053 deletions

View File

@@ -1,38 +1,45 @@
<?php
require_once 'config/participo.php';
require_once "bootstrap.php";
require_once './local/cwsvJudo.php';
require_once "participoLib/participo.php";
require_once "participoLib/apiKey.php";
require_once 'participoLib/apiKey.php';
dbConnector::connect(
$cwsvJudoConfig['db']['host'],
$cwsvJudoConfig['db']['name'],
$cwsvJudoConfig['db']['user'],
$cwsvJudoConfig['db']['password']
participo::initDb(
$CONFIG["cwsvJudo"]["db"]["host"],
$CONFIG["cwsvJudo"]["db"]["name"],
$CONFIG["cwsvJudo"]["db"]["user"],
$SECRETS["cwsvJudo"]["db"][$CONFIG["cwsvJudo"]["db"]["user"]],
$CONFIG["cwsvJudo"]["db"]["dbCharset"],
$CONFIG["cwsvJudo"]["db"]["outCharset"],
);
$jsonPost = file_get_contents('php://input');
$jsonPost = file_get_contents("php://input");
$call = json_decode($jsonPost, $associative = true);
if ($call) {
$allowKey = ApiKey::loadFromDb($call['apiKey']);
$allowKey = ApiKey::loadFromDb($call["apiKey"]);
if (!$allowKey) {
die(json_encode(['success' => false]));
}
if (!$allowKey) {
die(json_encode(["success" => false]));
}
if (!$allowKey->isValidFor('apiKeys.create')) {
die(json_encode(['success' => false]));
}
if (!$allowKey->isValidFor("apiKeys.create")) {
die(json_encode(["success" => false]));
}
$newKey = ApiKey::create();
$newLoginApiKey = new ApiKey(null, $call['userId'], $newKey, 'login', $call['endDate']);
$newLoginApiKey->addToDb();
$insertedApiKey = ApiKey::loadFromDb($newKey);
if (!$insertedApiKey) {
die(json_encode(['success' => false]));
}
echo(json_encode(['success' => true, 'apiKey' => $newKey]));
$newKey = ApiKey::create();
$newLoginApiKey = new ApiKey(
null,
$call["userId"],
$newKey,
"login",
$call["endDate"],
);
$newLoginApiKey->addToDb();
$insertedApiKey = ApiKey::loadFromDb($newKey);
if (!$insertedApiKey) {
die(json_encode(["success" => false]));
}
echo json_encode(["success" => true, "apiKey" => $newKey]);
}