You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.5 KiB
37 lines
1.5 KiB
<?php
|
|
// 载入db.php来连结资料库
|
|
/*--- 處理session ----*/
|
|
include "include-session-security.php"; #確認session
|
|
$latitude = $_REQUEST["latitude"];
|
|
$longitude = $_REQUEST["longitude"];
|
|
$off_line_time = 18000; #預設不可離線 30 mins
|
|
require_once "db/database.php"; # 載入db.php來連結資料庫
|
|
$data = array(); # 設置一個空陣列來放資料is
|
|
$sql = "SELECT * FROM account where (accountid = '$user_id')"; # sql語法存在變數中
|
|
$data = mysqli_query($link,$sql); # 用mysqli_query方法執行(sql語法)將結果存在變數中
|
|
foreach($data as $data){
|
|
$accounttype = $data['accounttype'];
|
|
$name = $data['name'];
|
|
}
|
|
if ((strlen($accounttype) != 0) and ($accounttype == 'B')){ #保養員屬性才將位置存入
|
|
|
|
$sql_1 = "INSERT INTO location_log (account_id, name, latitude, longitude, upload_time) values " .
|
|
"('$user_id', '$name', '$latitude', '$longitude', '$upload_time')";
|
|
mysqli_query($link,$sql_1); # 用mysqli_query方法執行(sql語法)將結果存在變數中
|
|
|
|
$upload_time = date('Y-m-d H:i:s');
|
|
$sql = "UPDATE location_last set name = '$name', latitude = '$latitude', longitude = '$longitude', upload_time = '$upload_time' WHERE account_id='$user_id'";
|
|
mysqli_query($link,$sql); # 用mysqli_query方法執行(sql語法)將結果存在變數中
|
|
if (mysqli_affected_rows($link)>0) {
|
|
$jsonres['code']='200';
|
|
echo json_encode($jsonres);
|
|
}else{
|
|
$jsonres['code']='1';
|
|
echo json_encode($jsonres);
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|