mirror of
https://github.com/owntracks/recorder.git
synced 2026-02-13 20:49:51 +00:00
@@ -761,6 +761,7 @@ The JSON in the view file (called `view.json` here) contains mandatory and optio
|
||||
| page | Y | HTML page to be loaded from `docroot/views/` for this view |
|
||||
| from | N | `from` timestamp for data, defaults to now - 6H |
|
||||
| to | N | `to` timestamp for data, defaults to now |
|
||||
| hours | N | number of past hours (from "now") for which to show data; use instead of `from` and `to`
|
||||
| auth | N | array of digest authentication tokens described below |
|
||||
| label | N | text to use in popup of default `vmap.html` instead of user/device |
|
||||
| zoom | N | zoom level for map used in `vmap.html`, defaults to 9 |
|
||||
|
||||
10
http.c
10
http.c
@@ -665,7 +665,7 @@ static int ctrl_track(struct mg_connection *conn)
|
||||
return (MG_TRUE);
|
||||
}
|
||||
|
||||
if (make_times(from, &s_lo, to, &s_hi) != 1) {
|
||||
if (make_times(from, &s_lo, to, &s_hi, 0) != 1) {
|
||||
send_status(conn, 416, "impossible date/time ranges");
|
||||
return (MG_TRUE);
|
||||
}
|
||||
@@ -757,6 +757,7 @@ static JsonNode *viewdata(struct mg_connection *conn, JsonNode *view, int limit)
|
||||
JsonNode *j, *json, *obj, *locs, *ju, *jd, *arr;
|
||||
char *from = NULL, *to = NULL;
|
||||
time_t s_lo, s_hi;
|
||||
int hours = 0;
|
||||
|
||||
ju = json_find_member(view, "user");
|
||||
jd = json_find_member(view, "device");
|
||||
@@ -764,11 +765,14 @@ static JsonNode *viewdata(struct mg_connection *conn, JsonNode *view, int limit)
|
||||
from = j->string_;
|
||||
if ((j = json_find_member(view, "to")) != NULL)
|
||||
to = j->string_;
|
||||
if ((j = json_find_member(view, "hours")) != NULL) {
|
||||
hours = j->number_;
|
||||
}
|
||||
|
||||
if (!ju || !jd)
|
||||
return (NULL);
|
||||
|
||||
if (make_times(from, &s_lo, to, &s_hi) != 1) {
|
||||
if (make_times(from, &s_lo, to, &s_hi, hours) != 1) {
|
||||
send_status(conn, 416, "impossible date/time ranges");
|
||||
return (NULL);
|
||||
}
|
||||
@@ -1084,7 +1088,7 @@ static int dispatch(struct mg_connection *conn, const char *uri)
|
||||
}
|
||||
}
|
||||
|
||||
if (make_times(time_from, &s_lo, time_to, &s_hi) != 1) {
|
||||
if (make_times(time_from, &s_lo, time_to, &s_hi, 0) != 1) {
|
||||
mg_send_status(conn, 416);
|
||||
mg_printf_data(conn, "impossible date/time ranges\n");
|
||||
return (MG_TRUE);
|
||||
|
||||
2
ocat.c
2
ocat.c
@@ -384,7 +384,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (make_times(time_from, &s_lo, time_to, &s_hi) != 1) {
|
||||
if (make_times(time_from, &s_lo, time_to, &s_hi, 0) != 1) {
|
||||
fprintf(stderr, "%s: bad time(s) specified\n", progname);
|
||||
return (-2);
|
||||
}
|
||||
|
||||
@@ -377,14 +377,13 @@ static int str_time_to_secs(char *s, time_t *secs)
|
||||
* Return 1 if the time conversion was successful and from <= to.
|
||||
*/
|
||||
|
||||
int make_times(char *time_from, time_t *s_lo, char *time_to, time_t *s_hi)
|
||||
int make_times(char *time_from, time_t *s_lo, char *time_to, time_t *s_hi, int hours)
|
||||
{
|
||||
time_t now;
|
||||
|
||||
|
||||
time(&now);
|
||||
if (!time_from || !*time_from) {
|
||||
*s_lo = now - (60 * 60 * DEFAULT_HISTORY_HOURS);
|
||||
*s_lo = now - (60 * 60 * ((hours) ? hours : DEFAULT_HISTORY_HOURS));
|
||||
} else {
|
||||
if (str_time_to_secs(time_from, s_lo) == 0)
|
||||
return (0);
|
||||
|
||||
@@ -41,7 +41,7 @@ typedef enum {
|
||||
JsonNode *lister(char *username, char *device, time_t s_lo, time_t s_hi, int reverse);
|
||||
JsonNode *multilister(JsonNode *udpairs, time_t s_lo, time_t s_hi, int reverse);
|
||||
void locations(char *filename, JsonNode *obj, JsonNode *arr, time_t s_lo, time_t s_hi, output_type otype, int limit, JsonNode *fields, char *username, char *device);
|
||||
int make_times(char *time_from, time_t *s_lo, char *time_to, time_t *s_to);
|
||||
int make_times(char *time_from, time_t *s_lo, char *time_to, time_t *s_to, int hours);
|
||||
JsonNode *geo_json(JsonNode *json);
|
||||
JsonNode *geo_linestring(JsonNode *location_array);
|
||||
JsonNode *kill_datastore(char *username, char *device);
|
||||
|
||||
Reference in New Issue
Block a user