From c62c03690517af1b53d5fddb3d4b4067d45da8c1 Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Sun, 12 Nov 2017 16:52:00 +0100 Subject: [PATCH] Added writing backup copy to data/ directory. --- .gitignore | 1 + index.php | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index f7ec1c5..c0c4d69 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +/data/ /otadb.db3 diff --git a/index.php b/index.php index 260fb61..726a8a2 100644 --- a/index.php +++ b/index.php @@ -27,10 +27,16 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { echo "Input length is " . strlen($input_xml) . " Bytes." . PHP_EOL; #echo $input_xml . PHP_EOL; + // Write backup copy (for maybe re-parsing later) + $bkup_dir = __DIR__ . '/data/'; + if (!is_dir($bkup_dir)) { + mkdir($bkup_dir); + } + $bkup_filename = $bkup_dir . sprintf('%f-%04x.xml', microtime(true), rand(0, 65535)); + file_put_contents($bkup_filename, $input_xml); + + // TODO: Parse XML into database - // TODO: Check if it's XML - // If so: Store a copy for re-parsing (or to print out and hang up on a wall) - // Then parse XML into database exit; }