Старт

This commit is contained in:
2023-11-07 19:51:49 +06:00
commit 86542a157f
5002 changed files with 199551 additions and 0 deletions

52
android/accept.php Normal file
View File

@ -0,0 +1,52 @@
<?php
//Принять накопившиеся GPS данные с телефона и сохранить в виде файлов во временное хранилище
//Отвечаю только на POST запросы
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
sendError("Request is GET method!");
}
if(!isset($HTTP_RAW_POST_DATA))
{ $HTTP_RAW_POST_DATA = file_get_contents("php://input");
}
$object = json_decode($HTTP_RAW_POST_DATA);
if ($object == null) {
sendError("Request is empty!");
}
$fn = filter_input(INPUT_GET, 'fn', FILTER_VALIDATE_INT, array('options' => array('default' => -1)));
if (isset($_GET['lng'])) $_SESSION["LNG"] = $_GET['lng']; else $_SESSION["LNG"] = 2;//'en';
$result=false;
if ($fn == 1) {
//Данные GPS
$file = fopen('./data/'.time().'_'.$object->imei.'_1.json','w');
fwrite($file, $HTTP_RAW_POST_DATA);
fclose($file);
$result=true;
}elseif ($fn == 2){
//Данные датчиков
$file = fopen('./data/'.time().'_'.$object->imei.'_2.json','w');
fwrite($file, $HTTP_RAW_POST_DATA);
fclose($file);
$result=true;
}
if($result){
$obj = new StdClass();
$obj->errorCode = 0;
$obj->errorMessage = '';
$obj->data = array();
header('Content-Type: application/json');
header("Cache-Control: no-cache, must-revalidate");
echo json_encode($obj);
}else{
$obj = new StdClass();
$obj->errorCode = 1;
$obj->errorMessage = '';
$obj->data = array();
header('Content-Type: application/json');
header("Cache-Control: no-cache, must-revalidate");
echo json_encode($obj);
}