From 707741aa4c6083a82fc3c0ea1e82aa0938167c87 Mon Sep 17 00:00:00 2001 From: Julien Cabillot Date: Fri, 17 Apr 2020 16:48:33 -0400 Subject: [PATCH] Use functions --- root/push.php | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/root/push.php b/root/push.php index 8d2c7e2..7931b13 100644 --- a/root/push.php +++ b/root/push.php @@ -1,22 +1,13 @@ exec(' CREATE TABLE IF NOT EXISTS history( tst INTEGER PRIMARY KEY, @@ -47,8 +38,18 @@ if ($data['_type'] == 'location') { $res = $stm->execute(); } -$response = array(); -# optionally add objects to return to the app (e.g. -# friends or cards) -print json_encode($response); +function store_raw($data) { + $db_path = DB_DIR.'/location-'.date('Y-m').'.raw'; + file_put_contents('toto', serialize($data)); +} + +$payload = file_get_contents("php://input"); +$data = @json_decode($payload, true); + +if ('location' == $data['_type']) { + store_raw($data); + store_sqlite3($data); +} + +print json_encode([]); ?>