1
0
mirror of https://github.com/mbirth/tcl_update_db.git synced 2024-12-26 12:34:07 +00:00

Added writing backup copy to data/ directory.

This commit is contained in:
Markus Birth 2017-11-12 16:52:00 +01:00
parent 0ac893aeca
commit c62c036905
Signed by: mbirth
GPG Key ID: A9928D7A098C3A9A
2 changed files with 10 additions and 3 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/data/
/otadb.db3 /otadb.db3

View File

@ -27,10 +27,16 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
echo "Input length is " . strlen($input_xml) . " Bytes." . PHP_EOL; echo "Input length is " . strlen($input_xml) . " Bytes." . PHP_EOL;
#echo $input_xml . 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; exit;
} }