From d48414bd943a2219107d6568fe2211b65db81f23 Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Mon, 9 Sep 2002 08:04:58 +0000 Subject: [PATCH] Added select boxes SVN revision: 224 --- elogd.c | 389 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 324 insertions(+), 65 deletions(-) diff --git a/elogd.c b/elogd.c index c6d2a998..acb75d4e 100755 --- a/elogd.c +++ b/elogd.c @@ -6,6 +6,9 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 2.70 2002/09/09 08:04:58 midas + Added select boxes + Revision 2.69 2002/08/13 12:24:37 midas Version 2.1.1 @@ -410,12 +413,14 @@ int tcp_port = 80; #define MAX_N_ATTR 50 #define VALUE_SIZE 256 #define PARAM_LENGTH 256 +#define CMD_SIZE 10000 #define TEXT_SIZE 100000 #define MAX_PATH_LENGTH 256 char _param[MAX_PARAM][PARAM_LENGTH]; char _value[MAX_PARAM][VALUE_SIZE]; char _text[TEXT_SIZE]; +char _cmdline[CMD_SIZE]; char *_attachment_buffer[MAX_ATTACHMENTS]; INT _attachment_size[MAX_ATTACHMENTS]; struct in_addr rem_addr; @@ -458,6 +463,7 @@ char author_list[MAX_N_LIST][NAME_LENGTH] = { #define AF_MULTI (1<<2) #define AF_FIXED (1<<3) #define AF_ICON (1<<4) +#define AF_RADIO (1<<5) char attr_list[MAX_N_ATTR][NAME_LENGTH]; char attr_options[MAX_N_ATTR][MAX_N_LIST][NAME_LENGTH]; @@ -2598,6 +2604,7 @@ INT el_delete_message(LOGBOOK *lbs, int message_id, BOOL delete_attachments, int message_id Message ID BOOL delete_attachments Delete attachments if TRUE char attachment Used to return attachments (on move) + BOOL delete_bw_ref If true, delete backward references Output: @@ -2811,7 +2818,7 @@ char buf[256]; now=time(0); strftime(buf, sizeof(buf), "%d-%b-%Y %H:%M:%S", localtime(&now)); - fprintf(f,"%s: %s",buf,str); + fprintf(f,"%s [%s]: %s", buf, rem_host, str); if (str[strlen(str)-1] != '\n') fprintf(f,"\n"); @@ -2980,6 +2987,21 @@ char str[10000]; return 1; } + if (equal_ustring(param, "cmdline")) + { + if (strlen(value) >= CMD_SIZE) + { + sprintf(str, "Error: Command line too big (%d bytes). Please increase CMD_SIZE and recompile elogd\n", + strlen(value)); + show_error(str); + return 0; + } + + strncpy(_cmdline, value, CMD_SIZE); + _cmdline[CMD_SIZE-1] = 0; + return 1; + } + /* paremeters can be superseeded */ for (i=0 ; i= VALUE_SIZE) { - sprintf(str, "Error: Parameter value %s for parameter %s too big. Please increase VALUE_SIZE and recompile elogd\n", param); + sprintf(str, "Error: Parameter value for parameter %s too big (%d bytes). Please increase VALUE_SIZE and recompile elogd\n", param, strlen(value)); show_error(str); return 0; } @@ -3014,6 +3036,9 @@ int i; if (equal_ustring(param, "text")) return _text; + if (equal_ustring(param, "cmdline")) + return _cmdline; + for (i=0 ; i\n", str, attr_options[index][i]); } } + else if (attr_flags[index] & AF_RADIO) + { + for (i=0 ; i\n", str, attr_options[index][i]); + } + } else if (attr_flags[index] & AF_ICON) { for (i=0 ; i\n"); + } + else if (attr_flags[index] & AF_RADIO) + { + /* display radio buttons */ + rsprintf("\n", gt("Categories bgcolor2")); + + for (i=0 ; i%s \n", + attr_list[index], attr_options[index][i], attr_options[index][i]); + else + rsprintf("%s \n", + attr_list[index], attr_options[index][i], attr_options[index][i]); + } + rsprintf("\n"); } else if (attr_flags[index] & AF_ICON) @@ -5332,7 +5391,7 @@ void show_new_user_page(LOGBOOK *lbs) void show_elog_delete(LOGBOOK *lbs, int message_id) { -int status; +int i, status, reply, next; char str[256], in_reply_to[80], reply_to[256]; /* redirect if confirm = NO */ @@ -5344,50 +5403,115 @@ char str[256], in_reply_to[80], reply_to[256]; return; } - /* header */ - sprintf(str, "%d", message_id); - show_standard_header("Delete ELog entry", str); - - rsprintf("

", - gt("Border width"), gt("Frame color")); - rsprintf("
\n", gt("Frame color")); - if (getparam("confirm") && *getparam("confirm")) { if (strcmp(getparam("confirm"), loc("Yes")) == 0) { - /* delete message */ - status = el_delete_message(lbs, message_id, TRUE, NULL, TRUE); - rsprintf("\n", loc("Message successfully deleted")); + if (message_id) + { + /* delete message */ + status = el_delete_message(lbs, message_id, TRUE, NULL, TRUE); + rsprintf("\n", loc("Error deleting message: status"), status); + { + for (i=reply=0 ; i\n", loc("Last")); - rsprintf("\n", - gt("Cell BGColor"), loc("Goto last message")); + redirect(getparam("lastcmd")); + return; + } } } else { + /* header */ + sprintf(str, "%d", message_id); + show_standard_header("Delete ELog entry", str); + + rsprintf("

"); - if (status == EL_SUCCESS) - rsprintf("%s
"); + if (status != EL_SUCCESS) + { + sprintf(str, "%s = %d", loc("Error deleting message: status"), status); + show_error(str); + return; + } + else + { + strcpy(str, getparam("nextmsg")); + if (atoi(str) == 0) + sprintf(str, "%d", el_search_message(lbs, EL_LAST, 0, TRUE)); + redirect(str); + return; + } + } else - rsprintf("%s = %d
", + gt("Border width"), gt("Frame color")); + rsprintf("
\n", gt("Frame color")); + /* define hidden field for command */ rsprintf("\n", loc("Delete")); rsprintf("\n", gt("Title fontcolor"), - loc("Are you sure to delete this message?")); + + if (!message_id) + { + rsprintf("%s\n", gt("Title fontcolor"), + loc("Are you sure to delete these messages?")); - /* check for replies */ + rsprintf("\n", gt("Cell BGColor"), message_id, loc("and all its replies")); + for (i=reply=0 ; i\n", str, getparam(str)); + } + + if (!reply) + { + el_retrieve(lbs, atoi(getparam(str)), NULL, attr_list, NULL, 0, + NULL, NULL, in_reply_to, reply_to, NULL, NULL); + if (reply_to[0]) + reply = TRUE; + } + } + + rsprintf("\n"); + + if (reply) + rsprintf("\n", gt("Cell BGColor"), loc("and all its replies")); + + } else - rsprintf("\n", gt("Cell BGColor"), message_id); + { + rsprintf("%s\n", gt("Title fontcolor"), + loc("Are you sure to delete this message?")); + + /* check for replies */ + + /* retrieve original message */ + el_retrieve(lbs, message_id, NULL, attr_list, NULL, 0, + NULL, NULL, in_reply_to, reply_to, NULL, NULL); + + if (reply_to[0]) + rsprintf("\n", gt("Cell BGColor"), message_id, loc("and all its replies")); + else + rsprintf("\n", gt("Cell BGColor"), message_id); + + /* put link to next message */ + next = el_search_message(lbs, EL_NEXT, message_id, TRUE); + + rsprintf("\n", next); + } rsprintf("\n\n"); +} + +/*------------------------------------------------------------------*/ + void show_elog_submit_find(LOGBOOK *lbs, INT past_n, INT last_n, INT page_n) { int i, j, n, index, size, status, d1, m1, y1, d2, m2, y2, n_line; -int current_year, current_month, current_day, printable, n_logbook, +int current_year, current_month, current_day, printable, n_logbook, n_display, reverse, n_attr_disp, n_msg, search_all, message_id, n_page, i_start, i_stop; char date[80], attrib[MAX_N_ATTR][NAME_LENGTH], disp_attr[MAX_N_ATTR+4][NAME_LENGTH], list[10000], text[TEXT_SIZE], text1[TEXT_SIZE], text2[TEXT_SIZE], @@ -6302,6 +6472,7 @@ MSG_LIST *msg_list; search_all = 0; n_msg = 0; + n_display = 0; if (search_all) { /* count logbooks */ @@ -6533,6 +6704,20 @@ MSG_LIST *msg_list; rsprintf("\n"); if (n_msg == 0) @@ -6863,11 +7084,15 @@ MSG_LIST *msg_list; rsprintf("
", gt("Title bgcolor")); - rsprintf("%s
\n", gt("Cell BGColor")); + rsprintf("\n", getparam("nsel")); - /* retrieve original message */ - el_retrieve(lbs, message_id, NULL, attr_list, NULL, 0, - NULL, NULL, in_reply_to, reply_to, NULL, NULL); + strcpy(str, getparam("cmdline")); + rsprintf("\n", str); - if (reply_to[0]) - rsprintf("
%d
%s
%s
%d
%d
%s
%d
\n", gt("Cell BGColor"), loc("Yes")); @@ -5484,7 +5608,8 @@ void display_line(LOGBOOK *lbs, int message_id, int number, char *mode, int n_attr_disp, char disp_attr[MAX_N_ATTR+4][NAME_LENGTH], char attrib[MAX_N_ATTR][NAME_LENGTH], int n_attr, char *text, - char attachment[MAX_ATTACHMENTS][256], char *encoding) + char attachment[MAX_ATTACHMENTS][256], char *encoding, + BOOL select, int *n_display) { char str[256], ref[256], *nowrap, col[80], format[256], file_name[256]; char slist[MAX_N_ATTR+10][NAME_LENGTH], svalue[MAX_N_ATTR+10][NAME_LENGTH]; @@ -5518,6 +5643,11 @@ FILE *f; if (equal_ustring(mode, "Threaded")) { rsprintf("", col); + + /* show select box */ + if (select) + rsprintf("\n", (*n_display)++, message_id); + for (i=0 ; i\n", col, message_id); + for (index=0 ; indexn_attr, NULL, NULL, encoding); + attrib, lbs->n_attr, NULL, NULL, encoding, 0, NULL); if (reply_to[0]) { @@ -6063,14 +6197,14 @@ char ref[256]; if (page_n == i+1) rsprintf("%d  ", i+1); else - rsprintf("%d  ", ref, i+1); + rsprintf("%d  \n", ref, i+1); } else { if (page_n == i+1) rsprintf("%d, ", i+1); else - rsprintf("%d, ", ref, i+1); + rsprintf("%d, \n", ref, i+1); } } @@ -6105,10 +6239,46 @@ char ref[256]; /*------------------------------------------------------------------*/ +void show_select_navigation(LOGBOOK *lbs) +{ +char str[256]; + + rsprintf("
\n", + gt("Border width"), gt("Categories cellpadding")); + rsprintf("
\n", gt("Menu1 Align"), gt("Menu1 BGColor")); + + rsprintf(" \n"); + + rsprintf("Selected entries: \n"); + + rsprintf("\n", loc("Toggle all")); + + if (!getcfg(lbs->name, "Menu commands", str) || + strstr(str, "Delete")) + { + rsprintf("\n"); + } + + rsprintf("
\n", gt("Menu1 Align"), gt("Menu1 BGColor")); + /* current command line for select command */ + strcpy(str, getparam("cmdline")); + + /* remove select switch */ + if (strstr(str, "select=1")) + { + *strstr(str, "select=1") = 0; + if (strlen(str) > 1 && + (str[strlen(str)-1] == '&' || str[strlen(str)-1] == '?')) + str[strlen(str)-1] = 0; + } + + rsprintf("\n", str); + if (!getcfg(lbs->name, "Guest Find menu commands", menu_str) || *getparam("unm") != 0) getcfg(lbs->name, "Find menu commands", menu_str); @@ -6544,6 +6729,8 @@ MSG_LIST *msg_list; strcat(menu_str, ", "); strcat(menu_str, loc("Find")); strcat(menu_str, ", "); + strcat(menu_str, loc("Select")); + strcat(menu_str, ", "); strcat(menu_str, loc("Back")); strcat(menu_str, ", "); strcat(menu_str, loc("Help")); @@ -6596,6 +6783,30 @@ MSG_LIST *msg_list; rsprintf(" %s |\n", last_n*2, mode, str); } } + else if (equal_ustring(menu_item[i], loc("Select"))) + { + strcpy(str, getparam("cmdline")); + if (atoi(getparam("select")) == 1) + { + /* remove select switch */ + if (strstr(str, "select=1")) + { + *strstr(str, "select=1") = 0; + if (strlen(str) > 1 && + (str[strlen(str)-1] == '&' || str[strlen(str)-1] == '?')) + str[strlen(str)-1] = 0; + } + } + else + { + /* add select switch */ + if (strchr(str, '?')) + strcat(str, "&select=1"); + else + strcat(str, "?select=1"); + } + rsprintf(" %s |\n", str, loc("Select")); + } else { strcpy(str, loc(menu_item[i])); @@ -6670,6 +6881,11 @@ MSG_LIST *msg_list; if (!printable && page_n && n_msg > n_page) show_page_navigation(n_msg, page_n, n_page); + /*---- select navigation ----*/ + + if (atoi(getparam("select")) == 1) + show_select_navigation(lbs); + /*---- table titles ----*/ rsprintf("
\n", @@ -6709,6 +6925,9 @@ MSG_LIST *msg_list; { rsprintf("\n"); + if (atoi(getparam("select")) == 1) + rsprintf("\n", col); + for (i=0 ; i"); - else if (strcmp(getparam("rsort"), disp_attr[i]) == 0) strcpy(img, ""); + else if (strcmp(getparam("rsort"), disp_attr[i]) == 0) + strcpy(img, ""); rsprintf("\n", col, size, ref, disp_attr[i], img); @@ -6831,7 +7050,7 @@ MSG_LIST *msg_list; display_line(msg_list[index].lbs, message_id, index, mode, 0, printable, n_line, show_attachments, date, reply_to, n_attr_disp, disp_attr, - attrib, lbs->n_attr, text, attachment, encoding); + attrib, lbs->n_attr, text, attachment, encoding, atoi(getparam("select")), &n_display); if (threaded) { @@ -6851,6 +7070,8 @@ MSG_LIST *msg_list; } } + rsprintf("\n", n_display); + rsprintf("
%s%s
\n"); } + /*---- select navigation ----*/ + + if (atoi(getparam("select")) == 1) + show_select_navigation(lbs); + /*---- page navigation ----*/ if (!printable && page_n && n_msg > n_page) show_page_navigation(n_msg, page_n, n_page); - rsprintf("
\n"); @@ -7371,13 +7596,14 @@ LOGBOOK *lbs_dest; void show_elog_page(LOGBOOK *lbs, char *dec_path) { -int size, i, j, len, n, status, fh, length, message_error, index; +int size, i, j, len, n, n_log, status, fh, length, message_error, index; int message_id, orig_message_id; -char str[256], command[80], ref[256], file_name[256], attrib[MAX_N_ATTR][NAME_LENGTH]; +char str[1000], command[80], ref[256], file_name[256], attrib[MAX_N_ATTR][NAME_LENGTH]; char date[80], text[TEXT_SIZE], menu_str[1000], other_str[1000], cmd[256], orig_tag[80], reply_tag[80], attachment[MAX_ATTACHMENTS][256], encoding[80], att[256], lattr[256]; char menu_item[MAX_N_LIST][NAME_LENGTH], format[80], admin_user[80], slist[MAX_N_ATTR+10][NAME_LENGTH], svalue[MAX_N_ATTR+10][NAME_LENGTH], *p; +char lb_list[MAX_N_LIST][NAME_LENGTH]; FILE *f; BOOL first; @@ -7509,6 +7735,8 @@ BOOL first; strcat(other_str, loc("Previous")); strcat(other_str, " "); strcat(other_str, loc("Next")); + strcat(other_str, " "); + strcat(other_str, loc("Select")); /* add non-localized submit for elog utility */ strcat(other_str, " "); @@ -7712,7 +7940,7 @@ BOOL first; if (equal_ustring(getparam("config"), getparam("unm"))) { /* log activity */ - logf("Logout of user \"%s\" from lbs->name \"%s\"",getparam("unm"),lbs->name); + logf("Logout of user \"%s\" from logbook \"%s\"", getparam("unm"), lbs->name); /* set cookies */ set_login_cookies(lbs, "", ""); @@ -7747,16 +7975,12 @@ BOOL first; if (equal_ustring(command, loc("Logout"))) { - rsprintf("HTTP/1.1 302 Found\r\n"); - rsprintf("Server: ELOG HTTP %s\r\n", VERSION); - if (use_keepalive) - { - rsprintf("Connection: Keep-Alive\r\n"); - rsprintf("Keep-Alive: timeout=60, max=10\r\n"); - } - /* log activity */ - logf("Logout of user \"%s\" from lbs->name \"%s\"",getparam("unm"),lbs->name); + logf("Logout of user \"%s\" from logbook \"%s\"", getparam("unm"), lbs->name); + + if (getcfg(lbs->name, "Logout to main", str) && + atoi(str) == 1) + setparam("redir", "../"); set_login_cookies(lbs, "", ""); return; @@ -7969,22 +8193,38 @@ BOOL first; { /* put one link for each logbook except current one */ if (equal_ustring(cmd, loc("Copy to"))) - rsprintf("\n"); - - for (j=0 ; ; j++) { - if (!enumgrp(j, str)) - break; + getcfg(lbs->name, "Copy to", str); + rsprintf("\n"); + } - if (equal_ustring(str, "global")) - continue; + if (str[0]) + { + n_log = strbreak(str, lb_list, MAX_N_LIST); - if (equal_ustring(str, lbs->name)) - continue; + for (j=0 ; j%s\n", lb_list[j], lb_list[j]); + } + else + { + for (j=0 ; ; j++) + { + if (!enumgrp(j, str)) + break; - rsprintf("