From fa8e75d747fddc21ab4aa6173eb16400eff66053 Mon Sep 17 00:00:00 2001 From: Tristan Schneider Date: Fri, 25 Dec 2020 13:39:54 +0100 Subject: [PATCH] add automatic initialization for newly installed instances --- index.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/index.php b/index.php index b23b9fd..133bff2 100644 --- a/index.php +++ b/index.php @@ -14,6 +14,15 @@ function get_color_from_ip($ip) { //header("refresh: 28"); header("Cache-Control: no-cache, no-store, must-revalidate"); +if (!is_dir("data")) { + // initialize everything + mkdir("data", 0755); + file_put_contents("data/sentences.txt", "\n"); + file_put_contents("data/archive-links.txt", "\n"); + file_put_contents("data/config.json", "{\n\n}\n"); + print("

Data directory automatically initialized

"); +} + if (array_key_exists("submitted", $_REQUEST)) { $word = urldecode($_REQUEST["submitted"]); //print("Jemand schreibt ".$word."
");