Files
cwsvJudo/homepage/participo/apiKeyTest.php
marko f28fa7b51b 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
2025-11-19 12:24:38 +01:00

40 lines
1015 B
PHP

<?php
require_once "config/participo.php";
require_once "./local/cwsvJudo.php";
require_once "participoLib/participo.php";
require_once "participoLib/apiKey.php";
require_once "spyc/Spyc.php";
dbConnector::setOptions([
"dbCharset" => $cwsvJudoConfig["dbCharset"] ?? "UTF-8",
"outCharset" => $cwsvJudoConfig["outCharset"] ?? "UTF-8",
]);
dbConnector::connect(
$cwsvJudoConfig["db"]["host"],
$cwsvJudoConfig["db"]["name"],
$cwsvJudoConfig["db"]["user"],
$cwsvJudoConfig["db"]["password"],
);
$userId = 1;
$apiKey = ApiKey::create();
// $rightString = 'event:' . PHP_EOL . ' id: 1';
// $rightArray = Spyc::YAMLLoadString($rightString);
$right = "login";
$date = new DateTime();
$newKey = new ApiKey(null, $userId, $apiKey, $right, $date->format("Y-m-d"));
$newKey->addToDb();
$loadedKey = ApiKey::loadFromDb($apiKey);
?>
<!doctype html>
<html>
<body>
<ul>
<li>rightsRoundabout: <?echo( $loadedKey->isValidFor($right) ? 'TRUE' : 'FALSE' );?></li>
</ul>
</body>
<html>