summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data.c14
-rw-r--r--html.c19
2 files changed, 28 insertions, 5 deletions
diff --git a/data.c b/data.c
index 1e46395..2fb00eb 100644
--- a/data.c
+++ b/data.c
@@ -1065,14 +1065,18 @@ int timeline_touch(snac *snac)
1065xs_str *timeline_fn_by_md5(snac *snac, const char *md5) 1065xs_str *timeline_fn_by_md5(snac *snac, const char *md5)
1066/* get the filename of an entry by md5 from any timeline */ 1066/* get the filename of an entry by md5 from any timeline */
1067{ 1067{
1068 xs_str *fn = xs_fmt("%s/private/%s.json", snac->basedir, md5); 1068 xs_str *fn = NULL;
1069 1069
1070 if (mtime(fn) == 0.0) { 1070 if (xs_is_hex(md5) && strlen(md5) == 32) {
1071 fn = xs_free(fn); 1071 fn = xs_fmt("%s/private/%s.json", snac->basedir, md5);
1072 fn = xs_fmt("%s/public/%s.json", snac->basedir, md5);
1073 1072
1074 if (mtime(fn) == 0.0) 1073 if (mtime(fn) == 0.0) {
1075 fn = xs_free(fn); 1074 fn = xs_free(fn);
1075 fn = xs_fmt("%s/public/%s.json", snac->basedir, md5);
1076
1077 if (mtime(fn) == 0.0)
1078 fn = xs_free(fn);
1079 }
1076 } 1080 }
1077 1081
1078 return fn; 1082 return fn;
diff --git a/html.c b/html.c
index d52ef03..fdc0975 100644
--- a/html.c
+++ b/html.c
@@ -2586,6 +2586,25 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2586 } 2586 }
2587 } 2587 }
2588 else 2588 else
2589 if (xs_startswith(p_path, "admin/p/")) { /** unique post by md5 **/
2590 if (!login(&snac, req)) {
2591 *body = xs_dup(uid);
2592 status = 401;
2593 }
2594 else {
2595 xs *l = xs_split(p_path, "/");
2596 char *md5 = xs_list_get(l, -1);
2597
2598 if (md5 && *md5 && timeline_here(&snac, md5)) {
2599 xs *list = xs_list_append(xs_list_new(), md5);
2600
2601 *body = html_timeline(&snac, list, 0, 0, 0, 0, NULL, "/admin", 1);
2602 *b_size = strlen(*body);
2603 status = 200;
2604 }
2605 }
2606 }
2607 else
2589 if (strcmp(p_path, "people") == 0) { /** the list of people **/ 2608 if (strcmp(p_path, "people") == 0) { /** the list of people **/
2590 if (!login(&snac, req)) { 2609 if (!login(&snac, req)) {
2591 *body = xs_dup(uid); 2610 *body = xs_dup(uid);