This commit is contained in:
parent
0685a316e8
commit
707741aa4c
@ -1,22 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
# Obtain the JSON payload from an OwnTracks app POSTed via HTTP
|
|
||||||
# and insert into database table.
|
|
||||||
|
|
||||||
header("Content-type: application/json");
|
header('Content-type: application/json');
|
||||||
|
|
||||||
$payload = file_get_contents("php://input");
|
define('DB_DIR', getenv('DB_DIR'));
|
||||||
$data = @json_decode($payload, true);
|
|
||||||
|
|
||||||
if ($data['_type'] == 'location') {
|
function store_sqlite3($data) {
|
||||||
file_put_contents('toto', serialize($data));
|
$db_path = DB_DIR.'/location-'.date('Y-m').'.db';
|
||||||
|
|
||||||
$db_dir = getenv('DB_DIR');
|
|
||||||
# TODO: pour plus tard afin de dynamiser le nom
|
|
||||||
$db_path = $db_dir.'/db.db';
|
|
||||||
$db = new SQLite3($db_path);
|
$db = new SQLite3($db_path);
|
||||||
|
|
||||||
# TODO: à commenter quand ready
|
|
||||||
# TODO: fixer type (https://owntracks.org/booklet/tech/json/)
|
|
||||||
$db->exec('
|
$db->exec('
|
||||||
CREATE TABLE IF NOT EXISTS history(
|
CREATE TABLE IF NOT EXISTS history(
|
||||||
tst INTEGER PRIMARY KEY,
|
tst INTEGER PRIMARY KEY,
|
||||||
@ -47,8 +38,18 @@ if ($data['_type'] == 'location') {
|
|||||||
$res = $stm->execute();
|
$res = $stm->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = array();
|
function store_raw($data) {
|
||||||
# optionally add objects to return to the app (e.g.
|
$db_path = DB_DIR.'/location-'.date('Y-m').'.raw';
|
||||||
# friends or cards)
|
file_put_contents('toto', serialize($data));
|
||||||
print json_encode($response);
|
}
|
||||||
|
|
||||||
|
$payload = file_get_contents("php://input");
|
||||||
|
$data = @json_decode($payload, true);
|
||||||
|
|
||||||
|
if ('location' == $data['_type']) {
|
||||||
|
store_raw($data);
|
||||||
|
store_sqlite3($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
print json_encode([]);
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user