Validate track when adding position
This commit is contained in:
parent
919cb4d9d3
commit
dccb90d6df
@ -85,19 +85,22 @@
|
|||||||
public function add($userId, $trackId, $time, $lat, $lon, $altitude, $speed, $bearing, $accuracy, $provider, $comment, $imageId) {
|
public function add($userId, $trackId, $time, $lat, $lon, $altitude, $speed, $bearing, $accuracy, $provider, $comment, $imageId) {
|
||||||
$positionId = false;
|
$positionId = false;
|
||||||
if (!is_null($lat) && !is_null($lon) && !is_null($time) && !empty($userId) && !empty($trackId)) {
|
if (!is_null($lat) && !is_null($lon) && !is_null($time) && !empty($userId) && !empty($trackId)) {
|
||||||
$query = "INSERT INTO `" . self::$db->table('positions') . "`
|
$track = new uTrack($trackId);
|
||||||
(user_id, track_id,
|
if ($track->isValid && $track->userId == $userId) {
|
||||||
time, latitude, longitude, altitude, speed, bearing, accuracy, provider, comment, image_id)
|
$query = "INSERT INTO `" . self::$db->table('positions') . "`
|
||||||
VALUES (?, ?, FROM_UNIXTIME(?), ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
(user_id, track_id,
|
||||||
$stmt = self::$db->prepare($query);
|
time, latitude, longitude, altitude, speed, bearing, accuracy, provider, comment, image_id)
|
||||||
$stmt->bind_param('iisddddddssi',
|
VALUES (?, ?, FROM_UNIXTIME(?), ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
$userId, $trackId,
|
$stmt = self::$db->prepare($query);
|
||||||
$time, $lat, $lon, $altitude, $speed, $bearing, $accuracy, $provider, $comment, $imageId);
|
$stmt->bind_param('iisddddddssi',
|
||||||
$stmt->execute();
|
$userId, $trackId,
|
||||||
if (!self::$db->error && !$stmt->errno) {
|
$time, $lat, $lon, $altitude, $speed, $bearing, $accuracy, $provider, $comment, $imageId);
|
||||||
$positionId = self::$db->insert_id;
|
$stmt->execute();
|
||||||
|
if (!self::$db->error && !$stmt->errno) {
|
||||||
|
$positionId = self::$db->insert_id;
|
||||||
|
}
|
||||||
|
$stmt->close();
|
||||||
}
|
}
|
||||||
$stmt->close();
|
|
||||||
}
|
}
|
||||||
return $positionId;
|
return $positionId;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user