add some failsafes
This commit is contained in:
parent
40ab0e4624
commit
40be40db92
@ -14,6 +14,9 @@ if (!empty($action)){
|
|||||||
|
|
||||||
if ($action == "get"){
|
if ($action == "get"){
|
||||||
if ($_POST["password"] == $config["admin_pwd"]){
|
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);
|
$stranky = json_decode(file_get_contents("../data/pageindex.json"), true);
|
||||||
$out = "<table><tbody><tr><th>ID</th><th>Content ID</th><th>Nickname</th><th>Button</th></tr>";
|
$out = "<table><tbody><tr><th>ID</th><th>Content ID</th><th>Nickname</th><th>Button</th></tr>";
|
||||||
foreach($stranky as $idx => $arr) {
|
foreach($stranky as $idx => $arr) {
|
||||||
@ -46,6 +49,9 @@ if (!empty($action)){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($action == "getcontent"){
|
if ($action == "getcontent"){
|
||||||
|
if(!file_exists("../data/contents.json")){
|
||||||
|
file_put_contents("../data/contents.json", "{}");
|
||||||
|
}
|
||||||
if ($_POST["password"] == $config["admin_pwd"]){
|
if ($_POST["password"] == $config["admin_pwd"]){
|
||||||
$contents = json_decode(file_get_contents("../data/contents.json"), true);
|
$contents = json_decode(file_get_contents("../data/contents.json"), true);
|
||||||
$out = "<table><tbody><tr><th>Content ID</th><th>Content</th><th>Button</th></tr>";
|
$out = "<table><tbody><tr><th>Content ID</th><th>Content</th><th>Button</th></tr>";
|
||||||
@ -77,6 +83,9 @@ if (!empty($action)){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($action == "getlog"&& !empty($_POST["id"])){
|
if ($action == "getlog"&& !empty($_POST["id"])){
|
||||||
|
if(!file_exists("../data/logs.json")){
|
||||||
|
file_put_contents("../data/logs.json", "{}");
|
||||||
|
}
|
||||||
if ($_POST["password"] == $config["admin_pwd"]){
|
if ($_POST["password"] == $config["admin_pwd"]){
|
||||||
$logy = json_decode(file_get_contents("../data/logs.json"), true)[$_POST["id"]];
|
$logy = json_decode(file_get_contents("../data/logs.json"), true)[$_POST["id"]];
|
||||||
$out = "<table><tbody><tr><th>Action</th><th>Date and Time</th><th>Nickname</th><th>Link</th><th>IP</th></tr>";
|
$out = "<table><tbody><tr><th>Action</th><th>Date and Time</th><th>Nickname</th><th>Link</th><th>IP</th></tr>";
|
||||||
|
10
index.php
10
index.php
@ -10,6 +10,14 @@ if (!empty($idcko)){
|
|||||||
file_put_contents("data/logs.json", "{}");
|
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);
|
$stranky = json_decode(file_get_contents("data/pageindex.json"), true);
|
||||||
$contents = json_decode(file_get_contents("data/contents.json"), true);
|
$contents = json_decode(file_get_contents("data/contents.json"), true);
|
||||||
$logs = json_decode(file_get_contents("data/logs.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)){
|
if(array_key_exists($idcko, $stranky)){
|
||||||
|
|
||||||
$entry = $stranky[$idcko];
|
$entry = $stranky[$idcko];
|
||||||
|
|
||||||
if (!array_key_exists($entry["contentid"], $contents)){
|
if (!array_key_exists($entry["contentid"], $contents)){
|
||||||
die("Faulty link");
|
die("Faulty link");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user