add some failsafes

This commit is contained in:
2023-06-09 22:06:13 +02:00
parent 40ab0e4624
commit 40be40db92
2 changed files with 18 additions and 1 deletions

View File

@@ -10,6 +10,14 @@ if (!empty($idcko)){
file_put_contents("data/logs.json", "{}");
}
if(!file_exists("data/pageindex.json")){
file_put_contents("data/pageindex.json", "{}");
}
if(!file_exists("data/contents.json")){
file_put_contents("data/contents.json", "{}");
}
$stranky = json_decode(file_get_contents("data/pageindex.json"), true);
$contents = json_decode(file_get_contents("data/contents.json"), true);
$logs = json_decode(file_get_contents("data/logs.json"), true);
@@ -20,7 +28,7 @@ if (!empty($idcko)){
if(array_key_exists($idcko, $stranky)){
$entry = $stranky[$idcko];
if (!array_key_exists($entry["contentid"], $contents)){
die("Faulty link");
}