From 6468c76c164f1f91e8d4441b53ac0b6151956373 Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Fri, 24 Oct 2003 20:14:45 +0000 Subject: [PATCH] - user cannot change login name if already existing - user cannot search in logbooks of which he has no access - added date of last entry in logbook selection pageg SVN revision: 616 --- src/elogd.c | 123 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 83 insertions(+), 40 deletions(-) diff --git a/src/elogd.c b/src/elogd.c index 228a5304..18a90ba6 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -6,6 +6,11 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 1.149 2003/10/24 20:14:45 midas + - user cannot change login name if already existing + - user cannot search in logbooks of which he has no access + - added date of last entry in logbook selection pageg + Revision 1.148 2003/10/01 06:52:01 midas Started to implement synchronize @@ -36,7 +41,7 @@ \********************************************************************/ /* Version of ELOG */ -#define VERSION "2.3.9" +#define VERSION "2.3.10beta" #include #include @@ -318,6 +323,7 @@ int execute_shell(LOGBOOK *lbs, int message_id, char attrib[MAX_N_ATTR][NAME_LEN BOOL isparam(char *param); char *getparam(char *param); void logf(LOGBOOK *lbs, const char *format, ...); +BOOL check_login_user(LOGBOOK *lbs, char *user); /*---- Funcions from the MIDAS library -----------------------------*/ @@ -6877,23 +6883,23 @@ void show_new_user_page(LOGBOOK *lbs) /*---- entry form ----*/ rsprintf("%s:\n", loc("Login name")); - rsprintf(" (%s)\n", + rsprintf("(%s)\n", loc("name may not contain blanks")); rsprintf("%s:\n", loc("Full name")); - rsprintf("\n"); + rsprintf("\n"); rsprintf("Email:\n"); - rsprintf("\n"); + rsprintf("\n"); - rsprintf("%s: \n", loc("Enable email notifications")); + rsprintf("%s: \n", loc("Enable email notifications")); rsprintf("\n"); rsprintf("%s:\n", loc("Password")); - rsprintf("\n"); + rsprintf("\n"); rsprintf("%s:\n", loc("Retype password")); - rsprintf("\n"); + rsprintf("\n"); rsprintf("\n"); @@ -9100,6 +9106,10 @@ LOGBOOK *lbs_cur; { if (!lb_list[n_logbook].name[0]) break; + + if (isparam("unm") && !check_login_user(&lb_list[n_logbook], getparam("unm"))) + continue; + n_msg += *lb_list[n_logbook].n_el_index; } } @@ -9117,6 +9127,9 @@ LOGBOOK *lbs_cur; if (search_all) lbs_cur = &lb_list[i]; + if (isparam("unm") && !check_login_user(lbs_cur, getparam("unm"))) + continue; + for (j=0 ; j<*lbs_cur->n_el_index ; j++) { msg_list[n].lbs = lbs_cur; @@ -10167,7 +10180,7 @@ char str[1000], str2[1000], file_name[256], error[1000], date[80], mail_list[MAX_N_LIST][NAME_LENGTH], list[10000], attrib[MAX_N_ATTR][NAME_LENGTH], subst_str[MAX_PATH_LENGTH], in_reply_to[80], reply_to[256], user[256], user_email[256], email_notify[256]; -char mail_param[1000], *mail_to, user_list[MAX_N_LIST][NAME_LENGTH]; +char mail_param[1000], *mail_to; char att_file[MAX_ATTACHMENTS][256]; char slist[MAX_N_ATTR+10][NAME_LENGTH], svalue[MAX_N_ATTR+10][NAME_LENGTH]; int i, j, n, missing, first, index, mindex, suppress, message_id, resubmit_orig, mail_to_size; @@ -10423,17 +10436,8 @@ int i, j, n, missing, first, index, mindex, suppress, message_id, resubmit_or if (email_notify[0]) { /* check if user has access to this logbook */ - if (getcfg(lbs->name, "Login user", str)) - { - n = strbreak(str, user_list, MAX_N_LIST); - for (i=0 ; i= mail_to_size) { @@ -11711,11 +11715,30 @@ int i; /*------------------------------------------------------------------*/ +BOOL check_login_user(LOGBOOK *lbs, char *user) +{ +int i, n; +char str[1000]; +char list[MAX_N_LIST][NAME_LENGTH]; + + if (getcfg(lbs->name, "Login user", str) && user[0]) + { + n = strbreak(str, list, MAX_N_LIST); + for (i=0 ; i"); rsprintf("%s", loc("Goto logbook selection page")); - rsprintf("<\n"); + rsprintf("\n"); rsprintf("\n"); return FALSE; } - if (getcfg(lbs->name, "Login user", str) && user[0]) + if (!check_login_user(lbs, user)) { - n = strbreak(str, list, MAX_N_LIST); - for (i=0 ; i\n"); + rsprintf("\n"); + rsprintf("%s\n", loc("Logbook")); + rsprintf("%s\n", loc("Entries")); + rsprintf("%s\n", loc("Last submission")); + rsprintf("\n"); + for (i=0 ; ; i++) { if (!lb_list[i].name[0]) @@ -11910,20 +11931,31 @@ char str[10000]; if (!getcfg(lb_list[i].name, "Hidden", str) || atoi(str) == 0) { - rsprintf("%s", lb_list[i].name_enc, lb_list[i].name); + rsprintf("%s", lb_list[i].name_enc, lb_list[i].name); if (getcfg(lb_list[i].name, "Read password", str) || (getcfg(lb_list[i].name, "Password file", str) && !getcfg(lb_list[i].name, "Guest menu commands", str))) rsprintf("  "); - rsprintf("\n"); + rsprintf("
\n"); str[0] = 0; getcfg(lb_list[i].name, "Comment", str); - rsprintf("%s \n", str); + rsprintf("%s\n", str); - rsprintf(""); - rsprintf(loc("%d entries"), *lb_list[i].n_el_index); + rsprintf(""); + rsprintf("%d", *lb_list[i].n_el_index); + rsprintf("\n"); + + rsprintf(""); + if (*lb_list[i].n_el_index == 0) + rsprintf("-"); + else + { + tms = localtime(&(lb_list[i].el_index[*lb_list[i].n_el_index-1].file_time)); + strftime(str, sizeof(str), "%a %b %d, %Y %H:%M", tms); + rsprintf(str); + } rsprintf("\n"); } } @@ -12714,6 +12746,17 @@ FILE *f; { if (isparam("config")) { + if (!equal_ustring(getparam("config"), getparam("new_user_name"))) + { + if (get_user_line(lbs->name, getparam("new_user_name"), NULL, NULL, NULL, NULL) == 1) + { + sprintf(str, "%s \"%s\" %s", loc("Login name"), getparam("new_user_name"), + loc("exists already")); + show_error(str); + return; + } + } + /* change existing user */ if (!save_user_config(lbs, getparam("config"), FALSE, FALSE)) return;