le-pere-noel-secret/etc/database.php
2020-10-31 18:34:26 +01:00

28 lines
523 B
PHP

<?php
$databasePath = __DIR__.'/../datas/results.json';
$database = [];
if (file_exists($databasePath)) {
$database = json_decode(file_get_contents($databasePath), true);
}
function getData($key, $default = null) {
global $database;
return $database[$key] ?? $default;
}
function setData($key, $value) {
global $database;
return $database[$key] = $value;
}
function saveDatabase() {
global $databasePath;
global $database;
file_put_contents($databasePath, json_encode($database));
}