From e57fa4c9ddf69b6bfd71e1f9805dca322bc8f771 Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Fri, 2 Aug 2002 11:00:10 +0000 Subject: [PATCH] Started working on user configuration page SVN revision: 194 --- elogd.c | 276 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 242 insertions(+), 34 deletions(-) diff --git a/elogd.c b/elogd.c index 620f3948..788718da 100755 --- a/elogd.c +++ b/elogd.c @@ -6,6 +6,9 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 2.54 2002/08/02 11:00:10 midas + Started working on user configuration page + Revision 2.53 2002/07/31 11:48:08 midas Added page wise display @@ -3522,7 +3525,8 @@ struct tm *ts; void show_change_pwd_page(LOGBOOK *lbs) { -char str[256], file_name[256], line[256], *p, *pl, old_pwd[32], new_pwd[32]; +char str[256], file_name[256], line[256], *p, *pl, old_pwd[32], + new_pwd[32], new_pwd2[32]; char *buf; FILE *f; int i, wrong_pwd, size; @@ -3530,9 +3534,9 @@ double exp; time_t now; struct tm *gmt; - do_crypt(getparam("oldpwd"), old_pwd); do_crypt(getparam("newpwd"), new_pwd); + do_crypt(getparam("newpwd2"), new_pwd2); getcfg(lbs->name, "Password file", str); @@ -3597,7 +3601,10 @@ struct tm *gmt; *strchr(str, ':') = 0; if (strcmp(old_pwd, str) != 0) - wrong_pwd = TRUE; + wrong_pwd = 1; + + if (strcmp(new_pwd, new_pwd2) != 0) + wrong_pwd = 2; } /* replace password */ @@ -3672,9 +3679,12 @@ struct tm *gmt; gt("Border width"), gt("Frame color")); rsprintf("\n", gt("Frame color")); - if (wrong_pwd) + if (wrong_pwd == 1) rsprintf("\n", loc("Wrong password")); + if (wrong_pwd == 2) + rsprintf("\n", loc("New passwords do not match, please retype")); + rsprintf("\n", @@ -3684,6 +3694,8 @@ struct tm *gmt; gt("Cell BGColor"), loc("Old Password")); rsprintf("\n", gt("Cell BGColor"), loc("New Password")); + rsprintf("\n", + gt("Cell BGColor"), loc("Retype new password")); rsprintf("", gt("Cell BGColor"), loc("Submit")); @@ -4411,6 +4423,13 @@ char str[256], mode[256]; } } + rsprintf("", gt("Categories bgcolor1"), loc("Start date")); rsprintf("\n\n"); + + /*---- entry form ----*/ + + /* overall table for message giving blue frame */ + rsprintf("\n"); + + rsprintf("
%s!
%s!
\n", gt("Title bgcolor")); rsprintf("%s \"%s\"
%s:     
%s:     
", gt("Categories bgcolor2")); + rsprintf(loc("Display")); + if (!getcfg(lbs->name, "Entries per page", str)) + strcpy(str, "20"); + rsprintf(" ", str); + rsprintf(loc("entries per page")); + rsprintf("
%s:
\n", + gt("Menu1 cellpadding"), gt("Frame color")); + + rsprintf("
\n", gt("Menu1 Align"), gt("Menu1 BGColor")); + + rsprintf("\n", loc("Save")); + rsprintf("\n", loc("Cancel")); + rsprintf("\n", getparam("unm")); + rsprintf("
\n", + gt("Categories border"), gt("Categories cellpadding"), gt("Frame color")); + + rsprintf("\n", gt("Categories bgcolor1"), loc("Login name")); + rsprintf("\n", + gt("Categories bgcolor2"), getparam("unm")); + + rsprintf("\n", gt("Categories bgcolor1"), loc("Full name")); + rsprintf("\n", + gt("Categories bgcolor2"), getparam("full_name")); + + rsprintf("\n", gt("Categories bgcolor1")); + rsprintf("\n", + gt("Categories bgcolor2"), getparam("user_email")); + + rsprintf("\n", loc("Change password")); + + rsprintf("
%s:
%s:
Email:
", gt("Categories bgcolor2")); + rsprintf("
\n\n"); + rsprintf("\r\n"); +} + +/*------------------------------------------------------------------*/ + void show_elog_delete(LOGBOOK *lbs, int message_id) { int status; @@ -5272,6 +5425,8 @@ int msg_compare_reverse(const void *m1, const void *m2) return strcmp(((MSG_LIST *)m2)->string, ((MSG_LIST *)m1)->string); } +/*------------------------------------------------------------------*/ + void show_page_navigation(int n_msg, int page_n, int n_page) { int i; @@ -5289,27 +5444,52 @@ char ref[256]; if (page_n > 1) { sprintf(ref, "page%d", page_n - 1); - if (strchr(getparam("cmdline"), '?')) + if (strstr(getparam("cmdline"), "cmd=Search&")) + { + strcat(ref, "?"); + strcat(ref, strstr(getparam("cmdline"), "cmd=Search&")+11); + } + else if (strchr(getparam("cmdline"), '?')) strcat(ref, strchr(getparam("cmdline"), '?')); rsprintf("Previous  ", ref); } - for (i=0 ; i%d  ", ref, i+1); + } else - rsprintf("%d, ", ref, i+1); + { + if (page_n == i+1) + rsprintf("%d, ", i+1); + else + rsprintf("%d, ", ref, i+1); + } } if (page_n != -1 && page_n * n_page < n_msg) { sprintf(ref, "page%d", page_n + 1); - if (strchr(getparam("cmdline"), '?')) + if (strstr(getparam("cmdline"), "cmd=Search&")) + { + strcat(ref, "?"); + strcat(ref, strstr(getparam("cmdline"), "cmd=Search&")+11); + } + else if (strchr(getparam("cmdline"), '?')) strcat(ref, strchr(getparam("cmdline"), '?')); rsprintf("Next  ", ref); } @@ -5317,7 +5497,12 @@ char ref[256]; if (page_n != -1 && n_page < n_msg) { sprintf(ref, "page"); - if (strchr(getparam("cmdline"), '?')) + if (strstr(getparam("cmdline"), "cmd=Search&")) + { + strcat(ref, "?"); + strcat(ref, strstr(getparam("cmdline"), "cmd=Search&")+11); + } + else if (strchr(getparam("cmdline"), '?')) strcat(ref, strchr(getparam("cmdline"), '?')); rsprintf("All\n", ref); } @@ -5325,6 +5510,8 @@ char ref[256]; 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; @@ -5684,6 +5871,10 @@ MSG_LIST *msg_list; memcpy(&msg_list[j++], &msg_list[i], sizeof(MSG_LIST)); n_msg = j; + /*---- sort messasges ----*/ + + qsort(msg_list, n_msg, sizeof(MSG_LIST), reverse ? msg_compare_reverse : msg_compare); + /*---- number of messages per page ----*/ n_page = 1000000; @@ -5691,24 +5882,30 @@ MSG_LIST *msg_list; i_stop = n_msg-1; if (page_n) { - if (getcfg(lbs->name, "Messages per page", str)) + if (getcfg(lbs->name, "Entries per page", str)) n_page = atoi(str); else n_page = 20; + if (isparam("npp")) + n_page = atoi(getparam("npp")); if (page_n != -1) { i_start = (page_n - 1) * n_page; i_stop = i_start + n_page - 1; + + if (i_start >= n_msg) + { + show_error("Page doesn't exist"); + free(msg_list); + return; + } + if (i_stop >= n_msg) i_stop = n_msg-1; } } - /*---- sort messasges ----*/ - - qsort(&msg_list[i_start], i_stop-i_start+1, sizeof(MSG_LIST), reverse ? msg_compare_reverse : msg_compare); - /*---- header ----*/ show_standard_header(loc("ELOG search result"), NULL); @@ -5908,7 +6105,7 @@ MSG_LIST *msg_list; /*---- page navigation ----*/ - if (!printable && page_n) + if (!printable && page_n && n_msg > n_page) show_page_navigation(n_msg, page_n, n_page); /*---- table titles ----*/ @@ -6106,7 +6303,7 @@ MSG_LIST *msg_list; /*---- page navigation ----*/ - if (!printable && page_n) + if (!printable && page_n && n_msg > n_page) show_page_navigation(n_msg, page_n, n_page); @@ -6780,7 +6977,7 @@ BOOL first; return; } - show_elog_submit_find(lbs, 0, 0, 0); + show_elog_submit_find(lbs, 0, 0, 1); return; } @@ -6808,6 +7005,12 @@ BOOL first; return; } + if (equal_ustring(command, loc("Admin"))) + { + show_admin_page(lbs); + return; + } + if (equal_ustring(command, loc("Config"))) { show_config_page(lbs); @@ -6823,8 +7026,14 @@ BOOL first; if (equal_ustring(command, loc("Save"))) { - if (!save_config()) + if (isparam("config")) + { + if (!save_user_config(lbs, getparam("unm"))) + return; + } + else if (!save_admin_config()) return; + sprintf(str, "../%s/", lbs->name_enc); redirect(str); return; @@ -7754,7 +7963,7 @@ char str[256], upwd[256], full_name[256], email[256]; void show_selection_page() { int i; -char str[10000], logbook[256]; +char str[10000]; show_http_header(); @@ -7777,7 +7986,7 @@ char str[10000], logbook[256]; rsprintf("

"); rsprintf("
\n"); - rsprintf("", str, logbook); + rsprintf("", lb_list[i].name_enc, lb_list[i].name); str[0] = 0; - getcfg(logbook, "Comment", str); - rsprintf("\n", str); + getcfg(lb_list[i].name, "Comment", str); + rsprintf("\n", str); + + rsprintf("\n"); } rsprintf("
\n"); + rsprintf("
\n"); if (getcfg("global", "Welcome title", str)) { @@ -7792,19 +8001,18 @@ char str[10000], logbook[256]; for (i=0 ; ; i++) { - if (!enumgrp(i, logbook)) + if (!lb_list[i].name[0]) break; - if (equal_ustring(logbook, "global")) - continue; - - strcpy(str, logbook); - url_encode(str); - rsprintf("
%s
%s%s 
%s "); + rsprintf(loc("%d entries"), *lb_list[i].n_el_index); + rsprintf("
\n");