90 || $lon < -180 || $lon > 180) die("Invalid location!\n"); // Not all devices report speed and accuracy, but if available, report them too. $speed = isset($_POST["spd"]) ? floatval($_POST["spd"]) : null; $accuracy = isset($_POST["acc"]) ? floatval($_POST["acc"]) : null; $memcache = memConnect(); // Retrieve the session data from memcached. $sid = $_POST["sid"]; $session = new Client($memcache, $sid); if (!$session->exists()) die("Session expired!\n"); // The location data object contains the sharing interval (i), duration (d) and // a location list (l). Each entry in the location list contains a latitude, // longitude, timestamp, accuracy and speed, in that order, as an array. $session->addPoint([$lat, $lon, $time, $accuracy, $speed])->save(); if ($session->hasExpired()) { echo "Session expired!\n"; } else { echo "OK\n"; }