diff --git a/admin/api.php b/admin/api.php
index 6d66327..9bbb386 100644
--- a/admin/api.php
+++ b/admin/api.php
@@ -14,6 +14,9 @@ if (!empty($action)){
if ($action == "get"){
if ($_POST["password"] == $config["admin_pwd"]){
+ if(!file_exists("../data/pageindex.json")){
+ file_put_contents("../data/pageindex.json", "{}");
+ }
$stranky = json_decode(file_get_contents("../data/pageindex.json"), true);
$out = "
ID | Content ID | Nickname | Button |
";
foreach($stranky as $idx => $arr) {
@@ -46,6 +49,9 @@ if (!empty($action)){
}
if ($action == "getcontent"){
+ if(!file_exists("../data/contents.json")){
+ file_put_contents("../data/contents.json", "{}");
+ }
if ($_POST["password"] == $config["admin_pwd"]){
$contents = json_decode(file_get_contents("../data/contents.json"), true);
$out = "Content ID | Content | Button |
";
@@ -77,6 +83,9 @@ if (!empty($action)){
}
if ($action == "getlog"&& !empty($_POST["id"])){
+ if(!file_exists("../data/logs.json")){
+ file_put_contents("../data/logs.json", "{}");
+ }
if ($_POST["password"] == $config["admin_pwd"]){
$logy = json_decode(file_get_contents("../data/logs.json"), true)[$_POST["id"]];
$out = "Action | Date and Time | Nickname | Link | IP |
";
diff --git a/index.php b/index.php
index 3d77fca..ded7785 100644
--- a/index.php
+++ b/index.php
@@ -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");
}