implement flagging on www
This commit is contained in:
53
src/www.c
53
src/www.c
@@ -699,6 +699,59 @@ int www_handler(void * cls, struct MHD_Connection * connection, const char * url
|
||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
||||
|
||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
||||
} else if (strncasecmp(url, "/msgs/flag/", 11) == 0) {
|
||||
con_inf->user = www_auth_ok(connection, url_);
|
||||
|
||||
if (con_inf->user == NULL) {
|
||||
www_401(header, footer, connection);
|
||||
free(header);
|
||||
free(footer);
|
||||
return MHD_YES;
|
||||
}
|
||||
conference = -1;
|
||||
area = -1;
|
||||
msg = -1;
|
||||
url_copy = strdup(&url[11]);
|
||||
|
||||
aptr = strtok(url_copy, "/");
|
||||
if (aptr != NULL) {
|
||||
conference = strtol(aptr, &endptr, 10);
|
||||
if (endptr == aptr) {
|
||||
conference = -1;
|
||||
}
|
||||
aptr = strtok(NULL, "/");
|
||||
if (aptr != NULL) {
|
||||
area = strtol(aptr, &endptr, 10);
|
||||
if (endptr == aptr) {
|
||||
area = -1;
|
||||
}
|
||||
aptr = strtok(NULL, "/");
|
||||
if (aptr != NULL) {
|
||||
msg = strtol(aptr, &endptr, 10);
|
||||
if (endptr == aptr) {
|
||||
msg = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
free(url_copy);
|
||||
|
||||
if (conference != -1 && area != -1 && msg != -1) {
|
||||
msgbase_flag_unflag(con_inf->user, conference, area, msg);
|
||||
response = MHD_create_response_from_buffer (0, (void*) "", MHD_RESPMEM_PERSISTENT);
|
||||
snprintf(buffer, PATH_MAX, "%smsgs/%d/%d/%d", conf.www_url, conference, area, msg);
|
||||
|
||||
MHD_add_response_header (response, "Location", buffer);
|
||||
MHD_queue_response (connection, MHD_HTTP_FOUND, response);
|
||||
MHD_destroy_response(response);
|
||||
free(header);
|
||||
free(footer);
|
||||
return MHD_YES;
|
||||
}
|
||||
www_404(header, footer, connection);
|
||||
free(header);
|
||||
free(footer);
|
||||
return MHD_YES;
|
||||
} else if (strncasecmp(url, "/msgs/new/", 10) == 0) {
|
||||
con_inf->user = www_auth_ok(connection, url_);
|
||||
|
||||
|
@@ -437,8 +437,11 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
|
||||
sprintf(buffer, "<div class=\"msg-view-header\">\n");
|
||||
if (msgbase_is_flagged(user, conference, area, msg)) {
|
||||
sprintf(buffer, "<div class=\"msg-view-header-flagged\">\n");
|
||||
} else {
|
||||
sprintf(buffer, "<div class=\"msg-view-header\">\n");
|
||||
}
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
@@ -486,6 +489,8 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
} else {
|
||||
sprintf(buffer, "<div class=\"msg-view-date\">Date: %.2d:%.2d %.2d-%.2d-%.2d</div>\n", msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||
}
|
||||
|
||||
sprintf(buffer, "<div class=\"msg-view-options\"><a href=\"%smsgs/flag/%d/%d/%d\"><img src=\"%sstatic/flag.png\" /></a></div>", conf.www_url, conference, area, msg, conf.www_url);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
|
Reference in New Issue
Block a user